Description not displayed from inherited @return PHPDoc?
I'm finding that PHPStorm does not display the description of a @return PHPDoc that is inherited interface.
For example:
interface FooInterface {
/**
* @return array An associative array.
*/
public function fooMethod();
}
class Foo implement FooInterface {
public function fooMethod() {
// ...
}
}
Checking the quick-docs for Foo::fooMethod() will correctly indicate the return type as hinted by the interface. However, it will not display the description from the @return tag defined on the interface.
Is this by design?
Please sign in to leave a comment.
You can use {@inheritdoc} but this is unfortunately not working properly at this moment: https://youtrack.jetbrains.com/issue/WI-23586
Hi!
I've just faced the same issue as Courtney and for me the issue you have linked seems unrelated.
The issue here is that - sticking to the example of Courtney - while PHPStorm (at least partly) uses the parent (or interface) PHPDoc for type hinting, it does not show the description of the return value itself.
I'm attaching 3 screenshots.
1st: the cursor is on "fooMethod" in FooInterface. PHPDoc shows properly the generic description, the parameter description and the return description and type.
2nd: the cursor is on "fooMethod" in the Foo class. PHPDoc shows properly the generic description and the parameter description. However the return has no description at all. The expected behaviour is to show the same description! Also the return type is determined to be "array|void" instead of "array" explicitly defined on the interface PHPDoc, but this may not be an issue, as actually the implementation has a void return (i.e. no return).
3rd: the cursor is on the call to the "fooMethod" on an instance of the Foo class. The documentation window is the same as in the 2nd case.
As far as I can see this is not related to the linked issue. That ticket explains that if the type of a variable or parameter (and I assume the same for a return value) can be determined in a local context, than PHPStorm does not try to use the parent PHPDoc to determine it. That is not an issue in this example: the type of the return is clearly shows the possibility to be an array indicating that it is in fact inherited from the interface.
Can you please explain, if you still think these two are connected, or let me know if we should open an issue for this topic in YouTrack?
Thanks!
Actually it is the same for @throws. Not inherited :(
Could be https://youtrack.jetbrains.com/issue/WI-18907 (based on https://youtrack.jetbrains.com/issue/WI-45040 that is marked as duplicate .. although that duplicate does not use @inheritDoc tag)
Yep, https://youtrack.jetbrains.com/issue/WI-45040 is the one for this issue. Although I don't think that is really a duplicate of WI-18907... more like related.
I'll wait for WI-18907 anyway and see if that would really resolve this one. Thanks!