Skip to content

Commit de2566a

Browse files
committed
array_is_list narrows the type even when not on Bleeding Edge
1 parent 8b1d78d commit de2566a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/PhpDoc/TypeNodeResolver.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ private function resolveIdentifierTypeNode(IdentifierTypeNode $typeNode, NameSco
390390
new ArrayType(new IntegerType(), new MixedType()),
391391
new NonEmptyArrayType(),
392392
));
393+
case '__always-list':
394+
return TypeCombinator::intersect(
395+
new ArrayType(new IntegerType(), new MixedType()),
396+
new AccessoryArrayListType(),
397+
);
393398

394399
case 'empty':
395400
$type = $this->tryResolvePseudoTypeClassType($typeNode, $nameScope);

stubs/arrayFunctions.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ function array_udiff(
6767

6868
/**
6969
* @param array<array-key, mixed> $value
70-
* @return ($value is list ? true : false)
70+
* @return ($value is __always-list ? true : false)
7171
*/
7272
function array_is_list(array $value): bool {}

0 commit comments

Comments
 (0)