Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ jobs:

# Step 7
- name: Check code style (PSR-12)
run: composer cs
run: composer cs:check

# Step 8: Run entire tests suite
- name: Run all tests
run: composer test

# Step 9: Static code analysis
- name: Run static code analysis
run: composer stan-dist
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ composer.lock
/.phpunit.cache
.phpunit.result.cache
/.php-cs-fixer.cache
phpstan.neon
/src/redis.php
/src/redisTestCLI.php
/vendor
/vendor
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017-2025 Laurent LEGAZ
Copyright (c) 2017-2026 Laurent LEGAZ

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"phpunit/phpunit": "^10.5",
"symfony/var-dumper": "~6.4",
"friendsofphp/php-cs-fixer": "~3.3",
"cache/integration-tests": "dev-master"
"cache/integration-tests": "dev-master",
"phpstan/phpstan": "^2.1"
},
"suggest": {
"ext-redis": "^5.3"
Expand All @@ -46,13 +47,16 @@
}
},
"scripts": {
"cs":"@phpcsfixer",
"pu":"@phpunit",
"puv":"@phpunit-verbose",
"pui":"@phpunit-int-suite",
"puiv":"@phpunit-int-verbose",
"puf":"@phpunit-func-suite",
"pufv":"@phpunit-func-verbose",
"cs":"@phpcsfixer",
"cs:check": "@phpcsfixer --dry-run --format=txt --verbose --diff --ansi --allow-unsupported-php-version=yes",
"stan":"vendor/bin/phpstan analyse -c phpstan.neon",
"stan-dist":"vendor/bin/phpstan analyse -c phpstan.neon.dist",
"test": "./vendor/bin/phpunit --display-deprecations --display-notices --display-warnings --colors=always --configuration ./phpunit.xml --bootstrap .phpunit_full",
"test-only": "./vendor/bin/phpunit --display-deprecations --display-notices --display-warnings --colors=always --configuration ./phpunit.xml --bootstrap .phpunit_full --filter SecurityTest::testSpecialCharactersDoNotCauseInjection",
"test-psr16": "./vendor/bin/phpunit --display-deprecations --display-notices --display-warnings --colors=always --configuration ./phpunit.xml --bootstrap .phpunit_full --filter CacheIntegrationTest",
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 6
paths:
- src
- tests
19 changes: 7 additions & 12 deletions src/CacheEntryPool/CacheEntryPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
*/
class CacheEntryPool implements CacheItemPoolInterface
{
/**
*
* @var Psr\SimpleCache\CacheInterface
*/
/** @var RedisEnhancedCache&\Psr\SimpleCache\CacheInterface */
private RedisEnhancedCache $cache;

/**
Expand All @@ -48,15 +45,12 @@
*/
private ?string $poolName = null;

/**
*
* @var array
*/
/** @var array */
private array $deferredItems = [];

Check failure on line 49 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - predis)

Property LLegaz\Cache\Pool\CacheEntryPool::$deferredItems type has no value type specified in iterable type array.

Check failure on line 49 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - phpredis)

Property LLegaz\Cache\Pool\CacheEntryPool::$deferredItems type has no value type specified in iterable type array.

Check failure on line 49 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - phpredis)

Property LLegaz\Cache\Pool\CacheEntryPool::$deferredItems type has no value type specified in iterable type array.

Check failure on line 49 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - phpredis)

Property LLegaz\Cache\Pool\CacheEntryPool::$deferredItems type has no value type specified in iterable type array.

Check failure on line 49 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - predis)

Property LLegaz\Cache\Pool\CacheEntryPool::$deferredItems type has no value type specified in iterable type array.

Check failure on line 49 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - predis)

Property LLegaz\Cache\Pool\CacheEntryPool::$deferredItems type has no value type specified in iterable type array.

Check failure on line 49 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - predis)

Property LLegaz\Cache\Pool\CacheEntryPool::$deferredItems type has no value type specified in iterable type array.

Check failure on line 49 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - phpredis)

Property LLegaz\Cache\Pool\CacheEntryPool::$deferredItems type has no value type specified in iterable type array.

/**
*
* @param Psr\SimpleCache\CacheInterface $cache
* @param RedisEnhancedCache&\Psr\SimpleCache\CacheInterface $cache
* @param string|null $pool
*/
public function __construct(RedisEnhancedCache $cache, ?string $pool = null)
Expand All @@ -83,7 +77,7 @@
$this->cache->delete($this->poolName);
unset($this->deferredItems);
$this->deferredItems = [];
} catch (Exception $e) {
} catch (\Exception $e) {
return false;
}

