Priorytety metod przy pracy z traitami w OOP w PHP

Jeśli klasa i trait mają metodę o tej samej nazwie, to metoda klasy nadpisze metodę traita:

php<?php
  trait TestTrait
  {
    // Metoda o nazwie method:
    public function method()
    {
      return 'trait';
    }
  }
  
  class TestClass
  {
    use TestTrait;
    
    // Taka sama metoda o nazwie method:
    public function method()
    {
      return 'test';
    }
  }
  
  $test = new TestClass;
  echo $test->method(); // wyświetli 'test' - zadziałała metoda samej klasy
?>

Jeśli sama klasa nie ma takiej metody, ale występuje konflikt nazw metod traita i metod klasy nadrzędnej, to metody traita mają priorytet:

php<?php
  trait TestTrait
  {
    // Metoda o nazwie method:
    public function method()
    {
      return 'trait';
    }
  }
  
  // Klasa nadrzędna:
  class ParentClass
  {
    // Metoda o nazwie method:
    public function method()
    {
      return 'parent';
    }
  }
  
  // Klasa dziedziczy metodę method od nadrzędnej:
  class TestClass extends ParentClass
  {
    use TestTrait;
  }
  
  $test = new TestClass;
  echo $test->method(); // wyświetli 'trait', ponieważ trait ma priorytet
?>