I have a class, which generate a data object and pass it to given callable variable
<?php
class Foo {
public function bar(callable $closure)
{
$data = $this->generateData();
call_user_func_array($closure, compact($data));
}
}
// example usage
$baz = new Foo()
$baz->bar(function($data) {
var_dump($data); // I want to test $data type inside this closure
});
How can I test $data dataType pass to the anonymous function?
Aucun commentaire:
Enregistrer un commentaire