undefined class bool in phpdoc

I'm running the latest version of PHPStorm (111.217) and am getting weird errors in my PHPDoc. I have a function:

public function Login($strUsername, $strPassword)
          {
               return true;
     }

And when I generate a PHPDoc block from that, it gives me:

          /**
           * @param $strUsername
           * @param $strPassword
           * @return bool
           */
          public function Login($strUsername, $strPassword)
          {
               return true;
}


But then PHPStorm highlights "bool" and flags it with the error "undefined class bool"
I can change this to boolean and it will go away, but why is PHPStorm using a class name it doesn't like?
0
4 comments

Hi Ryan,

It's a bug in 111.217 build -- already fixed. Please wait for next EAP .. or use previous EAP build if it's critical for you.

0

The bug is back....

/** @var $redis the redis database used */

highlights "the" with error: "undefined class the"

It sees 'the' in the comment as a classname which it obviously can't find. Change it to:

/** @var $redis /the redis database used */

surpresses the error, but it will show up in the documentation which is unwanted of course...

0
The bug is back....

Doubt so.

You are using wrong syntax -- there is no type anywhere in your PHPDoc and therefore it's basically useless in such form (as it misses the main reason of such comment -- provide typehint).

The correct one is

/** @var TYPE $varname optional-description-here */


PhpStorm also supports other 3 variations:

/** @var $varname TYPE optional-description-here */
/* @var TYPE $varname */
/* @var $varname TYPE */

The last 2 are ordinary PHP comments -- used (at least in the past) by Zend Studio and NetBeans (AFAIK). The first 2 are actual PHPDoc comments (notice the 2 stars instead of 1).

In your code example you are using variation #2 (#1 in last code block) -- IDE "correctly" pickups "the" as TYPE.

0

you are absolutely right! Sorry for this mistake. I assumed the code generated by phpStorm would have the type (or at least an indication it should be in there) in DocBlock. Thanks for pointing this out and sorry for wasting your time!

0

Please sign in to leave a comment.