mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix reconciliation of mixed to Traversable
This commit is contained in:
parent
1b983babd0
commit
b8bdaea09a
@ -1298,7 +1298,7 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
|
||||
$existing_var_atomic_types = $existing_var_type->getTypes();
|
||||
|
||||
if ($existing_var_type->hasMixed() || $existing_var_type->hasTemplate()) {
|
||||
return new Type\Union([new Type\Atomic\TIterable]);
|
||||
return new Type\Union([new Type\Atomic\TNamedObject('Traversable')]);
|
||||
}
|
||||
|
||||
$traversable_types = [];
|
||||
|
@ -1458,6 +1458,16 @@ class TypeReconciliationTest extends TestCase
|
||||
if (isset($e->bar)) {}
|
||||
}',
|
||||
],
|
||||
'assertArrayOffsetToTraversable' => [
|
||||
'<?php
|
||||
function render(array $data): ?Traversable {
|
||||
if ($data["o"] instanceof Traversable) {
|
||||
return $data["o"];
|
||||
}
|
||||
|
||||
return null;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user