phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

More precise `array_keys` return type

Open staabm opened this issue 1 year ago • 5 comments

closes https://github.com/phpstan/phpstan/issues/11928

staabm avatar Oct 28 '24 17:10 staabm

This pull request has been marked as ready for review.

phpstan-bot avatar Oct 28 '24 17:10 phpstan-bot

Just wondering if any of this could also be done inside Type::getKeysArray() as well? to e.g. avoid having to deal with lists outside of it again.

See also https://github.com/phpstan/phpstan-src/pull/2117 where I played around with adding filter support 😊

herndlm avatar Oct 29 '24 05:10 herndlm

Nice, sorry, noticed too late and should have mentioned it earlier. Later on, e.g. in https://github.com/phpstan/phpstan-src/pull/3514 I used TrinaryLogic instead of bool in the new Type function. Do you think you can use that too?

herndlm avatar Oct 29 '24 14:10 herndlm

I used $strict as bool, because other methods in Type also use it.

Do you see a use-case where Trinary would come in handy?

staabm avatar Oct 29 '24 14:10 staabm

Not necessarily. If others use that too, then consistency makes sense IMO.

herndlm avatar Oct 29 '24 16:10 herndlm

Please fix the conflict.

ondrejmirtes avatar Jul 17 '25 13:07 ondrejmirtes

Please fix the conflict.

resolved.

build errors are unrelated and fixed separately in https://github.com/phpstan/phpstan-src/pull/4104

staabm avatar Jul 17 '25 14:07 staabm

Thank you!

ondrejmirtes avatar Jul 17 '25 14:07 ondrejmirtes