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

[10.x] Refactor shared static methodExcludedByOptions method to trait #46498

Merged

Conversation

stayallive
Copy link
Contributor

#44516 introduces a new HasMiddleware interface (which is not documented as of today if anyone wants to take the bait...) that allows you to statically define middleware on controllers (very cool).

The implementation however relies on calling a static method (methodExcludedByOptions) on the framework provided ControllerDispatcher implementation, which in turn implements the ControllerDispatcher contract.

This static method is used in the provided ControllerDispatcher (which is fine) but also called from the Route class even though $this->controllerDispatcher() is type hinted as returning the contract ControllerDispatcher.

This came to light in the Sentry Laravel integration (getsentry/sentry-laravel#662) where we decorate the ControllerDispatcher which results in the call to $this->controllerDispatcher()::methodExcludedByOptions to fail since our decorator class does not have the static method (since it's not part of the contract). This PR aims to fix this without any BC since I've moved the method to a trait which I use on both classes using the method. This seemed like the most pragmatic solution to solve this at this time without BC breakage.

This should also be backported to 9.x probably, but targeted to 10.x feel free to let me know if I should rebase to 9.x instead.

@stayallive stayallive changed the title [10.x] Refactor shared methodExcludedByOptions static method to trait [10.x] Refactor shared static methodExcludedByOptions method to trait Mar 17, 2023
@taylorotwell taylorotwell merged commit 03c95e1 into laravel:10.x Mar 17, 2023
@stayallive stayallive deleted the fix-controller-dispatcher-static-call branch March 18, 2023 21:50
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.

None yet

2 participants