Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120738 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 27828 invoked from network); 3 Jul 2023 13:29:13 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jul 2023 13:29:13 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4F8BD180548 for ; Mon, 3 Jul 2023 06:29: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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 52.96.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from DM4PR02CU001.outbound.protection.outlook.com (mail-centralusazolkn19012032.outbound.protection.outlook.com [52.103.13.32]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 3 Jul 2023 06:29:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PIyPcvFIfg06CHK0Q32w5n5SeCgX58OZeNHlwIewitFvlpA4CFMwKcOgBSbk/XPq9HvVccTPSHagSO5EMQmn0tXpoz8I2X9JPcA/VFRl3z1Vv0lg00E4f8afJFXttrszH6rnSm95+JOx5a4JpQnpkFGWxwJ3rxf/AF2Oh6eirBs1taovp4qgBApNVPCQXBaLRQOgtGVNFo8RhHuoCi7cVE+7u3O1tqON9tvvfHk34TklT0Q/+lUPWyKNO7VbtDWI3rnDuGFrMGqLXnPPfgU+931DMj9iXhQjxxL7YnSE5pxq1iBTvweMDbE7LIO5Ph6GzFM917bVIpP63GqUrNpVSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bSAdZfrUI5UUQMSUn7OOq25o5uQ5mmH6iZ19UmJ8Fxg=; b=iURhRloYSDiCdgIQ6ainMPFrdi1MXYgtRWs+N2ldUxOlYrgDtZ5irEHcLuMr0j7gmJEHqed5VVwzKYV9bf+2qpF4oU/SURpqPrueAlgFg6Y1x4iUg2tBgIgf/zfVx/BURiSI4Agcpk5SDkFrKnhwK+wBowNPRcFSYkdUayF2maKJKWJsrvQcyJdl3gW532VTGUM/s4QWywc5sLY3UAt9yJyueQSTOEHONnFmifCqQu3RXRw6FJC1JKHdZjLc1fXoQDa+7TCo43w4xPKfSYDKk7xoJGs8aosKWgzlX75AOpTOxdUHZjhuLDgZQ1dCR2eR8vYX6J1SlhLRyUwT3CMWWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bSAdZfrUI5UUQMSUn7OOq25o5uQ5mmH6iZ19UmJ8Fxg=; b=b05MCMWhv04FaYh4oNMyx8ybmzuvWM4wW9q6Z4MbZwoUyxnNm5oFSWMQV4lVl5a4kSgf1j7KaApJpXOM5I9jNTQYYQZjm4jiXezCGjMlkcj0oPDCgGZ8zvVuhysm5sF+NZkykYLYY6+YhDOdzEXJD+2wF3lpz5qzXHqWgzVsiD6PhW5UaYiVeYDbSpQCRWJ7ZQR9F+Q6C9GGakQrGLuP9PK0/oC8rziBow8QNe0ri93ZRiSCNjW9mHEcuI1iV7nJr7kHTRmd8Itl2HhXG8tan9mmmbFy3xgz3Wis0oqeoyNR9uQtw5arq5uH1mb9gQLu6hEb/+FYo8gcN5xrtWhMcA== Received: from BN7PR05MB4033.namprd05.prod.outlook.com (2603:10b6:406:90::33) by SJ2PR05MB9657.namprd05.prod.outlook.com (2603:10b6:a03:4d2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Mon, 3 Jul 2023 13:29:05 +0000 Received: from BN7PR05MB4033.namprd05.prod.outlook.com ([fe80::caa8:dcd6:ca84:bb44]) by BN7PR05MB4033.namprd05.prod.outlook.com ([fe80::caa8:dcd6:ca84:bb44%7]) with mapi id 15.20.6544.024; Mon, 3 Jul 2023 13:29:05 +0000 To: Rowan Tommins , "internals@lists.php.net" CC: Nikita Popov Thread-Topic: [PHP-DEV] [RFC] [Vote] Deprecate functions with overloaded signatures Thread-Index: AQHZqDNOzscc7EYmMEqrpB8lsTz/k6+dZgkAgAAWZYCAAFdR/4AAsh6AgANtoEmABh+sxA== Date: Mon, 3 Jul 2023 13:29:05 +0000 Message-ID: References: <6B872612-2F31-49E0-949C-CDF6FB2B9BE4@benramsey.com> <57104d4a-6e7a-ab57-e2b2-7973ce4bb429@gmail.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [TDeaA3qVQkyDx7GCXU00dZ8wANqQ4TCd] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BN7PR05MB4033:EE_|SJ2PR05MB9657:EE_ x-ms-office365-filtering-correlation-id: 1df67b85-938c-4fd6-4a5c-08db7bc9796a x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: idWKVVC+HhhhSmolMu3rw36CiMAfR0kpBtlvrr1yLcBoYsaNnj0qzsMtunSA2cz7CLlC3Q8Cjq/37dmOA99XYO8oAl1oQMw1Sfj27XYG8FsDj7GE/yTY1KKUux6mUS4AdKKBok26H4UrME6IVXIk4cvERCUwsm9XlYNllLKXImgMfG5MwB0Ijh3wb2h+qjq26AYLh1SUq1uqf5/PBZ7Gu2p5ltpH/F9M2EmiTlRAW/C/iXli7+8ZYONYo44uiivJY7Bs32d/TkSOOyYa2tuJL1NcOo1XKJt5i80veldouwp+xB02dJlNcGv9AMNArFTqzlsZBEr3EZe36/UMMuEtnUYbUdHCHsBm4NAHHQg//H/4U3l5qkGs4/G5XxXVknezy2/x2UFf12Wf6lakj+I/aVLgQdHKjZRhWTkmw/Q2MO7imKwfGHnsYSVl460vM7yvjXMgD0l7plQT1w0KA5ecxgrKsQUi1gktkyuagMZxni+Bz/HKF5z30pQ6sTe/lBOFnyH9fDBBKpp4TQSkqlBg/i0oJGYZzkJqEAPySHE3sUQ= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?czw36zbeu0cTIeEuxEBr4wODM3wBLuRlKNGxlAPpL0zfAnXJnEZKczZCNN?= =?iso-8859-1?Q?zmBdGFemcAR29IzKDDWHBGCJLDbCiqrgDUBU0Gens8aKUIACA7hQJQGiaH?= =?iso-8859-1?Q?dYiqRKSeiL30QmUIN/PPI4bvH2h9YB3gFHj4+DO9faEKNYKIST/3n7Ko83?= =?iso-8859-1?Q?eGcMnS+DhyjZQ9kRuEb+4tLsMc1EE/qMMdkbOb+Yd0uuklnS/xyyR5Sre4?= =?iso-8859-1?Q?tit3+uqbIMyEaaijXcqcCs+fLnn5I8vPgRP/KKfST45o/RTwAReLS0/rcJ?= =?iso-8859-1?Q?G8i6vYz5ZIdROse17+aqxH8IgjfWgLRx0MIPbixoL3DP7EU6B7UUkohApl?= =?iso-8859-1?Q?vRRupzLqrAzjDen4XTH6L+PMogRGg4ZDUVC4ESaOwDZcfSNsRXoAEipIzZ?= =?iso-8859-1?Q?29mXlXB4Xoo/55QAV7NiCqiqur3PVETW0K+tfbABxHdlmH1rvGuX1TTdOQ?= =?iso-8859-1?Q?padvw+/4NJkTC2qJXpRf7qhGGOOsQsZ1RVbCzt4x8feHGMdbOkennitmDi?= =?iso-8859-1?Q?K04TqB677m85bzJ32lFIEKD9b51ebdiG8O0fDu2gmegiT5jkeoaf2MJvdU?= =?iso-8859-1?Q?Ci+UARKxwZNhnXcVkhBVoVmY1Zk7tW/zMCB/A5vHhYzf3RuJWv04OylWq3?= =?iso-8859-1?Q?m/XhjzOrAk92pH+pdXXLuAKCybvfY46/IeY+QeLlmgbCOVF2SvhhXxRTfU?= =?iso-8859-1?Q?vlEo1+SULn81UPM1LarGXrDyQOc7D45Zvp6juvVakVkxQuilUul0uPvhZ7?= =?iso-8859-1?Q?ciqbG+hP53Xem7X6sotrTUpAVn8SLPoqLHj0Fz4nemh7UtwWDOEs9bJcG5?= =?iso-8859-1?Q?ZNwI5ytNBPDI7sHFHpTCPMpTmS1t/mwsu2ejmbCtrGiCW+ePD4IqR2AaDf?= =?iso-8859-1?Q?hNia3XC0o2winIABxPO9q6JLWMLGNfHRG25fWDqfR4jyPTeQrf3qqKOBbf?= =?iso-8859-1?Q?TRzzl3I9psQbPklkN/QVReRSAmWvgpTz3mbawUHtxZILZpWQBDsvkR+te4?= =?iso-8859-1?Q?yYTt7//4BVCNiT8YmfOu5TSkuiB4tlNnWA8kkmAQpVutbtr3JXm/LMaIvr?= =?iso-8859-1?Q?CHSlh+lZKPjM3zThH1KlpeYbaJnvFsxx0eraoZY1vL9ytrHU5DxIR73guI?= =?iso-8859-1?Q?U4WYKL0AbYdJK2c3cugb061zmQmj6bOubNAKHsYMPszxh1pmL03o+e9OjY?= =?iso-8859-1?Q?JkODCEC7n36Ld/de8qlQGUfTPIK2Y4zSrXQUr3FAA+0mIWo8qMum4LKXHR?= =?iso-8859-1?Q?bZUyzAa3Zs+O19Yw6tBQ=3D=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN7PR05MB4033.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 1df67b85-938c-4fd6-4a5c-08db7bc9796a X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2023 13:29:05.8567 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR05MB9657 Subject: Re: [PHP-DEV] [RFC] [Vote] Deprecate functions with overloaded signatures From: theodorejb@outlook.com (Theodore Brown) On Thu June 29, 2023 at 11:51 AM Theodore Brown wrote:=0A= > On Tue, June 27, 2023, 6:33 Rowan Tommins wrote:=0A= > > On 27/06/2023 02:25, Theodore Brown wrote:=0A= > > > Currently the following code returns only the array keys that loosely= equal null:=0A= > > >=0A= > > > array_keys($array, null)=0A= > > >=0A= > > > If the function is changed to a single signature with $filter_value d= efaulting to null (with an argument count check to preserve the above funct= ionality), its behavior becomes a lot more surprising/unexpected. If a para= meter defaults to null, as a user I don't expect the function to work diffe= rently when I explicitly pass the default value.=0A= > >=0A= > >=0A= > > An alternative solution to this situation is to introduce a new dummy= =0A= > > value for such parameters, similar to how JavaScript uses the special= =0A= > > "Symbol" type to have keys that can't collide with any userland value.= =0A= > > In this context, this could be achieved with a single-value enum, i.e.:= =0A= > >=0A= > > enum ArrayKeys { case IncludeAll; }=0A= > >=0A= > > function array_keys(array $array, mixed $filter_value =3D=0A= > > ArrayKeys::IncludeAll, bool $strict =3D false): array {}=0A= > >=0A= > > That way, the optional parameter has a real default value, distinct fro= m=0A= > > any value the user might wish to filter by, including null, and full=0A= > > compatibility is maintained with existing code.=0A= >=0A= > ...Note that currently there is a draft RFC to support objects in array k= eys. [1] If that feature is accepted, would it not be allowed to filter arr= ay keys by the `ArrayKeys::IncludeAll` enum value? That would also be surpr= ising/unexpected.=0A= =0A= =0A= I must have been really tired when I wrote the above paragraph, because I f= orgot that the `filter_value` parameter matches against the value, not the = key (so the Object Keys in Arrays RFC has nothing to do with it).=0A= =0A= But this makes using an enum as the default `filter_value` even more proble= matic, since enums can already be used as array values and this would preve= nt filtering an array to return keys for this value. I.e. the following cod= e would stop working: https://3v4l.org/5Br1a=0A= =0A= So I still believe the overloaded array_keys signature should be deprecated= for consistency and to avoid confusing behavior.=0A= =0A= Best regards,=0A= Theodore=0A= =0A= [1]: https://wiki.php.net/rfc/object_keys_in_arrays=