> On 18 Nov 2014, at 17:33, guilhermebla...@gmail.com wrote: > > Library developers sometimes plan for extensibility of their code, but not > all pieces are able to be extended and unexpected usage can lead to > unpredictable behavior. > Based on that, I consider it may be a good addition to PHP to add class > visibility support and enhance existing modifiers' support.
I was thinking the very same thing after __construct() came up, but wasn’t sure how it should work. :) > Now what I mean by class visibility, it requires a better discussion on how > it could behave, since any other language relies on nested classes to > expose this support. Nevertheless, PHP's lack of Open/Close principle > support could be addressed easily. This is my POV on how it could behave: > > - private classes: Can only be extended and instantiated inside of the same > namespace it sits. This is the similar to private-package support in Java. > - protected classes: I can't determine any similarity to any other language > in this one, but it could behave somehow like: can be extended and > instantiated anywhere within the root namespace. > - public classes: same as current PHP support > > What do you think about it? I think it’s a good idea, the problem is defining private and protected. I wonder if this is something autoloaders could handle? private classes might be visible only within the same file, while protected classes might be visible only to other files the autoloader can see. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php