1
0
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:
Matthew Brown 2019-08-18 18:06:57 -04:00
parent 1b983babd0
commit b8bdaea09a
2 changed files with 11 additions and 1 deletions

View File

@ -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 = [];

View File

@ -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;
}'
],
];
}