- Output for 5.3.0 - 5.3.26, 5.4.0 - 5.4.16
- Parse error: syntax error, unexpected '}' in /in/DhlPv on line 39
Process exited with code 255.
<?php
class FunctionalFun
{
public function __construct()
{
$each = function(array $collection, callable $fn) {
$coll = $collection;
if (is_array($coll)) {
$length = count($coll);
} elseif (is_object($coll)) {
$length = count(get_object_vars($coll));
} else {
throw new Exception('Not iterable.');
}
$iteration = function($c, $f) {
if (!$called) {
$called = 0;
}
if ($iteration->called >= $length) {
return;
}
call_user_func($fn, $coll[$iteration->called++]);
$iteration($c, $f);
$iteration->called = $iteration->called;
}
}
}
$test = new FunctionalFun();