mirror of
https://github.com/predis/predis.git
synced 2026-08-20 07:01:55 +00:00
Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82eb18c6c3 | |||
| ac6b813ba9 | |||
| 6482956d96 | |||
| cf15dd9857 | |||
| 597c61a098 | |||
| 9aa99349b1 | |||
| b6f60f0d72 | |||
| 10235d62dc | |||
| ec2b1eacd2 | |||
| 9c3605ab33 | |||
| 55e6094954 | |||
| 15314b726b | |||
| 292604edbf | |||
| fc8f9f5604 | |||
| 77132e6c6b | |||
| a7571ef0c7 | |||
| 4901408b08 | |||
| dd3897b755 | |||
| 6e7dbe05fb | |||
| f0f9d68a8e | |||
| bb6f1ee0e3 | |||
| ffcc4bba8c | |||
| 83359dff9a | |||
| 710b4f901b | |||
| f3e46683b9 | |||
| 945e05819b | |||
| a64b7354e1 | |||
| 111d100ee3 | |||
| 893215a1d4 | |||
| f5d8b9fe2d | |||
| 722b513cea | |||
| 62774c6cc5 | |||
| 8aa2ded5b0 | |||
| 795c3e41b0 | |||
| 59e616b124 | |||
| 157f658f0b | |||
| 343afd312a | |||
| d77b77bbd9 | |||
| 34b678192f | |||
| 4de246cfee | |||
| 6fd6933580 | |||
| c7b38abe71 | |||
| 574ef78f86 | |||
| 1ebabaf8f8 | |||
| 98ec0cc27e | |||
| caf8a46cbb | |||
| 944a16d7c0 | |||
| d1290dfde0 | |||
| 9489d9e5aa | |||
| 94ccb2cc3b | |||
| 6c848db2a0 | |||
| 6ab10b2b70 | |||
| 2d4377fc81 |
@@ -0,0 +1,2 @@
|
||||
github: tillkruss
|
||||
custom: "https://www.paypal.me/tillkruss"
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
$PREDIS_HEADER = <<<EOS
|
||||
This file is part of the Predis package.
|
||||
|
||||
(c) Daniele Alessandri <suppakilla@gmail.com>
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
EOS;
|
||||
|
||||
Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($PREDIS_HEADER);
|
||||
|
||||
return Symfony\CS\Config\Config::create()
|
||||
->setUsingCache(true)
|
||||
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
|
||||
->fixers(array(
|
||||
// Symfony
|
||||
'-unalign_equals',
|
||||
'-unalign_double_arrow',
|
||||
|
||||
// Contribs
|
||||
'header_comment',
|
||||
'ordered_use',
|
||||
'phpdoc_order',
|
||||
'long_array_syntax',
|
||||
))
|
||||
->finder(
|
||||
Symfony\CS\Finder\DefaultFinder::create()
|
||||
->in(__DIR__.'/bin')
|
||||
->in(__DIR__.'/src')
|
||||
->in(__DIR__.'/tests')
|
||||
->in(__DIR__.'/examples')
|
||||
);
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
$PREDIS_HEADER = <<<EOS
|
||||
This file is part of the Predis package.
|
||||
|
||||
(c) Daniele Alessandri <suppakilla@gmail.com>
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
EOS;
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setUsingCache(true)
|
||||
->setRules(array(
|
||||
'@Symfony' => true,
|
||||
'header_comment' => array(
|
||||
'header' => $PREDIS_HEADER,
|
||||
),
|
||||
'ordered_imports' => true,
|
||||
'phpdoc_order' => true,
|
||||
'binary_operator_spaces' => array(
|
||||
'align_double_arrow' => false,
|
||||
'align_equals' => false,
|
||||
),
|
||||
'array_syntax' => array('syntax' => 'long'),
|
||||
))
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->in(__DIR__.'/bin')
|
||||
->in(__DIR__.'/src')
|
||||
->in(__DIR__.'/tests')
|
||||
->in(__DIR__.'/examples')
|
||||
);
|
||||
+18
-9
@@ -1,23 +1,32 @@
|
||||
language: php
|
||||
sudo: false
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
branches:
|
||||
except:
|
||||
- v0.5
|
||||
- v0.6
|
||||
- v0.6-PHP_5.2
|
||||
- documentation
|
||||
services: redis-server
|
||||
before_install:
|
||||
- docker run -d --rm -p 127.0.0.1:6379:6379 redis:3
|
||||
before_script:
|
||||
- composer self-update
|
||||
- composer install --no-interaction --prefer-source --dev
|
||||
script:
|
||||
- vendor/bin/phpunit -c phpunit.xml.travisci
|
||||
- travis_retry vendor/bin/phpunit -c phpunit.xml.travisci
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: 5.3
|
||||
dist: precise
|
||||
services: redis-server
|
||||
before_install: skip
|
||||
- php: 5.4
|
||||
dist: trusty
|
||||
- php: 5.5
|
||||
dist: trusty
|
||||
- php: 5.6
|
||||
- php: 7.0
|
||||
- php: 7.1
|
||||
- php: 7.2
|
||||
- php: 7.3
|
||||
- php: 7.4
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
v1.1.2 (2020-08-11)
|
||||
================================================================================
|
||||
|
||||
- __FIX__: pure CRC16 implementation failed to calculate the correct hash when
|
||||
the input value passed to the `hash()` method is an integer (PR #450).
|
||||
|
||||
- __FIX__: make PHP iterator abstractions for `ZSCAN` and `HSCAN` working with
|
||||
PHP 7.2 due to a breaking change, namely the removal of `each()` (PR #448).
|
||||
|
||||
|
||||
v1.1.1 (2016-06-16)
|
||||
================================================================================
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
[![Latest development][ico-version-dev]][link-packagist]
|
||||
[![Monthly installs][ico-downloads-monthly]][link-downloads]
|
||||
[![Build status][ico-travis]][link-travis]
|
||||
[![HHVM support][ico-hhvm]][link-hhvm]
|
||||
[![Gitter room][ico-gitter]][link-gitter]
|
||||
|
||||
Flexible and feature-complete [Redis](http://redis.io) client for PHP >= 5.3 and HHVM >= 2.3.0.
|
||||
@@ -41,7 +40,7 @@ More details about this project can be found on the [frequently asked questions]
|
||||
This library can be found on [Packagist](http://packagist.org/packages/predis/predis) for an easier
|
||||
management of projects dependencies using [Composer](http://packagist.org/about-composer) or on our
|
||||
[own PEAR channel](http://pear.nrk.io) for a more traditional installation using PEAR. Ultimately,
|
||||
compressed archives of each release are [available on GitHub](https://github.com/nrk/predis/tags).
|
||||
compressed archives of each release are [available on GitHub](https://github.com/nrk/predis/releases).
|
||||
|
||||
|
||||
### Loading the library ###
|
||||
@@ -108,7 +107,7 @@ of suitable [options](http://php.net/manual/context.ssl.php) passed via the `ssl
|
||||
$client = new Predis\Client([
|
||||
'scheme' => 'tls',
|
||||
'ssl' => ['cafile' => 'private.pem', 'verify_peer' => true],
|
||||
]
|
||||
]);
|
||||
|
||||
// Same set of parameters, but using an URI string:
|
||||
$client = new Predis\Client('tls://127.0.0.1?ssl[cafile]=private.pem&ssl[verify_peer]=1');
|
||||
@@ -463,7 +462,7 @@ found [on its project page](http://travis-ci.org/nrk/predis).
|
||||
### Project related links ###
|
||||
|
||||
- [Source code](https://github.com/nrk/predis)
|
||||
- [Wiki](https://wiki.github.com/nrk/predis)
|
||||
- [Wiki](https://github.com/nrk/predis/wiki)
|
||||
- [Issue tracker](https://github.com/nrk/predis/issues)
|
||||
- [PEAR channel](http://pear.nrk.io)
|
||||
|
||||
@@ -488,5 +487,4 @@ The code for Predis is distributed under the terms of the MIT license (see [LICE
|
||||
[link-packagist]: https://packagist.org/packages/predis/predis
|
||||
[link-travis]: https://travis-ci.org/nrk/predis
|
||||
[link-downloads]: https://packagist.org/packages/predis/predis/stats
|
||||
[link-hhvm]: http://hhvm.h4cc.de/package/predis/predis
|
||||
[link-gitter]: https://gitter.im/nrk/predis
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ spl_autoload_register(function (\$class) {
|
||||
}
|
||||
}
|
||||
});
|
||||
__HALT_COMPILER();
|
||||
__halt_compiler();
|
||||
EOSTUB;
|
||||
}
|
||||
|
||||
|
||||
+15
-2
@@ -16,7 +16,8 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.9"
|
||||
"php": ">=5.3.9",
|
||||
"cweagans/composer-patches": "^1.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.8"
|
||||
@@ -27,5 +28,17 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {"Predis\\": "src/"}
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"composer-exit-on-patch-failure": true,
|
||||
"patches": {
|
||||
"phpunit/phpunit-mock-objects": {
|
||||
"Fix PHP 7 and 8 compatibility": "./tests/phpunit_mock_objects.patch"
|
||||
},
|
||||
"phpunit/phpunit": {
|
||||
"Fix PHP 7 compatibility": "./tests/phpunit_php7.patch",
|
||||
"Fix PHP 8 compatibility": "./tests/phpunit_php8.patch"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
die("Example scripts are meant to be executed locally via CLI.");
|
||||
}
|
||||
|
||||
require __DIR__.'/../autoload.php';
|
||||
|
||||
function redis_version($info)
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ name = "Predis"
|
||||
desc = "Flexible and feature-complete Redis client for PHP and HHVM"
|
||||
homepage = "http://github.com/nrk/predis"
|
||||
license = "MIT"
|
||||
version = "1.1.1"
|
||||
version = "1.1.2"
|
||||
stability = "stable"
|
||||
channel = "pear.nrk.io"
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ use Predis\Transaction\MultiExec as MultiExecTransaction;
|
||||
*/
|
||||
class Client implements ClientInterface, \IteratorAggregate
|
||||
{
|
||||
const VERSION = '1.1.1';
|
||||
const VERSION = '1.1.2';
|
||||
|
||||
protected $connection;
|
||||
protected $options;
|
||||
|
||||
@@ -16,7 +16,7 @@ use Predis\Command\CommandInterface;
|
||||
/**
|
||||
* Interface defining a client-side context such as a pipeline or transaction.
|
||||
*
|
||||
* @method $this del(array $keys)
|
||||
* @method $this del(array|string $keys)
|
||||
* @method $this dump($key)
|
||||
* @method $this exists($key)
|
||||
* @method $this expire($key, $seconds)
|
||||
@@ -73,8 +73,8 @@ use Predis\Command\CommandInterface;
|
||||
* @method $this hsetnx($key, $field, $value)
|
||||
* @method $this hvals($key)
|
||||
* @method $this hstrlen($key, $field)
|
||||
* @method $this blpop(array $keys, $timeout)
|
||||
* @method $this brpop(array $keys, $timeout)
|
||||
* @method $this blpop(array|string $keys, $timeout)
|
||||
* @method $this brpop(array|string $keys, $timeout)
|
||||
* @method $this brpoplpush($source, $destination, $timeout)
|
||||
* @method $this lindex($key, $index)
|
||||
* @method $this linsert($key, $whence, $pivot, $value)
|
||||
@@ -92,10 +92,10 @@ use Predis\Command\CommandInterface;
|
||||
* @method $this rpushx($key, $value)
|
||||
* @method $this sadd($key, array $members)
|
||||
* @method $this scard($key)
|
||||
* @method $this sdiff(array $keys)
|
||||
* @method $this sdiffstore($destination, array $keys)
|
||||
* @method $this sinter(array $keys)
|
||||
* @method $this sinterstore($destination, array $keys)
|
||||
* @method $this sdiff(array|string $keys)
|
||||
* @method $this sdiffstore($destination, array|string $keys)
|
||||
* @method $this sinter(array|string $keys)
|
||||
* @method $this sinterstore($destination, array|string $keys)
|
||||
* @method $this sismember($key, $member)
|
||||
* @method $this smembers($key)
|
||||
* @method $this smove($source, $destination, $member)
|
||||
@@ -103,13 +103,13 @@ use Predis\Command\CommandInterface;
|
||||
* @method $this srandmember($key, $count = null)
|
||||
* @method $this srem($key, $member)
|
||||
* @method $this sscan($key, $cursor, array $options = null)
|
||||
* @method $this sunion(array $keys)
|
||||
* @method $this sunionstore($destination, array $keys)
|
||||
* @method $this sunion(array|string $keys)
|
||||
* @method $this sunionstore($destination, array|string $keys)
|
||||
* @method $this zadd($key, array $membersAndScoresDictionary)
|
||||
* @method $this zcard($key)
|
||||
* @method $this zcount($key, $min, $max)
|
||||
* @method $this zincrby($key, $increment, $member)
|
||||
* @method $this zinterstore($destination, array $keys, array $options = null)
|
||||
* @method $this zinterstore($destination, array|string $keys, array $options = null)
|
||||
* @method $this zrange($key, $start, $stop, array $options = null)
|
||||
* @method $this zrangebyscore($key, $min, $max, array $options = null)
|
||||
* @method $this zrank($key, $member)
|
||||
@@ -119,7 +119,7 @@ use Predis\Command\CommandInterface;
|
||||
* @method $this zrevrange($key, $start, $stop, array $options = null)
|
||||
* @method $this zrevrangebyscore($key, $min, $max, array $options = null)
|
||||
* @method $this zrevrank($key, $member)
|
||||
* @method $this zunionstore($destination, array $keys, array $options = null)
|
||||
* @method $this zunionstore($destination, array|string $keys, array $options = null)
|
||||
* @method $this zscore($key, $member)
|
||||
* @method $this zscan($key, $cursor, array $options = null)
|
||||
* @method $this zrangebylex($key, $start, $stop, array $options = null)
|
||||
@@ -127,8 +127,8 @@ use Predis\Command\CommandInterface;
|
||||
* @method $this zremrangebylex($key, $min, $max)
|
||||
* @method $this zlexcount($key, $min, $max)
|
||||
* @method $this pfadd($key, array $elements)
|
||||
* @method $this pfmerge($destinationKey, array $sourceKeys)
|
||||
* @method $this pfcount(array $keys)
|
||||
* @method $this pfmerge($destinationKey, array|string $sourceKeys)
|
||||
* @method $this pfcount(array|string $keys)
|
||||
* @method $this pubsub($subcommand, $argument)
|
||||
* @method $this publish($channel, $message)
|
||||
* @method $this discard()
|
||||
|
||||
+14
-14
@@ -24,7 +24,7 @@ use Predis\Profile\ProfileInterface;
|
||||
* and more friendly interface to ease programming which is described in the
|
||||
* following list of methods:
|
||||
*
|
||||
* @method int del(array $keys)
|
||||
* @method int del(array|string $keys)
|
||||
* @method string dump($key)
|
||||
* @method int exists($key)
|
||||
* @method int expire($key, $seconds)
|
||||
@@ -81,8 +81,8 @@ use Predis\Profile\ProfileInterface;
|
||||
* @method int hsetnx($key, $field, $value)
|
||||
* @method array hvals($key)
|
||||
* @method int hstrlen($key, $field)
|
||||
* @method array blpop(array $keys, $timeout)
|
||||
* @method array brpop(array $keys, $timeout)
|
||||
* @method array blpop(array|string $keys, $timeout)
|
||||
* @method array brpop(array|string $keys, $timeout)
|
||||
* @method array brpoplpush($source, $destination, $timeout)
|
||||
* @method string lindex($key, $index)
|
||||
* @method int linsert($key, $whence, $pivot, $value)
|
||||
@@ -100,24 +100,24 @@ use Predis\Profile\ProfileInterface;
|
||||
* @method int rpushx($key, $value)
|
||||
* @method int sadd($key, array $members)
|
||||
* @method int scard($key)
|
||||
* @method array sdiff(array $keys)
|
||||
* @method int sdiffstore($destination, array $keys)
|
||||
* @method array sinter(array $keys)
|
||||
* @method int sinterstore($destination, array $keys)
|
||||
* @method array sdiff(array|string $keys)
|
||||
* @method int sdiffstore($destination, array|string $keys)
|
||||
* @method array sinter(array|string $keys)
|
||||
* @method int sinterstore($destination, array|string $keys)
|
||||
* @method int sismember($key, $member)
|
||||
* @method array smembers($key)
|
||||
* @method int smove($source, $destination, $member)
|
||||
* @method string spop($key, $count = null)
|
||||
* @method array spop($key, $count = null)
|
||||
* @method string srandmember($key, $count = null)
|
||||
* @method int srem($key, $member)
|
||||
* @method array sscan($key, $cursor, array $options = null)
|
||||
* @method array sunion(array $keys)
|
||||
* @method int sunionstore($destination, array $keys)
|
||||
* @method array sunion(array|string $keys)
|
||||
* @method int sunionstore($destination, array|string $keys)
|
||||
* @method int zadd($key, array $membersAndScoresDictionary)
|
||||
* @method int zcard($key)
|
||||
* @method string zcount($key, $min, $max)
|
||||
* @method string zincrby($key, $increment, $member)
|
||||
* @method int zinterstore($destination, array $keys, array $options = null)
|
||||
* @method int zinterstore($destination, array|string $keys, array $options = null)
|
||||
* @method array zrange($key, $start, $stop, array $options = null)
|
||||
* @method array zrangebyscore($key, $min, $max, array $options = null)
|
||||
* @method int zrank($key, $member)
|
||||
@@ -127,7 +127,7 @@ use Predis\Profile\ProfileInterface;
|
||||
* @method array zrevrange($key, $start, $stop, array $options = null)
|
||||
* @method array zrevrangebyscore($key, $max, $min, array $options = null)
|
||||
* @method int zrevrank($key, $member)
|
||||
* @method int zunionstore($destination, array $keys, array $options = null)
|
||||
* @method int zunionstore($destination, array|string $keys, array $options = null)
|
||||
* @method string zscore($key, $member)
|
||||
* @method array zscan($key, $cursor, array $options = null)
|
||||
* @method array zrangebylex($key, $start, $stop, array $options = null)
|
||||
@@ -135,8 +135,8 @@ use Predis\Profile\ProfileInterface;
|
||||
* @method int zremrangebylex($key, $min, $max)
|
||||
* @method int zlexcount($key, $min, $max)
|
||||
* @method int pfadd($key, array $elements)
|
||||
* @method mixed pfmerge($destinationKey, array $sourceKeys)
|
||||
* @method int pfcount(array $keys)
|
||||
* @method mixed pfmerge($destinationKey, array|string $sourceKeys)
|
||||
* @method int pfcount(array|string $keys)
|
||||
* @method mixed pubsub($subcommand, $argument)
|
||||
* @method int publish($channel, $message)
|
||||
* @method mixed discard()
|
||||
|
||||
@@ -61,6 +61,8 @@ class CRC16 implements HashGeneratorInterface
|
||||
// CRC-CCITT-16 algorithm
|
||||
$crc = 0;
|
||||
$CCITT_16 = self::$CCITT_16;
|
||||
|
||||
$value = (string) $value;
|
||||
$strlen = strlen($value);
|
||||
|
||||
for ($i = 0; $i < $strlen; ++$i) {
|
||||
|
||||
@@ -50,11 +50,9 @@ class HashKey extends CursorBasedIterator
|
||||
*/
|
||||
protected function extractNext()
|
||||
{
|
||||
if ($kv = each($this->elements)) {
|
||||
$this->position = $kv[0];
|
||||
$this->current = $kv[1];
|
||||
$this->position = key($this->elements);
|
||||
$this->current = current($this->elements);
|
||||
|
||||
unset($this->elements[$this->position]);
|
||||
}
|
||||
unset($this->elements[$this->position]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,11 +50,9 @@ class SortedSetKey extends CursorBasedIterator
|
||||
*/
|
||||
protected function extractNext()
|
||||
{
|
||||
if ($kv = each($this->elements)) {
|
||||
$this->position = $kv[0];
|
||||
$this->current = $kv[1];
|
||||
$this->position = key($this->elements);
|
||||
$this->current = current($this->elements);
|
||||
|
||||
unset($this->elements[$this->position]);
|
||||
}
|
||||
unset($this->elements[$this->position]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,16 +11,22 @@
|
||||
|
||||
namespace Predis\Configuration;
|
||||
|
||||
use Predis\Command\Processor\ProcessorInterface;
|
||||
use Predis\Connection\Aggregate\ClusterInterface;
|
||||
use Predis\Connection\Aggregate\ReplicationInterface;
|
||||
use Predis\Connection\FactoryInterface;
|
||||
use Predis\Profile\ProfileInterface;
|
||||
|
||||
/**
|
||||
* Interface defining a container for client options.
|
||||
*
|
||||
* @property-read mixed aggregate Custom connection aggregator.
|
||||
* @property-read mixed cluster Aggregate connection for clustering.
|
||||
* @property-read mixed connections Connection factory.
|
||||
* @property-read mixed exceptions Toggles exceptions in client for -ERR responses.
|
||||
* @property-read mixed prefix Key prefixing strategy using the given prefix.
|
||||
* @property-read mixed profile Server profile.
|
||||
* @property-read mixed replication Aggregate connection for replication.
|
||||
* @property-read callable $aggregate Custom connection aggregator.
|
||||
* @property-read ClusterInterface $cluster Aggregate connection for clustering.
|
||||
* @property-read FactoryInterface $connections Connection factory.
|
||||
* @property-read bool $exceptions Toggles exceptions in client for -ERR responses.
|
||||
* @property-read ProcessorInterface $prefix Key prefixing strategy using the given prefix.
|
||||
* @property-read ProfileInterface $profile Server profile.
|
||||
* @property-read ReplicationInterface $replication Aggregate connection for replication.
|
||||
*
|
||||
* @author Daniele Alessandri <suppakilla@gmail.com>
|
||||
*/
|
||||
|
||||
@@ -515,8 +515,10 @@ class SentinelReplication implements ReplicationInterface
|
||||
/**
|
||||
* Asserts that the specified connection matches an expected role.
|
||||
*
|
||||
* @param NodeConnectionInterface $sentinel Connection to a redis server.
|
||||
* @param string $role Expected role of the server ("master", "slave" or "sentinel").
|
||||
* @param NodeConnectionInterface $connection Connection to a redis server.
|
||||
* @param string $role Expected role of the server ("master", "slave" or "sentinel").
|
||||
*
|
||||
* @throws RoleException
|
||||
*/
|
||||
protected function assertConnectionRole(NodeConnectionInterface $connection, $role)
|
||||
{
|
||||
|
||||
@@ -36,4 +36,15 @@ class CRC16Test extends PredisTestCase
|
||||
$this->assertSame(25343, $crc16->hash('key:008'));
|
||||
$this->assertSame(29406, $crc16->hash('key:009'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testHashGenerationWithIntegerValues()
|
||||
{
|
||||
$crc16 = new CRC16();
|
||||
|
||||
$this->assertSame(13907, $crc16->hash(0));
|
||||
$this->assertSame(55177, $crc16->hash(1234));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,12 +71,24 @@ class ConnectionSelectTest extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @expectedException \Predis\Response\ServerException
|
||||
* @expectedExceptionMessage ERR invalid DB index
|
||||
* @expectedExceptionMessageRegExp /ERR.*DB index/
|
||||
*/
|
||||
public function testThrowsExceptionOnUnexpectedDatabase()
|
||||
public function testThrowsExceptionOnUnexpectedDatabaseRange()
|
||||
{
|
||||
$redis = $this->getClient();
|
||||
|
||||
$redis->select(100000000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @expectedException \Predis\Response\ServerException
|
||||
* @expectedExceptionMessage ERR invalid DB index
|
||||
*/
|
||||
public function testThrowsExceptionOnUnexpectedDatabaseName()
|
||||
{
|
||||
$redis = $this->getClient();
|
||||
|
||||
$redis->select('x');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ class PubSubSubscribeByPatternTest extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @expectedException \Predis\Response\ServerException
|
||||
* @expectedExceptionMessageRegExp /ERR only .* allowed in this context/
|
||||
* @expectedExceptionMessageRegExp /ERR.*only .* allowed in this context/
|
||||
*/
|
||||
public function testCannotSendOtherCommandsAfterPsubscribe()
|
||||
{
|
||||
|
||||
@@ -145,7 +145,7 @@ class PubSubSubscribeTest extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @expectedException \Predis\Response\ServerException
|
||||
* @expectedExceptionMessageRegExp /ERR only .* allowed in this context/
|
||||
* @expectedExceptionMessageRegExp /ERR.*only .* allowed in this context/
|
||||
*/
|
||||
public function testCannotSendOtherCommandsAfterSubscribe()
|
||||
{
|
||||
|
||||
@@ -74,10 +74,29 @@ class RawCommandTest extends PredisTestCase
|
||||
* argument is missing, PHP emits an E_WARNING.
|
||||
*
|
||||
* @group disconnected
|
||||
* @expectedException \PHPUnit_Framework_Error_Warning
|
||||
*/
|
||||
public function testPHPWarningOnMissingCommandIDWithStaticCreate()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, "7.1", '>')) {
|
||||
$this->markTestSkipped('only for PHP < 7.1');
|
||||
}
|
||||
$this->setExpectedException('PHPUnit_Framework_Error_Warning');
|
||||
RawCommand::create();
|
||||
}
|
||||
|
||||
/**
|
||||
* The signature of RawCommand::create() requires one argument which is the
|
||||
* ID of the command (other arguments are fetched dinamically). If the first
|
||||
* argument is missing, PHP 7.1 throw an exception
|
||||
*
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testPHPWarningOnMissingCommandIDWithStaticCreate71()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, "7.1", '<')) {
|
||||
$this->markTestSkipped('only for PHP > 7.1');
|
||||
}
|
||||
$this->setExpectedException('ArgumentCountError');
|
||||
RawCommand::create();
|
||||
}
|
||||
|
||||
|
||||
@@ -245,8 +245,8 @@ class RedisClusterTest extends PredisTestCase
|
||||
public function testGetIteratorReturnsConnectionsMappedInSlotsMapWhenUseClusterSlotsIsDisabled()
|
||||
{
|
||||
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=0-5460');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382?slots=5461-10921');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6383?slots=10922-16383');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382?slots=5461-10922');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6383?slots=10923-16383');
|
||||
$connection4 = $this->getMockConnection('tcp://127.0.0.1:6384');
|
||||
|
||||
$cluster = new RedisCluster(new Connection\Factory());
|
||||
@@ -274,8 +274,8 @@ class RedisClusterTest extends PredisTestCase
|
||||
{
|
||||
$slotsmap = array(
|
||||
array(0, 5460, array('127.0.0.1', 6381), array()),
|
||||
array(5461, 10921, array('127.0.0.1', 6383), array()),
|
||||
array(10922, 16383, array('127.0.0.1', 6384), array()),
|
||||
array(5461, 10922, array('127.0.0.1', 6383), array()),
|
||||
array(10923, 16383, array('127.0.0.1', 6384), array()),
|
||||
);
|
||||
|
||||
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=0-5460');
|
||||
@@ -286,7 +286,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
))
|
||||
->will($this->returnValue($slotsmap));
|
||||
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382?slots=5461-10921');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382?slots=5461-10922');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6383');
|
||||
$connection4 = $this->getMockConnection('tcp://127.0.0.1:6384');
|
||||
|
||||
@@ -398,8 +398,8 @@ class RedisClusterTest extends PredisTestCase
|
||||
public function testCanAssignConnectionsToRangeOfSlotsFromParameters()
|
||||
{
|
||||
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6379?slots=0-5460');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=5461-10921');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=10922-16383');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=5461-10922');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=10923-16383');
|
||||
|
||||
$cluster = new RedisCluster(new Connection\Factory());
|
||||
$cluster->add($connection1);
|
||||
@@ -410,8 +410,8 @@ class RedisClusterTest extends PredisTestCase
|
||||
|
||||
$expectedMap = array_merge(
|
||||
array_fill(0, 5461, '127.0.0.1:6379'),
|
||||
array_fill(5460, 5461, '127.0.0.1:6380'),
|
||||
array_fill(10921, 5462, '127.0.0.1:6381')
|
||||
array_fill(5460, 5462, '127.0.0.1:6380'),
|
||||
array_fill(10923, 5461, '127.0.0.1:6381')
|
||||
);
|
||||
|
||||
$actualMap = $cluster->getSlotsMap();
|
||||
@@ -426,8 +426,8 @@ class RedisClusterTest extends PredisTestCase
|
||||
public function testCanAssignConnectionsToSingleSlotOrRangesOfSlotsFromParameters()
|
||||
{
|
||||
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6379?slots=0-5460,5500-5600,11000');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=5461-5499,5600-10921');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=10922-10999,11001-16383');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=5461-5499,5600-10922');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=10923-10999,11001-16383');
|
||||
|
||||
$cluster = new RedisCluster(new Connection\Factory());
|
||||
$cluster->add($connection1);
|
||||
@@ -440,8 +440,8 @@ class RedisClusterTest extends PredisTestCase
|
||||
array_fill(0, 5461, '127.0.0.1:6379'),
|
||||
array_fill(5460, 39, '127.0.0.1:6380'),
|
||||
array_fill(5499, 101, '127.0.0.1:6379'),
|
||||
array_fill(5599, 5321, '127.0.0.1:6380'),
|
||||
array_fill(10921, 78, '127.0.0.1:6381'),
|
||||
array_fill(5599, 5322, '127.0.0.1:6380'),
|
||||
array_fill(10923, 77, '127.0.0.1:6381'),
|
||||
array_fill(11000, 1, '127.0.0.1:6379'),
|
||||
array_fill(11000, 5383, '127.0.0.1:6381')
|
||||
);
|
||||
@@ -555,8 +555,8 @@ class RedisClusterTest extends PredisTestCase
|
||||
{
|
||||
$slotsmap = array(
|
||||
array(0, 5460, array('127.0.0.1', 9381), array()),
|
||||
array(5461, 10921, array('127.0.0.1', 6382), array()),
|
||||
array(10922, 16383, array('127.0.0.1', 6383), array()),
|
||||
array(5461, 10922, array('127.0.0.1', 6382), array()),
|
||||
array(10923, 16383, array('127.0.0.1', 6383), array()),
|
||||
);
|
||||
|
||||
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=0-5460');
|
||||
@@ -569,7 +569,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
new Connection\ConnectionException($connection1, 'Unknown connection error [127.0.0.1:6381]')
|
||||
));
|
||||
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382?slots=5461-10921');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382?slots=5461-10922');
|
||||
$connection2->expects($this->any())
|
||||
->method('executeCommand')
|
||||
->with($this->isRedisCommand(
|
||||
@@ -577,7 +577,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
))
|
||||
->will($this->returnValue($slotsmap));
|
||||
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6383?slots=10922-16383');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6383?slots=10923-16383');
|
||||
$connection3->expects($this->any())
|
||||
->method('executeCommand')
|
||||
->with($this->isRedisCommand(
|
||||
@@ -720,8 +720,8 @@ class RedisClusterTest extends PredisTestCase
|
||||
{
|
||||
$slotsmap = array(
|
||||
array(0, 5460, array('127.0.0.1', 9381), array()),
|
||||
array(5461, 10921, array('127.0.0.1', 6382), array()),
|
||||
array(10922, 16383, array('127.0.0.1', 6383), array()),
|
||||
array(5461, 10922, array('127.0.0.1', 6382), array()),
|
||||
array(10923, 16383, array('127.0.0.1', 6383), array()),
|
||||
);
|
||||
|
||||
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=0-5460');
|
||||
@@ -734,7 +734,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
new Connection\ConnectionException($connection1, 'Unknown connection error [127.0.0.1:6381]')
|
||||
));
|
||||
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382?slots=5461-10921');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382?slots=5461-10922');
|
||||
$connection2->expects($this->once())
|
||||
->method('executeCommand')
|
||||
->with($this->isRedisCommand(
|
||||
@@ -744,7 +744,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
new Connection\ConnectionException($connection2, 'Unknown connection error [127.0.0.1:6383]')
|
||||
));
|
||||
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6383?slots=10922-16383');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6383?slots=10923-16383');
|
||||
$connection3->expects($this->once())
|
||||
->method('executeCommand')
|
||||
->with($this->isRedisCommand(
|
||||
@@ -777,8 +777,8 @@ class RedisClusterTest extends PredisTestCase
|
||||
{
|
||||
$slotsmap = array(
|
||||
array(0, 5460, array('127.0.0.1', 9381), array()),
|
||||
array(5461, 10921, array('127.0.0.1', 6382), array()),
|
||||
array(10922, 16383, array('127.0.0.1', 6383), array()),
|
||||
array(5461, 10922, array('127.0.0.1', 6382), array()),
|
||||
array(10923, 16383, array('127.0.0.1', 6383), array()),
|
||||
);
|
||||
|
||||
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=0-5460');
|
||||
@@ -791,7 +791,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
new Connection\ConnectionException($connection1, 'Unknown connection error [127.0.0.1:6381]')
|
||||
));
|
||||
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382?slots=5461-10921');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382?slots=5461-10922');
|
||||
$connection2->expects($this->any())
|
||||
->method('executeCommand')
|
||||
->with($this->isRedisCommand(
|
||||
@@ -801,7 +801,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
new Connection\ConnectionException($connection2, 'Unknown connection error [127.0.0.1:6382]')
|
||||
));
|
||||
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6383?slots=10922-16383');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6383?slots=10923-16383');
|
||||
$connection3->expects($this->never())
|
||||
->method('executeCommand');
|
||||
|
||||
@@ -1142,9 +1142,9 @@ class RedisClusterTest extends PredisTestCase
|
||||
*/
|
||||
public function testCanBeSerialized()
|
||||
{
|
||||
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6379?slots=0-1364');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=1365-2729');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=2730-4095');
|
||||
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6379?slots=0-5460');
|
||||
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=5461-10922');
|
||||
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=10923-16383');
|
||||
|
||||
$cluster = new RedisCluster(new Connection\Factory());
|
||||
$cluster->add($connection1);
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ $ phpunit --exclude-group slow
|
||||
### Testing Redis commands ###
|
||||
|
||||
We also provide an helper script in the `bin` directory that can be used to automatically generate a
|
||||
file with the scheleton of a test case to test a Redis command by specifying the name of the class
|
||||
file with the skeleton of a test case to test a Redis command by specifying the name of the class
|
||||
in the `Predis\Command` namespace (only classes in this namespace are considered valid). For example
|
||||
to generate a test case for `SET` (represented by the `Predis\Command\StringSet` class):
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
diff --git a/src/Framework/MockObject/Generator.php b/src/Framework/MockObject/Generator.php
|
||||
index 3df3abb..fc76d5d 100644
|
||||
--- a/src/Framework/MockObject/Generator.php
|
||||
+++ b/src/Framework/MockObject/Generator.php
|
||||
@@ -1031,16 +1031,29 @@ protected function getMethodParameters(ReflectionMethod $method, $forCall = fals
|
||||
$typeDeclaration = '';
|
||||
|
||||
if (!$forCall) {
|
||||
+ if (PHP_VERSION_ID >= 80000) {
|
||||
+ $isArray = $parameter->getType() && $parameter->getType()->getName() === 'array';
|
||||
+ $isCallable = $parameter->getType() && $parameter->getType()->getName() === 'callable';
|
||||
+ } else {
|
||||
+ $isArray = $parameter->isArray();
|
||||
+ $isCallable = version_compare(PHP_VERSION, '5.4.0', '>=') ? $parameter->isCallable() : false;
|
||||
+ }
|
||||
+
|
||||
if ($this->hasType($parameter)) {
|
||||
- $typeDeclaration = (string) $parameter->getType() . ' ';
|
||||
- } elseif ($parameter->isArray()) {
|
||||
+ $type = $parameter->getType();
|
||||
+ $typeDeclaration = (PHP_VERSION_ID >= 70100 ? $type->getName() : (string) $type) . ' ';
|
||||
+ } elseif ($isArray) {
|
||||
$typeDeclaration = 'array ';
|
||||
} elseif ((defined('HHVM_VERSION') || version_compare(PHP_VERSION, '5.4.0', '>='))
|
||||
- && $parameter->isCallable()) {
|
||||
+ && $isCallable) {
|
||||
$typeDeclaration = 'callable ';
|
||||
} else {
|
||||
try {
|
||||
- $class = $parameter->getClass();
|
||||
+ if (PHP_VERSION_ID >= 80000) {
|
||||
+ $class = $parameter->getType();
|
||||
+ } else {
|
||||
+ $class = $parameter->getClass();
|
||||
+ }
|
||||
} catch (ReflectionException $e) {
|
||||
throw new PHPUnit_Framework_MockObject_RuntimeException(
|
||||
sprintf(
|
||||
@@ -0,0 +1,60 @@
|
||||
diff --git a/src/Util/Getopt.php b/src/Util/Getopt.php
|
||||
index ba21be3..96931a3 100644
|
||||
--- a/src/Util/Getopt.php
|
||||
+++ b/src/Util/Getopt.php
|
||||
@@ -35,7 +35,15 @@ class PHPUnit_Util_Getopt
|
||||
reset($args);
|
||||
array_map('trim', $args);
|
||||
|
||||
- while (list($i, $arg) = each($args)) {
|
||||
+ while (true) {
|
||||
+ $arg = current($args);
|
||||
+ $i = key($args);
|
||||
+ next($args);
|
||||
+
|
||||
+ if ($arg === false) {
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
if ($arg == '') {
|
||||
continue;
|
||||
}
|
||||
@@ -94,11 +102,14 @@ class PHPUnit_Util_Getopt
|
||||
if ($i + 1 < $argLen) {
|
||||
$opts[] = array($opt, substr($arg, $i + 1));
|
||||
break;
|
||||
- } elseif (list(, $opt_arg) = each($args)) {
|
||||
} else {
|
||||
- throw new PHPUnit_Framework_Exception(
|
||||
- "option requires an argument -- $opt"
|
||||
- );
|
||||
+ $opt_arg = current($args);
|
||||
+ next($args);
|
||||
+ if ($opt_arg === false) {
|
||||
+ throw new PHPUnit_Framework_Exception(
|
||||
+ "option requires an argument -- $opt"
|
||||
+ );
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,11 +150,14 @@ class PHPUnit_Util_Getopt
|
||||
|
||||
if (substr($long_opt, -1) == '=') {
|
||||
if (substr($long_opt, -2) != '==') {
|
||||
- if (!strlen($opt_arg) &&
|
||||
- !(list(, $opt_arg) = each($args))) {
|
||||
- throw new PHPUnit_Framework_Exception(
|
||||
- "option --$opt requires an argument"
|
||||
- );
|
||||
+ if (!strlen($opt_arg)) {
|
||||
+ $opt_arg = current($args);
|
||||
+ next($args);
|
||||
+ if ($opt_arg === false) {
|
||||
+ throw new PHPUnit_Framework_Exception(
|
||||
+ "option --$opt requires an argument"
|
||||
+ );
|
||||
+ }
|
||||
}
|
||||
}
|
||||
} elseif ($opt_arg) {
|
||||
@@ -0,0 +1,39 @@
|
||||
diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php
|
||||
index 638f42513..b4c7d3a5e 100644
|
||||
--- a/src/Framework/TestCase.php
|
||||
+++ b/src/Framework/TestCase.php
|
||||
@@ -905,7 +905,7 @@ protected function runTest()
|
||||
try {
|
||||
$testResult = $method->invokeArgs(
|
||||
$this,
|
||||
- array_merge($this->data, $this->dependencyInput)
|
||||
+ array_values(array_merge($this->data, $this->dependencyInput))
|
||||
);
|
||||
} catch (Throwable $_e) {
|
||||
$e = $_e;
|
||||
diff --git a/src/Util/Configuration.php b/src/Util/Configuration.php
|
||||
index 5c1041608..b2f7a7bd0 100644
|
||||
--- a/src/Util/Configuration.php
|
||||
+++ b/src/Util/Configuration.php
|
||||
@@ -162,7 +162,7 @@ protected function __construct($filename)
|
||||
/**
|
||||
* @since Method available since Release 3.4.0
|
||||
*/
|
||||
- final private function __clone()
|
||||
+ private function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
diff --git a/src/Util/PHP/Template/TestCaseMethod.tpl.dist b/src/Util/PHP/Template/TestCaseMethod.tpl.dist
|
||||
index b48f354cd..d59cdeea7 100644
|
||||
--- a/src/Util/PHP/Template/TestCaseMethod.tpl.dist
|
||||
+++ b/src/Util/PHP/Template/TestCaseMethod.tpl.dist
|
||||
@@ -78,7 +78,7 @@ if ('' !== $configurationFilePath) {
|
||||
unset($configuration);
|
||||
}
|
||||
|
||||
-function __phpunit_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
|
||||
+function __phpunit_error_handler($errno, $errstr, $errfile, $errline, $errcontext = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user