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',

0 commit comments

Comments
 (0)