Skip to content

Commit 1593e36

Browse files
Use rector-src#dev-upgrade-to-php-parser5-and-phpstan-2 (#235)
* Use rector-src#dev-upgrade-to-php-parser5-and-phpstan-2 * update to php-parser 5 nodes * cs fix * fix print return * fix use Token as array * fix use token as array on FollowedByCommaAnalyzer * fix downgrade array spread * [ci-review] Rector Rectify * fix Throw_ as Expr on DowngradeThrowExprRector * fix token as array on DowngradeDereferenceableOperationRector * fix constant type on DowngradeNamedArgumentRector * fix ParamTagValueNode usage on DowngradeEnumToConstantListClassRector * fix throw as expr on ArrowFunctionToAnonymousFunctionRector * [ci-review] Rector Rectify * fix * fix throw * [ci-review] Rector Rectify * fix downgrade json const and fix token as array * fix fixture on DowngradeUnionTypeDeclarationRector * fix constant type * fixing phpstan * [ci-review] Rector Rectify * fix phpstan on DowngradeAttributeToAnnotationRector * fix phpstan * fix fixture * handle doc indentation * require dev phpstan webmozart v2 and fix phsptan message return --------- Co-authored-by: GitHub Action <[email protected]>
1 parent eb03bfe commit 1593e36

File tree

59 files changed

+181
-171
lines changed

Some content is hidden

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

59 files changed

+181
-171
lines changed

composer.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
},
99
"require-dev": {
1010
"phpstan/extension-installer": "^1.3",
11-
"phpstan/phpstan": "^1.10",
12-
"phpstan/phpstan-webmozart-assert": "^1.2",
11+
"phpstan/phpstan": "^2.0",
12+
"phpstan/phpstan-webmozart-assert": "^2.0",
1313
"phpunit/phpunit": "^10.5",
14-
"rector/rector-src": "dev-main",
15-
"rector/type-perfect": "^1.0",
14+
"rector/rector-src": "dev-upgrade-to-php-parser5-and-phpstan-2",
1615
"symplify/easy-coding-standard": "^12.3",
17-
"symplify/phpstan-extensions": "^11.4",
18-
"symplify/phpstan-rules": "^13.0",
1916
"symplify/rule-doc-generator": "^12.2",
2017
"symplify/vendor-patches": "^11.3",
2118
"tomasvotruba/class-leak": "^1.0",
@@ -33,7 +30,7 @@
3330
"classmap": ["stubs"]
3431
},
3532
"scripts": {
36-
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify",
33+
"phpstan": "vendor/bin/phpstan analyse --ansi",
3734
"check-cs": "vendor/bin/ecs check --ansi",
3835
"fix-cs": "vendor/bin/ecs check --fix --ansi"
3936
},

phpstan.neon

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
includes:
2-
- vendor/symplify/phpstan-rules/config/symplify-rules.neon
3-
- vendor/symplify/phpstan-rules/config/rector-rules.neon
1+
# to be enabled later once rector upgraded to use phpstan v2
2+
# includes:
3+
# - vendor/symplify/phpstan-rules/config/symplify-rules.neon
4+
# - vendor/symplify/phpstan-rules/config/rector-rules.neon
45

56
parameters:
67
level: 8
@@ -10,6 +11,8 @@ parameters:
1011
# requires exact closure types
1112
checkMissingCallableSignature: true
1213

14+
treatPhpDocTypesAsCertain: false
15+
1316
paths:
1417
- src
1518
- config
@@ -24,11 +27,12 @@ parameters:
2427
- '*/Source/*'
2528

2629
# see https://github.com/rectorphp/type-perfect/
27-
type_perfect:
28-
no_mixed: true
29-
null_over_false: true
30-
narrow_param: true
31-
narrow_return: true
30+
# to be enabled later once rector upgraded to use phpstan v2
31+
# type_perfect:
32+
# no_mixed: true
33+
# null_over_false: true
34+
# narrow_param: true
35+
# narrow_return: true
3236

3337
ignoreErrors:
3438
# php enum value minus
@@ -55,3 +59,18 @@ parameters:
5559
message: '#Parameter \#1 \$attributeClass of class Rector\\DowngradePhp80\\ValueObject\\DowngradeAttributeToAnnotation constructor expects class\-string, string given#'
5660
path: "config/*"
5761

