Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.7] Add callable docblock to route registrar methods #26524

Merged
merged 1 commit into from
Nov 15, 2018
Merged

[5.7] Add callable docblock to route registrar methods #26524

merged 1 commit into from
Nov 15, 2018

Conversation

patrickbrouwers
Copy link
Contributor

Yesterday I replied on Twitter on an article about tuple/callable route registration that was recently added. However I wasn't completely right that it works. This PR should make it work.

Relevant PR: #24385
Article: https://murze.be/a-better-way-to-register-routes-in-laravel
Tweet: https://twitter.com/patrickbrouwers/status/1062854056522190849

When using Route registration as follows:

Route::get('smth', [SomeController::class, 'methodName']);

(same for typehinted $router - as Registrar/Router)

You can have the benefit of an IDE (tested with PHPStorm) to rename the methodName string automatically whenever you refactor/rename the actual method name.

However, PhpStorm only does this when the parameter is docblocked as callable. This PR adds the callable docblock to the $action param, so auto-refactoring works in IDE's.

Additional suggestion:

Could be an option to drop the Closure docblock, as that's captured with callable already.

@taylorotwell taylorotwell merged commit 5f06f87 into laravel:5.7 Nov 15, 2018
@patrickbrouwers patrickbrouwers deleted the callable-docblock-routes branch November 15, 2018 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants