我正在尝试记录我的项目。我想记录我的控制器。在我行动之前我有:
/**
* Description: xxx
* @param parameters of my function Action
* @return views of the action
*/
此处的返回值将显示:
为什么?
由于
编辑:
标准控制器:
public function myControllerAction(Request $request) {
return $this->render('AppBundle:Default:index.html.twig');
}
答案 0 :(得分:4)
原因是@return
之后的第一个单词被视为返回数据的类型according to the official phpDocumentor docs:
@return datatype description
@return datatype1|datatype2 description
答案 1 :(得分:3)
@return注释要求数据类型作为描述之前的第一个参数。在您的情况下,您已将数据类型指定为views
,但未包含在use
语句中,因此PHP假定它属于当前命名空间,并且您获得\AppBundle\Controllers\views
。控制器的返回类型必须是Symfony\Component\HttpFoundation\Response
。所以你想要:
@return \Symfony\Component\HttpFoundation\Response description
或者如果您已有响应的use
声明:
@return Response description
在某些情况下,如果您总是返回特定的响应子类,则可能需要更具体,例如: