From c9254eb60638eb837599ea0c01dbec96d9f55f65 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 23 Sep 2026 12:03:28 +0200 Subject: [PATCH] make complexity, configurable and static rule sets toggleable, drop duplicate naming-rules include --- README.md | 10 +++++++++ config/code-complexity-rules.neon | 18 +++++++++++++++- config/configurable-rules.neon | 14 ++++++++---- config/phpstan-extensions.neon | 6 ++++++ config/static-rules.neon | 36 ++++++++++++++++++++++++++++++- config/symplify-rules.neon | 1 - 6 files changed, 78 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index aa2b6e5a6..43c8a3b84 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,16 @@ parameters: naming: false ``` +The `code-complexity-rules.neon`, `configurable-rules.neon` and `static-rules.neon` sets are **enabled by default** once included, and can be toggled the same way: + +```yaml +parameters: + symplify: + complexity: false + configurable: false + static: false +``` +
### Symfony/Laravel container `->get()`/`->make()` return type extensions diff --git a/config/code-complexity-rules.neon b/config/code-complexity-rules.neon index 88472a28b..3a420bd92 100644 --- a/config/code-complexity-rules.neon +++ b/config/code-complexity-rules.neon @@ -1,4 +1,20 @@ -rules: +conditionalTags: + Symplify\PHPStanRules\Rules\NoDynamicNameRule: + phpstan.rules.rule: %symplify.complexity% + Symplify\PHPStanRules\Rules\Complexity\NoJustPropertyAssignRule: + phpstan.rules.rule: %symplify.complexity% + Symplify\PHPStanRules\Rules\Complexity\NoPropertyToPropertyAssignRule: + phpstan.rules.rule: %symplify.complexity% + Symplify\PHPStanRules\Rules\Complexity\NoArrayMapWithArrayCallableRule: + phpstan.rules.rule: %symplify.complexity% + Symplify\PHPStanRules\Rules\Complexity\NoConstructorOverrideRule: + phpstan.rules.rule: %symplify.complexity% + Symplify\PHPStanRules\Rules\Complexity\ForeachCeptionRule: + phpstan.rules.rule: %symplify.complexity% + Symplify\PHPStanRules\Rules\Explicit\NoMissingVariableDimFetchRule: + phpstan.rules.rule: %symplify.complexity% + +services: - Symplify\PHPStanRules\Rules\NoDynamicNameRule - Symplify\PHPStanRules\Rules\Complexity\NoJustPropertyAssignRule - Symplify\PHPStanRules\Rules\Complexity\NoPropertyToPropertyAssignRule diff --git a/config/configurable-rules.neon b/config/configurable-rules.neon index 58ef076ce..6114c3395 100644 --- a/config/configurable-rules.neon +++ b/config/configurable-rules.neon @@ -1,7 +1,16 @@ +conditionalTags: + Symplify\PHPStanRules\Rules\ForbiddenNodeRule: + phpstan.rules.rule: %symplify.configurable% + Symplify\PHPStanRules\Rules\PreferredClassRule: + phpstan.rules.rule: %symplify.configurable% + Symplify\PHPStanRules\Rules\ForbiddenFuncCallRule: + phpstan.rules.rule: %symplify.configurable% + Symplify\PHPStanRules\Rules\SeeAnnotationToTestRule: + phpstan.rules.rule: %symplify.configurable% + services: - class: Symplify\PHPStanRules\Rules\ForbiddenNodeRule - tags: [phpstan.rules.rule] arguments: forbiddenNodes: - PhpParser\Node\Stmt\Trait_ @@ -16,7 +25,6 @@ services: - class: Symplify\PHPStanRules\Rules\PreferredClassRule - tags: [phpstan.rules.rule] arguments: oldToPreferredClasses: # prevents typos @@ -25,7 +33,6 @@ services: - class: Symplify\PHPStanRules\Rules\ForbiddenFuncCallRule - tags: [phpstan.rules.rule] arguments: forbiddenFunctions: - 'd' @@ -43,7 +50,6 @@ services: - class: Symplify\PHPStanRules\Rules\SeeAnnotationToTestRule - tags: [phpstan.rules.rule] arguments: requiredSeeTypes: - PHPStan\Rules\Rule diff --git a/config/phpstan-extensions.neon b/config/phpstan-extensions.neon index 547cc98c3..c48090bd6 100644 --- a/config/phpstan-extensions.neon +++ b/config/phpstan-extensions.neon @@ -1,6 +1,9 @@ parameters: symplify: naming: true + complexity: true + configurable: true + static: true mocks: false ctor: false symfonyReturnType: false @@ -15,6 +18,9 @@ parameters: parametersSchema: symplify: structure([ naming: bool() + complexity: bool() + configurable: bool() + static: bool() mocks: bool() ctor: bool() symfonyReturnType: bool() diff --git a/config/static-rules.neon b/config/static-rules.neon index e83679061..15b9d8fa5 100644 --- a/config/static-rules.neon +++ b/config/static-rules.neon @@ -1,4 +1,38 @@ -rules: +conditionalTags: + Symplify\PHPStanRules\Rules\ForbiddenExtendOfNonAbstractClassRule: + phpstan.rules.rule: %symplify.static% + Symplify\PHPStanRules\Rules\NoGlobalConstRule: + phpstan.rules.rule: %symplify.static% + + # domain + Symplify\PHPStanRules\Rules\RequireAttributeNameRule: + phpstan.rules.rule: %symplify.static% + + Symplify\PHPStanRules\Rules\Enum\RequireUniqueEnumConstantRule: + phpstan.rules.rule: %symplify.static% + Symplify\PHPStanRules\Rules\PreventParentMethodVisibilityOverrideRule: + phpstan.rules.rule: %symplify.static% + + Symplify\PHPStanRules\Rules\ForbiddenMultipleClassLikeInOneFileRule: + phpstan.rules.rule: %symplify.static% + Symplify\PHPStanRules\Rules\NoReferenceRule: + phpstan.rules.rule: %symplify.static% + Symplify\PHPStanRules\Rules\ForbiddenStaticClassConstFetchRule: + phpstan.rules.rule: %symplify.static% + Symplify\PHPStanRules\Rules\Complexity\ForbiddenArrayMethodCallRule: + phpstan.rules.rule: %symplify.static% + + # docblock + Symplify\PHPStanRules\Rules\NoMissnamedDocTagRule: + phpstan.rules.rule: %symplify.static% + Symplify\PHPStanRules\Rules\RequireArrayShapeReturnRule: + phpstan.rules.rule: %symplify.static% + + # attributes + Symplify\PHPStanRules\Rules\NoDuplicateNonRepeatableAttributeRule: + phpstan.rules.rule: %symplify.static% + +services: - Symplify\PHPStanRules\Rules\ForbiddenExtendOfNonAbstractClassRule - Symplify\PHPStanRules\Rules\NoGlobalConstRule diff --git a/config/symplify-rules.neon b/config/symplify-rules.neon index c4a05d0ef..d01c6a9bd 100644 --- a/config/symplify-rules.neon +++ b/config/symplify-rules.neon @@ -1,5 +1,4 @@ includes: - code-complexity-rules.neon - configurable-rules.neon - - naming-rules.neon - static-rules.neon