PHP-Дайджест № 135 (9 – 23 июля 2018)

0-ykzcjy5-ahoqpvdgjwpnwue-4.jpeg
namespace Example {
    public class A 
    {
       private $property;
    }
 
    protected class B
    {
       public $property;
    }
 
    private class C
    {
       protected $property;
    }
}
 
namespace OtherVendor {
    public class Factory
    {
        public function A()
        {
            return new \Example\A();  // Allowed by public
        }
 
        public function B()
        {
            return new \Example\B();  // Not allowed because 
                                       // namespace is not shared
        }
 
        public function C()
        {
            return new \Example\C();  // Not allowed because
                                       // not from same namespace
        }
    }
}

© Habrahabr.ru