-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#2349Description
Bug report
non-empty-array should keep NonEmptyArrayType when cast with (array).
Code snippet that reproduces the problem
/**
* @param int|non-empty-list<int> $id_or_ids
* @return non-empty-list<int>
*/
function f(int|array $id_or_ids): array
{
if (is_array($id_or_ids)) {
\PHPStan\Testing\assertType('non-empty-list<int>', (array)$id_or_ids);
} else {
\PHPStan\Testing\assertType('array{int}', (array)$id_or_ids);
}
$ids = (array)$id_or_ids;
\PHPStan\Testing\assertType('non-empty-list<int>', $ids);
return $ids;
}https://phpstan.org/r/71dc2791-8fc0-4b1a-8c05-504ab454832e
Expected output
No errors.
Did PHPStan help you today? Did it make you happy in any way?
I enjoy seeing myself grow in solving PHPStan bugs when I encounter them.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels