Created
January 24, 2012 22:16
-
-
Save Majkl578/1673061 to your computer and use it in GitHub Desktop.
PHP 5.4 traits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait T { | |
public function xyz() | |
{ | |
echo __TRAIT__, PHP_EOL; | |
} | |
} | |
class A { | |
use T; | |
} | |
(new A)->xyz(); // T - OK | |
class B { | |
use T { | |
T::xyz as abc; | |
} | |
} | |
(new B)->xyz(); // T - should not work? | |
class C { | |
use T { | |
T::xyz as abc; | |
} | |
public function xyz() | |
{ | |
echo __CLASS__, PHP_EOL; | |
} | |
} | |
(new C)->xyz(); // C - magic? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment