Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPDoc using @method to declare magic method and @see to pick documentation from another method

What I want is that when I declare a magic method with @method PHPDoc, can i use @see so that the magic method has the same PHPDoc as the method pointed via @see

Here is the code of what I have tried. But IDE did not recognize it. I am using Netbeans 7.3.1.

/**
* @method string my_method() @see _my_method()
*/
class Foo {
  public __call($name, $args) {
     $name = "_".$name;
     $this->$name($args);
  }

  /**
  * @return String
  */
  protected _my_method() {
     return "bar";
  }
}
like image 457
Rishabh Avatar asked Jan 24 '26 01:01

Rishabh


1 Answers

The exact parsing will depend on which IDE you're using, but the PHPDocumentor documentation for @see shows a couple of differences from your usage:

  • The @see tag is on its own line, not appended to the line before. @link has a separate "inline" syntax if you want to include a cross-reference inside a description ({@link http://example.com/my/bar}).
  • The "target" should be a fully qualified element name, not just the local method name, e.g. @see Foo::_my_method()

There is also a draft PSR to standardise the behaviour, with similar requirements.

like image 196
IMSoP Avatar answered Jan 26 '26 18:01

IMSoP