3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ReportController { protected $source; protected $data; public function __construct(array $source, \Closure $transformer, $dataObject = null) { $this->source = $source; $this->data = (isset($dataObject)) ? new stdClass() : $dataObject; var_dump('data', $this->data, (isset($dataObject)) ? new stdClass() : $dataObject); $this->transform($transformer); } public function transform(\Closure $transformer) { array_walk($this->source, $transformer, $this->data); } public function getData() { return $this->data; } } $source = [ ['type'=>'open'], ['type'=>'closed'], ['type'=>'pending'], ['type'=>'accepted'] ]; $transformer = function($ticket, $key, $data) { var_dump($key, $data); (isset($data[$ticket['type']]))? $data[$ticket['type']]++: $data[$ticket['type']]=1; }; $report = new ReportController($source, $transformer); var_dump($report->getData());
Output for git.master, git.master_jit, rfc.property-hooks
string(4) "data" NULL NULL int(0) NULL int(1) NULL int(2) NULL int(3) NULL NULL

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:
48.49 ms | 401 KiB | 8 Q