PhpStorm 2022.3 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. See Operator Precedence (php.net) for details.

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. Position 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: 16 May 2022