Fix #13996: array_count_values array key inference broken since 2.1.34 by phpstan-bot · Pull Request #4909 · phpstan/phpstan-src
and others added 2 commits
February 12, 2026 19:28- PHP casts numeric strings to integer array keys, so array_count_values on array<string> should return non-empty-array<int|string, int<1, max>> not non-empty-array<string, int<1, max>> - Added isNumericString() check in ArrayCountValuesDynamicReturnTypeExtension to union IntegerType into key type when string may be numeric - New regression test in tests/PHPStan/Analyser/nsrt/bug-13996.php - Updated existing test expectation for general string case Closes phpstan/phpstan#13996
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters