mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
parent
2ed28764d6
commit
62451762fa
@ -223,8 +223,20 @@ class NegatedAssertionReconciler extends Reconciler
|
||||
} elseif (strtolower($assertion) === 'array'
|
||||
&& isset($existing_var_type->getTypes()['iterable'])
|
||||
) {
|
||||
$iterable = $existing_var_type->getTypes()['iterable'];
|
||||
|
||||
$existing_var_type->removeType('iterable');
|
||||
$existing_var_type->addType(new TNamedObject('Traversable'));
|
||||
|
||||
if ($iterable instanceof Atomic\TIterable
|
||||
&& $iterable->type_params
|
||||
&& (!$iterable->type_params[0]->isMixed() || !$iterable->type_params[1]->isMixed())
|
||||
) {
|
||||
$traversable = new Atomic\TGenericObject('Traversable', $iterable->type_params);
|
||||
} else {
|
||||
$traversable = new TNamedObject('Traversable');
|
||||
}
|
||||
|
||||
$existing_var_type->addType($traversable);
|
||||
} elseif (strtolower($assertion) === 'string'
|
||||
&& isset($existing_var_type->getTypes()['array-key'])
|
||||
) {
|
||||
|
@ -136,6 +136,8 @@ class TypeReconciliationTest extends TestCase
|
||||
'callableToCallableArray' => ['callable-array{0: string|object, 1: string}', 'array', 'callable'],
|
||||
'callableOrArrayToCallableArray' => ['array<array-key, mixed>|callable-array{0: string|object, 1: string}', 'array', 'callable|array'],
|
||||
'traversableToIntersection' => ['Countable&Traversable', 'Traversable', 'Countable'],
|
||||
'iterableWithoutParamsToTraversableWithoutParams' => ['Traversable', '!array', 'iterable'],
|
||||
'iterableWithParamsToTraversableWithParams' => ['Traversable<int, string>', '!array', 'iterable<int, string>'],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user