Re: Possible Bug with Interface, Constants and Inheritance
| From: | (Karl Pflästerer) | Date: | Mon, 27 Jun 2016 16:29:46 +0000 |
| Subject: | Re: Possible Bug with Interface, Constants and Inheritance | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-94287@lists.php.net to get a copy of this message | ||
Bishop Bettini <bishop@php.net> writes:
> On Mon, Jun 27, 2016 at 11:31 AM, Andreas Heigl <andreas@heigl.org> wrote:
>
>> Am 27.06.16 um 15:28 schrieb Karl Pflästerer:
>> > Andreas Heigl <andreas@heigl.org> writes:
>> >
>> >> Am 27.06.16 um 15:01 schrieb Karl Pflästerer:
>> >>> interface I1 { const C1 = '';}
>> >>> class C3 implements I1 { const C1 = 'c2';}
>> >>> $c3 = new C3;
>> >>> var_dump($c3::C1);
>> >>
>> >> According to https://3v4l.org/jIcs6 it looks like
>> >> that's intended
>> >> behaviour ;)
>> >
>> > But why does it work in the CLI if I write the code (instead of using a
>> > script)? That's my question.
>>
>> It doesn't. At least not on my machine. This is the output I get:
>>
>> $ php -v
>> PHP 7.1.0alpha2 (cli) (built: Jun 24 2016 13:50:28) ( NTS )
>> Copyright (c) 1997-2016 The PHP Group
>> Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
>>
>
> Technically, this is a different version than reported. Nonetheless, on the
> same version my REPL complains as well, I suspect because the original
> report misspelled the INI setting ("-ddispplay_errors=On", notice the
> double "p"):
[...]
Thanks; that explains why I didn't see the error message.
>
> Under normal interpretive operation, the Fatal terminates the script. But
> in the case of the REPL command line, those are swallowed up and you can
> keep going. Same as like:
>
And that explains why I was able to instantiate a broken class (with a
overriden constant).
So no bug but an interesting edge case.
KP