Repository navigation
Accept int timeout and null for $options parameter of Redis::set() in function map - #6801
Open
phpstan-bot wants to merge 1 commit into
Open
phpstan-bot wants to merge 1 commit into
phpstan-bot wants to merge 1 commit into
Conversation
…et()` in function map - phpredis declares `Redis::set(string $key, mixed $value, mixed $options = null)`; `$options` may be an array of options, an int TTL in seconds (legacy form), or null. The function map narrowed it to `array`, causing false positives. - Compared every Redis/RedisCluster/RedisArray entry in functionMap.php against the native signatures of the loaded phpredis extension (null-default parameters and `mixed` options/timeout parameters); `Redis::set` was the only mismatch.
VincentLanglet
approved these changes
Oct 24, 2026
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('key', 'value', 3600)reportedParameter #3 $options of method Redis::set() expects array, int given.phpredis accepts an int TTL here (as well as an options array ornull), so the call is valid.Changes
resources/functionMap.php:Redis::setoptions=changed fromarraytoarray|int|null.Root cause
The function map signature was narrower than phpredis's real signature (
mixed $options = null, handled as array of options, integer timeout, or null). I compared all Redis/RedisCluster/RedisArray function map entries against the native reflection of the phpredis extension (null-default parameters not allowing null, andmixedoptions/timeout parameters).Redis::setwas the only mismatch.RedisCluster::setis not in the function map, so it already uses the nativemixedsignature.Test
Added
tests/PHPStan/Rules/Methods/data/bug-15393.phpwithCallMethodsRuleTest::testBug15393. It coversset()with no options, an int timeout, an options array, andnull. Before the fix, the int and null calls failed.Fixes phpstan/phpstan#15393