3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait toArray { public function toArray() { return get_object_vars($this); } public function fromArray(array $properties) { foreach ($properties as $key => $value) { if (method_exists($this, 'set' . ucfirst($key))) { $this->{'set' . ucfirst($key)}($value); } } } } interface BazInterface { } class Bazz implements BazInterface { } interface FooInterface { public function add(BazInterface $baz); public function toArray(); public function fromArray(array $properties); } class Foo implements FooInterface { use toArray; private $bar; private $baz; public function add() { } public function setBar($bar) { $this->bar = $bar; return $this; } public function setBaz($baz) { $this->baz = $baz; return $this; } } $foo = new Foo; $foo->fromArray(['bar' => 'boo', 'baz' => 'test']); $fooArray = $foo->toArray(); var_export($fooArray);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Declaration of Foo::add() must be compatible with FooInterface::add(BazInterface $baz) in /in/sUW4U on line 44
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:
44.64 ms | 401 KiB | 8 Q