-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fix attributes type #66
Conversation
@greg0ire could you review my pull request. If it's ok for you I will merge the PR, and release a new |
@@ -14,11 +14,11 @@ class Duration implements AttributeInterface | |||
private $milliseconds; | |||
|
|||
/** | |||
* @param $duration | |||
* @param string $duration |
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.
string|int
, because the class should not know what it will be called with. In php7, you will use int
as type hinting (which accepts numeric strings IIRC)
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.
By default, PHP will coerce values of the wrong type into the expected scalar type if possible. For example, a function that is given an integer for a parameter that expects a string will get a variable of type string.
So when you drop php 5 (on next major release?), you can safely add int
as type hinting indeed.
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.
Fixed!
related (#65)