Rename NAME to constant
authorPhilipp <admin@philipp.info>
Wed, 26 Jul 2023 20:42:40 +0000 (22:42 +0200)
committerPhilipp <admin@philipp.info>
Fri, 28 Jul 2023 15:39:12 +0000 (17:39 +0200)
src/Core/Cache/Factory/Cache.php
src/Core/Cache/Type/APCuCache.php
src/Core/Cache/Type/AbstractCache.php
src/Core/Cache/Type/ArrayCache.php
src/Core/Cache/Type/DatabaseCache.php
src/Core/Cache/Type/MemcacheCache.php
src/Core/Cache/Type/MemcachedCache.php
src/Core/Cache/Type/RedisCache.php
tests/src/Core/Cache/CacheTest.php

index 02cdb1a..000233d 100644 (file)
@@ -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.');
                }
 
index 02b2d0f..f35815c 100644 (file)
@@ -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;
index 36e301a..211f28b 100644 (file)
@@ -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;
        }
 }
index ad87eaf..34246af 100644 (file)
@@ -29,7 +29,7 @@ use Friendica\Core\Cache\Enum;
  */
 class ArrayCache extends AbstractCache implements ICanCacheInMemory
 {
-       public static $NAME = 'array';
+       const NAME = 'array';
 
        use CompareDeleteTrait;
 
index 18541e0..4959d6a 100644 (file)
@@ -32,7 +32,7 @@ use Friendica\Util\DateTimeFormat;
  */
 class DatabaseCache extends AbstractCache implements ICanCache
 {
-       public static $NAME = 'database';
+       const NAME = 'database';
 
        /**
         * @var Database
index 09394a1..fccaff6 100644 (file)
@@ -33,7 +33,7 @@ use Memcache;
  */
 class MemcacheCache extends AbstractCache implements ICanCacheInMemory
 {
-       static $NAME = 'memcached';
+       const NAME = 'memcached';
 
        use CompareSetTrait;
        use CompareDeleteTrait;
index 45a7a0f..160c5a1 100644 (file)
@@ -34,7 +34,7 @@ use Psr\Log\LoggerInterface;
  */
 class MemcachedCache extends AbstractCache implements ICanCacheInMemory
 {
-       static $NAME = 'memcached';
+       const NAME = 'memcached';
 
        use CompareSetTrait;
        use CompareDeleteTrait;
index 36c60a1..be2a7ff 100644 (file)
@@ -33,7 +33,7 @@ use Redis;
  */
 class RedisCache extends AbstractCache implements ICanCacheInMemory
 {
-       public static $NAME = 'redis';
+       const NAME = 'redis';
 
        /**
         * @var Redis
index dbcc56e..775a293 100644 (file)
@@ -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();
                }