From f503b821da2ea34541a3c2a5b67f425276d810fa Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 3 Feb 2026 23:14:53 +0100 Subject: [PATCH 1/2] bump PHPStan to 2.1.38 --- build/target-repository/composer.json | 2 +- composer.json | 2 +- .../config/configured_rule.php | 9 +++------ rules/Carbon/NodeFactory/CarbonCallFactory.php | 4 ++-- .../Catch_/CatchExceptionNameMatchingTypeRector.php | 2 +- .../ExpectedNameResolver/InflectorSingularResolver.php | 2 +- rules/Naming/RectorNamingInflector.php | 2 +- rules/Php55/RegexMatcher.php | 2 +- scripts/check-before-after-same-fixtures.php | 2 +- .../PhpDocParser/BetterPhpDocParser.php | 2 +- src/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php | 2 +- src/FileSystem/FilePathHelper.php | 1 + src/PhpParser/Parser/InlineCodeParser.php | 2 +- 13 files changed, 16 insertions(+), 18 deletions(-) diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json index 68b0b680172..f320d428e5d 100644 --- a/build/target-repository/composer.json +++ b/build/target-repository/composer.json @@ -9,7 +9,7 @@ ], "require": { "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.1.37" + "phpstan/phpstan": "^2.1.38" }, "autoload": { "files": [ diff --git a/composer.json b/composer.json index 5b9ca2ff2e6..0c70a4a9f9e 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "nikic/php-parser": "^5.7", "ondram/ci-detector": "^4.2", "phpstan/phpdoc-parser": "^2.3", - "phpstan/phpstan": "^2.1.37", + "phpstan/phpstan": "^2.1.38", "react/event-loop": "^1.6", "react/promise": "^3.3", "react/socket": "^1.17", diff --git a/rules-tests/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector/config/configured_rule.php b/rules-tests/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector/config/configured_rule.php index 080cca4b1c8..2d0ea1ab77c 100644 --- a/rules-tests/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector/config/configured_rule.php +++ b/rules-tests/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector/config/configured_rule.php @@ -6,9 +6,6 @@ use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeForArrayMapRector; use Rector\ValueObject\PhpVersionFeature; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig - ->rules([AddClosureParamTypeForArrayMapRector::class]); - - $rectorConfig->phpVersion(PhpVersionFeature::UNION_TYPES); -}; +return RectorConfig::configure() + ->withRules([AddClosureParamTypeForArrayMapRector::class]) + ->withPhpVersion(PhpVersionFeature::UNION_TYPES); diff --git a/rules/Carbon/NodeFactory/CarbonCallFactory.php b/rules/Carbon/NodeFactory/CarbonCallFactory.php index 3d0180a2ee2..f5c9c92f26c 100644 --- a/rules/Carbon/NodeFactory/CarbonCallFactory.php +++ b/rules/Carbon/NodeFactory/CarbonCallFactory.php @@ -37,8 +37,8 @@ public function createFromDateTimeString( $methodCall = $this->createModifyMethodCall( $carbonCall, new Int_((int) $match['count']), - $match['unit'], - $match['operator'] + (string) $match['unit'], + (string) $match['operator'] ); if ($methodCall instanceof MethodCall) { $carbonCall = $methodCall; diff --git a/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php b/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php index 7864ddde1ca..aefa965e17b 100644 --- a/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php +++ b/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php @@ -170,7 +170,7 @@ private function resolveNewVariableName(string $typeShortName): string lcfirst($typeShortName), self::STARTS_WITH_ABBREVIATION_REGEX, static function (array $matches): string { - $output = isset($matches[1]) ? strtolower((string) $matches[1]) : ''; + $output = isset($matches[1]) ? strtolower($matches[1]) : ''; $output .= $matches[2] ?? ''; return $output . ($matches[3] ?? ''); diff --git a/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php b/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php index 639e3ec1a6f..c5eef049b0c 100644 --- a/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php +++ b/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php @@ -93,7 +93,7 @@ private function singularizeCamelParts(string $currentName): string if (in_array($camelCase[self::CAMELCASE], ['is', 'has', 'cms', 'this'], true)) { $value = $camelCase[self::CAMELCASE]; } else { - $value = $this->inflector->singularize($camelCase[self::CAMELCASE]); + $value = $this->inflector->singularize((string) $camelCase[self::CAMELCASE]); } $resolvedName .= $value; diff --git a/rules/Naming/RectorNamingInflector.php b/rules/Naming/RectorNamingInflector.php index 8ea3d2b17db..7e651daab98 100644 --- a/rules/Naming/RectorNamingInflector.php +++ b/rules/Naming/RectorNamingInflector.php @@ -26,7 +26,7 @@ public function singularize(string $name): string return $this->inflector->singularize($name); } - $singularized = $this->inflector->singularize($matches['prefix']); + $singularized = $this->inflector->singularize((string) $matches['prefix']); $uninflectable = $matches['suffix']; return $singularized . $uninflectable; diff --git a/rules/Php55/RegexMatcher.php b/rules/Php55/RegexMatcher.php index b9bf582ca43..3a8b6d26125 100644 --- a/rules/Php55/RegexMatcher.php +++ b/rules/Php55/RegexMatcher.php @@ -96,7 +96,7 @@ private function matchConcat(Concat $concat): ?Concat return null; } - if (! \str_contains((string) $matches['modifiers'], 'e')) { + if (! \str_contains($matches['modifiers'], 'e')) { return null; } diff --git a/scripts/check-before-after-same-fixtures.php b/scripts/check-before-after-same-fixtures.php index 27f207e2781..30118cb4045 100644 --- a/scripts/check-before-after-same-fixtures.php +++ b/scripts/check-before-after-same-fixtures.php @@ -59,7 +59,7 @@ private function hasFileSameBeforeAndAfterPart(SplFileInfo $fixtureFile): bool return false; } - return trim((string) $parts[0]) === trim((string) $parts[1]); + return trim($parts[0]) === trim($parts[1]); } } diff --git a/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php b/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php index da65d242540..fe9b99f2084 100644 --- a/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php +++ b/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php @@ -133,7 +133,7 @@ public function parseTagValue(TokenIterator $tokenIterator, string $tag): PhpDoc $phpDocTagValueNode->value = Strings::replace( $phpDocTagValueNode->value, self::MULTI_NEW_LINES_REGEX, - static fn (array $match) => $match['new_line'] + static fn (array $match): string => (string) $match['new_line'] ); } diff --git a/src/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php b/src/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php index 3ad49312553..cdc528c66ce 100644 --- a/src/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php +++ b/src/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php @@ -181,7 +181,7 @@ private function printPhpDocNode(PhpDocNode $phpDocNode): string return Strings::replace( $output, self::NEW_LINE_WITH_SPACE_REGEX, - static fn (array $match) => $match['new_line'] + static fn (array $match): string => (string) $match['new_line'] ); } diff --git a/src/FileSystem/FilePathHelper.php b/src/FileSystem/FilePathHelper.php index 83d1d72e0d7..656784226ad 100644 --- a/src/FileSystem/FilePathHelper.php +++ b/src/FileSystem/FilePathHelper.php @@ -62,6 +62,7 @@ public function normalizePathAndSchema(string $originalPath): string $pathRoot = str_starts_with($path, '/') ? $directorySeparator : ''; $pathParts = explode('/', trim($path, '/')); + /** @var string $scheme */ $normalizedPathParts = $this->normalizePathParts($pathParts, $scheme); $pathStart = ($scheme !== self::SCHEME_UNDEFINED ? $scheme . '://' : ''); diff --git a/src/PhpParser/Parser/InlineCodeParser.php b/src/PhpParser/Parser/InlineCodeParser.php index 18bfe874ee3..6bc47e76d49 100644 --- a/src/PhpParser/Parser/InlineCodeParser.php +++ b/src/PhpParser/Parser/InlineCodeParser.php @@ -159,7 +159,7 @@ private function resolveConcatValue(Concat $concat): string return Strings::replace( $string, self::VARIABLE_IN_SINGLE_QUOTED_REGEX, - static fn (array $match) => $match['variable'] + static fn (array $match): string => (string) $match['variable'] ); } } From eb359a7a441d7f8750395933c7112c5752b4bae4 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 3 Feb 2026 23:24:30 +0100 Subject: [PATCH 2/2] bump process to 7.4 --- composer.json | 2 +- .../PHPStan/Scope/PHPStanNodeScopeResolver.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 0c70a4a9f9e..02d8b0f3e1c 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "symfony/console": "^6.4.24", "symfony/filesystem": "^7.0", "symfony/finder": "^6.4", - "symfony/process": "^6.4|7.0.*", + "symfony/process": "^6.4|^7.4", "symplify/easy-parallel": "^11.2.2", "symplify/rule-doc-generator-contracts": "^11.2", "webmozart/assert": "^2.1" diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index aa71da7ca19..e7427f62abb 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -509,9 +509,11 @@ private function processAssign(Assign|AssignOp|AssignRef $assign, MutatingScope private function processArray(List_|Array_ $array, MutatingScope $mutatingScope): void { foreach ($array->items as $arrayItem) { - if ($arrayItem instanceof ArrayItem) { - $this->processArrayItem($arrayItem, $mutatingScope); + if (! $arrayItem instanceof ArrayItem) { + continue; } + + $this->processArrayItem($arrayItem, $mutatingScope); } }