[10.x] Refactor shared static methodExcludedByOptions
method to trait
#46498
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#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 theRoute
class even though$this->controllerDispatcher()
is type hinted as returning the contractControllerDispatcher
.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 Iuse
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.