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) { 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: ReportController::transform(): Argument #1 ($transformer) must be of type Closure, null given, called in /in/KlVg5 on line 13 and defined in /in/KlVg5:16 Stack trace: #0 /in/KlVg5(13): ReportController->transform(NULL) #1 /in/KlVg5(37): ReportController->__construct(Array) #2 {main} thrown in /in/KlVg5 on line 16
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:
63.43 ms | 401 KiB | 8 Q