Conversation
|
There may be a conflict with type hinting the methods as an array. The FastRoute RouteCollector::addRoute method accepts a string or array of strings of http methods. This is the only place I think we use the Route::getMethods function. So technically, even though the phpdoc documents an array of strings, if you use a string everything should work. This could be a BC break. |
|
@danielgsims, thanks for looking into this. The framework seems to consistently call I have removed the typehint and added a check in the constructor to convert the parameter to an array if a string is passed. This way |
|
Maybe go make a note on the Slim 4 road map discussion! |
| public function __construct($methods, $pattern, $callable, $groups = [], $identifier = 0) | ||
| { | ||
| $this->methods = $methods; | ||
| $this->methods = is_string($methods) ? [$methods] : $methods; |
There was a problem hiding this comment.
Because FastRoute supports both a string parameter and an array of string. Because there is no array typehint on $methods, string was already supported. I updated the docblock to reflect this.
Also, when setting Route::$methods in the constructor, the value is set to an array, so Route::getMethods() always returns an array as stated in the docblock.
No description provided.