trait Log {
protected function log($message) {
echo "$message<br>\n";
}
}
trait Informer {
// This method has the same name as the parent, which will cause a collision.
// Need to tell caller to use parent (see below)
protected function log() {
echo "I had a big ass ham sandwich for lunch and I'm still hungry.<br>\n";
}
}
trait Traffic {
protected function suspend() {
echo "All Systems have been SUSPENDED! Try again later.<br>\n";
}
}
class Table {
use Traffic, Log, Informer {
Log::log insteadof Informer;
}
public function save() {
$this->log('HTTP/2 protocol will be inactive');
$this->suspend();
}
}
// I HATE this syntax!
//(new Table())->save();
//echo "//##############################<br>\n";
$t = new Table;
$t->save();
echo "//##############################<br>\n";