Created
March 21, 2014 18:12
-
-
Save jeffturcotte/9692230 to your computer and use it in GitHub Desktop.
Trait Usage
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 | |
class Word {} | |
class NotAWord { } | |
trait SayTrait { | |
function say(Word $word) { | |
echo 'word?'; | |
} | |
} | |
class Speaker { | |
use SayTrait; | |
function say(NotAWord $notAWord) { | |
echo 'whaaaa!'; | |
} | |
} | |
$speaker = new Speaker(); | |
$notAWord = new NotAWord(); | |
$speaker->say($notAWord); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment