lookyman/phpstan-symfony
PHPStan extension for Symfony projects. Improves static analysis with Symfony-specific type inference and container/framework awareness, helping catch bugs earlier and reduce false positives when analyzing services, controllers, and common Symfony patterns.
Use phpstan/phpstan-symfony instead.
ContainerInterface::get() method,Controller::get() method,composer require --dev lookyman/phpstan-symfony
Put this into your phpstan.neon config:
includes:
- vendor/lookyman/phpstan-symfony/extension.neon
parameters:
symfony:
container_xml_path: %rootDir%/../../../var/cache/dev/appDevDebugProjectContainer.xml # or srcDevDebugProjectContainer.xml for Symfony 4+
It can only recognize pure strings or ::class constants passed into get() method. This follows from the nature of static code analysis.
You have to provide a path to appDevDebugProjectContainer.xml or similar xml file describing your container.
I don't use Symfony that often. So it might be entirely possible that something doesn't work here or that it lacks some functionality. If that's the case, PLEASE DO NOT HESITATE to open an issue or send a pull request. I will have a look at it and together we'll get you what you need. Thanks.
How can I help you explore Laravel packages today?