Created
September 18, 2010 11:48
-
-
Save sotarok/585598 to your computer and use it in GitHub Desktop.
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 A | |
{ | |
public function smallTalk() { | |
echo 'a'; | |
} | |
public function bigTalk() { | |
echo 'A'; | |
} | |
} | |
trait B | |
{ | |
public function smallTalk() { | |
echo 'b'; | |
} | |
public function bigTalk() { | |
echo 'B'; | |
} | |
} | |
trait C | |
{ | |
use A, B { | |
B::smallTalk insteadof A; | |
A::bigTalk insteadof B; | |
B::bigTalk as talk; | |
} | |
} | |
class Talker | |
{ | |
use A, B { | |
B::smallTalk insteadof A; | |
A::bigTalk insteadof B; | |
B::bigTalk as talk; | |
} | |
} | |
class Talker2 | |
{ | |
use C; | |
} | |
$t = new Talker(); | |
$t->smallTalk(); | |
$t2 = new Talker2(); | |
$t2->smallTalk(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment