mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 13:28:18 +01:00
Updated Rector to commit 3aa886f88d54d440d107577996d65cd968c0c8b0
3aa886f88d
[deprecated] Remove deprecated ChangeAndIfToEarlyReturnRector, CallableThisArrayToAnonymousFunctionRector + casting rules (#6276)
This commit is contained in:
parent
da9d971829
commit
3936c30c7e
@ -1,127 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\CodeQuality\Rector\Array_;
|
|
||||||
|
|
||||||
use PhpParser\Node;
|
|
||||||
use PhpParser\Node\Expr\Array_;
|
|
||||||
use PhpParser\Node\Stmt\ClassConst;
|
|
||||||
use PhpParser\Node\Stmt\Property;
|
|
||||||
use PhpParser\NodeTraverser;
|
|
||||||
use PHPStan\Analyser\Scope;
|
|
||||||
use PHPStan\Reflection\Php\PhpMethodReflection;
|
|
||||||
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
|
|
||||||
use Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher;
|
|
||||||
use Rector\NodeCollector\ValueObject\ArrayCallable;
|
|
||||||
use Rector\Php72\NodeFactory\AnonymousFunctionFactory;
|
|
||||||
use Rector\Rector\AbstractScopeAwareRector;
|
|
||||||
use Rector\Reflection\ReflectionResolver;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|
||||||
/**
|
|
||||||
* @see \Rector\Tests\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector\CallableThisArrayToAnonymousFunctionRectorTest
|
|
||||||
*
|
|
||||||
* @deprecated This rule is surpassed by more advanced one
|
|
||||||
* Use @see FirstClassCallableRector instead
|
|
||||||
*/
|
|
||||||
final class CallableThisArrayToAnonymousFunctionRector extends AbstractScopeAwareRector implements DeprecatedInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\Php72\NodeFactory\AnonymousFunctionFactory
|
|
||||||
*/
|
|
||||||
private $anonymousFunctionFactory;
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\Reflection\ReflectionResolver
|
|
||||||
*/
|
|
||||||
private $reflectionResolver;
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher
|
|
||||||
*/
|
|
||||||
private $arrayCallableMethodMatcher;
|
|
||||||
public function __construct(AnonymousFunctionFactory $anonymousFunctionFactory, ReflectionResolver $reflectionResolver, ArrayCallableMethodMatcher $arrayCallableMethodMatcher)
|
|
||||||
{
|
|
||||||
$this->anonymousFunctionFactory = $anonymousFunctionFactory;
|
|
||||||
$this->reflectionResolver = $reflectionResolver;
|
|
||||||
$this->arrayCallableMethodMatcher = $arrayCallableMethodMatcher;
|
|
||||||
}
|
|
||||||
public function getRuleDefinition() : RuleDefinition
|
|
||||||
{
|
|
||||||
return new RuleDefinition('Convert [$this, "method"] to proper anonymous function', [new CodeSample(<<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function run()
|
|
||||||
{
|
|
||||||
$values = [1, 5, 3];
|
|
||||||
usort($values, [$this, 'compareSize']);
|
|
||||||
|
|
||||||
return $values;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function compareSize($first, $second)
|
|
||||||
{
|
|
||||||
return $first <=> $second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
, <<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function run()
|
|
||||||
{
|
|
||||||
$values = [1, 5, 3];
|
|
||||||
usort($values, function ($first, $second) {
|
|
||||||
return $this->compareSize($first, $second);
|
|
||||||
});
|
|
||||||
|
|
||||||
return $values;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function compareSize($first, $second)
|
|
||||||
{
|
|
||||||
return $first <=> $second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
)]);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return array<class-string<Node>>
|
|
||||||
*/
|
|
||||||
public function getNodeTypes() : array
|
|
||||||
{
|
|
||||||
return [Property::class, ClassConst::class, Array_::class];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param Property|ClassConst|Array_ $node
|
|
||||||
* @return null|int|\PhpParser\Node
|
|
||||||
*/
|
|
||||||
public function refactorWithScope(Node $node, Scope $scope)
|
|
||||||
{
|
|
||||||
if ($node instanceof Property || $node instanceof ClassConst) {
|
|
||||||
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
|
|
||||||
}
|
|
||||||
if ($this->shouldSkipTwigExtension($scope)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$arrayCallable = $this->arrayCallableMethodMatcher->match($node, $scope);
|
|
||||||
if (!$arrayCallable instanceof ArrayCallable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$phpMethodReflection = $this->reflectionResolver->resolveMethodReflection($arrayCallable->getClass(), $arrayCallable->getMethod(), $scope);
|
|
||||||
if (!$phpMethodReflection instanceof PhpMethodReflection) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $this->anonymousFunctionFactory->createFromPhpMethodReflection($phpMethodReflection, $arrayCallable->getCallerExpr());
|
|
||||||
}
|
|
||||||
private function shouldSkipTwigExtension(Scope $scope) : bool
|
|
||||||
{
|
|
||||||
if (!$scope->isInClass()) {
|
|
||||||
return \false;
|
|
||||||
}
|
|
||||||
$classReflection = $scope->getClassReflection();
|
|
||||||
return $classReflection->isSubclassOf('Twig\\Extension\\ExtensionInterface');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\CodeQuality\Rector\FuncCall;
|
|
||||||
|
|
||||||
use PhpParser\Node;
|
|
||||||
use PhpParser\Node\Expr\Cast\Bool_;
|
|
||||||
use PhpParser\Node\Expr\FuncCall;
|
|
||||||
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
|
|
||||||
use Rector\Rector\AbstractRector;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|
||||||
/**
|
|
||||||
* @deprecated Since 1.1.2 as no clear performance difference and both are equivalent.
|
|
||||||
*/
|
|
||||||
final class BoolvalToTypeCastRector extends AbstractRector implements DeprecatedInterface
|
|
||||||
{
|
|
||||||
public function getRuleDefinition() : RuleDefinition
|
|
||||||
{
|
|
||||||
return new RuleDefinition('Change boolval() to faster and readable (bool) $value', [new CodeSample(<<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function run($value)
|
|
||||||
{
|
|
||||||
return boolval($value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
, <<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function run($value)
|
|
||||||
{
|
|
||||||
return (bool) $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
)]);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return array<class-string<Node>>
|
|
||||||
*/
|
|
||||||
public function getNodeTypes() : array
|
|
||||||
{
|
|
||||||
return [FuncCall::class];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param FuncCall $node
|
|
||||||
*/
|
|
||||||
public function refactor(Node $node) : ?Node
|
|
||||||
{
|
|
||||||
if ($node->isFirstClassCallable()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!$this->isName($node, 'boolval')) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!isset($node->getArgs()[0])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Bool_($node->getArgs()[0]->value);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\CodeQuality\Rector\FuncCall;
|
|
||||||
|
|
||||||
use PhpParser\Node;
|
|
||||||
use PhpParser\Node\Expr\Cast\Double;
|
|
||||||
use PhpParser\Node\Expr\FuncCall;
|
|
||||||
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
|
|
||||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
|
||||||
use Rector\Rector\AbstractRector;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|
||||||
/**
|
|
||||||
* @deprecated Since 1.1.2 as no clear performance difference and both are equivalent.
|
|
||||||
*/
|
|
||||||
final class FloatvalToTypeCastRector extends AbstractRector implements DeprecatedInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
private const VAL_FUNCTION_NAMES = ['floatval', 'doubleval'];
|
|
||||||
public function getRuleDefinition() : RuleDefinition
|
|
||||||
{
|
|
||||||
return new RuleDefinition('Change floatval() and doubleval() to faster and readable (float) $value', [new CodeSample(<<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function run($value)
|
|
||||||
{
|
|
||||||
$a = floatval($value);
|
|
||||||
$b = doubleval($value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
, <<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function run($value)
|
|
||||||
{
|
|
||||||
$a = (float) $value;
|
|
||||||
$b = (float) $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
)]);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return array<class-string<Node>>
|
|
||||||
*/
|
|
||||||
public function getNodeTypes() : array
|
|
||||||
{
|
|
||||||
return [FuncCall::class];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param FuncCall $node
|
|
||||||
*/
|
|
||||||
public function refactor(Node $node) : ?Node
|
|
||||||
{
|
|
||||||
$methodName = $this->getName($node);
|
|
||||||
if ($methodName === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!\in_array($methodName, self::VAL_FUNCTION_NAMES, \true)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if ($node->isFirstClassCallable()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$firstArg = $node->getArgs()[0];
|
|
||||||
$double = new Double($firstArg->value);
|
|
||||||
$double->setAttribute(AttributeKey::KIND, Double::KIND_FLOAT);
|
|
||||||
return $double;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\CodeQuality\Rector\FuncCall;
|
|
||||||
|
|
||||||
use PhpParser\Node;
|
|
||||||
use PhpParser\Node\Arg;
|
|
||||||
use PhpParser\Node\Expr\Cast\Int_;
|
|
||||||
use PhpParser\Node\Expr\FuncCall;
|
|
||||||
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
|
|
||||||
use Rector\PhpParser\Node\Value\ValueResolver;
|
|
||||||
use Rector\Rector\AbstractRector;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|
||||||
/**
|
|
||||||
* @deprecated Since 1.1.2 as no clear performance difference and both are equivalent.
|
|
||||||
*/
|
|
||||||
final class IntvalToTypeCastRector extends AbstractRector implements DeprecatedInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\PhpParser\Node\Value\ValueResolver
|
|
||||||
*/
|
|
||||||
private $valueResolver;
|
|
||||||
public function __construct(ValueResolver $valueResolver)
|
|
||||||
{
|
|
||||||
$this->valueResolver = $valueResolver;
|
|
||||||
}
|
|
||||||
public function getRuleDefinition() : RuleDefinition
|
|
||||||
{
|
|
||||||
return new RuleDefinition('Change intval() to faster and readable (int) $value', [new CodeSample(<<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function run($value)
|
|
||||||
{
|
|
||||||
return intval($value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
, <<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function run($value)
|
|
||||||
{
|
|
||||||
return (int) $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
)]);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return array<class-string<Node>>
|
|
||||||
*/
|
|
||||||
public function getNodeTypes() : array
|
|
||||||
{
|
|
||||||
return [FuncCall::class];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param FuncCall $node
|
|
||||||
*/
|
|
||||||
public function refactor(Node $node) : ?Node
|
|
||||||
{
|
|
||||||
if (!$this->isName($node, 'intval')) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isset($node->args[1]) && $node->args[1] instanceof Arg) {
|
|
||||||
$secondArgumentValue = $this->valueResolver->getValue($node->args[1]->value);
|
|
||||||
// default value
|
|
||||||
if ($secondArgumentValue !== 10) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($node->isFirstClassCallable()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!isset($node->getArgs()[0])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Int_($node->getArgs()[0]->value);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\CodeQuality\Rector\FuncCall;
|
|
||||||
|
|
||||||
use PhpParser\Node;
|
|
||||||
use PhpParser\Node\Expr\Cast\String_;
|
|
||||||
use PhpParser\Node\Expr\FuncCall;
|
|
||||||
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
|
|
||||||
use Rector\Rector\AbstractRector;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|
||||||
/**
|
|
||||||
* @deprecated Since 1.1.2 as no clear performance difference and both are equivalent.
|
|
||||||
*/
|
|
||||||
final class StrvalToTypeCastRector extends AbstractRector implements DeprecatedInterface
|
|
||||||
{
|
|
||||||
public function getRuleDefinition() : RuleDefinition
|
|
||||||
{
|
|
||||||
return new RuleDefinition('Change strval() to faster and readable (string) $value', [new CodeSample(<<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function run($value)
|
|
||||||
{
|
|
||||||
return strval($value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
, <<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function run($value)
|
|
||||||
{
|
|
||||||
return (string) $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
)]);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return array<class-string<Node>>
|
|
||||||
*/
|
|
||||||
public function getNodeTypes() : array
|
|
||||||
{
|
|
||||||
return [FuncCall::class];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param FuncCall $node
|
|
||||||
*/
|
|
||||||
public function refactor(Node $node) : ?Node
|
|
||||||
{
|
|
||||||
if (!$this->isName($node, 'strval')) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if ($node->isFirstClassCallable()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!isset($node->getArgs()[0])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new String_($node->getArgs()[0]->value);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\EarlyReturn\NodeAnalyzer;
|
|
||||||
|
|
||||||
use PhpParser\Node;
|
|
||||||
use PhpParser\Node\Expr;
|
|
||||||
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
|
|
||||||
use PhpParser\Node\Expr\Instanceof_;
|
|
||||||
use PhpParser\Node\Stmt\If_;
|
|
||||||
use PhpParser\Node\Stmt\Return_;
|
|
||||||
use Rector\PhpParser\Comparing\NodeComparator;
|
|
||||||
use Rector\PhpParser\Node\BetterNodeFinder;
|
|
||||||
/**
|
|
||||||
* @deprecated Since 1.1.2, as related rule creates inverted conditions and makes code much less readable.
|
|
||||||
*/
|
|
||||||
final class IfAndAnalyzer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\PhpParser\Node\BetterNodeFinder
|
|
||||||
*/
|
|
||||||
private $betterNodeFinder;
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\PhpParser\Comparing\NodeComparator
|
|
||||||
*/
|
|
||||||
private $nodeComparator;
|
|
||||||
public function __construct(BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator)
|
|
||||||
{
|
|
||||||
$this->betterNodeFinder = $betterNodeFinder;
|
|
||||||
$this->nodeComparator = $nodeComparator;
|
|
||||||
}
|
|
||||||
public function isIfAndWithInstanceof(BooleanAnd $booleanAnd) : bool
|
|
||||||
{
|
|
||||||
if (!$booleanAnd->left instanceof Instanceof_) {
|
|
||||||
return \false;
|
|
||||||
}
|
|
||||||
// only one instanceof check
|
|
||||||
return !$booleanAnd->right instanceof Instanceof_;
|
|
||||||
}
|
|
||||||
public function isIfStmtExprUsedInNextReturn(If_ $if, Return_ $return) : bool
|
|
||||||
{
|
|
||||||
if (!$return->expr instanceof Expr) {
|
|
||||||
return \false;
|
|
||||||
}
|
|
||||||
$ifExprs = $this->betterNodeFinder->findInstanceOf($if->stmts, Expr::class);
|
|
||||||
return (bool) $this->betterNodeFinder->findFirst($return->expr, function (Node $node) use($ifExprs) : bool {
|
|
||||||
return $this->nodeComparator->isNodeEqual($node, $ifExprs);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\EarlyReturn\NodeAnalyzer;
|
|
||||||
|
|
||||||
use PhpParser\Node\Expr;
|
|
||||||
use PhpParser\Node\Expr\Array_;
|
|
||||||
use PhpParser\Node\Scalar\String_;
|
|
||||||
/**
|
|
||||||
* @deprecated Since 1.1.2, as related rule creates inverted conditions and makes code much less readable.
|
|
||||||
*/
|
|
||||||
final class SimpleScalarAnalyzer
|
|
||||||
{
|
|
||||||
public function isSimpleScalar(Expr $expr) : bool
|
|
||||||
{
|
|
||||||
// empty array
|
|
||||||
if ($expr instanceof Array_ && $expr->items === []) {
|
|
||||||
return \true;
|
|
||||||
}
|
|
||||||
// empty string
|
|
||||||
return $expr instanceof String_ && $expr->value === '';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\EarlyReturn\NodeFactory;
|
|
||||||
|
|
||||||
use PhpParser\Node\Expr;
|
|
||||||
use PhpParser\Node\Stmt;
|
|
||||||
use PhpParser\Node\Stmt\Continue_;
|
|
||||||
use PhpParser\Node\Stmt\If_;
|
|
||||||
use PhpParser\Node\Stmt\Return_;
|
|
||||||
use Rector\EarlyReturn\NodeTransformer\ConditionInverter;
|
|
||||||
use Rector\NodeNestingScope\ContextAnalyzer;
|
|
||||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
|
||||||
/**
|
|
||||||
* @deprecated Since 1.1.2, as related rule creates inverted conditions and makes code much less readable.
|
|
||||||
*/
|
|
||||||
final class InvertedIfFactory
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\EarlyReturn\NodeTransformer\ConditionInverter
|
|
||||||
*/
|
|
||||||
private $conditionInverter;
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\NodeNestingScope\ContextAnalyzer
|
|
||||||
*/
|
|
||||||
private $contextAnalyzer;
|
|
||||||
public function __construct(ConditionInverter $conditionInverter, ContextAnalyzer $contextAnalyzer)
|
|
||||||
{
|
|
||||||
$this->conditionInverter = $conditionInverter;
|
|
||||||
$this->contextAnalyzer = $contextAnalyzer;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param Expr[] $conditions
|
|
||||||
* @return If_[]
|
|
||||||
*/
|
|
||||||
public function createFromConditions(If_ $if, array $conditions, Return_ $return, ?Stmt $ifNextReturnStmt) : array
|
|
||||||
{
|
|
||||||
$ifs = [];
|
|
||||||
$stmt = $this->contextAnalyzer->isInLoop($if) && !$ifNextReturnStmt instanceof Return_ ? [new Continue_()] : [$return];
|
|
||||||
if ($ifNextReturnStmt instanceof Return_) {
|
|
||||||
$stmt[0]->setAttribute(AttributeKey::COMMENTS, $ifNextReturnStmt->getAttribute(AttributeKey::COMMENTS));
|
|
||||||
}
|
|
||||||
if ($ifNextReturnStmt instanceof Return_ && $ifNextReturnStmt->expr instanceof Expr) {
|
|
||||||
$return->expr = $ifNextReturnStmt->expr;
|
|
||||||
}
|
|
||||||
foreach ($conditions as $condition) {
|
|
||||||
$invertedCondition = $this->conditionInverter->createInvertedCondition($condition);
|
|
||||||
$if = new If_($invertedCondition);
|
|
||||||
$if->stmts = $stmt;
|
|
||||||
$ifs[] = $if;
|
|
||||||
}
|
|
||||||
return $ifs;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,244 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\EarlyReturn\Rector\If_;
|
|
||||||
|
|
||||||
use PhpParser\Node;
|
|
||||||
use PhpParser\Node\Expr;
|
|
||||||
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
|
|
||||||
use PhpParser\Node\Expr\Closure;
|
|
||||||
use PhpParser\Node\Expr\ConstFetch;
|
|
||||||
use PhpParser\Node\Scalar;
|
|
||||||
use PhpParser\Node\Stmt;
|
|
||||||
use PhpParser\Node\Stmt\Break_;
|
|
||||||
use PhpParser\Node\Stmt\ClassMethod;
|
|
||||||
use PhpParser\Node\Stmt\Continue_;
|
|
||||||
use PhpParser\Node\Stmt\Foreach_;
|
|
||||||
use PhpParser\Node\Stmt\Function_;
|
|
||||||
use PhpParser\Node\Stmt\If_;
|
|
||||||
use PhpParser\Node\Stmt\Namespace_;
|
|
||||||
use PhpParser\Node\Stmt\Return_;
|
|
||||||
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
|
|
||||||
use Rector\EarlyReturn\NodeAnalyzer\IfAndAnalyzer;
|
|
||||||
use Rector\EarlyReturn\NodeAnalyzer\SimpleScalarAnalyzer;
|
|
||||||
use Rector\EarlyReturn\NodeFactory\InvertedIfFactory;
|
|
||||||
use Rector\NodeCollector\BinaryOpConditionsCollector;
|
|
||||||
use Rector\NodeManipulator\IfManipulator;
|
|
||||||
use Rector\NodeNestingScope\ContextAnalyzer;
|
|
||||||
use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
|
||||||
use Rector\Rector\AbstractRector;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|
||||||
/**
|
|
||||||
* @deprecated Since 1.1.2, as this rule creates inverted conditions and makes code much less readable.
|
|
||||||
*/
|
|
||||||
final class ChangeAndIfToEarlyReturnRector extends AbstractRector implements DeprecatedInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\NodeManipulator\IfManipulator
|
|
||||||
*/
|
|
||||||
private $ifManipulator;
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\EarlyReturn\NodeFactory\InvertedIfFactory
|
|
||||||
*/
|
|
||||||
private $invertedIfFactory;
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\NodeNestingScope\ContextAnalyzer
|
|
||||||
*/
|
|
||||||
private $contextAnalyzer;
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\NodeCollector\BinaryOpConditionsCollector
|
|
||||||
*/
|
|
||||||
private $binaryOpConditionsCollector;
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\EarlyReturn\NodeAnalyzer\SimpleScalarAnalyzer
|
|
||||||
*/
|
|
||||||
private $simpleScalarAnalyzer;
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\EarlyReturn\NodeAnalyzer\IfAndAnalyzer
|
|
||||||
*/
|
|
||||||
private $ifAndAnalyzer;
|
|
||||||
public function __construct(IfManipulator $ifManipulator, InvertedIfFactory $invertedIfFactory, ContextAnalyzer $contextAnalyzer, BinaryOpConditionsCollector $binaryOpConditionsCollector, SimpleScalarAnalyzer $simpleScalarAnalyzer, IfAndAnalyzer $ifAndAnalyzer)
|
|
||||||
{
|
|
||||||
$this->ifManipulator = $ifManipulator;
|
|
||||||
$this->invertedIfFactory = $invertedIfFactory;
|
|
||||||
$this->contextAnalyzer = $contextAnalyzer;
|
|
||||||
$this->binaryOpConditionsCollector = $binaryOpConditionsCollector;
|
|
||||||
$this->simpleScalarAnalyzer = $simpleScalarAnalyzer;
|
|
||||||
$this->ifAndAnalyzer = $ifAndAnalyzer;
|
|
||||||
}
|
|
||||||
public function getRuleDefinition() : RuleDefinition
|
|
||||||
{
|
|
||||||
return new RuleDefinition('Changes if && to early return', [new CodeSample(<<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function canDrive(Car $car)
|
|
||||||
{
|
|
||||||
if ($car->hasWheels && $car->hasFuel) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
, <<<'CODE_SAMPLE'
|
|
||||||
class SomeClass
|
|
||||||
{
|
|
||||||
public function canDrive(Car $car)
|
|
||||||
{
|
|
||||||
if (! $car->hasWheels) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $car->hasFuel) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
)]);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return array<class-string<Node>>
|
|
||||||
*/
|
|
||||||
public function getNodeTypes() : array
|
|
||||||
{
|
|
||||||
return [ClassMethod::class, Function_::class, Foreach_::class, Closure::class, FileWithoutNamespace::class, Namespace_::class];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param Stmt\ClassMethod|Stmt\Function_|Stmt\Foreach_|Expr\Closure|FileWithoutNamespace|Stmt\Namespace_ $node
|
|
||||||
*/
|
|
||||||
public function refactor(Node $node) : ?Node
|
|
||||||
{
|
|
||||||
$stmts = (array) $node->stmts;
|
|
||||||
if ($stmts === []) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$newStmts = [];
|
|
||||||
foreach ($stmts as $key => $stmt) {
|
|
||||||
if (!$stmt instanceof If_) {
|
|
||||||
// keep natural original order
|
|
||||||
$newStmts[] = $stmt;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$nextStmt = $stmts[$key + 1] ?? null;
|
|
||||||
if ($this->isComplexReturn($nextStmt)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if ($this->shouldSkip($stmt, $nextStmt)) {
|
|
||||||
$newStmts[] = $stmt;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($nextStmt instanceof Return_) {
|
|
||||||
if ($this->ifAndAnalyzer->isIfStmtExprUsedInNextReturn($stmt, $nextStmt)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($nextStmt->expr instanceof BooleanAnd) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** @var BooleanAnd $expr */
|
|
||||||
$expr = $stmt->cond;
|
|
||||||
$booleanAndConditions = $this->binaryOpConditionsCollector->findConditions($expr, BooleanAnd::class);
|
|
||||||
$afterStmts = [];
|
|
||||||
if (!$nextStmt instanceof Return_) {
|
|
||||||
$afterStmts[] = $stmt->stmts[0];
|
|
||||||
$node->stmts = \array_merge($newStmts, $this->processReplaceIfs($stmt, $booleanAndConditions, new Return_(), $afterStmts, $nextStmt));
|
|
||||||
return $node;
|
|
||||||
}
|
|
||||||
// remove next node
|
|
||||||
unset($newStmts[$key + 1]);
|
|
||||||
$afterStmts[] = $stmt->stmts[0];
|
|
||||||
$ifNextReturnClone = $stmt->stmts[0] instanceof Return_ ? clone $stmt->stmts[0] : new Return_();
|
|
||||||
if ($this->isInLoopWithoutContinueOrBreak($stmt)) {
|
|
||||||
$afterStmts[] = new Return_();
|
|
||||||
}
|
|
||||||
$changedStmts = $this->processReplaceIfs($stmt, $booleanAndConditions, $ifNextReturnClone, $afterStmts, $nextStmt);
|
|
||||||
// update stmts
|
|
||||||
$node->stmts = \array_merge($newStmts, $changedStmts);
|
|
||||||
return $node;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
private function isInLoopWithoutContinueOrBreak(If_ $if) : bool
|
|
||||||
{
|
|
||||||
if (!$this->contextAnalyzer->isInLoop($if)) {
|
|
||||||
return \false;
|
|
||||||
}
|
|
||||||
if ($if->stmts[0] instanceof Continue_) {
|
|
||||||
return \false;
|
|
||||||
}
|
|
||||||
return !$if->stmts[0] instanceof Break_;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param Expr[] $conditions
|
|
||||||
* @param Stmt[] $afters
|
|
||||||
* @return Stmt[]
|
|
||||||
*/
|
|
||||||
private function processReplaceIfs(If_ $if, array $conditions, Return_ $ifNextReturn, array $afters, ?Stmt $nextStmt) : array
|
|
||||||
{
|
|
||||||
$ifs = $this->invertedIfFactory->createFromConditions($if, $conditions, $ifNextReturn, $nextStmt);
|
|
||||||
$this->mirrorComments($ifs[0], $if);
|
|
||||||
$result = \array_merge($ifs, $afters);
|
|
||||||
if ($if->stmts[0] instanceof Return_) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
if (!$ifNextReturn->expr instanceof Expr) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
if ($this->contextAnalyzer->isInLoop($if)) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
return \array_merge($result, [$ifNextReturn]);
|
|
||||||
}
|
|
||||||
private function shouldSkip(If_ $if, ?Stmt $nexStmt) : bool
|
|
||||||
{
|
|
||||||
if (!$this->ifManipulator->isIfWithOnlyOneStmt($if)) {
|
|
||||||
return \true;
|
|
||||||
}
|
|
||||||
if (!$if->cond instanceof BooleanAnd) {
|
|
||||||
return \true;
|
|
||||||
}
|
|
||||||
if (!$this->ifManipulator->isIfWithoutElseAndElseIfs($if)) {
|
|
||||||
return \true;
|
|
||||||
}
|
|
||||||
// is simple return? skip it
|
|
||||||
$onlyStmt = $if->stmts[0];
|
|
||||||
if ($onlyStmt instanceof Return_ && $onlyStmt->expr instanceof Expr && $this->simpleScalarAnalyzer->isSimpleScalar($onlyStmt->expr)) {
|
|
||||||
return \true;
|
|
||||||
}
|
|
||||||
if ($this->ifAndAnalyzer->isIfAndWithInstanceof($if->cond)) {
|
|
||||||
return \true;
|
|
||||||
}
|
|
||||||
return !$this->isLastIfOrBeforeLastReturn($nexStmt);
|
|
||||||
}
|
|
||||||
private function isLastIfOrBeforeLastReturn(?Stmt $nextStmt) : bool
|
|
||||||
{
|
|
||||||
if (!$nextStmt instanceof Stmt) {
|
|
||||||
return \true;
|
|
||||||
}
|
|
||||||
return $nextStmt instanceof Return_;
|
|
||||||
}
|
|
||||||
private function isComplexReturn(?Stmt $stmt) : bool
|
|
||||||
{
|
|
||||||
if (!$stmt instanceof Return_) {
|
|
||||||
return \false;
|
|
||||||
}
|
|
||||||
if (!$stmt->expr instanceof Expr) {
|
|
||||||
return \false;
|
|
||||||
}
|
|
||||||
if ($stmt->expr instanceof ConstFetch) {
|
|
||||||
return \false;
|
|
||||||
}
|
|
||||||
return !$stmt->expr instanceof Scalar;
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,41 +8,25 @@ use PhpParser\Node;
|
|||||||
use PhpParser\Node\ComplexType;
|
use PhpParser\Node\ComplexType;
|
||||||
use PhpParser\Node\Expr;
|
use PhpParser\Node\Expr;
|
||||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||||
use PhpParser\Node\Expr\ClassConstFetch;
|
|
||||||
use PhpParser\Node\Expr\Closure;
|
use PhpParser\Node\Expr\Closure;
|
||||||
use PhpParser\Node\Expr\ClosureUse;
|
use PhpParser\Node\Expr\ClosureUse;
|
||||||
use PhpParser\Node\Expr\MethodCall;
|
|
||||||
use PhpParser\Node\Expr\New_;
|
|
||||||
use PhpParser\Node\Expr\StaticCall;
|
|
||||||
use PhpParser\Node\Expr\Variable;
|
use PhpParser\Node\Expr\Variable;
|
||||||
use PhpParser\Node\Identifier;
|
use PhpParser\Node\Identifier;
|
||||||
use PhpParser\Node\Name;
|
use PhpParser\Node\Name;
|
||||||
use PhpParser\Node\Name\FullyQualified;
|
|
||||||
use PhpParser\Node\NullableType;
|
use PhpParser\Node\NullableType;
|
||||||
use PhpParser\Node\Param;
|
use PhpParser\Node\Param;
|
||||||
use PhpParser\Node\Scalar\LNumber;
|
use PhpParser\Node\Scalar\LNumber;
|
||||||
use PhpParser\Node\Scalar\String_;
|
use PhpParser\Node\Scalar\String_;
|
||||||
use PhpParser\Node\Stmt;
|
use PhpParser\Node\Stmt;
|
||||||
use PhpParser\Node\Stmt\ClassMethod;
|
|
||||||
use PhpParser\Node\Stmt\Expression;
|
use PhpParser\Node\Stmt\Expression;
|
||||||
use PhpParser\Node\Stmt\Return_;
|
use PhpParser\Node\Stmt\Return_;
|
||||||
use PhpParser\Node\UnionType;
|
use PhpParser\Node\UnionType;
|
||||||
use PHPStan\Reflection\FunctionVariantWithPhpDocs;
|
|
||||||
use PHPStan\Reflection\ParameterReflection;
|
|
||||||
use PHPStan\Reflection\ParametersAcceptorSelector;
|
|
||||||
use PHPStan\Reflection\Php\PhpMethodReflection;
|
|
||||||
use PHPStan\Type\MixedType;
|
|
||||||
use PHPStan\Type\Type;
|
|
||||||
use Rector\NodeNameResolver\NodeNameResolver;
|
use Rector\NodeNameResolver\NodeNameResolver;
|
||||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||||
use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
|
use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
|
||||||
use Rector\PhpParser\AstResolver;
|
|
||||||
use Rector\PhpParser\Node\BetterNodeFinder;
|
use Rector\PhpParser\Node\BetterNodeFinder;
|
||||||
use Rector\PhpParser\Node\NodeFactory;
|
|
||||||
use Rector\PhpParser\Parser\InlineCodeParser;
|
use Rector\PhpParser\Parser\InlineCodeParser;
|
||||||
use Rector\PhpParser\Parser\SimplePhpParser;
|
use Rector\PhpParser\Parser\SimplePhpParser;
|
||||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
|
||||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
|
||||||
final class AnonymousFunctionFactory
|
final class AnonymousFunctionFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -55,16 +39,6 @@ final class AnonymousFunctionFactory
|
|||||||
* @var \Rector\PhpParser\Node\BetterNodeFinder
|
* @var \Rector\PhpParser\Node\BetterNodeFinder
|
||||||
*/
|
*/
|
||||||
private $betterNodeFinder;
|
private $betterNodeFinder;
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\PhpParser\Node\NodeFactory
|
|
||||||
*/
|
|
||||||
private $nodeFactory;
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\StaticTypeMapper\StaticTypeMapper
|
|
||||||
*/
|
|
||||||
private $staticTypeMapper;
|
|
||||||
/**
|
/**
|
||||||
* @readonly
|
* @readonly
|
||||||
* @var \Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser
|
* @var \Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser
|
||||||
@ -75,11 +49,6 @@ final class AnonymousFunctionFactory
|
|||||||
* @var \Rector\PhpParser\Parser\SimplePhpParser
|
* @var \Rector\PhpParser\Parser\SimplePhpParser
|
||||||
*/
|
*/
|
||||||
private $simplePhpParser;
|
private $simplePhpParser;
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\PhpParser\AstResolver
|
|
||||||
*/
|
|
||||||
private $astResolver;
|
|
||||||
/**
|
/**
|
||||||
* @readonly
|
* @readonly
|
||||||
* @var \Rector\PhpParser\Parser\InlineCodeParser
|
* @var \Rector\PhpParser\Parser\InlineCodeParser
|
||||||
@ -90,15 +59,12 @@ final class AnonymousFunctionFactory
|
|||||||
* @see https://regex101.com/r/jkLLlM/2
|
* @see https://regex101.com/r/jkLLlM/2
|
||||||
*/
|
*/
|
||||||
private const DIM_FETCH_REGEX = '#(\\$|\\\\|\\x0)(?<number>\\d+)#';
|
private const DIM_FETCH_REGEX = '#(\\$|\\\\|\\x0)(?<number>\\d+)#';
|
||||||
public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, NodeFactory $nodeFactory, StaticTypeMapper $staticTypeMapper, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, SimplePhpParser $simplePhpParser, AstResolver $astResolver, InlineCodeParser $inlineCodeParser)
|
public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, SimplePhpParser $simplePhpParser, InlineCodeParser $inlineCodeParser)
|
||||||
{
|
{
|
||||||
$this->nodeNameResolver = $nodeNameResolver;
|
$this->nodeNameResolver = $nodeNameResolver;
|
||||||
$this->betterNodeFinder = $betterNodeFinder;
|
$this->betterNodeFinder = $betterNodeFinder;
|
||||||
$this->nodeFactory = $nodeFactory;
|
|
||||||
$this->staticTypeMapper = $staticTypeMapper;
|
|
||||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||||
$this->simplePhpParser = $simplePhpParser;
|
$this->simplePhpParser = $simplePhpParser;
|
||||||
$this->astResolver = $astResolver;
|
|
||||||
$this->inlineCodeParser = $inlineCodeParser;
|
$this->inlineCodeParser = $inlineCodeParser;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -124,27 +90,6 @@ final class AnonymousFunctionFactory
|
|||||||
$anonymousFunctionClosure->stmts = $stmts;
|
$anonymousFunctionClosure->stmts = $stmts;
|
||||||
return $anonymousFunctionClosure;
|
return $anonymousFunctionClosure;
|
||||||
}
|
}
|
||||||
public function createFromPhpMethodReflection(PhpMethodReflection $phpMethodReflection, Expr $expr) : ?Closure
|
|
||||||
{
|
|
||||||
/** @var FunctionVariantWithPhpDocs $parametersAcceptorWithPhpDocs */
|
|
||||||
$parametersAcceptorWithPhpDocs = ParametersAcceptorSelector::selectSingle($phpMethodReflection->getVariants());
|
|
||||||
$newParams = $this->createParams($phpMethodReflection, $parametersAcceptorWithPhpDocs->getParameters());
|
|
||||||
$innerMethodCall = $this->createInnerMethodCall($phpMethodReflection, $expr, $newParams);
|
|
||||||
if ($innerMethodCall === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$returnTypeNode = null;
|
|
||||||
if (!$parametersAcceptorWithPhpDocs->getReturnType() instanceof MixedType) {
|
|
||||||
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parametersAcceptorWithPhpDocs->getReturnType(), TypeKind::RETURN);
|
|
||||||
}
|
|
||||||
$uses = [];
|
|
||||||
if ($expr instanceof Variable && !$this->nodeNameResolver->isName($expr, 'this')) {
|
|
||||||
$uses[] = new ClosureUse($expr);
|
|
||||||
}
|
|
||||||
// does method return something?
|
|
||||||
$stmts = $this->resolveStmts($parametersAcceptorWithPhpDocs, $innerMethodCall);
|
|
||||||
return new Closure(['params' => $newParams, 'returnType' => $returnTypeNode, 'uses' => $uses, 'stmts' => $stmts]);
|
|
||||||
}
|
|
||||||
public function createAnonymousFunctionFromExpr(Expr $expr) : ?Closure
|
public function createAnonymousFunctionFromExpr(Expr $expr) : ?Closure
|
||||||
{
|
{
|
||||||
$stringValue = $this->inlineCodeParser->stringify($expr);
|
$stringValue = $this->inlineCodeParser->stringify($expr);
|
||||||
@ -221,116 +166,4 @@ final class AnonymousFunctionFactory
|
|||||||
}
|
}
|
||||||
return $filteredVariables;
|
return $filteredVariables;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param ParameterReflection[] $parameterReflections
|
|
||||||
* @return Param[]
|
|
||||||
*/
|
|
||||||
private function createParams(PhpMethodReflection $phpMethodReflection, array $parameterReflections) : array
|
|
||||||
{
|
|
||||||
$classReflection = $phpMethodReflection->getDeclaringClass();
|
|
||||||
$className = $classReflection->getName();
|
|
||||||
$methodName = $phpMethodReflection->getName();
|
|
||||||
/** @var ClassMethod $classMethod */
|
|
||||||
$classMethod = $this->astResolver->resolveClassMethod($className, $methodName);
|
|
||||||
$params = [];
|
|
||||||
foreach ($parameterReflections as $key => $parameterReflection) {
|
|
||||||
$variable = new Variable($parameterReflection->getName());
|
|
||||||
$defaultExpr = $this->resolveParamDefaultExpr($parameterReflection, $key, $classMethod);
|
|
||||||
$type = $this->resolveParamType($parameterReflection);
|
|
||||||
$byRef = $parameterReflection->passedByReference()->yes();
|
|
||||||
$params[] = new Param($variable, $defaultExpr, $type, $byRef);
|
|
||||||
}
|
|
||||||
return $params;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return \PhpParser\Node\Name|\PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|null
|
|
||||||
*/
|
|
||||||
private function resolveParamType(ParameterReflection $parameterReflection)
|
|
||||||
{
|
|
||||||
if ($parameterReflection->getType() instanceof MixedType) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parameterReflection->getType(), TypeKind::PARAM);
|
|
||||||
}
|
|
||||||
private function resolveParamDefaultExpr(ParameterReflection $parameterReflection, int $key, ClassMethod $classMethod) : ?Expr
|
|
||||||
{
|
|
||||||
if (!$parameterReflection->getDefaultValue() instanceof Type) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$paramDefaultExpr = $classMethod->params[$key]->default;
|
|
||||||
if (!$paramDefaultExpr instanceof Expr) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $this->nodeFactory->createReprintedNode($paramDefaultExpr);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param Param[] $params
|
|
||||||
* @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|null
|
|
||||||
*/
|
|
||||||
private function createInnerMethodCall(PhpMethodReflection $phpMethodReflection, Expr $expr, array $params)
|
|
||||||
{
|
|
||||||
if ($phpMethodReflection->isStatic()) {
|
|
||||||
$expr = $this->normalizeClassConstFetchForStatic($expr);
|
|
||||||
if (!$expr instanceof Node) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$innerMethodCall = new StaticCall($expr, $phpMethodReflection->getName());
|
|
||||||
} else {
|
|
||||||
$expr = $this->resolveExpr($expr);
|
|
||||||
if (!$expr instanceof Expr) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$innerMethodCall = new MethodCall($expr, $phpMethodReflection->getName());
|
|
||||||
}
|
|
||||||
$innerMethodCall->args = $this->nodeFactory->createArgsFromParams($params);
|
|
||||||
return $innerMethodCall;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return null|\PhpParser\Node\Name|\PhpParser\Node\Name\FullyQualified|\PhpParser\Node\Expr
|
|
||||||
*/
|
|
||||||
private function normalizeClassConstFetchForStatic(Expr $expr)
|
|
||||||
{
|
|
||||||
if (!$expr instanceof ClassConstFetch) {
|
|
||||||
return $expr;
|
|
||||||
}
|
|
||||||
if (!$this->nodeNameResolver->isName($expr->name, 'class')) {
|
|
||||||
return $expr;
|
|
||||||
}
|
|
||||||
// dynamic name, nothing we can do
|
|
||||||
$className = $this->nodeNameResolver->getName($expr->class);
|
|
||||||
if ($className === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$name = new Name($className);
|
|
||||||
if ($name->isSpecialClassName()) {
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
return new FullyQualified($className);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return \PhpParser\Node\Expr\New_|\PhpParser\Node\Expr|null
|
|
||||||
*/
|
|
||||||
private function resolveExpr(Expr $expr)
|
|
||||||
{
|
|
||||||
if (!$expr instanceof ClassConstFetch) {
|
|
||||||
return $expr;
|
|
||||||
}
|
|
||||||
if (!$this->nodeNameResolver->isName($expr->name, 'class')) {
|
|
||||||
return $expr;
|
|
||||||
}
|
|
||||||
// dynamic name, nothing we can do
|
|
||||||
$className = $this->nodeNameResolver->getName($expr->class);
|
|
||||||
return $className === null ? null : new New_(new FullyQualified($className));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return Stmt[]
|
|
||||||
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $innerMethodCall
|
|
||||||
*/
|
|
||||||
private function resolveStmts(FunctionVariantWithPhpDocs $functionVariantWithPhpDocs, $innerMethodCall) : array
|
|
||||||
{
|
|
||||||
if ($functionVariantWithPhpDocs->getReturnType()->isVoid()->yes()) {
|
|
||||||
return [new Expression($innerMethodCall)];
|
|
||||||
}
|
|
||||||
return [new Return_($innerMethodCall)];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const PACKAGE_VERSION = 'a9575034c3c774fe8aa5c42a0adbea008efaf000';
|
public const PACKAGE_VERSION = '3aa886f88d54d440d107577996d65cd968c0c8b0';
|
||||||
/**
|
/**
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const RELEASE_DATE = '2024-09-02 02:39:38';
|
public const RELEASE_DATE = '2024-09-02 10:04:28';
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
@ -7,7 +7,6 @@ use PhpParser\Node\Expr;
|
|||||||
use PhpParser\Node\Expr\BinaryOp;
|
use PhpParser\Node\Expr\BinaryOp;
|
||||||
/**
|
/**
|
||||||
* @see \Rector\Tests\NodeCollector\BinaryOpConditionsCollectorTest
|
* @see \Rector\Tests\NodeCollector\BinaryOpConditionsCollectorTest
|
||||||
* @deprecated Since 1.1.2, as related rule creates inverted conditions and makes code much less readable.
|
|
||||||
*/
|
*/
|
||||||
final class BinaryOpConditionsCollector
|
final class BinaryOpConditionsCollector
|
||||||
{
|
{
|
||||||
|
@ -157,10 +157,6 @@ final class IfManipulator
|
|||||||
}
|
}
|
||||||
return $this->hasOnlyStmtOfType($if, $stmtClass);
|
return $this->hasOnlyStmtOfType($if, $stmtClass);
|
||||||
}
|
}
|
||||||
public function isIfWithOnlyOneStmt(If_ $if) : bool
|
|
||||||
{
|
|
||||||
return \count($if->stmts) === 1;
|
|
||||||
}
|
|
||||||
public function isIfWithoutElseAndElseIfs(If_ $if) : bool
|
public function isIfWithoutElseAndElseIfs(If_ $if) : bool
|
||||||
{
|
{
|
||||||
if ($if->else instanceof Else_) {
|
if ($if->else instanceof Else_) {
|
||||||
|
@ -258,18 +258,6 @@ final class NodeFactory
|
|||||||
$name = new Name(ObjectReference::SELF);
|
$name = new Name(ObjectReference::SELF);
|
||||||
return new ClassConstFetch($name, $constantName);
|
return new ClassConstFetch($name, $constantName);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param Param[] $params
|
|
||||||
* @return Arg[]
|
|
||||||
*/
|
|
||||||
public function createArgsFromParams(array $params) : array
|
|
||||||
{
|
|
||||||
$args = [];
|
|
||||||
foreach ($params as $param) {
|
|
||||||
$args[] = new Arg($param->var);
|
|
||||||
}
|
|
||||||
return $args;
|
|
||||||
}
|
|
||||||
public function createNull() : ConstFetch
|
public function createNull() : ConstFetch
|
||||||
{
|
{
|
||||||
return new ConstFetch(new Name('null'));
|
return new ConstFetch(new Name('null'));
|
||||||
|
9
vendor/composer/autoload_classmap.php
vendored
9
vendor/composer/autoload_classmap.php
vendored
@ -1091,7 +1091,6 @@ return array(
|
|||||||
'Rector\\CodeQuality\\NodeFactory\\MissingPropertiesFactory' => $baseDir . '/rules/CodeQuality/NodeFactory/MissingPropertiesFactory.php',
|
'Rector\\CodeQuality\\NodeFactory\\MissingPropertiesFactory' => $baseDir . '/rules/CodeQuality/NodeFactory/MissingPropertiesFactory.php',
|
||||||
'Rector\\CodeQuality\\NodeFactory\\PropertyTypeDecorator' => $baseDir . '/rules/CodeQuality/NodeFactory/PropertyTypeDecorator.php',
|
'Rector\\CodeQuality\\NodeFactory\\PropertyTypeDecorator' => $baseDir . '/rules/CodeQuality/NodeFactory/PropertyTypeDecorator.php',
|
||||||
'Rector\\CodeQuality\\NodeManipulator\\ExprBoolCaster' => $baseDir . '/rules/CodeQuality/NodeManipulator/ExprBoolCaster.php',
|
'Rector\\CodeQuality\\NodeManipulator\\ExprBoolCaster' => $baseDir . '/rules/CodeQuality/NodeManipulator/ExprBoolCaster.php',
|
||||||
'Rector\\CodeQuality\\Rector\\Array_\\CallableThisArrayToAnonymousFunctionRector' => $baseDir . '/rules/CodeQuality/Rector/Array_/CallableThisArrayToAnonymousFunctionRector.php',
|
|
||||||
'Rector\\CodeQuality\\Rector\\Assign\\CombinedAssignRector' => $baseDir . '/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php',
|
'Rector\\CodeQuality\\Rector\\Assign\\CombinedAssignRector' => $baseDir . '/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\BooleanAnd\\RemoveUselessIsObjectCheckRector' => $baseDir . '/rules/CodeQuality/Rector/BooleanAnd/RemoveUselessIsObjectCheckRector.php',
|
'Rector\\CodeQuality\\Rector\\BooleanAnd\\RemoveUselessIsObjectCheckRector' => $baseDir . '/rules/CodeQuality/Rector/BooleanAnd/RemoveUselessIsObjectCheckRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\BooleanAnd\\SimplifyEmptyArrayCheckRector' => $baseDir . '/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php',
|
'Rector\\CodeQuality\\Rector\\BooleanAnd\\SimplifyEmptyArrayCheckRector' => $baseDir . '/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php',
|
||||||
@ -1117,13 +1116,10 @@ return array(
|
|||||||
'Rector\\CodeQuality\\Rector\\Foreach_\\SimplifyForeachToCoalescingRector' => $baseDir . '/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php',
|
'Rector\\CodeQuality\\Rector\\Foreach_\\SimplifyForeachToCoalescingRector' => $baseDir . '/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\Foreach_\\UnusedForeachValueToArrayKeysRector' => $baseDir . '/rules/CodeQuality/Rector/Foreach_/UnusedForeachValueToArrayKeysRector.php',
|
'Rector\\CodeQuality\\Rector\\Foreach_\\UnusedForeachValueToArrayKeysRector' => $baseDir . '/rules/CodeQuality/Rector/Foreach_/UnusedForeachValueToArrayKeysRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\ArrayMergeOfNonArraysToSimpleArrayRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/ArrayMergeOfNonArraysToSimpleArrayRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\ArrayMergeOfNonArraysToSimpleArrayRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/ArrayMergeOfNonArraysToSimpleArrayRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\BoolvalToTypeCastRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/BoolvalToTypeCastRector.php',
|
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\CallUserFuncWithArrowFunctionToInlineRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\CallUserFuncWithArrowFunctionToInlineRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\ChangeArrayPushToArrayAssignRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\ChangeArrayPushToArrayAssignRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\CompactToVariablesRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/CompactToVariablesRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\CompactToVariablesRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/CompactToVariablesRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\FloatvalToTypeCastRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/FloatvalToTypeCastRector.php',
|
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\InlineIsAInstanceOfRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\InlineIsAInstanceOfRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\IntvalToTypeCastRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/IntvalToTypeCastRector.php',
|
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\IsAWithStringWithThirdArgumentRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\IsAWithStringWithThirdArgumentRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\RemoveSoleValueSprintfRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\RemoveSoleValueSprintfRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\SetTypeToCastRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\SetTypeToCastRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php',
|
||||||
@ -1132,7 +1128,6 @@ return array(
|
|||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\SimplifyRegexPatternRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\SimplifyRegexPatternRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\SimplifyStrposLowerRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\SimplifyStrposLowerRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\SingleInArrayToCompareRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\SingleInArrayToCompareRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\StrvalToTypeCastRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/StrvalToTypeCastRector.php',
|
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\UnwrapSprintfOneArgumentRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/UnwrapSprintfOneArgumentRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\UnwrapSprintfOneArgumentRector' => $baseDir . '/rules/CodeQuality/Rector/FuncCall/UnwrapSprintfOneArgumentRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FunctionLike\\SimplifyUselessVariableRector' => $baseDir . '/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php',
|
'Rector\\CodeQuality\\Rector\\FunctionLike\\SimplifyUselessVariableRector' => $baseDir . '/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\Identical\\BooleanNotIdenticalToNotIdenticalRector' => $baseDir . '/rules/CodeQuality/Rector/Identical/BooleanNotIdenticalToNotIdenticalRector.php',
|
'Rector\\CodeQuality\\Rector\\Identical\\BooleanNotIdenticalToNotIdenticalRector' => $baseDir . '/rules/CodeQuality/Rector/Identical/BooleanNotIdenticalToNotIdenticalRector.php',
|
||||||
@ -1506,12 +1501,8 @@ return array(
|
|||||||
'Rector\\DowngradePhp82\\Rector\\Class_\\DowngradeReadonlyClassRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php',
|
'Rector\\DowngradePhp82\\Rector\\Class_\\DowngradeReadonlyClassRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php',
|
||||||
'Rector\\DowngradePhp82\\Rector\\FunctionLike\\DowngradeStandaloneNullTrueFalseReturnTypeRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php',
|
'Rector\\DowngradePhp82\\Rector\\FunctionLike\\DowngradeStandaloneNullTrueFalseReturnTypeRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php',
|
||||||
'Rector\\DowngradePhp83\\Rector\\ClassConst\\DowngradeTypedClassConstRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp83/Rector/ClassConst/DowngradeTypedClassConstRector.php',
|
'Rector\\DowngradePhp83\\Rector\\ClassConst\\DowngradeTypedClassConstRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp83/Rector/ClassConst/DowngradeTypedClassConstRector.php',
|
||||||
'Rector\\EarlyReturn\\NodeAnalyzer\\IfAndAnalyzer' => $baseDir . '/rules/EarlyReturn/NodeAnalyzer/IfAndAnalyzer.php',
|
|
||||||
'Rector\\EarlyReturn\\NodeAnalyzer\\SimpleScalarAnalyzer' => $baseDir . '/rules/EarlyReturn/NodeAnalyzer/SimpleScalarAnalyzer.php',
|
|
||||||
'Rector\\EarlyReturn\\NodeFactory\\InvertedIfFactory' => $baseDir . '/rules/EarlyReturn/NodeFactory/InvertedIfFactory.php',
|
|
||||||
'Rector\\EarlyReturn\\NodeTransformer\\ConditionInverter' => $baseDir . '/rules/EarlyReturn/NodeTransformer/ConditionInverter.php',
|
'Rector\\EarlyReturn\\NodeTransformer\\ConditionInverter' => $baseDir . '/rules/EarlyReturn/NodeTransformer/ConditionInverter.php',
|
||||||
'Rector\\EarlyReturn\\Rector\\Foreach_\\ChangeNestedForeachIfsToEarlyContinueRector' => $baseDir . '/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php',
|
'Rector\\EarlyReturn\\Rector\\Foreach_\\ChangeNestedForeachIfsToEarlyContinueRector' => $baseDir . '/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php',
|
||||||
'Rector\\EarlyReturn\\Rector\\If_\\ChangeAndIfToEarlyReturnRector' => $baseDir . '/rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php',
|
|
||||||
'Rector\\EarlyReturn\\Rector\\If_\\ChangeIfElseValueAssignToEarlyReturnRector' => $baseDir . '/rules/EarlyReturn/Rector/If_/ChangeIfElseValueAssignToEarlyReturnRector.php',
|
'Rector\\EarlyReturn\\Rector\\If_\\ChangeIfElseValueAssignToEarlyReturnRector' => $baseDir . '/rules/EarlyReturn/Rector/If_/ChangeIfElseValueAssignToEarlyReturnRector.php',
|
||||||
'Rector\\EarlyReturn\\Rector\\If_\\ChangeNestedIfsToEarlyReturnRector' => $baseDir . '/rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php',
|
'Rector\\EarlyReturn\\Rector\\If_\\ChangeNestedIfsToEarlyReturnRector' => $baseDir . '/rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php',
|
||||||
'Rector\\EarlyReturn\\Rector\\If_\\ChangeOrIfContinueToMultiContinueRector' => $baseDir . '/rules/EarlyReturn/Rector/If_/ChangeOrIfContinueToMultiContinueRector.php',
|
'Rector\\EarlyReturn\\Rector\\If_\\ChangeOrIfContinueToMultiContinueRector' => $baseDir . '/rules/EarlyReturn/Rector/If_/ChangeOrIfContinueToMultiContinueRector.php',
|
||||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -1310,7 +1310,6 @@ class ComposerStaticInitf022c0913f90a8ce8e0872b4624f9c82
|
|||||||
'Rector\\CodeQuality\\NodeFactory\\MissingPropertiesFactory' => __DIR__ . '/../..' . '/rules/CodeQuality/NodeFactory/MissingPropertiesFactory.php',
|
'Rector\\CodeQuality\\NodeFactory\\MissingPropertiesFactory' => __DIR__ . '/../..' . '/rules/CodeQuality/NodeFactory/MissingPropertiesFactory.php',
|
||||||
'Rector\\CodeQuality\\NodeFactory\\PropertyTypeDecorator' => __DIR__ . '/../..' . '/rules/CodeQuality/NodeFactory/PropertyTypeDecorator.php',
|
'Rector\\CodeQuality\\NodeFactory\\PropertyTypeDecorator' => __DIR__ . '/../..' . '/rules/CodeQuality/NodeFactory/PropertyTypeDecorator.php',
|
||||||
'Rector\\CodeQuality\\NodeManipulator\\ExprBoolCaster' => __DIR__ . '/../..' . '/rules/CodeQuality/NodeManipulator/ExprBoolCaster.php',
|
'Rector\\CodeQuality\\NodeManipulator\\ExprBoolCaster' => __DIR__ . '/../..' . '/rules/CodeQuality/NodeManipulator/ExprBoolCaster.php',
|
||||||
'Rector\\CodeQuality\\Rector\\Array_\\CallableThisArrayToAnonymousFunctionRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Array_/CallableThisArrayToAnonymousFunctionRector.php',
|
|
||||||
'Rector\\CodeQuality\\Rector\\Assign\\CombinedAssignRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php',
|
'Rector\\CodeQuality\\Rector\\Assign\\CombinedAssignRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\BooleanAnd\\RemoveUselessIsObjectCheckRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/BooleanAnd/RemoveUselessIsObjectCheckRector.php',
|
'Rector\\CodeQuality\\Rector\\BooleanAnd\\RemoveUselessIsObjectCheckRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/BooleanAnd/RemoveUselessIsObjectCheckRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\BooleanAnd\\SimplifyEmptyArrayCheckRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php',
|
'Rector\\CodeQuality\\Rector\\BooleanAnd\\SimplifyEmptyArrayCheckRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php',
|
||||||
@ -1336,13 +1335,10 @@ class ComposerStaticInitf022c0913f90a8ce8e0872b4624f9c82
|
|||||||
'Rector\\CodeQuality\\Rector\\Foreach_\\SimplifyForeachToCoalescingRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php',
|
'Rector\\CodeQuality\\Rector\\Foreach_\\SimplifyForeachToCoalescingRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\Foreach_\\UnusedForeachValueToArrayKeysRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Foreach_/UnusedForeachValueToArrayKeysRector.php',
|
'Rector\\CodeQuality\\Rector\\Foreach_\\UnusedForeachValueToArrayKeysRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Foreach_/UnusedForeachValueToArrayKeysRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\ArrayMergeOfNonArraysToSimpleArrayRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/ArrayMergeOfNonArraysToSimpleArrayRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\ArrayMergeOfNonArraysToSimpleArrayRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/ArrayMergeOfNonArraysToSimpleArrayRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\BoolvalToTypeCastRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/BoolvalToTypeCastRector.php',
|
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\CallUserFuncWithArrowFunctionToInlineRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\CallUserFuncWithArrowFunctionToInlineRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\ChangeArrayPushToArrayAssignRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\ChangeArrayPushToArrayAssignRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\CompactToVariablesRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/CompactToVariablesRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\CompactToVariablesRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/CompactToVariablesRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\FloatvalToTypeCastRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/FloatvalToTypeCastRector.php',
|
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\InlineIsAInstanceOfRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\InlineIsAInstanceOfRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\IntvalToTypeCastRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/IntvalToTypeCastRector.php',
|
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\IsAWithStringWithThirdArgumentRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\IsAWithStringWithThirdArgumentRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\RemoveSoleValueSprintfRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\RemoveSoleValueSprintfRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\SetTypeToCastRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\SetTypeToCastRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php',
|
||||||
@ -1351,7 +1347,6 @@ class ComposerStaticInitf022c0913f90a8ce8e0872b4624f9c82
|
|||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\SimplifyRegexPatternRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\SimplifyRegexPatternRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\SimplifyStrposLowerRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\SimplifyStrposLowerRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\SingleInArrayToCompareRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\SingleInArrayToCompareRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\StrvalToTypeCastRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/StrvalToTypeCastRector.php',
|
|
||||||
'Rector\\CodeQuality\\Rector\\FuncCall\\UnwrapSprintfOneArgumentRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/UnwrapSprintfOneArgumentRector.php',
|
'Rector\\CodeQuality\\Rector\\FuncCall\\UnwrapSprintfOneArgumentRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FuncCall/UnwrapSprintfOneArgumentRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\FunctionLike\\SimplifyUselessVariableRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php',
|
'Rector\\CodeQuality\\Rector\\FunctionLike\\SimplifyUselessVariableRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php',
|
||||||
'Rector\\CodeQuality\\Rector\\Identical\\BooleanNotIdenticalToNotIdenticalRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Identical/BooleanNotIdenticalToNotIdenticalRector.php',
|
'Rector\\CodeQuality\\Rector\\Identical\\BooleanNotIdenticalToNotIdenticalRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Identical/BooleanNotIdenticalToNotIdenticalRector.php',
|
||||||
@ -1725,12 +1720,8 @@ class ComposerStaticInitf022c0913f90a8ce8e0872b4624f9c82
|
|||||||
'Rector\\DowngradePhp82\\Rector\\Class_\\DowngradeReadonlyClassRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php',
|
'Rector\\DowngradePhp82\\Rector\\Class_\\DowngradeReadonlyClassRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php',
|
||||||
'Rector\\DowngradePhp82\\Rector\\FunctionLike\\DowngradeStandaloneNullTrueFalseReturnTypeRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php',
|
'Rector\\DowngradePhp82\\Rector\\FunctionLike\\DowngradeStandaloneNullTrueFalseReturnTypeRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php',
|
||||||
'Rector\\DowngradePhp83\\Rector\\ClassConst\\DowngradeTypedClassConstRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp83/Rector/ClassConst/DowngradeTypedClassConstRector.php',
|
'Rector\\DowngradePhp83\\Rector\\ClassConst\\DowngradeTypedClassConstRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp83/Rector/ClassConst/DowngradeTypedClassConstRector.php',
|
||||||
'Rector\\EarlyReturn\\NodeAnalyzer\\IfAndAnalyzer' => __DIR__ . '/../..' . '/rules/EarlyReturn/NodeAnalyzer/IfAndAnalyzer.php',
|
|
||||||
'Rector\\EarlyReturn\\NodeAnalyzer\\SimpleScalarAnalyzer' => __DIR__ . '/../..' . '/rules/EarlyReturn/NodeAnalyzer/SimpleScalarAnalyzer.php',
|
|
||||||
'Rector\\EarlyReturn\\NodeFactory\\InvertedIfFactory' => __DIR__ . '/../..' . '/rules/EarlyReturn/NodeFactory/InvertedIfFactory.php',
|
|
||||||
'Rector\\EarlyReturn\\NodeTransformer\\ConditionInverter' => __DIR__ . '/../..' . '/rules/EarlyReturn/NodeTransformer/ConditionInverter.php',
|
'Rector\\EarlyReturn\\NodeTransformer\\ConditionInverter' => __DIR__ . '/../..' . '/rules/EarlyReturn/NodeTransformer/ConditionInverter.php',
|
||||||
'Rector\\EarlyReturn\\Rector\\Foreach_\\ChangeNestedForeachIfsToEarlyContinueRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php',
|
'Rector\\EarlyReturn\\Rector\\Foreach_\\ChangeNestedForeachIfsToEarlyContinueRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php',
|
||||||
'Rector\\EarlyReturn\\Rector\\If_\\ChangeAndIfToEarlyReturnRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php',
|
|
||||||
'Rector\\EarlyReturn\\Rector\\If_\\ChangeIfElseValueAssignToEarlyReturnRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/If_/ChangeIfElseValueAssignToEarlyReturnRector.php',
|
'Rector\\EarlyReturn\\Rector\\If_\\ChangeIfElseValueAssignToEarlyReturnRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/If_/ChangeIfElseValueAssignToEarlyReturnRector.php',
|
||||||
'Rector\\EarlyReturn\\Rector\\If_\\ChangeNestedIfsToEarlyReturnRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php',
|
'Rector\\EarlyReturn\\Rector\\If_\\ChangeNestedIfsToEarlyReturnRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php',
|
||||||
'Rector\\EarlyReturn\\Rector\\If_\\ChangeOrIfContinueToMultiContinueRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/If_/ChangeOrIfContinueToMultiContinueRector.php',
|
'Rector\\EarlyReturn\\Rector\\If_\\ChangeOrIfContinueToMultiContinueRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/If_/ChangeOrIfContinueToMultiContinueRector.php',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user