Skip to content

Commit

Permalink
Allow int keys when calling Redis methods
Browse files Browse the repository at this point in the history
In 5bfc0f9, risky casting was invoked
as a way to show there is an issue here. However, it is not always
possible to use a string. For instance, there is no such thing as this
in PHP: ["1" => "whatever"]. If you try to create such an array, you
will obtain [1 => "whatever"] instead.

Ironically, this was copied in jetbrains/phpstorm, which is used in
PHPStan, which exhibited that false positive.

See JetBrains/phpstorm-stubs#1454
  • Loading branch information
greg0ire committed Nov 8, 2023
1 parent 5f07988 commit 460ba3d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stubs/extensions/redis.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,20 @@ class Redis {

public function ltrim(string $key, int $start , int $end): Redis|bool {}

/** @return false|list<false|string>|Redis */
/** @return false|list<false|int|string>|Redis */
public function mget(array $keys) {}

public function migrate(string $host, int $port, string $key, string $dst, int $timeout, bool $copy = false, bool $replace = false): bool {}

public function move(string $key, int $index): bool {}

/**
* @param array<string, string>
* @param array<int|string, string>
*/
public function mset($key_values): Redis|bool {}

/**
* @param array<string, string>
* @param array<int|string, string>
*/
public function msetnx($key_values): Redis|bool {}

Expand Down

0 comments on commit 460ba3d

Please sign in to comment.