-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Bugfix values function #3192
Bugfix values function #3192
Conversation
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.
Apart from my comment I very much welcome this PR. Thank you @mahasadhu
This must have slipped while we refactored Filters into classes. So sorry for the trouble.
If you don't have time to make the suggested changes let us know so we can finish this up and merge the PR.
Wish you the best,
Pedro
@@ -285,7 +285,7 @@ public function label($value) | |||
*/ | |||
public function values($value) | |||
{ | |||
$this->values = $value; | |||
$this->values = is_callable($value) ? $value() : $value; |
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.
We had trouble using this kind of check in the past, who knows what values could endup there 😃
Just to make sure we don't get into the same hole I would go here with:
$this->values = (!is_string($value) && is_callable($value)) ? $value() : $value;
If the string is a php core function we know what is going to happen 👍
@pxpm Hi Pedro, thanks for checking 😃 Sorry I did not know that. I've pushed some updates to the code. Another idea, we can just close this PR and update the docs from this: to, for example, this:
Because (CMIIW) it seems no one has realized this errors yet. But it's up to you though, just a thought. Thank you! |
The inspection completed: No new issues |
Hello @mahasadhu thank you very much once again 👍 The refactor to use Fluent api for Filters happened not so long time, so that's why I think not so many people switch from old array definition to the new fluent syntax. The array definition supports anonymous functions in value key, this was just a mistake we let slip when refactoring to the Fluent API. With your PR merged the documentation should be ok ? Best, |
No problem at all @pxpm Ah I see... Thank you |
Thank a lot @mahasadhu & @pxpm . You're right, of course. Keep 'em coming! Cheers. |
Values function in fluent API not calling the inner / callback / anonymous function sent to it as parameter