So, i’m working with Silex microframework and i’m curious about the correct PHPDoc way to document a closure.
require_once __DIR__.'/silex.phar';
$app = new Silex\Application();
$app->get('/hello/{name}', function($name) use($app) {
return 'Hello '.$app->escape($name);
});
$app->run();
How do i document the GET closure?
What is it that you are wanting to say to the reader of your document with regard to that closure? Do you want to highlight that it exists, or create a @uses<–>@usedby documentation link to the Silex\Application->escape() method that your closure is using?
I’m not aware that any PHPDoc syntax exists to document a closure (yet), but given that it can’t actually be used by a consumer in an API context, I’m not sure there’s a use case to document it… well, aside from providing details to a code-reading doc reader. If the latter is the case, I’d probably use an @internal tag to write whatever notes about the closure that I wanted the reader to be aware of. Further, given that I see no “documentable elements” in that code snippet, you’d have to put that @internal tag in the file-level docblock.