mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 01:10:53 +00:00
Updated Rector to commit 6845975035
6845975035
[Core] Replace deprecated ->enterCatch() with enterCatchType() (#2548)
This commit is contained in:
parent
582aecc7dd
commit
a0705ea3d6
|
@ -35,6 +35,8 @@ use PHPStan\Node\UnreachableStatementNode;
|
|||
use PHPStan\Reflection\BetterReflection\Reflector\MemoizingReflector;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\TypeCombinator;
|
||||
use Rector\Caching\Detector\ChangedFilesDetector;
|
||||
use Rector\Caching\FileSystem\DependencyResolver;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
|
@ -169,7 +171,10 @@ final class PHPStanNodeScopeResolver
|
|||
if ($node instanceof TryCatch) {
|
||||
foreach ($node->catches as $catch) {
|
||||
$varName = $catch->var instanceof Variable ? $this->nodeNameResolver->getName($catch->var) : null;
|
||||
$catchMutatingScope = $mutatingScope->enterCatch($catch->types, $varName);
|
||||
$type = TypeCombinator::union(...\array_map(static function (Name $class) : ObjectType {
|
||||
return new ObjectType((string) $class);
|
||||
}, $catch->types));
|
||||
$catchMutatingScope = $mutatingScope->enterCatchType($type, $varName);
|
||||
$this->processNodes($catch->stmts, $smartFileInfo, $catchMutatingScope);
|
||||
}
|
||||
if ($node->finally instanceof Finally_) {
|
||||
|
|
|
@ -15,7 +15,6 @@ use Rector\Core\Exception\ShouldNotHappenException;
|
|||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PostRector\Contract\Collector\NodeCollectorInterface;
|
||||
use RectorPrefix202206\Symplify\SmartFileSystem\SmartFileInfo;
|
||||
final class NodesToAddCollector implements NodeCollectorInterface
|
||||
{
|
||||
/**
|
||||
|
@ -60,18 +59,13 @@ final class NodesToAddCollector implements NodeCollectorInterface
|
|||
/**
|
||||
* @deprecated Return created nodes right in refactor() method to keep context instead.
|
||||
*/
|
||||
public function addNodeBeforeNode(Node $addedNode, Node $positionNode, ?SmartFileInfo $smartFileInfo = null) : void
|
||||
public function addNodeBeforeNode(Node $addedNode, Node $positionNode) : void
|
||||
{
|
||||
if ($positionNode->getAttributes() === []) {
|
||||
$message = \sprintf('Switch arguments in "%s()" method', __METHOD__);
|
||||
throw new ShouldNotHappenException($message);
|
||||
}
|
||||
// @todo the node must be returned here, so traverser can refresh it
|
||||
// this is nasty hack to verify it works
|
||||
if ($smartFileInfo instanceof SmartFileInfo) {
|
||||
$currentScope = $positionNode->getAttribute(AttributeKey::SCOPE);
|
||||
$this->changedNodeScopeRefresher->refresh($addedNode, $smartFileInfo, $currentScope);
|
||||
}
|
||||
$this->changedNodeScopeRefresher->refresh($addedNode, $positionNode->getAttribute(AttributeKey::SCOPE));
|
||||
$position = $this->resolveNearestStmtPosition($positionNode);
|
||||
$this->nodesToAddBefore[$position][] = $this->wrapToExpression($addedNode);
|
||||
$this->rectorChangeCollector->notifyNodeFileInfo($positionNode);
|
||||
|
@ -82,11 +76,10 @@ final class NodesToAddCollector implements NodeCollectorInterface
|
|||
*/
|
||||
public function addNodesAfterNode(array $addedNodes, Node $positionNode) : void
|
||||
{
|
||||
$position = $this->resolveNearestStmtPosition($positionNode);
|
||||
foreach ($addedNodes as $addedNode) {
|
||||
// prevent fluent method weird indent
|
||||
$addedNode->setAttribute(AttributeKey::ORIGINAL_NODE, null);
|
||||
$this->nodesToAddAfter[$position][] = $this->wrapToExpression($addedNode);
|
||||
$this->addNodeAfterNode($addedNode, $positionNode);
|
||||
}
|
||||
$this->rectorChangeCollector->notifyNodeFileInfo($positionNode);
|
||||
}
|
||||
|
@ -96,6 +89,11 @@ final class NodesToAddCollector implements NodeCollectorInterface
|
|||
*/
|
||||
public function addNodeAfterNode(Node $addedNode, Node $positionNode) : void
|
||||
{
|
||||
if ($positionNode->getAttributes() === []) {
|
||||
$message = \sprintf('Switch arguments in "%s()" method', __METHOD__);
|
||||
throw new ShouldNotHappenException($message);
|
||||
}
|
||||
$this->changedNodeScopeRefresher->refresh($addedNode, $positionNode->getAttribute(AttributeKey::SCOPE));
|
||||
$position = $this->resolveNearestStmtPosition($positionNode);
|
||||
$this->nodesToAddAfter[$position][] = $this->wrapToExpression($addedNode);
|
||||
$this->rectorChangeCollector->notifyNodeFileInfo($positionNode);
|
||||
|
@ -133,7 +131,7 @@ final class NodesToAddCollector implements NodeCollectorInterface
|
|||
public function addNodesBeforeNode(array $newNodes, Node $positionNode) : void
|
||||
{
|
||||
foreach ($newNodes as $newNode) {
|
||||
$this->addNodeBeforeNode($newNode, $positionNode, null);
|
||||
$this->addNodeBeforeNode($newNode, $positionNode);
|
||||
}
|
||||
$this->rectorChangeCollector->notifyNodeFileInfo($positionNode);
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ CODE_SAMPLE
|
|||
$firstArg = $funcCall->args[0];
|
||||
$assignVariable = $firstArg->value;
|
||||
$preAssign = new Assign($assignVariable, $array);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($preAssign, $currentStmt, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($preAssign, $currentStmt);
|
||||
return $expr;
|
||||
}
|
||||
private function refactorAssignArray(Expr $expr, FuncCall $funcCall) : ?Expr
|
||||
|
|
|
@ -115,11 +115,13 @@ CODE_SAMPLE
|
|||
if (($node instanceof Identical || $node instanceof NotIdentical) && $node->right instanceof LNumber && $node->right->value === 0) {
|
||||
$this->removeNode($funcCall);
|
||||
$node->right = new Array_([]);
|
||||
$node->right->setAttribute(AttributeKey::SCOPE, $node->getAttribute(AttributeKey::SCOPE));
|
||||
return $expr;
|
||||
}
|
||||
if (($node instanceof Identical || $node instanceof NotIdentical) && $node->left instanceof LNumber && $node->left->value === 0) {
|
||||
$this->removeNode($funcCall);
|
||||
$node->left = new Array_([]);
|
||||
$node->left->setAttribute(AttributeKey::SCOPE, $node->getAttribute(AttributeKey::SCOPE));
|
||||
return $expr;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -96,7 +96,7 @@ CODE_SAMPLE
|
|||
}
|
||||
$selfVariable = $this->namedVariableFactory->createVariable($node, 'self');
|
||||
$expression = new Expression(new Assign($selfVariable, new Variable('this')));
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($expression, $node, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($expression, $node);
|
||||
$this->traverseNodesWithCallable($node, static function (Node $subNode) use($selfVariable) : ?Closure {
|
||||
if (!$subNode instanceof Closure) {
|
||||
return null;
|
||||
|
|
|
@ -60,7 +60,7 @@ CODE_SAMPLE
|
|||
}
|
||||
$variable = $this->namedVariableFactory->createVariable($node, 'object');
|
||||
$expression = new Expression(new Assign($variable, $node->var));
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($expression, $node, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($expression, $node);
|
||||
$node->var = $variable;
|
||||
// necessary to remove useless parentheses
|
||||
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
|
||||
|
|
|
@ -104,11 +104,11 @@ CODE_SAMPLE
|
|||
}
|
||||
$scope = $funcCall->getAttribute(AttributeKey::SCOPE);
|
||||
$variable = new Variable($this->variableNaming->createCountedValueName('result', $scope));
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression(new Assign($variable, new Array_([]))), $funcCall, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression(new Assign($variable, new Array_([]))), $funcCall);
|
||||
/** @var ConstFetch $constant */
|
||||
$constant = $args[2]->value;
|
||||
$foreach = $this->nodeNameResolver->isName($constant, 'ARRAY_FILTER_USE_KEY') ? $this->applyArrayFilterUseKey($args, $closure, $variable) : $this->applyArrayFilterUseBoth($args, $closure, $variable);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($foreach, $funcCall, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($foreach, $funcCall);
|
||||
return $variable;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -109,7 +109,7 @@ CODE_SAMPLE
|
|||
$funcVariable = $this->namedVariableFactory->createVariable($funcCall, 'dirnameFunc');
|
||||
$closure = $this->createClosure();
|
||||
$exprAssignClosure = $this->createExprAssign($funcVariable, $closure);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($exprAssignClosure, $funcCall, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($exprAssignClosure, $funcCall);
|
||||
$funcCall->name = $funcVariable;
|
||||
return $funcCall;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ CODE_SAMPLE
|
|||
$sessionKey = new String_('session.' . $option->key->value);
|
||||
$funcName = new Name('ini_set');
|
||||
$iniSet = new FuncCall($funcName, [new Arg($sessionKey), new Arg($option->value)]);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($iniSet), $node, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($iniSet), $node);
|
||||
}
|
||||
unset($node->args[0]);
|
||||
return $node;
|
||||
|
|
|
@ -73,7 +73,7 @@ CODE_SAMPLE
|
|||
$variable = new Variable($newVariableName);
|
||||
$assign = new Assign($variable, $node->var);
|
||||
}
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($assign), $node, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($assign), $node);
|
||||
$node->var = $variable;
|
||||
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
|
||||
return $node;
|
||||
|
|
|
@ -85,7 +85,7 @@ CODE_SAMPLE
|
|||
$anonymousFunction->stmts[1] = new Return_($ternary);
|
||||
$assignVariable = $this->namedVariableFactory->createVariable($node, 'battleShipcompare');
|
||||
$assignExpression = $this->getAssignExpression($anonymousFunction, $assignVariable);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($assignExpression, $node, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($assignExpression, $node);
|
||||
return new FuncCall($assignVariable, [new Arg($node->left), new Arg($node->right)]);
|
||||
}
|
||||
private function getAssignExpression(Closure $closure, Variable $variable) : Expression
|
||||
|
|
|
@ -68,7 +68,7 @@ CODE_SAMPLE
|
|||
}
|
||||
$tempVariable = $this->namedVariableFactory->createVariable($node, 'callable');
|
||||
$expression = new Expression(new Assign($tempVariable, $node->args[0]->value));
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($expression, $node, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($expression, $node);
|
||||
$closure = new Closure();
|
||||
$closure->uses[] = new ClosureUse($tempVariable);
|
||||
$innerFuncCall = new FuncCall($tempVariable, [new Arg($this->nodeFactory->createFuncCall('func_get_args'), \false, \true)]);
|
||||
|
|
|
@ -209,7 +209,7 @@ CODE_SAMPLE
|
|||
{
|
||||
if ($if->stmts !== []) {
|
||||
$firstStmt = $if->stmts[0];
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($funcCall, $firstStmt, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($funcCall, $firstStmt);
|
||||
return;
|
||||
}
|
||||
$if->stmts[0] = new Expression($funcCall);
|
||||
|
|
|
@ -111,7 +111,7 @@ CODE_SAMPLE
|
|||
$function = $this->createClosure();
|
||||
$variable = new Variable($this->variableNaming->createCountedValueName('streamIsatty', $scope));
|
||||
$assign = new Assign($variable, $function);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($assign, $node, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($assign, $node);
|
||||
return new FuncCall($variable, $node->args);
|
||||
}
|
||||
private function createClosure() : Closure
|
||||
|
|
|
@ -90,7 +90,7 @@ CODE_SAMPLE
|
|||
$this->addAssignNewVariable($funcCall, $originalArray, $array);
|
||||
}
|
||||
$resetFuncCall = $this->nodeFactory->createFuncCall('reset', [$array]);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($resetFuncCall, $funcCall, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($resetFuncCall, $funcCall);
|
||||
$funcCall->name = new Name('key');
|
||||
if ($originalArray !== $array) {
|
||||
$funcCall->args[0]->value = $array;
|
||||
|
@ -111,7 +111,7 @@ CODE_SAMPLE
|
|||
$this->addAssignNewVariable($funcCall, $originalArray, $array);
|
||||
}
|
||||
$resetFuncCall = $this->nodeFactory->createFuncCall('end', [$array]);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($resetFuncCall, $funcCall, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($resetFuncCall, $funcCall);
|
||||
$funcCall->name = new Name('key');
|
||||
if ($originalArray !== $array) {
|
||||
$funcCall->args[0]->value = $array;
|
||||
|
@ -123,7 +123,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
private function addAssignNewVariable(FuncCall $funcCall, Expr $expr, $variable) : void
|
||||
{
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression(new Assign($variable, $expr)), $funcCall, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression(new Assign($variable, $expr)), $funcCall);
|
||||
}
|
||||
/**
|
||||
* @return \PhpParser\Node\Expr|\PhpParser\Node\Expr\Variable
|
||||
|
|
|
@ -107,7 +107,7 @@ CODE_SAMPLE
|
|||
$variableName = $this->variableNaming->resolveFromFuncCallFirstArgumentWithSuffix($node, 'AllowableTags', 'allowableTags', $node->getAttribute(AttributeKey::SCOPE));
|
||||
// Assign the value to the variable
|
||||
$newVariable = new Variable($variableName);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Assign($newVariable, $allowableTagsParam), $node, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Assign($newVariable, $allowableTagsParam), $node);
|
||||
// Apply refactor on the variable
|
||||
$newExpr = $this->createIsArrayTernaryFromExpression($newVariable);
|
||||
}
|
||||
|
|
|
@ -118,11 +118,11 @@ CODE_SAMPLE
|
|||
$reflectionClassConstants = $this->variableNaming->createCountedValueName('reflectionClassConstants', $scope);
|
||||
$variableReflectionClassConstants = new Variable($this->variableNaming->createCountedValueName($reflectionClassConstants, $scope));
|
||||
$assign = new Assign($variableReflectionClassConstants, new MethodCall($methodCall->var, 'getReflectionConstants'));
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($assign), $methodCall, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($assign), $methodCall);
|
||||
$result = $this->variableNaming->createCountedValueName('result', $scope);
|
||||
$variableResult = new Variable($result);
|
||||
$assignVariableResult = new Assign($variableResult, new Array_());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($assignVariableResult), $methodCall, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($assignVariableResult), $methodCall);
|
||||
$ifs = [];
|
||||
$valueVariable = new Variable('value');
|
||||
$key = new MethodCall($valueVariable, 'getName');
|
||||
|
@ -138,7 +138,7 @@ CODE_SAMPLE
|
|||
$closure->uses = [new ClosureUse($variableResult, \true)];
|
||||
$closure->stmts = $ifs;
|
||||
$funcCall = $this->nodeFactory->createFuncCall('array_walk', [$variableReflectionClassConstants, $closure]);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($funcCall), $methodCall, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Expression($funcCall), $methodCall);
|
||||
return $variableResult;
|
||||
}
|
||||
private function resolveClassConstFetchName(ClassConstFetch $classConstFetch) : ?string
|
||||
|
|
|
@ -87,7 +87,7 @@ CODE_SAMPLE
|
|||
$variable = $this->namedVariableFactory->createVariable($node, 'className');
|
||||
$assign = new Assign($variable, $node->class);
|
||||
}
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($assign, $node, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($assign, $node);
|
||||
$node->class = $variable;
|
||||
return $node;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ final class ArrayMergeFromArraySpreadFactory
|
|||
// Assign the value to the variable, and replace the element with the variable
|
||||
$newVariable = new Variable($variableName);
|
||||
$newVariableAssign = new Assign($newVariable, $arrayItem->value);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($newVariableAssign, $array, $file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($newVariableAssign, $array);
|
||||
return $newVariable;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -93,7 +93,7 @@ CODE_SAMPLE
|
|||
$variable = new Variable($this->variableNaming->createCountedValueName('arrayIsList', $scope));
|
||||
$function = $this->createClosure();
|
||||
$expression = new Expression(new Assign($variable, $function));
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($expression, $node, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($expression, $node);
|
||||
return new FuncCall($variable, $node->args);
|
||||
}
|
||||
private function createClosure() : Closure
|
||||
|
|
|
@ -115,7 +115,7 @@ CODE_SAMPLE
|
|||
private function processEarlyReturn(Expression $expression, Assign $assign, array $breaks, Return_ $return, Assign $assignPreviousVariable, Foreach_ $foreach) : Foreach_
|
||||
{
|
||||
$this->removeNode($expression);
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Return_($assign->expr), $breaks[0], $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode(new Return_($assign->expr), $breaks[0]);
|
||||
$this->removeNode($breaks[0]);
|
||||
$return->expr = $assignPreviousVariable->expr;
|
||||
$this->removeNode($assignPreviousVariable);
|
||||
|
|
|
@ -112,7 +112,7 @@ final class NonVariableToVariableOnFunctionCallRector extends AbstractRector imp
|
|||
if (!$currentStmt instanceof Stmt) {
|
||||
continue;
|
||||
}
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($replacements->getAssign(), $currentStmt, $this->file->getSmartFileInfo());
|
||||
$this->nodesToAddCollector->addNodeBeforeNode($replacements->getAssign(), $currentStmt);
|
||||
$node->args[$key]->value = $replacements->getVariable();
|
||||
// add variable name to scope, so we prevent duplication of new variable of the same name
|
||||
$currentScope = $currentScope->assignExpression($replacements->getVariable(), $currentScope->getType($replacements->getVariable()));
|
||||
|
|
|
@ -31,6 +31,8 @@ use Rector\Core\NodeAnalyzer\ScopeAnalyzer;
|
|||
use Rector\Core\NodeAnalyzer\UnreachableStmtAnalyzer;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver;
|
||||
use RectorPrefix202206\Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
@ -59,14 +61,20 @@ final class ChangedNodeScopeRefresher
|
|||
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
||||
*/
|
||||
private $betterNodeFinder;
|
||||
public function __construct(PHPStanNodeScopeResolver $phpStanNodeScopeResolver, ScopeAnalyzer $scopeAnalyzer, UnreachableStmtAnalyzer $unreachableStmtAnalyzer, BetterNodeFinder $betterNodeFinder)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Provider\CurrentFileProvider
|
||||
*/
|
||||
private $currentFileProvider;
|
||||
public function __construct(PHPStanNodeScopeResolver $phpStanNodeScopeResolver, ScopeAnalyzer $scopeAnalyzer, UnreachableStmtAnalyzer $unreachableStmtAnalyzer, BetterNodeFinder $betterNodeFinder, CurrentFileProvider $currentFileProvider)
|
||||
{
|
||||
$this->phpStanNodeScopeResolver = $phpStanNodeScopeResolver;
|
||||
$this->scopeAnalyzer = $scopeAnalyzer;
|
||||
$this->unreachableStmtAnalyzer = $unreachableStmtAnalyzer;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->currentFileProvider = $currentFileProvider;
|
||||
}
|
||||
public function refresh(Node $node, SmartFileInfo $smartFileInfo, ?MutatingScope $mutatingScope) : void
|
||||
public function refresh(Node $node, ?MutatingScope $mutatingScope, ?SmartFileInfo $smartFileInfo = null) : void
|
||||
{
|
||||
// nothing to refresh
|
||||
if (!$this->scopeAnalyzer->hasScope($node)) {
|
||||
|
@ -86,6 +94,11 @@ final class ChangedNodeScopeRefresher
|
|||
throw new ShouldNotHappenException($errorMessage);
|
||||
}
|
||||
}
|
||||
if (!$smartFileInfo instanceof SmartFileInfo) {
|
||||
/** @var File $file */
|
||||
$file = $this->currentFileProvider->getFile();
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
}
|
||||
// note from flight: when we traverse ClassMethod, the scope must be already in Class_, otherwise it crashes
|
||||
// so we need to somehow get a parent scope that is already in the same place the $node is
|
||||
if ($node instanceof Attribute) {
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '237f603c81d4bbbd0de22e5eebdf32f53902ee15';
|
||||
public const PACKAGE_VERSION = '6845975035289df55f72cc710101fc9ae5d4ae1b';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-06-25 18:05:51';
|
||||
public const RELEASE_DATE = '2022-06-25 18:07:41';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -246,7 +246,7 @@ CODE_SAMPLE;
|
|||
/** @var Node $node */
|
||||
$this->mirrorAttributes($originalAttributes, $node);
|
||||
$currentScope = $originalNode->getAttribute(AttributeKey::SCOPE);
|
||||
$this->changedNodeScopeRefresher->refresh($node, $this->file->getSmartFileInfo(), $currentScope);
|
||||
$this->changedNodeScopeRefresher->refresh($node, $currentScope, $this->file->getSmartFileInfo());
|
||||
$this->connectParentNodes($node);
|
||||
// is equals node type? return node early
|
||||
if (\get_class($originalNode) === \get_class($node)) {
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitcb12a9846c5e7eaa0d5edcb9461d0adf::getLoader();
|
||||
return ComposerAutoloaderInit823c01ea85d61dbd009573be8e82a712::getLoader();
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitcb12a9846c5e7eaa0d5edcb9461d0adf
|
||||
class ComposerAutoloaderInit823c01ea85d61dbd009573be8e82a712
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInitcb12a9846c5e7eaa0d5edcb9461d0adf
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitcb12a9846c5e7eaa0d5edcb9461d0adf', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit823c01ea85d61dbd009573be8e82a712', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitcb12a9846c5e7eaa0d5edcb9461d0adf', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit823c01ea85d61dbd009573be8e82a712', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitcb12a9846c5e7eaa0d5edcb9461d0adf::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit823c01ea85d61dbd009573be8e82a712::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitcb12a9846c5e7eaa0d5edcb9461d0adf::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit823c01ea85d61dbd009573be8e82a712::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequirecb12a9846c5e7eaa0d5edcb9461d0adf($fileIdentifier, $file);
|
||||
composerRequire823c01ea85d61dbd009573be8e82a712($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInitcb12a9846c5e7eaa0d5edcb9461d0adf
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequirecb12a9846c5e7eaa0d5edcb9461d0adf($fileIdentifier, $file)
|
||||
function composerRequire823c01ea85d61dbd009573be8e82a712($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitcb12a9846c5e7eaa0d5edcb9461d0adf
|
||||
class ComposerStaticInit823c01ea85d61dbd009573be8e82a712
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
|
@ -3403,9 +3403,9 @@ class ComposerStaticInitcb12a9846c5e7eaa0d5edcb9461d0adf
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitcb12a9846c5e7eaa0d5edcb9461d0adf::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitcb12a9846c5e7eaa0d5edcb9461d0adf::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitcb12a9846c5e7eaa0d5edcb9461d0adf::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit823c01ea85d61dbd009573be8e82a712::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit823c01ea85d61dbd009573be8e82a712::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit823c01ea85d61dbd009573be8e82a712::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user