Skip to content

Commit

Permalink
Remove RemoveUnusedVariableAssignRector, as could be breaking code in…
Browse files Browse the repository at this point in the history
… order of excution and hard to do reliable (#3793)

* Remove RemoveUnusedVariableAssignRector, as could be breaking code in order of excution and hard to do reliable

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
TomasVotruba and actions-user authored May 11, 2023
1 parent c63dd46 commit 074b178
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 387 deletions.
24 changes: 2 additions & 22 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 413 Rules Overview
# 412 Rules Overview

<br>

## Categories

- [Arguments](#arguments) (6)

- [CodeQuality](#codequality) (77)
- [CodeQuality](#codequality) (76)

- [CodingStyle](#codingstyle) (37)

Expand Down Expand Up @@ -1612,26 +1612,6 @@ Change switch with only 1 check to if

<br>

### SplitListAssignToSeparateLineRector

Splits `[$a, $b] = [5, 10]` scalar assign to standalone lines

- class: [`Rector\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector`](../rules/CodeQuality/Rector/Assign/SplitListAssignToSeparateLineRector.php)

```diff
final class SomeClass
{
public function run(): void
{
- [$a, $b] = [1, 2];
+ $a = 1;
+ $b = 2;
}
}
```

<br>

### StrlenZeroToIdenticalEmptyStringRector

Changes strlen comparison to 0 to direct empty string compare
Expand Down
2 changes: 0 additions & 2 deletions config/set/code-quality.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodeQuality\Rector\Assign\CombinedAssignRector;
use Rector\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector;
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
use Rector\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector;
use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector;
Expand Down Expand Up @@ -170,7 +169,6 @@
ForeachItemsAssignToEmptyArrayToAssignRector::class,
InlineIfToExplicitIfRector::class,
ArrayKeysAndInArrayToArrayKeyExistsRector::class,
SplitListAssignToSeparateLineRector::class,
UnusedForeachValueToArrayKeysRector::class,
CommonNotEqualRector::class,
SetTypeToCastRector::class,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ private function shouldSkip(Assign $assign): bool

private function isUsed(Assign $assign, Variable $variable, Scope $scope): bool
{
$isUsedPrev = $scope->hasVariableType((string) $this->getName($variable))->yes();
$isUsedPrev = $scope->hasVariableType((string) $this->getName($variable))
->yes();

if ($isUsedPrev) {
return true;
Expand Down Expand Up @@ -239,7 +240,8 @@ private function refactorUsedVariable(Assign $assign, Scope $scope): null|Expr
if (! $if instanceof If_) {
if (
$assign->var instanceof Variable &&
! $scope->hasVariableType((string) $this->getName($assign->var))->yes() &&
! $scope->hasVariableType((string) $this->getName($assign->var))
->yes() &&
! $this->exprUsedInNextNodeAnalyzer->isUsed($assign->var)) {
return $this->cleanCastedExpr($assign->expr);
}
Expand Down
Loading

0 comments on commit 074b178

Please sign in to comment.