Using PHPStan to Extract Data About Your Codebase https://phpstan.org/blog/using-phpstan-to-extract-data-about-your-codebase
Using PHPStan to Extract Data About Your Codebase

@Ondřej Mirtes This is interesting! Especially the part of resolving to the declaring class. That works with traits and interfaces too?

@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.

Class PHPStan\Reflection\Php\PhpMethodReflection | PHPStan API