Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117544 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89392 invoked from network); 19 Apr 2022 13:44:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Apr 2022 13:44:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1072A180541 for ; Tue, 19 Apr 2022 08:18:15 -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=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 ; Tue, 19 Apr 2022 08:18:14 -0700 (PDT) Received: by mail-ej1-f42.google.com with SMTP id y10so16218255ejw.8 for ; Tue, 19 Apr 2022 08:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=/kLyWSzBqXMU56nipvVVD/cI0/MAuOkFkf1ljLU7srE=; b=BVrzBxAwkSFdconmxgs8/ym7A2Q4YdmdVngUi7Dy+nckMsls7WxgmCQsIdCjBj9CV2 SIa4GNIOjq8PdTdbg63N2SYlA6WL6hERXxJlgKDUsry/zAB8BcT9496kv6beOWwW9020 HQZqro/DpkuyEbj9sYSv3apmCaDwHNg2QKMLUoOwff+XLhu+a4Rkso82IVoDfuR8aG/w f6sLQXZd9WQYGbpkhYZ3RIzpmh+iydkQy2J/sqyOfrRi/bx+TMuw6ydiPKMNdFZa4sQD 5MEb0JzNCO7Kg97t/GsqfcVd7RTMikCY+LmhQknU7rQuPqEth8Qo8nmR3RPNrQ8SZhVF EMYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=/kLyWSzBqXMU56nipvVVD/cI0/MAuOkFkf1ljLU7srE=; b=4l1nQNA24T1qL69QTYb7AXdPqV6mK8vkHcEhoHcfg0HtfVzpcPFU2e8tncgX1Injmn mUvy8VEzoheFBX+/Rm2cZUE1XNMkxyukCGjf4G48+VBB90UpTCFaEb7JJ/P3hfvANF4w y2Z8Lmh5UBfcYk5N5ee1o3/PnW+PaDIjABW6fqCf2A7n7+9uL7yaeYCbY4G8mShcHFtu g0H0F9HE4S6yvhWOi7ymHOOmpSpWr4JfR+9EKQtYQAbhDlxDas3IeODd8d8FHhIiP4zl PNpieUsCV9ufkYXmmQNykLFvpCTXMoQ94TLM/V/yIiHWIC5aozWRgsq3caDgAGnD1jtC r62A== X-Gm-Message-State: AOAM530rS3MZRCmld9wkETjK/Im6mxkArTJeUUur8jZhewNgXeDquyAE EeYRqbFxLEvZ0aclFxTUoXsLGFQsrng= X-Google-Smtp-Source: ABdhPJyM8pCJkZC/pEOkMCpY8TVpCQBEbQarRwEhjtIFJ4NDSj5SHQXdA5mSajsHTnCC0WxO+tXIWg== X-Received: by 2002:a17:907:3f0f:b0:6ef:e43f:f3e7 with SMTP id hq15-20020a1709073f0f00b006efe43ff3e7mr2796347ejc.758.1650381493226; Tue, 19 Apr 2022 08:18:13 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id i12-20020a05640200cc00b00421058b175esm8375912edu.53.2022.04.19.08.18.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Apr 2022 08:18:12 -0700 (PDT) Message-ID: <0E683978-1E7F-4033-8B6D-F0CB74CC214C@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_0AF6D210-C813-4F73-A5AE-10EF546B1633" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Date: Tue, 19 Apr 2022 17:18:11 +0200 In-Reply-To: <6234BB7F.90507@adviesenzo.nl> Cc: "Christoph M. Becker" , PHP internals To: Juliette Reinders Folmer References: <62317B01.90907@adviesenzo.nl> <70c5d418-7472-7f87-dc2c-e1a60ee09df6@gmx.de> <6234BB7F.90507@adviesenzo.nl> X-Mailer: Apple Mail (2.3696.80.82.1.1) Subject: Re: [PHP-DEV] Deprecated partially supported callables: should is_callable() throwa deprecation notice ? From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_0AF6D210-C813-4F73-A5AE-10EF546B1633 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 18 mars 2022 =C3=A0 18:03, Juliette Reinders Folmer = a =C3=A9crit : >=20 > On 18-3-2022 14:37, Christoph M. Becker wrote: >> On 16.03.2022 at 06:52, Juliette Reinders Folmer wrote: >>> 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. >>>> The |is_callable()| function and |callable| type remain side-effect >>>> free and do not throw a deprecation warning. They will continue to >>>> accept these callables until support is removed entirely. >>> While I can fully support this for the `callable` type, I wonder if = the >>> decision to not throw a deprecation on use in `is_callable()` is the >>> right one (though I understand the desire to keep it side-effect = free). >>> Consider these code samples: >>> function foo(callable $callback) {} >>> foo('static::method'); >>> This function call not throwing a deprecation is not problematic as = in >>> PHP 9.0 the function will start throwing a TypeError. >>> if (is_callable('static::method')) { >>> static::method(); >>> } >>> The second code sample, however, is problematic, as 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. >>> Would anyone care to enlighten me as to whether this was given due >>> consideration ? >> Frankly, I don't know. Apparently, there was almost no discussion = about >> that RFC. Part of the reasoning to not raise E_DEPRECATED when = calling >> is_callable() was likely the typical use case >> $callable =3D =E2=80=A6; >> if (is_callable($callable)) { >> call_user_func($callable); >> } >> what would report the deprecation when actually calling the callable. >> Not sure what to do regarding your given use case(s). >> -- >> Christoph M. Becker >=20 > Unfortunately, those aren't the only places I see this happening and = my example is not a stand-alone case either. >=20 > I came across the above code sample ( is_callable('static::method') / = is_callable(['parent', __FUNCTION__]) with variable method calls) in a = number of different packages when testing a (PHPCompatibility) sniff I = am writing to detect the deprecation, so this code pattern looks to be = relatively common. >=20 > Some examples: > * = https://github.com/symfony/service-contracts/blob/bc0a2247c72d29241b5a06fb= 60dc1c9d9acf2a3a/ServiceSubscriberTrait.php#L39 > * = https://github.com/mockery/mockery/blob/c10a5f6e06fc2470ab1822fa13fa2a7380= f8fbac/library/Mockery/Mock.php#L960 > * = https://github.com/simplepie/simplepie/blob/dacf0ed495d2e8fb306e526ca3f2a8= 46af78a7c9/tests/oldtests/absolutize/RFC3986.5.4/base.php#L13 >=20 As I think that it is a serious oversight of the RFC, I have open: https://github.com/php/php-src/issues/8401 = =E2=80=94Claude --Apple-Mail=_0AF6D210-C813-4F73-A5AE-10EF546B1633--