Updated Rector to commit 2194c6eec73db88500a42b2f443ca6c022b7d6a1

2194c6eec7 [NodeTypeResolver] Ignore PHPStan internal error on PHPStanNodeScopeResolver on NodeScopeResolver::processNodes() (#5586)
This commit is contained in:
Tomas Votruba 2024-02-08 07:30:40 +00:00
parent 831bb7a9f7
commit 512a9f7130
2 changed files with 20 additions and 5 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '2aa1c38988c58fda5ae04a5b27fad255eaa2b141';
public const PACKAGE_VERSION = '2194c6eec73db88500a42b2f443ca6c022b7d6a1';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-02-08 05:37:38';
public const RELEASE_DATE = '2024-02-08 14:28:34';
/**
* @var int
*/

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace Rector\NodeTypeResolver\PHPStan\Scope;
use Throwable;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
@ -143,7 +144,7 @@ final class PHPStanNodeScopeResolver
$nodeCallback = function (Node $node, MutatingScope $mutatingScope) use(&$nodeCallback, $filePath) : void {
if ($node instanceof FileWithoutNamespace) {
$node->setAttribute(AttributeKey::SCOPE, $mutatingScope);
$this->nodeScopeResolver->processNodes($node->stmts, $mutatingScope, $nodeCallback);
$this->nodeScopeResolverProcessNodes($node->stmts, $mutatingScope, $nodeCallback);
return;
}
if (($node instanceof Expression || $node instanceof Return_ || $node instanceof EnumCase || $node instanceof Cast) && $node->expr instanceof Expr) {
@ -208,13 +209,27 @@ final class PHPStanNodeScopeResolver
$node->setAttribute(AttributeKey::SCOPE, $mutatingScope);
}
};
$this->nodeScopeResolver->processNodes($stmts, $scope, $nodeCallback);
$this->nodeScopeResolverProcessNodes($stmts, $scope, $nodeCallback);
$nodeTraverser = new NodeTraverser();
$nodeTraverser->addVisitor(new WrappedNodeRestoringNodeVisitor());
$nodeTraverser->addVisitor(new ExprScopeFromStmtNodeVisitor($this, $filePath, $scope));
$nodeTraverser->traverse($stmts);
return $stmts;
}
/**
* @param Stmt[] $stmts
* @param callable(Node $node, MutatingScope $scope): void $nodeCallback
*/
private function nodeScopeResolverProcessNodes(array $stmts, MutatingScope $mutatingScope, callable $nodeCallback) : void
{
try {
$this->nodeScopeResolver->processNodes($stmts, $mutatingScope, $nodeCallback);
} catch (Throwable $throwable) {
if ($throwable->getMessage() !== 'Internal error.') {
throw $throwable;
}
}
}
public function hasUnreachableStatementNode() : bool
{
return $this->hasUnreachableStatementNode;
@ -377,7 +392,7 @@ final class PHPStanNodeScopeResolver
$this->privatesAccessor->setPrivateProperty($traitContext, 'classReflection', $traitClassReflection);
$this->privatesAccessor->setPrivateProperty($traitScope, self::CONTEXT, $traitContext);
$trait->setAttribute(AttributeKey::SCOPE, $traitScope);
$this->nodeScopeResolver->processNodes($trait->stmts, $traitScope, $nodeCallback);
$this->nodeScopeResolverProcessNodes($trait->stmts, $traitScope, $nodeCallback);
$this->decorateTraitAttrGroups($trait, $traitScope);
}
}