-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Small fixes #1889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small fixes #1889
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add support for string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.