Skip to content

Commit 00bbfb3

Browse files
authored
Add Laravel 10 upgrade rules (#89)
Add Laravel 10 upgrade rules
1 parent 21c7c03 commit 00bbfb3

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

config/sets/laravel100.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
7+
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
8+
use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector;
9+
use Rector\Renaming\ValueObject\MethodCallRename;
10+
use Rector\Renaming\ValueObject\RenameProperty;
11+
use RectorLaravel\Rector\Class_\UnifyModelDatesWithCastsRector;
12+
13+
# see https://laravel.com/docs/10.x/upgrade
14+
return static function (RectorConfig $rectorConfig): void {
15+
$rectorConfig->import(__DIR__ . '/../config.php');
16+
17+
// https://github.com/laravel/framework/pull/32856/files
18+
$rectorConfig->rule(UnifyModelDatesWithCastsRector::class);
19+
20+
$rectorConfig
21+
->ruleWithConfiguration(RenamePropertyRector::class, [
22+
# https://github.com/laravel/laravel/commit/edcbe6de7c3f17070bf0ccaa2e2b785158ae5ceb
23+
new RenameProperty('App\Http\Kernel', 'routeMiddleware', 'middlewareAliases'),
24+
]);
25+
26+
$rectorConfig
27+
->ruleWithConfiguration(RenameMethodRector::class, [
28+
// https://github.com/laravel/framework/pull/41136/files
29+
new MethodCallRename('Illuminate\Database\Eloquent\Relations\Relation', 'getBaseQuery', 'toBase'),
30+
// https://github.com/laravel/framework/pull/42591/files
31+
new MethodCallRename('Illuminate\Support\Facades\Bus', 'dispatchNow', 'dispatchSync'),
32+
]);
33+
34+
$rectorConfig
35+
->ruleWithConfiguration(RenameFunctionRector::class, [
36+
// https://github.com/laravel/framework/pull/42591/files
37+
'dispatch_now' => 'dispatch_sync',
38+
]);
39+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
use RectorLaravel\Set\LaravelLevelSetList;
8+
use RectorLaravel\Set\LaravelSetList;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->sets([LaravelSetList::LARAVEL_100, LaravelLevelSetList::UP_TO_LARAVEL_90]);
12+
};

src/Set/LaravelLevelSetList.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,9 @@ final class LaravelLevelSetList implements SetListInterface
6767
* @var string
6868
*/
6969
final public const UP_TO_LARAVEL_90 = __DIR__ . '/../../config/sets/level/up-to-laravel-90.php';
70+
71+
/**
72+
* @var string
73+
*/
74+
final public const UP_TO_LARAVEL_100 = __DIR__ . '/../../config/sets/level/up-to-laravel-100.php';
7075
}

src/Set/LaravelSetList.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ final class LaravelSetList implements SetListInterface
7878
*/
7979
final public const LARAVEL_90 = __DIR__ . '/../../config/sets/laravel90.php';
8080

81+
/**
82+
* @var string
83+
*/
84+
final public const LARAVEL_100 = __DIR__ . '/../../config/sets/laravel100.php';
85+
8186
/**
8287
* @var string
8388
*/

0 commit comments

Comments
 (0)