When a class is using a trait, but is overriding a method from the trait,
the extending class still expects the type of the trait and not the overridden function.
Code to reproduce:
<?php
trait T {
public function foo(string $s): string {
return $s;
}
}
class A {
use T;
public function foo(int $i): int {
return $i;
}
}
class B extends A {
public function foo(int $i): int {
return $i;
}
}
Declaration of B::foo(int $i): int must be compatible with A::foo(string $s): stringPHP(PHP2439)
When a class is using a trait, but is overriding a method from the trait, the extending class still expects the type of the trait and not the overridden function.
Code to reproduce:
Declaration of B::foo(int $i): int must be compatible with A::foo(string $s): stringPHP(PHP2439)