Fix the type of the options of the RedisArray constructor - #6399
Conversation
|
You've opened the pull request against the latest branch 2.3.x. PHPStan 2.3 is not going to be released for months. If your code is relevant on 2.2.x and you want it to be released sooner, please rebase your pull request and change its target to 2.2.x. |
93fa9f6 to
0af0a71
Compare
Done. |
The options may have any type: for example, connect_timeout and read_timeout are numbers, lazy_connect and consistent are booleans, function and distributor are callables, previous is an array. See the phpredis documentation of RedisArray: https://github.com/phpredis/phpredis/blob/develop/arrays.md and the phpredis stub of the constructor: https://github.com/phpredis/phpredis/blob/develop/redis_array.stub.php
0af0a71 to
8b6f1aa
Compare
|
@SanderMuller please review |
|
I am not a maintainer, so the merge call is @staabm's. I verified the change rather than read it, and it does what it says. The type claim holds. The Base against your head, on a file that passes one option of every documented type: One thing I would add while you are in there. The parameter is still not nullable, so the documented default is a false positive: new RedisArray($hosts, null);
'Redis::copy' => [..., 'options='=>'?array<string, mixed>'],Your call whether that belongs here or in a separate PR. Checked and found fine: Gate on your head: full suite green, 21440 tests. The signature map suite is green too, 2844 tests and 64036 assertions. No performance statement is needed beyond the obvious: this is a data entry read through the signature map, with no runtime path. CI: 31 of the 32 red checks also fail on other open 2.2.x pull requests, so they are the base. The one that does not, |
Fixed, thanks!. |
SanderMuller
left a comment
There was a problem hiding this comment.
Verified on 672a020ec. The repro that failed twice on the base now reports nothing. The three cases that should still be rejected still are: a non-array second argument, an array<int, string>, and an int for the first parameter.
Gate on your head is green. Full suite 21440 tests, signature map 2844 tests and 64036 assertions. No performance note beyond the obvious, since this is a data entry read through the signature map with no runtime path. There is no test in the diff because a functionMap entry has nowhere to put one, so I checked the behaviour with a file instead.
Your six red checks that other open 2.2.x pull requests do not share are the base, not you. Lint fails on Parse error: tests/PHPStan/Rules/DeadCode/data/dynamic-name-always-terminating.php:20, and Name Collision Detector on Bug15244\Foo is defined 2 times. Both files are on 2.2.x already and neither is in your one-line diff.
|
thank you! |
The options may have any type: for example,
connect_timeoutandread_timeoutare numbers,lazy_connectandconsistentare booleans,functionanddistributorare callables,previousis an array.See the phpredis documentation of RedisArray:
https://github.com/phpredis/phpredis/blob/develop/arrays.md
and the phpredis stub of the constructor:
https://github.com/phpredis/phpredis/blob/develop/redis_array.stub.php