Hi internals, I finalized a new proposal for PHP. It consists into adding support for package-private classes in the language.
A package private class is basically a class that can only be instantiated in its declared namespace. This means that you cannot extend, implement or use a class, interface or trait outside of declared namespace. It can be referenced outside of the package, but instantiation can only be done there. Other languages such as Java and C# consider package-private class as a top-level class without any declared visibility. PHP cannot enforce this as it would be an incredible BC break, but we can reuse an already declared keyword "private" to fit this purpose. A class declared without any visibility modifier is considered "public" and works exactly as it currently does. The same applies to a class written with "public" keyword (ie. public class Foo {}). Most of checks are done at compile time and only instantiation is done at runtime (the only place I found out it could be done). Performance impact seems negligible as only one top condition is added during instantiation bytecode executor. At this stage I want to collect implementation feedback. Explanation is done above and the extensive amount of tests self explains what the entire purpose of this feature is. RFC will be created together with voting once I'm able to gather some considerations. Link to PR: https://github.com/php/php-src/pull/947 Cheers, -- Guilherme Blanco MSN: guilhermebla...@hotmail.com GTalk: guilhermeblanco Toronto - ON/Canada