Skip to content

Commit

Permalink
Merge pull request #112 from KacerCZ/php81-support
Browse files Browse the repository at this point in the history
Added support for PHP 8.1
  • Loading branch information
Spamercz authored Feb 10, 2022
2 parents f14bb26 + f97af1e commit 66f609d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/Kdyby/Redis/RedisClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ public function offsetExists($offset): bool
* @param string|int $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->__get($offset);
Expand Down
7 changes: 3 additions & 4 deletions src/Kdyby/Redis/RedisSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down
27 changes: 8 additions & 19 deletions tests/KdybyTests/Redis/SessionHandlerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,17 @@ 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());

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());
Expand All @@ -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));
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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__);
Expand Down

0 comments on commit 66f609d

Please sign in to comment.