Skip to content

Commit 684554a

Browse files
committed
docs: update docs for version auto-detection
1 parent 75c549e commit 684554a

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,20 @@ composer require --dev driftingly/rector-laravel
2323

2424
## Automate Laravel Upgrades
2525

26-
To add a set to your config, use `RectorLaravel\Set\LaravelLevelSetList` and pick the constant that matches your target version.
27-
Sets for higher versions include sets for lower versions.
26+
To automatically apply the correct rules depending on the version of Laravel (or other packages) you are currently on (as detected in the `composer.json`), use the following:
2827

2928
```php
3029
<?php declare(strict_types=1);
3130

3231
use Rector\Config\RectorConfig;
33-
use RectorLaravel\Set\LaravelLevelSetList;
32+
use RectorLaravel\Set\LaravelSetProvider;
3433

3534
return RectorConfig::configure()
36-
->withSets([
37-
LaravelLevelSetList::UP_TO_LARAVEL_110,
38-
]);
35+
->withSetProviders(LaravelSetProvider::class)
36+
->withComposerBased(laravel: true, /** other options */);
3937
```
4038

41-
The sets in `RectorLaravel\Set\LaravelSetList` only contain changes related to a specific version upgrade.
42-
For example, the rules in `LaravelSetList::LARAVEL_110` apply when upgrading from Laravel 10 to Laravel 11.
39+
You can use the sets in `RectorLaravel\Set\LaravelLevelSetList` if you would like to only include sets that are relevant to a specific version upgrade.
4340

4441
## Additional Sets
4542

@@ -62,15 +59,15 @@ return RectorConfig::configure()
6259
| Set | Purpose |
6360
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
6461
| [LaravelSetList::LARAVEL_ARRAYACCESS_TO_METHOD_CALL](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-arrayaccess-to-method-call.php) | Converts uses of things like `$app['config']` to `$app->make('config')`. |
65-
| [LaravelSetList::LARAVEL_ARRAY_STR_FUNCTION_TO_STATIC_CALL](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-array-str-functions-to-static-call.php) | Converts most string and array helpers into Str and Arr Facades' static calls.<br/>https://laravel.com/docs/11.x/facades#facades-vs-helper-functions |
62+
| [LaravelSetList::LARAVEL_ARRAY_STR_FUNCTION_TO_STATIC_CALL](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-array-str-functions-to-static-call.php) | Converts most string and array helpers into Str and Arr Facades' static calls.<br/><https://laravel.com/docs/11.x/facades#facades-vs-helper-functions> |
6663
| [LaravelSetList::LARAVEL_CODE_QUALITY](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-code-quality.php) | Replaces magical call on `$this->app["something"]` to standalone variable with PHPDocs. |
6764
| [LaravelSetList::LARAVEL_COLLECTION](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-collection.php) | Improves the usage of Laravel Collections by using simpler, more efficient, or more readable methods. |
68-
| [LaravelSetList::LARAVEL_CONTAINER_STRING_TO_FULLY_QUALIFIED_NAME](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-container-string-to-fully-qualified-name.php) | Changes the string or class const used for a service container make call.<br/>https://laravel.com/docs/11.x/container#the-make-method |
69-
| [LaravelSetList::LARAVEL_ELOQUENT_MAGIC_METHOD_TO_QUERY_BUILDER](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-eloquent-magic-method-to-query-builder.php) | Transforms magic method calls on Eloquent Models into corresponding Query Builder method calls.<br/>https://laravel.com/docs/11.x/eloquent |
70-
| [LaravelSetList::LARAVEL_FACADE_ALIASES_TO_FULL_NAMES](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-facade-aliases-to-full-names.php) | Replaces Facade aliases with full Facade names.<br/>https://laravel.com/docs/11.x/facades#facade-class-reference |
71-
| [LaravelSetList::LARAVEL_IF_HELPERS](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-if-helpers.php) | Replaces `abort()`, `report()`, `throw` statements inside conditions with `abort_if()`, `report_if()`, `throw_if()` function calls.<br/>https://laravel.com/docs/11.x/helpers#method-abort-if |
72-
| [LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-legacy-factories-to-classes.php) | Migrates Eloquent legacy model factories (with closures) into class based factories.<br/>https://laravel.com/docs/8.x/releases#model-factory-classes |
73-
| [LaravelSetList::LARAVEL_STATIC_TO_INJECTION](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-static-to-injection.php) | Replaces Laravel's Facades with Dependency Injection.<br/>https://tomasvotruba.com/blog/2019/03/04/how-to-turn-laravel-from-static-to-dependency-injection-in-one-day/<br/>https://laravel.com/docs/11.x/facades#facades-vs-dependency-injection |
65+
| [LaravelSetList::LARAVEL_CONTAINER_STRING_TO_FULLY_QUALIFIED_NAME](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-container-string-to-fully-qualified-name.php) | Changes the string or class const used for a service container make call.<br/><https://laravel.com/docs/11.x/container#the-make-method> |
66+
| [LaravelSetList::LARAVEL_ELOQUENT_MAGIC_METHOD_TO_QUERY_BUILDER](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-eloquent-magic-method-to-query-builder.php) | Transforms magic method calls on Eloquent Models into corresponding Query Builder method calls.<br/><https://laravel.com/docs/11.x/eloquent> |
67+
| [LaravelSetList::LARAVEL_FACADE_ALIASES_TO_FULL_NAMES](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-facade-aliases-to-full-names.php) | Replaces Facade aliases with full Facade names.<br/><https://laravel.com/docs/11.x/facades#facade-class-reference> |
68+
| [LaravelSetList::LARAVEL_IF_HELPERS](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-if-helpers.php) | Replaces `abort()`, `report()`, `throw` statements inside conditions with `abort_if()`, `report_if()`, `throw_if()` function calls.<br/><https://laravel.com/docs/11.x/helpers#method-abort-if> |
69+
| [LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-legacy-factories-to-classes.php) | Migrates Eloquent legacy model factories (with closures) into class based factories.<br/><https://laravel.com/docs/8.x/releases#model-factory-classes> |
70+
| [LaravelSetList::LARAVEL_STATIC_TO_INJECTION](https://github.com/driftingly/rector-laravel/blob/main/config/sets/laravel-static-to-injection.php) | Replaces Laravel's Facades with Dependency Injection.<br/><https://tomasvotruba.com/blog/2019/03/04/how-to-turn-laravel-from-static-to-dependency-injection-in-one-day/><br/><https://laravel.com/docs/11.x/facades#facades-vs-dependency-injection> |
7471

7572
## Creating New Rules
7673

0 commit comments

Comments
 (0)