Created
January 29, 2012 20:22
-
-
Save manuelpichler/1700470 to your computer and use it in GitHub Desktop.
Trait nightmare
This file contains hidden or 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 A { | |
function f( ) { | |
return __METHOD__; | |
} | |
} | |
class C { | |
use A { | |
f as x; | |
f as y; | |
} | |
} | |
$c = new C; | |
var_dump( $c->x(), $c->y() ); |
This file contains hidden or 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 A { | |
function f() { | |
return __METHOD__; | |
} | |
} | |
trait B { | |
function f() { | |
return __METHOD__; | |
} | |
} | |
class C { | |
use A { | |
A::f insteadof B; | |
} | |
use B { | |
B::f insteadof A; | |
} | |
} | |
$c = new C; | |
$c->f(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment