Voidify methods with no side effects
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
af9d68a58b
commit
aeefbf8f3e
@ -20,11 +20,9 @@ class Cache
|
||||
* @param string $cacheKey The key to use
|
||||
* @param mixed $value The value to cache
|
||||
*/
|
||||
public static function set(string $cacheKey, $value): bool
|
||||
public static function set(string $cacheKey, $value): void
|
||||
{
|
||||
self::$cacheData[$cacheKey] = $value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,20 +53,16 @@ class Cache
|
||||
*
|
||||
* @param string $cacheKey The key to use to remove the value
|
||||
*/
|
||||
public static function remove(string $cacheKey): bool
|
||||
public static function remove(string $cacheKey): void
|
||||
{
|
||||
unset(self::$cacheData[$cacheKey]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge all cached values
|
||||
*/
|
||||
public static function purge(): bool
|
||||
public static function purge(): void
|
||||
{
|
||||
self::$cacheData = [];
|
||||
|
||||
return self::$cacheData === [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,11 +95,6 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/BrowseForeigners.php
|
||||
|
||||
-
|
||||
message: "#^Strict comparison using \\=\\=\\= between array\\{\\} and array\\{\\} will always evaluate to true\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Cache.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$state of static method PhpMyAdmin\\\\Charsets\\\\Charset\\:\\:fromServer\\(\\) expects array\\{Charset\\?\\: string, Description\\?\\: string, Default collation\\?\\: string, Maxlen\\?\\: string\\}, array\\<string, string\\|null\\> given\\.$#"
|
||||
count: 1
|
||||
|
||||
@ -46,9 +46,9 @@ class CacheTest extends AbstractTestCase
|
||||
public function testCacheHas(string $cacheKey, $valueToCache): void
|
||||
{
|
||||
$this->assertFalse(Cache::has($cacheKey));
|
||||
$this->assertTrue(Cache::set($cacheKey, $valueToCache));
|
||||
Cache::set($cacheKey, $valueToCache);
|
||||
$this->assertTrue(Cache::has($cacheKey));
|
||||
$this->assertTrue(Cache::remove($cacheKey));
|
||||
Cache::remove($cacheKey);
|
||||
$this->assertFalse(Cache::has($cacheKey));
|
||||
}
|
||||
|
||||
@ -60,9 +60,9 @@ class CacheTest extends AbstractTestCase
|
||||
public function testCachePurge(string $cacheKey, $valueToCache): void
|
||||
{
|
||||
$this->assertFalse(Cache::has($cacheKey));
|
||||
$this->assertTrue(Cache::set($cacheKey, $valueToCache));
|
||||
Cache::set($cacheKey, $valueToCache);
|
||||
$this->assertTrue(Cache::has($cacheKey));
|
||||
$this->assertTrue(Cache::purge());
|
||||
Cache::purge();
|
||||
$this->assertFalse(Cache::has($cacheKey));
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ class CacheTest extends AbstractTestCase
|
||||
public function testCacheSet(string $cacheKey, $valueToCache): void
|
||||
{
|
||||
$this->assertFalse(Cache::has($cacheKey));
|
||||
$this->assertTrue(Cache::set($cacheKey, $valueToCache));
|
||||
Cache::set($cacheKey, $valueToCache);
|
||||
$this->assertTrue(Cache::has($cacheKey));
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class CacheTest extends AbstractTestCase
|
||||
public function testCacheGet(string $cacheKey, $valueToCache): void
|
||||
{
|
||||
$this->assertFalse(Cache::has($cacheKey));
|
||||
$this->assertTrue(Cache::set($cacheKey, $valueToCache));
|
||||
Cache::set($cacheKey, $valueToCache);
|
||||
$this->assertTrue(Cache::has($cacheKey));
|
||||
$this->assertSame(Cache::get($cacheKey), $valueToCache);
|
||||
}
|
||||
@ -99,10 +99,10 @@ class CacheTest extends AbstractTestCase
|
||||
public function testCacheGetDefaultValue(string $cacheKey, $valueToCache): void
|
||||
{
|
||||
$this->assertFalse(Cache::has($cacheKey));
|
||||
$this->assertTrue(Cache::set($cacheKey, $valueToCache));
|
||||
Cache::set($cacheKey, $valueToCache);
|
||||
$this->assertTrue(Cache::has($cacheKey));
|
||||
$this->assertSame(Cache::get($cacheKey, null), $valueToCache);
|
||||
$this->assertTrue(Cache::remove($cacheKey));
|
||||
Cache::remove($cacheKey);
|
||||
$this->assertFalse(Cache::has($cacheKey));
|
||||
$this->assertNull(Cache::get($cacheKey, null));
|
||||
$defaultValue = new stdClass();
|
||||
@ -118,9 +118,9 @@ class CacheTest extends AbstractTestCase
|
||||
public function testCacheRemove(string $cacheKey, $valueToCache): void
|
||||
{
|
||||
$this->assertFalse(Cache::has($cacheKey));
|
||||
$this->assertTrue(Cache::set($cacheKey, $valueToCache));
|
||||
Cache::set($cacheKey, $valueToCache);
|
||||
$this->assertTrue(Cache::has($cacheKey));
|
||||
$this->assertTrue(Cache::remove($cacheKey));
|
||||
Cache::remove($cacheKey);
|
||||
$this->assertFalse(Cache::has($cacheKey));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user