Overwritting phpdoc

HI,

I'm new at phpstorm and still trying to figure out some parts of it. Coming from notepad++ and ST now I'm having doubts about PhpDoc.

Using package Monolog ("monolog/monolog":"1.*") I'm overwritting \Monolog\Logger, method addRecord so $message can be either a string, a json or an ArraybleInterface object. The first thing I noticed was phpstorm is duplicating my @params attribute

I tried something different: define @method attribute at class level to point out the changes but phpstorm seems to have problems recognizing "string" (appending class' namespace) and I loose method text description

Class description

/**
* Class Logger
*
* @method bool info(array|string $message, array $context = array())
* @package Core\Log
*/
class Logger extends \Monolog\Logger

Using [Ctrl]+[P] to display attributes (

No method description

So, I know I should create a method like `mixedInfo($message, $context)` that defines all kinds of parameters in its phpdoc, but this isn't java right?. Or am I being lazy and shouldn't be programming this way and phpstorm constraints me from being evil?

4 comments

Hi there,

>The first thing I noticed was phpstorm is duplicating my @params attribute

Must be some index/cache issue. I'm very rarely seeing it and cannot say for sure why it's happening.

 

>define @method attribute at class level to point out the changes but phpstorm seems to have problems recognizing "string" (appending class' namespace)

It's a regression in 2018.1 -- should be fixed for 2018.1.1 or 2018.1.2 -- https://youtrack.jetbrains.com/issue/WI-12451

 

>and I loose method text description

>No method description

But you have no method description there in @method declaration...

If you were overriding the info() from a parent class this way .. you need to re-add description as well.

 

0

Thank you Andriy

For now I will extract methods from parent class and overwrite phpdoc. @method option is not my favorite and if I manage to use refactoring for this it shouldn't be too much of a pain

0

>>The first thing I noticed was phpstorm is duplicating my @params attribute

>Must be some index/cache issue. I'm very rarely seeing it and cannot say for sure why it's happening.

I have the same issue. Invalidating cache and re-indexing doesn't help:

If a method is overridden in a child Class, the method Documentation viewer shows the @param tags from both the Parent and the Child methods.

Is this a bug? Should I open a ticket for that?

0

Please sign in to leave a comment.