我无法在PHPDoc中找到关于Closure类型的任何文档.所以我的问题是如何定义发送到闭包的参数的参数及其返回值?
例:
我如何描述"回调"将获得"MyCustomClass",数字和字符串,并返回"MyOtherCustomClass"?
/**
* @param MyCustomClass $cls
* @param Closure $callback this isn't really explaining what this is
*
* @return MyOtherCustomClass
*/
function changer($cls, $callback){
return $callback($cls, 2, "a string");
}
changer($aCustomeClass, function($cls, $int, $string){
return new MyOtherCustomClass($cls, $int, $string);
})
Run Code Online (Sandbox Code Playgroud)
或者如果它可能的话?