diff --git a/rules/CodeQuality/Rector/FuncCall/ArrayKeysAndInArrayToArrayKeyExistsRector.php b/rules/CodeQuality/Rector/FuncCall/ArrayKeysAndInArrayToArrayKeyExistsRector.php index 016c4739b66..bc3bef830a1 100644 --- a/rules/CodeQuality/Rector/FuncCall/ArrayKeysAndInArrayToArrayKeyExistsRector.php +++ b/rules/CodeQuality/Rector/FuncCall/ArrayKeysAndInArrayToArrayKeyExistsRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\CodeQuality\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\FuncCall; @@ -78,19 +77,13 @@ CODE_SAMPLE } private function createArrayKeyExists(FuncCall $inArrayFuncCall, FuncCall $arrayKeysFuncCall) : ?FuncCall { - if (!isset($inArrayFuncCall->args[0])) { + if (!isset($inArrayFuncCall->getArgs()[0])) { return null; } - if (!$inArrayFuncCall->args[0] instanceof Arg) { + if (!isset($arrayKeysFuncCall->getArgs()[0])) { return null; } - if (!isset($arrayKeysFuncCall->args[0])) { - return null; - } - if (!$arrayKeysFuncCall->args[0] instanceof Arg) { - return null; - } - $arguments = [$inArrayFuncCall->args[0], $arrayKeysFuncCall->args[0]]; + $arguments = [$inArrayFuncCall->getArgs()[0], $arrayKeysFuncCall->getArgs()[0]]; return new FuncCall(new Name('array_key_exists'), $arguments); } /** diff --git a/rules/CodeQuality/Rector/FuncCall/BoolvalToTypeCastRector.php b/rules/CodeQuality/Rector/FuncCall/BoolvalToTypeCastRector.php index ac2dfa7e7d9..cdc4948ab82 100644 --- a/rules/CodeQuality/Rector/FuncCall/BoolvalToTypeCastRector.php +++ b/rules/CodeQuality/Rector/FuncCall/BoolvalToTypeCastRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\CodeQuality\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\Cast\Bool_; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; @@ -52,12 +51,9 @@ CODE_SAMPLE if (!$this->isName($node, 'boolval')) { return null; } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - return new Bool_($node->args[0]->value); + return new Bool_($node->getArgs()[0]->value); } } diff --git a/rules/CodeQuality/Rector/FuncCall/FloatvalToTypeCastRector.php b/rules/CodeQuality/Rector/FuncCall/FloatvalToTypeCastRector.php index 677942579f1..eafd834e5bc 100644 --- a/rules/CodeQuality/Rector/FuncCall/FloatvalToTypeCastRector.php +++ b/rules/CodeQuality/Rector/FuncCall/FloatvalToTypeCastRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\CodeQuality\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\Cast\Double; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; @@ -63,13 +62,11 @@ CODE_SAMPLE if (!\in_array($methodName, self::VAL_FUNCTION_NAMES, \true)) { return null; } - if (!isset($node->args[0])) { - return null; - } - if (!$node->args[0] instanceof Arg) { - return null; - } - $double = new Double($node->args[0]->value); + // if (! isset($node->getArgs[0])) { + // return null; + // } + $firstArg = $node->getArgs()[0]; + $double = new Double($firstArg->value); $double->setAttribute(AttributeKey::KIND, Double::KIND_FLOAT); return $double; } diff --git a/rules/CodeQuality/Rector/FuncCall/IntvalToTypeCastRector.php b/rules/CodeQuality/Rector/FuncCall/IntvalToTypeCastRector.php index 88859ea260a..83a47accd30 100644 --- a/rules/CodeQuality/Rector/FuncCall/IntvalToTypeCastRector.php +++ b/rules/CodeQuality/Rector/FuncCall/IntvalToTypeCastRector.php @@ -61,12 +61,9 @@ CODE_SAMPLE return null; } } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - return new Int_($node->args[0]->value); + return new Int_($node->getArgs()[0]->value); } } diff --git a/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php b/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php index 5da066e357b..93b7bd8f6ac 100644 --- a/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php +++ b/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php @@ -51,13 +51,11 @@ CODE_SAMPLE if (!$this->isName($node, 'is_a')) { return null; } - if (isset($node->args[2])) { + if (isset($node->getArgs()[2])) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - $firstArgumentStaticType = $this->getType($node->args[0]->value); + $firstArg = $node->getArgs()[0]; + $firstArgumentStaticType = $this->getType($firstArg->value); if (!$firstArgumentStaticType->isString()->yes()) { return null; } diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php index 114fa0790f5..0b82b9b7d00 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\CodeQuality\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; @@ -33,14 +32,12 @@ final class SimplifyFuncGetArgsCountRector extends AbstractRector if (!$this->isName($node, 'count')) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - if (!$node->args[0]->value instanceof FuncCall) { + $firstArg = $node->getArgs()[0]; + if (!$firstArg->value instanceof FuncCall) { return null; } /** @var FuncCall $innerFuncCall */ - $innerFuncCall = $node->args[0]->value; + $innerFuncCall = $firstArg->value; if (!$this->isName($innerFuncCall, 'func_get_args')) { return null; } diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php index fd16d7d88d8..1c7109a3af1 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php @@ -47,13 +47,10 @@ final class SimplifyInArrayValuesRector extends AbstractRector if (!$this->isName($innerFunCall, 'array_values')) { return null; } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - $node->args[1] = $innerFunCall->args[0]; + $node->args[1] = $innerFunCall->getArgs()[0]; return $node; } } diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php index 199a2e30f07..3902a69c433 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\CodeQuality\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; @@ -34,22 +33,20 @@ final class SimplifyStrposLowerRector extends AbstractRector if (!$this->isName($node, 'strpos')) { return null; } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - if (!$node->args[0]->value instanceof FuncCall) { + $firstArg = $node->getArgs()[0]; + if (!$firstArg->value instanceof FuncCall) { return null; } /** @var FuncCall $innerFuncCall */ - $innerFuncCall = $node->args[0]->value; + $innerFuncCall = $firstArg->value; if (!$this->isName($innerFuncCall, 'strtolower')) { return null; } // pop 1 level up - $node->args[0] = $innerFuncCall->args[0]; + $node->args[0] = $innerFuncCall->getArgs()[0]; $node->name = new Name('stripos'); return $node; } diff --git a/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php b/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php index 09ec37fb784..875e4baaa54 100644 --- a/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php @@ -80,17 +80,15 @@ CODE_SAMPLE if ($firstArrayItem->unpack) { return null; } - if (!isset($node->args[0])) { - return null; - } - if (!$node->args[0] instanceof Arg) { + if (!isset($node->getArgs()[0])) { return null; } $firstArrayItemValue = $firstArrayItem->value; + $firstArg = $node->getArgs()[0]; // strict - if (isset($node->args[2])) { - return new Identical($node->args[0]->value, $firstArrayItemValue); + if (isset($node->getArgs()[2])) { + return new Identical($firstArg->value, $firstArrayItemValue); } - return new Equal($node->args[0]->value, $firstArrayItemValue); + return new Equal($firstArg->value, $firstArrayItemValue); } } diff --git a/rules/CodeQuality/Rector/FuncCall/StrvalToTypeCastRector.php b/rules/CodeQuality/Rector/FuncCall/StrvalToTypeCastRector.php index 7c9f34ab986..3527cb9c797 100644 --- a/rules/CodeQuality/Rector/FuncCall/StrvalToTypeCastRector.php +++ b/rules/CodeQuality/Rector/FuncCall/StrvalToTypeCastRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\CodeQuality\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\Cast\String_; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; @@ -52,12 +51,9 @@ CODE_SAMPLE if (!$this->isName($node, 'strval')) { return null; } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - return new String_($node->args[0]->value); + return new String_($node->getArgs()[0]->value); } } diff --git a/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php b/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php index 83a1718f86b..3fb3547085e 100644 --- a/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php +++ b/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\CodeQuality\Rector\Identical; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\BinaryOp\Identical; use PhpParser\Node\Expr\BinaryOp\NotIdentical; use PhpParser\Node\Expr\BooleanNot; @@ -66,13 +65,11 @@ final class GetClassToInstanceOfRector extends AbstractRector $firstExpr = $twoNodeMatch->getFirstExpr(); /** @var FuncCall $secondExpr */ $secondExpr = $twoNodeMatch->getSecondExpr(); - if (!isset($secondExpr->args[0])) { + if (!isset($secondExpr->getArgs()[0])) { return null; } - if (!$secondExpr->args[0] instanceof Arg) { - return null; - } - $varNode = $secondExpr->args[0]->value; + $firstArg = $secondExpr->getArgs()[0]; + $varNode = $firstArg->value; if ($firstExpr instanceof String_) { $className = $this->valueResolver->getValue($firstExpr); } else { diff --git a/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php b/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php index c5677ad66b2..145fffcf8d5 100644 --- a/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php +++ b/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\CodingStyle\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\MethodCall; @@ -65,13 +64,10 @@ CODE_SAMPLE if (!$this->isName($node, 'call_user_func')) { return null; } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - $firstArgValue = $node->args[0]->value; + $firstArgValue = $node->getArgs()[0]->value; if (!$firstArgValue instanceof Array_) { return null; } diff --git a/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php b/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php index 38502c64df6..0914d63288f 100644 --- a/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php +++ b/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\CodingStyle\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\BinaryOp\Greater; @@ -57,14 +56,11 @@ CODE_SAMPLE if (!$this->isName($node, 'count')) { return null; } - if (!isset($node->args[0])) { - return null; - } - if (!$node->args[0] instanceof Arg) { + if (!isset($node->getArgs()[0])) { return null; } /** @var Expr $expr */ - $expr = $node->args[0]->value; + $expr = $node->getArgs()[0]->value; // not pass array type, skip if (!$this->isArray($expr)) { return null; @@ -88,17 +84,15 @@ CODE_SAMPLE if (!$booleanNot->expr instanceof FuncCall) { return null; } - if (!$this->isName($booleanNot->expr, 'count')) { + $funcCall = $booleanNot->expr; + if (!$this->isName($funcCall, 'count')) { return null; } - if (!isset($booleanNot->expr->args[0])) { - return null; - } - if (!$booleanNot->expr->args[0] instanceof Arg) { + if (!isset($funcCall->getArgs()[0])) { return null; } /** @var Expr $expr */ - $expr = $booleanNot->expr->args[0]->value; + $expr = $funcCall->getArgs()[0]->value; // not pass array type, skip if (!$this->isArray($expr)) { return null; diff --git a/rules/DeadCode/NodeManipulator/CountManipulator.php b/rules/DeadCode/NodeManipulator/CountManipulator.php index cc69510c17e..c08276c75a9 100644 --- a/rules/DeadCode/NodeManipulator/CountManipulator.php +++ b/rules/DeadCode/NodeManipulator/CountManipulator.php @@ -3,7 +3,6 @@ declare (strict_types=1); namespace Rector\DeadCode\NodeManipulator; -use PhpParser\Node\Arg; use PhpParser\Node\Expr; use PhpParser\Node\Expr\BinaryOp\Greater; use PhpParser\Node\Expr\BinaryOp\GreaterOrEqual; @@ -93,13 +92,10 @@ final class CountManipulator if (!$this->nodeNameResolver->isName($node, 'count')) { return \false; } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return \false; } - if (!$node->args[0] instanceof Arg) { - return \false; - } - $countedExpr = $node->args[0]->value; + $countedExpr = $node->getArgs()[0]->value; return $this->nodeComparator->areNodesEqual($countedExpr, $expr); } } diff --git a/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php b/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php index 902e4cb20e4..365f2ba6a99 100644 --- a/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php +++ b/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\MysqlToMysqli\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr; use PhpParser\Node\Expr\BinaryOp\Concat; use PhpParser\Node\Expr\FuncCall; @@ -56,14 +55,11 @@ CODE_SAMPLE if (!$this->isName($node, 'mysql_pconnect')) { return null; } - if (!isset($node->args[0])) { - return null; - } - if (!$node->args[0] instanceof Arg) { + if (!isset($node->getArgs()[0])) { return null; } $node->name = new Name('mysqli_connect'); - $node->args[0]->value = $this->joinStringWithNode('p:', $node->args[0]->value); + $node->args[0]->value = $this->joinStringWithNode('p:', $node->getArgs()[0]->value); return $node; } /** diff --git a/rules/Naming/Naming/VariableNaming.php b/rules/Naming/Naming/VariableNaming.php index 71b84604159..13c0ca52683 100644 --- a/rules/Naming/Naming/VariableNaming.php +++ b/rules/Naming/Naming/VariableNaming.php @@ -163,13 +163,10 @@ final class VariableNaming } private function resolveBareFuncCallArgumentName(FuncCall $funcCall, string $fallbackName, string $suffix) : string { - if (!isset($funcCall->args[0])) { + if (!isset($funcCall->getArgs()[0])) { return ''; } - if (!$funcCall->args[0] instanceof Arg) { - return ''; - } - $argumentValue = $funcCall->args[0]->value; + $argumentValue = $funcCall->getArgs()[0]->value; if ($argumentValue instanceof MethodCall || $argumentValue instanceof StaticCall) { $name = $this->nodeNameResolver->getName($argumentValue->name); } else { diff --git a/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php b/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php index d74502eb4ce..563f900aa3a 100644 --- a/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php +++ b/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\Php53\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Scalar\MagicConst\Dir; use PhpParser\Node\Scalar\MagicConst\File; @@ -58,14 +57,11 @@ CODE_SAMPLE if (\count($node->args) !== 1) { return null; } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - $firstArgValue = $node->args[0]->value; - if (!$firstArgValue instanceof File) { + $firstArg = $node->getArgs()[0]; + if (!$firstArg->value instanceof File) { return null; } return new Dir(); diff --git a/rules/Php71/IsArrayAndDualCheckToAble.php b/rules/Php71/IsArrayAndDualCheckToAble.php index ce901ff7753..b169370f370 100644 --- a/rules/Php71/IsArrayAndDualCheckToAble.php +++ b/rules/Php71/IsArrayAndDualCheckToAble.php @@ -56,13 +56,11 @@ final class IsArrayAndDualCheckToAble if (!$this->nodeNameResolver->isName($funcCallExpr, 'is_array')) { return null; } - if (!isset($funcCallExpr->args[0])) { + if (!isset($funcCallExpr->getArgs()[0])) { return null; } - if (!$funcCallExpr->args[0] instanceof Arg) { - return null; - } - $firstExprNode = $funcCallExpr->args[0]->value; + $firstArg = $funcCallExpr->getArgs()[0]; + $firstExprNode = $firstArg->value; if (!$this->nodeComparator->areNodesEqual($instanceofExpr->expr, $firstExprNode)) { return null; } diff --git a/rules/Php71/Rector/FuncCall/CountOnNullRector.php b/rules/Php71/Rector/FuncCall/CountOnNullRector.php index 4bd278b80b3..d22d237bffb 100644 --- a/rules/Php71/Rector/FuncCall/CountOnNullRector.php +++ b/rules/Php71/Rector/FuncCall/CountOnNullRector.php @@ -151,13 +151,11 @@ CODE_SAMPLE if (!$this->isName($funcCall, 'count')) { return \true; } - if (!isset($funcCall->args[0])) { + if (!isset($funcCall->getArgs()[0])) { return \true; } - if (!$funcCall->args[0] instanceof Arg) { - return \true; - } - if ($funcCall->args[0]->value instanceof ClassConstFetch) { + $firstArg = $funcCall->getArgs()[0]; + if ($firstArg->value instanceof ClassConstFetch) { return \true; } $parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE); diff --git a/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php b/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php index f1b0a5cdb85..51e0cacbfcb 100644 --- a/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php +++ b/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php @@ -72,14 +72,11 @@ CODE_SAMPLE } /** @var FuncCall $eachFuncCall */ $eachFuncCall = $assign->expr; - if (!isset($eachFuncCall->args[0])) { + if (!isset($eachFuncCall->getArgs()[0])) { return null; } - if (!$eachFuncCall->args[0] instanceof Arg) { - return null; - } - $eachedVariable = $eachFuncCall->args[0]->value; $assignVariable = $assign->var; + $eachedVariable = $eachFuncCall->getArgs()[0]->value; return $this->createNewStmts($assignVariable, $eachedVariable); } private function shouldSkip(Assign $assign) : bool diff --git a/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php b/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php index a307c20168a..19fbe74dd17 100644 --- a/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php +++ b/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php @@ -68,13 +68,11 @@ CODE_SAMPLE if (!$this->isName($node, 'get_class')) { return null; } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - $firstArgValue = $node->args[0]->value; + $firstArg = $node->getArgs()[0]; + $firstArgValue = $firstArg->value; if (!$scope->isInClass()) { return null; } @@ -124,16 +122,13 @@ CODE_SAMPLE if (!$ternary->cond instanceof Identical) { return \false; } - if (!isset($funcCall->args[0])) { + if (!isset($funcCall->getArgs()[0])) { return \false; } - if (!$funcCall->args[0] instanceof Arg) { - return \false; - } - if ($this->nodeComparator->areNodesEqual($ternary->cond->left, $funcCall->args[0]->value) && !$this->valueResolver->isNull($ternary->cond->right)) { + if ($this->nodeComparator->areNodesEqual($ternary->cond->left, $funcCall->getArgs()[0]->value) && !$this->valueResolver->isNull($ternary->cond->right)) { return \true; } - if (!$this->nodeComparator->areNodesEqual($ternary->cond->right, $funcCall->args[0]->value)) { + if (!$this->nodeComparator->areNodesEqual($ternary->cond->right, $funcCall->getArgs()[0]->value)) { return \false; } return !$this->valueResolver->isNull($ternary->cond->left); diff --git a/rules/Php72/Rector/FuncCall/IsObjectOnIncompleteClassRector.php b/rules/Php72/Rector/FuncCall/IsObjectOnIncompleteClassRector.php index dc6e58f0683..0cc42be4f9e 100644 --- a/rules/Php72/Rector/FuncCall/IsObjectOnIncompleteClassRector.php +++ b/rules/Php72/Rector/FuncCall/IsObjectOnIncompleteClassRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\Php72\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\FuncCall; use PHPStan\Type\ObjectType; @@ -53,16 +52,14 @@ CODE_SAMPLE return null; } $incompleteClassObjectType = new ObjectType('__PHP_Incomplete_Class'); - if (!isset($node->args[0])) { - return null; - } - if (!$node->args[0] instanceof Arg) { + if (!isset($node->getArgs()[0])) { return null; } if ($this->shouldSkip($node)) { return null; } - if (!$this->isObjectType($node->args[0]->value, $incompleteClassObjectType)) { + $firstArg = $node->getArgs()[0]; + if (!$this->isObjectType($firstArg->value, $incompleteClassObjectType)) { return null; } return new BooleanNot($node); diff --git a/rules/Php72/Rector/FuncCall/StringifyDefineRector.php b/rules/Php72/Rector/FuncCall/StringifyDefineRector.php index 36b34332f22..3ae057cd5a7 100644 --- a/rules/Php72/Rector/FuncCall/StringifyDefineRector.php +++ b/rules/Php72/Rector/FuncCall/StringifyDefineRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\Php72\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\ConstFetch; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Scalar\String_; @@ -72,21 +71,19 @@ CODE_SAMPLE if (!$this->isName($node, 'define')) { return null; } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return null; } - if (!$node->args[0] instanceof Arg) { + $firstArg = $node->getArgs()[0]; + if ($this->stringTypeAnalyzer->isStringOrUnionStringOnlyType($firstArg->value)) { return null; } - if ($this->stringTypeAnalyzer->isStringOrUnionStringOnlyType($node->args[0]->value)) { - return null; - } - if ($node->args[0]->value instanceof ConstFetch) { - $nodeName = $this->getName($node->args[0]->value); + if ($firstArg->value instanceof ConstFetch) { + $nodeName = $this->getName($firstArg->value); if ($nodeName === null) { return null; } - $node->args[0]->value = new String_($nodeName); + $firstArg->value = new String_($nodeName); } return $node; } diff --git a/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php b/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php index 2d4cc91e92d..d7048a02c23 100644 --- a/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php +++ b/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php @@ -67,10 +67,8 @@ CODE_SAMPLE if (!$this->isName($node, 'assert')) { return null; } - if (!$node->args[0] instanceof Arg) { - return null; - } - $firstArgValue = $node->args[0]->value; + $firstArg = $node->getArgs()[0]; + $firstArgValue = $firstArg->value; if (!$firstArgValue instanceof String_) { return null; } diff --git a/rules/Php72/Rector/While_/WhileEachToForeachRector.php b/rules/Php72/Rector/While_/WhileEachToForeachRector.php index a8cbbf1d6d9..9a8691c7f2a 100644 --- a/rules/Php72/Rector/While_/WhileEachToForeachRector.php +++ b/rules/Php72/Rector/While_/WhileEachToForeachRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\Php72\Rector\While_; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\ArrayItem; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\FuncCall; @@ -85,13 +84,11 @@ CODE_SAMPLE $eachFuncCall = $assignNode->expr; /** @var List_ $listNode */ $listNode = $assignNode->var; - if (!isset($eachFuncCall->args[0])) { + if (!isset($eachFuncCall->getArgs()[0])) { return null; } - if (!$eachFuncCall->args[0] instanceof Arg) { - return null; - } - $foreachedExpr = \count($listNode->items) === 1 ? $this->nodeFactory->createFuncCall('array_keys', [$eachFuncCall->args[0]]) : $eachFuncCall->args[0]->value; + $firstArg = $eachFuncCall->args[0]; + $foreachedExpr = \count($listNode->items) === 1 ? $this->nodeFactory->createFuncCall('array_keys', [$firstArg]) : $firstArg->value; $arrayItem = \array_pop($listNode->items); $isTrailingCommaLast = \false; if (!$arrayItem instanceof ArrayItem) { diff --git a/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php b/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php index 559c307b671..fb39f5c13bb 100644 --- a/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php +++ b/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php @@ -176,9 +176,6 @@ CODE_SAMPLE if (!$this->nodeNameResolver->isName($expr, 'iterator_to_array')) { return \false; } - if (!isset($expr->args[0])) { - return \false; - } - return $expr->args[0] instanceof Arg; + return isset($expr->getArgs()[0]); } } diff --git a/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php b/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php index 78c3c553ff8..1b2d6af3176 100644 --- a/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php +++ b/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\Php80\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; @@ -57,13 +56,10 @@ CODE_SAMPLE if (!$this->nodeNameResolver->isName($node, 'get_class')) { return null; } - if (!isset($node->args[0])) { + if (!isset($node->getArgs()[0])) { return new ClassConstFetch(new Name('self'), 'class'); } - if (!$node->args[0] instanceof Arg) { - return null; - } - $object = $node->args[0]->value; + $object = $node->getArgs()[0]->value; return new ClassConstFetch($object, 'class'); } public function provideMinPhpVersion() : int diff --git a/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php b/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php index acd6c6adcc4..c2f9d54a8bd 100644 --- a/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php +++ b/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\Transform\Rector\FuncCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\PropertyFetch; @@ -197,18 +196,15 @@ CODE_SAMPLE */ private function createMethodCallArrayFunctionToMethodCall(FuncCall $funcCall, ArrayFuncCallToMethodCall $arrayFuncCallToMethodCall, PropertyFetch $propertyFetch) : ?Node { - if ($funcCall->args === []) { + if ($funcCall->getArgs() === []) { return $propertyFetch; } - if (!$funcCall->args[0] instanceof Arg) { - return null; - } - if ($this->arrayTypeAnalyzer->isArrayType($funcCall->args[0]->value)) { - return new MethodCall($propertyFetch, $arrayFuncCallToMethodCall->getArrayMethod(), $funcCall->args); + if ($this->arrayTypeAnalyzer->isArrayType($funcCall->getArgs()[0]->value)) { + return new MethodCall($propertyFetch, $arrayFuncCallToMethodCall->getArrayMethod(), $funcCall->getArgs()); } if ($arrayFuncCallToMethodCall->getNonArrayMethod() === '') { return null; } - return new MethodCall($propertyFetch, $arrayFuncCallToMethodCall->getNonArrayMethod(), $funcCall->args); + return new MethodCall($propertyFetch, $arrayFuncCallToMethodCall->getNonArrayMethod(), $funcCall->getArgs()); } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 0e0dd3cf15f..1cf5163fbf4 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '103148c1af587421c31c68c6a7bc2ce623aaf7cf'; + public const PACKAGE_VERSION = '13d81f90894396f7e443cb5cb9198aeacb6bc05a'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-05-08 11:34:07'; + public const RELEASE_DATE = '2023-05-08 07:32:49'; /** * @var int */ diff --git a/src/NodeManipulator/ClassMethodAssignManipulator.php b/src/NodeManipulator/ClassMethodAssignManipulator.php index ad9dd6fd303..22ef678d37d 100644 --- a/src/NodeManipulator/ClassMethodAssignManipulator.php +++ b/src/NodeManipulator/ClassMethodAssignManipulator.php @@ -304,17 +304,15 @@ final class ClassMethodAssignManipulator if (!$node instanceof FuncCall) { return \false; } - if (!isset($node->args[0])) { - return \false; - } - if (!$node->args[0] instanceof Arg) { + if (!isset($node->getArgs()[0])) { return \false; } if (!$this->nodeNameResolver->isNames($node, ['array_shift', '*sort'])) { return \false; } // is 1st argument - return $node->args[0]->value !== $variable; + $firstArg = $node->getArgs()[0]; + return $firstArg->value !== $variable; } private function isConstructorWithReference(Node $node, int $argumentPosition) : bool { diff --git a/vendor/autoload.php b/vendor/autoload.php index adf35dd900a..50af8c43305 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitea719d688067d71c5e9ce19715a56549::getLoader(); +return ComposerAutoloaderInit861ab03aa616d1f38d85273839029a00::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index cca03e3a707..e724383c27d 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitea719d688067d71c5e9ce19715a56549 +class ComposerAutoloaderInit861ab03aa616d1f38d85273839029a00 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInitea719d688067d71c5e9ce19715a56549 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitea719d688067d71c5e9ce19715a56549', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit861ab03aa616d1f38d85273839029a00', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitea719d688067d71c5e9ce19715a56549', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit861ab03aa616d1f38d85273839029a00', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitea719d688067d71c5e9ce19715a56549::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit861ab03aa616d1f38d85273839029a00::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitea719d688067d71c5e9ce19715a56549::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit861ab03aa616d1f38d85273839029a00::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 2227dccc18a..89bf5bfa4da 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitea719d688067d71c5e9ce19715a56549 +class ComposerStaticInit861ab03aa616d1f38d85273839029a00 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3121,9 +3121,9 @@ class ComposerStaticInitea719d688067d71c5e9ce19715a56549 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitea719d688067d71c5e9ce19715a56549::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitea719d688067d71c5e9ce19715a56549::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitea719d688067d71c5e9ce19715a56549::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit861ab03aa616d1f38d85273839029a00::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit861ab03aa616d1f38d85273839029a00::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit861ab03aa616d1f38d85273839029a00::$classMap; }, null, ClassLoader::class); }