PhpStorm 2024.1 Help

Code Inspection: Expression without clarifying parentheses

Reports potentially ambiguous expressions and proposes enclosing them in clarifying parentheses.

By using parentheses, you can increase code readability by grouping operations explicitly rather than relying on the implicit operator precedence and associativity. For more information, refer to Operator Precedence (php.net).

In the following example, several potential ambiguities are eliminated by introducing parentheses inside expressions.

$a = 1 - 2 + 3; $b = true && false || true && false && true; $c = true ? $a == 2 : $a + 1 == 3 ? $a : !$b;
$a = (1 - 2) + 3; $b = (true && false) || (true && false && true); $c = true ? ($a == 2) : ($a + 1 == 3 ? $a : !$b);

Suppress an inspection in the editor

  1. Place the caret at the highlighted line and press Alt+Enter or click the Intention action icon.

  2. Click the arrow next to the inspection you want to suppress and select the necessary suppress action.

Last modified: 11 February 2024