Class Tree · Level 4 of 7

Two skills, one name

Two traits both bring a say() method into the same class.

<?phptrait Hello {    public function say(): string { return 'Hello'; }}trait World {    public function say(): string { return 'World'; }}class Greeting {    use Hello, World {        Hello::say insteadof World;        World::say as sayWorld;    }}$g = new Greeting();echo $g->say(), "\n";echo $g->sayWorld(), "\n";echo implode(',', class_uses($g)), "\n";

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…