Skip to content
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

Replace $userdata check with isset() to ensure correct handling of falsy arguments #5

Open
michaelrog opened this issue Oct 22, 2018 · 1 comment
Assignees

Comments

@michaelrog
Copy link
Member

michaelrog commented Oct 22, 2018

Per discussion in #4, re: resolution of #2 — We should only be passing $userdata downstream to the target callable if our user actually provides an argument. However, a simple boolean check is insufficient here, because the intended argument could be non-null but still falsy. We should replace the current check with isset().

@michaelrog
Copy link
Member Author

Looking further into this... My original intent was was that the signature for craftArrayWalk would match the native array_walk, which appears (in the docs, at least) to also provide a default null value if no $userdata argument is passed.

So, I'm not sure if adding an additional check in our method would actually make any difference. 🤔

@jalendport, did you test the case in #2 to see whether excluding that param allows the walk to run without error? If so, it means PHP's array_walk isn't normalizing the optional param, but actually excluding it, and we could do the same. If excluding the param from our call to array_walk doesn't actually make a difference, this would be a #wontfix. (or more accurately, a #cantfix.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants