Skip to content

Commit

Permalink
Cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
freost committed Sep 14, 2024
1 parent 623dc68 commit 2cf6cad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/mako/database/query/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace mako\database\query;

use AllowDynamicProperties;
use JsonSerializable;
use Stringable;

Expand All @@ -16,7 +17,7 @@
/**
* Result.
*/
#[\AllowDynamicProperties]
#[AllowDynamicProperties]
class Result implements JsonSerializable, Stringable
{
/**
Expand Down
25 changes: 12 additions & 13 deletions src/mako/redis/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
/**
* Redis client.
*
* @see http://redis.io/topics/protocol Redis protocol specification.
* @see https://github.com/antirez/RESP3/blob/master/spec.md Redis protocol specification.
* @see https://redis.io/docs/latest/develop/reference/protocol-spec/ Redis protocol specification.
*
* @method mixed aclLoad(...$arguments)
* @method mixed aclSave(...$arguments)
Expand Down Expand Up @@ -463,17 +462,17 @@ protected function handleSimpleStringResponse(string $response): string
}

/**
* Handles a blob string response.
* Handles a bulk string response.
*/
protected function handleBlobStringResponse(string $response): ?string
protected function handleBulkStringResponse(string $response): ?string
{
if ($response === '$-1') {
return null;
}

$length = substr($response, 1);

// Do we have a streamed blob string response?
// Do we have a streamed bulk string response?
if ($length === '?') {
$string = '';
Expand All @@ -489,7 +488,7 @@ protected function handleBlobStringResponse(string $response): ?string
return $string;
}

// It was just a normal blob string response
// It was just a normal bulk string response

return substr($this->connection->read((int) $length + static::CRLF_LENGTH), 0, -static::CRLF_LENGTH);
}
Expand All @@ -505,9 +504,9 @@ protected function handleVerbatimStringResponse(string $response): string
}

/**
* Handles a number response.
* Handles an integer response.
*/
protected function handleNumberResponse(string $response): int
protected function handleIntegerResponse(string $response): int
{
return (int) substr($response, 1);
}
Expand Down Expand Up @@ -680,9 +679,9 @@ protected function handleSimpleErrorResponse(string $response): mixed
}

/**
* Handles blob error responses.
* Handles bulk error responses.
*/
protected function handleBlobErrorResponse(string $response): void
protected function handleBulkErrorResponse(string $response): void
{
$length = (int) substr($response, 1);

Expand All @@ -700,9 +699,9 @@ protected function getResponse(): mixed

return match (substr($response, 0, 1)) {
'+' => $this->handleSimpleStringResponse($response),
'$' => $this->handleBlobStringResponse($response),
'$' => $this->handleBulkStringResponse($response),
'=' => $this->handleVerbatimStringResponse($response),
':' => $this->handleNumberResponse($response),
':' => $this->handleIntegerResponse($response),
',' => $this->handleDoubleResponse($response),
'(' => $this->handleBigNumberResponse($response),
'#' => $this->handleBooleanResponse($response),
Expand All @@ -712,7 +711,7 @@ protected function getResponse(): mixed
'|' => $this->handleAttributeResponse($response),
'>' => $this->handlePushResponse($response),
'-' => $this->handleSimpleErrorResponse($response),
'!' => $this->handleBlobErrorResponse($response),
'!' => $this->handleBulkErrorResponse($response),
'_' => null,
'.' => static::END,
default => throw new RedisException(vsprintf('Unable to handle server response [ %s ].', [$response])),
Expand Down

0 comments on commit 2cf6cad

Please sign in to comment.