Re: [CFV] how to mark protected items?
| From: | Hans Lellelid | Date: | Tue, 22 Jun 2004 19:38:22 +0000 |
| Subject: | Re: [CFV] how to mark protected items? | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-31105@lists.php.net to get a copy of this message | ||
Daniel Convissor wrote:
On Tue, Jun 22, 2004 at 03:18:34PM -0400, Hans Lellelid wrote:Yeah, but since (according to Tomas, anyway) this discussion concerns PHP5, that's a non-issue. I.e. you'd never have tried to use it in the first place if it was marked protected.... but if you didn't have the '_' you would just know that the var was protected or public and hence your subclass was welcome to use it.Sure, my class is welcome to use it. But the code written by someone using the package is not.
Anyone who builds classes that can be customized through extension, and Bertrand ;) I don't want to enter a debate over basic OO best practices, but certainly from my experience Bertrand's assertion is true.PHP5 code you will realize that all your vars are protected or privateSays who?
Right, but they don't need to think anymore thanks to the lovely E_FATAL mentioned before. 1 - If they are using the class externally then they have read the API docs & they won't even make the mistake of trying to access something internal. And if they do try then they will be told by the engine that it's protected. 2 - If they are extending classes they know that any non-prefixed var in parent class is fair game. (and also that the prefixed vars in their subclass are private vars they added) HansIf the answer is always supposed to be "think!" then why are we discussing putting anything on the beginning of var names?The question, as I mentioned above, is who's supposed to be thinking here? I'm more concerned with the end users than the PEAR programmers.