Array constant PHP and isset suport

Hello again.

php7 have new suport with array constant but phpstorm not.

 

if(!isset(self::EVENT[$event])){
throw new \Exception('event doesn't exist');
}
$this->event = $event;

phpstorm throw the error: Expected variable
7 comments

Hi there,

It must be a bug in PhpStorm.

https://youtrack.jetbrains.com/issue/WI-30239 --> https://youtrack.jetbrains.com/issue/WI-27451 -- watch this ticket (star/vote/comment) to get notified on any progress.

0

Hello,

this is not the same thing.

PHP 7 allows declarations of array constants

const COLORS = ['red => 1, 'blue' => 2];

then, to check if a color is set

$mycolor = 'red';
if (isset(COLORS[$mycolor])) echo 'Yes';
^Expecting: variable

However PhpStorm, even setting PHP to v7, shows a syntax error "Expecting: variable" after isset.

Is there a way to configure this, or do we have to wait for a coming version?

Thanks

0

Actually, it is the same thing. Have you taken a look at WI-30239?
There's no way to configure this, we have to wait until the causing issue is fixed.

0

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

0

still not fixed??  Its been two years!!

0

Fix this please. Wery annoying bug!

0

Commenting here with "please fix asap" wouldn't help much. Please vote/comment https://youtrack.jetbrains.com/issue/WI-30239 instead.

0

Please sign in to leave a comment.