mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix checks for possibly null right part of binary op
This commit is contained in:
parent
76a3fbbdf0
commit
7d747be5d5
@ -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,
|
||||
|
@ -217,6 +217,11 @@ class BinaryOperationTest extends TestCase
|
||||
$a++;',
|
||||
'error_message' => 'InvalidOperand',
|
||||
],
|
||||
'possiblyDivByZero' => [
|
||||
'<?php
|
||||
$a = 5 / (rand(0, 1) ? 2 : null);',
|
||||
'error_message' => 'PossiblyNullOperand',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user