Skip to content

Commit 4887f50

Browse files
authored
Merge pull request #52 from cheprasov/v161
v161
2 parents bd07732 + 6818bc7 commit 4887f50

File tree

9 files changed

+35
-15
lines changed

9 files changed

+35
-15
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## CHANGELOG
22

3+
### v1.6.1 (2017-02-04)
4+
- Added check for empty data on reading response.
5+
- Fixed some tests.
6+
37
### v1.6.0 (2017-01-07)
48
- Added support for Redis 4.0 (the Client was tested with Redis 4.0 RC2).
59
- Added support for Redis Cluster.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
22
[![Latest Stable Version](https://poser.pugx.org/cheprasov/php-redis-client/v/stable)](https://packagist.org/packages/cheprasov/php-redis-client)
33
[![Total Downloads](https://poser.pugx.org/cheprasov/php-redis-client/downloads)](https://packagist.org/packages/cheprasov/php-redis-client)
4-
# RedisClient v1.6.0 for PHP >= 5.5
4+
# RedisClient v1.6.1 for PHP >= 5.5
55

66
## About
77
RedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from __2.6__ to __4.0__
@@ -16,7 +16,7 @@ RedisClient is a fast, fully-functional and user-friendly client for Redis, opti
1616
- Connections to Redis are established lazily by the client upon the first command.
1717
- Easy to use with IDE, client has PHPDocs for all supported versions.
1818
- By default, the client works with the latest stable version of Redis (3.2).
19-
- Client was tested on the next versions of Redis: 2.6.17, 2.8.24, 3.0.7, 3.2.6, 4.0 RC2 (and other).
19+
- Client was tested on the next versions of Redis: 2.6.17, 2.8.24, 3.0.7, 3.2.7, 4.0 RC2 (and other).
2020
- Also, Client was tested on PHP 5.5, 5.6, 7.0, 7.1, HHVM.
2121

2222
## Usage

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cheprasov/php-redis-client",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "Php client for Redis. It is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 4.0",
55
"homepage": "http://github.com/cheprasov/php-redis-client",
66
"minimum-stability": "stable",

src/RedisClient/Client/AbstractRedisClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
abstract class AbstractRedisClient {
2828

29-
const VERSION = '1.6.0';
29+
const VERSION = '1.6.1';
3030

3131
const CONFIG_SERVER = 'server';
3232
const CONFIG_TIMEOUT = 'timeout';

src/RedisClient/Command/Parameter/Parameter.php

+10-4
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

+1-1
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

+6-2
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

+7-3
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

+3-1
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)