diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a819f5b..c99a22e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ 7.4, 8.0 ] + php: [ 7.4, 8.0, 8.1 ] redis-version: [4, 5, 6] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index e4c603f..12f5127 100755 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Kdyby/Redis Requirements ------------ -Kdyby/Redis requires PHP 7.1 or newer. +Kdyby/Redis requires PHP 7.4 or newer. - [Nette Framework](https://github.com/nette/nette) - [Redis database](http://redis.io) diff --git a/src/Kdyby/Redis/RedisClient.php b/src/Kdyby/Redis/RedisClient.php index 8530a84..8af46b7 100644 --- a/src/Kdyby/Redis/RedisClient.php +++ b/src/Kdyby/Redis/RedisClient.php @@ -720,6 +720,7 @@ public function offsetExists($offset): bool * @param string|int $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->__get($offset); diff --git a/src/Kdyby/Redis/RedisSessionHandler.php b/src/Kdyby/Redis/RedisSessionHandler.php index c2ec9f2..5a7310b 100644 --- a/src/Kdyby/Redis/RedisSessionHandler.php +++ b/src/Kdyby/Redis/RedisSessionHandler.php @@ -102,7 +102,7 @@ public function open($savePath, $sessionName): bool * @throws \Kdyby\Redis\Exception\SessionHandlerException * @return string */ - // phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint,SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint + #[\ReturnTypeWillChange] public function read($id): string { return (string) $this->client->get($this->lock($id)); @@ -138,7 +138,6 @@ public function destroy($id): bool return TRUE; } - // phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint,SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint public function close(): bool { foreach ($this->ssIds as $key) { @@ -150,9 +149,9 @@ public function close(): bool } // phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint,SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint - public function gc($maxLifeTime): bool + public function gc($maxLifeTime): int { - return TRUE; + return 1; } protected function lock(string $id): string diff --git a/tests/KdybyTests/Redis/SessionHandlerDecorator.php b/tests/KdybyTests/Redis/SessionHandlerDecorator.php index 59c74eb..d821727 100644 --- a/tests/KdybyTests/Redis/SessionHandlerDecorator.php +++ b/tests/KdybyTests/Redis/SessionHandlerDecorator.php @@ -54,13 +54,9 @@ private function log(string $msg): void /** * @param string $savePath * @param string $sessionId - * @return bool */ // phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint,SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint - public function open( - $savePath, - $sessionId - ) + public function open($savePath, $sessionId): bool { $this->log(\sprintf('%s: %s', __FUNCTION__, $sessionId)); $this->openedSessionCalls[] = \array_merge([__FUNCTION__], \func_get_args()); @@ -68,11 +64,7 @@ public function open( return $this->handler->open($savePath, $sessionId); } - /** - * @return bool - */ - // phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint,SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint - public function close() + public function close(): bool { $this->log(__FUNCTION__); $this->openedSessionCalls[] = \array_merge([__FUNCTION__], \func_get_args()); @@ -84,10 +76,11 @@ public function close() /** * @param string $sessionId - * @return string + * @return string|false * @throws \Throwable */ // phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint,SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint + #[\ReturnTypeWillChange] public function read($sessionId) { $this->log(\sprintf('%s: %s', __FUNCTION__, $sessionId)); @@ -102,11 +95,10 @@ public function read($sessionId) /** * @param string $sessionId - * @return bool * @throws \Throwable */ // phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint,SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint - public function destroy($sessionId) + public function destroy($sessionId): bool { $this->log(\sprintf('%s: %s', __FUNCTION__, $sessionId)); $this->openedSessionCalls[] = \array_merge([__FUNCTION__], \func_get_args()); @@ -121,14 +113,10 @@ public function destroy($sessionId) /** * @param string $sessionId * @param string $sessionData - * @return bool * @throws \Throwable */ // phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint,SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint - public function write( - $sessionId, - $sessionData - ) + public function write($sessionId, $sessionData): bool { $this->log(\sprintf('%s: %s', __FUNCTION__, $sessionId)); $this->openedSessionCalls[] = \array_merge([__FUNCTION__], \func_get_args()); @@ -142,9 +130,10 @@ public function write( /** * @param int $maxlifetime - * @return bool + * @return int|false */ // phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint,SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint + #[\ReturnTypeWillChange] public function gc($maxlifetime) { $this->log(__FUNCTION__);