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

Fix checks for possibly null right part of binary op

This commit is contained in:
Matthew Brown 2018-07-03 19:52:40 -04:00
parent 76a3fbbdf0
commit 7d747be5d5
2 changed files with 6 additions and 1 deletions

View File

@ -651,7 +651,7 @@ class BinaryOpChecker
return;
}
if ($right_type->isNullable() && $right_type->ignore_falsable_issues) {
if ($right_type->isNullable() && !$right_type->ignore_nullable_issues) {
if ($statements_source && IssueBuffer::accepts(
new PossiblyNullOperand(
'Right operand cannot be nullable, got ' . $right_type,

View File

@ -217,6 +217,11 @@ class BinaryOperationTest extends TestCase
$a++;',
'error_message' => 'InvalidOperand',
],
'possiblyDivByZero' => [
'<?php
$a = 5 / (rand(0, 1) ? 2 : null);',
'error_message' => 'PossiblyNullOperand',
],
];
}
}