Phpinspectionsea: Redudant @var/@type/@param

Created on 30 Oct 2019  路  9Comments  路  Source: kalessil/phpinspectionsea

Description (screenshot):

PS supports "redundant suppression". I think a good idea supports "redundant @var" and similar. For instance, if a method always returns User|null, so @var User|null is redundant.

Example

function getUser(): ?User { ... }

/** @var User|null $user redundant! */
$user = getUser();

/** @var User $user allowed */
$user = getUser();
3rd party

Most helpful comment

FYI, Issue was implemented in PhpStorm 2020.1

All 9 comments

I wrote simple plugin which contains this feature https://github.com/funivan/phpclean#redundantdoccommenttag
You can test it already.

It can be simply implemented in this repository if needed.

I wrote simple plugin which contains this feature https://github.com/funivan/phpclean#redundantdoccommenttag
You can test it already.

It can be simply implemented in this repository if needed.

Would it be possible to implement the same thing but for @var related to variables in code? IIRC, your inspection flag only the doc blocks related to functions, methods or attributes.

@orklah So you write var for the variable and want to remove it?

Yeah. It happens a lot, you write a @var because the IDE doesn't resolve a type, but later you add a type somewhere else(in a return hint for example) and the @var become useless.

For example, I used your VirtualTypeCheck inspection to remove a lot of @var that were redundant in my code.

@funivan, check your link - looks pretty much the same pattern. Can you incorporate this into your plugin, please?

If yes, feel free to close this ticket.

Sorry for the delay.
I have created an issue in the PhpClean repository.

No worries, thank you!

FYI, Issue was implemented in PhpStorm 2020.1

Was this page helpful?
0 / 5 - 0 ratings