Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:108905
Return-Path: <rowan.collins@gmail.com>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 21314 invoked from network); 9 Mar 2020 11:07:15 -0000
Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5)
  by pb1.pair.com with SMTP; 9 Mar 2020 11:07:15 -0000
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 401821804E4
	for <internals@lists.php.net>; Mon,  9 Mar 2020 02:27:50 -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,SPF_HELO_NONE,SPF_PASS autolearn=no
	autolearn_force=no version=3.4.2
X-Spam-ASN: AS15169 209.85.128.0/17
X-Spam-Virus: No
X-Envelope-From: <rowan.collins@gmail.com>
Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178])
	(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 <internals@lists.php.net>; Mon,  9 Mar 2020 02:27:49 -0700 (PDT)
Received: by mail-il1-f178.google.com with SMTP id a6so8001193ilc.4
        for <internals@lists.php.net>; Mon, 09 Mar 2020 02:27:49 -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;
        bh=UVqt/zS0YIJkj+n73P2f2UZ0xeA77DL1tLsk7pR7bQM=;
        b=J7WBuVvsyIMpOJK+LFMdE0FqKfAAQnVkZGqub2lbKeMVed0nHogOJBMTvRFefch9uh
         KTo2NlfqC2281KhUmzMKw2Gms4xSIA8+WGJ5e8Gv+JuyB5EZoxipcFVJtmy8Ax9Up7sq
         hR8qZCUAqjmodgnQ4koieG3DEzv26EuYD+Jvaw65k7LZhQPjtocHCl/jxzLlfLUFVCyE
         njTu7Tfc7d76FXybr1luXVI8lpcKmb+b2Xdliu1vdrGtuv6M6AqZrE9SV3vQiLcwhtmK
         y2yEmhiNzdw7uITyMDaJRWOtrGlkXEb4oCi2Z4SIA3ZYgTNqH7EFDqB8FgYUk8UwQdYT
         mbDA==
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;
        bh=UVqt/zS0YIJkj+n73P2f2UZ0xeA77DL1tLsk7pR7bQM=;
        b=NBCSb5nVB1xzZEY4ppADxdqAzS0SCaTFQS0nQlwY6vX7buMvCT3yY4wvjOsvmBo5Ys
         THSVHearGIHfxZXWhubqZtFUs0n/eE1vO953Q6Q6wSlBRr06egkF5GFmbzjk+zBhoBhF
         0KlG0ee+C4vJmtwf56m61xBPx05U5DVj5DBbmWgul4eInUEncwqiBHqZVbC60hOfNkyR
         9schD/JVV/JS6yV6G+BW7U/zM64LEnKVDeQn8OaXfTvgCFIhW2i3dRGs9N2qytyRYfZP
         hUFAwmzXPjrokkq/OvglY7ngspxOi8DuKY36XiXBsA4IopAVt7sGB55vkKAZ5DCyPf4k
         QVCQ==
X-Gm-Message-State: ANhLgQ1zk8AP0oDF8Cne2eTMcybpSwqERJqh/aYiaq+6840dgOhQMuzG
	o1s1BR2CDXtj3u1UUiq9G5CHN1Ffs2ezewVevXU8IEWo
X-Google-Smtp-Source: ADFU+vtVxykWJV8H6qJHOBDGl+w/4oXN13+dIBZDk4ZaR98MaKBGgrYqgVLIpQN/eNaX3DX5RBRPw0R+3ZXJBcMlzCU=
X-Received: by 2002:a92:5a88:: with SMTP id b8mr12446242ilg.206.1583746065771;
 Mon, 09 Mar 2020 02:27:45 -0700 (PDT)
MIME-Version: 1.0
References: <1845472b-08ab-bb31-dc77-23c620b8d217@mabe.berlin>
 <4D79715B-D9F8-42F8-B0DB-4EA7B6DBFB6A@gmail.com> <58110de6-9d68-869c-9381-d50c1ea46616@mabe.berlin>
In-Reply-To: <58110de6-9d68-869c-9381-d50c1ea46616@mabe.berlin>
Date: Mon, 9 Mar 2020 09:27:34 +0000
Message-ID: <CALKiJKqGvt0aeg5mqix+jpHko3GeqPMZWytN97BagAbg7goTTA@mail.gmail.com>
To: PHP internals <internals@lists.php.net>
Content-Type: multipart/alternative; boundary="000000000000aa314e05a0689dc0"
Subject: Re: [PHP-DEV] Bug Wrong resolution of "Late Static Binding" after self::method()
From: rowan.collins@gmail.com (Rowan Tommins)

--000000000000aa314e05a0689dc0
Content-Type: text/plain; charset="UTF-8"

On Mon, 9 Mar 2020 at 05:38, Marc <marc@mabe.berlin> 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,
-- 
Rowan Tommins
[IMSoP]

--000000000000aa314e05a0689dc0--