-
Notifications
You must be signed in to change notification settings - Fork 62
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
Upgrade RouteActionCallableRector rule to handle groups #284
Conversation
@peterfox let's add it to the Laravel 11 rules, please. |
@GeniJaho I've added it to the Laravel 8 set. Based on the docs https://laravel.com/docs/8.x/upgrade#automatic-controller-namespace-prefixing The only slight issue I can see is that the namespace is set to be |
You're right, there's no easy way to include this rule by default, I missed that case 😅 Should we just keep it out of the set until we find a good solution? Also are the tests failing because of changes in core Rector? |
@GeniJaho as for the set. I think personally for now, let's remove it from the set and consider it in another PR. |
This reverts commit f9c86cf. # Conflicts: # tests/Sets/Laravel80/config/configured_rule.php
Changes
Why
Resolves #178
This also fixes a bug as such where previously routes within a group with a namespace would be rewritten by the rule but given the wrong namespace. This likely didn't occur often because the rule only applies a change if the controller can be found as an existing class.
Notes
Removing Group info
This doesn't remove the namespace from the group. Right now that wouldn't cause a problem because when the controller fully qualified class name is provided to the router, it overrides the group namespace. It would be challenging to implement a removal of the namespace from the group if one or more routes can't be updated within a group.
Another rule that removes the property group etc. might be best to avoid over stuffing this rule anyways.
Groups with the Namespace call
currently:
Won't be converted. It shouldn't be too hard to make this happen, but I wanted to get an MVP of the rule with groups merged in first.
Adding to Laravel 11 Upgrades
This rule should ideally be added to Laravel 11's upgrade rules. I wasn't aware of this because I never used namespaces once Laravel introduced the fully qualified names, but Laravel 11 does away with namespaces, making this rule a valuable upgrade option over having to fiddle with routes.