8

如何表明该方法是 PHPDoc 接口的一部分?

例如:

/**
 * @implements BarInterface
 */
class Foo implements BarInterface
{
    /**
     * @thisMethodIsHereBecauseItIsAPartOf("BarInterface")
     */
    public function doBar()
    {
    }
}

有什么合适的可以代替@thisMethodIsHereBecauseItIsAPartOf("BarInterface")吗?

4

1 回答 1

13

如何表明该方法是 PHPDoc 接口的一部分?

您不需要记录这些,因为您使用implements BarInterface源代码文档系统通常会自动处理这些。

但是,您也可以使用@inherit(doc)

/**
 * @implements BarInterface
 */
class Foo implements BarInterface
{
    /**
     * @inherit
     * {@inherit}
     * {@inheritdoc}
     */
    public function doBar()
    {
    }
}

关于你@implements BarInterface在上面,这是多余的,因为它已经写在类定义中。由于注释算作代码,并且您不应该编写多余的代码,因此我建议您将其删除。

于 2013-04-10T11:56:39.420 回答