From efda7e00c0eca9b00a6d72ab6eab721421065eeb Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 6 Dec 2025 15:16:45 +0100 Subject: [PATCH 1/2] misc --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index e0a31069..198461ff 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "phpstan/phpstan-webmozart-assert": "^2.0", "phpunit/phpunit": "^11.5", "rector/rector-src": "dev-main", + "rector/type-perfect": "^2.1", "symplify/easy-coding-standard": "^12.3", "symplify/phpstan-extensions": "^12.0", "symplify/phpstan-rules": "^14.9", From dfb786003162a38f6c8b86fe33770bde42efcd8f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 6 Dec 2025 15:17:34 +0100 Subject: [PATCH 2/2] enable type perfectx --- phpstan.neon | 13 ++++++------- .../DowngradePipeOperatorRector.php | 11 ++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index be0a8de4..4d80f4cd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,7 +6,7 @@ parameters: level: 8 errorFormat: symplify - reportUnmatchedIgnoredErrors: false + # reportUnmatchedIgnoredErrors: false # see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases typeAliases: @@ -31,12 +31,11 @@ parameters: - '*/Source/*' # see https://github.com/rectorphp/type-perfect/ -# to be enabled later once rector upgraded to use phpstan v2 -# type_perfect: -# no_mixed: true -# null_over_false: true -# narrow_param: true -# narrow_return: true + type_perfect: + no_mixed: true + null_over_false: true + narrow_param: true + narrow_return: true ignoreErrors: # php enum value minus diff --git a/rules/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector.php b/rules/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector.php index 56f04303..2362490b 100644 --- a/rules/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector.php +++ b/rules/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector.php @@ -5,6 +5,7 @@ namespace Rector\DowngradePhp85\Rector\StmtsAwareInterface; use PhpParser\Node; +use PhpParser\Node\Expr; use PhpParser\Node\Expr\ArrowFunction; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\BinaryOp\Pipe; @@ -104,14 +105,14 @@ public function refactor(Node $node): ?Node return $hasChanged ? $node : null; } - private function findPipeNode(Node $node): ?Pipe + private function findPipeNode(Expr $expr): ?Pipe { - if ($node instanceof Pipe) { - return $node; + if ($expr instanceof Pipe) { + return $expr; } - if ($node instanceof Assign && $node->expr instanceof Pipe) { - return $node->expr; + if ($expr instanceof Assign && $expr->expr instanceof Pipe) { + return $expr->expr; } return null;