Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/Service/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()];
Expand Down
10 changes: 4 additions & 6 deletions tests/AbstractCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
*/
abstract class AbstractCache extends TestCase
{

private ?Cache $cache = null;

private ?Foo $foo = null;

public final function setCache(?Cache $cache): void
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -149,15 +147,15 @@ 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);
}

public function testEmptyDecrement(): void
{
$key="test_empty_decrement";
$key = "test_empty_decrement";
$expected = -1;
$actual = $this->cache->decrement($key);
$this->assertEquals($expected, $actual);
Expand Down Expand Up @@ -189,4 +187,4 @@ public final function getCache(): ?Cache
{
return $this->cache;
}
}
}