» Metadata | » Status |
---|---|
|
|
» Description | |
Premace:This RFC aims to resolve whether or not protected class members will be prefixed with an underscore, or prefixed with nothing. Once a decision has been reached, the result will be added to the PEAR coding standards. Private members will still be prefixed. These standards will only apply to PHP5 classes. In PHP4, if it's not public it's private and thus prefixed. Voting:A vote of +1 suggests class members should not be prefixed.<php> class Foo { protected $somevar; protected function somefunc(); } </php> A vote of -1 suggests class members should be prefixed with an underscore.<php> class Foo { protected $_somevar; protected function _somefunc(); } </php> A vote of 0 will not be counted. If the overall score at the end of the call-for-votes is positive, class members will not be prefixed. If negative, they will be prefixed. Information:What's changed?PHP5 Introduces PPP - Private, Public and Protected. What's protected and private?Protected members can be accessed in classes extending the class they are declared in, where as private members can only be accessed by the class they belong to. What did we use to do, and why?In PHP4, both private and protected members were prefixed with an underscore. This was to ensure the user of the class knew what methods were available to them, and not to mess with anything else. One of the key reasons for prefixed members is the visual expression of "Do not mess with this member, I may remove/rename it in the future". This is fine for private members, however will not follow for protected members when the class is extended by the user. Is it possible to accidently ignore the declarations?If a member is declared as protected (using the protected keyword), an E_FATAL error will be thrown if the member is used incorrectly. PHP5 will also provide errors if a user attempts to redeclare a In this regard 'protected' is like public in terms of the obligations of mega hobby |
|
» Dependencies | » Links |
|
|
» Timeline | » Changelog |
|
|