Skip to content

Commit 63459a0

Browse files
Migrate Rector Laravel to community (#65)
* Change namespace, update composer/readme Co-authored-by: Abdul Malik Ikhsan <[email protected]>
1 parent 2decdcf commit 63459a0

File tree

204 files changed

+415
-413
lines changed

Some content is hidden

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

204 files changed

+415
-413
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ See available [Laravel rules](/docs/rector_rules_overview.md)
44

55
## Install
66

7-
This package is already part of [rector/rector](http://github.com/rectorphp/rector) package, so it works out of the box.
7+
This package is a [Rector](https://github.com/rectorphp/rector) extension developed by the Laravel community.
88

9-
All you need to do is install the main package, and you're good to go:
9+
Install the `RectorLaravel` package as dependency:
1010

1111
```bash
12-
composer require rector/rector --dev
12+
composer require driftingly/rector-laravel --dev
1313
```
1414

1515
## Use Sets
1616

17-
To add a set to your config, use `Rector\Laravel\Set\LaravelSetList` class and pick one of constants:
17+
To add a set to your config, use `RectorLaravel\Set\LaravelSetList` class and pick one of the constants:
1818

1919
```php
20-
use Rector\Laravel\Set\LaravelSetList;
20+
use RectorLaravel\Set\LaravelSetList;
2121
use Rector\Config\RectorConfig;
2222

2323
return static function (RectorConfig $rectorConfig): void {
@@ -34,6 +34,6 @@ return static function (RectorConfig $rectorConfig): void {
3434
Rector is a tool that [we develop](https://getrector.org/) and share for free, so anyone can save hundreds of hours on refactoring. But not everyone has time to understand Rector and AST complexity. You have 2 ways to speed this process up:
3535

3636
* read a book - <a href="https://leanpub.com/rector-the-power-of-automated-refactoring">The Power of Automated Refactoring</a>
37-
* hire our experienced team to <a href="https://getrector.org/contact">improve your code base</a>
37+
* hire our experienced team to <a href="https://getrector.org/contact">improve your codebase</a>
3838

3939
Both ways support us to and improve Rector in sustainable way by learning from practical projects.

composer.json

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
{
2-
"name": "rector/rector-laravel",
2+
"name": "driftingly/rector-laravel",
33
"type": "rector-extension",
44
"license": "MIT",
55
"description": "Rector upgrades rules for Laravel Framework",
66
"require": {
77
"php": ">=8.1"
88
},
99
"require-dev": {
10-
"rector/rector-src": "dev-main",
10+
"rector/rector": "dev-main",
1111
"phpunit/phpunit": "^9.5",
1212
"phpstan/phpstan": "^1.8.2",
1313
"symplify/phpstan-rules": "^11.0",
1414
"symplify/phpstan-extensions": "^11.0",
1515
"symplify/easy-coding-standard": "^11.0",
1616
"symplify/rule-doc-generator": "^11.0",
17-
"symplify/monorepo-builder": "^11.0",
1817
"rector/phpstan-rules": "^0.6",
1918
"phpstan/extension-installer": "^1.1",
2019
"phpstan/phpstan-webmozart-assert": "^1.1",
@@ -24,17 +23,16 @@
2423
},
2524
"autoload": {
2625
"psr-4": {
27-
"Rector\\Laravel\\": "src"
26+
"RectorLaravel\\": "src"
2827
}
2928
},
3029
"autoload-dev": {
3130
"psr-4": {
32-
"Rector\\Laravel\\Tests\\": "tests"
31+
"RectorLaravel\\Tests\\": "tests"
3332
},
3433
"classmap": ["stubs"]
3534
},
3635
"scripts": {
37-
"release": "vendor/bin/monorepo-builder release patch --ansi",
3836
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify",
3937
"check-cs": "vendor/bin/ecs check --ansi",
4038
"fix-cs": "vendor/bin/ecs check --fix --ansi",
@@ -43,20 +41,6 @@
4341
"vendor/bin/ecs check-markdown docs/rector_rules_overview.md --ansi --fix"
4442
]
4543
},
46-
"extra": {
47-
"enable-patching": true,
48-
"branch-alias": {
49-
"dev-main": "0.11-dev"
50-
},
51-
"rector": {
52-
"includes": [
53-
"config/config.php"
54-
]
55-
}
56-
},
57-
"conflict": {
58-
"rector/rector": "<0.11"
59-
},
6044
"minimum-stability": "dev",
6145
"prefer-stable": true,
6246
"config": {

config/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
->autowire()
1515
->autoconfigure();
1616

17-
$services->load('Rector\\Laravel\\', __DIR__ . '/../src')
17+
$services->load('RectorLaravel\\', __DIR__ . '/../src')
1818
->exclude([__DIR__ . '/../src/{Rector,ValueObject}']);
1919

2020
$services->set(RenameClassNonPhpRector::class);

config/sets/laravel-array-str-functions-to-static-call.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// @see https://laravel.com/docs/5.7/facades#facades-vs-dependency-injection
1212

1313
return static function (RectorConfig $rectorConfig): void {
14+
$rectorConfig->import(__DIR__ . '/../config.php');
1415
$rectorConfig
1516
->ruleWithConfiguration(
1617
FuncCallToStaticCallRector::class,

config/sets/laravel-code-quality.php

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

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Rector\Assign\CallOnAppArrayAccessToStandaloneAssignRector;
7+
use RectorLaravel\Rector\Assign\CallOnAppArrayAccessToStandaloneAssignRector;
88

99
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->import(__DIR__ . '/../config.php');
1011
$rectorConfig->rule(CallOnAppArrayAccessToStandaloneAssignRector::class);
1112
};

config/sets/laravel-legacy-factories-to-classes.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Rector\FuncCall\FactoryFuncCallToStaticCallRector;
8-
use Rector\Laravel\Rector\MethodCall\FactoryApplyingStatesRector;
9-
use Rector\Laravel\Rector\Namespace_\FactoryDefinitionRector;
7+
use RectorLaravel\Rector\FuncCall\FactoryFuncCallToStaticCallRector;
8+
use RectorLaravel\Rector\MethodCall\FactoryApplyingStatesRector;
9+
use RectorLaravel\Rector\Namespace_\FactoryDefinitionRector;
1010

1111
return static function (RectorConfig $rectorConfig): void {
12+
$rectorConfig->import(__DIR__ . '/../config.php');
13+
1214
// https://laravel.com/docs/7.x/database-testing#writing-factories
1315
// https://laravel.com/docs/8.x/database-testing#defining-model-factories
1416
$rectorConfig->rule(FactoryDefinitionRector::class);

config/sets/laravel-static-to-injection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Rector\FuncCall\HelperFuncCallToFacadeClassRector;
8-
use Rector\Laravel\Rector\StaticCall\RequestStaticValidateToInjectRector;
97
use Rector\Renaming\Rector\Name\RenameClassRector;
108
use Rector\Transform\Rector\FuncCall\ArgumentFuncCallToMethodCallRector;
119
use Rector\Transform\Rector\FuncCall\FuncCallToNewRector;
1210
use Rector\Transform\Rector\StaticCall\StaticCallToMethodCallRector;
1311
use Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall;
1412
use Rector\Transform\ValueObject\ArrayFuncCallToMethodCall;
1513
use Rector\Transform\ValueObject\StaticCallToMethodCall;
14+
use RectorLaravel\Rector\FuncCall\HelperFuncCallToFacadeClassRector;
15+
use RectorLaravel\Rector\StaticCall\RequestStaticValidateToInjectRector;
1616

1717
/**
1818
* @see https://www.freecodecamp.org/news/moving-away-from-magic-or-why-i-dont-want-to-use-laravel-anymore-2ce098c979bd/

config/sets/laravel50.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
# see: https://laravel.com/docs/5.0/upgrade
1212
return static function (RectorConfig $rectorConfig): void {
13+
$rectorConfig->import(__DIR__ . '/../config.php');
14+
1315
# https://stackoverflow.com/a/24949656/1348344
1416
$rectorConfig
1517
->ruleWithConfiguration(RenameClassRector::class, [

config/sets/laravel51.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# see: https://laravel.com/docs/5.1/upgrade
1010
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->import(__DIR__ . '/../config.php');
1112
$rectorConfig
1213
->ruleWithConfiguration(RenameClassRector::class, [
1314
'Illuminate\Validation\Validator' => 'Illuminate\Contracts\Validation\Validator',

config/sets/laravel52.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# see: https://laravel.com/docs/5.2/upgrade
1212
return static function (RectorConfig $rectorConfig): void {
13+
$rectorConfig->import(__DIR__ . '/../config.php');
1314
$rectorConfig
1415
->ruleWithConfiguration(RenameClassRector::class, [
1516
'Illuminate\Auth\Access\UnauthorizedException' => 'Illuminate\Auth\Access\AuthorizationException',

config/sets/laravel53.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Rector\Removing\Rector\Class_\RemoveTraitUseRector;
88

99
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->import(__DIR__ . '/../config.php');
1011
$rectorConfig
1112
->ruleWithConfiguration(RemoveTraitUseRector::class, [
1213
# see https://laravel.com/docs/5.3/upgrade

config/sets/laravel54.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# see: https://laravel.com/docs/5.4/upgrade
1414

1515
return static function (RectorConfig $rectorConfig): void {
16+
$rectorConfig->import(__DIR__ . '/../config.php');
1617
$rectorConfig
1718
->ruleWithConfiguration(StringToClassConstantRector::class, [new StringToClassConstant(
1819
'kernel.handled',

config/sets/laravel55.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# see: https://laravel.com/docs/5.5/upgrade
1414

1515
return static function (RectorConfig $rectorConfig): void {
16+
$rectorConfig->import(__DIR__ . '/../config.php');
1617
$rectorConfig
1718
->ruleWithConfiguration(
1819
RenameMethodRector::class,

config/sets/laravel56.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# see: https://laravel.com/docs/5.6/upgrade
1414

1515
return static function (RectorConfig $rectorConfig): void {
16+
$rectorConfig->import(__DIR__ . '/../config.php');
1617
$rectorConfig
1718
->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename(
1819
'Illuminate\Validation\ValidatesWhenResolvedTrait',

config/sets/laravel57.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
use Rector\Arguments\ValueObject\ArgumentAdder;
99
use Rector\Config\RectorConfig;
1010
use Rector\Core\ValueObject\Visibility;
11-
use Rector\Laravel\Rector\Class_\AddMockConsoleOutputFalseToConsoleTestsRector;
12-
use Rector\Laravel\Rector\ClassMethod\AddParentBootToModelClassMethodRector;
13-
use Rector\Laravel\Rector\MethodCall\ChangeQueryWhereDateValueWithCarbonRector;
14-
use Rector\Laravel\Rector\New_\AddGuardToLoginEventRector;
15-
use Rector\Laravel\Rector\StaticCall\Redirect301ToPermanentRedirectRector;
1611
use Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector;
1712
use Rector\Removing\ValueObject\ArgumentRemover;
1813
use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector;
1914
use Rector\Visibility\ValueObject\ChangeMethodVisibility;
15+
use RectorLaravel\Rector\Class_\AddMockConsoleOutputFalseToConsoleTestsRector;
16+
use RectorLaravel\Rector\ClassMethod\AddParentBootToModelClassMethodRector;
17+
use RectorLaravel\Rector\MethodCall\ChangeQueryWhereDateValueWithCarbonRector;
18+
use RectorLaravel\Rector\New_\AddGuardToLoginEventRector;
19+
use RectorLaravel\Rector\StaticCall\Redirect301ToPermanentRedirectRector;
2020

2121
# see: https://laravel.com/docs/5.7/upgrade
2222
return static function (RectorConfig $rectorConfig): void {
23+
$rectorConfig->import(__DIR__ . '/../config.php');
2324
$rectorConfig
2425
->ruleWithConfiguration(
2526
ChangeMethodVisibilityRector::class,

config/sets/laravel58.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use PHPStan\Type\BooleanType;
66

77
use Rector\Config\RectorConfig;
8-
use Rector\Laravel\Rector\Class_\PropertyDeferToDeferrableProviderToRector;
9-
use Rector\Laravel\Rector\StaticCall\MinutesToSecondsInCacheRector;
108
use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector;
119
use Rector\Renaming\ValueObject\RenameProperty;
1210
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
1311
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
12+
use RectorLaravel\Rector\Class_\PropertyDeferToDeferrableProviderToRector;
13+
use RectorLaravel\Rector\StaticCall\MinutesToSecondsInCacheRector;
1414

1515
# https://laravel-news.com/laravel-5-8-deprecates-string-and-array-helpers
1616
# https://github.com/laravel/framework/pull/26898

config/sets/laravel60.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# https://github.com/laravel/docs/pull/5531/files
2121

2222
return static function (RectorConfig $rectorConfig): void {
23+
$rectorConfig->import(__DIR__ . '/../config.php');
24+
2325
# https://github.com/laravel/framework/commit/67a38ba0fa2acfbd1f4af4bf7d462bb4419cc091
2426
$rectorConfig->rule(ParamTypeDeclarationRector::class);
2527

config/sets/laravel70.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
# see https://laravel.com/docs/7.x/upgrade
1717
return static function (RectorConfig $rectorConfig): void {
18+
$rectorConfig->import(__DIR__ . '/../config.php');
19+
1820
# https://github.com/laravel/framework/pull/30610/files
1921
$rectorConfig
2022
->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [

config/sets/laravel80.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88
use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
99
use Rector\Arguments\ValueObject\ArgumentAdder;
1010
use Rector\Config\RectorConfig;
11-
use Rector\Laravel\Rector\ClassMethod\AddArgumentDefaultValueRector;
12-
use Rector\Laravel\Rector\ClassMethod\AddParentRegisterToEventServiceProviderRector;
13-
use Rector\Laravel\ValueObject\AddArgumentDefaultValue;
1411
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
1512
use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector;
1613
use Rector\Renaming\ValueObject\MethodCallRename;
1714
use Rector\Renaming\ValueObject\RenameProperty;
15+
use RectorLaravel\Rector\ClassMethod\AddArgumentDefaultValueRector;
16+
use RectorLaravel\Rector\ClassMethod\AddParentRegisterToEventServiceProviderRector;
17+
use RectorLaravel\ValueObject\AddArgumentDefaultValue;
1818

1919
# see https://laravel.com/docs/8.x/upgrade
2020
return static function (RectorConfig $rectorConfig): void {
21+
$rectorConfig->import(__DIR__ . '/../config.php');
22+
2123
# https://github.com/laravel/framework/commit/4d228d6e9dbcbd4d97c45665980d8b8c685b27e6
2224
$rectorConfig
2325
->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder(

config/sets/laravel90.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
# see https://laravel.com/docs/9.x/upgrade
1515
return static function (RectorConfig $rectorConfig): void {
16+
$rectorConfig->import(__DIR__ . '/../config.php');
17+
1618
// https://github.com/laravel/framework/commit/8f9ddea4481717943ed4ecff96d86b703c81a87d
1719
$rectorConfig
1820
->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder(

config/sets/level/up-to-laravel-51.php

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

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Set\LaravelSetList;
7+
use RectorLaravel\Set\LaravelSetList;
88

99
return static function (RectorConfig $rectorConfig): void {
1010
$rectorConfig->sets([LaravelSetList::LARAVEL_50, LaravelSetList::LARAVEL_51]);

config/sets/level/up-to-laravel-52.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Set\LaravelLevelSetList;
8-
use Rector\Laravel\Set\LaravelSetList;
7+
use RectorLaravel\Set\LaravelLevelSetList;
8+
use RectorLaravel\Set\LaravelSetList;
99

1010
return static function (RectorConfig $rectorConfig): void {
1111
$rectorConfig->sets([LaravelSetList::LARAVEL_52, LaravelLevelSetList::UP_TO_LARAVEL_51]);

config/sets/level/up-to-laravel-53.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Set\LaravelLevelSetList;
8-
use Rector\Laravel\Set\LaravelSetList;
7+
use RectorLaravel\Set\LaravelLevelSetList;
8+
use RectorLaravel\Set\LaravelSetList;
99

1010
return static function (RectorConfig $rectorConfig): void {
1111
$rectorConfig->sets([LaravelSetList::LARAVEL_53, LaravelLevelSetList::UP_TO_LARAVEL_52]);

config/sets/level/up-to-laravel-54.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Set\LaravelLevelSetList;
8-
use Rector\Laravel\Set\LaravelSetList;
7+
use RectorLaravel\Set\LaravelLevelSetList;
8+
use RectorLaravel\Set\LaravelSetList;
99

1010
return static function (RectorConfig $rectorConfig): void {
1111
$rectorConfig->sets([LaravelSetList::LARAVEL_54, LaravelLevelSetList::UP_TO_LARAVEL_53]);

config/sets/level/up-to-laravel-55.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Set\LaravelLevelSetList;
8-
use Rector\Laravel\Set\LaravelSetList;
7+
use RectorLaravel\Set\LaravelLevelSetList;
8+
use RectorLaravel\Set\LaravelSetList;
99

1010
return static function (RectorConfig $rectorConfig): void {
1111
$rectorConfig->sets([LaravelSetList::LARAVEL_55, LaravelLevelSetList::UP_TO_LARAVEL_54]);

config/sets/level/up-to-laravel-56.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Set\LaravelLevelSetList;
8-
use Rector\Laravel\Set\LaravelSetList;
7+
use RectorLaravel\Set\LaravelLevelSetList;
8+
use RectorLaravel\Set\LaravelSetList;
99

1010
return static function (RectorConfig $rectorConfig): void {
1111
$rectorConfig->sets([LaravelSetList::LARAVEL_56, LaravelLevelSetList::UP_TO_LARAVEL_55]);

config/sets/level/up-to-laravel-57.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Set\LaravelLevelSetList;
8-
use Rector\Laravel\Set\LaravelSetList;
7+
use RectorLaravel\Set\LaravelLevelSetList;
8+
use RectorLaravel\Set\LaravelSetList;
99

1010
return static function (RectorConfig $rectorConfig): void {
1111
$rectorConfig->sets([LaravelSetList::LARAVEL_57, LaravelLevelSetList::UP_TO_LARAVEL_56]);

config/sets/level/up-to-laravel-58.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Rector\Config\RectorConfig;
66

7-
use Rector\Laravel\Set\LaravelLevelSetList;
8-
use Rector\Laravel\Set\LaravelSetList;
7+
use RectorLaravel\Set\LaravelLevelSetList;
8+
use RectorLaravel\Set\LaravelSetList;
99

1010
return static function (RectorConfig $rectorConfig): void {
1111
$rectorConfig->sets([LaravelSetList::LARAVEL_58, LaravelLevelSetList::UP_TO_LARAVEL_57]);

0 commit comments

Comments
 (0)