Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108915 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35853 invoked from network); 9 Mar 2020 20:28:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Mar 2020 20:28:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 268221804D3 for ; Mon, 9 Mar 2020 11:49:42 -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.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS35329 80.237.132.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wp160.webpack.hosteurope.de (wp160.webpack.hosteurope.de [80.237.132.167]) (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 ; Mon, 9 Mar 2020 11:49:40 -0700 (PDT) Received: from [2a02:8109:9d40:1d44:19ae:717a:50a6:57a6]; authenticated by wp160.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) id 1jBNT9-0004MP-27; Mon, 09 Mar 2020 19:49:39 +0100 To: internals@lists.php.net References: <1845472b-08ab-bb31-dc77-23c620b8d217@mabe.berlin> <4D79715B-D9F8-42F8-B0DB-4EA7B6DBFB6A@gmail.com> <58110de6-9d68-869c-9381-d50c1ea46616@mabe.berlin> Message-ID: Date: Mon, 9 Mar 2020 19:49:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-bounce-key: webpack.hosteurope.de;marc@mabe.berlin;1583779782;4958c931; X-HE-SMSGID: 1jBNT9-0004MP-27 Subject: Re: [PHP-DEV] Bug Wrong resolution of "Late Static Binding" after self::method() From: marc@mabe.berlin (Marc) Thank you all for explaining. This helps a lot! Marc On 09.03.20 10:27, Rowan Tommins wrote: > On Mon, 9 Mar 2020 at 05:38, Marc wrote: > >> Does it make sense? -> I have read "self::" all time as a shortcut for >> "MyClass::" until I noticed this is not the case and I expect most PHP >> devs would explain it this way. >> >> Is there a reason why self:: doesn't reset the internal "static" reference? >> > > > A reasonably intuitive parallel that occurred to me is that $this is also > maintained through self:: calls (as long as they're not to a method > declared static). > > So if you replace the static:: call in my previous example with a $this-> > call, you get the same result: > > > # https://3v4l.org/deRcD > class A { > function call() { > self::method1(); > } > function method1() { > $this->method2(); > } > function method2() { > echo 'Base definition'; > } > } > class B extends A { > function method2() { > echo 'Override'; > } > } > (new B)->call(); # echoes 'Override' > > > Regards,