0

我总是在我的 phpdoc 块中使用冒号。例如,而不是:

/** Some comment
 *
 *@private
 * 
 *@param string $sTable The name of the table 
 *@return bool True otherwise void
 *@example className->tableExists($sTable);
 *@since date
 */

而不是上面的,我使用以下样式:

/** Some comment
 *
 * @private
 * 
 * @param   : string $sTable The name of the table 
 * @return  : bool True otherwise void
 * @example : className->tableExists($sTable);
 * @since   : date
 */

你看,我更喜欢用冒号分隔标签和描述。它更易于阅读并且具有更多风格。但我想知道这对 PHPdoc 解析 docbloc 有什么影响吗?

4

2 回答 2

2

对 PHPDocumentor 来说,它有很大的不同。测试显示如下

/**
 * Test constructor.
 * @param : string $var testvar
 *
 */

记录到: 在此处输入图像描述

在哪里

/**
 * Test constructor.
 * @param  string $var testvar
 *
 */

输出在此处输入图像描述

这样做当然有点合乎逻辑,因为它是语法错误。如果您想让 docblock 看起来不错,可以将值与空格对齐。

/** Some comment
 *
 *@private
 *
 *@param   string $sTable The name of the table
 *@return  bool|void      True otherwise void
 *@example className->tableExists($sTable);
 *@since   date
 */
于 2017-06-02T12:51:43.543 回答
0

我不确定 PHPDoc 本身,但它会对某些 IDE 产生影响。我在 PHPStorm 中试过这个,虽然@param没有@var受到影响,@return但失败了。

我会谨慎使用非标准格式。

于 2017-06-02T12:24:40.447 回答