From 1a03030d0ac8cf314129e7f74d2bf262bcb35d8e Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Mon, 2 Mar 2026 16:42:34 -0300 Subject: [PATCH 01/16] Require PHP 8.5 --- .github/workflows/tests.yml | 4 ++-- .gitlab-ci.yml | 2 +- composer.json | 2 +- docker-compose.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4421f5f..1749112 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,7 +22,7 @@ jobs: ports: - 6379:6379 - name: PHP 8.3 + name: PHP 8.5 steps: - name: Checkout @@ -31,7 +31,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.3 + php-version: 8.5 tools: composer coverage: xdebug ini-values: apc.enable_cli=1 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca9281d..bdf472d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ --- -image: registry.gitlab.com/aplus-framework/images/base:4 +image: registry.gitlab.com/aplus-framework/images/base:6 include: - template: Security/SAST.gitlab-ci.yml diff --git a/composer.json b/composer.json index 20877f2..0ae67fd 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ } ], "require": { - "php": ">=8.3", + "php": ">=8.5", "ext-apcu": "*", "ext-igbinary": "*", "ext-json": "*", diff --git a/docker-compose.yml b/docker-compose.yml index 8edab3b..fde0801 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: "3" services: package: - image: registry.gitlab.com/aplus-framework/images/package:4 + image: registry.gitlab.com/aplus-framework/images/package:6 container_name: package-cache working_dir: /package volumes: From 2d45e9c63b9f37998dab522d3cb34c5daf3b06b4 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Mon, 2 Mar 2026 16:52:57 -0300 Subject: [PATCH 02/16] Upgrade required packages --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 0ae67fd..83cb793 100644 --- a/composer.json +++ b/composer.json @@ -42,12 +42,12 @@ "ext-memcached": "*", "ext-msgpack": "*", "ext-redis": "*", - "aplus/debug": "^4.5", - "aplus/log": "^4.0" + "aplus/debug": "^5.0", + "aplus/log": "^5.0" }, "require-dev": { "ext-xdebug": "*", - "aplus/coding-standard": "^2.8", + "aplus/coding-standard": "^3.0", "ergebnis/composer-normalize": "^2.25", "jetbrains/phpstorm-attributes": "^1.0", "phpmd/phpmd": "^2.13", From 46066dab53766a2bde7f0bb19f0939239097d9b9 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Mon, 2 Mar 2026 17:37:32 -0300 Subject: [PATCH 03/16] Add method to validate TTL --- phpmd.xml | 1 + src/Cache.php | 21 +++++++++++++++------ tests/TestCase.php | 7 +++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/phpmd.xml b/phpmd.xml index 16baad8..dc5a529 100644 --- a/phpmd.xml +++ b/phpmd.xml @@ -2,6 +2,7 @@ + diff --git a/src/Cache.php b/src/Cache.php index a79da37..bd69b84 100644 --- a/src/Cache.php +++ b/src/Cache.php @@ -187,15 +187,22 @@ public function getDefaultTtl() : int */ public function setDefaultTtl(int $seconds) : static { - if ($seconds < 1) { - throw new InvalidArgumentException( - 'Default TTL must be greater than 0. ' . $seconds . ' given' - ); - } + $this->validateTtl($seconds, true); $this->defaultTtl = $seconds; return $this; } + protected function validateTtl(?int $seconds, bool $isDefault = false) : void + { + if ($seconds < 1) { + $message = 'TTL must be greater than 0. ' . $seconds . ' given'; + if ($isDefault) { + $message = 'Default ' . $message; + } + throw new InvalidArgumentException($message); + } + } + /** * Make the Time To Live value. * @@ -206,7 +213,9 @@ public function setDefaultTtl(int $seconds) : static #[Pure] protected function makeTtl(?int $seconds) : int { - return $seconds ?? $this->getDefaultTtl(); + $seconds ??= $this->getDefaultTtl(); + $this->validateTtl($seconds); + return $seconds; } /** diff --git a/tests/TestCase.php b/tests/TestCase.php index 00d8420..cbb7e4d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -271,4 +271,11 @@ public function __destruct() $cache->setDebugCollector($collector); self::assertStringContainsString('@anonymous', $collector->getHandler()); } + + public function testInvalidTtl() : void + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('TTL must be greater than 0. -2 given'); + $this->cache->set('foo', 'bar', -2); + } } From 949a97087f80fe25810cc9669fe061c001efc144 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Mon, 2 Mar 2026 19:02:29 -0300 Subject: [PATCH 04/16] Add Cache::isDebugging method --- src/ApcuCache.php | 8 ++++---- src/Cache.php | 10 ++++++++++ src/FilesCache.php | 8 ++++---- src/MemcachedCache.php | 8 ++++---- src/RedisCache.php | 8 ++++---- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/ApcuCache.php b/src/ApcuCache.php index 4b51872..5e3350b 100644 --- a/src/ApcuCache.php +++ b/src/ApcuCache.php @@ -29,7 +29,7 @@ protected function initialize() : void public function get(string $key) : mixed { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugGet( $key, @@ -50,7 +50,7 @@ protected function getValue(string $key) : mixed public function set(string $key, mixed $value, ?int $ttl = null) : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugSet( $key, @@ -73,7 +73,7 @@ public function set(string $key, mixed $value, ?int $ttl = null) : bool public function delete(string $key) : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugDelete( $key, @@ -86,7 +86,7 @@ public function delete(string $key) : bool public function flush() : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugFlush( $start, diff --git a/src/Cache.php b/src/Cache.php index bd69b84..ec14793 100644 --- a/src/Cache.php +++ b/src/Cache.php @@ -466,4 +466,14 @@ protected function addDebugFlush(float $start, bool $status) : bool ]); return $status; } + + /** + * Tell if the cache driver is in debug mode. + * + * @return bool + */ + public function isDebugging() : bool + { + return isset($this->debugCollector); + } } diff --git a/src/FilesCache.php b/src/FilesCache.php index 5157983..2397fab 100644 --- a/src/FilesCache.php +++ b/src/FilesCache.php @@ -107,7 +107,7 @@ protected function setBaseDirectory() : void public function get(string $key) : mixed { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugGet( $key, @@ -156,7 +156,7 @@ protected function createSubDirectory(string $filepath) : void public function set(string $key, mixed $value, ?int $ttl = null) : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugSet( $key, @@ -192,7 +192,7 @@ public function setValue(string $key, mixed $value, ?int $ttl = null) : bool public function delete(string $key) : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugDelete( $key, @@ -205,7 +205,7 @@ public function delete(string $key) : bool public function flush() : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugFlush( $start, diff --git a/src/MemcachedCache.php b/src/MemcachedCache.php index 91c4523..e66aba7 100644 --- a/src/MemcachedCache.php +++ b/src/MemcachedCache.php @@ -112,7 +112,7 @@ public function getMemcached() : ?Memcached public function get(string $key) : mixed { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugGet( $key, @@ -133,7 +133,7 @@ protected function getValue(string $key) : mixed public function set(string $key, mixed $value, ?int $ttl = null) : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugSet( $key, @@ -148,7 +148,7 @@ public function set(string $key, mixed $value, ?int $ttl = null) : bool public function delete(string $key) : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugDelete( $key, @@ -161,7 +161,7 @@ public function delete(string $key) : bool public function flush() : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugFlush( $start, diff --git a/src/RedisCache.php b/src/RedisCache.php index bafef71..ffbf740 100644 --- a/src/RedisCache.php +++ b/src/RedisCache.php @@ -108,7 +108,7 @@ public function getRedis() : ?Redis public function get(string $key) : mixed { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugGet( $key, @@ -130,7 +130,7 @@ protected function getValue(string $key) : mixed public function set(string $key, mixed $value, ?int $ttl = null) : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugSet( $key, @@ -153,7 +153,7 @@ public function set(string $key, mixed $value, ?int $ttl = null) : bool public function delete(string $key) : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugDelete( $key, @@ -166,7 +166,7 @@ public function delete(string $key) : bool public function flush() : bool { - if (isset($this->debugCollector)) { + if ($this->isDebugging()) { $start = \microtime(true); return $this->addDebugFlush( $start, From 48e3603131c005e70e1858e5d0e3014c472e32e7 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Mon, 2 Mar 2026 23:00:54 -0300 Subject: [PATCH 05/16] Remove parentheses --- .php-cs-fixer.dist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index d48ec68..c63ccba 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -10,7 +10,7 @@ use Framework\CodingStandard\Config; use Framework\CodingStandard\Finder; -return (new Config())->setDefaultHeaderComment( +return new Config()->setDefaultHeaderComment( 'Aplus Framework Cache Library', 'Natan Felles ' )->setFinder( From 962183fcab273cdfd84e82c2dacdd48ff4c4d9a4 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Mon, 2 Mar 2026 23:11:55 -0300 Subject: [PATCH 06/16] Add since tags --- src/Cache.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Cache.php b/src/Cache.php index ec14793..d67d5fe 100644 --- a/src/Cache.php +++ b/src/Cache.php @@ -192,6 +192,14 @@ public function setDefaultTtl(int $seconds) : static return $this; } + /** + * Validate TTL. + * + * @since 5 + * + * @param int|null $seconds + * @param bool $isDefault + */ protected function validateTtl(?int $seconds, bool $isDefault = false) : void { if ($seconds < 1) { @@ -470,6 +478,8 @@ protected function addDebugFlush(float $start, bool $status) : bool /** * Tell if the cache driver is in debug mode. * + * @since 5 + * * @return bool */ public function isDebugging() : bool From be86989ed3176e3e06641c843e11140605c1ffe2 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Mon, 23 Mar 2026 15:25:24 -0300 Subject: [PATCH 07/16] Remove obsolete attribute 'version' --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index fde0801..87b7c87 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: "3" services: package: image: registry.gitlab.com/aplus-framework/images/package:6 From 2c63b1db8537c8cba45d0f4f1fc36f8d7504d0d6 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Mon, 23 Mar 2026 15:26:09 -0300 Subject: [PATCH 08/16] Use Checkout v6 --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1749112..b4ac8d9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,7 +26,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -90,7 +90,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 From d8044d4869446749ab2b2bb462c38a75bd1eb267 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Wed, 22 Apr 2026 14:08:20 -0300 Subject: [PATCH 09/16] Fix coding standard --- tests/TestCase.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index cbb7e4d..09917c9 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -242,7 +242,8 @@ public function testDebugRunCommands() : void public function testDebugHandler() : void { - $collector = new class() extends CacheCollector { + $collector = new class() extends CacheCollector + { public function getHandler() : string { return parent::getHandler(); @@ -257,7 +258,8 @@ public function getHandler() : string RedisCache::class => 'redis', }; self::assertSame($handler, $collector->getHandler()); - $cache = new class() extends FilesCache { + $cache = new class() extends FilesCache + { protected Serializer $serializer = Serializer::PHP; public function __construct() From 8c158e8382fed1ab6f82542519f75524d9b574d9 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Wed, 19 Aug 2026 16:35:51 -0300 Subject: [PATCH 10/16] Upgrade PHPStan --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 83cb793..0b64d96 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "ergebnis/composer-normalize": "^2.25", "jetbrains/phpstorm-attributes": "^1.0", "phpmd/phpmd": "^2.13", - "phpstan/phpstan": "^1.9", + "phpstan/phpstan": "^2.2", "phpunit/phpunit": "^10.5" }, "minimum-stability": "dev", From 39798e44110221ec1aaac529fb6be4c416d36b70 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Mon, 24 Aug 2026 19:30:25 -0300 Subject: [PATCH 11/16] Update exception message --- src/FilesCache.php | 2 +- tests/FilesCacheTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FilesCache.php b/src/FilesCache.php index 2397fab..88bdfe0 100644 --- a/src/FilesCache.php +++ b/src/FilesCache.php @@ -94,7 +94,7 @@ protected function setBaseDirectory() : void } if (!\is_dir($real)) { throw new RuntimeException( - "Invalid cache directory path: {$real}" + "Cache directory does not exist: {$real}" ); } if (!\is_writable($real)) { diff --git a/tests/FilesCacheTest.php b/tests/FilesCacheTest.php index c0a8b8d..f80cced 100644 --- a/tests/FilesCacheTest.php +++ b/tests/FilesCacheTest.php @@ -81,7 +81,7 @@ public function testInvalidCacheDirectoryPath() : void $this->prefix = 'foo'; $this->expectException(\RuntimeException::class); $this->expectExceptionMessage( - "Invalid cache directory path: {$this->configs['directory']}{$this->prefix}" + "Cache directory does not exist: {$this->configs['directory']}{$this->prefix}" ); new FilesCache($this->configs, $this->prefix, $this->serializer); } From 1ae452afff3caac565696e24ac36d19da229e031 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Sat, 29 Aug 2026 21:27:15 -0300 Subject: [PATCH 12/16] Use Debugger::esc function --- src/Debug/CacheCollector.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Debug/CacheCollector.php b/src/Debug/CacheCollector.php index 9d001e5..cfd84d7 100644 --- a/src/Debug/CacheCollector.php +++ b/src/Debug/CacheCollector.php @@ -14,7 +14,7 @@ use Framework\Cache\MemcachedCache; use Framework\Cache\RedisCache; use Framework\Debug\Collector; -use Framework\Debug\Debugger; +use Framework\Debug\Debugger as D; /** * Class CacheCollector. @@ -61,17 +61,17 @@ public function getContents() : string } \ob_start(); ?>

Handler: - getHandler()) ?> + getHandler()) ?>

info['prefix'])) : ?>

Keys Prefix: - info['prefix']) ?> + info['prefix']) ?>

Serializer: - getSerializer()) ?> + getSerializer()) ?>

Commands

getData() as $index => $data): ?> - + - + - + -
+
- + - + @@ -143,7 +143,7 @@ protected function getCommandsTime() : float $total = $data['end'] - $data['start']; $time += $total; } - return Debugger::roundSecondsToMilliseconds($time); + return D::roundSecondsToMilliseconds($time); } protected function getHandler() : string From 580baca899ffabf5db0bb4765b892810ffa679dd Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Thu, 17 Sep 2026 17:36:12 -0300 Subject: [PATCH 13/16] Add array shapes --- src/FilesCache.php | 12 ++++++++++-- src/MemcachedCache.php | 18 ++++++++++++++++-- src/RedisCache.php | 16 ++++++++++++++-- tests/MemcachedCacheMultiServerTest.php | 4 ++-- tests/MemcachedCacheTest.php | 2 +- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/FilesCache.php b/src/FilesCache.php index 88bdfe0..31946a7 100644 --- a/src/FilesCache.php +++ b/src/FilesCache.php @@ -25,7 +25,11 @@ class FilesCache extends Cache /** * Files Cache handler configurations. * - * @var array + * @var array{ + * directory: string|null, + * files_permission: int, + * gc: int, + * } */ protected array $configs = [ 'directory' => null, @@ -40,7 +44,11 @@ class FilesCache extends Cache /** * FilesCache constructor. * - * @param array|null $configs Driver specific configurations + * @param array{ + * directory?: string|null, + * files_permission?: int, + * gc?: int, + * }|null $configs Driver specific configurations * @param string|null $prefix Keys prefix * @param Serializer|string $serializer Data serializer * @param Logger|null $logger Logger instance diff --git a/src/MemcachedCache.php b/src/MemcachedCache.php index e66aba7..c7b315b 100644 --- a/src/MemcachedCache.php +++ b/src/MemcachedCache.php @@ -28,7 +28,14 @@ class MemcachedCache extends Cache /** * Memcached Cache handler configurations. * - * @var array + * @var array{ + * servers: array, + * options: array, + * } */ protected array $configs = [ 'servers' => [ @@ -46,7 +53,14 @@ class MemcachedCache extends Cache /** * MemcachedCache constructor. * - * @param Memcached|array|null $configs Driver specific + * @param Memcached|array{ + * servers?: array, + * options?: array, + * }|null $configs Driver specific * configurations. Set null to not initialize or a custom Memcached object. * @param string|null $prefix Keys prefix * @param Serializer|string $serializer Data serializer diff --git a/src/RedisCache.php b/src/RedisCache.php index ffbf740..0b91b73 100644 --- a/src/RedisCache.php +++ b/src/RedisCache.php @@ -25,7 +25,13 @@ class RedisCache extends Cache /** * Redis Cache handler configurations. * - * @var array + * @var array{ + * host: string, + * port: int, + * timeout: float, + * password: mixed, + * database: int|null, + * } */ protected array $configs = [ 'host' => '127.0.0.1', @@ -38,7 +44,13 @@ class RedisCache extends Cache /** * RedisCache constructor. * - * @param Redis|array|null $configs Driver specific + * @param Redis|array{ + * host?: string, + * port?: int, + * timeout?: float, + * password?: mixed, + * database?: int|null, + * }|null $configs Driver specific * configurations. Set null to not initialize or a custom Redis object. * @param string|null $prefix Keys prefix * @param Serializer|string $serializer Data serializer diff --git a/tests/MemcachedCacheMultiServerTest.php b/tests/MemcachedCacheMultiServerTest.php index e1aa519..0677b15 100644 --- a/tests/MemcachedCacheMultiServerTest.php +++ b/tests/MemcachedCacheMultiServerTest.php @@ -46,10 +46,10 @@ public function testHostInPool() : void $configs = [ 'servers' => [ [ - 'host' => \getenv('MEMCACHED_HOST'), + 'host' => (string) \getenv('MEMCACHED_HOST'), ], [ - 'host' => \getenv('MEMCACHED_HOST'), + 'host' => (string) \getenv('MEMCACHED_HOST'), ], ], ]; diff --git a/tests/MemcachedCacheTest.php b/tests/MemcachedCacheTest.php index 3bbec2d..c363801 100644 --- a/tests/MemcachedCacheTest.php +++ b/tests/MemcachedCacheTest.php @@ -18,7 +18,7 @@ public function setUp() : void $this->configs = [ 'servers' => [ [ - 'host' => \getenv('MEMCACHED_HOST'), + 'host' => (string) \getenv('MEMCACHED_HOST'), ], ], ]; From 8c6ce0fb53fa0fed9fd353873e948ef1973fec2c Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Thu, 17 Sep 2026 17:46:37 -0300 Subject: [PATCH 14/16] Rename RedisCache options --- src/RedisCache.php | 20 ++++++++++---------- tests/RedisCacheTest.php | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/RedisCache.php b/src/RedisCache.php index 0b91b73..11389b2 100644 --- a/src/RedisCache.php +++ b/src/RedisCache.php @@ -29,16 +29,16 @@ class RedisCache extends Cache * host: string, * port: int, * timeout: float, - * password: mixed, - * database: int|null, + * credentials: mixed, + * db: int|null, * } */ protected array $configs = [ 'host' => '127.0.0.1', 'port' => 6379, 'timeout' => 0.0, - 'password' => null, - 'database' => null, + 'credentials' => null, + 'db' => null, ]; /** @@ -48,8 +48,8 @@ class RedisCache extends Cache * host?: string, * port?: int, * timeout?: float, - * password?: mixed, - * database?: int|null, + * credentials?: mixed, + * db?: int|null, * }|null $configs Driver specific * configurations. Set null to not initialize or a custom Redis object. * @param string|null $prefix Keys prefix @@ -83,11 +83,11 @@ protected function connect() : void $this->configs['port'], $this->configs['timeout'] ); - if (isset($this->configs['password'])) { - $this->redis->auth($this->configs['password']); + if (isset($this->configs['credentials'])) { + $this->redis->auth($this->configs['credentials']); } - if (isset($this->configs['database'])) { - $this->redis->select($this->configs['database']); + if (isset($this->configs['db'])) { + $this->redis->select($this->configs['db']); } } diff --git a/tests/RedisCacheTest.php b/tests/RedisCacheTest.php index 059e5ae..538c24c 100644 --- a/tests/RedisCacheTest.php +++ b/tests/RedisCacheTest.php @@ -55,7 +55,7 @@ public function testAuth() : void { $this->configs = [ 'host' => \getenv('REDIS_HOST'), - 'password' => 'foo', + 'credentials' => 'foo', ]; $this->expectException(\RedisException::class); $this->setCache(); @@ -65,7 +65,7 @@ public function testSelect() : void { $this->configs = [ 'host' => \getenv('REDIS_HOST'), - 'database' => 0, + 'db' => 0, ]; $this->setCache(); self::assertInstanceOf(RedisCache::class, $this->cache); From ea7efeaab3cae59be4e5ed33cd6b521da3784b41 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Thu, 17 Sep 2026 17:54:58 -0300 Subject: [PATCH 15/16] Update phpdocs --- src/RedisCache.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RedisCache.php b/src/RedisCache.php index 11389b2..453c165 100644 --- a/src/RedisCache.php +++ b/src/RedisCache.php @@ -29,7 +29,7 @@ class RedisCache extends Cache * host: string, * port: int, * timeout: float, - * credentials: mixed, + * credentials: array|string|null, * db: int|null, * } */ @@ -48,7 +48,7 @@ class RedisCache extends Cache * host?: string, * port?: int, * timeout?: float, - * credentials?: mixed, + * credentials?: array|string|null, * db?: int|null, * }|null $configs Driver specific * configurations. Set null to not initialize or a custom Redis object. From 1049e4197fa2555b9dd96c7df92558ad0cd16d75 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Thu, 17 Sep 2026 17:58:40 -0300 Subject: [PATCH 16/16] Update user guide --- guide/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guide/index.rst b/guide/index.rst index 8a849ae..6de6e27 100644 --- a/guide/index.rst +++ b/guide/index.rst @@ -244,8 +244,8 @@ If it is necessary to define another address, do as in the example below: 'host' => '192.168.1.100', 'port' => 6379, 'timeout' => 0.0, - 'password' => null, - 'database' => null, + 'credentials' => null, + 'db' => null, ]; $cache = new RedisCache($configs);