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

Fix #985 - strip null from object type where possible

This commit is contained in:
Matt Brown 2018-09-07 11:01:10 -04:00
parent 6e5a9bf076
commit 4d676afaef
2 changed files with 11 additions and 0 deletions

View File

@ -448,6 +448,7 @@ class Reconciler
foreach ($existing_var_atomic_types as $type_key => $type) {
if ($type instanceof TNamedObject
|| $type instanceof TObject
|| $type instanceof TResource
|| $type instanceof TCallable
) {

View File

@ -1019,6 +1019,16 @@ class TypeReconciliationTest extends TestCase
echo substr($_SERVER["abc"], 1, 2);
}',
],
'notObject' => [
'<?php
function f(): ?object {
return rand(0,1) ? new stdClass : null;
}
$data = f();
if (!$data) {}
if ($data) {}',
],
];
}