Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dagy's avatar
Level 1

Phpstorm flags a Typo in some Laravel 5 doc blocs on a fresh install

Hi, This is probably a silly question but anyways. I just installed L5 and required barryvdh/laravel-ide-helper. When I display the controllers files (HomeController for example) there is a yellow underline in the doc blocs that says Typo and when I let PhpStorm 'fix' it, it removes the @return void line from the comment. Is this phpstorm behaviour normal and desirable ?

How can I go about not showing that yellow line...

Thx, for any reply...

0 likes
9 replies
michaeldyrynda's avatar

I think in this instance the underline is suggesting that the return type of the method doesn't actually match the return type declared by @return in the docblock. PHP doesn't have a way to return void, so we define it in the docblock.

I don't believe there's any granularity to disabling this; PhpStorm will validate either all of the docblock, or none of it. You may be able to disable PHPDoc: Missing @return tag preference but I'm not sure that will do what you're after. The other option is to disable PHPDoc: PHPDoc comment matches function/method signature option, but then it won't validate the docblock at all.

You could always ignore it, I suppose.

1 like
dagy's avatar
Level 1

Hey deringer thanks for the reply. So would it be a bad practice disabling the docblock validation? or would it be better just to get use to the yellow underline...

Thx

michaeldyrynda's avatar

I wouldn't say it's bad practice, no. It certainly makes things easier having PhpStorm indicate whether or not your docblock is valid based on the method signature it's attached to. I keep it enabled personally.

Somebody else may be able to shed some light on it, though you could try JetBrains' support - they may have info on how to do it. If it's not possible, they're certainly the best people to contact about having something done about it :)

nolros's avatar

Always try to resolve the doc blocks as it is normally an indication of a potential error and I wouldn't disable. Initially it might seems like a pain the butt, but I cannot tell you how many times it has helped me with some debugging.

Example below. It would complain about the type injection and in the case I will get type error as Username is not uuid. Easy to miss this, but in this case phpstorm will hint that there is a type mismatch between my param and injection. I notice that many of the experienced guys on this forum go to great length to really document their docblocks and Jeff does a great job of driving it home.

   /**
     * Mutator to set the uuid of the user
     *
     * @param   UserId $uuid
     */
    protected function setUuidAttribute( Username $uuid )
    {
        $this->attributes['uuid'] = $uuid->toString();
    } 
michaeldyrynda's avatar

In that example @nolros you have no @return set in the docblock (because the method doesn't return).

If you were to set @return void in the docblock, I believe that's where PhpStorm will complain about the return.

3 likes
robgeorgeuk's avatar

Personally I just ignore this particular squawking (as Jeffery would say) as disabling the docblock validation would be more of a hindrance. Hopefully JetBrains will address the issue if enough users suggest it.

1 like
dagy's avatar
Level 1

Ok. Thank you all for your comments I decided to go with getting used to see that yellow underlining.

janderson's avatar

@dagy So, I think maybe you're seeing this, if I'm guessing correctly, on __constructor methods. Am I correct in that assumption?


    /**
     * A New instance of this controller
     * 
     * @return void
     */
public function __construct()
    {
        $this->middleware('auth');
    }   

This is sort of a known-issue with PhpStorm and DocBlocks, I think if it is a __construct method the @return statement is pointless, but a lot of people have adopted the standard, including the Laravel community. I'd like to know more about this apparent war of style and hear other folks' thoughts. It appears the PhpDoc standards support it, see number 9 here but there doesn't appear to be a known way to disable the Code Inspection warning in PhpStorm. Upvote this question

Here's my trouble with ignoring that squawking, it might cause me to artificially ignore other inspection squawking that I should be paying attention to. It is a small but distracting problem.

2 likes

Please or to participate in this conversation.