3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php interface NodeInterface { public function addNode(Node $node); public function isLeaf(); public function isNode(); public function getKey(); public function setKey($key); public function getValue(); public function setValue($value); public function getUid(); public function uid(); public function key(); public function value(); } class ArrayComposition implements NodeInterface { protected $uid; protected $nodes; protected $value; public function __construct($value = null, $key = null) { $this->uid = rand(0, 9) . md5(rand(10, 99) . time() . rand(100, 999)) . rand(1000, 9999); $this->value->key = $key; $this->value->val = $value; } public function addNode(Node $node) { $this->nodes[] = $node; return $this; } public function isLeaf() { return count($this->nodes) == 0; } public function isNode() { return count($this->nodes) > 0; } public function getKey() { return $this->value->key; } public function key() { return $this->value->key; } public function setKey($key = null) { $this->value->key = $key; return $this; } public function getValue() { return $this->value->val; } public function value() { return $this->value->val; } public function setValue($value = null) { $this->value->val = $value; return $this; } public function getUid() { return $this->uid; } public function uid() { return $this->uid; } }
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Output for 5.0.0 - 5.2.17
Fatal error: Declaration of ArrayComposition::setKey() must be compatible with that of NodeInterface::setKey() in /in/9Xq4O on line 18
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/9Xq4O on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/9Xq4O on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/9Xq4O on line 3
Process exited with code 255.