2013/2/27 Jens Riisom Schultz <ibmu...@me.com> > Hi, > > I just want to get a feel for whether the following idea would be > instantly rejected (for example I get the feeling that adding keywords is a > big deal): > > Often, when writing frameworks, you need to make public or protected > functionality or classes which should only be called from inside the > framework. You CAN ensure this with a lot of ninja tricks and > debug_backtrace, but it is very cumbersome and often hides your methods and > properties from class signatures. >
Just my 2 cent, but whats about just trust other developers, that when they call a method/function marked with @internal they know, what they are doing? > > Therefore I would propose adding a C# style "internal" keyword. ( > http://msdn.microsoft.com/en-us/library/7c5ka91b(v=vs.80).aspx ) > > The idea is, simply, that functions, methods and classes marked as > "internal" would only be accessible from within the namespace in which they > are defined. > I don't think it makes sense for methods as public/protected/private is enough. For know I don't see reasonable use-cases for an additional visibility-modifier for "public as long as in the same namespace", or "namespace-protected" for methods. But maybe it's interesting to extend public/private/protected to classes and functions like protected function anInternalFunction() { /* Restricted to this and subnamespaces */ } private class { /* Restricted to this namespace */ } Worth the mention, that I rarely miss something like this, but at least I can imagine some use-cases. > > For example the following class, "namespace Framework; internal class > Something {}", would only be visible from within the "Framework" namespace. > > I have a hunch that this would be relatively easy to implement. > > If noone objects I would attempt to create a patch and an RFC. > > What do you think? > > > -Jens Riisom Schultz > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- github.com/KingCrunch