Using PHPStan to Extract Data About Your Codebase https://phpstan.org/blog/using-phpstan-to-extract-data-about-your-codebase
@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.