diff --git a/src/Psalm/Checker/Statements/Expression/BinaryOpChecker.php b/src/Psalm/Checker/Statements/Expression/BinaryOpChecker.php index 6373291ec..dbc1a845d 100644 --- a/src/Psalm/Checker/Statements/Expression/BinaryOpChecker.php +++ b/src/Psalm/Checker/Statements/Expression/BinaryOpChecker.php @@ -769,6 +769,17 @@ class BinaryOpChecker )) { // fall through } + } else { + if ($statements_source && IssueBuffer::accepts( + new InvalidOperand( + 'Cannot perform a numeric operation with non-numeric types ' . $left_type_part + . ' and ' . $right_type_part, + new CodeLocation($statements_source, $parent) + ), + $statements_source->getSuppressedIssues() + )) { + // fall through + } } } } diff --git a/tests/BinaryOperationTest.php b/tests/BinaryOperationTest.php index 679e0bcfc..932b95077 100644 --- a/tests/BinaryOperationTest.php +++ b/tests/BinaryOperationTest.php @@ -23,7 +23,7 @@ class BinaryOperationTest extends TestCase 'numericAddition' => [ ' [], 'strict_mode' => true, ], + 'additionWithClassInWeakMode' => [ + ' 'InvalidOperand', + ], ]; } }