Error Identifier: phpstan.reflection
Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.
Code example #
This error does not correspond to a specific PHP code pattern. It is emitted when PHPStan is unable to find the reflection of a class, function, or constant referenced in the analysed code.
Why is it reported? #
PHPStan needs to resolve information about all symbols (classes, interfaces, traits, functions, constants) used in the analysed code. When a symbol cannot be found through reflection, this error is reported.
This typically happens when:
- A class, interface, or trait is not autoloadable
- A required dependency is not installed
- The autoloader configuration does not cover all necessary paths
This error is not ignorable because PHPStan cannot perform accurate analysis when it cannot resolve the types involved.
How to fix it #
Make sure all symbols are autoloadable. Learn more at Discovering Symbols.
Common solutions:
- Run
composer installorcomposer dump-autoloadto ensure the autoloader is up to date. - Add missing paths to the
scanFilesorscanDirectoriesconfiguration options inphpstan.neon. - Add stub files for symbols from extensions that are not always installed.
Non-ignorable error #
This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.