Re: RFC proposal for adding SORT_STRICT flag to array_unique()
| From: | Jason Marble | Date: | Sat, 25 Oct 2025 21:01:00 +0000 |
| Subject: | Re: RFC proposal for adding SORT_STRICT flag to array_unique() | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128967@lists.php.net to get a copy of this message | ||
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.
>