Updated Rector to commit 23597c551da3bd1f1477f4415b1b2cad4651307c

23597c551d [Cleanup] Deprecate UseIncrementAssignRector as depends on context and might be intentional (#6042)
This commit is contained in:
Tomas Votruba 2024-06-26 10:04:52 +00:00
parent a26759c6e7
commit 253b752428
5 changed files with 63 additions and 60 deletions

View File

@ -7,11 +7,10 @@ use Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector;
use Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector;
use Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector;
use Rector\CodeQuality\Rector\FuncCall\StrvalToTypeCastRector;
use Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector;
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
use Rector\Config\RectorConfig;
use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([DeclareStrictTypesRector::class, IntvalToTypeCastRector::class, StrvalToTypeCastRector::class, BoolvalToTypeCastRector::class, FloatvalToTypeCastRector::class, PostIncDecToPreIncDecRector::class, UseIncrementAssignRector::class, FinalizeTestCaseClassRector::class]);
$rectorConfig->rules([DeclareStrictTypesRector::class, IntvalToTypeCastRector::class, StrvalToTypeCastRector::class, BoolvalToTypeCastRector::class, FloatvalToTypeCastRector::class, PostIncDecToPreIncDecRector::class, FinalizeTestCaseClassRector::class]);
};

View File

@ -10,11 +10,11 @@
- [CodeQuality](#codequality) (73)
- [CodingStyle](#codingstyle) (28)
- [CodingStyle](#codingstyle) (27)
- [DeadCode](#deadcode) (45)
- [EarlyReturn](#earlyreturn) (9)
- [EarlyReturn](#earlyreturn) (8)
- [Instanceof](#instanceof) (1)
@ -60,7 +60,7 @@
- [Transform](#transform) (25)
- [TypeDeclaration](#typedeclaration) (50)
- [TypeDeclaration](#typedeclaration) (52)
- [Visibility](#visibility) (3)
@ -1354,6 +1354,8 @@ Simplify tautology ternary to value
Removes useless variable assigns
:wrench: **configure it!**
- class: [`Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector`](../rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php)
```diff
@ -1366,6 +1368,18 @@ Removes useless variable assigns
<br>
```diff
function () {
$a = 'Hello, ';
- $a .= 'World!';
- return $a;
+ return $a . 'World!';
};
```
<br>
### SingleInArrayToCompareRector
Changes `in_array()` with single element to ===
@ -2141,25 +2155,6 @@ Use `class` keyword for class name resolution in string instead of hardcoded str
<br>
### UseIncrementAssignRector
Use ++ increment instead of `$var += 1`
- class: [`Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector`](../rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php)
```diff
class SomeClass
{
public function run()
{
- $style += 1;
+ ++$style;
}
}
```
<br>
### VersionCompareFuncCallToConstantRector
Changes use of call to version compare function to use of PHP version constant
@ -3111,35 +3106,6 @@ Remove php version checks if they are passed
## EarlyReturn
### ChangeAndIfToEarlyReturnRector
Changes if && to early return
- class: [`Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector`](../rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php)
```diff
class SomeClass
{
public function canDrive(Car $car)
{
- if ($car->hasWheels && $car->hasFuel) {
- return true;
+ if (! $car->hasWheels) {
+ return false;
}
- return false;
+ if (! $car->hasFuel) {
+ return false;
+ }
+
+ return true;
}
}
```
<br>
### ChangeIfElseValueAssignToEarlyReturnRector
Change if/else value to early return
@ -6500,6 +6466,40 @@ Add known return type to arrow function
<br>
### AddClosureNeverReturnTypeRector
Add "never" return-type for closure that never return anything
- class: [`Rector\TypeDeclaration\Rector\Closure\AddClosureNeverReturnTypeRector`](../rules/TypeDeclaration/Rector/Closure/AddClosureNeverReturnTypeRector.php)
```diff
-function () {
+function (): never {
throw new InvalidException();
}
```
<br>
### AddClosureUnionReturnTypeRector
Add union return type on closure
- class: [`Rector\TypeDeclaration\Rector\Closure\AddClosureUnionReturnTypeRector`](../rules/TypeDeclaration/Rector/Closure/AddClosureUnionReturnTypeRector.php)
```diff
-function () {
+function (): int|string {
if (rand(0, 1)) {
return 1;
}
return 'one';
}
```
<br>
### AddClosureVoidReturnTypeWhereNoReturnRector
Add closure return type void if there is no return

View File

@ -20,7 +20,6 @@ use Rector\NodeAnalyzer\VariableAnalyzer;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\PhpParser\Node\AssignAndBinaryMap;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -70,17 +69,22 @@ final class SimplifyUselessVariableRector extends AbstractRector implements Conf
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Removes useless variable assigns', [new CodeSample(<<<'CODE_SAMPLE'
return new RuleDefinition('Removes useless variable assigns', [new ConfiguredCodeSample(
<<<'CODE_SAMPLE'
function () {
$a = true;
return $a;
};
CODE_SAMPLE
, <<<'CODE_SAMPLE'
,
<<<'CODE_SAMPLE'
function () {
return true;
};
CODE_SAMPLE
,
// default
[self::ONLY_DIRECT_ASSIGN => \true]
), new ConfiguredCodeSample(<<<'CODE_SAMPLE'
function () {
$a = 'Hello, ';

View File

@ -13,7 +13,7 @@ use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\CodingStyle\Rector\Plus\UseIncrementAssignRector\UseIncrementAssignRectorTest
* @deprecated Since 1.1.2 as often used intentionally and depends on context. Cannot be changed in one way.
*/
final class UseIncrementAssignRector extends AbstractRector
{

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'd68e8fa32a27c1ddd474ef6f1b4e1f63a74e5708';
public const PACKAGE_VERSION = '23597c551da3bd1f1477f4415b1b2cad4651307c';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-06-26 11:07:18';
public const RELEASE_DATE = '2024-06-26 12:02:15';
/**
* @var int
*/