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.

 

1
4 comments

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
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

This annoying mistake also annoys me.

0

Please sign in to leave a comment.