如何为slim框架路由/回调生成phpdoc

时间:2013-08-19 22:31:19

标签: php phpdoc slim

我正在努力弄清楚如何构建我的代码,以便phpDocumentor将使用代码块。

/**
 * GET -- Book, either filtered by id or a full list.
 *
 * @param   SlimApplication     $app    The application object instance.
 * @param   integer             $id The id of the book
 */
$callbackFunction = function($id) use ($app)
{
    //some functionality here.
};
$app->get('/books(/:id)', $callbackFunction );

我可能应该继续使用内联use语句,以便我可以使用$app

有人有任何建议吗?

1 个答案:

答案 0 :(得分:1)

phpDocumentor没有特殊的语法来记录这样的匿名函数。如果你想要记录闭包本身,你需要将它实际定义为第一类函数,然后你可以将其记录下来。

如果知道闭包存在并且文档读者需要知道它的细节,那么大概是重要的是成为一流的函数?然后,作为一个闭包,它实际上并没有在代码的API上提供......所以它甚至需要记录下来吗?