Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

phpdoc

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?

like image 607
Mateusz Charytoniuk Avatar asked Apr 10 '13 11:04

Mateusz Charytoniuk


1 Answers

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.

like image 169
M8R-1jmw5r Avatar answered Oct 27 '22 08:10

M8R-1jmw5r