- var_dump: documentation ( source)
<?php
function decorate(callable $fn, callable $decorator)
{
return function() use ($fn, $decorator) {
$d = $decorator();
$gen = $d();
var_dump($gen->current());
};
}
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();