I cant find any documentation on the Closure type in PHPDoc. So my question is how do I define the parameter of the parameters sent to the closure and its return value ?
use indirect technique
Your code:
/**
* @param MyCustomClass $cls
* @param MyFancyClosure $callback
*
* @return MyOtherCustomClass
*/
function changer($cls, $callback){
return $callback($cls, 2, "a string");
}
changer($aCustomeClass, function($cls, $int, $string){
return new MyOtherCustomClass($cls, $int, $string);
})
and than provide a dummy code somewhere:
/**
* this is awesome closure!
*/
class MyFancyClosure {
/**
* @param MyCustomClass $cls
* @param int $int
* @param string $str
*
* @return MyOtherCustomClass
*/
public function __invoke($cls, $int, $str) {}
}
note: