driftingly/rector-laravel

RouteActionCallableRector with Named Routes

Closed this issue · 3 comments

This currently doesn't work for named routes. I searched through possible configuration options but couldn't find anything.

Is it possible to do this currently?

@bradsi I don't follow latest laravel feature, could you provide the failing fixture test to show diff before and after for expected input/output for it with the rule related to it? It should be on

https://github.com/rectorphp/rector-laravel/tree/main/tests/Rector/StaticCall/RouteActionCallableRector/Fixture

Thank you.

@samsonasik Thanks for replying so quick!

I'm not too clued up on Rector or fixtures, sorry. Happy to contribute where I can though, might just need a bit of guidance.

Here is an example of a named route in the old Laravel syntax:

Route::get('/test', ['as' => 'test-route', 'uses' => 'TestController@action']);

New syntax named route looks like this:

Route::get('/test', [TestController::class, 'action'])->name('test-route');

Currently, when running the RouteActionCallableRector rule, the named routes are skipped.

I hope that helps, happy to provide any more info if needed.

Could you create failing fixture PR test for it? You can copy one of fixture and modify to show before after at

https://github.com/rectorphp/rector-laravel/tree/main/tests/Rector/StaticCall/RouteActionCallableRector/Fixture