I see, but that's not how traits and method overriding works.
Using a trait is not the same as extending a parent class, so the #[Override] attribute does not apply.
This is described in PHP's RFC: https://wiki.php.net/rfc/marking_overriden_methods, section Semantics:
The attribute is ignored on traits, but:
- Methods from a used trait behave as if the method definition was copied and pasted into the target class. Specifically the #[\Override] attribute on a trait method requires the existence of a matching method in a parent class or implemented interface.
Additionally, in the sample above we should report barMethod() as an error as well.