Expand All @@ -96,7 +90,7 @@
* @param string $key
* The key to delete.
*
* @throws InvalidArgumentException
* @throws \Psr\Cache\InvalidArgumentException
* If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
* MUST be thrown.
*
Expand Down Expand Up @@ -139,7 +133,7 @@
* @param string $key
* The key for which to return the corresponding Cache Item.
*
* @throws InvalidArgumentException
* @throws \Psr\Cache\InvalidArgumentException
* If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
* MUST be thrown.
*
Expand Down Expand Up @@ -198,7 +192,7 @@
* key is not found. However, if no keys are specified then an empty
* traversable MUST be returned instead.
*/
public function getItems(array $keys = []): iterable

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - predis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - predis)

Method LLegaz\Cache\Pool\CacheEntryPool::getItems() return type has no value type specified in iterable type iterable.

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - phpredis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - phpredis)

Method LLegaz\Cache\Pool\CacheEntryPool::getItems() return type has no value type specified in iterable type iterable.

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - phpredis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - phpredis)

Method LLegaz\Cache\Pool\CacheEntryPool::getItems() return type has no value type specified in iterable type iterable.

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - phpredis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - phpredis)

Method LLegaz\Cache\Pool\CacheEntryPool::getItems() return type has no value type specified in iterable type iterable.

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - predis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - predis)

Method LLegaz\Cache\Pool\CacheEntryPool::getItems() return type has no value type specified in iterable type iterable.

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - predis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - predis)

Method LLegaz\Cache\Pool\CacheEntryPool::getItems() return type has no value type specified in iterable type iterable.

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - predis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - predis)

Method LLegaz\Cache\Pool\CacheEntryPool::getItems() return type has no value type specified in iterable type iterable.

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - phpredis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 195 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - phpredis)

Method LLegaz\Cache\Pool\CacheEntryPool::getItems() return type has no value type specified in iterable type iterable.
{
$items = [];
$values = $this->cache->fetchFromPool($keys, $this->poolName);
Expand Down Expand Up @@ -258,7 +252,7 @@
* @return bool
* True if item exists in the cache, false otherwise.
*/
public function hasItem(string $key): bool

Check failure on line 255 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - predis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 255 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - phpredis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 255 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - phpredis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 255 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - phpredis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 255 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - predis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 255 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - predis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 255 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - predis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable

Check failure on line 255 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - phpredis)

PHPDoc tag `@throws` with type LLegaz\Cache\Pool\InvalidArgumentException is not subtype of Throwable
{
if ($this->isDeferred($key)) {
if ($this->deferredItems[$key]->isExpiredFromDLC()) {
Expand Down Expand Up @@ -293,7 +287,7 @@
*/
public function save(CacheItemInterface $item): bool
{
if ($this->isExpired($item)) {

Check failure on line 290 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - predis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 290 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - phpredis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 290 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - phpredis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 290 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - phpredis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 290 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - predis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 290 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - predis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 290 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - predis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 290 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - phpredis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.
$this->deleteItem($item->getKey());

return false;
Expand Down Expand Up @@ -329,7 +323,7 @@
/**
* @todo handle commit history for return value
*/
if (!$this->isExpired($item)) {

Check failure on line 326 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - predis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 326 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - phpredis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 326 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - phpredis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 326 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - phpredis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 326 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - predis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 326 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - predis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 326 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - predis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.

Check failure on line 326 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - phpredis)

Parameter #1 $item of method LLegaz\Cache\Pool\CacheEntryPool::isExpired() expects LLegaz\Cache\Entry\CacheEntry, Psr\Cache\CacheItemInterface given.
$this->deferredItems[$item->getKey()] = clone $item;

return true;
Expand All @@ -353,6 +347,7 @@
return true;
}

$deferred = [];
foreach ($this->deferredItems as $key => $item) {
if (!$this->isExpired($item)) {
$deferred[$key] = $item->get();
Expand Down Expand Up @@ -386,7 +381,7 @@

public function printCachePool(): string
{
return $this->cache->printCacheHash($this->poolName);

Check failure on line 384 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - predis)

Call to an undefined method LLegaz\Cache\RedisEnhancedCache::printCacheHash().

Check failure on line 384 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - phpredis)

Call to an undefined method LLegaz\Cache\RedisEnhancedCache::printCacheHash().

Check failure on line 384 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - phpredis)

Call to an undefined method LLegaz\Cache\RedisEnhancedCache::printCacheHash().

Check failure on line 384 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - phpredis)

Call to an undefined method LLegaz\Cache\RedisEnhancedCache::printCacheHash().

Check failure on line 384 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - predis)

Call to an undefined method LLegaz\Cache\RedisEnhancedCache::printCacheHash().

Check failure on line 384 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - predis)

Call to an undefined method LLegaz\Cache\RedisEnhancedCache::printCacheHash().

Check failure on line 384 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - predis)

