Last active
August 29, 2015 13:59
-
-
Save kuzuha/10949354 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 AbstractSpeak | |
{ | |
abstract protected function speak($string); | |
} | |
trait PrintSpeak | |
{ | |
protected function speak($string) | |
{ | |
print "$string\n"; | |
} | |
} | |
trait Hello | |
{ | |
use AbstractSpeak; | |
public function sayHello() | |
{ | |
$this->speak("hello"); | |
} | |
} | |
trait Hey | |
{ | |
use AbstractSpeak; | |
public function sayHey() | |
{ | |
$this->speak("hey"); | |
} | |
} | |
class Hoge | |
{ | |
use Hello; | |
use Hey; | |
use PrintSpeak; | |
} | |
$hoge = new Hoge(); | |
$hoge->sayHello(); | |
$hoge->sayHey(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment