Download the PHP package phpstan/phpstan-symfony without Composer
On this page you can find all versions of the php package phpstan/phpstan-symfony. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phpstan/phpstan-symfony
More information about phpstan/phpstan-symfony
Files in phpstan/phpstan-symfony
Package phpstan-symfony
Short Description Symfony Framework extensions and rules for PHPStan
License MIT
Informations about the package phpstan-symfony
PHPStan Symfony Framework extensions and rules
This extension provides following features:
- Provides correct return type for
ContainerInterface::get()
and::has()
methods. - Provides correct return type for
Controller::get()
and::has()
methods. - Provides correct return type for
AbstractController::get()
and::has()
methods. - Provides correct return type for
ContainerInterface::getParameter()
and::hasParameter()
methods. - Provides correct return type for
ParameterBagInterface::get()
and::has()
methods. - Provides correct return type for
Controller::getParameter()
method. - Provides correct return type for
AbstractController::getParameter()
method. - Provides correct return type for
Request::getContent()
method based on the$asResource
parameter. - Provides correct return type for
HeaderBag::get()
method based on the$first
parameter. - Provides correct return type for
Envelope::all()
method based on the$stampFqcn
parameter. - Provides correct return type for
InputBag::get()
method based on the$default
parameter. - Provides correct return type for
InputBag::all()
method based on the$key
parameter. - Provides correct return types for
TreeBuilder
andNodeDefinition
objects. - 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.
- Optionally correct return types for
InputInterface::getArgument()
,::getOption
,::hasArgument
, and::hasOption
.
Installation
To use this extension, require it in Composer:
If you also install phpstan/extension-installer then you're all set!
Manual installation
If you don't want to use `phpstan/extension-installer`, include extension.neon in your project's PHPStan config: To perform framework-specific checks, include also this file:Configuration
You have to provide a path to srcDevDebugProjectContainer.xml
or similar XML file describing your container.
Constant hassers
Sometimes, when you are dealing with optional dependencies, the ::has()
methods can cause problems. For example, the following construct would complain that the condition is always either on or off, depending on whether you have the dependency for service
installed:
In that case, you can disable the ::has()
method return type resolving like this:
Be aware that it may hide genuine errors in your application.
Analysis of Symfony Console Commands
You can opt in for more advanced analysis of Symfony Console Commands
by providing the console application from your own application. This will allow the correct argument and option types to be inferred when accessing $input->getArgument()
or $input->getOption()
.
Symfony 4:
Symfony 5:
You may then encounter an error with PhpParser:
Compile Error: Cannot Declare interface PhpParser\NodeVisitor, because the name is already in use
If this is the case, you should create a new environment for your application that will disable inlining. In config/packages/phpstan_env/parameters.yaml
:
Call the new env in your console-application.php
: