diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml index 8c447308..b87d60ca 100644 --- a/.github/workflows/rector.yaml +++ b/.github/workflows/rector.yaml @@ -23,7 +23,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.3 + php-version: 8.4 coverage: none - uses: "ramsey/composer-install@v2" diff --git a/composer.json b/composer.json index 6b5a62db..32bdc647 100644 --- a/composer.json +++ b/composer.json @@ -4,10 +4,10 @@ "license": "MIT", "description": "Rector downgrade PHP rules", "require": { - "php": ">=8.3" + "php": ">=8.4" }, "require-dev": { - "boundwize/structarmed": "^0.9", + "boundwize/structarmed": "^0.14", "phpstan/extension-installer": "^1.4", "phpstan/phpstan": "^2.1.33", "phpstan/phpstan-webmozart-assert": "^2.0", diff --git a/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php b/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php index b153bc67..37a8987a 100644 --- a/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php +++ b/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php @@ -211,13 +211,7 @@ private function removeParamTypeFromMethod(ClassMethod $classMethod, int $paramP private function hasParamAlreadyNonTyped(ClassMethod $classMethod): bool { - foreach ($classMethod->params as $param) { - if ($param->type !== null) { - return false; - } - } - - return true; + return array_all($classMethod->params, fn(Param $param): bool => !$param->type instanceof Node); } private function isSafeType(ClassReflection $classReflection, ClassMethod $classMethod): bool diff --git a/rules/DowngradePhp74/Rector/ClassMethod/DowngradeCovariantReturnTypeRector.php b/rules/DowngradePhp74/Rector/ClassMethod/DowngradeCovariantReturnTypeRector.php index c1184515..c3505300 100644 --- a/rules/DowngradePhp74/Rector/ClassMethod/DowngradeCovariantReturnTypeRector.php +++ b/rules/DowngradePhp74/Rector/ClassMethod/DowngradeCovariantReturnTypeRector.php @@ -261,12 +261,6 @@ private function isNullable(Type $parentReturnType, Type $returnType): bool return false; } - foreach ($parentReturnType->getTypes() as $type) { - if ($type->equals($returnType)) { - return true; - } - } - - return false; + return array_any($parentReturnType->getTypes(), fn(Type $type): bool => $type->equals($returnType)); } } diff --git a/rules/DowngradePhp82/Rector/Class_/DowngradeUnionIntersectionRector.php b/rules/DowngradePhp82/Rector/Class_/DowngradeUnionIntersectionRector.php index 9f7ee694..1acdb235 100644 --- a/rules/DowngradePhp82/Rector/Class_/DowngradeUnionIntersectionRector.php +++ b/rules/DowngradePhp82/Rector/Class_/DowngradeUnionIntersectionRector.php @@ -4,6 +4,8 @@ namespace Rector\DowngradePhp82\Rector\Class_; +use PhpParser\Node\Identifier; +use PhpParser\Node\Name; use PhpParser\Node; use PhpParser\Node\Expr\ArrowFunction; use PhpParser\Node\Expr\Closure; @@ -135,12 +137,6 @@ private function isUnionIntersection(?Node $node): bool return false; } - foreach ($node->types as $type) { - if ($type instanceof IntersectionType) { - return true; - } - } - - return false; + return array_any($node->types, fn(Identifier|Name|IntersectionType $type): bool => $type instanceof IntersectionType); } }