Flip Comparison Operators

#19 Flip Comparison Operators

code, refactoring, intention actions

To swap the values on either side of a comparison operator with each other, place the cursor on the operator and press Alt+Enter to invoke the intention actions menu then select Flip 'X' .

With certain operators changing the order of the arguments can change the semantics of the condition, as such PhpStorm will display the (change semantics) warning in the menu when this is the case. Make sure your conditions still make sense when you see this warning.

Related Tips

Blog Comments powered by Disqus.