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

Fix #2677 - use better assertion for null coalesce

This commit is contained in:
Brown 2020-01-23 14:52:35 -05:00
parent 0f659d996d
commit 0ffb833bf3
2 changed files with 11 additions and 1 deletions

View File

@ -778,7 +778,7 @@ class BinaryOpAnalyzer
if ($stmt_left_type = $statements_analyzer->node_data->getType($stmt->left)) {
$if_return_type_reconciled = AssertionReconciler::reconcile(
'!null',
'isset',
clone $stmt_left_type,
'',
$statements_analyzer,

View File

@ -1061,6 +1061,16 @@ class AnnotationTest extends TestCase
/** @param list<scalar|array|object|resource|null> $_s */
function foo(array $_s) : void { }'
],
'possiblyUndefinedObjectProperty' => [
'<?php
function consume(string $value): void {
echo $value;
}
/** @var object{value?: string} $data */
$data = json_decode("{}", false);
consume($data->value ?? "");'
],
];
}