- Output for 5.3.0 - 5.3.20, 5.4.0 - 5.4.10
- Parse error: syntax error, unexpected '{' in /in/ANtF0 on line 9
Process exited with code 255.
<?php
function decorate(callable $fn, callable $decorator)
{
return function() use ($fn, $decorator) {
$d = $decorator();
$gen = $d();
if (is_array($gen->current()) {
$arguments = $gen->current();
} else {
$arguments = func_get_args();
}
$gen->send(call_user_func_array($fn, $arguments);
};
}
function foo()
{
throw new Exception("Error!");
}
function catch_all_exceptions()
{
return function() {
try {
(yield ["foo" => "bar"]);
} catch (\Exception $e) {
echo "Caught Exception: $e\n";
}
};
}
$foo = decorate("foo", "catch_all_exceptions");
$foo();