Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117656 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65842 invoked from network); 2 May 2022 10:20:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 May 2022 10:20:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5A632180053 for ; Mon, 2 May 2022 04:57:01 -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,HTML_MESSAGE, 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-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 2 May 2022 04:57:00 -0700 (PDT) Received: by mail-ej1-f47.google.com with SMTP id i27so27288229ejd.9 for ; Mon, 02 May 2022 04:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/5at5petM+nmtVz6rgRhIX28yDaMYJTYDhm195/LH34=; b=JhoQySD6Ya0lKMztmV38t/1IefRrIcNSOlnXpg40yR5CCm3B8cLEIsm1hHE3UkExhD nxpVIlkSy0qM2YKrzRJiFPMBvFToq32LE20F0AQM7N9ip18AwqG5rI1ZBTrqoCY28XAb i4w4KK0rg96/q7tSFHfunolHNrdMw2yJr1C8zJreX2hI4QnjJLh802kjvGhY4oMlndrm KWhSSH5nkNXSYRn+5HirXNyeUcdaR/Qk6McgiYLtjLM5/Ge8x0NZNIiLR+sXnKPzvkKS OsH++b5xL4kMQW53O8UjIOlqSDr3PAD1KeOHLqy+3D3kb0vSDzTe7s9ElVFO13j9GH5Z VzSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/5at5petM+nmtVz6rgRhIX28yDaMYJTYDhm195/LH34=; b=zElR+4rGXpiQ8I5IS5iS0S3aPqbV1VdZbgFe71nyf7zrZFLW0+Nxf+q5NgX7IZya36 qWsv1xnohQ4B6WQ5bx8Z3rGYUI+UsMHw/wXsLYJL6QY/8DzwwNELYTrBoVG04K/SP6F4 P7sY9MFDV9N5pYTqFiQVCbC5ghvmZ/0YKHJ5cNrY9LwnqIpyJwHpM0lK60Fg/RP5E60T BgcJTZppAw9HsIRzNCPqYu6pGBvjO2oj3plN5RkagcZRk3fmFrbhxunTC3NA4DFhLpc1 stEy2NizMwx0IscnH8FzpWNiIsWdaVoxdDrr+bKD6t765NYHPWFgnEuiUPGXrGOXhMJL tohQ== X-Gm-Message-State: AOAM532icB3WGkKWzmCX27JjbyLCpWbphQrIa2GYFnWMrlvPaZlfjsNM Rjor9YNnDx5D197BDlRr6pgJdJPomp9YzgarapQ= X-Google-Smtp-Source: ABdhPJzdHZoQDGZdXFt2e3ePmwaFkdK1QGAqvB2usc91V2hHeTHJB5IHfVIIeaO3Ot7R1NWQW49DWnSYx95gL+0IlTQ= X-Received: by 2002:a17:906:2ac9:b0:6ce:dc0f:9139 with SMTP id m9-20020a1709062ac900b006cedc0f9139mr10837449eje.206.1651492619260; Mon, 02 May 2022 04:56:59 -0700 (PDT) MIME-Version: 1.0 References: <62317B01.90907@adviesenzo.nl> <3F016525-CCDE-4229-9260-7C76A6FF42E1@cschneid.com> In-Reply-To: Date: Mon, 2 May 2022 14:56:42 +0300 Message-ID: To: Guilliam Xavier Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000eb98a105de061648" Subject: Re: [PHP-DEV] Deprecated partially supported callables: should is_callable() throw a deprecation notice ? From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000eb98a105de061648 Content-Type: text/plain; charset="UTF-8" On Mon, May 2, 2022 at 2:15 PM Guilliam Xavier wrote: > On Wed, Mar 16, 2022 at 9:57 AM Christian Schneider > wrote: > > > > Am 16.03.2022 um 06:52 schrieb Juliette Reinders Folmer < > php-internals_nospam@adviesenzo.nl>: > > > I've just been looking in detail at the Partially Supported Callables > deprecation RFC: > https://wiki.php.net/rfc/deprecate_partially_supported_callables > > > > > > The RFC explicitly excludes the `is_callable()` function and the > `callable` type from throwing deprecation notices. > > > > > > [...] I wonder if the decision [...] is the right one (though I > understand the desire to keep [them] side-effect free). > > > > > > Consider these code samples: > > > > > > function foo(callable $callback) {} > > > foo('static::method'); > > > > > > [...] in PHP 9.0 the function will start throwing a TypeError. > > > > [...] This is a major problem because code which was "just working" > directly goes to a TypeError without a migration phase warning about it. > This is something I've repeatedly advocated against. > > > > > if (is_callable('static::method')) { > > > static::method(); > > > } > > > > > > [...] in PHP 9.0, the behaviour of this code will be silently reversed > for those callbacks which would previously result in `is_callable()` > returning true, which makes this a potentially dangerous change without > deprecation notice. > > > > I agree with you here: Code which silently changes behavior is also a > migration hassle. > > Hi, > > I too would rather have "extra" deprecation notices in 8.2 than > *sudden errors / silent behavior changes* in 9.0 (for the callable > type declaration / the is_callable() function)... > > > The point is that this is not an usual deprecation, something that will change to an error in the future. In the end, it's just a change in behavior with no error before or after. It does not fit the "deprecation". As I dealt with several PHP upgrades, and I'm still going to deal with them in the future, I proposed an idea at some point on the mailing list: To find a way to "flag" a behavior change. The problem is that it should be something outside E_ALL, or to be able to handle it in a totally different way than setting an error handler for it. Something that can be used when preparing for an PHP upgrade, something like: register_version_change_handler(callable $callback, $toPhpVersion) While preparing for a future runtime version, it would be deployed to production and would record behavioral changes in a logging system. These changes need to be manually reviewed, of course, as a change can be to return false instead of null and if that value would be used further in an if. When using in a library maybe there could be some token like @@@ to not trigger the handler. So yeah, this cannot really be an usual deprecation, it needs to be something else, IMO. Regards, Alex --000000000000eb98a105de061648--