Hi Tim,

On 2026-10-27, Tim Düsterhus wrote:
> Please do not "top post".

Sorry about that, noted.

> One hint for the Wiki: Using `<php>` around code will perform the proper
> escaping, and will also enable syntax highlighting.

Thanks, I've switched that bullet to <php>.

> Can you please add another "edge case"
> example that clearly shows the reference handling behavior to make sure
> every reader is aware of the full implications.

Done, in a new "By-reference elements" subsection. It shows that
writing through the result changes the input (and the other way
round), and that a reference which is no longer shared is copied as a
plain value. The outputs in the examples come from running them against
the implementation.

> I'm also not sure, I like the fact that `array_partition()` has behavior
> that cannot be replicated in userland. I can see the "follow
> array_filter()" argument for consistency, but at the same time
> `array_find()` is dropping references (I believe)

You're right about array_find(). I checked the other functions in
ext/standard to see where array_partition() would fit:

    keep references:  array_filter(), array_diff_key(), array_slice(),
                      array_values(), array_chunk()
    drop references:  array_find(), array_map()

So the functions that return part of their input as an array all keep
references. array_find() returns a single value, which can't hold a
reference anyway. I think the strongest argument for keeping them is
that replacing the current array_filter() + array_diff_key() idiom with
array_partition() then doesn't change behaviour.

That said, your point about userland replicability is fair, and
dropping references would be a one-line change. I've added it to "Open
Issues" so it gets settled before a vote, and I'm happy to go with
whatever the list prefers.

Best regards,
Ayoub

Reply via email to