Question

I use PHPDoc to enhance PhpStorm hinting. Normally, a method would have a PHPDoc like this:

/**
 * @param array|callable $a
 * @param int $b
 * @return mixed
 */
public function x($a, $b) {
    // …
}

I need to describe the same inside a @method tag. PhpStorm (or PHPDoc) doesn't like the vertical bar. If I take it out with one of the types – everything looks good.

/**
 * @method mixed x(array|callable $a, int $b)
 */
class A {
    // …
}

First, is this a legal syntax for @method tag and the problem is with PhpStorm? If not, is there a way to describe arguments in full inside @method? Thanks!

Was it helpful?

Solution

It's not yet supported, just like specifying arrays of types using the bracket syntax.

http://youtrack.jetbrains.com/issue/WI-22571

I'm not aware of any workaround for this, other than using mixed (which isn't really a workaround).

I'd suggest to comment and vote in the tracker.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top