Repository navigation
Widen Redis::set() $options, Redis::sInter()/RedisCluster::sInter() $key and Redis::zCount() bounds in functionMap to match phpredis signatures - #6940
Merged
VincentLanglet merged 1 commit intoNov 4, 2026
Conversation
…ter()` `$key` and `Redis::zCount()` bounds in functionMap to match phpredis signatures - `Redis::set()` `$options`: `array` -> `array|int|null` (phpredis accepts an int TTL, sending SETEX, or null) - `Redis::sInter()` and `RedisCluster::sInter()` `$key`: `string` -> `string|string[]` (native `array|string`) - `Redis::zCount()` `$start`/`$end`: `string` -> `string|int` (native `string|int`) - Audited all Redis/RedisCluster/RedisArray/RedisSentinel functionMap entries against the native signatures of the phpredis extension; remaining differences are intentional refinements (array shapes, string[] instead of array, by-ref scan iterators).
VincentLanglet
approved these changes
Nov 4, 2026
Contributor
|
shouldn't issue-bot report the initial snippet as beeing fixed by the PR? |
Contributor
It does https://github.com/phpstan/phpstan-src/actions/runs/41806668097?pr=6940 |
staabm
approved these changes
Nov 4, 2026
staabm
left a comment
Contributor
There was a problem hiding this comment.
ok - I think the issue bot result was not there at the time I looked because github currently has some problems
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Redis::set()accepts an integer TTL as its third argument ($redis->set('key', 'value', 60)makes phpredis sendSETEX), as well asnull. PHPStan's functionMap only allowedarray, so it reportedParameter #3 $options of method Redis::set() expects array, int given.This PR widens the parameter type to match phpredis.Changes
resources/functionMap.php:Redis::setoptions:array→array|int|nullRedis*::functionMap entry with the native signatures that the phpredis extension reports through reflection:Redis::sInterandRedisCluster::sInterkey:string→string|string[](native type isarray|string)Redis::zCountstart/end:string→string|int(native type isstring|int)string[]instead ofarray,?intfor by-ref scan iterators, and narrower types where the native type ismixed.Root cause
The hand-written functionMap signatures were narrower than the actual phpredis signatures, so PHPStan rejected valid arguments.
Test
CallMethodsRuleTest::testBug15393(tests/PHPStan/Rules/Methods/data/bug-15393.php) coversRedis::set()with an int, array, null, omitted, and invalid string$options. It also coversRedis::sInter()/RedisCluster::sInter()with an array of keys andRedis::zCount()with int bounds. Every case except the invalid string reported a false positive before the fix.Fixes phpstan/phpstan#15393