mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-29 11:33:33 +01:00
Updated Rector to commit be53013ca3dff5b3eca8cdb3e688d744585e2557
be53013ca3
[CodeQuality] Remove SimplifyIfExactValueReturnValueRector, as overly defensive + InlineSimplePropertyAnnotationRector as purely coding standard area (#3764)
This commit is contained in:
parent
82228b7056
commit
4bf474e653
@ -62,7 +62,6 @@ use Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQue
|
||||
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
|
||||
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfExactValueReturnValueRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector;
|
||||
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
|
||||
@ -113,5 +112,5 @@ return static function (RectorConfig $rectorConfig) : void {
|
||||
'mbstrrpos' => 'mb_strrpos',
|
||||
'mbsubstr' => 'mb_substr',
|
||||
]);
|
||||
$rectorConfig->rules([CombinedAssignRector::class, SimplifyEmptyArrayCheckRector::class, ReplaceMultipleBooleanNotRector::class, ForeachToInArrayRector::class, SimplifyForeachToCoalescingRector::class, SimplifyFuncGetArgsCountRector::class, SimplifyInArrayValuesRector::class, SimplifyStrposLowerRector::class, GetClassToInstanceOfRector::class, SimplifyArraySearchRector::class, SimplifyConditionsRector::class, SimplifyIfNotNullReturnRector::class, SimplifyIfReturnBoolRector::class, SimplifyUselessVariableRector::class, UnnecessaryTernaryExpressionRector::class, RemoveExtraParametersRector::class, SimplifyDeMorganBinaryRector::class, SimplifyTautologyTernaryRector::class, SimplifyForeachToArrayFilterRector::class, SingleInArrayToCompareRector::class, SimplifyIfElseToTernaryRector::class, JoinStringConcatRector::class, ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, ExplicitBoolCompareRector::class, CombineIfRector::class, UseIdenticalOverEqualWithSameTypeRector::class, SimplifyBoolIdenticalTrueRector::class, SimplifyRegexPatternRector::class, BooleanNotIdenticalToNotIdenticalRector::class, StrvalToTypeCastRector::class, FloatvalToTypeCastRector::class, CallableThisArrayToAnonymousFunctionRector::class, AndAssignsToSeparateLinesRector::class, CompactToVariablesRector::class, CompleteDynamicPropertiesRector::class, IsAWithStringWithThirdArgumentRector::class, StrlenZeroToIdenticalEmptyStringRector::class, RemoveAlwaysTrueConditionSetInConstructorRector::class, ThrowWithPreviousExceptionRector::class, RemoveSoleValueSprintfRector::class, ShortenElseIfRector::class, AddPregQuoteDelimiterRector::class, ArrayMergeOfNonArraysToSimpleArrayRector::class, IntvalToTypeCastRector::class, BoolvalToTypeCastRector::class, ArrayKeyExistsTernaryThenValueToCoalescingRector::class, AbsolutizeRequireAndIncludePathRector::class, ChangeArrayPushToArrayAssignRector::class, ForRepeatedCountToOwnVariableRector::class, ForeachItemsAssignToEmptyArrayToAssignRector::class, InlineIfToExplicitIfRector::class, ArrayKeysAndInArrayToArrayKeyExistsRector::class, SplitListAssignToSeparateLineRector::class, UnusedForeachValueToArrayKeysRector::class, CommonNotEqualRector::class, SetTypeToCastRector::class, LogicalToBooleanRector::class, VarToPublicPropertyRector::class, IssetOnPropertyObjectToPropertyExistsRector::class, NewStaticToNewSelfRector::class, UnwrapSprintfOneArgumentRector::class, SwitchNegatedTernaryRector::class, SingularSwitchToIfRector::class, SimplifyIfNullableReturnRector::class, NarrowUnionTypeDocRector::class, FuncGetArgsToVariadicParamRector::class, CallUserFuncToMethodCallRector::class, CallUserFuncWithArrowFunctionToInlineRector::class, CountArrayToEmptyArrayComparisonRector::class, FlipTypeControlToUseExclusiveTypeRector::class, ExplicitMethodCallOverMagicGetSetRector::class, InlineArrayReturnAssignRector::class, InlineIsAInstanceOfRector::class, TernaryFalseExpressionToIfRector::class, InlineConstructorDefaultToPropertyRector::class, SimplifyIfExactValueReturnValueRector::class, SimplifyUselessLastVariableAssignRector::class, ReturnTypeFromStrictScalarReturnExprRector::class, TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, OptionalParametersAfterRequiredRector::class, SimplifyEmptyCheckOnEmptyArrayRector::class, SwitchTrueToIfRector::class]);
|
||||
$rectorConfig->rules([CombinedAssignRector::class, SimplifyEmptyArrayCheckRector::class, ReplaceMultipleBooleanNotRector::class, ForeachToInArrayRector::class, SimplifyForeachToCoalescingRector::class, SimplifyFuncGetArgsCountRector::class, SimplifyInArrayValuesRector::class, SimplifyStrposLowerRector::class, GetClassToInstanceOfRector::class, SimplifyArraySearchRector::class, SimplifyConditionsRector::class, SimplifyIfNotNullReturnRector::class, SimplifyIfReturnBoolRector::class, SimplifyUselessVariableRector::class, UnnecessaryTernaryExpressionRector::class, RemoveExtraParametersRector::class, SimplifyDeMorganBinaryRector::class, SimplifyTautologyTernaryRector::class, SimplifyForeachToArrayFilterRector::class, SingleInArrayToCompareRector::class, SimplifyIfElseToTernaryRector::class, JoinStringConcatRector::class, ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, ExplicitBoolCompareRector::class, CombineIfRector::class, UseIdenticalOverEqualWithSameTypeRector::class, SimplifyBoolIdenticalTrueRector::class, SimplifyRegexPatternRector::class, BooleanNotIdenticalToNotIdenticalRector::class, StrvalToTypeCastRector::class, FloatvalToTypeCastRector::class, CallableThisArrayToAnonymousFunctionRector::class, AndAssignsToSeparateLinesRector::class, CompactToVariablesRector::class, CompleteDynamicPropertiesRector::class, IsAWithStringWithThirdArgumentRector::class, StrlenZeroToIdenticalEmptyStringRector::class, RemoveAlwaysTrueConditionSetInConstructorRector::class, ThrowWithPreviousExceptionRector::class, RemoveSoleValueSprintfRector::class, ShortenElseIfRector::class, AddPregQuoteDelimiterRector::class, ArrayMergeOfNonArraysToSimpleArrayRector::class, IntvalToTypeCastRector::class, BoolvalToTypeCastRector::class, ArrayKeyExistsTernaryThenValueToCoalescingRector::class, AbsolutizeRequireAndIncludePathRector::class, ChangeArrayPushToArrayAssignRector::class, ForRepeatedCountToOwnVariableRector::class, ForeachItemsAssignToEmptyArrayToAssignRector::class, InlineIfToExplicitIfRector::class, ArrayKeysAndInArrayToArrayKeyExistsRector::class, SplitListAssignToSeparateLineRector::class, UnusedForeachValueToArrayKeysRector::class, CommonNotEqualRector::class, SetTypeToCastRector::class, LogicalToBooleanRector::class, VarToPublicPropertyRector::class, IssetOnPropertyObjectToPropertyExistsRector::class, NewStaticToNewSelfRector::class, UnwrapSprintfOneArgumentRector::class, SwitchNegatedTernaryRector::class, SingularSwitchToIfRector::class, SimplifyIfNullableReturnRector::class, NarrowUnionTypeDocRector::class, FuncGetArgsToVariadicParamRector::class, CallUserFuncToMethodCallRector::class, CallUserFuncWithArrowFunctionToInlineRector::class, CountArrayToEmptyArrayComparisonRector::class, FlipTypeControlToUseExclusiveTypeRector::class, ExplicitMethodCallOverMagicGetSetRector::class, InlineArrayReturnAssignRector::class, InlineIsAInstanceOfRector::class, TernaryFalseExpressionToIfRector::class, InlineConstructorDefaultToPropertyRector::class, SimplifyUselessLastVariableAssignRector::class, ReturnTypeFromStrictScalarReturnExprRector::class, TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, OptionalParametersAfterRequiredRector::class, SimplifyEmptyCheckOnEmptyArrayRector::class, SwitchTrueToIfRector::class]);
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
# 420 Rules Overview
|
||||
# 418 Rules Overview
|
||||
|
||||
<br>
|
||||
|
||||
@ -6,9 +6,9 @@
|
||||
|
||||
- [Arguments](#arguments) (6)
|
||||
|
||||
- [CodeQuality](#codequality) (78)
|
||||
- [CodeQuality](#codequality) (77)
|
||||
|
||||
- [CodingStyle](#codingstyle) (39)
|
||||
- [CodingStyle](#codingstyle) (38)
|
||||
|
||||
- [Compatibility](#compatibility) (1)
|
||||
|
||||
@ -1404,23 +1404,6 @@ Changes if/else for same value as assign to ternary
|
||||
|
||||
<br>
|
||||
|
||||
### SimplifyIfExactValueReturnValueRector
|
||||
|
||||
Changes compared to value and return of expr to direct return
|
||||
|
||||
- class: [`Rector\CodeQuality\Rector\If_\SimplifyIfExactValueReturnValueRector`](../rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php)
|
||||
|
||||
```diff
|
||||
$value = 'something';
|
||||
-if ($value === 52) {
|
||||
- return 52;
|
||||
-}
|
||||
-
|
||||
return $value;
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### SimplifyIfNotNullReturnRector
|
||||
|
||||
Changes redundant null check to instant return
|
||||
@ -2143,51 +2126,6 @@ Refactor `func_get_args()` in to a variadic param
|
||||
|
||||
<br>
|
||||
|
||||
### InlineSimplePropertyAnnotationRector
|
||||
|
||||
Inline simple `@var` annotations (or other annotations) when they are the only thing in the phpdoc
|
||||
|
||||
:wrench: **configure it!**
|
||||
|
||||
- class: [`Rector\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector`](../rules/CodingStyle/Rector/Property/InlineSimplePropertyAnnotationRector.php)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector;
|
||||
use Rector\Config\RectorConfig;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(InlineSimplePropertyAnnotationRector::class, [
|
||||
'var',
|
||||
'phpstan-var',
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
final class SomeClass
|
||||
{
|
||||
- /**
|
||||
- * @phpstan-var string
|
||||
- */
|
||||
+ /** @phpstan-var string */
|
||||
private const TEXT = 'text';
|
||||
|
||||
- /**
|
||||
- * @var DateTime[]
|
||||
- */
|
||||
+ /** @var DateTime[] */
|
||||
private ?array $dateTimes;
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### MakeInheritedMethodVisibilitySameAsParentRector
|
||||
|
||||
Make method visibility same as parent one
|
||||
@ -5398,11 +5336,13 @@ Replace `each()` assign outside loop
|
||||
|
||||
```diff
|
||||
$array = ['b' => 1, 'a' => 2];
|
||||
|
||||
-$eachedArray = each($array);
|
||||
+$eachedArray[1] = current($array);
|
||||
+$eachedArray['value'] = current($array);
|
||||
+$eachedArray[0] = key($array);
|
||||
+$eachedArray['key'] = key($array);
|
||||
+
|
||||
+next($array);
|
||||
```
|
||||
|
||||
|
@ -318,10 +318,6 @@ final class PhpDocInfo
|
||||
}
|
||||
return $this->betterTokenIterator->count() === 0;
|
||||
}
|
||||
public function makeSingleLined() : void
|
||||
{
|
||||
$this->isSingleLine = \true;
|
||||
}
|
||||
public function isSingleLine() : bool
|
||||
{
|
||||
return $this->isSingleLine;
|
||||
|
@ -138,10 +138,7 @@ CODE_SAMPLE
|
||||
return \true;
|
||||
}
|
||||
$foreachValueStaticType = $this->getType($foreach->expr);
|
||||
if ($foreachValueStaticType instanceof ObjectType) {
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
return $foreachValueStaticType instanceof ObjectType;
|
||||
}
|
||||
private function shouldSkipIf(If_ $if) : bool
|
||||
{
|
||||
|
@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\CodeQuality\Rector\If_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface;
|
||||
use Rector\Core\NodeManipulator\IfManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\CodeQuality\Rector\If_\SimplifyIfExactValueReturnValueRector\SimplifyIfExactValueReturnValueRectorTest
|
||||
*/
|
||||
final class SimplifyIfExactValueReturnValueRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\NodeManipulator\IfManipulator
|
||||
*/
|
||||
private $ifManipulator;
|
||||
public function __construct(IfManipulator $ifManipulator)
|
||||
{
|
||||
$this->ifManipulator = $ifManipulator;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Changes compared to value and return of expr to direct return', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
$value = 'something';
|
||||
if ($value === 52) {
|
||||
return 52;
|
||||
}
|
||||
|
||||
return $value;
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
$value = 'something';
|
||||
return $value;
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [StmtsAwareInterface::class];
|
||||
}
|
||||
/**
|
||||
* @param StmtsAwareInterface $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?StmtsAwareInterface
|
||||
{
|
||||
foreach ((array) $node->stmts as $key => $stmt) {
|
||||
if (!$stmt instanceof If_) {
|
||||
continue;
|
||||
}
|
||||
// on last stmt already
|
||||
if (!isset($node->stmts[$key + 1])) {
|
||||
return null;
|
||||
}
|
||||
$nextNode = $node->stmts[$key + 1];
|
||||
if (!$nextNode instanceof Return_) {
|
||||
continue;
|
||||
}
|
||||
$expr = $this->ifManipulator->matchIfValueReturnValue($stmt);
|
||||
if (!$expr instanceof Expr) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->nodeComparator->areNodesEqual($expr, $nextNode->expr)) {
|
||||
return null;
|
||||
}
|
||||
unset($node->stmts[$key]);
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\CodingStyle\Rector\Property;
|
||||
|
||||
use PhpParser\Comment\Doc;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\ClassConst;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix202305\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @see \Rector\Tests\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector\InlineSimplePropertyAnnotationRectorTest
|
||||
*
|
||||
* rector-src dev note:
|
||||
*
|
||||
* Do not register to coding-style config/set/coding-style.php set
|
||||
* as it will always conflict with ECS use of \PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer
|
||||
* so rectify CI will always rolled back the change
|
||||
*/
|
||||
final class InlineSimplePropertyAnnotationRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $annotationsToConsiderForInlining = ['@var', '@phpstan-var', '@psalm-var'];
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Inline simple @var annotations (or other annotations) when they are the only thing in the phpdoc', [new ConfiguredCodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
* @phpstan-var string
|
||||
*/
|
||||
private const TEXT = 'text';
|
||||
|
||||
/**
|
||||
* @var DateTime[]
|
||||
*/
|
||||
private ?array $dateTimes;
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
/** @phpstan-var string */
|
||||
private const TEXT = 'text';
|
||||
|
||||
/** @var DateTime[] */
|
||||
private ?array $dateTimes;
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, ['var', 'phpstan-var'])]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Property::class, ClassConst::class];
|
||||
}
|
||||
/**
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
Assert::allString($configuration);
|
||||
$this->annotationsToConsiderForInlining = \array_map(static function (string $annotation) : string {
|
||||
return '@' . \ltrim($annotation, '@');
|
||||
}, $configuration);
|
||||
}
|
||||
/**
|
||||
* @param Property|ClassConst $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if ($this->shouldSkipNode($node)) {
|
||||
return null;
|
||||
}
|
||||
$comments = $node->getAttribute(AttributeKey::COMMENTS, []);
|
||||
if ((\is_array($comments) || $comments instanceof \Countable ? \count($comments) : 0) !== 1) {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
if (\count($phpDocInfo->getPhpDocNode()->children) > 1) {
|
||||
return null;
|
||||
}
|
||||
$phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||
$tags = $phpDocNode->getTags();
|
||||
if (\count($tags) !== 1) {
|
||||
return null;
|
||||
}
|
||||
// The first value may not be at index 0
|
||||
$phpDocTagNode = \reset($tags);
|
||||
if (!\in_array($phpDocTagNode->name, $this->annotationsToConsiderForInlining, \true)) {
|
||||
return null;
|
||||
}
|
||||
if (\strpos((string) $phpDocTagNode, "\n") !== \false) {
|
||||
return null;
|
||||
}
|
||||
// Handle edge cases where stringified tag is not same as it was originally
|
||||
/** @var Doc $comment */
|
||||
$comment = $comments[0];
|
||||
if (\strpos($comment->getText(), (string) $phpDocTagNode) === \false) {
|
||||
return null;
|
||||
}
|
||||
// Creating new node is the only way to enforce the "singleLined" property AFAIK
|
||||
$newPhpDocInfo = $this->phpDocInfoFactory->createEmpty($node);
|
||||
$newPhpDocInfo->makeSingleLined();
|
||||
$newPhpDocNode = $newPhpDocInfo->getPhpDocNode();
|
||||
$newPhpDocNode->children = [$phpDocTagNode];
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\ClassConst|\PhpParser\Node\Stmt\Property $node
|
||||
*/
|
||||
private function shouldSkipNode($node) : bool
|
||||
{
|
||||
if ($node instanceof Property && \count($node->props) !== 1) {
|
||||
return \true;
|
||||
}
|
||||
return $node instanceof ClassConst && \count($node->consts) !== 1;
|
||||
}
|
||||
}
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'ea3d4f164337d11e757a0348d5445efb4b6d5b2f';
|
||||
public const PACKAGE_VERSION = 'be53013ca3dff5b3eca8cdb3e688d744585e2557';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-05-07 19:09:23';
|
||||
public const RELEASE_DATE = '2023-05-07 19:30:55';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -6,7 +6,6 @@ namespace Rector\Core\NodeManipulator;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\Exit_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
@ -75,37 +74,6 @@ final class IfManipulator
|
||||
}
|
||||
return $this->matchComparedAndReturnedNode($if->cond, $insideIfNode);
|
||||
}
|
||||
/**
|
||||
* Matches:
|
||||
*
|
||||
* if (<$value> === null) {
|
||||
* return null;
|
||||
* }
|
||||
*
|
||||
* if (<$value> === 53;) {
|
||||
* return 53;
|
||||
* }
|
||||
*/
|
||||
public function matchIfValueReturnValue(If_ $if) : ?Expr
|
||||
{
|
||||
if (\count($if->stmts) !== 1) {
|
||||
return null;
|
||||
}
|
||||
$insideIfStmt = $if->stmts[0];
|
||||
if (!$insideIfStmt instanceof Return_) {
|
||||
return null;
|
||||
}
|
||||
if (!$if->cond instanceof Identical) {
|
||||
return null;
|
||||
}
|
||||
if ($this->nodeComparator->areNodesEqual($if->cond->left, $insideIfStmt->expr)) {
|
||||
return $if->cond->right;
|
||||
}
|
||||
if ($this->nodeComparator->areNodesEqual($if->cond->right, $insideIfStmt->expr)) {
|
||||
return $if->cond->left;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @return If_[]
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit52a3827c6463d92d419685a8496bb0f3::getLoader();
|
||||
return ComposerAutoloaderInit966f676a276559bf92a7dc1baed7ed72::getLoader();
|
||||
|
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
@ -1276,7 +1276,6 @@ return array(
|
||||
'Rector\\CodeQuality\\Rector\\If_\\ExplicitBoolCompareRector' => $baseDir . '/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\ShortenElseIfRector' => $baseDir . '/rules/CodeQuality/Rector/If_/ShortenElseIfRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfElseToTernaryRector' => $baseDir . '/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfExactValueReturnValueRector' => $baseDir . '/rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfNotNullReturnRector' => $baseDir . '/rules/CodeQuality/Rector/If_/SimplifyIfNotNullReturnRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfNullableReturnRector' => $baseDir . '/rules/CodeQuality/Rector/If_/SimplifyIfNullableReturnRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfReturnBoolRector' => $baseDir . '/rules/CodeQuality/Rector/If_/SimplifyIfReturnBoolRector.php',
|
||||
@ -1347,7 +1346,6 @@ return array(
|
||||
'Rector\\CodingStyle\\Rector\\Plus\\UseIncrementAssignRector' => $baseDir . '/rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\PostInc\\PostIncDecToPreIncDecRector' => $baseDir . '/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\AddFalseDefaultToBoolPropertyRector' => $baseDir . '/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\InlineSimplePropertyAnnotationRector' => $baseDir . '/rules/CodingStyle/Rector/Property/InlineSimplePropertyAnnotationRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\NullifyUnionNullableRector' => $baseDir . '/rules/CodingStyle/Rector/Property/NullifyUnionNullableRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\SplitGroupedPropertiesRector' => $baseDir . '/rules/CodingStyle/Rector/Property/SplitGroupedPropertiesRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Stmt\\NewlineAfterStatementRector' => $baseDir . '/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php',
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit52a3827c6463d92d419685a8496bb0f3
|
||||
class ComposerAutoloaderInit966f676a276559bf92a7dc1baed7ed72
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit52a3827c6463d92d419685a8496bb0f3
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit52a3827c6463d92d419685a8496bb0f3', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit966f676a276559bf92a7dc1baed7ed72', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit52a3827c6463d92d419685a8496bb0f3', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit966f676a276559bf92a7dc1baed7ed72', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit52a3827c6463d92d419685a8496bb0f3::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit966f676a276559bf92a7dc1baed7ed72::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit52a3827c6463d92d419685a8496bb0f3::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit966f676a276559bf92a7dc1baed7ed72::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
10
vendor/composer/autoload_static.php
vendored
10
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit52a3827c6463d92d419685a8496bb0f3
|
||||
class ComposerStaticInit966f676a276559bf92a7dc1baed7ed72
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -1518,7 +1518,6 @@ class ComposerStaticInit52a3827c6463d92d419685a8496bb0f3
|
||||
'Rector\\CodeQuality\\Rector\\If_\\ExplicitBoolCompareRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\ShortenElseIfRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/ShortenElseIfRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfElseToTernaryRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfExactValueReturnValueRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfNotNullReturnRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/SimplifyIfNotNullReturnRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfNullableReturnRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/SimplifyIfNullableReturnRector.php',
|
||||
'Rector\\CodeQuality\\Rector\\If_\\SimplifyIfReturnBoolRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/If_/SimplifyIfReturnBoolRector.php',
|
||||
@ -1589,7 +1588,6 @@ class ComposerStaticInit52a3827c6463d92d419685a8496bb0f3
|
||||
'Rector\\CodingStyle\\Rector\\Plus\\UseIncrementAssignRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\PostInc\\PostIncDecToPreIncDecRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\AddFalseDefaultToBoolPropertyRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\InlineSimplePropertyAnnotationRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Property/InlineSimplePropertyAnnotationRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\NullifyUnionNullableRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Property/NullifyUnionNullableRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\SplitGroupedPropertiesRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Property/SplitGroupedPropertiesRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Stmt\\NewlineAfterStatementRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php',
|
||||
@ -3124,9 +3122,9 @@ class ComposerStaticInit52a3827c6463d92d419685a8496bb0f3
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit52a3827c6463d92d419685a8496bb0f3::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit52a3827c6463d92d419685a8496bb0f3::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit52a3827c6463d92d419685a8496bb0f3::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit966f676a276559bf92a7dc1baed7ed72::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit966f676a276559bf92a7dc1baed7ed72::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit966f676a276559bf92a7dc1baed7ed72::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user