Skip to content

Commit 4f4a01a

Browse files
committed
upd CommandDecorator
1 parent 0745170 commit 4f4a01a

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/predis/Command/CommandDecorator.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,41 @@
88

99
class CommandDecorator extends COMMAND
1010
{
11-
private $originalCommand;
11+
private CommandInterface $originalCommand;
1212

1313
public function __construct(CommandInterface $command)
1414
{
1515
$this->originalCommand = $command;
1616
}
1717

1818
/**
19+
* Yii components expect response without changes
1920
* @inheritdoc
2021
*/
2122
public function parseResponse($data)
2223
{
2324
return $data;
2425
}
2526

26-
public function __call($method, $args)
27-
{
28-
return call_user_func_array([$this->originalCommand, $method], $args);
29-
}
27+
// Calling methods of the original class
28+
29+
public function __call($method, $args): mixed { return call_user_func_array([$this->originalCommand, $method], $args); }
3030

3131
public function getId():string { return $this->originalCommand->getId(); }
32-
public function setArguments(array $arguments):void { $this->originalCommand->setArguments($arguments); }
33-
public function getArguments():array { return $this->originalCommand->getArguments(); }
32+
33+
public function setArguments(array $arguments): void { $this->originalCommand->setArguments($arguments); }
34+
35+
public function getArguments(): array { return $this->originalCommand->getArguments(); }
36+
37+
public function setSlot($slot): void { $this->originalCommand->setSlot($slot); }
38+
39+
public function getSlot(): ?int { return $this->originalCommand->getSlot(); }
40+
41+
public function setRawArguments(array $arguments): void { $this->originalCommand->setRawArguments($arguments); }
42+
43+
public function getArgument($index): mixed { return $this->originalCommand->getArgument($index); }
44+
45+
public function parseResp3Response($data): mixed { return $this->originalCommand->parseResp3Response($data); }
46+
47+
public function serializeCommand(): string { return $this->originalCommand->serializeCommand(); }
3448
}

src/predis/PredisConnection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ public function executeCommand($name, $params = []): mixed
324324
$command = $this->client->createCommand($name, $params);
325325
$response = $this->client->executeCommand(new CommandDecorator($command));
326326
if ($response instanceof Status) {
327+
// ResponseStatus yii expect as bool
327328
return (string)$response === 'OK' || (string)$response === 'PONG';
328329
}
329330
return $response;

0 commit comments

Comments
 (0)