PHPStorm warning for unused variable, but not if set to null

Answered

I noticed in PHPStorm that if a variable is declared and set to null, there is no warning that it is unused. 

For any other value, the warning is there. 

I would expect the warning to show for a variable set to null, just as for the string variable.

What is the logic here? 

0
1 comment

Hi there,

Check that inspection settings: "Settings/Preferences | Editor | Inspections | PHP | Unused | Unused local variable" -- it will have "Don't report assignment to 'null'" option enabled.

It's done like that by default because of https://youtrack.jetbrains.com/issue/WI-6415

Other than that -- watch https://youtrack.jetbrains.com/issue/WI-39131 ticket (star/vote/comment) to get notified on any progress.

1

Please sign in to leave a comment.