3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class myClass { public function add() : self { /** code **/ return "adad"; } } class myExtendedClass extends myClass { public function add() : parent { return "adad"; } } $instance = new myExtendedClass(); $instance->add();
based on O2HdE
Output for 7.0.0 - 7.3.0rc3
Fatal error: Uncaught TypeError: Return value of myExtendedClass::add() must be an instance of myClass, string returned in /in/sCCpP:16 Stack trace: #0 /in/sCCpP(21): myExtendedClass->add() #1 {main} thrown in /in/sCCpP on line 16
Process exited with code 255.
Output for 5.5.0 - 5.6.23
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/sCCpP on line 5
Process exited with code 255.