2017 © Pedro Peláez
 

library phpstan-symfony

Symfony extension for PHPStan

image

lookyman/phpstan-symfony

Symfony extension for PHPStan

  • Monday, June 25, 2018
  • by lookyman
  • Repository
  • 5 Watchers
  • 43 Stars
  • 51,593 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 9 Versions
  • 58 % Grown

The README.md

DEPRECATED

Use phpstan/phpstan-symfony instead., (*1)

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:, (*2)

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., (*3)

You have to provide a path to appDevDebugProjectContainer.xml or similar xml file describing your container., (*4)

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., (*5)

The Versions

15/01 2018
12/12 2017