Skip to content

Latest commit

 

History

History
82 lines (55 loc) · 3.52 KB

README.md

File metadata and controls

82 lines (55 loc) · 3.52 KB

PHPStan PHP Language Extensions (currently in BETA)

PHP versions: 8.0 to 8.3 Latest Stable Version License Total Downloads

Continuous Integration PHPStan max level

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.