Inspection of single equal vs double equal in conditional

Looking for a way to set PhpStorm the show an error in this case.

if( $a = $b ) {
     doSomething();
}

I would like be alerted somehow that I am assigning when I whould be comparing with if( $a == $b ).

5 comments
Comment actions Permalink

Hi there,

Settings (Preferences on Mac) | Editor | Inspections | PHP | Probable bugs | Assignment in conditions

0
Comment actions Permalink

Perfect!

Thank you so much.

0
Comment actions Permalink

It seems that the inspection does not work when you have another condition present:

if ($a >1 || $b = 2) { ... }

will not be detected...

0
Comment actions Permalink

Thanks for the link. Couldn't find anything searching...

0

Please sign in to leave a comment.