diff --git a/src/Cluster/Hash/PhpiredisCRC16.php b/src/Cluster/Hash/PhpiredisCRC16.php deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Cluster/SlotRange.php b/src/Cluster/SlotRange.php index 95fdeab4..03be46e7 100644 --- a/src/Cluster/SlotRange.php +++ b/src/Cluster/SlotRange.php @@ -66,7 +66,7 @@ class SlotRange implements Countable */ public static function isValidRange($first, $last) { - return $first >= 0 && $first <= self::MAX_SLOTS && $last >= 0x0000 && $last <= self::MAX_SLOTS && $first <= $last; + return $first >= 0x0000 && $first <= self::MAX_SLOTS && $last >= 0x0000 && $last <= self::MAX_SLOTS && $first <= $last; } /** diff --git a/src/Connection/PhpiredisSocketConnection.php b/src/Connection/PhpiredisSocketConnection.php deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Consumer/PubSub/Consumer.php b/src/Consumer/PubSub/Consumer.php index 768e1124..96ee0c55 100644 --- a/src/Consumer/PubSub/Consumer.php +++ b/src/Consumer/PubSub/Consumer.php @@ -146,9 +146,9 @@ class Consumer extends AbstractConsumer /** * Subscribes to the specified channels. * - * @param string ...$channel One or more channel names. + * @param string ...$channels One or more channel names. */ - public function subscribe($channel /* , ... */) + public function subscribe(string ...$channels) { $this->writeRequest(self::SUBSCRIBE, func_get_args()); $this->statusFlags |= self::STATUS_SUBSCRIBED; diff --git a/src/PubSub/AbstractConsumer.php b/src/PubSub/AbstractConsumer.php deleted file mode 100644 index fa4ea360..00000000 --- a/src/PubSub/AbstractConsumer.php +++ /dev/null @@ -1,226 +0,0 @@ -stop(true); - } - - /** - * Checks if the specified flag is valid based on the state of the consumer. - * - * @param int $value Flag. - * - * @return bool - */ - protected function isFlagSet($value) - { - return ($this->statusFlags & $value) === $value; - } - - /** - * Subscribes to the specified channels. - * - * @param string ...$channel One or more channel names. - */ - public function subscribe($channel /* , ... */) - { - $this->writeRequest(self::SUBSCRIBE, func_get_args()); - $this->statusFlags |= self::STATUS_SUBSCRIBED; - } - - /** - * Unsubscribes from the specified channels. - * - * @param string ...$channel One or more channel names. - */ - public function unsubscribe(...$channel) - { - $this->writeRequest(self::UNSUBSCRIBE, func_get_args()); - } - - /** - * Subscribes to the specified channels using a pattern. - * - * @param string ...$pattern One or more channel name patterns. - */ - public function psubscribe(...$pattern) - { - $this->writeRequest(self::PSUBSCRIBE, func_get_args()); - $this->statusFlags |= self::STATUS_PSUBSCRIBED; - } - - /** - * Unsubscribes from the specified channels using a pattern. - * - * @param string ...$pattern One or more channel name patterns. - */ - public function punsubscribe(...$pattern) - { - $this->writeRequest(self::PUNSUBSCRIBE, func_get_args()); - } - - /** - * PING the server with an optional payload that will be echoed as a - * PONG message in the pub/sub loop. - * - * @param string $payload Optional PING payload. - */ - public function ping($payload = null) - { - $this->writeRequest('PING', [$payload]); - } - - /** - * Closes the context by unsubscribing from all the subscribed channels. The - * context can be forcefully closed by dropping the underlying connection. - * - * @param bool $drop Indicates if the context should be closed by dropping the connection. - * - * @return bool Returns false when there are no pending messages. - */ - public function stop($drop = false) - { - if (!$this->valid()) { - return false; - } - - if ($drop) { - $this->invalidate(); - $this->disconnect(); - } else { - if ($this->isFlagSet(self::STATUS_SUBSCRIBED)) { - $this->unsubscribe(); - } - if ($this->isFlagSet(self::STATUS_PSUBSCRIBED)) { - $this->punsubscribe(); - } - } - - return !$drop; - } - - /** - * Closes the underlying connection when forcing a disconnection. - */ - abstract protected function disconnect(); - - /** - * Writes a Redis command on the underlying connection. - * - * @param string $method Command ID. - * @param array $arguments Arguments for the command. - */ - abstract protected function writeRequest($method, $arguments); - - /** - * @return void - */ - #[ReturnTypeWillChange] - public function rewind() - { - // NOOP - } - - /** - * Returns the last message payload retrieved from the server and generated - * by one of the active subscriptions. - * - * @return array - */ - #[ReturnTypeWillChange] - public function current() - { - return $this->getValue(); - } - - /** - * @return int|null - */ - #[ReturnTypeWillChange] - public function key() - { - return $this->position; - } - - /** - * @return int|null - */ - #[ReturnTypeWillChange] - public function next() - { - if ($this->valid()) { - ++$this->position; - } - - return $this->position; - } - - /** - * Checks if the the consumer is still in a valid state to continue. - * - * @return bool - */ - #[ReturnTypeWillChange] - public function valid() - { - $isValid = $this->isFlagSet(self::STATUS_VALID); - $subscriptionFlags = self::STATUS_SUBSCRIBED | self::STATUS_PSUBSCRIBED; - $hasSubscriptions = ($this->statusFlags & $subscriptionFlags) > 0; - - return $isValid && $hasSubscriptions; - } - - /** - * Resets the state of the consumer. - */ - protected function invalidate() - { - $this->statusFlags = 0; // 0b0000; - } - - /** - * Waits for a new message from the server generated by one of the active - * subscriptions and returns it when available. - * - * @return array - */ - abstract protected function getValue(); -} diff --git a/src/PubSub/Consumer.php b/src/PubSub/Consumer.php deleted file mode 100644 index e69de29b..00000000 diff --git a/src/PubSub/DispatcherLoop.php b/src/PubSub/DispatcherLoop.php deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Predis/Cluster/Hash/PhpiredisCRC16Test.php b/tests/Predis/Cluster/Hash/PhpiredisCRC16Test.php deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Predis/Connection/PhpiredisSocketConnectionTest.php b/tests/Predis/Connection/PhpiredisSocketConnectionTest.php deleted file mode 100644 index e69de29b..00000000