3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a; public function __construct($a) { $this->a = (int) $a; } public static function maxA(array $fooList) { return array_reduce($fooList, function(Foo $carry, Foo $item) { return ($carry == null || $item->a > $carry->a) ? $item : $carry; }); } } $fooList = [ new Foo(1), new Foo(5), new Foo(2), ]; var_dump(Foo::maxA($fooList));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: Foo::{closure}(): Argument #1 ($carry) must be of type Foo, null given in /in/ZflBM:14 Stack trace: #0 [internal function]: Foo::{closure}(NULL, Object(Foo)) #1 /in/ZflBM(14): array_reduce(Array, Object(Closure)) #2 /in/ZflBM(26): Foo::maxA(Array) #3 {main} thrown in /in/ZflBM on line 14
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:
75.55 ms | 401 KiB | 8 Q