Debugging of the partial that throws the error reveals a route with an empty methods array.
Debugging of the RouteMatcher reveals that all routes have entries in the methods array.
Placing a try/catch around the render call responsible for triggering the error reveals the route without the method. It's a HEAD route. The method has been lost somewhere.
Tracing the call stack back to the GenerateCommand leads us to Line 118 and $generator->processRoute() as the point where the method is "lost".
On stepping into the Knuckles\Scribe\Extracting\Generator source code, the getMethods method is observed.
/**
* @param Route $route
*
* @return mixed
*/
public function getMethods(Route $route)
{
return array_diff($route->methods(), ['HEAD']);
}
Because HEAD is the only method in the methods array, it is striped out. We are using the HEAD verb in our API in accordance to its semantic purpose.
Proposed Fixes
Remove the use of array_diff. The addition of the HEAD verb is Laravel's doing and therefore they should fix that.
Add a defensive check to make sure that there is always one value in the methods array.
What happened?
php artisan scribe:generate
Screenshots and stack traces:
TL;SR; Already found the cause of the bug! It just needs fixing :) Click Here or scroll to Additional Info
My environment:
My Scribe config (minus the comments):
Additional info:
try/catch
around the render call responsible for triggering the error reveals the route without the method. It's aHEAD
route. The method has been lost somewhere.GenerateCommand
leads us to Line 118 and$generator->processRoute()
as the point where the method is "lost".Knuckles\Scribe\Extracting\Generator
source code, thegetMethods
method is observed.Because
HEAD
is the only method in the methods array, it is striped out. We are using theHEAD
verb in our API in accordance to its semantic purpose.Proposed Fixes
array_diff
. The addition of theHEAD
verb is Laravel's doing and therefore they should fix that.Thoughts?
TIA