diff --git a/README.md b/README.md index bbd169fd784..bbbaacca455 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Rector **instantly upgrades and instantly refactors PHP code of your application - Rename classes, methods, properties, namespaces, constants... anything :) - Add, replace or remove arguments -- Add [parameter or return type declarations](https://www.tomasvotruba.cz/blog/2019/01/03/how-to-complete-type-declarations-without-docblocks-with-rector/) without docblocks - just with static analysis +- Add [parameter or return type declarations](https://www.tomasvotruba.cz/blog/2019/01/03/how-to-complete-type-declarations-without-docblocks-with-rector/) without docblocks - just with static analysis - Change visibility of constant, property or method - Upgrade from PHP 5.3 to PHP 7.4 - [Complete PHP 7.4 property type declarations](https://www.tomasvotruba.cz/blog/2018/11/15/how-to-get-php-74-typed-properties-to-your-code-in-few-seconds/) diff --git a/config/level/laravel/laravel50.yaml b/config/level/laravel/laravel50.yaml new file mode 100644 index 00000000000..48110292a70 --- /dev/null +++ b/config/level/laravel/laravel50.yaml @@ -0,0 +1,16 @@ +# see: https://laravel.com/docs/5.0/upgrade +services: + Rector\Rector\Class_\RenameClassRector: + Illuminate\Cache\CacheManager: 'Illuminate\Contracts\Cache\Repository' + # https://stackoverflow.com/a/24949656/1348344 + Illuminate\Database\Eloquent\SoftDeletingTrait: 'Illuminate\Database\Eloquent\SoftDeletes' + + Rector\Rector\MethodCall\RenameMethodRector: + Illuminate\Contracts\Pagination\Paginator: + links: 'render' + getFrom: 'firstItem' + getTo: 'lastItem' + getPerPage: 'perPage' + getCurrentPage: 'currentPage' + getLastPage: 'lastPage' + getTotal: 'total' diff --git a/config/level/laravel/laravel51.yaml b/config/level/laravel/laravel51.yaml new file mode 100644 index 00000000000..da7f6c08199 --- /dev/null +++ b/config/level/laravel/laravel51.yaml @@ -0,0 +1,4 @@ +# see: https://laravel.com/docs/5.1/upgrade +services: + Rector\Rector\Class_\RenameClassRector: + Illuminate\Validation\Validator: 'Illuminate\Contracts\Validation\Validator' diff --git a/config/level/laravel/laravel52.yaml b/config/level/laravel/laravel52.yaml new file mode 100644 index 00000000000..be5b1aa04ff --- /dev/null +++ b/config/level/laravel/laravel52.yaml @@ -0,0 +1,23 @@ +# see: https://laravel.com/docs/5.2/upgrade +services: + Rector\Rector\Class_\RenameClassRector: + Illuminate\Auth\Access\UnauthorizedException: 'Illuminate\Auth\Access\AuthorizationException' + Illuminate\Http\Exception\HttpResponseException: 'Illuminate\Foundation\Validation\ValidationException' + Illuminate\Foundation\Composer: 'Illuminate\Support\Composer' + + Rector\Rector\String_\StringToClassConstantRector: + artisan.start: ['Illuminate\Console\Events\ArtisanStarting', 'class'] + auth.attempting: ['Illuminate\Auth\Events\Attempting', 'class'] + auth.login: ['Illuminate\Auth\Events\Login', 'class'] + auth.logout: ['Illuminate\Auth\Events\Logout', 'class'] + cache.missed: ['Illuminate\Cache\Events\CacheMissed', 'class'] + cache.hit: ['Illuminate\Cache\Events\CacheHit', 'class'] + cache.write: ['Illuminate\Cache\Events\KeyWritten', 'class'] + cache.delete: ['Illuminate\Cache\Events\KeyForgotten', 'class'] + illuminate.query: ['Illuminate\Database\Events\QueryExecuted', 'class'] + illuminate.queue.before: ['Illuminate\Queue\Events\JobProcessing', 'class'] + illuminate.queue.after: ['Illuminate\Queue\Events\JobProcessed', 'class'] + illuminate.queue.failed: ['Illuminate\Queue\Events\JobFailed', 'class'] + illuminate.queue.stopping: ['Illuminate\Queue\Events\WorkerStopping', 'class'] + mailer.sending: ['Illuminate\Mail\Events\MessageSending', 'class'] + router.matched: ['Illuminate\Routing\Events\RouteMatched', 'class'] diff --git a/docs/AllRectorsOverview.md b/docs/AllRectorsOverview.md index 5916c3d3894..aa158e9926b 100644 --- a/docs/AllRectorsOverview.md +++ b/docs/AllRectorsOverview.md @@ -2277,7 +2277,7 @@ Changes rand, srand and getrandmax by new md_* alternatives. - class: `Rector\Php\Rector\FuncCall\PregReplaceEModifierRector` -The /e modifier is no longer supported, use preg_replace_callback instead +The /e modifier is no longer supported, use preg_replace_callback instead ```diff class SomeClass diff --git a/docs/NodesOverview.md b/docs/NodesOverview.md index 81aef55e937..134b5d8a865 100644 --- a/docs/NodesOverview.md +++ b/docs/NodesOverview.md @@ -910,7 +910,7 @@ if (true) { ```php ?> -feelfeel diff --git a/tests/Rector/String_/StringToClassConstantRector/Fixture/fixture.php.inc b/tests/Rector/String_/StringToClassConstantRector/Fixture/fixture.php.inc index 76bac9db0f3..0a2d14141e5 100644 --- a/tests/Rector/String_/StringToClassConstantRector/Fixture/fixture.php.inc +++ b/tests/Rector/String_/StringToClassConstantRector/Fixture/fixture.php.inc @@ -6,7 +6,10 @@ final class SomeSubscriber { public static function getSubscribedEvents() { - return ['compiler.post_dump' => 'compile']; + return [ + 'compiler.post_dump' => 'compile', + 'compiler.to_class' => 'compile' + ]; } } @@ -20,7 +23,10 @@ final class SomeSubscriber { public static function getSubscribedEvents() { - return [\Yet\AnotherClass::CONSTANT => 'compile']; + return [ + \Yet\AnotherClass::CONSTANT => 'compile', + \Yet\AnotherClass::class => 'compile' + ]; } } diff --git a/tests/Rector/String_/StringToClassConstantRector/StringToClassConstantRectorTest.php b/tests/Rector/String_/StringToClassConstantRector/StringToClassConstantRectorTest.php index 5e8548e576b..90a5e2d91fc 100644 --- a/tests/Rector/String_/StringToClassConstantRector/StringToClassConstantRectorTest.php +++ b/tests/Rector/String_/StringToClassConstantRector/StringToClassConstantRectorTest.php @@ -24,6 +24,7 @@ final class StringToClassConstantRectorTest extends AbstractRectorTestCase { return [ 'compiler.post_dump' => ['Yet\AnotherClass', 'CONSTANT'], + 'compiler.to_class' => ['Yet\AnotherClass', 'class'], ]; } }