From 911e446bd59a53af7ae9bbd05013168c019e890d Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 8 Jan 2024 13:46:06 +0000 Subject: [PATCH] Updated Rector to commit 7e566722a08a546858fa67d73915c9dff9a0c018 https://github.com/rectorphp/rector-src/commit/7e566722a08a546858fa67d73915c9dff9a0c018 [Php80][CodeQuality] Handle crash on ChangeSwitchToMatchRector + TernaryFalseExpressionToIfRector on under if else (#5446) --- src/Application/VersionResolver.php | 4 ++-- src/NodeTypeResolver/NodeTypeResolver.php | 3 ++- .../PHPStan/Scope/PHPStanNodeScopeResolver.php | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index a9f934f01ef2..9958c25eb691 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'b71c3265d5f90745d52b081a1201e3d97617e14a'; + public const PACKAGE_VERSION = '7e566722a08a546858fa67d73915c9dff9a0c018'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-01-07 17:54:29'; + public const RELEASE_DATE = '2024-01-08 20:43:57'; /** * @var int */ diff --git a/src/NodeTypeResolver/NodeTypeResolver.php b/src/NodeTypeResolver/NodeTypeResolver.php index 9f9d79605aee..4b047e87e36a 100644 --- a/src/NodeTypeResolver/NodeTypeResolver.php +++ b/src/NodeTypeResolver/NodeTypeResolver.php @@ -3,6 +3,7 @@ declare (strict_types=1); namespace Rector\NodeTypeResolver; +use PhpParser\Node\Expr\NullsafeMethodCall; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\ArrayDimFetch; @@ -280,7 +281,7 @@ public function getFullyQualifiedClassName(TypeWithClassName $typeWithClassName) } public function isMethodStaticCallOrClassMethodObjectType(Node $node, ObjectType $objectType) : bool { - if ($node instanceof MethodCall || $node instanceof Expr\NullsafeMethodCall) { + if ($node instanceof MethodCall || $node instanceof NullsafeMethodCall) { // method call is variable return return $this->isObjectType($node->var, $objectType); } diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 85255a90103b..60e5eb241345 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -51,6 +51,7 @@ use PHPStan\Reflection\ReflectionProvider; use PHPStan\Type\ObjectType; use PHPStan\Type\TypeCombinator; +use Rector\Contract\PhpParser\Node\StmtsAwareInterface; use Rector\Exception\ShouldNotHappenException; use Rector\NodeAnalyzer\ClassAnalyzer; use Rector\NodeNameResolver\NodeNameResolver; @@ -146,6 +147,11 @@ public function processNodes(array $stmts, string $filePath, ?MutatingScope $for $this->nodeScopeResolver->processNodes($node->stmts, $mutatingScope, $nodeCallback); return; } + if ($node instanceof StmtsAwareInterface && $node->stmts !== null) { + foreach ($node->stmts as $stmt) { + $stmt->setAttribute(AttributeKey::SCOPE, $mutatingScope); + } + } if (($node instanceof Expression || $node instanceof Return_ || $node instanceof EnumCase || $node instanceof Cast) && $node->expr instanceof Expr) { $node->expr->setAttribute(AttributeKey::SCOPE, $mutatingScope); } elseif ($node instanceof Assign || $node instanceof AssignOp) {