All commands must run inside the PHP container:
docker compose run --rm php composer install
docker compose run --rm php composer test
docker compose run --rm php composer phpstan
docker compose run --rm php composer cs-fix
docker compose run --rm php composer cs-checkRun a single test file:
docker compose run --rm php vendor/bin/phpunit tests/Rules/Psr/Psr20RuleTest.phpCI runs all three checks (test, phpstan, cs-check) on PHP 8.2, 8.3, 8.4 and 8.5.
PHPStan extension package. Each rule lives in src/Rules/<Namespace>/ and implements PHPStan\Rules\Rule<NodeType>.
Rules are registered as services in extension.neon with tag phpstan.rules.rule. This file is the extension entry point declared in composer.json under extra.phpstan.includes.
- Create
src/Rules/<Namespace>/<RuleName>.php— implementRule<T>whereTis the AST node type fromPhpParser\Node. - Register the class as a service in
extension.neon. - Create
tests/Rules/<Namespace>/<RuleName>Test.php— extendPHPStan\Testing\RuleTestCase<YourRule>. - Add a fixture file at
tests/Rules/<Namespace>/fixtures/<name>.phpwith PHP code that triggers (and doesn't trigger) the rule. - Call
$this->analyse([__DIR__ . '/fixtures/<name>.php'], [...expected errors with message + line...])in the test.
php-cs-fixer enforces PSR-12 + declare_strict_types, strict_param, no_unused_imports, ordered_imports (alpha). All source files must have declare(strict_types=1).