Post #2539112
2026-03-26 09:00 UTC
@@OndrejMirtes@phpc.social This is interesting! Especially the part of resolving to the declaring class. That works with traits and interfaces too?
Replies (1)
-
@OndrejMirtes@phpc.social 2026-03-26 09:04
@harald Interfaces too. Trait is not really a declaring class, the class using the trait is. But the information about the trait is also available: https://apiref.phpstan.org/2.1.x/PHPStan.Reflection.Php.PhpMethodReflection.html#_getDeclaringTrait PHPStan knows everything about your code. It needs it for 1st party rules, but you can use it too.