Zend certified PHP/Magento developer

[Idea] Access-controlled classes

Just a quick idea I had: what if PHP had support for access-controlled classes?

You could have something like this:

< ?php namespace Something; public class SomeClass {} 

This class could be accessed from everywhere; you could just do this from anywhere:

new SomethingSomeClass; 

Now, if you had a private class, it could only be accessed from within the same namespace:

< ?php namespace Something; private class SomeClass {} 

Inside of Something, you could use it. However, inside of SomethingSub, you couldn’t use it.

If the class happened to be protected, you would be able to access it from subnamespaces too:

< ?php namespace Something; protected class SomeClass {} 

This is just a quick thought I had

submitted by /u/ImMaaxYT
[link] [comments]