function test() { (new B())->foo(); (new B())->bar(); (new B())->baz(); B::baz(); }
<?php trait A { protected static function foo() { echo "abc\n"; } private static function bar() { echo "def\n"; } } class B { use A { A::foo as public; A::bar as public baz; } } B::foo(); B::baz();
print "bar {$a}\n"; } class A { private function priv() { static $x = 0; $x += 4; print "A::priv {$x}\n"; } function baz() { static $a; $a += 4; print "A::baz {$a}\n"; $this->priv(); } } class B extends A { } $a = new A(); $b = new B(); foo(); bar(); $a->baz(); $b->baz(); foo(); bar(); $a->baz(); $b->baz();