-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.5] allows array or multiple params for hasAny helper #22919
Conversation
Can you add tests? |
@Dylan-DPC It's an existing function that has tests already. |
If you're changing the code, it means the current implementation isn't sufficient for a use-case and would require test for it to avoid regression, so Dylan is right. |
@Dylan-DPC @deleugpn There you go lads. |
This is a change to a method signature, thus a breaking change and should not go into the 5.5 release. Perhaps the 5.6 branch? The problem shows itself when you have classes that derives from Request and overrides the hasAny method.
|
* @return bool | ||
*/ | ||
public function hasAny(...$keys) | ||
public function hasAny($key) |
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.
Could just avoid the breaking change.
public function hasAny(...$keys)
{
if (isset($keys[0]) && is_array($keys[0])) {
$keys = $keys[0];
}
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.
I agree that the method signature could be kept and avoid that specific breaking change; but some further digging shows that we already support arrays to Request::hasAny(), so a change like this would introduce other problems.
Only one of the tests actually fails with the current code; The problem is that Request::hasAny, with arrays as the use-case has them, isn't clearly documented and we're now trying to change it. There's even use-cases like |
I agree that it should probably support both but would definitely need to go to 5.6 and appears we need some test improvements? |
Make this the same as
has()
allowing array or paramsCloses #22917