Cover image for post "protected $var", has won by far.

"protected $var", has won by far.

The PEAR community has decided on how to deal with protected attributes and methodes regarding the PEAR coding standards for PHP5. In the past private members of a class were prefixed by an underscore (_), the question now was, how to deal with protected members, since they're not private nor public.

The developers had to choose from the following versions:

A (+1 vote in PEPr)

class Foo { protected $somevar; protected function somefunc(); }

B (-1 vote in PEPr)

class Foo { protected $_somevar; protected function _somefunc(); }

The community decided very unique for the first variation, which is (IMHO) the more logical one, since protected members can become public once, when extending a class. The second variation would then cause to have public members which look like private members.

Currently I assume that in future private members of a class will stay being prefixed by underscores, for the reason of backwards compatibillity and readabillity. Even if private members are declared explicitly inside the code, the code can be understood much better, when they keep branded.

So long: A good decision for PEAR, but just a small sandcorn in the huge amount of pending decisions for PHP5 coding.