Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117814 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45619 invoked from network); 28 May 2022 06:39:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 May 2022 06:39:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 424EB1804C6 for ; Sat, 28 May 2022 01:22:29 -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,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.222.0/24 X-Spam-Virus: No X-Envelope-From: Received: from dragonfly.ash.relay.mailchannels.net (dragonfly.ash.relay.mailchannels.net [23.83.222.51]) (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 ; Sat, 28 May 2022 01:22:27 -0700 (PDT) X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 442E1817B7; Sat, 28 May 2022 08:22:23 +0000 (UTC) Received: from nlss2.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id 114728183F; Sat, 28 May 2022 08:22:21 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653726142; a=rsa-sha256; cv=none; b=NhH7WmoszxmW0TwqJPwcWTB2gNY4PbxZlMNURLpQq3rde0+431ySzNzh0tBQcHHz3LInZI bsi2H2FKlWTgC3hFTrJaJ3icAwZcVeb8up66K6dCnyOEIrrQW2fNEEoimHqbtOry+BCHp9 FybdYf3Pm5ICOjfbviu25e/0Fb69e6NHzCdsQjfXV9DDHuFWgZDS8BL6/ZTUZBOwuKPD4A DFAdnaRzPvAbt5TdM31OObQ8a96pPs1kqUZlkhrTvyKQ4VBGfn2ino/j90f0X5sh2Oa0oX R9FCtK/ei+1m0Zj2W7Rndix07I3CD5TwSqRzMglnhffciv6wKGGn7uiWcnVp9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653726142; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=F8BPpH7bWYSdWJbH9bwbFg75ddlWUkZyTdcJlDtky0U=; b=gv8GwHNLVUCp13DZxUCD2n3AZdyM8D7z/p88wPLA7si8bu9o1VLL+u8jCTpPIJ7PRZayLn 6lS7eA/uf2mKACztF1Io2Kf22VvN548llZhXdJJwshNbb4kN2j4LXJCDDoWucMhQte4YgU caKTC7/O3YWohEwnKTtSxjx+qVba1dGPXUlEYMssGI88PURRWiQvlI/114lFzcgt9VPS80 LPmlMIzpr5ceC1HloyMb+zhkN1C41MpDoPpPCR1bX9r8B/3O10qoIbNW18UGl+0pzJznQ/ Uu2vCzoO/Ko0ltfNqDJgh2YMhGR4KkzR4iYKYTdGvH7hhefIijlzv1yuZFBYyQ== ARC-Authentication-Results: i=1; rspamd-84fcb66578-4ctwp; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|juliette@adviesenzo.nl X-MailChannels-Auth-Id: a2hosting X-Squirrel-Wiry: 3c6e89d47c95dffd_1653726142913_2019024698 X-MC-Loop-Signature: 1653726142913:1085713471 X-MC-Ingress-Time: 1653726142913 Received: from nlss2.a2hosting.com (nlss2.a2hosting.com [209.124.66.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.106.158.163 (trex/6.7.1); Sat, 28 May 2022 08:22:22 +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:Cc:References:To:Subject:Sender:Reply-To: 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=F8BPpH7bWYSdWJbH9bwbFg75ddlWUkZyTdcJlDtky0U=; b=TwyBkbwAi99AEwSxQKwouIC2EP StJCo8q4EWz1cbOvD7OpTkvAiz79oSBVoM8IFv+epWufd8pxZGNhX7D8YYs7wuERQt87K/J6O4aeN jFR8NffHw3909fuOEl2YJXvoAGMUL6kEXuZlUABsWAz1jcGjvN7rGDL3Dg0Gp3UtyNx8=; Received: from 86-154-178-143.ftth.glasoperator.nl ([143.178.154.86]:52275 helo=[192.168.1.104]) by nlss2.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.95) (envelope-from ) id 1nuriG-0022mo-93; Sat, 28 May 2022 10:22:20 +0200 To: internals@lists.php.net References: <627D3BCF.7020903@adviesenzo.nl> <628F685B.8090909@adviesenzo.nl> Cc: Dan Ackroyd Message-ID: <6291DBBC.8020403@adviesenzo.nl> Date: Sat, 28 May 2022 10:22:20 +0200 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: Content-Type: multipart/alternative; boundary="------------090805030501010409050206" X-AuthUser: juliette@adviesenzo.nl Subject: Re: [PHP-DEV] [Discussion] Expand deprecation notice scope for partially supported callables From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) --------------090805030501010409050206 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 26-5-2022 20:23, Dan Ackroyd wrote: > Hey Julie, > > On Thu, 26 May 2022 at 12:45, Juliette Reinders Folmer > wrote: >> I propose to open the vote on this RFC tomorrow. > Before you open the vote, please could you split the voting into two, > one for the is_callable, and one for the callable type check? > > Rowan wrote in https://news-web.php.net/php.internals/117670: >> is that passing "99 red balloons" to an "int" >> parameter raised an E_NOTICE in PHP 7.x, so a "callable" parameter >> raising an E_DEPRECATED should be fine. > There's one issue. > > When "99 red balloons" is coerced to an int, that is done once, and > then any further int type check will pass. For callables, it's pretty > common to pass them down a stack of code, e.g. similar to: > > function foo(callable $fn, $data) > { > $fn($data); > } > > function bar(callable $fn, $data) > { > return foo($fn); > } > > function quux(callable $fn, $data) > { > return bar($fn, $data); > } > > > function main(array $data) > { > $fn = get_callable_from_input(); > if (is_callable($fn) === false) { > // give some error. > return; > } > > quux($data); > } > > As far as I understand it, this code would give a deprecation notice > for each call level, which seems quite undesirable. Particularly if > the callable is being used in a loop. > > Also, without a patch it's hard to guess what performance impact this > would have. I doubt it would be huge, but it probably wouldn't be zero > either. Performance wouldn't matter for is_callable, as that is > typically only done once per callable, but callable type checks are > done continuously. > > cheers > Dan > Ack Hiya Dan, I admit, I puzzled over this for a little and wanted to take the time to respond properly before opening the vote, so I'm delaying the start of the vote until beginning of the upcoming week. In my first draft of the RFC I actually had two votes, but once it shaped up this was brought down to one vote. Reason being, that for the practical implications of fixing the deprecations, there is no difference between the two. In your example, you suggest a variable being passed between functions all using the `callable` type. The same can be encountered with functions without the `callable` type, but using manual defensive coding via `is_callable()` - typical example: a collection of callbacks being checked before being registered to a callback stack and being checked again before actually being called as the stack may have been manipulated from outside. Yes, having each of those instances throw a deprecation notice will be more noisy, especially if the same deprecated callback is used in a loop and yes, this will have a (small) performance impact while these callbacks aren't fixed yet, but the same *one* fix - at the point where the problematic callback is defined - will fix them all in one go, so the amount of fixes to be made does not change, but the chances of _identifying_ all the places were a fix is _needed_ is greatly improved. In that sense, it is no different from the "99 red balloons" case when those issues are solved at the _source_ of the problem. Patching the "99 red balloons" by applying `(int)` casts at the point the deprecation is thrown, will lead to a codebase full of type casts, while the underlying problem - the origin of the text string - is not addressed (and in the case of the callbacks, the origin is the only place they _can_ realistically be solved). Considering the above, do you still feel that splitting the vote in two is the best way to go ? Smile, Juliette --------------090805030501010409050206--