phpstan/phpstan-symfony
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
phpstan/phpstan | 1.11.1 | - | MIT | prod |
PHPStan Symfony, or phpstan/phpstan-symfony, is a vital extension of PHPStan, popular for its Symfony Framework rules and extensions. It enhances functionality by providing accurate return types for various method calls commonly used in Symfony applications. This includes methods like ContainerInterface:get()
, ::has()
, AbstractController::get()
, ::has()
, among others. Additionally, it notifies users when they attempt to retrieve an unregistered service from the container or try to access a private service.
One can add phpstan/phpstan-symfony to their Symfony project using Composer, a PHP package manager, with the following command:
composer require --dev phpstan/phpstan-symfony
Once the extension is installed, it can be included in the project's PHPStan config file using:
includes:
- vendor/phpstan/phpstan-symfony/extension.neon
For implementing framework-specific checks, this file should also be included:
includes:
- vendor/phpstan/phpstan-symfony/rules.neon
Users must also provide a path to the srcDevDebugProjectContainer.xml
file or similar XML file describing the project's container. This can be done in the PHPStan config file:
parameters:
symfony:
containerXmlPath: var/cache/dev/srcDevDebugProjectContainer.xml
# or with Symfony 4.2+
containerXmlPath: var/cache/dev/srcApp_KernelDevDebugContainer.xml
# or with Symfony 5+
containerXmlPath: var/cache/dev/App_KernelDevDebugContainer.xml
# If you're using PHP config files for Symfony 5.3+, you also need this for auto-loading of `Symfony\Config`:
scanDirectories:
- var/cache/dev/Symfony/Config
For more intricate analysis of Symfony Console Commands, users can provide the console application from their application.
The phpstan/phpstan-symfony documentation is embedded within the README file of the package hosted on GitHub. By checking the GitHub repository at https://github.com/phpstan/phpstan-symfony, developers will find a comprehensive guide to using the package, including its installation, configuration, and example code snippets.