diff --git a/src/Service/Cache.php b/src/Service/Cache.php index 35b9ebd..b7fcf37 100644 --- a/src/Service/Cache.php +++ b/src/Service/Cache.php @@ -155,7 +155,7 @@ abstract protected function getMandatoryConfig(): array; * @param int|float|string|Cacheable $val value to be serialised * @return int|float|string|array value serialized */ - final protected function serializeVal(int|float|string|Cacheable $val): int|float|string|array + final protected function serializeVal(int|float|string|Cacheable|null $val): int|float|string|array|null { if ($val instanceof Cacheable) { return ['__cacheable' => 1, '__class' => $val::class, '__data' => $val->serialize()]; diff --git a/tests/AbstractCache.php b/tests/AbstractCache.php index 66a07bc..27bd4ae 100644 --- a/tests/AbstractCache.php +++ b/tests/AbstractCache.php @@ -15,9 +15,7 @@ */ abstract class AbstractCache extends TestCase { - private ?Cache $cache = null; - private ?Foo $foo = null; public final function setCache(?Cache $cache): void @@ -80,7 +78,7 @@ public function testString(): void public function testArray(): void { - $x = [1, 2, 3]; + $x = [1, 2, 3, null]; $key = 'test_array'; $res = $this->cache->set($key, $x); $this->assertTrue($res); @@ -149,7 +147,7 @@ public function testClearAllCache(): void public function testEmptyIncrement(): void { - $key="test_empty_increment"; + $key = "test_empty_increment"; $expected = 1; $actual = $this->cache->increment($key); $this->assertEquals($expected, $actual); @@ -157,7 +155,7 @@ public function testEmptyIncrement(): void public function testEmptyDecrement(): void { - $key="test_empty_decrement"; + $key = "test_empty_decrement"; $expected = -1; $actual = $this->cache->decrement($key); $this->assertEquals($expected, $actual); @@ -189,4 +187,4 @@ public final function getCache(): ?Cache { return $this->cache; } -} +} \ No newline at end of file