This is an extension for PHPStan for adding analysis for PHP Language Extensions.
Language feature added:
To make the attributes available for your codebase use:
composer require dave-liddament/php-language-extensionsTo use install PHPStan extension use:
composer require --dev dave-liddament/phpstan-php-language-extensionsIf you are using phpstan/extension-installer you're ready to go (but you might want to check out the configuration options)
Manual installation
If you don't want to use phpstan/extension-installer, include rules.neon in your project's PHPStan config:
includes:
- vendor/dave-liddament/phpstan-php-language-extensions/extension.neon
Some attributes, e.g. #[package], might make testing difficult. It is possible to disable the checks for test code in one of two ways:
To exclude any checks from classes that where the name ends with Test add the following to the parameters section of your phpstan.neon file:
parameters:
phpLanguageExtensions:
mode: classNameTo exclude any checks from classes that are in the test namespace (e.g. Acme\Test) add the following to the parameters section of your phpstan.neon file:
parameters:
phpLanguageExtensions:
mode: namespace
testNamespace: 'Acme\Test'See Contributing.
See PHP language extensions PHPStan demo project.