Re: PEAR Coding Standards question

From: Date: Tue, 19 Aug 2008 21:51:33 +0000
Subject: Re: PEAR Coding Standards question
References: 1 2 3 4 5 6  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-50572@lists.php.net to get a copy of this message
On Aug 19, 2008, at 2:36 PM, Paul M Jones wrote:
Having the underscore prefix as a visual hint that the method/property is not accessible from outside the class makes the most sense to me in this case.
I'm guessing your version of PHP5 works much differently than mine. When I use a protected or private member/method it's a fatal error. When that functionality changes in PHP then I'm for bringing back the underscore. Underscores indicating protected/private are, basically, the vermiform appendix left over from PHP4 days. 1.) Protected variables can be made public via child classes, leaving us with a public variable that has a prefixed underscore. 2.) The underscore does *nothing* to indicate if it's protected or private. 3.) It smacks of Hungarian notation. Why not just prepend everything with public_, private_ and protected_? 4.) If I ever decide to loosen access to a variable or method I actually have to break BC to loosen those restrictions as it stands. I can't simply make "private $foo" "public $foo" because it *has* to be "private $_foo", but "public $_foo" is a CS error. Underscores should die with PHP4. --Joe

« previous php.pear.dev (#50572) next »