dave-liddament / phpstan-php-language-extensions
PHPStan rules to implement the language extensions provided by the php-language-extensions
Installs: 172 253
Dependents: 2
Suggesters: 0
Security: 0
Stars: 28
Watchers: 2
Forks: 3
Open Issues: 1
Type:phpstan-extension
Requires
- php: ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0
- dave-liddament/php-language-extensions: ^0.8.0 || ^0.9.0
- phpstan/phpstan: ^1.12 || ^2.0
Requires (Dev)
- dave-liddament/phpstan-rule-test-helper: ^0.4.0
- friendsofphp/php-cs-fixer: ^3.26.1
- nette/neon: ^3.4
- php-parallel-lint/php-parallel-lint: ^1.3.2
- phpunit/phpunit: ^9.6.12
README
This is an extension for PHPStan for adding analysis for PHP Language Extensions.
Language feature added:
Installation
To make the attributes available for your codebase use:
composer require dave-liddament/php-language-extensions
To use install PHPStan extension use:
composer require --dev dave-liddament/phpstan-php-language-extensions
If 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
Configuring
Some attributes, e.g. #[package]
, might make testing difficult. It is possible to disable the checks for test code in one of two ways:
Exclude checks on class names ending with Test:
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: className
Exclude checks based on test namespace
To 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'
Contributing
See Contributing.
Demo project
See PHP language extensions PHPStan demo project.