Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114038 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6574 invoked from network); 12 Apr 2021 13:33:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Apr 2021 13:33:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 30E0B180002 for ; Mon, 12 Apr 2021 06:33:44 -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 autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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, 12 Apr 2021 06:33:43 -0700 (PDT) Received: by mail-lj1-f173.google.com with SMTP id u4so15370951ljo.6 for ; Mon, 12 Apr 2021 06:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lq63tDLr8P0xjcL9PKZ/fbVSQLCSEwX2h17Q5FAS7qE=; b=rrJZIO5Xaecw1Jus311qMwhFLv4mxVjzTyh3uN2nofK+AfhwqGqA4vqrAkG2XUdzTM WqNVQPeJIbsHhlDhZz5HkrKFEd5tzt6sUIcnsUo0NgW3rI6j90Egef/eAYpkIXN6o8BF kbOut5r1QzGA9P8ezEwx1Beo9rcNnPMITh9bOA43nZ6BNqPDPXzKMs+QrnRPe2LusQ1U Wzk4Ue5HakAwmNaHpImxg6jnScxRbQqWwoM3DQOQlqRrhux0OLJ06m6ZtohoF9GdxWiO 6mV/LnX9IUI+emEgLKI336kjrqVzVVAE7Z8Pyq1DezJhjK5Djz0Umejd+lowFwOEKSeF dK+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lq63tDLr8P0xjcL9PKZ/fbVSQLCSEwX2h17Q5FAS7qE=; b=ikM8tZg54Ody4l2EDYITsPAsXwW6R1qU5WUXQSayllFC451dTDfSMQIJa9ctXA4SzV /5FtXJNRAtk7EF0bNa/yHRGZX4SRn53lbWOWt3TGKt+MrrZSLXvZx6B+deJb8ZU0Ejor 1Q7E7I1iCdCIU7Y6E/YmrwPprFKE/4lS/HatI1wEbtxzAeWOtuFppYv4fgg2Fi6+1KAE 90eUxX4VgjSXTfgFlTaDyPPmnr0FXGgUYWzwTNxhc7agcIqmC1+ND5k6/l8/fUf1S+3T ESH7QyKjDnCRWBXLJCN1iFVeLMr5JHDEOotmH3fyEQsqK33hBrNC7Wae6d8eVy0M7LG8 Ewuw== X-Gm-Message-State: AOAM531z4XA3/7uZLC2XvQ0lg+lHjd7cqouj/3wy0tFuBdFmJfeuGRd2 d29xtDeVxRcNiMg6igGGBrxCoKrbQaNEsM1kqvU= X-Google-Smtp-Source: ABdhPJzdQZ1fbbEbN3WUiVUbCDwM5Su753rBNkrx71DCnbP5nHUjXeQY96BqzLPHuj3HgVM5Q69kET6TOBV04f68uy4= X-Received: by 2002:a05:651c:1198:: with SMTP id w24mr7627099ljo.29.1618234419688; Mon, 12 Apr 2021 06:33:39 -0700 (PDT) MIME-Version: 1.0 References: <28be190c-21ea-b796-cec7-b8db21d14eca@gmail.com> In-Reply-To: Date: Mon, 12 Apr 2021 15:33:23 +0200 Message-ID: To: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= Cc: Stanislav Malyshev , PHP internals Content-Type: multipart/alternative; boundary="000000000000bfb9ef05bfc68f07" Subject: Re: [PHP-DEV] [RFC] Deprecations for PHP 8.1 From: nikita.ppv@gmail.com (Nikita Popov) --000000000000bfb9ef05bfc68f07 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 12, 2021 at 3:15 PM M=C3=A1t=C3=A9 Kocsis wrote: > Hi Nikita and Stanislav, > > > > get_class(), get_parent_class() and get_called_class() without >> argument >> > >> > I'm not sure why. I mean if we want to make them return the same as >> > self::class etc. - up to the point of actually compiling them as such = - >> > no problem, but I don't see why they need to be deprecated. And I >> > vaguely remember seeing get_class() at least a bunch of times in old >> > code, when ::class didn't even exist. I don't see a good reason why th= at >> > code should be broken. >> > >> >> I agree with you on this one. From my perspective, there should be some >> technical motivation for deprecations, and this one seems to be more abo= ut >> coding style -- it removes an old way to write something, which has been >> subsumed by a different construct in the meantime. I think M=C3=A1t=C3= =A9 suggested >> this one, maybe he can provide additional reasoning. >> > > The technical motivation why I suggested this idea is because the optiona= l > parameter of get_class() and get_parent_class() doesn't have a correct > default value > since https://wiki.php.net/rfc/get_class_disallow_null_parameter. So I > don't really mind > the coding style perspective, I'd only like to ensure that default value > handling is > right without reverting the relevant RFC. If you think it's too much of a > BC break for a > small gain, then I'm ok to remove this item from the list. > Just to get a rough idea on how common these are, on the top 2k composer packages: $ rg -t php "get_class\(\)" sources/ | wc -l 379 $ rg -t php "get_parent_class\(\)" sources/ | wc -l 174 $ rg -t php "get_called_class\(\)" sources/ | wc -l 218 For get_class() and get_parent_class() a large fraction of uses seem to be in generated code. get_parent_class() is almost always used to check if a parent class exists, not get what it actually is. So the replacement for that would be get_parent_class(self::class) rather than parent:class. Here's the grep output if you want to take a look: https://gist.github.com/nikic/12f963fbb4af9d0b2ef885a7417f6016 I don't have a strong opinion regarding the default value issue. It would be nicer if we did not have functions with argument count dependent behavior, but I also don't think it's a big deal in this case. These functions are still rather benign -- they don't perform crazy signature overloading like pg_query(), where it's impossible to express the signature in normal PHP code anymore. Overall I'm unsure the breakage is worthwhile here. Maybe someone else wants to chime in as well. Regards, Nikita --000000000000bfb9ef05bfc68f07--