mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 13:28:18 +01:00
Updated Rector to commit b5859be5c0af9089cc6fd2b007c24163db198334
b5859be5c0
[CodeQuality] Handle crash on Yield_ with first class callable on OptionalParametersAfterRequiredRector (#6529)
This commit is contained in:
parent
3877f3d6f4
commit
55001041d1
@ -3,8 +3,11 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Application;
|
||||
|
||||
use PhpParser\Modifiers;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\ArrayItem;
|
||||
use PhpParser\Node\ClosureUse;
|
||||
use PhpParser\Node\DeclareItem;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\CallLike;
|
||||
@ -15,13 +18,20 @@ use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\NullsafeMethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\PropertyItem;
|
||||
use PhpParser\Node\StaticVar;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Declare_;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\Stmt\Static_;
|
||||
use PhpParser\Node\Stmt\Switch_;
|
||||
use PhpParser\Node\Stmt\TryCatch;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\UseItem;
|
||||
use PHPStan\Analyser\MutatingScope;
|
||||
use Rector\Exception\ShouldNotHappenException;
|
||||
use Rector\NodeAnalyzer\ScopeAnalyzer;
|
||||
@ -91,9 +101,27 @@ final class ChangedNodeScopeRefresher
|
||||
if ($node instanceof Expr) {
|
||||
return [new Expression($node)];
|
||||
}
|
||||
// moved from Expr/Stmt to directly under Node on PHPParser 5
|
||||
if ($node instanceof ArrayItem) {
|
||||
return [new Expression(new Array_([$node]))];
|
||||
}
|
||||
if ($node instanceof ClosureUse) {
|
||||
$closure = new Closure();
|
||||
$closure->uses[] = $node;
|
||||
return [new Expression($closure)];
|
||||
}
|
||||
if ($node instanceof DeclareItem) {
|
||||
return [new Declare_([$node])];
|
||||
}
|
||||
if ($node instanceof PropertyItem) {
|
||||
return [new Property(Modifiers::PUBLIC, [$node])];
|
||||
}
|
||||
if ($node instanceof StaticVar) {
|
||||
return [new Static_([$node])];
|
||||
}
|
||||
if ($node instanceof UseItem) {
|
||||
return [new Use_([$node])];
|
||||
}
|
||||
$errorMessage = \sprintf('Complete parent node of "%s" be a stmt.', \get_class($node));
|
||||
throw new ShouldNotHappenException($errorMessage);
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '2.0.0-rc2';
|
||||
public const PACKAGE_VERSION = 'b5859be5c0af9089cc6fd2b007c24163db198334';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-12-03 20:06:47';
|
||||
public const RELEASE_DATE = '2024-12-05 10:00:50';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -28,6 +28,7 @@ use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Expr\StaticPropertyFetch;
|
||||
use PhpParser\Node\Expr\Ternary;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Expr\Yield_;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\IntersectionType;
|
||||
use PhpParser\Node\Name;
|
||||
@ -260,6 +261,9 @@ final class PHPStanNodeScopeResolver
|
||||
$this->processMatch($node, $mutatingScope);
|
||||
return;
|
||||
}
|
||||
if ($node instanceof Yield_) {
|
||||
$this->processYield($node, $mutatingScope);
|
||||
}
|
||||
};
|
||||
$this->nodeScopeResolverProcessNodes($stmts, $scope, $nodeCallback);
|
||||
$nodeTraverser = new NodeTraverser();
|
||||
@ -270,6 +274,15 @@ final class PHPStanNodeScopeResolver
|
||||
$nodeTraverser->traverse($stmts);
|
||||
return $stmts;
|
||||
}
|
||||
private function processYield(Yield_ $yield, MutatingScope $mutatingScope) : void
|
||||
{
|
||||
if ($yield->key instanceof Expr) {
|
||||
$yield->key->setAttribute(AttributeKey::SCOPE, $mutatingScope);
|
||||
}
|
||||
if ($yield->value instanceof Expr) {
|
||||
$yield->value->setAttribute(AttributeKey::SCOPE, $mutatingScope);
|
||||
}
|
||||
}
|
||||
private function processMatch(Match_ $match, MutatingScope $mutatingScope) : void
|
||||
{
|
||||
$match->cond->setAttribute(AttributeKey::SCOPE, $mutatingScope);
|
||||
|
Loading…
x
Reference in New Issue
Block a user