Walk icon indicating copy to clipboard operation
Walk copied to clipboard

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

Open michaelrog opened this issue 7 years ago • 1 comments

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 avatar Oct 22 '18 13:10 michaelrog

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.)

michaelrog avatar Oct 22 '18 14:10 michaelrog