3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class myClass { protected $value; function setValue($value) : self { $this->value = $value; } function doubleValue() : self { $this->value*=2; } function getValue() : self { return $this->value; } } $calculator = new myClass(); $returnValue = $calculator->setValue(3) ->doubleValue() ->getValue(); echo $returnValue;
based on iIZl9
Output for 7.0.0 - 7.3.0rc3
Fatal error: Uncaught TypeError: Return value of myClass::setValue() must be an instance of myClass, none returned in /in/7ha2r:10 Stack trace: #0 /in/7ha2r(25): myClass->setValue(3) #1 {main} thrown in /in/7ha2r on line 10
Process exited with code 255.
Output for 5.5.0 - 5.6.23
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/7ha2r on line 7
Process exited with code 255.