Skip to content

Commit 8d7beed

Browse files
samsonasiksimonschaufi
authored andcommitted
[TASK] Upgrade to Rector 2.0 with PHPStan 2 and PHPParser 5
1 parent c95bbdf commit 8d7beed

File tree

69 files changed

+206
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+206
-158
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
"league/flysystem": "^2.0 || ^3.0",
3939
"league/flysystem-memory": "^2.0 || ^3.0",
4040
"nette/utils": "^3.2.10 || ^4.0.4",
41-
"nikic/php-parser": "^4.18.0",
42-
"phpstan/phpstan": "^1.10.56",
43-
"rector/rector": "^1.1.0",
41+
"nikic/php-parser": "^5.3.1",
42+
"phpstan/phpstan": "^2.0.3",
43+
"rector/rector": "^2.0.0",
4444
"symfony/console": "^5.4 || ^6.4 || ^7.0",
4545
"symfony/filesystem": "^5.4 || ^6.4 || ^7.0",
4646
"symfony/finder": "^5.4 || ^6.4 || ^7.0",
@@ -53,8 +53,8 @@
5353
"ergebnis/composer-normalize": "^2.42.0",
5454
"php-parallel-lint/php-parallel-lint": "^1.3.2",
5555
"phpstan/extension-installer": "^1.3.1",
56-
"phpstan/phpstan-deprecation-rules": "^1.1.4",
57-
"phpstan/phpstan-phpunit": "^1.3.16",
56+
"phpstan/phpstan-deprecation-rules": "^2.0.1",
57+
"phpstan/phpstan-phpunit": "^2.0.1",
5858
"phpunit/phpunit": "^9.6.17 || ^10.0",
5959
"symfony/config": "^5.0 || ^6.0 || ^7.0",
6060
"symfony/dependency-injection": "^5.4.36 || ^6.4.2 || ^7.0.2",

phpstan.neon

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ parameters:
77
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
88
level: 8
99

10+
treatPhpDocTypesAsCertain: false
11+
1012
paths:
1113
- bin
1214
- config
@@ -29,10 +31,6 @@ parameters:
2931
# static reflection
3032
- stubs
3133

32-
# see https://github.com/rectorphp/rector/issues/3490#issue-634342324
33-
featureToggles:
34-
disableRuntimeReflectionProvider: true
35-
3634
bootstrapFiles:
3735
- tests/bootstrap-phpstan.php
3836

@@ -50,3 +48,23 @@ parameters:
5048

5149
- '#^Call to method needs\(\) on an unknown class Illuminate\\Contracts\\Container\\ContextualBindingBuilder.$#'
5250
- '#^Parameter \#1 \$node \(PhpParser\\Node\\Stmt\\Return_\) of method Ssch\\TYPO3Rector\\TYPO310\\v3\\RemoveExcludeOnTransOrigPointerFieldRector::refactor\(\)#'
51+
52+
-
53+
identifier: phpunit.dataProviderMethod
54+
55+
-
56+
identifier: return.type
57+
58+
-
59+
identifier: method.childReturnType
60+
61+
-
62+
identifier: return.unusedType
63+
64+
-
65+
identifier: assign.propertyType
66+
67+
-
68+
identifier: argument.type
69+
70+
- '#Method .*::provideMinPhpVersion\(\) never returns#'

rules/CodeQuality/General/AddErrorCodeToExceptionRector.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
use PhpParser\Node;
88
use PhpParser\Node\Expr\New_;
9-
use PhpParser\Node\Expr\Throw_ as ThrowExpression;
10-
use PhpParser\Node\Stmt\Throw_ as ThrowStatement;
9+
use PhpParser\Node\Expr\Throw_;
1110
use Rector\Rector\AbstractRector;
1211
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
1312
use Ssch\TYPO3Rector\Contract\NoChangelogRequiredInterface;
@@ -37,11 +36,11 @@ public function getRuleDefinition(): RuleDefinition
3736
*/
3837
public function getNodeTypes(): array
3938
{
40-
return [ThrowStatement::class, ThrowExpression::class];
39+
return [Throw_::class];
4140
}
4241

4342
/**
44-
* @param ThrowStatement|ThrowExpression $node
43+
* @param Throw_ $node
4544
*/
4645
public function refactor(Node $node): ?Node
4746
{
@@ -63,10 +62,7 @@ public function refactor(Node $node): ?Node
6362
return $node;
6463
}
6564

