Re: [PEPr] Comment on RFC::ProtectedMembers

From: Date: Mon, 28 Jun 2004 15:22:10 +0000
Subject: Re: [PEPr] Comment on RFC::ProtectedMembers
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-31294@lists.php.net to get a copy of this message
Hundiak, Arthur wrote:
Klaus Guenther (http://pear.php.net/user/thesaur) has commented on the
proposal for RFC::ProtectedMembers.
Comment: The current standard states that any method or property prefixed with an
underscore is for internal use. The proper >understanding of such methods and properties is that they are protected, not private. The php4 "@access private
means that the marked methods/properties are private/protected. In other
words, that they are non-public. (If the
manual states it in any other terms, it is completely belied by usage.)
Would it be possible to have the "real" coding standards posted to the pear web site? The current version states: "Private class members (meaning class members that are intented(sic) to be used only from within the same class in which they are declared; PHP does not yet support truly-enforceable private namespaces) are preceded by a single underscore."
Hmm... interesting point... I had assumed that this wording was due to someone trying to clarify the coding standard. Apparently, it is not. It has been worded like this from the beginning. However, in usage, the "private" variables are often accessed in extending classes, if only when rewriting a function such as toHtml(). This is perhaps a reflection of "sloppy" programming, but it sure beats declaring everything private. Not only that, underscores were a convenient way of keeping the API simple by not showing people functions they weren't supposed to see anyway (e.g., internal stuff that might be very useful within a class or when propagating settings between objects, but had virtually no use for the ordinary user -- though they could be found by looking at the source). And I personally think that's what underscores should still be used for.
I am assuming that there is another version out there that reads: "Private/PROTECTED class members (meaning class members that are intended to be used only from within the same class in which they are declared OR WITHIN EXTENDED CLASSES; PHP does not yet support truly-enforceable private/PROTECTED namespaces) are preceded by a single underscore." Having two manuals is confusing to say the least especially when one does not appear to be available to the general public. I am also intrigued by the notion that "@access private" implies that the variable might be protected. I can't help but think that "@access protected" would be a better choice. The phpdoc.org site distingushes between private and protected. Maybe it has two manuals as well?
Come on, sarcasm won't take you very far. In fact, I do not think that the phpdoc differentiation between private and protected arose before php5 introduced those to php. Iirc, prior to that, there was only "private" and "public". Maybe Greg or Joshua can shed more light on this :-) Klaus

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