Skip to content

Commit e8fd370

Browse files
committed
v161
1 parent bd07732 commit e8fd370

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

src/RedisClient/Command/Parameter/Parameter.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static function assocArrayFlip(array $array) {
9191
/**
9292
* @param string $operation
9393
* @return string
94-
* @return InvalidArgumentException
94+
* @throws InvalidArgumentException
9595
*/
9696
public static function bitOperation($operation) {
9797
$operation = strtoupper((string)$operation);
@@ -134,7 +134,7 @@ public static function enum($param, array $enum) {
134134
* @return float
135135
*/
136136
public static function float($float) {
137-
return (float) $float;
137+
return (float)$float;
138138
}
139139

140140
/**
@@ -145,7 +145,8 @@ public static function float($float) {
145145

146146
/**
147147
* @param string $unit
148-
* @return string mixed
148+
* @return string
149+
* @throws InvalidArgumentException
149150
*/
150151
public static function geoUnit($unit) {
151152
if (!in_array($unit, static::$geoUnits)) {
@@ -193,14 +194,15 @@ public static function keys($keys) {
193194
/**
194195
* @param int|string|int[]|string[] $limit
195196
* @return int[]
197+
* @throws InvalidArgumentException
196198
*/
197199
public static function limit($limit) {
198200
if (is_numeric($limit)) {
199201
return [0, (int)$limit];
200202
}
201203
if (is_array($limit) && isset($limit['count'])) {
202204
return [
203-
empty($limit['offset']) ? 0: (int) $limit['offset'],
205+
empty($limit['offset']) ? 0: (int)$limit['offset'],
204206
(int)$limit['count'],
205207
];
206208
}
@@ -223,6 +225,7 @@ public static function limit($limit) {
223225
/**
224226
* @param int|string $param
225227
* @return int|string
228+
* @throws InvalidArgumentException
226229
*/
227230
public static function minMax($param) {
228231
$param = trim($param);
@@ -235,6 +238,7 @@ public static function minMax($param) {
235238
/**
236239
* @param string $param
237240
* @return string
241+
* @throws InvalidArgumentException
238242
*/
239243
public static function nxXx($param) {
240244
if ($param === 'NX' || $param === 'XX') {
@@ -253,6 +257,7 @@ public static function nxXx($param) {
253257
/**
254258
* @param int|float|string $int
255259
* @return int
260+
* @throws InvalidArgumentException
256261
*/
257262
public static function port($int) {
258263
$int = (int)$int;
@@ -267,6 +272,7 @@ public static function port($int) {
267272
/**
268273
* @param string|int $param
269274
* @return string
275+
* @throws InvalidArgumentException
270276
*/
271277
public static function specifyInterval($param) {
272278
$param = trim($param);

src/RedisClient/Command/Response/ResponseParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function parseInfo($response) {
105105
if (!$response) {
106106
return $response;
107107
}
108-
$response = trim((string) $response);
108+
$response = trim((string)$response);
109109
$result = [];
110110
$link = &$result;
111111
foreach (explode("\n", $response) as $line) {

src/RedisClient/Connection/StreamConnection.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,18 @@ public function readLine() {
122122

123123
/**
124124
* @param int $length
125-
* @return string
125+
* @return string|null
126126
*/
127127
public function read($length) {
128128
$resource = $this->getResource();
129129
$left = $length;
130130
$data = '';
131131
do {
132-
$data .= fread($resource, min($left, 8192));
132+
$read = fread($resource, min($left, 8192));
133+
if (false === $read) {
134+
return null;
135+
}
136+
$data .= $read;
133137
$left = $length - strlen($data);
134138
} while ($left > 0);
135139

src/RedisClient/Protocol/RedisProtocol.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getConnection() {
5858
*/
5959
protected function pack($data) {
6060
if (is_string($data) || is_int($data) || is_bool($data) || is_float($data) || is_null($data)) {
61-
return $this->packProtocolBulkString((string) $data);
61+
return $this->packProtocolBulkString((string)$data);
6262
}
6363
if (is_array($data)) {
6464
return $this->packProtocolArray($data);
@@ -119,7 +119,11 @@ protected function read() {
119119
if ($length === -1) {
120120
return null;
121121
}
122-
return substr($this->Connection->read($length + 2), 0, -2);
122+
$read = $this->Connection->read($length + 2);
123+
if (is_null($read)) {
124+
throw new EmptyResponseException('Can not read response. Please, check connection timeout.');
125+
}
126+
return substr($read, 0, -2);
123127
}
124128

125129
if ($type === self::TYPE_SIMPLE_STRINGS) {
@@ -130,7 +134,7 @@ protected function read() {
130134
}
131135

132136
if ($type === self::TYPE_INTEGERS) {
133-
return (int) $data;
137+
return (int)$data;
134138
}
135139

136140
if ($type === self::TYPE_ARRAYS) {

tests/Integration/Version3x2/ServerCommandsTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ServerCommandsTest extends \Test\Integration\Version3x0\ServerCommandsTest
2222
*/
2323
public function test_commandCount() {
2424
$Redis = static::$Redis;
25-
$this->assertSame(172, $Redis->commandCount());
25+
$this->assertSame(174, $Redis->commandCount());
2626
}
2727

2828
/**
@@ -49,9 +49,11 @@ public function test_command() {
4949
'debug',
5050
'echo',
5151
'eval',
52+
'host:',
5253
'latency',
5354
'pfdebug',
5455
'pfselftest',
56+
'post',
5557
'psync',
5658
'replconf',
5759
'restore-asking',

0 commit comments

Comments
 (0)