lookyman / phpstan-symfony
Symfony extension for PHPStan
Installs: 144 526
Dependents: 4
Suggesters: 0
Security: 0
Stars: 41
Watchers: 5
Forks: 6
Open Issues: 0
Requires
- php: ^7.1
- phpstan/phpstan: ^0.9.2
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^0.9.2
- lookyman/coding-standard: 0.1.0
- phpstan/phpstan-phpunit: ^0.9.0
- phpstan/phpstan-strict-rules: ^0.9.0
- phpunit/phpunit: ^6.4 || ^7.0
- symfony/framework-bundle: ^4.0
This package is not auto-updated.
Last update: 2022-02-01 13:07:04 UTC
README
Use phpstan/phpstan-symfony instead.
Symfony extension for PHPStan
What does it do?
- Provides correct return type for
ContainerInterface::get()
method, - provides correct return type for
Controller::get()
method, - notifies you when you try to get an unregistered service from the container,
- notifies you when you try to get a private service from the container.
Installation
composer require --dev lookyman/phpstan-symfony
Configuration
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+
Limitations
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.
Need something?
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.