On Mon, Jun 27, 2016 at 11:31 AM, Andreas Heigl <andr...@heigl.org> wrote:
> Am 27.06.16 um 15:28 schrieb Karl Pflästerer: > > Andreas Heigl <andr...@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"): $ php -v PHP 7.0.7 (cli) (built: May 28 2016 08:26:36) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans $ php -a Interactive shell php > interface I1 { const C1 = ''; } php > class C3 implements I1 { const C1 = 'c2'; } PHP Fatal error: Cannot inherit previously-inherited or override constant C1 from interface I1 in php shell code on line 1 PHP Stack trace: PHP 1. {main}() php shell code:0 > So it crashes with a fatal error when Implementing the interface. It'S > interesting though that the script allows me to instantiate the class > nonetheless. That's right. > 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: php > foo(); PHP Warning: Uncaught Error: Call to undefined function foo() in php shell code:1 Stack trace: #0 {main} thrown in php shell code on line 1 PHP Stack trace: PHP 1. {main}() php shell code:0 php > echo 'hi'; hi I'm not seeing any bugs here. bishop