seferov / symfony-psalm-plugin
Psalm Plugin for Symfony
Installs: 9 848
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 1
Open Issues: 0
Type:psalm-plugin
Requires
- php: ^7.1
- ext-simplexml: *
- symfony/framework-bundle: ^3.0 || ^4.0 || ^5.0
- vimeo/psalm: ^3.7
Requires (Dev)
- codeception/base: ^2.5
- phpunit/phpunit: ~7.5
- weirdan/codeception-psalm-module: ^0.2.2
This package is auto-updated.
Last update: 2020-03-14 05:22:27 UTC
README
Installation
composer require --dev psalm/plugin-symfony
vendor/bin/psalm-plugin enable psalm/plugin-symfony
Features
- Detect
ContainerInterface::get()
result type. Works better if you configure compiled container XML file. - Fixes
PossiblyInvalidArgument
forSymfony\Component\HttpFoundation\Request::getContent
. The plugin calculates real return type by checking the given argument and marks return type as either string or resource. - Complains when
Container
is injected to a service. Use dependency-injection.
Configuration
If you followed installation instructions, psalm-plugin command would added plugin configuration to psalm.xml
<?xml version="1.0"?> <psalm totallyTyped="true"> <!-- project configuration --> <plugins> <pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin" /> </plugins> </psalm>
To be able to detect return types of services using ID (generally starts with @
in Symfony YAML config files. Ex: logger
service)
containerXml
must be provided. Example:
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"> <containerXml>var/cache/dev/App_KernelDevDebugContainer.xml</containerXml> </pluginClass>
This file path may change based on your Symfony version, file structure and environment settings. Default file for Symfony versions:
- Symfony 3: var/cache/dev/srcDevDebugProjectContainer.xml
- Symfony 4: var/cache/dev/srcApp_KernelDevDebugContainer.xml
- Symfony 5: var/cache/dev/App_KernelDevDebugContainer.xml