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.
Please sign in to leave a comment.
It's https://youtrack.jetbrains.com/issue/WI-30239, which is caused by https://youtrack.jetbrains.com/issue/WI-27451.
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 "??".
come on!!! It's a very annoying mistake
This annoying mistake also annoys me.