There seems to be an implicit contract in League\Route\Dispatcher::dispatchRequest
that match[1] (the handler) is a League\Route\Route (as it calls setVars)
This throws when the route is created via Router::addRoute, because now $match[1] will be a callable|mixed|Closure etc.
A possible solution is to ensure that the matching handler is a Router.
Other things to consider:
Maybe using Router::addRoute should be avoided. Reasons:
It is not possible for to add middleware when calling addRoute directly.
It doesn't add any route in the routes array, as it is the parent class method.
Background:
There seems to be an implicit contract in
League\Route\Dispatcher::dispatchRequest
that match[1] (the handler) is aLeague\Route\Route
(as it calls setVars)This throws when the route is created via
Router::addRoute
, because now $match[1] will be acallable|mixed|Closure etc
.A possible solution is to ensure that the matching handler is a Router.
Other things to consider:
Maybe using
Router::addRoute
should be avoided. Reasons: