Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110683 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34127 invoked from network); 19 Jun 2020 14:13:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jun 2020 14:13:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 467831804C3 for ; Fri, 19 Jun 2020 05:59:16 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS20857 149.210.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from outbound0.mail.transip.nl (outbound0.mail.transip.nl [149.210.149.69]) (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, 19 Jun 2020 05:59:15 -0700 (PDT) Received: from submission1.mail.transip.nl (unknown [10.100.4.70]) by outbound0.mail.transip.nl (Postfix) with ESMTP id 49pJm156wHzxPVx for ; Fri, 19 Jun 2020 14:59:13 +0200 (CEST) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by submission1.mail.transip.nl (Postfix) with ESMTPA id 49pJm04flpz1nt4b for ; Fri, 19 Jun 2020 14:59:12 +0200 (CEST) Received: by mail-wm1-f53.google.com with SMTP id f185so9050839wmf.3 for ; Fri, 19 Jun 2020 05:59:12 -0700 (PDT) X-Gm-Message-State: AOAM531PnXuAS/90bz2tnvMzzPORuKVo03SPomeTH/DqZsyOvoxUblb7 DPgl52I4DQdvkCHNM2+fJTQkcsoscu0dwOpKzSs= X-Google-Smtp-Source: ABdhPJzHt3baz9tS42sf3v9vIIdFPxMLRH33VVYHrgLewLr6/PIJxeE9Vhe+A5u1WGM2cFkQMkL/oKVsAz89P7RbIP0= X-Received: by 2002:a1c:790a:: with SMTP id l10mr3457263wme.80.1592571552441; Fri, 19 Jun 2020 05:59:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 19 Jun 2020 13:59:01 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Nikita Popov Cc: Marco Pivetta , PHP internals Content-Type: multipart/alternative; boundary="000000000000a9a96005a86f75e9" X-Scanned-By: ClueGetter at submission1.mail.transip.nl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=transip-a; d=pmmaga.net; t=1592571552; h=from:subject:to:cc: references:in-reply-to:date:mime-version:content-type; bh=WO6/OaO88yWAfoRir5dz1Cp6R0BZd/5ON9UPAqWMPaQ=; b=cBnOx1xqgrxYo9hLPUG5VOIWhYp8A6e/g8xhCqjmtlxe+9hP3tq42pnbrB7I+CH6q5Pno4 M47Nnv5BCdRFD489lYcPoxQi3vE9N7xpCWpuHgL+kc677xMQGxUmPwQcSU6Cgd3+Sx9eRy XzPBqXXKLuo8UfcYLyGvR/oo7Hc7JGbxmsBih2AGRD2xBiu5ifdxERUDMWXU+5WLswqJHh jyzu5mit1K4EVeOiN+YbJ9JoMWdGFoDvb+e7Vi7e3tbYBKvjS7jaA+yJX2A6HHrijY+Le0 kJ4W7R8zUFknjmalxp8vqck/DJNuIFNjXRE/iMkfVzm3ex0DHr3CA1wT9DAdjw== X-Report-Abuse-To: abuse@transip.nl Subject: Re: [PHP-DEV] [VOTE] Remove inappropriate inheritance signature checks on private methods From: mail@pmmaga.net (=?UTF-8?Q?Pedro_Magalh=C3=A3es?=) --000000000000a9a96005a86f75e9 Content-Type: text/plain; charset="UTF-8" On Fri, Jun 19, 2020 at 10:17 AM Nikita Popov wrote: > On Tue, Jun 16, 2020 at 11:19 AM Marco Pivetta wrote: > >> Maybe the magic methods would indeed all need to respect `final`, and we >> haven't considered all scenarios? >> > > Or ... we could just not change this part of the behavior at all :) If we > acknowledge that this is definitely useful for constructors and possibly > useful for cloning, then maybe it is useful for other things as well? I > still haven't heard a reason *why* we would want to do this change (not the > general change, but specifically the "private final" one). > > This stuff really isn't super important to me, and I'd be happy to > sacrifice this functionality in the name of the greater good, but I > honestly don't understand what that greater good is in this case. It seems > like a strict loss in functionality. > > Regards, > Nikita > Hi Nikita, The motivations for changing the behavior of final private are the following: - Theoretical: Even though private members are technically inherited by child classes, they are not overridable. You can already have public methods in a child class with the same name as a private parent, but you are not overriding it (if you call that method in the parent, you will use the private method declared there. If you call it in the child, you will use the public method declared there - https://3v4l.org/TImO8). You can have different visibility, different signatures (thanks to a bugfix that was actually my first contribution to PHP :) ) and the methods are completely unrelated except that they share the name. Sharing the name shouldn't be a reason to enforce any inheritance rules. - Implementation: My preferred way to implement this would have been to skip the call to `do_inheritance_check_on_method_ex` on private methods completely, as that would make the intention very clear. The only reason why I couldn't is the check for abstract private methods coming from traits. And currently, the ZEND_ACC_CHANGED flag is also added there, but I think that could be easily avoided. - Other languages: - Java: https://www.ideone.com/P71k8J - final has no effect when added to a private method ( https://www.javaworld.com/article/2077399/private-and-final.html) - C#: https://www.ideone.com/i1OtFe - In C#, for a method to be overridable it has to be marked as virtual. In this snippet, we are not marking it as virtual (hence it acts as final) and nothing prevents us from declaring it in the child class. Regards, Pedro --000000000000a9a96005a86f75e9--