PHP - Interfaces and Traits
Given two traits
TraitA and TraitB both defining a method greet(), how can a class Welcome use both traits and specify that TraitB::greet() should be used instead of TraitA::greet()?trait TraitA {
public function greet() {
echo 'Hello from A';
}
}
trait TraitB {
public function greet() {
echo 'Hello from B';
}
}
class Welcome {
use TraitA, TraitB {
TraitB::greet insteadof TraitA;
}
}