mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 13d81f90894396f7e443cb5cb9198aeacb6bc05a
13d81f9089
[Cleanup] Make use of getArgs() directly (#3766)
This commit is contained in:
parent
eebb3e5a4f
commit
a2c39b778e
|
@ -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);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitea719d688067d71c5e9ce19715a56549::getLoader();
|
||||
return ComposerAutoloaderInit861ab03aa616d1f38d85273839029a00::getLoader();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue