-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#3590Description
Bug report
array_keys would never return a key that is not already part of the (narrowed) key type.
a simple first fix (i suppose): just removing this check: https://github.com/phpstan/phpstan-src/blob/612ee600d58315b23506a8a148b0100597b7661b/src/Type/Php/ArrayKeysFunctionDynamicReturnTypeExtension.php#L30
While this might not fix all cases, it would certainly fix the cases of narrowed array-key types to int or string? (*)
(*) with the known caveat of the internal type conversion of integer strings, of course
Code snippet that reproduces the problem
https://phpstan.org/r/f43ddd65-69db-4d3e-acb4-9d2689e5f5b3
Expected output
8: Dumped type: list<int>
11: Dumped type: list<int>
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels