mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
parent
068afa09d3
commit
4a28525275
@ -238,13 +238,15 @@ class NegatedAssertionReconciler extends Reconciler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strtolower($assertion) === 'traversable'
|
if (strtolower($assertion) === 'traversable'
|
||||||
&& isset($existing_var_type->getTypes()['iterable'])
|
&& isset($existing_var_atomic_types['iterable'])
|
||||||
) {
|
) {
|
||||||
|
/** @var Type\Atomic\TIterable */
|
||||||
|
$iterable = $existing_var_atomic_types['iterable'];
|
||||||
$existing_var_type->removeType('iterable');
|
$existing_var_type->removeType('iterable');
|
||||||
$existing_var_type->addType(new TArray(
|
$existing_var_type->addType(new TArray(
|
||||||
[
|
[
|
||||||
new Type\Union([new TArrayKey]),
|
$iterable->type_params[0],
|
||||||
new Type\Union([new TMixed]),
|
$iterable->type_params[1],
|
||||||
]
|
]
|
||||||
));
|
));
|
||||||
} elseif (strtolower($assertion) === 'int'
|
} elseif (strtolower($assertion) === 'int'
|
||||||
|
@ -2376,6 +2376,20 @@ class ConditionalTest extends \Psalm\Tests\TestCase
|
|||||||
return $foo;
|
return $foo;
|
||||||
}'
|
}'
|
||||||
],
|
],
|
||||||
|
'isNotTraversable' => [
|
||||||
|
'<?php
|
||||||
|
/**
|
||||||
|
* @psalm-param iterable<string> $collection
|
||||||
|
* @psalm-return array<string>
|
||||||
|
*/
|
||||||
|
function order(iterable $collection): array {
|
||||||
|
if ($collection instanceof \Traversable) {
|
||||||
|
$collection = iterator_to_array($collection, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
|
}'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user