Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Alpha
- {
- class Foo
- {
- public function test() {}
- }
- }
- namespace Beta
- {
- use Alpha as NamespaceAlias;
- use Alpha\Foo as ClassAlias;
- class TestClass
- {
- public function methodA()
- {
- return new \Alpha\Foo();
- }
- public function methodB()
- {
- return new ClassAlias;
- }
- public function methodC()
- {
- return new NamespaceAlias\Foo();
- }
- }
- $testClass = new TestClass();
- $testClass->methodA()->test(); // OK
- $testClass->methodB()->test(); // OK
- $testClass->methodC()->test(); // OK
- }
- namespace Gamma
- {
- class Child extends \Beta\TestClass {}
- $child = new Child();
- $child->methodA()->test(); // OK
- $child->methodB()->test(); // fails
- $child->methodC()->test(); // fails
- }
Add Comment
Please, Sign In to add comment