From: Philipp Date: Wed, 26 Jul 2023 20:42:40 +0000 (+0200) Subject: Rename NAME to constant X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9ff89a970a87582520e2051230da04c7e7a93de6;p=friendica.git Rename NAME to constant --- diff --git a/src/Core/Cache/Factory/Cache.php b/src/Core/Cache/Factory/Cache.php index 02cdb1a79e..000233df7f 100644 --- a/src/Core/Cache/Factory/Cache.php +++ b/src/Core/Cache/Factory/Cache.php @@ -69,7 +69,7 @@ class Cache */ public function createDistributed(string $type = null): ICanCache { - if ($type === Type\APCuCache::$NAME) { + if ($type === Type\APCuCache::NAME) { throw new InvalidCacheDriverException('apcu doesn\'t support distributed caching.'); } diff --git a/src/Core/Cache/Type/APCuCache.php b/src/Core/Cache/Type/APCuCache.php index 02b2d0fbdb..f35815c15a 100644 --- a/src/Core/Cache/Type/APCuCache.php +++ b/src/Core/Cache/Type/APCuCache.php @@ -30,7 +30,7 @@ use Friendica\Core\Cache\Exception\InvalidCacheDriverException; */ class APCuCache extends AbstractCache implements ICanCacheInMemory { - public static $NAME = 'apcu'; + const NAME = 'apcu'; use CompareSetTrait; use CompareDeleteTrait; diff --git a/src/Core/Cache/Type/AbstractCache.php b/src/Core/Cache/Type/AbstractCache.php index 36e301ad20..211f28b9a6 100644 --- a/src/Core/Cache/Type/AbstractCache.php +++ b/src/Core/Cache/Type/AbstractCache.php @@ -28,7 +28,7 @@ use Friendica\Core\Cache\Capability\ICanCache; */ abstract class AbstractCache implements ICanCache { - public static $NAME = ''; + const NAME = ''; /** * @var string The hostname @@ -111,6 +111,6 @@ abstract class AbstractCache implements ICanCache /** {@inheritDoc} */ public function getName(): string { - return static::$NAME; + return static::NAME; } } diff --git a/src/Core/Cache/Type/ArrayCache.php b/src/Core/Cache/Type/ArrayCache.php index ad87eaf23a..34246afffa 100644 --- a/src/Core/Cache/Type/ArrayCache.php +++ b/src/Core/Cache/Type/ArrayCache.php @@ -29,7 +29,7 @@ use Friendica\Core\Cache\Enum; */ class ArrayCache extends AbstractCache implements ICanCacheInMemory { - public static $NAME = 'array'; + const NAME = 'array'; use CompareDeleteTrait; diff --git a/src/Core/Cache/Type/DatabaseCache.php b/src/Core/Cache/Type/DatabaseCache.php index 18541e0d2b..4959d6a751 100644 --- a/src/Core/Cache/Type/DatabaseCache.php +++ b/src/Core/Cache/Type/DatabaseCache.php @@ -32,7 +32,7 @@ use Friendica\Util\DateTimeFormat; */ class DatabaseCache extends AbstractCache implements ICanCache { - public static $NAME = 'database'; + const NAME = 'database'; /** * @var Database diff --git a/src/Core/Cache/Type/MemcacheCache.php b/src/Core/Cache/Type/MemcacheCache.php index 09394a1dd3..fccaff6c00 100644 --- a/src/Core/Cache/Type/MemcacheCache.php +++ b/src/Core/Cache/Type/MemcacheCache.php @@ -33,7 +33,7 @@ use Memcache; */ class MemcacheCache extends AbstractCache implements ICanCacheInMemory { - static $NAME = 'memcached'; + const NAME = 'memcached'; use CompareSetTrait; use CompareDeleteTrait; diff --git a/src/Core/Cache/Type/MemcachedCache.php b/src/Core/Cache/Type/MemcachedCache.php index 45a7a0f1c1..160c5a16f4 100644 --- a/src/Core/Cache/Type/MemcachedCache.php +++ b/src/Core/Cache/Type/MemcachedCache.php @@ -34,7 +34,7 @@ use Psr\Log\LoggerInterface; */ class MemcachedCache extends AbstractCache implements ICanCacheInMemory { - static $NAME = 'memcached'; + const NAME = 'memcached'; use CompareSetTrait; use CompareDeleteTrait; diff --git a/src/Core/Cache/Type/RedisCache.php b/src/Core/Cache/Type/RedisCache.php index 36c60a12c1..be2a7ff080 100644 --- a/src/Core/Cache/Type/RedisCache.php +++ b/src/Core/Cache/Type/RedisCache.php @@ -33,7 +33,7 @@ use Redis; */ class RedisCache extends AbstractCache implements ICanCacheInMemory { - public static $NAME = 'redis'; + const NAME = 'redis'; /** * @var Redis diff --git a/tests/src/Core/Cache/CacheTest.php b/tests/src/Core/Cache/CacheTest.php index dbcc56e228..775a29374c 100644 --- a/tests/src/Core/Cache/CacheTest.php +++ b/tests/src/Core/Cache/CacheTest.php @@ -250,8 +250,8 @@ abstract class CacheTest extends MockedTest public function testGetName() { - if (property_exists($this->instance, '$NAME')) { - self::assertEquals($this->instance::$NAME, $this->instance->getName()); + if (defined(get_class($this->instance) . '::NAME')) { + self::assertEquals($this->instance::NAME, $this->instance->getName()); } else { self::expectNotToPerformAssertions(); }