Non riesco a trovare alcuna documentazione sul tipo di chiusura in PHPDoc. Quindi la mia domanda è: come definire il parametro dei parametri inviati alla chiusura e il suo valore di ritorno?Sintassi di chiusura in PHPDoc
Esempio:
Come faccio a descrivere che il "callback" otterrà un "myCustomClass", un numero e una stringa, e restituire un "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);
})
O se è possibile?
Non penso che ci sia un modo ragionevole per descriverlo nelle annotazioni. Anche nei manuali PHP sono indicati come "callable" nelle descrizioni degli argomenti. –
Questo è ciò che temono, ma sarebbe bello se fosse possibile. –
"Approfondimento sulla definizione della chiusura": https://github.com/phpDocumentor/phpDocumentor2/issues/830 –