Re: RFC proposal for adding SORT_STRICT flag to array_unique()

From: Date: Tue, 28 Oct 2025 21:59:40 +0000
Subject: Re: RFC proposal for adding SORT_STRICT flag to array_unique()
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-128992@lists.php.net to get a copy of this message
If someone can grant me Karma (username jmarble), I'm happy to start the
process of submitting an RFC for an ARRAY_UNIQUE_STRICT flag.
Thank you!

On Sun, Oct 26, 2025 at 10:50 AM Jason Marble <
jmarble@intuitivetechnology.com> wrote:

> Here's a nice example inspired by Rob's comparison of object identity and
> value:
> https://gist.github.com/jmarble/c86b5b0b3373498c889bc9c5579105a8
>
> On Sat, Oct 25, 2025 at 2:01 PM Jason Marble <
> jmarble@intuitivetechnology.com> wrote:
>
>> Rob has convinced me SORT_STRICT is semantically incorrect. I agree
>> SORT_BINARY has merit, though I'm having difficulty with the implementation.
>>
>> I think I got too focused on _convention_ wanting to align naming
>> convention with the existing SORT_* flags. But a perfectly acceptable
>> alternative exists, ARRAY_UNIQUE_STRICT.
>>
>> I'm aware of the previous effort (https://externals.io/message/118952)
>> made regarding the flag ARRAY_UNIQUE_IDENTICAL. While this is technically
>> correct and follows existing convention (e.g. ARRAY_FILTER_USE_*), I
>> personally feel it's a bit awkward.
>>
>> ARRAY_UNIQUE_STRICT is, I think, a bit more intuitive. Especially today,
>> as declare(strict_types=1) has become more common and even encouraged,
>> particularly for those who love PHPStan level max haha.
>>
>> Pull it, test it, break it. Let's do this!
>>
>> https://github.com/php/php-src/compare/master...jmarble:php-src:feature/array-unique-sort-strict
>>
>> On Sat, Oct 25, 2025 at 7:41 AM Morgan <Weedpacket@varteg.nz> wrote:
>>
>>> On 2025-10-26 00:16, Rob Landers wrote:
>>>
>>> >
>>> > Object identity and value are different things...
>>> https://3v4l.org/uZTsN
>>> > <https://3v4l.org/uZTsN>
>>> >
>>>
>>>
>>>   $white == new Color("white")
>>>
>>> That's comparing the values of the objects' properties (which may or may
>>> not be relevant to its "effective value" - the comparison applies to
>>> private properties as well) and considering the aggregate to be the
>>> "value of the object".
>>>
>>> Regardless, the comparison is certainly not useful to me (where
>>> recursively grovelling around in the objects' properties would be
>>> prohibitively expensive if not fatal), and doesn't make array_unique()
>>> any more helpful in deduplicating.
>>>
>>


Thread (15 messages)

« previous php.internals (#128992) next »