PHPStan config for AirLST projects.
You can install the package via Composer:
composer require --dev airlst/phpstan-config
Make sure to allow the phpstan/extension-installer
plugin to run in your composer.json
:
{
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
}
}
Create a phpstan.php
in the root of your project with the following contents:
<?php
declare(strict_types=1);
$factory = new Airlst\PhpstanConfig\Factory(['src']);
return $factory
->level(8)
->create();
The constructor of the Factory
class takes an array of paths to be scanned for PHP files and analyzed. You can pass any number of paths to it.
You can use following configuration options on the Factory
class by chaining them before create()
call:
level(int $level)
: Set the level of PHPStaninclude(string $file)
: Include additional PHPStan neon fileexclude(string $file)
: Exclude provided PHPStan neon filewithBleedingEdge()
: Use bleeding edge version of PHPStanuseCacheDir(string $cacheDir)
: Use cache directory for PHPStantypeCoverage(int $return, int $param, int $property, int $constant)
: Set type coverage percentage, default is 100% for alltypePerfect(bool $nullOverFalse, bool $noMixed, bool $narrowParam)
: Set type perfect configuration, by default all turned on. See rectorphp/type-perfect README for more details.addRule(string $file)
: Add additional rule to PHPStanignoreError(string $message, ?string $path, ?int $count, ?bool $reportUnmatched)
: Ignore provided error messagecheckMissingIterableValueType(bool $enable = true)
: Enables/DisablescheckMissingIterableValueType
rulecheckGenericClassInNonGenericObjectType(bool $enable = true)
: Enables/DisablescheckGenericClassInNonGenericObjectType
rulestrictRules()
: Enables/disables strict rules. For available method arguments you can checkphpstan/phpstan-strict-rules
documentation
Run PHPStan with the following command:
./vendor/bin/phpstan analyse -c phpstan.php
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.