symplify/phpstan-rules

Set of Symplify rules for PHPStan

Installs: 3 084 471

Dependents: 101

Suggesters: 2

Security: 0

Stars: 127

Watchers: 5

Forks: 23

Open Issues: 2

Type:phpstan-extension

12.4.8 2024-02-09 21:23 UTC

This package is auto-updated.

Last update: 2024-02-09 21:23:37 UTC


README

Downloads

Set of rules for PHPStan used by Symplify projects


Install

composer require symplify/phpstan-rules --dev

Note: Make sure you use phpstan/extension-installer to load necessary service configs.


1. Add Prepared Sets

Sets are bunch of rules grouped by a common area, e.g. improve naming. You can pick from 5 sets:

includes:
    - vendor/symplify/phpstan-rules/config/code-complexity-rules.neon
    - vendor/symplify/phpstan-rules/config/collector-rules.neon
    - vendor/symplify/phpstan-rules/config/naming-rules.neon
    - vendor/symplify/phpstan-rules/config/regex-rules.neon
    - vendor/symplify/phpstan-rules/config/static-rules.neon

Add sets one by one, fix what you find useful and ignore the rest.


Do you write custom Rector rules? Add rules for them too:

includes:
    - vendor/symplify/phpstan-rules/config/rector-rules.neon

2. Cherry-pick Configurable Rules

There is one set with pre-configured configurable rules. Include it and see what is errors are found:

# phpstan.neon
includes:
    - vendor/symplify/phpstan-rules/config/configurable-rules.neon

Would you like to tailor it to fit your taste? Pick one PHPStan rule and configure it manually ↓

services:
    -
        class: Symplify\PHPStanRules\Rules\ForbiddenNodeRule
        tags: [phpstan.rules.rule]
        arguments:
            forbiddenNodes:
                - PhpParser\Node\Expr\Empty_
                - PhpParser\Node\Stmt\Switch_

Happy coding!