Call to an undefined method LLegaz\Cache\RedisEnhancedCache::printCacheHash().

Check failure on line 384 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - phpredis)

Call to an undefined method LLegaz\Cache\RedisEnhancedCache::printCacheHash().
}

/**
Expand All @@ -395,7 +390,7 @@
* @param mixed $poolSuffix
* @return string
*/
protected function getPoolName(string $poolSuffix): string

Check failure on line 393 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - predis)

PHPDoc tag `@param` for parameter $poolSuffix with type mixed is not subtype of native type string.

Check failure on line 393 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - phpredis)

PHPDoc tag `@param` for parameter $poolSuffix with type mixed is not subtype of native type string.

Check failure on line 393 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.5 - phpredis)

PHPDoc tag `@param` for parameter $poolSuffix with type mixed is not subtype of native type string.

Check failure on line 393 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - phpredis)

PHPDoc tag `@param` for parameter $poolSuffix with type mixed is not subtype of native type string.

Check failure on line 393 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - predis)

PHPDoc tag `@param` for parameter $poolSuffix with type mixed is not subtype of native type string.

Check failure on line 393 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3 - predis)

PHPDoc tag `@param` for parameter $poolSuffix with type mixed is not subtype of native type string.

Check failure on line 393 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.4 - predis)

PHPDoc tag `@param` for parameter $poolSuffix with type mixed is not subtype of native type string.

Check failure on line 393 in src/CacheEntryPool/CacheEntryPool.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2 - phpredis)

PHPDoc tag `@param` for parameter $poolSuffix with type mixed is not subtype of native type string.
{
return strlen($poolSuffix) ?
RedisEnhancedCache::HASH_DB_PREFIX . "_{$poolSuffix}" :
Expand Down
4 changes: 3 additions & 1 deletion src/RedisCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public function get(string $key, mixed $default = null): mixed
*/
private function getWithNonStrKey(mixed $key, mixed $default = null): mixed
{
// @phpstan-ignore method.void
return $this->get($this->checkKeyValidity($key), $default);
}

Expand Down Expand Up @@ -405,7 +406,7 @@ public function setMultiple(iterable $values, null|int|\DateInterval $ttl = self
$this->formatException($t);
$redisResponse = false;
} finally {
return $redisResponse;
return $redisResponse; // @phpstan-ignore variable.undefined
}
}

Expand Down Expand Up @@ -523,6 +524,7 @@ protected function setCorrectValue(string &$value): mixed

