1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #676 - bitwise operators didn’t have int return type

This commit is contained in:
Matt Brown 2018-04-16 16:36:06 -04:00
parent 3cc549384f
commit 55153f9542
2 changed files with 21 additions and 1 deletions

View File

@ -401,7 +401,12 @@ class BinaryOpChecker
$stmt instanceof PhpParser\Node\Expr\BinaryOp\Minus ||
$stmt instanceof PhpParser\Node\Expr\BinaryOp\Mod ||
$stmt instanceof PhpParser\Node\Expr\BinaryOp\Mul ||
$stmt instanceof PhpParser\Node\Expr\BinaryOp\Pow
$stmt instanceof PhpParser\Node\Expr\BinaryOp\Pow ||
$stmt instanceof PhpParser\Node\Expr\BinaryOp\BitwiseOr ||
$stmt instanceof PhpParser\Node\Expr\BinaryOp\BitwiseXor ||
$stmt instanceof PhpParser\Node\Expr\BinaryOp\BitwiseAnd ||
$stmt instanceof PhpParser\Node\Expr\BinaryOp\ShiftLeft ||
$stmt instanceof PhpParser\Node\Expr\BinaryOp\ShiftRight
) {
self::analyzeNonDivArithmenticOp(
$statements_checker,

View File

@ -44,6 +44,21 @@ class BinaryOperationTest extends TestCase
'assertions' => [],
'error_levels' => ['PossiblyFalseOperand'],
],
'bitwiseoperations' => [
'<?php
$a = 4 & 5;
$b = 2 | 3;
$c = 4 ^ 3;
$d = 1 << 2;
$e = 15 >> 2;',
'assertions' => [
'$a' => 'int',
'$b' => 'int',
'$c' => 'int',
'$d' => 'int',
'$e' => 'int',
],
],
];
}