diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonDivArithmeticOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonDivArithmeticOpAnalyzer.php index 2352f2b09..26265117b 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonDivArithmeticOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonDivArithmeticOpAnalyzer.php @@ -295,13 +295,14 @@ class NonDivArithmeticOpAnalyzer && $right_type_part instanceof TLiteralInt && ($left instanceof PhpParser\Node\Scalar || $left instanceof PhpParser\Node\Expr\ConstFetch - || $left instanceof PhpParser\Node\Expr\ClassConstFetch) + || $left instanceof PhpParser\Node\Expr\ClassConstFetch + || $left instanceof PhpParser\Node\Expr\BinaryOp) && ($right instanceof PhpParser\Node\Scalar || $right instanceof PhpParser\Node\Expr\ConstFetch - || $right instanceof PhpParser\Node\Expr\ClassConstFetch) + || $right instanceof PhpParser\Node\Expr\ClassConstFetch + || $right instanceof PhpParser\Node\Expr\BinaryOp) ) { // time for some arithmetic! - $calculated_type = null; if ($parent instanceof PhpParser\Node\Expr\BinaryOp\Plus) { diff --git a/tests/BinaryOperationTest.php b/tests/BinaryOperationTest.php index 74e7ddd4f..cb898886f 100644 --- a/tests/BinaryOperationTest.php +++ b/tests/BinaryOperationTest.php @@ -196,6 +196,15 @@ class BinaryOperationTest extends TestCase '$f' => 'string', ], ], + 'ComplexLiteralBitwise' => [ + ' [ '