Updated Rector to commit 00876daa5dbda14d26b36b8c4365362b7e1cb7ac

00876daa5d [Renaming] Handle crash on RenameFunctionRector with die() and $_SESSION usage (#5646)
This commit is contained in:
Tomas Votruba 2024-02-20 20:26:25 +00:00
parent bf8ee68288
commit 4461c6c31d
2 changed files with 17 additions and 4 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = '29562ce48e265fbd75bf13df5e6662af76a44846'; public const PACKAGE_VERSION = '00876daa5dbda14d26b36b8c4365362b7e1cb7ac';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2024-02-21 01:58:22'; public const RELEASE_DATE = '2024-02-21 03:24:01';
/** /**
* @var int * @var int
*/ */

View File

@ -4,12 +4,14 @@ declare (strict_types=1);
namespace Rector\PHPStan\NodeVisitor; namespace Rector\PHPStan\NodeVisitor;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Exit_; use PhpParser\Node\Expr\Exit_;
use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\Declare_; use PhpParser\Node\Stmt\Declare_;
use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Expression;
use PhpParser\NodeVisitorAbstract; use PhpParser\NodeVisitorAbstract;
use PHPStan\Analyser\MutatingScope; use PHPStan\Analyser\MutatingScope;
use PHPStan\Analyser\Scope;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface; use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver; use Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver;
@ -46,11 +48,11 @@ final class UnreachableStatementNodeVisitor extends NodeVisitorAbstract
return null; return null;
} }
$isPassedUnreachableStmt = \false; $isPassedUnreachableStmt = \false;
$mutatingScope = $node->getAttribute(AttributeKey::SCOPE); $mutatingScope = $this->resolveScope($node->getAttribute(AttributeKey::SCOPE));
$mutatingScope = $mutatingScope instanceof MutatingScope ? $mutatingScope : $this->scopeFactory->createFromFile($this->filePath);
foreach ($node->stmts as $stmt) { foreach ($node->stmts as $stmt) {
if ($stmt instanceof Expression && $stmt->expr instanceof Exit_) { if ($stmt instanceof Expression && $stmt->expr instanceof Exit_) {
$isPassedUnreachableStmt = \true; $isPassedUnreachableStmt = \true;
$this->processExitScope($stmt->expr, $stmt, $mutatingScope);
continue; continue;
} }
if ($stmt->getAttribute(AttributeKey::IS_UNREACHABLE) === \true) { if ($stmt->getAttribute(AttributeKey::IS_UNREACHABLE) === \true) {
@ -65,4 +67,15 @@ final class UnreachableStatementNodeVisitor extends NodeVisitorAbstract
} }
return null; return null;
} }
private function processExitScope(Exit_ $exit, Expression $expression, MutatingScope $mutatingScope) : void
{
if ($exit->expr instanceof Expr && !$exit->expr->getAttribute(AttributeKey::SCOPE) instanceof MutatingScope) {
$expression->setAttribute(AttributeKey::SCOPE, $mutatingScope);
$this->phpStanNodeScopeResolver->processNodes([$expression], $this->filePath, $mutatingScope);
}
}
private function resolveScope(?Scope $mutatingScope) : MutatingScope
{
return $mutatingScope instanceof MutatingScope ? $mutatingScope : $this->scopeFactory->createFromFile($this->filePath);
}
} }