Skip to content

Commit e4c6f83

Browse files
Fix
1 parent 363b2ce commit e4c6f83

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/Type/Php/ArrayCountValuesDynamicReturnTypeExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ public function getTypeFromFunctionCall(
5454
continue;
5555
}
5656

57+
<<<<<<< HEAD
5758
$outputTypes[] = new IntersectionType([
5859
new ArrayType($itemType, IntegerRangeType::fromInterval(1, null)),
60+
=======
61+
$outputTypes[] = TypeCombinator::intersect(
62+
new ArrayType($itemType->toArrayKey(), IntegerRangeType::fromInterval(1, null)),
63+
>>>>>>> 793506dbb (Fix)
5964
new NonEmptyArrayType(),
6065
]);
6166
}

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)