Property Declarations

Property names should not be prefixed with an underscore to indicate visibility. Visibility should be used to declare properties rather than the var keyword. Only one property should be declared within a statement. The static declaration must come after the visibility declaration.

Valid: Correct property naming.

class Foo { private $<em>bar</em>; }

Invalid: An underscore prefix used to indicate visibility.

class Foo { private $<em>_bar</em>; }

Valid: Visibility of property declared.

class Foo { <em>private</em> $bar; }

Invalid: Var keyword used to declare property.

class Foo { <em>var</em> $bar; }

Valid: One property declared per statement.

class Foo { private $bar; private $baz; }

Invalid: Multiple properties declared in one statement.

class Foo { private <em>$bar, $baz</em>; }

Valid: If declared as static, the static declaration must come after the visibility declaration.

class Foo { public <em>static</em> $bar; private $baz; }

Invalid: Static declaration before the visibility declaration.

class Foo { <em>static<em> protected $bar; }