Pre-escaped error messages in 'symplify' error format, container aware test case and other useful extensions for PHPStan

Installs: 4 015 054

Dependents: 77

Suggesters: 0

Security: 0

Stars: 28

Watchers: 3

Forks: 1

Open Issues: 0


11.4.3 2024-01-05 11:11 UTC

This package is auto-updated.

Last update: 2024-07-05 12:12:59 UTC


PHPStan Extensions

Downloads total


composer require symplify/phpstan-extensions --dev

Update config:

# phpstan.neon
    - 'vendor/symplify/phpstan-extensions/config/config.neon'


Symplify Error Formatter

Works best with anthraxx/intellij-awesome-console

  • Do you want to click the error and get right to the line in the file it's reported at?
  • Do you want to copy-paste regex escaped error to your ignoreErrors?
vendor/bin/phpstan analyse src --level max --error-format symplify

- "Call to an undefined method Symplify\\Command\\ReleaseCommand\:\:nonExistingCall\(\)"

Return Type Extensions


With Symfony container and type as an argument, you always know the same type is returned:

use Symfony\Component\DependencyInjection\Container;

/** @var Container $container */
// PHPStan: object ❌
// Reality: Type ✅

// same for in-controller/container-aware context


After Symfony Kernel boot, getContainer() always returns the container:

use Symfony\Component\HttpKernel\Kernel;

final class AppKernel extends Kernel
    // ...

$kernel = new AppKernel('prod', false);

// PHPStan: null|ContainerInterface ❌
// Reality: ContainerInterface ✅
// Reality: ContainerInterface ✅


Symfony Finder finds only existing files (obviously), so the getRealPath() always return string:

use Symfony\Component\Finder\Finder;

$finder = new Finder();

foreach ($finder as $fileInfo) {
    // PHPStan: false|string ❌
    // Reality: string ✅

Report Issues

In case you are experiencing a bug or want to request a new feature head over to the Symplify monorepo issue tracker


The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on symplify/symplify.