Open rvock opened 4 months ago
<?php declare(strict_types = 1); var_dump(!(12 % 12)); var_dump(!12 % 12);
Output:
bool(true) int(0)
Here I get an error, that the first parentheses are useless. But that's not the case, because the output is different, if I remove them.
The ! operator has a higher precedence than the module % operator: https://www.php.net/manual/en/language.operators.precedence.php
!
%
See also #1674 (bit-shift operator) & #1672 (string concat & ternary operator)
This sniff doesn't seem to take context into account? 3 * (2 + 1) doesn't trigger UselessParentheses though ¯\_(ツ)_/¯
3 * (2 + 1)
Output:
Here I get an error, that the first parentheses are useless. But that's not the case, because the output is different, if I remove them.
The
!
operator has a higher precedence than the module%
operator: https://www.php.net/manual/en/language.operators.precedence.php