Aller au contenu

Private Member Naming (ARCH7009)

Ce contenu n’est pas encore disponible dans votre langue.

Key php.naming.private-member-naming · Severity info · Category naming

Some codebases mark private members with a leading underscore. When that convention is adopted, private members without the underscore create inconsistency and obscure visibility at a glance.

<?php
class Cache
{
private $store = [];
private function evict(): void
{
$this->store = [];
}
}
<?php
class Cache
{
private $_store = [];
private function _evict(): void
{
$this->_store = [];
}
}

Name private members with a leading underscore per the project convention.