From 256b6de4accbd954731b1bf829f7cbc2816f10d8 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 9 Oct 2026 22:43:13 +0200 Subject: [PATCH 1/5] bump deps --- composer.json | 5 ++--- phpstan.neon | 48 +----------------------------------------------- 2 files changed, 3 insertions(+), 50 deletions(-) diff --git a/composer.json b/composer.json index 3eaca32401e..879870963e8 100644 --- a/composer.json +++ b/composer.json @@ -48,12 +48,11 @@ "phpstan/phpstan-phpunit": "^2.0", "phpstan/phpstan-webmozart-assert": "^2.0", "phpunit/phpunit": "^13.3", - "rector/jack": "^1.1", - "rector/swiss-knife": "^2.6", + "rector/swiss-knife": "^2.7", "shipmonk/composer-dependency-analyser": "^1.8", "symfony/process": "^8.1", "symplify/easy-coding-standard": "^13.2.13", - "symplify/phpstan-rules": "^14.13", + "symplify/phpstan-rules": "^14.18", "tomasvotruba/class-leak": "^2.1", "tomasvotruba/fast-unit": "^0.1", "tomasvotruba/type-coverage": "^2.3.6", diff --git a/phpstan.neon b/phpstan.neon index 0081acb6394..83ae478a3d8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,7 +7,7 @@ rules: parameters: level: 8 - reportUnmatchedIgnoredErrors: false + # reportUnmatchedIgnoredErrors: false errorFormat: symplify # see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases @@ -331,36 +331,6 @@ parameters: paths: - src/Skipper/SkipCriteriaResolver/SkippedClassResolver.php - - - identifier: symplify.noConstructorOverride - path: src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php - - # dynamic printer - - - identifier: symplify.noDynamicName - message: '#Use explicit names over dynamic ones#' - paths: - - src/CustomRules/SimpleNodeDumper.php - - src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php - - # copied from /vendor, to keep as original as possible - - - identifier: symplify.noDynamicName - path: src/PhpParser/NodeTraverser/RectorNodeTraverser.php - - - - identifier: symplify.noReference - message: '#Use explicit return value over magic &reference#' - paths: - - src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php - - rules/Php70/EregToPcreTransformer.php - - src/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php - - src/NodeTypeResolver/PHPStan/Type/TypeFactory.php - - - - identifier: symplify.noReference - message: '#Use explicit return value over magic &reference#' - # fixture Rector rules - identifier: symplify.seeAnnotationToTest @@ -376,19 +346,3 @@ parameters: - identifier: varTag.nativeType path: src/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php - - - - - identifier: symplify.noNullableServiceInConstructor - paths: - - src/NodeTypeResolver/PHPStan/ObjectWithoutClassTypeWithParentTypes.php - - - identifier: symplify.commandHasAsCommandAttribute - paths: - - src/Console/Command/ValidateConfigCommand.php - - src/Console/Command/WorkerCommand.php - - src/Console/Command/ProcessCommand.php - - src/Console/Command/ListRulesCommand.php - - src/Console/Command/CustomRuleCommand.php - - src/Console/Command/ComposerBasedCommand.php - - src/Console/Command/SetupCICommand.php \ No newline at end of file From afa97843ce8e8bbd6a1522d0e5513bdffc2bb6bb Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 9 Oct 2026 22:46:49 +0200 Subject: [PATCH 2/5] enable --- phpstan.neon | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 83ae478a3d8..1f3a8f27f5c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,7 +7,7 @@ rules: parameters: level: 8 - # reportUnmatchedIgnoredErrors: false + reportUnmatchedIgnoredErrors: false errorFormat: symplify # see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases @@ -45,6 +45,13 @@ parameters: # see https://github.com/symplify/phpstan-rules symplify: pathStrings: true + naming: true + complexity: true + configurable: true + static: true + phpunit: true + mocks: true + ctor: true # see https://github.com/TomasVotruba/type-coverage type_coverage: From d592d7bb88e717be156e6ca923c98b160b61d16b Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 9 Oct 2026 23:39:13 +0200 Subject: [PATCH 3/5] Restore symplify ignores activated by phpstan-rules 14.18 --- phpstan.neon | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/phpstan.neon b/phpstan.neon index 1f3a8f27f5c..ed3abf13af6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -338,6 +338,26 @@ parameters: paths: - src/Skipper/SkipCriteriaResolver/SkippedClassResolver.php + - + identifier: symplify.noConstructorOverride + path: src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php + + # dynamic printer + - + identifier: symplify.noDynamicName + message: '#Use explicit names over dynamic ones#' + + # reference params in legacy/perf code, kept as original + - + identifier: symplify.noReference + message: '#Use explicit return value over magic &reference#' + + - + identifier: symplify.noNullableServiceInConstructor + path: src/NodeTypeResolver/PHPStan/ObjectWithoutClassTypeWithParentTypes.php + + - identifier: symplify.commandHasAsCommandAttribute + # fixture Rector rules - identifier: symplify.seeAnnotationToTest From a21f06c3a684b1a029c8ed962af0b7ec9bbaed50 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 9 Oct 2026 23:43:34 +0200 Subject: [PATCH 4/5] not ref --- phpstan.neon | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index ed3abf13af6..5b12cd2fcb6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,7 +7,7 @@ rules: parameters: level: 8 - reportUnmatchedIgnoredErrors: false + # reportUnmatchedIgnoredErrors: false errorFormat: symplify # see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases @@ -351,6 +351,15 @@ parameters: - identifier: symplify.noReference message: '#Use explicit return value over magic &reference#' + paths: + - src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php + - rules/Php70/EregToPcreTransformer.php + - src/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php + - src/NodeTypeResolver/PHPStan/Type/TypeFactory.php + - rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php + - rules/CodeQuality/Rector/Class_/InnerFunctionToPrivateMethodRector.php + - rules/CodeQuality/NodeAnalyzer/VariableDimFetchAssignResolver.php + - rules/CodeQuality/Rector/Expression/InlineIfToExplicitIfRector.php - identifier: symplify.noNullableServiceInConstructor From 48880cd31b9adc34edbe4314bccc234036c6fa2b Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 9 Oct 2026 23:58:18 +0200 Subject: [PATCH 5/5] Refactor by-ref params to return values, drop their noReference ignores --- phpstan.neon | 2 -- .../Expression/InlineIfToExplicitIfRector.php | 13 +++++-------- .../Assign/RemoveUnusedVariableAssignRector.php | 11 +++++++---- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 5b12cd2fcb6..db3e0962757 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -356,10 +356,8 @@ parameters: - rules/Php70/EregToPcreTransformer.php - src/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php - src/NodeTypeResolver/PHPStan/Type/TypeFactory.php - - rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php - rules/CodeQuality/Rector/Class_/InnerFunctionToPrivateMethodRector.php - rules/CodeQuality/NodeAnalyzer/VariableDimFetchAssignResolver.php - - rules/CodeQuality/Rector/Expression/InlineIfToExplicitIfRector.php - identifier: symplify.noNullableServiceInConstructor diff --git a/rules/CodeQuality/Rector/Expression/InlineIfToExplicitIfRector.php b/rules/CodeQuality/Rector/Expression/InlineIfToExplicitIfRector.php index eabaf9b59b3..0915c20d9c0 100644 --- a/rules/CodeQuality/Rector/Expression/InlineIfToExplicitIfRector.php +++ b/rules/CodeQuality/Rector/Expression/InlineIfToExplicitIfRector.php @@ -121,8 +121,7 @@ private function processExplicitIf(Expression $expression): ?Node private function isSameLocalMethodCallChain(BooleanAnd|BooleanOr $booleanExpr): bool { - $leaves = []; - $this->collectOperands($booleanExpr, $leaves); + $leaves = $this->collectOperands($booleanExpr); $firstMethodCall = null; foreach ($leaves as $leaf) { @@ -148,16 +147,14 @@ private function isSameLocalMethodCallChain(BooleanAnd|BooleanOr $booleanExpr): } /** - * @param Expr[] $leaves + * @return Expr[] */ - private function collectOperands(Expr $expr, array &$leaves): void + private function collectOperands(Expr $expr): array { if ($expr instanceof BooleanAnd || $expr instanceof BooleanOr) { - $this->collectOperands($expr->left, $leaves); - $this->collectOperands($expr->right, $leaves); - return; + return array_merge($this->collectOperands($expr->left), $this->collectOperands($expr->right)); } - $leaves[] = $expr; + return [$expr]; } } diff --git a/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php b/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php index c6f056461da..d9bb3477202 100644 --- a/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php +++ b/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php @@ -211,14 +211,15 @@ private function shouldSkip(array $stmts): bool } /** - * @param string[] $refVariableNames + * @return string[] */ - private function collectAssignRefVariableNames(Stmt $stmt, array &$refVariableNames): void + private function collectAssignRefVariableNames(Stmt $stmt): array { if (! NodeGroup::isStmtAwareNode($stmt)) { - return; + return []; } + $refVariableNames = []; $this->traverseNodesWithCallable($stmt, function (Node $subNode) use (&$refVariableNames): Node { if ($subNode instanceof AssignRef && $subNode->var instanceof Variable) { $refVariableNames[] = (string) $this->getName($subNode->var); @@ -226,6 +227,8 @@ private function collectAssignRefVariableNames(Stmt $stmt, array &$refVariableNa return $subNode; }); + + return $refVariableNames; } /** @@ -239,7 +242,7 @@ private function resolvedAssignedVariablesByStmtPosition(array $stmts): array foreach ($stmts as $key => $stmt) { if (! $stmt instanceof Expression) { - $this->collectAssignRefVariableNames($stmt, $refVariableNames); + $refVariableNames = array_merge($refVariableNames, $this->collectAssignRefVariableNames($stmt)); continue; }