Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108896 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72101 invoked from network); 8 Mar 2020 12:53:48 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Mar 2020 12:53:48 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E5CF71804E4 for ; Sun, 8 Mar 2020 04:14:08 -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=-0.6 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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: Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 ; Sun, 8 Mar 2020 04:14:08 -0700 (PDT) Received: by mail-wm1-f46.google.com with SMTP id 6so6979578wmi.5 for ; Sun, 08 Mar 2020 04:14:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:from:message-id; bh=3YbNpwYsybkexefHQWcMjioo26g3+shrO6l8t/zuwnU=; b=TGC7zTy3qGSyZx5aCSIGIfZiHzR40Ne7JXFWvsh66ktHnqNEoCfHZmcCTuNq+ZPVzJ tdkqBfnNOCCT8SvngnrXBfzotBNKhnEXT/z3CtbbGrCPn1w/ZPThV4dTosvWgwsM2ejS TKq5u9ZwKCGMZER3+1CZVV9fWPCgjatI6QoAYpCdNcVDvkAPH9iBm+3oBwbrLZAyBebV oF8EhkuVyRXBYHJJo+ZwYUkbhyVQLEnQ+SJI7jaRAQhyTHzFoRhr8Ni7GlBE/FI7BQze Jw0bMAOBbvZj7EzBjSGJUz1N80V96uEQAJv2lIJoTBs7tTRdoOctQgXO4SF8Yccv1KMC YB2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=3YbNpwYsybkexefHQWcMjioo26g3+shrO6l8t/zuwnU=; b=KiVUS3I38LdWOc17xk3ys4azLkWnWRQGScABVdWEe5vL7dm3seRHJGpqodzZMLB8HO Iw7XcTjjsVO5/HY9oOoaSuSBWoWqoQhBneRk/jS69NP4GVT8vTQ9nL9YnJJ+ond42fX9 IF9Ja+S8yb/EYfS2gPKSnB8qAstJxK+fJfLb7yrbpqUqufWHfGltc+InrlBsZ7ss3ehJ Gsyw2bAc3rpxrhNq3qKs3PO2BKqUveIGZIgvx8Gmgznm6xyj7OpRTEkYUpdPWusYidxs BLu/SSPW2cpAFsep0v2FdYtQ+oYRU3CjY3/kjLkTwLj1hFn8eQ5op7/H3BG/cn4tXLgd +ZNg== X-Gm-Message-State: ANhLgQ1bqtumuau52EO57ARD+ZMXS4m9r4XqBfzBXNJEy8ue2npMbIh9 VopnT8Rr5N2gguQ+ehB33x9on4OC X-Google-Smtp-Source: ADFU+vssR+ViQKWeLbZgdTxup5tTx6IRJLnQ1hqkBoO2S4dPIAjJnSc9SDZxo5WS/3mNnOtew3w4Sg== X-Received: by 2002:a1c:f003:: with SMTP id a3mr8067058wmb.41.1583666046106; Sun, 08 Mar 2020 04:14:06 -0700 (PDT) Received: from [192.168.0.12] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.gmail.com with ESMTPSA id w19sm19969238wmc.22.2020.03.08.04.14.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Mar 2020 04:14:05 -0700 (PDT) Date: Sun, 08 Mar 2020 11:14:03 +0000 User-Agent: K-9 Mail for Android In-Reply-To: <1845472b-08ab-bb31-dc77-23c620b8d217@mabe.berlin> References: <1845472b-08ab-bb31-dc77-23c620b8d217@mabe.berlin> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net,Marc Message-ID: <577AEC29-07C5-4B5D-BC90-14E09063AAB1@gmail.com> Subject: Re: [PHP-DEV] Bug Wrong resolution of "Late Static Binding" after self::method() From: rowan.collins@gmail.com (Rowan Tommins) On 8 March 2020 09:47:37 GMT+00:00, Marc wrote: >https://3v4l=2Eorg/NSdB8 > >class A { > =C2=A0=C2=A0=C2=A0 static function call() { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 self::method(); > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $self =3D self::class; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $self::method(); > =C2=A0=C2=A0=C2=A0 } > =C2=A0=C2=A0=C2=A0 static function method() { echo static::class; } >} > >class B extends A {} > >B::call(); // displays "BA" instead of "AA" Someone else may be able to confirm if this is a bug or working as designe= d, but what seems to be happening is that the value of "static" is not rese= t when calling a method using self:: This doesn't just apply to getting the class name, but to actual static ca= lls; for instance: # https://3v4l=2Eorg/p2g8E class A { static function call() { self::method1(); } static function method1() { static::method2();=20 } static function method2() { echo 'Base definition'; } } class B extends A { static function method2() {=20 echo 'Override'; } } B::call(); If the call to self::method1() reset the called class, this would run A::m= ethod2() and echo 'Base definition'; instead, the called class is remembere= d, and it calls B::method2() and echoes 'Override'=2E If you explicitly call A::method1(), as you are effectively doing in your = self::class example, the "called class" information is reset, and the call = goes through to A::method2()=2E Regards, Hi Marc, --=20 Rowan Tommins [IMSoP]