Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118965 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 56017 invoked from network); 4 Nov 2022 14:55:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Nov 2022 14:55:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3BB3F18005C for ; Fri, 4 Nov 2022 07:55:10 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 4 Nov 2022 07:55:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1667573706; bh=wq3gtVFggKOupSfllLtH3zHDJwjbEs8K51f2ev6PqVA=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=jtvotXvwYOU6baIxTuCT3+pfDSPOfQjYFqZ+BRmznXx110m8PONHxuStHTPMsqyf5 GNhXu4P2KLfghB75E8f3slh0bI0EkfKTv73Cu6q4wWa8pIk/OTeWBJEdd/wwltwTSt mdE0JFOGDriO7cIdi2IeqD/FwMh/4zCTVzAJ6HUEgq9/X/D4GeTpzPk0M6DGsdQlKW 06PirA20DLWxMiqEoFjSWTceoRkjzGqmAu3XG1oGvoAAc2MSbJLHGaBCHNpDwtncEp JuY1uA3aY10bhpMoqurrdrPiBj32MxXwO+roL+9N+uS/v0gvB3E1Qwa5dvc7YCCyil tMPnk+YDFQt4Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.2.130] ([79.220.80.221]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M2f5Z-1osLPJ0mUB-004BTa; Fri, 04 Nov 2022 15:55:06 +0100 Message-ID: Date: Fri, 4 Nov 2022 15:55:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 To: Rowan Tommins , internals@lists.php.net References: <0053C284-958F-482E-A648-39652442D4B8@gmail.com> In-Reply-To: <0053C284-958F-482E-A648-39652442D4B8@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:vxac1vh5/ZOlHLpWM8+IECa8BOvGMFHTfp8LJxxHWj/ekOnyCXG 4Qzx2hnIpQIDKHO+V1nM9LP+pIQ3UFNXqmpTshexJ4+WmTib19oSadA6LXHPCcGLiFtQLE4 W80+2qp0zQclViNpYPinYZbor36zneii43kocNruVzhooo5oly23Y+0lRzGciLfZwdqKDBP IS8u304CWOdmZnUszwF2g== UI-OutboundReport: notjunk:1;M01:P0:q+AnxQEOG1s=;QouXKkY8qVvviQoMLNC8BG/1xPD b0+VqJ5slaqQ1ZHaNufg/4ALKDnbcqTnxLV1FqVKdBtyhLt6qZZH3vuYm5AnROuznpVmAQpJH ftG5hHoz249jf59wYXCD4spXjfwVYUZeKr2UXddk8ThcNkfP2oZ+mZfpBLzGwmh+gnfRDQmZS M2ZrU1JMCwNx+b3oOrO0KCgme4AVBD74pzcPU5klfiTNPHuzFz+wLy6YqCSrqFwbLsZRTqXeX CWGoXo1FNx/sTvk99Qk+5tl8w2EHRVQVTmvcUpxsZs2Dk6KnAwI7W+YcJHOoBrEcUh3hh115V bQg1Fn4LWq3CFufuXiJ91qp++aiGxLisIDnPB7Y5XIZVE/LNyM+Qv99o+iHDuORLGAkJWAUA+ Wy0gRsBYMZ2RZjbAFlnLjqVq9G1Y/jGQqZb9Nwk/0wabfkFx0isK/OEd+en4/gWe+3bSUjg2o +G03qruKbQBvA8gbZd91YTE8u8jn5bFiQ+cLs923juzbw8S9ZaF45JcodslZWlkED+3Qb6HVb hx7uJxlySp9CXam1H2Bv0rq3dt+HT4qHALIE7/3Dy4CNcPI9W0uoAt+g+gf7SH/VJ7hefgAdc VcLIBBgzboGihA2iK2fpdugwGPBvpGBvT37pEfHSLh2Dr0WPaJ9PjZEY9cUvVjbSaGaZ0/nt4 kYSZ6vS+mrauu3tHSSK8k4YEpbEnVchdq6OcEO5wHLN5mU0wqChstdBAsZeuQB6IHk/sUUtDY 2vyfSN54u9XXaIg6rgmC6KszSkX/euWqzF2n5H5bg7hGA7wSakNpCe+YHtil3qNyeu2LaVXkG ud5wdNPANN+lqkh7NhwhD2cnUoGcjlULmTvYTVFjYxMGUB0UTCUFeKQ8P5wXUWbUoWTfBEM4U rDmVHQGHx9X9JgPs3jO5Kri7e9HHgbzeN2N9PRqDpmWrl3MJAQw5s4X0dujuO+3tC7ZdCuEND k+1Q7Q== Subject: Re: [PHP-DEV] ARRAY_UNIQUE_IDENTICAL option From: cmbecker69@gmx.de ("Christoph M. Becker") On 04.11.2022 at 10:05, Rowan Tommins wrote: > On 3 November 2022 18:53:40 GMT, someniatko wrote= : > >> You will have to memorize yet another PHP quirk, or be able to build a >> logical chain: >> - enums are non-comparable by default >> - enums have no default string value (if not baked by a string) >> - array_unique internally sorts an array >> - default flag for array_unique compares the string representations of = its items >> - thus it won't work for enums in a general case > > Actually, I think this is already the case for "normal" objects - I had = no idea that array_unique used a string cast to compare objects, so am ver= y surprised that it will not consider objects of completely different clas= ses unique, if they happen to have the same string value: https://3v4l.org= /UGCvB > > Making backed enums work with their backing value would be equally confu= sing to me - Day::MONDAY and Month::JANUARY might both be backed by a 1, b= ut they are certainly distinct values. I'd much rather get an error that m= ade me check the manual and find a flag than have one of them silently dis= carded. I agree. In my opinion, we should *consider* to *always* raise a warning on attempts to compare incomparable values. As it is now, silently returning false looks like a footgun to me. =2D- Christoph M. Becker