thephpleague / route

Fast PSR-7 based routing and dispatch component including PSR-15 middleware, built on top of FastRoute.
http://route.thephpleague.com
MIT License
651 stars 126 forks source link

Dispatcher::dispatchRequest: Ensure matching handlers are Route objects #230

Closed pgk closed 5 years ago

pgk commented 5 years ago

Background:

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:

philipobenito commented 5 years ago

Great catch, thank you, remember docblocks even in tests for any future PRs though please :-) I will add it before release