PhpStorm " isset " bug!

PhpStorm for PHP 7 (PHP language level set to 7)

isset() doesn't recognize properly the new Array Constants.

const COLORS = [ 'RED' => 1, 'GREEN' => 2 ];
$mine = 'GREEN';

if ( isset( COLORS[ $mine ] )) echo "Yes.";
^Expected: variable

This is annoying since that gives an error, not a warning.

Thanks.

 

4 comments
Comment actions Permalink

Reading further on the issue, https://youtrack.jetbrains.com/issue/WI-27451 is actually more generic, and harder to parse than a "simple" const variable.

Is it possible to fix the "const" case aside and ahead of the general case? 

That's easier IMO.

"const" is a variable declaration without a "$".
PhpStorm has to check its list of "const"s to check if the name has been declared, and allow that in "isset()" or "??".

 

0
Comment actions Permalink

come on!!! It's a very annoying mistake

0
Comment actions Permalink

This annoying mistake also annoys me.

0

Please sign in to leave a comment.