Nested Ternary Operator

If I create a scratch file in PHPStorm 2019.0.3 which contains:

```

<?php
$var1 = true;
$var2 = false;
$var3 = true;
$var4 = false;
$var5 = true;
$value = $var1 ? $var2 : $var3 ? $var4 : $var5;

```

Then I run the "Nested ternary operator usage" inspection by name on this specific scratch file, it doesn't find anything.

I tried this in a scratch file to test this because I was certain I had usages in a particular project which didn't come up in the results. Is there a setting I need to enable to get this to work?

0
4 comments

Please check your project PHP Language level in "Languages & Frameworks | PHP", this specific inspection is working for PHP 7.4 projects only.

1

Scratch files can't be inspected via Code > Inspect Code or "Run inspection by name". 

Try running "Run inspection by name" + "Nested ternary operator usage" on your project - it would show you results if you have any usages to report. I've just checked that and it worked.

0

Hi Dmitry, I put the same code in my project and it still did not find it. Any idea why?

0

Thank you Vasiliy, that was it.  Now it recognizes the occurrences I was expecting to come up.

0

Please sign in to leave a comment.