Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117344 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 37058 invoked from network); 16 Mar 2022 07:32:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Mar 2022 07:32:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B7B73180541 for ; Wed, 16 Mar 2022 01:57:06 -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.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS1836 195.49.0.0/17 X-Spam-Virus: No X-Envelope-From: Received: from darkcity.gna.ch (darkcity.gna.ch [195.49.47.11]) (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 ; Wed, 16 Mar 2022 01:57:06 -0700 (PDT) Received: from smtpclient.apple (unknown [IPv6:2a02:1210:2ea4:cf00:100c:d908:fc69:af84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id ED2031516681 for ; Wed, 16 Mar 2022 09:57:04 +0100 (CET) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Date: Wed, 16 Mar 2022 09:57:04 +0100 References: <62317B01.90907@adviesenzo.nl> To: PHP internals In-Reply-To: <62317B01.90907@adviesenzo.nl> Message-ID: <3F016525-CCDE-4229-9260-7C76A6FF42E1@cschneid.com> X-Mailer: Apple Mail (2.3696.80.82.1.1) Subject: Re: [PHP-DEV] Deprecated partially supported callables: should is_callable() throw a deprecation notice ? From: cschneid@cschneid.com (Christian Schneider) Am 16.03.2022 um 06:52 schrieb Juliette Reinders Folmer = : > I've just been looking in detail at the Partially Supported Callables = deprecation RFC: = https://wiki.php.net/rfc/deprecate_partially_supported_callables >=20 > The RFC explicitly excludes the `is_callable()` function and the = `callable` type from throwing deprecation notices. >=20 >> 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.=20 >=20 > 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). >=20 > Consider these code samples: >=20 > function foo(callable $callback) {} > foo('static::method'); >=20 > This function call not throwing a deprecation is not problematic as in = PHP 9.0 the function will start throwing a TypeError. My reaction to your last sentence is actually quite the opposite: 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(); > } >=20 > 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. I agree with you here: Code which silently changes behavior is also a = migration hassle. - Chris