mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit 2194c6eec73db88500a42b2f443ca6c022b7d6a1
2194c6eec7
[NodeTypeResolver] Ignore PHPStan internal error on PHPStanNodeScopeResolver on NodeScopeResolver::processNodes() (#5586)
This commit is contained in:
parent
831bb7a9f7
commit
512a9f7130
@ -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
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user