Re: Re: static:: and PHP 7 (from bug #70997)
| From: | Xinchen Hui | Date: | Mon, 30 Nov 2015 15:07:40 +0000 |
| Subject: | Re: Re: static:: and PHP 7 (from bug #70997) | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-89500@lists.php.net to get a copy of this message | ||
Hey:
> On Nov 30, 2015, at 22:48, Rowan Collins <rowan.collins@gmail.com> wrote:
>
> Andreas Heigl wrote on 30/11/2015 12:23:
>>> Am 30.11.15 um 13:18 schrieb Peter Cowburn:
>>> class A {
>>>> const TEST = false;
>>>> public function test() {
>>>> var_dump(static::TEST);
>>>> }
>>>> }
>>>>
>>>> class B extends A {
>>>> const TEST = true;
>>>>
>>>> public function test() {
>>>> A::test();
>>>> }
>>>> }
>>>>
>>>> $b = new B;
>>>> $b->test();
>> You are calling explicitly A::test().
>>
>> When you call parent::test() everything works as you'd expect it.
>>
>> Have a look at https://3v4l.org/RCrRd
>>
>> Apart from that you are calling an instance-method as a static method by
>> using A::test().
>
> This appears to be the crucial thing: if you declare the test() method as static in both
> classes, it returns false in all versions: https://3v4l.org/hJoor
>
> It's almost like A::test() is now interpreted as a static call, rather than a "scope
> resolution" of the instance method, but $this is still available, so it's not quite as
> simple as that: https://3v4l.org/qbT3j
>
dmitry has committed a fix, please have a look
Thanks
> Regards,
> --
> Rowan Collins
> [IMSoP]
>
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php