66-
/**
67-
* @param ThrowStatement|ThrowExpression $node
68-
*/
69-
private function shouldSkip($node): bool
65+
private function shouldSkip(Throw_ $node): bool
7066
{
7167
if (! $node->expr instanceof New_) {
7268
return true;

rules/CodeQuality/General/ExtEmConfRector.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
namespace Ssch\TYPO3Rector\CodeQuality\General;
66

77
use PhpParser\Node;
8+
use PhpParser\Node\ArrayItem;
89
use PhpParser\Node\Expr;
910
use PhpParser\Node\Expr\Array_;
1011
use PhpParser\Node\Expr\ArrayDimFetch;
11-
use PhpParser\Node\Expr\ArrayItem;
1212
use PhpParser\Node\Expr\Assign;
1313
use PhpParser\Node\Scalar\String_;
1414
use Rector\Contract\Rector\ConfigurableRectorInterface;
@@ -111,7 +111,7 @@ public function refactor(Node $node): ?Node
111111
return null;
112112
}
113113

114-
if ($node->expr->items === [] || $node->expr->items === null) {
114+
if ($node->expr->items === []) {
115115
return null;
116116
}
117117

@@ -142,7 +142,7 @@ public function refactor(Node $node): ?Node
142142
continue;
143143
}
144144

145-
if ($item->value->items === null) {
145+
if ($item->value->items === []) {
146146
continue;
147147
}
148148

@@ -160,7 +160,7 @@ public function refactor(Node $node): ?Node
160160
continue;
161161
}
162162

163-
if ($constraintItem->value->items === null) {
163+
if ($constraintItem->value->items === []) {
164164
continue;
165165
}
166166

rules/CodeQuality/General/InjectMethodToConstructorInjectionRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Ssch\TYPO3Rector\CodeQuality\General;
66

7+
use PhpParser\Modifiers;
78
use PhpParser\Node;
89
use PhpParser\Node\Expr\Assign;
910
use PhpParser\Node\Expr\PropertyFetch;
@@ -142,7 +143,7 @@ public function refactor(Node $node): ?Node
142143

143144
$this->classDependencyManipulator->addConstructorDependency(
144145
$node,
145-
new PropertyMetadata($paramName, new ObjectType((string) $param->type), Class_::MODIFIER_PROTECTED)
146+
new PropertyMetadata($paramName, new ObjectType((string) $param->type), Modifiers::PROTECTED)
146147
);
147148
$this->removeNodeFromStatements($node, $injectMethod);
148149
}

rules/CodeQuality/General/MoveExtensionManagementUtilityAddStaticFileIntoTCAOverridesRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use PhpParser\Node\Expr\Variable;
1010
use PhpParser\Node\Scalar\String_;
1111
use PhpParser\Node\Stmt\Expression;
12-
use PhpParser\NodeTraverser;
12+
use PhpParser\NodeVisitor;
1313
use PHPStan\Type\ObjectType;
1414
use Rector\PhpParser\Printer\BetterStandardPrinter;
1515
use Rector\Rector\AbstractRector;
@@ -126,7 +126,7 @@ public function refactor(Node $node)
126126
);
127127
}
128128

129-
return NodeTraverser::REMOVE_NODE;
129+
return NodeVisitor::REMOVE_NODE;
130130
}
131131

132132
private function shouldSkip(StaticCall $staticMethodCall): bool

rules/CodeQuality/General/MoveExtensionManagementUtilityAddToAllTCAtypesIntoTCAOverridesRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use PhpParser\Node\Expr\Variable;
1010
use PhpParser\Node\Scalar\String_;
1111
use PhpParser\Node\Stmt\Expression;
12-
use PhpParser\NodeTraverser;
12+
use PhpParser\NodeVisitor;
1313
use PHPStan\Type\ObjectType;
1414
use Rector\PhpParser\Node\Value\ValueResolver;
1515
use Rector\PhpParser\Printer\BetterStandardPrinter;
@@ -131,7 +131,7 @@ public function refactor(Node $node)
131131
);
132132
}
133133

134-
return NodeTraverser::REMOVE_NODE;
134+
return NodeVisitor::REMOVE_NODE;
135135
}
136136

137137
private function shouldSkip(StaticCall $staticMethodCall): bool

rules/CodeQuality/General/MoveExtensionUtilityRegisterPluginIntoTCAOverridesRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use PhpParser\Node\Expr\Variable;
1010
use PhpParser\Node\Scalar\String_;
1111
use PhpParser\Node\Stmt\Expression;
12-
use PhpParser\NodeTraverser;
12+
use PhpParser\NodeVisitor;
1313
use PHPStan\Type\ObjectType;
1414
use Rector\PhpParser\Printer\BetterStandardPrinter;
1515
use Rector\Rector\AbstractRector;
@@ -126,7 +126,7 @@ public function refactor(Node $node)
126126
);
127127
}
128128

129-
return NodeTraverser::REMOVE_NODE;
129+
return NodeVisitor::REMOVE_NODE;
130130
}
131131

132132
private function shouldSkip(StaticCall $staticMethodCall): bool

rules/TYPO310/v0/RemoveFormatConstantsEmailFinisherRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
namespace Ssch\TYPO3Rector\TYPO310\v0;
66

77
use PhpParser\Node;
8+
use PhpParser\Node\ArrayItem;
89
use PhpParser\Node\Expr;
910
use PhpParser\Node\Expr\ArrayDimFetch;
10-
use PhpParser\Node\Expr\ArrayItem;
1111
use PhpParser\Node\Expr\Assign;
1212
use PhpParser\Node\Expr\BinaryOp\Identical;
1313
use PhpParser\Node\Expr\ClassConstFetch;

rules/TYPO310/v0/UseControllerClassesInExtbasePluginsAndModulesRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
namespace Ssch\TYPO3Rector\TYPO310\v0;
66

77
use PhpParser\Node;
8+
use PhpParser\Node\ArrayItem;
89
use PhpParser\Node\Expr;
910
use PhpParser\Node\Expr\Array_;
10-
use PhpParser\Node\Expr\ArrayItem;
1111
use PhpParser\Node\Expr\BinaryOp\Concat;
1212
use PhpParser\Node\Expr\StaticCall;
1313
use PhpParser\Node\Expr\Variable;

0 commit comments

Comments
 (0)