Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117374 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60695 invoked from network); 18 Mar 2022 15:39:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Mar 2022 15:39:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 37A13180382 for ; Fri, 18 Mar 2022 10:04:35 -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=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_SOFTFAIL,STOX_BOUND_090909_B,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS36483 23.83.208.0/21 X-Spam-Virus: No X-Envelope-From: Received: from bee.dogwood.relay.mailchannels.net (bee.dogwood.relay.mailchannels.net [23.83.211.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 18 Mar 2022 10:04:33 -0700 (PDT) Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 3935F6C1B14; Fri, 18 Mar 2022 17:04:28 +0000 (UTC) Received: from nlss2.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id 403DC6C1D83; Fri, 18 Mar 2022 17:04:02 +0000 (UTC) Received: from nlss2.a2hosting.com ([TEMPUNAVAIL]. [209.124.66.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.112.144.24 (trex/6.5.3); Fri, 18 Mar 2022 17:04:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=adviesenzo.nl; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=eaUECb3n7HDNkb4YxzReMlbGnk7pmtmfUTs+PVTDnY0=; b=DRMLbK8OmqqopGQquVnC+licXo 0QXBkJjwpov4b0IDB5kdepfuD7aQvKHHGP2mACTf6YBpMIiLcI6kShPRzTjxCsUUEd87C/un8TOuH BKcHuctKHlObzRvk4XmctvhdgclWiKQ/vX7+qJDuVylqcYP4l1S84lhD80GcNuSgz1Hs=; Received: from 86-154-178-143.ftth.glasoperator.nl ([143.178.154.86]:55918 helo=[192.168.1.104]) by nlss2.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nVG1A-00GM97-Fh; Fri, 18 Mar 2022 18:04:00 +0100 To: "Christoph M. Becker" , PHP internals References: <62317B01.90907@adviesenzo.nl> <70c5d418-7472-7f87-dc2c-e1a60ee09df6@gmx.de> Message-ID: <6234BB7F.90507@adviesenzo.nl> Date: Fri, 18 Mar 2022 18:03:59 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <70c5d418-7472-7f87-dc2c-e1a60ee09df6@gmx.de> Content-Type: multipart/alternative; boundary="------------030808070708090502020305" X-AuthUser: juliette@adviesenzo.nl Subject: Re: Deprecated partially supported callables: should is_callable() throwa deprecation notice ? From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) --------------030808070708090502020305 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 = …; > 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 Unfortunately, those aren't the only places I see this happening and my example is not a stand-alone case either. 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. Some examples: * https://github.com/symfony/service-contracts/blob/bc0a2247c72d29241b5a06fb60dc1c9d9acf2a3a/ServiceSubscriberTrait.php#L39 * https://github.com/mockery/mockery/blob/c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac/library/Mockery/Mock.php#L960 * https://github.com/simplepie/simplepie/blob/dacf0ed495d2e8fb306e526ca3f2a846af78a7c9/tests/oldtests/absolutize/RFC3986.5.4/base.php#L13 --------------030808070708090502020305--