62+
# more advanced usage, but not always working
63+
# see https://github.com/rectorphp/rector-src/actions/runs/11798721617/job/32865546672?pr=6422#step:5:110
64+
- '#Doing instanceof PHPStan\\Type\\.+ is error\-prone and deprecated#'
65+
66+
# phpstan instanceof
67+
-
68+
identifier: phpstanApi.instanceofAssumption
69+
70+
-
71+
identifier: phpstanApi.varTagAssumption
72+
73+
-
74+
identifier: argument.type
75+
76+
- '#Asking about instanceof PHPStan\\.* is not covered by backward compatibility promise#'

rules-tests/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector/Fixture/fixture.php.inc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ SQL;
4242
SELECT *
4343
FROM `table`
4444
WHERE `column` = true;
45-
SQL
46-
);
45+
SQL);
4746
$this->setOnClick(<<<JAVASCRIPT
4847
document.getElementById('{$this->getHtmlId()}').value = '';
4948
document.getElementById('{$this->getHtmlId()}').onchange();
50-
JAVASCRIPT
51-
);
49+
JAVASCRIPT);
5250
}
5351
}
5452

rules-tests/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector/Fixture/line_ends_with_newline_or_semicolon.php.inc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ EOS
4646

4747
$needsDowngrade1 = sprintf(<<<EOS
4848
test %s
49-
EOS
50-
, 'more');
49+
EOS, 'more');
5150

5251
$needsDowngrade2 = <<<EOS
5352
test
54-
EOS
55-
; $z = '';
53+
EOS; $z = '';
5654
}
5755
}
5856

rules-tests/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector/Fixture/arrow_function_inside_call_like.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class ErrorsConsoleStyle
3333

3434
public function table(int $terminalWidth, int $maxHeaderWidth): void
3535
{
36-
$f = static function ($rows) use ($terminalWidth, $maxHeaderWidth) : array {
37-
return array_map(static function ($row) use ($terminalWidth, $maxHeaderWidth) : array {
36+
$f = static function ($rows) use ($terminalWidth, $maxHeaderWidth): array {
37+
return array_map(static function ($row) use ($terminalWidth, $maxHeaderWidth): array {
3838
return array_map(static function ($s) use ($terminalWidth, $maxHeaderWidth) {
3939
if ($terminalWidth > $maxHeaderWidth + 5) {
4040
return wordwrap(

rules-tests/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector/Fixture/preserve-by-ref-closureuse.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class PreserveByRefClosureUse
3737
$nameScopeMap = [];
3838
$f = function () use ($j, &$nameScopeMap): ?int {
3939
$nameScopeMap[] = function () use ($j): callable {
40-
return static function (int $i) use ($j) : int {
40+
return static function (int $i) use ($j): int {
4141
return $i + $j;
4242
};
4343
};

rules-tests/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector/Fixture/with_nullable_return_type.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class WithNullableReturnType
2020
{
2121
public function run()
2222
{
23-
$callable = function () : ?string {
23+
$callable = function (): ?string {
2424
return 'Hello world';
2525
};
2626
}

rules-tests/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector/Fixture/with_return_type.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class WithReturnType
2020
{
2121
public function run()
2222
{
23-
$callable = function () : string {
23+
$callable = function (): string {
2424
return 'Hello world';
2525
};
2626
}

rules-tests/DowngradePhp80/Rector/Expression/DowngradeMatchToSwitchRector/Fixture/in_arrow_function.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class InArrowFunction
3636
];
3737

3838
$mapped = array_map(
39-
static function (mixed $default) : mixed {
39+
static function (mixed $default): mixed {
4040
switch (true) {
4141
case is_string($default):
4242
return sprintf('"%s"', $default);

rules-tests/DowngradePhp80/Rector/Expression/DowngradeMatchToSwitchRector/Fixture/in_arrow_function2.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class InArrowFunction2
2323
{
2424
public function run($value)
2525
{
26-
$mapped = static function (mixed $default) : mixed {
26+
$mapped = static function (mixed $default): mixed {
2727
switch (true) {
2828
case is_string($default):
2929
return sprintf('"%s"', $default);

0 commit comments

Comments
 (0)