run code in 150+ php & hhvm versions
Bugs & Features
<?php class EventDispatcher{function r($e, ListenerInterface $l){$this->e[$e][] = $l;} function d($e){foreach ($this->e[$e] as $l){$l->o();}}} class ListenerInterface{function o();} class MyListener{function o(echo '*';)} $l = new MyListener(); $e = new EventDispatcher(); $e->r('1', $l); $e->r('1', $l); $e->r('2', $l); $e->d();
Output for 7.0.0 - 7.1.0RC4
Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting variable (T_VARIABLE) in /in/npUX8 on line 6
Process exited with code 255.
Output for 5.3.0 - 5.6.21, hhvm-3.10.0 - 3.12.0
Fatal error: Non-abstract method ListenerInterface::o() must contain body in /in/npUX8 on line 4
Process exited with code 255.