run code in 150+ php & hhvm versions
Bugs & Features
<?php class StaticA { public function setEmail($redirect) { $this->email = $redirect; } static function dosomething(){ $obj = new static; $obj->email = "e@01art.de"; $obj->classInfo(); } function classInfo(){ echo get_class(new static). "\n"; echo $this->email. "\n"; } } class StaticB extends StaticA { function test(){ //echo get_class(new self). "\n"; parent::classInfo(); } function doit(){ self::dosomething(); echo $this->email. "\n"; } function dosomething(){ echo "this is overwritten now". $this->email. "\n"; } } $object = new StaticB(); $object->setEmail("erno@01art.de"); $object->doit();
Output for 5.3.0 - 5.6.21, 7.0.0 - 7.1.0RC3
Fatal error: Cannot make static method StaticA::dosomething() non static in class StaticB in /in/jBZbr on line 41
Process exited with code 255.
Output for hhvm-3.12.0
Fatal error: Cannot change static method StaticA::dosomething() to non-static in StaticB in /in/jBZbr on line 24
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.