Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120697 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54563 invoked from network); 27 Jun 2023 11:33:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Jun 2023 11:33:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5DDAC1804B0 for ; Tue, 27 Jun 2023 04:33:08 -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,NICE_REPLY_A, 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: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 27 Jun 2023 04:33:07 -0700 (PDT) Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-3fb4146e8fcso12038575e9.0 for ; Tue, 27 Jun 2023 04:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687865586; x=1690457586; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=w/bi5oLYpNqnhGyVpfOQzKssz0nVg1paOf1MJtZhh/Q=; b=lHg2Gu2AyDNBaPcW3EXuOUnc56J/gPZ2PZC0LgphRQaI3m3sOE9QbZfLylSaAVQ6C1 M0zgOy7UbRQMngaE+utRYCuIwC8/AIh6E6VwMtzuDzhUZ4ZLfQ4C7p8YdMW1oVA62kWB qZJk2rqbRrfEAuEAKlKN8Yi2LC5RXaniFEExsyQcpIVpNClSUcR/3j+Ylr7aJl454T3S USpTu+nEL1qD5Z050qjiz7Qx4ZgnmT0+24O2tiAWgypftVols75T1QM42BnaSLTg8mL9 Y75P8VGcq/p8AfAZKS8FVetxpMdEpTjTA4RP6QBJCTXIC0OuUOtp4E62sCzA03sBih8F hkmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687865586; x=1690457586; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w/bi5oLYpNqnhGyVpfOQzKssz0nVg1paOf1MJtZhh/Q=; b=MfeYqnDODQ0iiJ5OjV40O8BwOlVln696dzx8thtP1i/hmpNOPcY47yIBazD/jLQOKp Tdo/tMEXmUW6Ll96xzHGmFbjbWogrEZsgKDca2n/lM3oDsYJrX61l0xsdyExin/9KJ2e bTmXyTsNDmSJz7Z6KdL/l+5WxL1s1x+qtMZQdJ8ZTyT4zs5wgAurtsT9Ckq612QF2HaP gqOFxN1MVn/35C/VU5mPJb3LNUqU05MRy0//U1VVKdpYk4HzKjRQNP10MW+3CTIULNRe s0rKupW+EXIrtBOfjd5eM/3jyZeJykEcL2dypBbbHEETYfdllac6ZSMwFbv/Dw1qWD+F n4cQ== X-Gm-Message-State: AC+VfDx530SZDSn/CRYuncxk935GzKljMsAcCkoAQohJN+dKZJOoMPHQ hQqVg+Gr7iEBFIXZOlsCmaNmJHzAG0Y= X-Google-Smtp-Source: ACHHUZ5CutlOdiEHzz3I4ifUI2lnguFxQHRx4WA0KEFfie7McWzpRD9TuZQf/0/i1ZZoP4I1r2ijhg== X-Received: by 2002:a1c:4c0f:0:b0:3fa:8c8b:716 with SMTP id z15-20020a1c4c0f000000b003fa8c8b0716mr6445623wmf.1.1687865586108; Tue, 27 Jun 2023 04:33:06 -0700 (PDT) Received: from [192.168.0.22] (cpc83311-brig21-2-0-cust191.3-3.cable.virginm.net. [86.20.40.192]) by smtp.googlemail.com with ESMTPSA id x9-20020a05600c21c900b003fb40ec9475sm3480330wmj.11.2023.06.27.04.33.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Jun 2023 04:33:05 -0700 (PDT) Message-ID: <57104d4a-6e7a-ab57-e2b2-7973ce4bb429@gmail.com> Date: Tue, 27 Jun 2023 12:33:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-GB To: internals@lists.php.net References: <6B872612-2F31-49E0-949C-CDF6FB2B9BE4@benramsey.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] [Vote] Deprecate functions with overloaded signatures From: rowan.collins@gmail.com (Rowan Tommins) On 27/06/2023 02:25, Theodore Brown wrote: > Currently the following code returns only the array keys that loosely equal null [1]: > > array_keys($array, null) > > If the function is changed to a single signature with $filter_value defaulting to null (with an argument count check to preserve the above functionality), its behavior becomes a lot more surprising/unexpected. If a parameter defaults to null, as a user I don't expect the function to work differently when I explicitly pass the default value. An alternative solution to this situation is to introduce a new dummy value for such parameters, similar to how JavaScript uses the special "Symbol" type to have keys that can't collide with any userland value. In this context, this could be achieved with a single-value enum, i.e.: enum ArrayKeys { case IncludeAll; } function array_keys(array $array, mixed $filter_value = ArrayKeys::IncludeAll, bool $strict = false): array {} That way, the optional parameter has a real default value, distinct from any value the user might wish to filter by, including null, and full compatibility is maintained with existing code. I don't know whether this is a direction we want to go, but thought I'd throw it out there. Regards, -- Rowan Tommins [IMSoP]