mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit dae413184be4437f111a45fd99746454115cd8ab
dae413184b
[static] Fix mixed type on property fetches and method calls (#1769)
This commit is contained in:
parent
02632d1547
commit
d86e5d640a
@ -7,6 +7,7 @@ use RectorPrefix20220205\Nette\Utils\Json;
|
||||
use Rector\ChangesReporting\Annotation\RectorsChangelogResolver;
|
||||
use Rector\ChangesReporting\Contract\Output\OutputFormatterInterface;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\Core\ValueObject\Error\SystemError;
|
||||
use Rector\Core\ValueObject\ProcessResult;
|
||||
use Rector\Parallel\ValueObject\Bridge;
|
||||
final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Output\OutputFormatterInterface
|
||||
@ -50,7 +51,7 @@ final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Out
|
||||
echo $json . \PHP_EOL;
|
||||
}
|
||||
/**
|
||||
* @param mixed[] $errors
|
||||
* @param SystemError[] $errors
|
||||
* @return mixed[]
|
||||
*/
|
||||
private function createErrorsData(array $errors) : array
|
||||
@ -58,7 +59,7 @@ final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Out
|
||||
$errorsData = [];
|
||||
foreach ($errors as $error) {
|
||||
$errorDataJson = ['message' => $error->getMessage(), 'file' => $error->getRelativeFilePath()];
|
||||
if ($error->getRectorClass()) {
|
||||
if ($error->getRectorClass() !== null) {
|
||||
$errorDataJson['caused_by'] = $error->getRectorClass();
|
||||
}
|
||||
if ($error->getLine() !== null) {
|
||||
|
@ -8,12 +8,8 @@ use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Name;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
|
||||
/**
|
||||
* Utils for chain of MethodCall Node:
|
||||
* "$this->methodCall()->chainedMethodCall()"
|
||||
@ -25,15 +21,9 @@ final class FluentChainMethodCallNodeAnalyzer
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeTypeResolver\NodeTypeResolver
|
||||
*/
|
||||
private $nodeTypeResolver;
|
||||
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver)
|
||||
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
@ -73,38 +63,6 @@ final class FluentChainMethodCallNodeAnalyzer
|
||||
}
|
||||
return $chainMethodCalls;
|
||||
}
|
||||
/**
|
||||
* Checks "$this->someMethod()->anotherMethod()"
|
||||
*
|
||||
* @param string[] $methods
|
||||
*/
|
||||
public function isTypeAndChainCalls(\PhpParser\Node $node, \PHPStan\Type\Type $type, array $methods) : bool
|
||||
{
|
||||
if (!$node instanceof \PhpParser\Node\Expr\MethodCall) {
|
||||
return \false;
|
||||
}
|
||||
$rootMethodCall = $this->resolveRootMethodCall($node);
|
||||
if (!$rootMethodCall instanceof \PhpParser\Node\Expr\MethodCall) {
|
||||
return \false;
|
||||
}
|
||||
$rootMethodCallVarType = $this->nodeTypeResolver->getType($rootMethodCall->var);
|
||||
if (!$rootMethodCallVarType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) {
|
||||
return \false;
|
||||
}
|
||||
// node chaining is in reverse order than code
|
||||
$methods = \array_reverse($methods);
|
||||
foreach ($methods as $method) {
|
||||
if (!$this->nodeNameResolver->isName($node->name, $method)) {
|
||||
return \false;
|
||||
}
|
||||
$node = $node->var;
|
||||
}
|
||||
$variableType = $this->nodeTypeResolver->getType($node);
|
||||
if ($variableType instanceof \PHPStan\Type\MixedType) {
|
||||
return \false;
|
||||
}
|
||||
return $variableType->isSuperTypeOf($type)->yes();
|
||||
}
|
||||
/**
|
||||
* @return \PhpParser\Node\Expr|\PhpParser\Node\Name
|
||||
*/
|
||||
|
@ -3,6 +3,7 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\FileFormatter\EditorConfig;
|
||||
|
||||
use RectorPrefix20220205\Idiosyncratic\EditorConfig\Declaration\Declaration;
|
||||
use RectorPrefix20220205\Idiosyncratic\EditorConfig\EditorConfig;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\FileFormatter\ValueObject\EditorConfigConfiguration;
|
||||
@ -25,6 +26,7 @@ final class EditorConfigParser
|
||||
public function extractConfigurationForFile(\Rector\Core\ValueObject\Application\File $file, \Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder $editorConfigConfigurationBuilder) : \Rector\FileFormatter\ValueObject\EditorConfigConfiguration
|
||||
{
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
/** @var Declaration[] $configuration */
|
||||
$configuration = $this->editorConfig->getConfigForPath($smartFileInfo->getRealPath());
|
||||
if (\array_key_exists(\Rector\FileFormatter\ValueObject\EditorConfigOption::INDENT_STYLE, $configuration)) {
|
||||
$indentStyle = (string) $configuration[\Rector\FileFormatter\ValueObject\EditorConfigOption::INDENT_STYLE]->getValue();
|
||||
|
@ -23,7 +23,7 @@ final class BinaryOpTreeRootLocator
|
||||
public function findOperationRoot(\PhpParser\Node\Expr $expr, string $binaryOpClass) : \PhpParser\Node\Expr
|
||||
{
|
||||
$parentNode = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
if ($parentNode === null) {
|
||||
if (!$parentNode instanceof \PhpParser\Node) {
|
||||
// No more parents so the Expr node must be root.
|
||||
return $expr;
|
||||
}
|
||||
@ -32,6 +32,7 @@ final class BinaryOpTreeRootLocator
|
||||
// it must already be the root of the operation tree.
|
||||
return $expr;
|
||||
}
|
||||
/** @var BinaryOp $parentNode */
|
||||
$isParentARightAssociativeTree = $parentNode->right === $expr && \get_class($expr) === $binaryOpClass;
|
||||
if ($isParentARightAssociativeTree) {
|
||||
// The Expr node is the right child of its parent but it is the desired operation (BinaryOp b c).
|
||||
|
@ -36,6 +36,7 @@ final class StatementNodeVisitor extends \PhpParser\NodeVisitorAbstract
|
||||
if (\property_exists($node, 'stmts')) {
|
||||
$previous = $node;
|
||||
foreach ((array) $node->stmts as $stmt) {
|
||||
/** @var Stmt $stmt */
|
||||
$stmt->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_STATEMENT, $previous);
|
||||
$stmt->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT, $stmt);
|
||||
$previous = $stmt;
|
||||
|
@ -107,6 +107,9 @@ CODE_SAMPLE
|
||||
if ($node instanceof \PhpParser\Node\FunctionLike) {
|
||||
return $node->returnsByRef();
|
||||
}
|
||||
if (!$node instanceof \PhpParser\Node) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\CodingStyle\Rector\Stmt;
|
||||
|
||||
use PhpParser\Comment\Doc;
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Catch_;
|
||||
@ -94,6 +94,9 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
$nextNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
|
||||
if (!$nextNode instanceof \PhpParser\Node) {
|
||||
return null;
|
||||
}
|
||||
if ($this->shouldSkip($nextNode)) {
|
||||
return null;
|
||||
}
|
||||
@ -101,6 +104,7 @@ CODE_SAMPLE
|
||||
$line = $nextNode->getLine();
|
||||
$rangeLine = $line - $endLine;
|
||||
if ($rangeLine > 1) {
|
||||
/** @var Comment[]|null $comments */
|
||||
$comments = $nextNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS);
|
||||
if ($this->hasNoComment($comments)) {
|
||||
return null;
|
||||
@ -109,6 +113,7 @@ CODE_SAMPLE
|
||||
if ($phpDocInfo->hasChanged()) {
|
||||
return null;
|
||||
}
|
||||
/** @var Comment[] $comments */
|
||||
$line = $comments[0]->getLine();
|
||||
$rangeLine = $line - $endLine;
|
||||
if ($rangeLine > 1) {
|
||||
@ -125,7 +130,7 @@ CODE_SAMPLE
|
||||
return $currentStatement instanceof \PhpParser\Node\Stmt ? $currentStatement : $stmt;
|
||||
}
|
||||
/**
|
||||
* @param null|Doc[] $comments
|
||||
* @param Comment[]|null $comments
|
||||
*/
|
||||
private function hasNoComment(?array $comments) : bool
|
||||
{
|
||||
|
@ -182,6 +182,9 @@ CODE_SAMPLE
|
||||
private function refactorUsedVariable(\PhpParser\Node\Expr\Assign $assign) : ?\PhpParser\Node\Expr\Assign
|
||||
{
|
||||
$parentNode = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
if (!$parentNode instanceof \PhpParser\Node) {
|
||||
return null;
|
||||
}
|
||||
$if = $parentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
|
||||
// check if next node is if
|
||||
if (!$if instanceof \PhpParser\Node\Stmt\If_) {
|
||||
|
@ -11,7 +11,9 @@ use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
@ -80,6 +82,9 @@ CODE_SAMPLE
|
||||
private function createVariable(\PhpParser\Node $node) : \PhpParser\Node\Expr\Variable
|
||||
{
|
||||
$currentStmt = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if (!$currentStmt instanceof \PhpParser\Node\Stmt) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
$scope = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
return new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName('object', $scope));
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ use PhpParser\Node\Expr\List_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Foreach_;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
@ -69,6 +70,9 @@ CODE_SAMPLE
|
||||
private function createVariable(\PhpParser\Node\Stmt\Foreach_ $foreach) : \PhpParser\Node\Expr\Variable
|
||||
{
|
||||
$currentStmt = $foreach->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if (!$currentStmt instanceof \PhpParser\Node) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
$scope = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
return new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName('arrayItem', $scope));
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ use PhpParser\Node\Scalar\LNumber;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PhpParser\Node\Stmt\While_;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
@ -108,6 +109,9 @@ CODE_SAMPLE
|
||||
private function refactorForVariableLevels(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\FuncCall
|
||||
{
|
||||
$currentStmt = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if (!$currentStmt instanceof \PhpParser\Node) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
$scope = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
$funcVariable = new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName('dirnameFunc', $scope));
|
||||
$closure = $this->createClosure();
|
||||
|
@ -10,6 +10,8 @@ use PhpParser\Node\Expr\Instanceof_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
use Rector\NodeCollector\BinaryOpConditionsCollector;
|
||||
@ -88,6 +90,9 @@ CODE_SAMPLE
|
||||
private function createVariable(\PhpParser\Node\Expr\Instanceof_ $instanceof) : \PhpParser\Node\Expr\Variable
|
||||
{
|
||||
$currentStmt = $instanceof->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if (!$currentStmt instanceof \PhpParser\Node\Stmt) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
$scope = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
return new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName('throwable', $scope));
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Scalar\LNumber;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\NodeManipulator\IfManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
@ -85,6 +86,9 @@ CODE_SAMPLE
|
||||
$ternary = new \PhpParser\Node\Expr\Ternary($smaller, $ternaryIf, $ternaryElse);
|
||||
$anonymousFunction->stmts[1] = new \PhpParser\Node\Stmt\Return_($ternary);
|
||||
$currentStatement = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if (!$currentStatement instanceof \PhpParser\Node) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
$scope = $currentStatement->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
$variableAssignName = $this->variableNaming->createCountedValueName('battleShipcompare', $scope);
|
||||
$variableAssign = new \PhpParser\Node\Expr\Variable($variableAssignName);
|
||||
|
@ -129,6 +129,7 @@ CODE_SAMPLE
|
||||
$attrGroupsPrint = $this->betterStandardPrinter->print($param->attrGroups);
|
||||
$comments = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS);
|
||||
if (\is_array($comments)) {
|
||||
/** @var Comment[] $comments */
|
||||
foreach ($comments as $comment) {
|
||||
$attrGroupsPrint = \str_replace($comment->getText(), '', $attrGroupsPrint);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\StaticPropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Naming\Naming\VariableNaming;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
@ -85,6 +86,9 @@ CODE_SAMPLE
|
||||
$variable = $assign->var;
|
||||
} else {
|
||||
$currentStmt = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if (!$currentStmt instanceof \PhpParser\Node) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
$scope = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
$variable = new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName('className', $scope));
|
||||
$assign = new \PhpParser\Node\Expr\Assign($variable, $node->class);
|
||||
|
@ -158,7 +158,7 @@ CODE_SAMPLE
|
||||
{
|
||||
$parentNode = $callNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
$callNodeClass = \get_class($callNode);
|
||||
while ($parentNode) {
|
||||
while ($parentNode instanceof \PhpParser\Node) {
|
||||
$usedNodes = $this->betterNodeFinder->find($parentNode, function (\PhpParser\Node $node) use($callNodeClass, $callNode) : bool {
|
||||
$nodeClass = \get_class($node);
|
||||
if ($callNodeClass !== $nodeClass) {
|
||||
|
@ -100,7 +100,7 @@ final class NonVariableToVariableOnFunctionCallRector extends \Rector\Core\Recto
|
||||
return null;
|
||||
}
|
||||
$currentScope = $scopeNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
if (!$currentScope instanceof \PHPStan\Analyser\Scope) {
|
||||
if (!$currentScope instanceof \PHPStan\Analyser\MutatingScope) {
|
||||
return null;
|
||||
}
|
||||
foreach ($arguments as $key => $argument) {
|
||||
@ -153,7 +153,7 @@ final class NonVariableToVariableOnFunctionCallRector extends \Rector\Core\Recto
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Stmt\Namespace_ $scopeNode
|
||||
*/
|
||||
private function getReplacementsFor(\PhpParser\Node\Expr $expr, \PHPStan\Analyser\Scope $scope, $scopeNode) : \Rector\Php70\ValueObject\VariableAssignPair
|
||||
private function getReplacementsFor(\PhpParser\Node\Expr $expr, \PHPStan\Analyser\MutatingScope $scope, $scopeNode) : \Rector\Php70\ValueObject\VariableAssignPair
|
||||
{
|
||||
if ($this->isAssign($expr)) {
|
||||
/** @var Assign|AssignRef|AssignOp $expr */
|
||||
@ -164,10 +164,8 @@ final class NonVariableToVariableOnFunctionCallRector extends \Rector\Core\Recto
|
||||
$variableName = $this->variableNaming->resolveFromNodeWithScopeCountAndFallbackName($expr, $scope, 'tmp');
|
||||
$variable = new \PhpParser\Node\Expr\Variable($variableName);
|
||||
// add a new scope with this variable
|
||||
if ($scope instanceof \PHPStan\Analyser\MutatingScope) {
|
||||
$mutatingScope = $scope->assignExpression($variable, new \PHPStan\Type\MixedType());
|
||||
$scopeNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope);
|
||||
}
|
||||
return new \Rector\Php70\ValueObject\VariableAssignPair($variable, new \PhpParser\Node\Expr\Assign($variable, $expr));
|
||||
}
|
||||
private function isVariableLikeNode(\PhpParser\Node\Expr $expr) : bool
|
||||
|
@ -7,6 +7,7 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
@ -57,7 +58,7 @@ CODE_SAMPLE
|
||||
$resultVariable = new \PhpParser\Node\Expr\Variable('result');
|
||||
$node->args[1] = new \PhpParser\Node\Arg($resultVariable);
|
||||
$expression = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if ($expression === null) {
|
||||
if (!$expression instanceof \PhpParser\Node\Stmt) {
|
||||
return null;
|
||||
}
|
||||
$nextExpression = $expression->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE);
|
||||
|
@ -151,7 +151,7 @@ final class ComplexNodeRemover
|
||||
private function resolveAssign($expr) : ?\PhpParser\Node\Expr\Assign
|
||||
{
|
||||
$assign = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
while ($assign !== null && !$assign instanceof \PhpParser\Node\Expr\Assign) {
|
||||
while ($assign instanceof \PhpParser\Node && !$assign instanceof \PhpParser\Node\Expr\Assign) {
|
||||
$assign = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
}
|
||||
if (!$assign instanceof \PhpParser\Node\Expr\Assign) {
|
||||
|
@ -9,6 +9,7 @@ use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
@ -93,6 +94,9 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
$scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
if (!$scope instanceof \PHPStan\Analyser\Scope) {
|
||||
return null;
|
||||
}
|
||||
$classReflection = $scope->getClassReflection();
|
||||
if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) {
|
||||
return null;
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'fd7667b5aa8a17d28e61016463575eb4629744b1';
|
||||
public const PACKAGE_VERSION = 'dae413184be4437f111a45fd99746454115cd8ab';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-02-05 12:30:11';
|
||||
public const RELEASE_DATE = '2022-02-05 12:51:30';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20220205\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
@ -8,6 +8,9 @@ use Rector\Core\DependencyInjection\Collector\ConfigureCallValuesCollector;
|
||||
use RectorPrefix20220205\Symfony\Component\Config\FileLocatorInterface;
|
||||
use RectorPrefix20220205\Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use RectorPrefix20220205\Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
/**
|
||||
* @property-read ContainerBuilder $container
|
||||
*/
|
||||
final class ConfigurableCallValuesCollectingPhpFileLoader extends \RectorPrefix20220205\Symfony\Component\DependencyInjection\Loader\PhpFileLoader
|
||||
{
|
||||
/**
|
||||
@ -45,9 +48,6 @@ final class ConfigurableCallValuesCollectingPhpFileLoader extends \RectorPrefix2
|
||||
private function collectConfigureCallsFromJustImportedConfigurableRectorDefinitions() : void
|
||||
{
|
||||
foreach ($this->container->getDefinitions() as $class => $definition) {
|
||||
if (!\is_string($class)) {
|
||||
continue;
|
||||
}
|
||||
if (!\is_a($class, \Rector\Core\Contract\Rector\ConfigurableRectorInterface::class, \true)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ final class AssignManipulator
|
||||
{
|
||||
$previousNode = $node;
|
||||
$parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
while ($parentNode !== null && !$parentNode instanceof \PhpParser\Node\Stmt\Expression) {
|
||||
while ($parentNode instanceof \PhpParser\Node && !$parentNode instanceof \PhpParser\Node\Stmt\Expression) {
|
||||
if ($parentNode instanceof \PhpParser\Node\Expr\Assign && $this->nodeComparator->areNodesEqual($parentNode->var, $previousNode)) {
|
||||
return \true;
|
||||
}
|
||||
|
@ -125,6 +125,7 @@ final class IfManipulator
|
||||
$currentIf = $if;
|
||||
while ($this->isIfWithOnlyStmtIf($currentIf)) {
|
||||
$ifs[] = $currentIf;
|
||||
/** @var If_ $currentIf */
|
||||
$currentIf = $currentIf->stmts[0];
|
||||
}
|
||||
if ($ifs === []) {
|
||||
@ -193,6 +194,7 @@ final class IfManipulator
|
||||
$currentIf = $onlyForeachStmt;
|
||||
while ($this->isIfWithOnlyStmtIf($currentIf)) {
|
||||
$ifs[] = $currentIf;
|
||||
/** @var If_ $currentIf */
|
||||
$currentIf = $currentIf->stmts[0];
|
||||
}
|
||||
// IfManipulator is not build to handle elseif and else
|
||||
|
@ -293,21 +293,21 @@ final class BetterNodeFinder
|
||||
public function findFirstPrevious(\PhpParser\Node $node, callable $filter) : ?\PhpParser\Node
|
||||
{
|
||||
$node = $node instanceof \PhpParser\Node\Stmt\Expression ? $node : $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if ($node === null) {
|
||||
if (!$node instanceof \PhpParser\Node) {
|
||||
return null;
|
||||
}
|
||||
$foundNode = $this->findFirst([$node], $filter);
|
||||
// we found what we need
|
||||
if ($foundNode !== null) {
|
||||
if ($foundNode instanceof \PhpParser\Node) {
|
||||
return $foundNode;
|
||||
}
|
||||
// move to previous expression
|
||||
$previousStatement = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_STATEMENT);
|
||||
if ($previousStatement !== null) {
|
||||
if ($previousStatement instanceof \PhpParser\Node) {
|
||||
return $this->findFirstPrevious($previousStatement, $filter);
|
||||
}
|
||||
$parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
if ($parent === null) {
|
||||
if (!$parent instanceof \PhpParser\Node) {
|
||||
return null;
|
||||
}
|
||||
return $this->findFirstPrevious($parent, $filter);
|
||||
|
@ -4,6 +4,7 @@ declare (strict_types=1);
|
||||
namespace Rector\Core\PhpParser\Printer;
|
||||
|
||||
use RectorPrefix20220205\Nette\Utils\Strings;
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
@ -377,6 +378,7 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard
|
||||
if (!$parentNode->hasAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENT_CLOSURE_RETURN_MIRRORED)) {
|
||||
return $content;
|
||||
}
|
||||
/** @var Comment[] $comments */
|
||||
$comments = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS) ?? [];
|
||||
if ($comments === []) {
|
||||
return $content;
|
||||
|
@ -246,6 +246,7 @@ abstract class AbstractRector extends \PhpParser\NodeVisitorAbstract implements
|
||||
if ($node === null) {
|
||||
return null;
|
||||
}
|
||||
/** @var Node $originalNode */
|
||||
if (\is_array($node)) {
|
||||
$this->createdByRule($node, $originalNode);
|
||||
$originalNodeHash = \spl_object_hash($originalNode);
|
||||
|
@ -61,6 +61,10 @@ final class SystemError implements \RectorPrefix20220205\Symplify\EasyParallel\C
|
||||
{
|
||||
return $this->relativeFilePath . ':' . $this->line;
|
||||
}
|
||||
public function getRelativeFilePath() : ?string
|
||||
{
|
||||
return $this->relativeFilePath;
|
||||
}
|
||||
/**
|
||||
* @return array{message: string, relative_file_path: string|null, line: int|null, rector_class: string|null}
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707::getLoader();
|
||||
return ComposerAutoloaderInit7ee6f613a7a5701e3d648cb3fb36d387::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 ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707
|
||||
class ComposerAutoloaderInit7ee6f613a7a5701e3d648cb3fb36d387
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit7ee6f613a7a5701e3d648cb3fb36d387', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit7ee6f613a7a5701e3d648cb3fb36d387', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitf39785332fd75ed91a3d1878ff255707::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit7ee6f613a7a5701e3d648cb3fb36d387::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,12 +42,12 @@ class ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitf39785332fd75ed91a3d1878ff255707::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit7ee6f613a7a5701e3d648cb3fb36d387::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequiref39785332fd75ed91a3d1878ff255707($fileIdentifier, $file);
|
||||
composerRequire7ee6f613a7a5701e3d648cb3fb36d387($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -59,7 +59,7 @@ class ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequiref39785332fd75ed91a3d1878ff255707($fileIdentifier, $file)
|
||||
function composerRequire7ee6f613a7a5701e3d648cb3fb36d387($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 ComposerStaticInitf39785332fd75ed91a3d1878ff255707
|
||||
class ComposerStaticInit7ee6f613a7a5701e3d648cb3fb36d387
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
@ -3864,9 +3864,9 @@ class ComposerStaticInitf39785332fd75ed91a3d1878ff255707
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitf39785332fd75ed91a3d1878ff255707::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitf39785332fd75ed91a3d1878ff255707::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitf39785332fd75ed91a3d1878ff255707::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit7ee6f613a7a5701e3d648cb3fb36d387::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit7ee6f613a7a5701e3d648cb3fb36d387::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit7ee6f613a7a5701e3d648cb3fb36d387::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
|
||||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20220205\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707', false) && !interface_exists('ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707', false) && !trait_exists('ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707', false)) {
|
||||
spl_autoload_call('RectorPrefix20220205\ComposerAutoloaderInitf39785332fd75ed91a3d1878ff255707');
|
||||
if (!class_exists('ComposerAutoloaderInit7ee6f613a7a5701e3d648cb3fb36d387', false) && !interface_exists('ComposerAutoloaderInit7ee6f613a7a5701e3d648cb3fb36d387', false) && !trait_exists('ComposerAutoloaderInit7ee6f613a7a5701e3d648cb3fb36d387', false)) {
|
||||
spl_autoload_call('RectorPrefix20220205\ComposerAutoloaderInit7ee6f613a7a5701e3d648cb3fb36d387');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20220205\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -71,9 +71,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220205\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequiref39785332fd75ed91a3d1878ff255707')) {
|
||||
function composerRequiref39785332fd75ed91a3d1878ff255707() {
|
||||
return \RectorPrefix20220205\composerRequiref39785332fd75ed91a3d1878ff255707(...func_get_args());
|
||||
if (!function_exists('composerRequire7ee6f613a7a5701e3d648cb3fb36d387')) {
|
||||
function composerRequire7ee6f613a7a5701e3d648cb3fb36d387() {
|
||||
return \RectorPrefix20220205\composerRequire7ee6f613a7a5701e3d648cb3fb36d387(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user