Updated Rector to commit 3b44873d14db5c15a33147bc6aa395e95ec17def

3b44873d14 [Renaming] Handle crash on RenameFunctionRector with die() and $_SESSION part 2 (#5647)
This commit is contained in:
Tomas Votruba 2024-02-21 07:47:43 +00:00
parent 4461c6c31d
commit c6cecac9f8
2 changed files with 4 additions and 17 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = '00876daa5dbda14d26b36b8c4365362b7e1cb7ac'; public const PACKAGE_VERSION = '3b44873d14db5c15a33147bc6aa395e95ec17def';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2024-02-21 03:24:01'; public const RELEASE_DATE = '2024-02-21 14:45:26';
/** /**
* @var int * @var int
*/ */

View File

@ -4,11 +4,8 @@ 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\Stmt\ClassLike; use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\Declare_; use PhpParser\Node\Stmt\Declare_;
use PhpParser\Node\Stmt\Expression;
use PhpParser\NodeVisitorAbstract; use PhpParser\NodeVisitorAbstract;
use PHPStan\Analyser\MutatingScope; use PHPStan\Analyser\MutatingScope;
use PHPStan\Analyser\Scope; use PHPStan\Analyser\Scope;
@ -50,10 +47,8 @@ final class UnreachableStatementNodeVisitor extends NodeVisitorAbstract
$isPassedUnreachableStmt = \false; $isPassedUnreachableStmt = \false;
$mutatingScope = $this->resolveScope($node->getAttribute(AttributeKey::SCOPE)); $mutatingScope = $this->resolveScope($node->getAttribute(AttributeKey::SCOPE));
foreach ($node->stmts as $stmt) { foreach ($node->stmts as $stmt) {
if ($stmt instanceof Expression && $stmt->expr instanceof Exit_) { if (!$stmt->getAttribute(AttributeKey::SCOPE) instanceof MutatingScope) {
$isPassedUnreachableStmt = \true; $this->phpStanNodeScopeResolver->processNodes([$stmt], $this->filePath, $mutatingScope);
$this->processExitScope($stmt->expr, $stmt, $mutatingScope);
continue;
} }
if ($stmt->getAttribute(AttributeKey::IS_UNREACHABLE) === \true) { if ($stmt->getAttribute(AttributeKey::IS_UNREACHABLE) === \true) {
$isPassedUnreachableStmt = \true; $isPassedUnreachableStmt = \true;
@ -62,18 +57,10 @@ final class UnreachableStatementNodeVisitor extends NodeVisitorAbstract
if ($isPassedUnreachableStmt) { if ($isPassedUnreachableStmt) {
$stmt->setAttribute(AttributeKey::IS_UNREACHABLE, \true); $stmt->setAttribute(AttributeKey::IS_UNREACHABLE, \true);
$stmt->setAttribute(AttributeKey::SCOPE, $mutatingScope); $stmt->setAttribute(AttributeKey::SCOPE, $mutatingScope);
$this->phpStanNodeScopeResolver->processNodes([$stmt], $this->filePath, $mutatingScope);
} }
} }
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 private function resolveScope(?Scope $mutatingScope) : MutatingScope
{ {
return $mutatingScope instanceof MutatingScope ? $mutatingScope : $this->scopeFactory->createFromFile($this->filePath); return $mutatingScope instanceof MutatingScope ? $mutatingScope : $this->scopeFactory->createFromFile($this->filePath);