Skip to content

Conversation

@negoziator
Copy link

When calling ->get(..) without parameters, PHP will default the empty array to null

One way of calling it without this, would be to call get([]) with an empty array.
That seems like a bad behavior.

Just a neat little trick is to let the user call the function with null and then just typecast the array.

… withput parameters, without throwing a nullpointer. Just a neat PHP-thing :)
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 17, 2019
@jdpedrie
Copy link

@negoziator unfortunately, this repository contains generated code and can't be modified directly. I'm curious about this though:

PHP will default the empty array to null

When I run similar code, I don't see it casting anything to null:

function foo($arg = []) {
    $other = [];
    print_r(array_merge($other, $arg));
}

foo();

// Array
// (
// )

I think there might be an issue a bit deeper which we need to keep looking for.

If it happens that there is a generator problem, we can work on addressing it there, but I'm not entirely sure that's the case yet.

Let's continue the discussion and research in the original PR since I think it's likely a fix will originate there. :)

@jdpedrie jdpedrie closed this Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants