Skip to content

Commit

Permalink
[5.4] Fix PhpRedis’ ZADD (#17832)
Browse files Browse the repository at this point in the history
* Fix PhpRedis’ zadd adapter

* Formatting

* Simplify formatting
  • Loading branch information
tillkruss authored and taylorotwell committed Feb 9, 2017
1 parent 33feebd commit 57eacff
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Illuminate/Redis/Connections/PhpRedisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,23 @@ public function spop($key, $count = null)
* Add one or more members to a sorted set or update its score if it already exists.
*
* @param string $key
* @param array $membersAndScoresDictionary
* @param mixed $dictionary
* @return int
*/
public function zadd($key, array $membersAndScoresDictionary)
public function zadd($key, ...$dictionary)
{
$arguments = [];
if (count($dictionary) === 1) {
$_dictionary = [];

foreach ($membersAndScoresDictionary as $score => $member) {
$arguments[] = $score;
$arguments[] = $member;
foreach ($dictionary[0] as $member => $score) {
$_dictionary[] = $score;
$_dictionary[] = $member;
}

$dictionary = $_dictionary;
}

return $this->client->zadd($key, ...$arguments);
return $this->client->zadd($key, ...$dictionary);
}

/**
Expand Down

0 comments on commit 57eacff

Please sign in to comment.