3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ReportController { protected $source; protected $data; public function __construct(array $source, $dataObject = null, \Closure $transformer = null) { $this->source = $source; $this->data = ($dataObject) ? [] : $dataObject; $this->transform($transformer); } public function transform(\Closure $transformer = null) { array_walk($this->source, $transformer); } public function getData() { return $this->data; } } $source = [ ['type'=>'open'], ['type'=>'closed'], ['type'=>'pending'], ['type'=>'accepted'] ]; $transformer = function($ticket, $key) { (isset($this->data[$ticket['type']]))? $this->data[$ticket['type']]++: $this->data[$ticket['type']]=1; }; $report = new ReportController($source); var_dump($report->getData());
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: array_walk(): Argument #2 ($callback) must be a valid callback, no array or string given in /in/lAhIs:18 Stack trace: #0 /in/lAhIs(18): array_walk(Array, NULL) #1 /in/lAhIs(13): ReportController->transform(NULL) #2 /in/lAhIs(37): ReportController->__construct(Array) #3 {main} thrown in /in/lAhIs on line 18
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:
49.88 ms | 401 KiB | 8 Q