diff --git a/composer.json b/composer.json index 017c52e..02361b8 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ }, "require-dev": { "ext-xdebug": "*", - "aplus/coding-standard": "^2.0", + "aplus/coding-standard": "^2.8", "ergebnis/composer-normalize": "^2.25", "jetbrains/phpstorm-attributes": "^1.0", "phpmd/phpmd": "^2.13", diff --git a/src/Cache.php b/src/Cache.php index c73cbd9..c7f1957 100644 --- a/src/Cache.php +++ b/src/Cache.php @@ -69,9 +69,9 @@ abstract class Cache public function __construct( #[SensitiveParameter] ?array $configs = [], - string $prefix = null, + ?string $prefix = null, Serializer | string $serializer = Serializer::PHP, - Logger $logger = null + ?Logger $logger = null ) { $this->prefix = $prefix; if (\is_string($serializer)) { @@ -179,7 +179,7 @@ public function getMulti(array $keys) : array * * @return bool TRUE if the item was set, FALSE if fail to set */ - abstract public function set(string $key, mixed $value, int $ttl = null) : bool; + abstract public function set(string $key, mixed $value, ?int $ttl = null) : bool; /** * Sets multi items to the cache storage. @@ -189,7 +189,7 @@ abstract public function set(string $key, mixed $value, int $ttl = null) : bool; * * @return array associative array with key names and respective set status */ - public function setMulti(array $data, int $ttl = null) : array + public function setMulti(array $data, ?int $ttl = null) : array { foreach ($data as $key => &$value) { $value = $this->set($key, $value, $ttl); @@ -238,7 +238,7 @@ abstract public function flush() : bool; * * @return int The current item value */ - public function increment(string $key, int $offset = 1, int $ttl = null) : int + public function increment(string $key, int $offset = 1, ?int $ttl = null) : int { $offset = (int) \abs($offset); $value = (int) $this->get($key); @@ -256,7 +256,7 @@ public function increment(string $key, int $offset = 1, int $ttl = null) : int * * @return int The current item value */ - public function decrement(string $key, int $offset = 1, int $ttl = null) : int + public function decrement(string $key, int $offset = 1, ?int $ttl = null) : int { $offset = (int) \abs($offset); $value = (int) $this->get($key); diff --git a/src/FilesCache.php b/src/FilesCache.php index 716703c..03d5a90 100644 --- a/src/FilesCache.php +++ b/src/FilesCache.php @@ -133,7 +133,7 @@ protected function createSubDirectory(string $filepath) : void } } - public function set(string $key, mixed $value, int $ttl = null) : bool + public function set(string $key, mixed $value, ?int $ttl = null) : bool { if (isset($this->debugCollector)) { $start = \microtime(true); @@ -148,7 +148,7 @@ public function set(string $key, mixed $value, int $ttl = null) : bool return $this->setValue($key, $value, $ttl); } - public function setValue(string $key, mixed $value, int $ttl = null) : bool + public function setValue(string $key, mixed $value, ?int $ttl = null) : bool { $filepath = $this->renderFilepath($key); $this->createSubDirectory($filepath); diff --git a/src/MemcachedCache.php b/src/MemcachedCache.php index 9c71391..c8e88c4 100644 --- a/src/MemcachedCache.php +++ b/src/MemcachedCache.php @@ -110,7 +110,7 @@ protected function getValue(string $key) : mixed : $key; } - public function set(string $key, mixed $value, int $ttl = null) : bool + public function set(string $key, mixed $value, ?int $ttl = null) : bool { if (isset($this->debugCollector)) { $start = \microtime(true); diff --git a/src/RedisCache.php b/src/RedisCache.php index 840ff7d..e7403fe 100644 --- a/src/RedisCache.php +++ b/src/RedisCache.php @@ -107,7 +107,7 @@ protected function getValue(string $key) : mixed return $this->unserialize($value); } - public function set(string $key, mixed $value, int $ttl = null) : bool + public function set(string $key, mixed $value, ?int $ttl = null) : bool { if (isset($this->debugCollector)) { $start = \microtime(true); diff --git a/tests/CacheMock.php b/tests/CacheMock.php index a847fa2..36028cc 100644 --- a/tests/CacheMock.php +++ b/tests/CacheMock.php @@ -23,7 +23,7 @@ public function get(string $key) : mixed return 1; } - public function set(string $key, mixed $value, int $ttl = null) : bool + public function set(string $key, mixed $value, ?int $ttl = null) : bool { return true; }