Stubs multi handling and more specific types#2799
Conversation
Fix phpstan/phpstan#7745 and various similar ones This commit is just a proof-of-concept for the necessary changes to allow getting a quick overview of the proposed changes, which will be implemented in the next commits
|
Looks good. I'll need to regenerate the We're restricted in what we can change except in a major version bump. I'm not actually sure what |
In terms of phpredis itself I hope nothing changed (can't guarantee though, bc it's just so many, but if any change/issue I'll fix it)
If it's an issue, I'll just keep it in phpdoc only - however technically it's at least misleading since one assumes that We're using these internally in the next days, I'll update it if we encounter any issues and/or I have time to make some additional improvements. |
|
Interesting it looks like You can build these locally by doiing this: cd /path/to/phpredis
phpize
php build/gen_stub.php
# You could also chmod +x build/gen_stub.php && build/gen_stub.php |
|
That's because of the conditional return type though, not bc of "self" is it? |
|
Sorry you're right I didn't look too closely. Just saw that Edit: It doesn't like |
235eb8d to
34f362f
Compare
Weird, bc "self" is a native PHP type hint since PHP 7.0. Anyway: given that the conditional return types aren't supported either, I suggest that I:
Let me know if that sounds good, then I'll take care of it tomorrow morning so this can get merged |
Yeah the What you can do to confirm that the stubs parse is something like this: cd phpredis
phpize && php build/gen_stub.phpIdeally where your system-wide version of php is 8.5 as |
Follow-up to previous PRs in psalm and discussions in phpredis for stubs.
multi()mode correctly phpstan/phpstan#7745 and various similar onesInitial setup and key methods types were fixed manually, cross-referencing the .c source code, others were bulk replaced due to the sheer number of methods.
There are still further improvements possible to make some types more specific (e.g. some int/array types can be changed to int<0, max> or string[]), which I might add at a later point.
The reason
string[]was used instead ofarray<string, string>even though that would be what usually be expected is that PHP will automatically cast int-like numeric array keys to intI PRed it here since instead of having to maintain everything twice (= in phpredis + in psalm) it saves me a lot of time to only do it once.