Skip to content

Conversation

@abdel-aouby
Copy link
Contributor

Changes

  • Remove the use of Arr::get($this->routes, $method, []) from the get method in \Illuminate\Routing\RouteCollection::get because it allows to return a route object when searching with "dot" notation. despite the method name, parameter, and PHPDoc indicating that the search is performed by $method (e.g GET , POST ...) and should return array of Route objects when found

Changes
as described and discussed in #54541

  • The current implementation of the get method in \Illuminate\Routing\RouteCollection::get has a side effect that allows us to search by "dot" notation
    example: $this->routeCollectionget->('GET.foo/index'); will return an object instance of Route (not array)
    which contradict:
  1. The parameter name ($method)
  2. The phpDoc that says it should return \Illuminate\Routing\Route[] and not \Illuminate\Routing\Route object as it is in this case

Solution

  • Eliminate the side effect by removing the search by "dot" notation that is provided by Arr::get() and use null-coalescing operator instead to perform a search on the routes collection (first level that contains the methods)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants