mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-22 08:25:02 +02:00
Updated Rector to commit 9adc7a04b3a312957bb305edafcd0427fa6bd257
9adc7a04b3
[CodingStyle] Move ArraySpreadInsteadOfArrayMergeRector from php74 to codingstyle sets list (#5230)
This commit is contained in:
parent
73986cddda
commit
0cbee62160
@ -15,6 +15,7 @@ use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
|
||||
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
|
||||
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
|
||||
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector;
|
||||
@ -36,5 +37,5 @@ use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector;
|
||||
use Rector\Visibility\Rector\ClassMethod\ExplicitPublicClassMethodRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->ruleWithConfiguration(FuncCallToConstFetchRector::class, ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']);
|
||||
$rectorConfig->rules([SeparateMultiUseImportsRector::class, PostIncDecToPreIncDecRector::class, NewlineAfterStatementRector::class, RemoveFinalFromConstRector::class, NullableCompareToNullRector::class, ConsistentImplodeRector::class, TernaryConditionVariableAssignmentRector::class, SymplifyQuoteEscapeRector::class, StringClassNameToClassConstantRector::class, CatchExceptionNameMatchingTypeRector::class, UseIncrementAssignRector::class, SplitDoubleAssignRector::class, EncapsedStringsToSprintfRector::class, WrapEncapsedVariableInCurlyBracesRector::class, NewlineBeforeNewAssignSetRector::class, AddArrayDefaultToArrayPropertyRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, CallUserFuncArrayToVariadicRector::class, VersionCompareFuncCallToConstantRector::class, StaticArrowFunctionRector::class, StaticClosureRector::class, CountArrayToEmptyArrayComparisonRector::class, CallUserFuncToMethodCallRector::class, FuncGetArgsToVariadicParamRector::class, StrictArraySearchRector::class, UseClassKeywordForClassNameResolutionRector::class, SplitGroupedPropertiesRector::class, SplitGroupedClassConstantsRector::class, ExplicitPublicClassMethodRector::class]);
|
||||
$rectorConfig->rules([SeparateMultiUseImportsRector::class, PostIncDecToPreIncDecRector::class, NewlineAfterStatementRector::class, RemoveFinalFromConstRector::class, NullableCompareToNullRector::class, ConsistentImplodeRector::class, TernaryConditionVariableAssignmentRector::class, SymplifyQuoteEscapeRector::class, StringClassNameToClassConstantRector::class, CatchExceptionNameMatchingTypeRector::class, UseIncrementAssignRector::class, SplitDoubleAssignRector::class, EncapsedStringsToSprintfRector::class, WrapEncapsedVariableInCurlyBracesRector::class, NewlineBeforeNewAssignSetRector::class, AddArrayDefaultToArrayPropertyRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, CallUserFuncArrayToVariadicRector::class, VersionCompareFuncCallToConstantRector::class, StaticArrowFunctionRector::class, StaticClosureRector::class, CountArrayToEmptyArrayComparisonRector::class, CallUserFuncToMethodCallRector::class, FuncGetArgsToVariadicParamRector::class, StrictArraySearchRector::class, UseClassKeywordForClassNameResolutionRector::class, SplitGroupedPropertiesRector::class, SplitGroupedClassConstantsRector::class, ExplicitPublicClassMethodRector::class, ArraySpreadInsteadOfArrayMergeRector::class]);
|
||||
};
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
- [CodeQuality](#codequality) (72)
|
||||
|
||||
- [CodingStyle](#codingstyle) (28)
|
||||
- [CodingStyle](#codingstyle) (29)
|
||||
|
||||
- [DeadCode](#deadcode) (42)
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
- [Php73](#php73) (9)
|
||||
|
||||
- [Php74](#php74) (13)
|
||||
- [Php74](#php74) (12)
|
||||
|
||||
- [Php80](#php80) (16)
|
||||
|
||||
@ -1597,6 +1597,32 @@ Adds array default value to property to prevent foreach over null error
|
||||
|
||||
<br>
|
||||
|
||||
### ArraySpreadInsteadOfArrayMergeRector
|
||||
|
||||
Change `array_merge()` to spread operator
|
||||
|
||||
- class: [`Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector`](../rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run($iter1, $iter2)
|
||||
{
|
||||
- $values = array_merge(iterator_to_array($iter1), iterator_to_array($iter2));
|
||||
+ $values = [...$iter1, ...$iter2];
|
||||
|
||||
// Or to generalize to all iterables
|
||||
- $anotherValues = array_merge(
|
||||
- is_array($iter1) ? $iter1 : iterator_to_array($iter1),
|
||||
- is_array($iter2) ? $iter2 : iterator_to_array($iter2)
|
||||
- );
|
||||
+ $anotherValues = [...$iter1, ...$iter2];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### BinarySwitchToIfElseRector
|
||||
|
||||
Changes switch with 2 options to if-else
|
||||
@ -4483,32 +4509,6 @@ Change `array_key_exists()` on property to `property_exists()`
|
||||
|
||||
<br>
|
||||
|
||||
### ArraySpreadInsteadOfArrayMergeRector
|
||||
|
||||
Change `array_merge()` to spread operator
|
||||
|
||||
- class: [`Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector`](../rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run($iter1, $iter2)
|
||||
{
|
||||
- $values = array_merge(iterator_to_array($iter1), iterator_to_array($iter2));
|
||||
+ $values = [...$iter1, ...$iter2];
|
||||
|
||||
// Or to generalize to all iterables
|
||||
- $anotherValues = array_merge(
|
||||
- is_array($iter1) ? $iter1 : iterator_to_array($iter1),
|
||||
- is_array($iter2) ? $iter2 : iterator_to_array($iter2)
|
||||
- );
|
||||
+ $anotherValues = [...$iter1, ...$iter2];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### ClosureToArrowFunctionRector
|
||||
|
||||
Change closure to arrow function
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Php74\Rector\FuncCall;
|
||||
namespace Rector\CodingStyle\Rector\FuncCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
@ -22,8 +22,8 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://wiki.php.net/rfc/spread_operator_for_array
|
||||
*
|
||||
* @see \Rector\Tests\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector\Php74ArraySpreadInsteadOfArrayMergeRectorTest
|
||||
* @see \Rector\Tests\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector\Php81ArraySpreadInsteadOfArrayMergeRectorTest
|
||||
* @see \Rector\Tests\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector\Php74ArraySpreadInsteadOfArrayMergeRectorTest
|
||||
* @see \Rector\Tests\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector\Php81ArraySpreadInsteadOfArrayMergeRectorTest
|
||||
*/
|
||||
final class ArraySpreadInsteadOfArrayMergeRector extends AbstractRector implements MinPhpVersionInterface
|
||||
{
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'bd191f05ad1e632df5b656c1da0fb56a426f5a0a';
|
||||
public const PACKAGE_VERSION = '9adc7a04b3a312957bb305edafcd0427fa6bd257';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-11-07 15:40:17';
|
||||
public const RELEASE_DATE = '2023-11-08 01:54:33';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
@ -1124,6 +1124,7 @@ return array(
|
||||
'Rector\\CodingStyle\\Rector\\Closure\\StaticClosureRector' => $baseDir . '/rules/CodingStyle/Rector/Closure/StaticClosureRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Encapsed\\EncapsedStringsToSprintfRector' => $baseDir . '/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Encapsed\\WrapEncapsedVariableInCurlyBracesRector' => $baseDir . '/rules/CodingStyle/Rector/Encapsed/WrapEncapsedVariableInCurlyBracesRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\FuncCall\\ArraySpreadInsteadOfArrayMergeRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\FuncCall\\CallUserFuncArrayToVariadicRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\FuncCall\\CallUserFuncToMethodCallRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\FuncCall\\ConsistentImplodeRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php',
|
||||
@ -1827,7 +1828,6 @@ return array(
|
||||
'Rector\\Php74\\Rector\\Closure\\ClosureToArrowFunctionRector' => $baseDir . '/rules/Php74/Rector/Closure/ClosureToArrowFunctionRector.php',
|
||||
'Rector\\Php74\\Rector\\Double\\RealToFloatTypeCastRector' => $baseDir . '/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php',
|
||||
'Rector\\Php74\\Rector\\FuncCall\\ArrayKeyExistsOnPropertyRector' => $baseDir . '/rules/Php74/Rector/FuncCall/ArrayKeyExistsOnPropertyRector.php',
|
||||
'Rector\\Php74\\Rector\\FuncCall\\ArraySpreadInsteadOfArrayMergeRector' => $baseDir . '/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php',
|
||||
'Rector\\Php74\\Rector\\FuncCall\\FilterVarToAddSlashesRector' => $baseDir . '/rules/Php74/Rector/FuncCall/FilterVarToAddSlashesRector.php',
|
||||
'Rector\\Php74\\Rector\\FuncCall\\MbStrrposEncodingArgumentPositionRector' => $baseDir . '/rules/Php74/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector.php',
|
||||
'Rector\\Php74\\Rector\\FuncCall\\MoneyFormatToNumberFormatRector' => $baseDir . '/rules/Php74/Rector/FuncCall/MoneyFormatToNumberFormatRector.php',
|
||||
|
2
vendor/composer/autoload_static.php
vendored
2
vendor/composer/autoload_static.php
vendored
@ -1342,6 +1342,7 @@ class ComposerStaticInit18ad0e678efbbb500e116f7c54cccdd4
|
||||
'Rector\\CodingStyle\\Rector\\Closure\\StaticClosureRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Closure/StaticClosureRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Encapsed\\EncapsedStringsToSprintfRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Encapsed\\WrapEncapsedVariableInCurlyBracesRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Encapsed/WrapEncapsedVariableInCurlyBracesRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\FuncCall\\ArraySpreadInsteadOfArrayMergeRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\FuncCall\\CallUserFuncArrayToVariadicRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\FuncCall\\CallUserFuncToMethodCallRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\FuncCall\\ConsistentImplodeRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php',
|
||||
@ -2045,7 +2046,6 @@ class ComposerStaticInit18ad0e678efbbb500e116f7c54cccdd4
|
||||
'Rector\\Php74\\Rector\\Closure\\ClosureToArrowFunctionRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/Closure/ClosureToArrowFunctionRector.php',
|
||||
'Rector\\Php74\\Rector\\Double\\RealToFloatTypeCastRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php',
|
||||
'Rector\\Php74\\Rector\\FuncCall\\ArrayKeyExistsOnPropertyRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/FuncCall/ArrayKeyExistsOnPropertyRector.php',
|
||||
'Rector\\Php74\\Rector\\FuncCall\\ArraySpreadInsteadOfArrayMergeRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php',
|
||||
'Rector\\Php74\\Rector\\FuncCall\\FilterVarToAddSlashesRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/FuncCall/FilterVarToAddSlashesRector.php',
|
||||
'Rector\\Php74\\Rector\\FuncCall\\MbStrrposEncodingArgumentPositionRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector.php',
|
||||
'Rector\\Php74\\Rector\\FuncCall\\MoneyFormatToNumberFormatRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/FuncCall/MoneyFormatToNumberFormatRector.php',
|
||||
|
Loading…
x
Reference in New Issue
Block a user