return self::DOES_NOT_EXIST;
} finally {
// @phpstan-ignore variable.undefined
if ($tmp !== false || ($tmp === false && $value === 'b:0;')) {
$value = $tmp; // if value var wasn't a string affect its original value type to it
}
Expand Down
22 changes: 15 additions & 7 deletions src/RedisEnhancedCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace LLegaz\Cache;

use LLegaz\Cache\Exception\InvalidArgumentException;
use LLegaz\Cache\Exception\InvalidKeyException;

/**
Expand Down Expand Up @@ -161,12 +162,17 @@ public function storeToPool(array $values, string $pool = self::DEFAULT_POOL): b
return $this->getRedis()->hmset($pool, $values) == 'OK';
} elseif ($cnt === 1) {
$key = array_keys($values)[0];
$value = isset($key) ? $values[$key] : (isset($values[0]) ? $values[0] : null);
$value = $values[$key];
if (!$this->exist($value)) {
/**
* @todo test this specific scenario (maybe apply it to hmset ?)
* @todo and maybe refactor that exception handling system inherited from previous project (redis-adapter)
*
* because all values are authorized except this predefined value to sort actual existing values internally...
*/
$this->throwUEx('The value: ' . $value . ' isn\'t accepted'); // because all values are authorized except this predefined value to sort actual exisiting values internally...
$e = new InvalidArgumentException('The value: ' . $value . ' isn\'t accepted');
$this->formatException($e);
$this->throwUEx();
}
if ($value) {
//hset should returns the number of fields stored for a single key (always one here)
Expand Down Expand Up @@ -223,7 +229,11 @@ public function fetchFromPool(mixed $key, string $pool = self::DEFAULT_POOL): mi

break;
case 'array':
if (count($key)) {
if (count($key) === 1) {
// redirect to string's or integer's case
return $this->fetchFromPool(reset($key), $pool);
}
if (count($key) > 1) {
$this->checkKeysValidity($key);
$this->begin();
$data = array_combine(
Expand All @@ -238,10 +248,8 @@ public function fetchFromPool(mixed $key, string $pool = self::DEFAULT_POOL): mi
$data[$key] = self::DOES_NOT_EXIST;
}
}
if (count($data)) {

return $data;
}
return $data;
}

break;
Expand Down Expand Up @@ -362,7 +370,7 @@ public function deleteFromPool(array $keys, string $pool = self::DEFAULT_POOL):

try {
$redisResponse = call_user_func_array([$this->getRedis(), 'hdel'], $params);
} catch (Exception $e) {
} catch (\Exception $e) {
$redisResponse = false;
$this->formatException($e);
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Integration/CacheIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Cache\IntegrationTests\SimpleCacheTest;
use LLegaz\Cache\RedisCache as SUT;
use LLegaz\Cache\Tests\TestState;
use PHPUnit\Framework\Attributes\Before;
use PHPUnit\Framework\Attributes\DataProvider;
use Psr\SimpleCache\CacheInterface;
use TypeError;

Expand Down Expand Up @@ -122,7 +124,7 @@ public static function invalidTEKeysSingle()
/**
* Type Error keys (psr/cache version 3)
*
* @return type
* @return array
*/
public static function invalidTEKeys()
{
Expand Down
2 changes: 2 additions & 0 deletions tests/Integration/CacheIntegrationWithPCTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Cache\IntegrationTests\SimpleCacheTest;
use LLegaz\Cache\RedisCache as SUT;
use LLegaz\Cache\Tests\TestState;
use PHPUnit\Framework\Attributes\Before;
use PHPUnit\Framework\Attributes\DataProvider;
use Psr\SimpleCache\CacheInterface;
use TypeError;

Expand Down
1 change: 1 addition & 0 deletions tests/Integration/PoolIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use LLegaz\Cache\Pool\CacheEntryPool as SUT;
use LLegaz\Cache\RedisEnhancedCache;
use LLegaz\Cache\Tests\TestState;
use PHPUnit\Framework\Attributes\Before;
use Psr\Cache\CacheItemPoolInterface;

if (!defined('SKIP_INTEGRATION_TESTS')) {
Expand Down
1 change: 1 addition & 0 deletions tests/Integration/PoolIntegrationWithPCTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use LLegaz\Cache\Pool\CacheEntryPool as SUT;
use LLegaz\Cache\RedisEnhancedCache;
use LLegaz\Cache\Tests\TestState;
use PHPUnit\Framework\Attributes\Before;
use Psr\Cache\CacheItemPoolInterface;

if (!defined('SKIP_INTEGRATION_TESTS')) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/SimpleCacheRCTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SimpleCacheRCTest extends RedisAdapterTestBase
{
protected SUT $cache;

/** @var \PHPUnit\Framework\MockObject\MockObject&RedisClientInterface */
protected RedisClientInterface $redisClient;

public static function setUpBeforeClass(): void
Expand Down Expand Up @@ -378,11 +379,10 @@ public function testSetWithTtl()

/**
*
* @return type
* @return RedisClientInterface
*/
protected function getSelfClient(): RedisClientInterface
{
return $this->redisClient;
}

}
4 changes: 2 additions & 2 deletions tests/Unit/SimpleCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class SimpleCacheTest extends RedisAdapterTestBase
{
protected SUT $cache;

/** @var \PHPUnit\Framework\MockObject\MockObject&RedisClientInterface */
protected RedisClientInterface $predisClient;

public static function setUpBeforeClass(): void
Expand Down Expand Up @@ -360,11 +361,10 @@ public function testSetMultipleWithTtl()

/**
*
* @return type
* @return RedisClientInterface
*/
protected function getSelfClient(): RedisClientInterface
{
return $this->predisClient;
}

}
Loading