Skip to content

Commit 793506d

Browse files
Fix
1 parent 8aa9b78 commit 793506d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Type/Php/ArrayCountValuesDynamicReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function getTypeFromFunctionCall(
5454
}
5555

5656
$outputTypes[] = TypeCombinator::intersect(
57-
new ArrayType($itemType, IntegerRangeType::fromInterval(1, null)),
57+
new ArrayType($itemType->toArrayKey(), IntegerRangeType::fromInterval(1, null)),
5858
new NonEmptyArrayType(),
5959
);
6060
}

tests/PHPStan/Analyser/nsrt/array-count-values.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ public function __toString(): string
4646
$scalar = array_count_values([true, 1.0, false, 0.0, null]);
4747

4848
assertType('array{}', $scalar);
49+
50+
$intAsString = array_count_values(['1', '2', '2', '3']);
51+
52+
assertType("non-empty-array<1|2|3, int<1, max>>", $intAsString);

0 commit comments

Comments
 (0)