Léo*_* 준영 3 php documentation parameters return-type
如何描述PHP函数的参数和返回类型(getter/setter)?
我需要告诉我的主持人返回类型并列出每个函数的参数.我有数百个函数,所以这成为问题,因为我需要为每个修订版本执行此操作.
我现在使用以下程序
ack-grep "function " > /tmp/functions
2.在Vim:
%s/\d//g, %s/{//, %s/://gsetter或写入getter相应的行paste -d"&" /tmp/{functions,functions_param,functions_type}基本上你会在代码中添加特殊注释:
/**
* A sample function docblock
* @global string document the fact that this function uses $_myvar
* @staticvar integer $staticvar this is actually what is returned
* @param string $param1 name to declare
* @param string $param2 value of the name
* @return integer
*/
function firstFunc($param1, $param2 = 'optional') {
static $staticvar = 7;
global $_myvar;
return $staticvar;
}
Run Code Online (Sandbox Code Playgroud)
它会自动为它生成HTML文档.
基本上,这背后的想法是让程序员的生活更轻松,并允许编写内联API文档而无需花费大量时间.
有些IDE也能理解这一点,并会在您使用它时显示文档.例如,功能:
/** Retrieve the action key
* @return string
*/
function isValid($value) {
....
}
Run Code Online (Sandbox Code Playgroud)
在Zend工作室中显示:http://static.zend.com/topics/code-assist.png
特别是如果你正在使用这样的IDE(除了Zend之外还有其他人这样做),你可能会发现自然会记录每个函数和参数,因为它可以帮助你进行编码.
| 归档时间: |
|
| 查看次数: |
982 次 |
| 最近记录: |