diff --git a/resources/functionMap.php b/resources/functionMap.php index 8e291259e0a..6a689fb7c5c 100644 --- a/resources/functionMap.php +++ b/resources/functionMap.php @@ -8635,12 +8635,12 @@ 'Redis::sDiff' => ['__benevolent|false>', 'key'=>'string', '...other_keys='=>'string'], 'Redis::sDiffStore' => ['__benevolent', 'dst'=>'string', 'key'=>'string', '...other_keys='=>'string'], 'Redis::select' => ['__benevolent', 'db'=>'int'], -'Redis::set' => ['__benevolent', 'key'=>'string', 'value'=>'mixed', 'options='=>'array'], +'Redis::set' => ['__benevolent', 'key'=>'string', 'value'=>'mixed', 'options='=>'array|int|null'], 'Redis::setBit' => ['__benevolent', 'key'=>'string', 'idx'=>'int', 'value'=>'bool'], 'Redis::setex' => ['__benevolent', 'key'=>'string', 'expire'=>'int', 'value'=>'mixed'], 'Redis::setnx' => ['__benevolent', 'key'=>'string', 'value'=>'mixed'], 'Redis::setRange' => ['__benevolent', 'key'=>'string', 'index'=>'int', 'value'=>'string'], -'Redis::sInter' => ['__benevolent|false>', 'key'=>'string', '...other_keys='=>'string'], +'Redis::sInter' => ['__benevolent|false>', 'key'=>'string|string[]', '...other_keys='=>'string'], 'Redis::sintercard' => ['__benevolent', 'keys'=>'string[]', 'limit='=>'int'], 'Redis::sInterStore' => ['__benevolent', 'key'=>'string[]|string', '...other_keys='=>'string'], 'Redis::sismember' => ['__benevolent', 'key'=>'string', 'value'=>'mixed'], @@ -8680,7 +8680,7 @@ 'Redis::xtrim' => ['__benevolent', 'key'=>'string', 'threshold'=>'string', 'approx='=>'bool', 'minid='=>'bool', 'limit='=>'int'], 'Redis::zAdd' => ['__benevolent', 'key'=>'string', 'score_or_options'=>'array|float', '...more_scores_and_mems='=>'mixed'], 'Redis::zCard' => ['__benevolent', 'key'=>'string'], -'Redis::zCount' => ['__benevolent', 'key'=>'string', 'start'=>'string', 'end'=>'string'], +'Redis::zCount' => ['__benevolent', 'key'=>'string', 'start'=>'string|int', 'end'=>'string|int'], 'Redis::zIncrBy' => ['__benevolent', 'key'=>'string', 'value'=>'float', 'member'=>'mixed'], 'Redis::zInter' => ['__benevolent', 'keys'=>'string[]', 'weights='=>'?array', 'options='=>'?array'], 'Redis::zmpop' => ['__benevolent', 'keys'=>'string[]', 'from'=>'string', 'count='=>'int'], @@ -8719,7 +8719,7 @@ 'RedisCluster::multi' => ['__benevolent', 'mode='=>'int'], 'RedisCluster::punSubscribe' => ['__benevolent', 'pattern'=>'string', '...other_patterns='=>'string'], 'RedisCluster::sDiff' => ['list', 'key'=>'string', '...other_keys='=>'string'], -'RedisCluster::sInter' => ['list', 'key'=>'string', '...other_keys='=>'string'], +'RedisCluster::sInter' => ['list', 'key'=>'string|string[]', '...other_keys='=>'string'], 'RedisCluster::sMembers' => ['list', 'key'=>'string'], 'RedisCluster::unSubscribe' => ['__benevolent', 'channels'=>'array'], 'ReflectionClass::export' => ['string|null', 'argument'=>'string|object', 'return='=>'bool'], diff --git a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php index 3151e173287..62761326049 100644 --- a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php @@ -4581,6 +4581,19 @@ public function testBug15251(): void $this->analyse([__DIR__ . '/data/bug-15251.php'], []); } + public function testBug15393(): void + { + $this->checkThisOnly = false; + $this->checkNullables = true; + $this->checkUnionTypes = true; + $this->analyse([__DIR__ . '/data/bug-15393.php'], [ + [ + 'Parameter #3 $options of method Redis::set() expects array|int|null, string given.', + 11, + ], + ]); + } + #[RequiresPhp('>= 8.0.0')] public function testBug12820(): void { diff --git a/tests/PHPStan/Rules/Methods/data/bug-15393.php b/tests/PHPStan/Rules/Methods/data/bug-15393.php new file mode 100644 index 00000000000..d6def950745 --- /dev/null +++ b/tests/PHPStan/Rules/Methods/data/bug-15393.php @@ -0,0 +1,20 @@ +set('key', 'value', 60); + $redis->set('key', 'value', ['nx', 'ex' => 60]); + $redis->set('key', 'value', null); + $redis->set('key', 'value'); + $redis->set('key', 'value', 'foo'); +} + +function doBar(\Redis $redis, \RedisCluster $cluster): void +{ + $redis->sInter(['key1', 'key2']); + $cluster->sInter(['key1', 'key2']); + $redis->zCount('key', 0, 100); + $redis->zCount('key', '-inf', '+inf'); +}