Skip to content

Commit 9e81001

Browse files
[Config] Re-enable Config SetList on rector.php (#1360)
Co-authored-by: GitHub Action <action@github.com>
1 parent 33c225d commit 9e81001

7 files changed

Lines changed: 25 additions & 16 deletions

File tree

rector.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
$containerConfigurator->import(LevelSetList::UP_TO_PHP_80);
2222

2323
// include sets
24-
// $containerConfigurator->import(SetList::CODING_STYLE);
25-
// $containerConfigurator->import(SetList::CODING_STYLE_ADVANCED);
26-
// $containerConfigurator->import(SetList::CODE_QUALITY);
27-
// $containerConfigurator->import(SetList::DEAD_CODE);
28-
// $containerConfigurator->import(SetList::PRIVATIZATION);
29-
// $containerConfigurator->import(SetList::NAMING);
30-
// $containerConfigurator->import(SetList::TYPE_DECLARATION);
31-
// $containerConfigurator->import(SetList::EARLY_RETURN);
32-
// $containerConfigurator->import(SetList::TYPE_DECLARATION_STRICT);
33-
// $containerConfigurator->import(NetteSetList::NETTE_UTILS_CODE_QUALITY);
34-
// $containerConfigurator->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY);
24+
$containerConfigurator->import(SetList::CODING_STYLE);
25+
$containerConfigurator->import(SetList::CODING_STYLE_ADVANCED);
26+
$containerConfigurator->import(SetList::CODE_QUALITY);
27+
$containerConfigurator->import(SetList::DEAD_CODE);
28+
$containerConfigurator->import(SetList::PRIVATIZATION);
29+
$containerConfigurator->import(SetList::NAMING);
30+
$containerConfigurator->import(SetList::TYPE_DECLARATION);
31+
$containerConfigurator->import(SetList::EARLY_RETURN);
32+
$containerConfigurator->import(SetList::TYPE_DECLARATION_STRICT);
33+
$containerConfigurator->import(NetteSetList::NETTE_UTILS_CODE_QUALITY);
34+
$containerConfigurator->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY);
3535

3636
$services = $containerConfigurator->services();
3737

rules-tests/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/config/configured_rule_php74.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
return static function (ContainerConfigurator $containerConfigurator): void {
1111
$parameters = $containerConfigurator->parameters();
1212
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_74);
13+
1314
$services = $containerConfigurator->services();
1415
$services->set(ArraySpreadInsteadOfArrayMergeRector::class);
1516
};

rules-tests/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/config/configured_rule_php81.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
return static function (ContainerConfigurator $containerConfigurator): void {
1111
$parameters = $containerConfigurator->parameters();
1212
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_81);
13+
1314
$services = $containerConfigurator->services();
1415
$services->set(ArraySpreadInsteadOfArrayMergeRector::class);
1516
};

rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function refactor(Node $node): ?Node
7575
}
7676

7777
$isAllowed = $this->isAllowed($node->class);
78-
$toSkip = $isAllowed && $this->isBetweenParentheses($node) !== false;
78+
$toSkip = $isAllowed && $this->isBetweenParentheses($node);
7979
if ($toSkip) {
8080
return null;
8181
}

rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,19 @@ private function shouldSkipArrayForInvalidTypeOrKeys(Expr $expr): bool
136136
if (! $arrayStaticType instanceof ArrayType) {
137137
return true;
138138
}
139+
139140
return ! $this->isArrayKeyTypeAllowed($arrayStaticType);
140141
}
141142

142-
private function isArrayKeyTypeAllowed(ArrayType $arrayStaticType): bool
143+
private function isArrayKeyTypeAllowed(ArrayType $arrayType): bool
143144
{
144145
$allowedKeyTypes = [IntegerType::class];
145146
if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::ARRAY_SPREAD_STRING_KEYS)) {
146147
$allowedKeyTypes[] = StringType::class;
147148
}
148149

149150
foreach ($allowedKeyTypes as $allowedKeyType) {
150-
if ($arrayStaticType->getKeyType() instanceof $allowedKeyType) {
151+
if ($arrayType->getKeyType() instanceof $allowedKeyType) {
151152
return true;
152153
}
153154
}

rules/Php81/Rector/Property/ReadOnlyPropertyRector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ public function refactor(Node $node): ?Node
8989
return null;
9090
}
9191

92-
if ($node->isReadonly() || $node->props[0]->default instanceof Expr) {
92+
if ($node->isReadonly()) {
93+
return null;
94+
}
95+
96+
if ($node->props[0]->default instanceof Expr) {
9397
return null;
9498
}
9599

rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ public function refactor(Node $node): ?Node
121121

122122
if ($argumentFuncCallToMethodCall instanceof ArgumentFuncCallToMethodCall) {
123123
return $this->refactorFuncCallToMethodCall($argumentFuncCallToMethodCall, $classLike, $node);
124-
} elseif ($argumentFuncCallToMethodCall instanceof ArrayFuncCallToMethodCall) {
124+
}
125+
126+
if ($argumentFuncCallToMethodCall instanceof ArrayFuncCallToMethodCall) {
125127
return $this->refactorArrayFunctionToMethodCall($argumentFuncCallToMethodCall, $node, $classLike);
126128
}
127129
}

0 commit comments

Comments
 (0)