Skip to content

Commit 44674a8

Browse files
GeniJahomwikberg-virtasamsonasikmaks-oleksyuk
authored
Rector 2.0 (#277)
* PHPStan & Rector 2.0 support (#271) * Update rector dependency to 2.0.0-rc1 (#273) * Update rector to 2.0.0.rc2 * Simplify composer scripts * Fix downgrade scripts * Add MigrateToSimplifiedAttributeRector to Laravel 9 set (#275) * Update Duster and use latest Pint configuration (#276) * Update Duster * Remove pint.json and run Duster * Refactor into our own AbstractRector that implements DocumentedRuleInterface * Update to Rector 2.0 --------- Co-authored-by: Michael Wikberg <[email protected]> Co-authored-by: Abdul Malik Ikhsan <[email protected]> Co-authored-by: M ɑ k s <[email protected]>
1 parent f8d624d commit 44674a8

File tree

153 files changed

+418
-509
lines changed

Some content is hidden

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

153 files changed

+418
-509
lines changed

.github/workflows/downgraded_release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515

1616
steps:
1717
-
18-
uses: "actions/checkout@v3"
18+
uses: "actions/checkout@v4"
1919

2020
-
2121
uses: "shivammathur/setup-php@v2"
2222
with:
23-
php-version: 8.2
23+
php-version: 8.3
2424
coverage: none
2525

2626
- uses: "ramsey/composer-install@v2"

build/composer-php-72.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Rector upgrades rules for Laravel Framework",
66
"require": {
77
"php": "^7.2 || ^8.0",
8-
"rector/rector": "^1.0"
8+
"rector/rector": "^2.0"
99
},
1010
"autoload": {
1111
"psr-4": {

build/rector-downgrade-php-72.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\Set\ValueObject\DowngradeLevelSetList;
76

8-
return static function (RectorConfig $rectorConfig): void {
9-
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_72]);
10-
};
7+
return RectorConfig::configure()->withDowngradeSets(php72: true);

composer.json

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
"description": "Rector upgrades rules for Laravel Framework",
66
"require": {
77
"php": ">=8.2",
8-
"rector/rector": "^1.2.5"
8+
"rector/rector": "^2.0.0",
9+
"webmozart/assert": "^1.11",
10+
"symplify/rule-doc-generator-contracts": "^11.2"
911
},
1012
"require-dev": {
11-
"nikic/php-parser": "^4.18",
13+
"nikic/php-parser": "^5.3",
1214
"phpstan/extension-installer": "^1.3",
13-
"phpstan/phpstan": "^1.10",
14-
"phpstan/phpstan-strict-rules": "^1.5",
15-
"phpstan/phpstan-webmozart-assert": "^1.2",
15+
"phpstan/phpstan": "^2.0",
16+
"phpstan/phpstan-deprecation-rules": "^2.0",
17+
"phpstan/phpstan-strict-rules": "^2.0",
18+
"phpstan/phpstan-webmozart-assert": "^2.0",
1619
"phpunit/phpunit": "^10.5",
17-
"symplify/phpstan-extensions": "^11.4",
18-
"symplify/phpstan-rules": "^12.4",
19-
"symplify/rule-doc-generator": "^12.1",
20-
"tightenco/duster": "^2.7"
20+
"symplify/rule-doc-generator": "^12.2",
21+
"tightenco/duster": "^3.1"
2122
},
2223
"autoload": {
2324
"psr-4": {
@@ -31,9 +32,7 @@
3132
"classmap": ["stubs"]
3233
},
3334
"scripts": {
34-
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify",
35-
"check-cs": "vendor/bin/duster lint",
36-
"fix-cs": "vendor/bin/duster fix",
35+
"phpstan": "vendor/bin/phpstan analyse --ansi",
3736
"lint": "vendor/bin/duster lint",
3837
"fix": "vendor/bin/duster fix",
3938
"rector-dry-run": "vendor/bin/rector process --dry-run --ansi",

config/config.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44

55
use Rector\Config\RectorConfig;
66

7-
return static function (RectorConfig $rectorConfig): void {
8-
};
7+
return static function (RectorConfig $rectorConfig): void {};

config/sets/laravel90.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector;
1313
use Rector\Visibility\ValueObject\ChangeMethodVisibility;
1414
use RectorLaravel\Rector\Class_\AddExtendsAnnotationToModelFactoriesRector;
15+
use RectorLaravel\Rector\ClassMethod\MigrateToSimplifiedAttributeRector;
1516
use RectorLaravel\Rector\PropertyFetch\ReplaceFakerInstanceWithHelperRector;
1617

1718
// see https://laravel.com/docs/9.x/upgrade
@@ -106,4 +107,7 @@
106107
// https://github.com/laravel/framework/commit/9894c2c64dc70f7dfda2ac46dfdaa8769ce4596a
107108
new MethodCallRename('Illuminate\Testing\TestResponse', 'assertDeleted', 'assertModelMissing'),
108109
]);
110+
111+
// https://github.com/laravel/framework/commit/e0c2620b57be6416820ea7ca8e46fd2f71d2fe35
112+
$rectorConfig->rule(MigrateToSimplifiedAttributeRector::class);
109113
};

phpstan.neon

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
includes:
2-
- vendor/symplify/phpstan-rules/config/rector-rules.neon
31
parameters:
42
level: max
53

@@ -15,7 +13,7 @@ parameters:
1513
- */Source/*
1614
- *Source/*
1715

18-
# reportUnmatchedIgnoredErrors: false
16+
treatPhpDocTypesAsCertain: false
1917

2018
ignoreErrors:
2119
# false positive
@@ -32,3 +30,7 @@ parameters:
3230

3331
# Laravel Container not being recognized properly in some of the tests
3432
- '#Call to method needs\(\) on an unknown class Illuminate\\Contracts\\Container\\ContextualBindingBuilder#'
33+
- '#Cannot call method give\(\) on mixed.#'
34+
35+
# No easy replacement for this check, it's also ignored in core Rector
36+
- '#Doing instanceof PHPStan\\Type\\Generic\\GenericObjectType is error\-prone and deprecated#'

pint.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/AbstractRector.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace RectorLaravel;
4+
5+
use Rector\Rector\AbstractRector as BaseAbstractRector;
6+
use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
7+
8+
abstract class AbstractRector extends BaseAbstractRector implements DocumentedRuleInterface {}

src/NodeAnalyzer/LumenRouteRegisteringMethodAnalyzer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
public function __construct(
1717
private NodeTypeResolver $nodeTypeResolver,
1818
private NodeNameResolver $nodeNameResolver
19-
) {
20-
}
19+
) {}
2120

2221
public function isLumenRoutingClass(MethodCall $methodCall): bool
2322
{

0 commit comments

Comments
 (0)