-
-
Notifications
You must be signed in to change notification settings - Fork 942
Description
Bug report
PHP casts strings which represent an integer to integer when used as keys for the combined array.
see also: https://www.php.net/manual/en/language.types.array.php
Additionally the following key casts will occur:
Strings containing valid decimal ints, unless the number is preceded by a + sign, will be cast to the int type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.
PhpStan seems to not recognize this casting.
For example see https://3v4l.org/nJFhp
Code snippet that reproduces the problem
https://phpstan.org/r/98627364-2e71-4197-8c94-3b51b8d220d1
Expected output
There should be no error on return type of cInt().
There should be an error on return type of cString():
Function cString() should return array<string, string> but returns array<int|string, string>.
Did PHPStan help you today? Did it make you happy in any way?
PhpStan had a great impact on our code quality. Thank you very much for your work :-)