How to indicate that method is a part of interface with PHPDoc?

让人想犯罪 __ 提交于 2019-12-07 00:36:51

问题


How to indicate that method is a part of interface with PHPDoc?

For example:

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

Is there anything appropriate to replace @thisMethodIsHereBecauseItIsAPartOf("BarInterface") with?


回答1:


How to indicate that method is a part of interface with PHPDoc?

You do not need to document that, because you use implements BarInterface and a source-code documentation system normally handles these automatically.

However you can also use @inherit(doc):

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

About your @implements BarInterface on top, this is superfluous, because it's already written in the class definition. As comments count as code, and as you should not write superfluous code, I suggest you to remove it.



来源:https://stackoverflow.com/questions/15924854/how-to-indicate-that-method-is-a-part-of-interface-with-phpdoc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!