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:
parent
6e5a9bf076
commit
4d676afaef
@ -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
|
||||
) {
|
||||
|
@ -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) {}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user