mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 11:39:21 +03:00
Predis to v2.2.2
This commit is contained in:
parent
f6b440adef
commit
84ffe1e552
259 changed files with 2407 additions and 9937 deletions
|
|
@ -3,7 +3,8 @@
|
|||
/*
|
||||
* This file is part of the Predis package.
|
||||
*
|
||||
* (c) Daniele Alessandri <suppakilla@gmail.com>
|
||||
* (c) 2009-2020 Daniele Alessandri
|
||||
* (c) 2021-2023 Till Krüss
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
|
@ -11,27 +12,28 @@
|
|||
|
||||
namespace Predis\PubSub;
|
||||
|
||||
use Iterator;
|
||||
use ReturnTypeWillChange;
|
||||
|
||||
/**
|
||||
* Base implementation of a PUB/SUB consumer abstraction based on PHP iterators.
|
||||
*
|
||||
* @author Daniele Alessandri <suppakilla@gmail.com>
|
||||
*/
|
||||
abstract class AbstractConsumer implements \Iterator
|
||||
abstract class AbstractConsumer implements Iterator
|
||||
{
|
||||
const SUBSCRIBE = 'subscribe';
|
||||
const UNSUBSCRIBE = 'unsubscribe';
|
||||
const PSUBSCRIBE = 'psubscribe';
|
||||
const PUNSUBSCRIBE = 'punsubscribe';
|
||||
const MESSAGE = 'message';
|
||||
const PMESSAGE = 'pmessage';
|
||||
const PONG = 'pong';
|
||||
public const SUBSCRIBE = 'subscribe';
|
||||
public const UNSUBSCRIBE = 'unsubscribe';
|
||||
public const PSUBSCRIBE = 'psubscribe';
|
||||
public const PUNSUBSCRIBE = 'punsubscribe';
|
||||
public const MESSAGE = 'message';
|
||||
public const PMESSAGE = 'pmessage';
|
||||
public const PONG = 'pong';
|
||||
|
||||
const STATUS_VALID = 1; // 0b0001
|
||||
const STATUS_SUBSCRIBED = 2; // 0b0010
|
||||
const STATUS_PSUBSCRIBED = 4; // 0b0100
|
||||
public const STATUS_VALID = 1; // 0b0001
|
||||
public const STATUS_SUBSCRIBED = 2; // 0b0010
|
||||
public const STATUS_PSUBSCRIBED = 4; // 0b0100
|
||||
|
||||
private $position = null;
|
||||
private $statusFlags = self::STATUS_VALID;
|
||||
protected $position;
|
||||
protected $statusFlags = self::STATUS_VALID;
|
||||
|
||||
/**
|
||||
* Automatically stops the consumer when the garbage collector kicks in.
|
||||
|
|
@ -56,9 +58,9 @@ abstract class AbstractConsumer implements \Iterator
|
|||
/**
|
||||
* Subscribes to the specified channels.
|
||||
*
|
||||
* @param mixed $channel,... One or more channel names.
|
||||
* @param string ...$channel One or more channel names.
|
||||
*/
|
||||
public function subscribe($channel /*, ... */)
|
||||
public function subscribe($channel /* , ... */)
|
||||
{
|
||||
$this->writeRequest(self::SUBSCRIBE, func_get_args());
|
||||
$this->statusFlags |= self::STATUS_SUBSCRIBED;
|
||||
|
|
@ -67,9 +69,9 @@ abstract class AbstractConsumer implements \Iterator
|
|||
/**
|
||||
* Unsubscribes from the specified channels.
|
||||
*
|
||||
* @param string ... One or more channel names.
|
||||
* @param string ...$channel One or more channel names.
|
||||
*/
|
||||
public function unsubscribe(/* ... */)
|
||||
public function unsubscribe(...$channel)
|
||||
{
|
||||
$this->writeRequest(self::UNSUBSCRIBE, func_get_args());
|
||||
}
|
||||
|
|
@ -77,9 +79,9 @@ abstract class AbstractConsumer implements \Iterator
|
|||
/**
|
||||
* Subscribes to the specified channels using a pattern.
|
||||
*
|
||||
* @param mixed $pattern,... One or more channel name patterns.
|
||||
* @param string ...$pattern One or more channel name patterns.
|
||||
*/
|
||||
public function psubscribe($pattern /* ... */)
|
||||
public function psubscribe(...$pattern)
|
||||
{
|
||||
$this->writeRequest(self::PSUBSCRIBE, func_get_args());
|
||||
$this->statusFlags |= self::STATUS_PSUBSCRIBED;
|
||||
|
|
@ -88,9 +90,9 @@ abstract class AbstractConsumer implements \Iterator
|
|||
/**
|
||||
* Unsubscribes from the specified channels using a pattern.
|
||||
*
|
||||
* @param string ... One or more channel name patterns.
|
||||
* @param string ...$pattern One or more channel name patterns.
|
||||
*/
|
||||
public function punsubscribe(/* ... */)
|
||||
public function punsubscribe(...$pattern)
|
||||
{
|
||||
$this->writeRequest(self::PUNSUBSCRIBE, func_get_args());
|
||||
}
|
||||
|
|
@ -103,7 +105,7 @@ abstract class AbstractConsumer implements \Iterator
|
|||
*/
|
||||
public function ping($payload = null)
|
||||
{
|
||||
$this->writeRequest('PING', array($payload));
|
||||
$this->writeRequest('PING', [$payload]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -149,8 +151,9 @@ abstract class AbstractConsumer implements \Iterator
|
|||
abstract protected function writeRequest($method, $arguments);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
// NOOP
|
||||
|
|
@ -162,22 +165,25 @@ abstract class AbstractConsumer implements \Iterator
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return $this->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return int|null
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return int|null
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
if ($this->valid()) {
|
||||
|
|
@ -192,6 +198,7 @@ abstract class AbstractConsumer implements \Iterator
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function valid()
|
||||
{
|
||||
$isValid = $this->isFlagSet(self::STATUS_VALID);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue