<?php
trait PersonPL{
public function sayHello($name){
echo 'Witaj, nazywam siÄ™ '.$name;
}
public function whereFrom($country){
echo 'Jestem z '.$country;
}
}
trait PersonENG{
public function sayHello($name){
echo 'Hi, my name is '.$name;
}
public function whereFrom($country){
echo 'I am form '.$country;
}
}
class TestA{
use PersonPL, PersonENG{
PersonPL::sayHello insteadof PersonENG;
PersonENG::sayHello insteadof PersonPL;
PersonPL::whereFrom insteadof PersonENG;
}
}
$objA = new TestA();
$objA->sayHello('Anna');
$objA->whereFrom('Polski');
Fatal error: Uncaught Error: Call to undefined method TestA::sayHello() in /in/KtBk0:35
Stack trace:
#0 {main}
thrown in /in/KtBk0 on line 35
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Fatal error: Call to undefined method TestA::sayHello() in /in/KtBk0 on line 35
Process exited with code 255.