20

Is it possible to link to another method/class/property/etc. inside my project inline inside the @deprecated tag? Like this:

/**
 * Method description
 * @deprecated 1.0 Reason for deprecation, use {@link newMethod()} instead!
 * @param string $str
 * @param string|null $str2
 * @return bool
*/
public function method($str, $str2) {
    // TODO: Code...
}

...

?

Top-Master
  • 7,611
  • 5
  • 39
  • 71
armin
  • 353
  • 1
  • 3
  • 8
  • 1
    you can use the [@see](https://www.phpdoc.org/docs/latest/references/phpdoc/tags/see.html) tag – Dragos Dec 23 '16 at 14:37

1 Answers1

28

According to PHPdoc.org, you could use the @see tag for that.

 /**
 * @see http://example.com/my/bar Documentation of Foo.
 * @see MyClass::$items           For the property whose items are counted.
 * @see MyClass::setItems()       To set the items for this collection.
 *
 * @return integer Indicates the number of items.
 */
function count()
{
     <...>
}

Also, PHPdoc.org recommends to use @see in case of a @deprecated method:

It is RECOMMENDED (but not required) to provide an additional description stating why the associated element is deprecated. If it is superceded by another method it is RECOMMENDED to add a @see tag in the same PHPDoc pointing to the new element.

But @see is not always required, for example "Link to another method in @param tag's description?"

Top-Master
  • 7,611
  • 5
  • 39
  • 71
Dragos
  • 1,824
  • 16
  • 19