3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Base { protected $foo = null; final public function __construct(Granny $init = null) { return $this->init($init); } protected function init(Granny $dependency = null) { throw new Exception("Don't run me from Base, foo!"); } } class Granny { protected $name = null; protected $age = null; public function __construct(array $vals = null) { foreach($vals as $name => $val) { $name = 'set'.ucfirst($name); if (method_exists($this, $name)) { $this->{$name}($val); } } return $this; } //basic gettter && setters public function getAge() { return $this->age; } public function setAge($age = null) { $this->age = $age === null ? null : (int) $age; return $this; } } class Dad extends Granny { //Dad's secret private $likesMom = null; public function getLikesMom() { return $this->likesMom; } public function setLikesMom($bool = null) { $this->likesMom = $bool === null ? null : !!$bool; return $this; } } class Ball extends Base { protected function init(Dad $dependency = null) { $this->foo = $dependency; return $this; } } var_dump(new Ball(new Dad()));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Declaration of Ball::init(?Dad $dependency = null) must be compatible with Base::init(?Granny $dependency = null) in /in/Oh9GQ on line 59
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.17 ms | 401 KiB | 8 Q