- class_alias: documentation ( source)
<?php
namespace NS {
class A {
function test() { echo 'test'; }
}
}
namespace NS2 {
class_alias( 'NS\A', 'B' );
}
namespace NS3 {
class MyClass extends \B {
function test() { echo 'test under MyClass'; }
}
}
namespace NS4 {
function foo (B $f) {
$f->test();
}
foo (new MyClass);
}