From 0347417a0cc09b100971513f949c131f1812fdad Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 3 Nov 2024 15:38:44 +0700 Subject: [PATCH] Update to use PHP 8.1 syntax Signed-off-by: Abdul Malik Ikhsan --- src/Pattern/ObjectCache.php | 4 ++-- src/Psr/CacheItemPool/CacheItem.php | 4 ++-- src/Service/StorageAdapterFactory.php | 4 ++-- src/Service/StoragePluginFactory.php | 2 +- test/Psr/SimpleCache/SimpleCacheDecoratorTest.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Pattern/ObjectCache.php b/src/Pattern/ObjectCache.php index 5d540555..49170443 100644 --- a/src/Pattern/ObjectCache.php +++ b/src/Pattern/ObjectCache.php @@ -20,7 +20,7 @@ final class ObjectCache extends AbstractStorageCapablePattern implements Stringable { - private CallbackCache $callbackCache; + private readonly CallbackCache $callbackCache; /** * @param StorageInterface $storage @@ -154,7 +154,7 @@ public function call(string $method, array $args = []): mixed if (! method_exists($object, $method)) { throw new Exception\RuntimeException(sprintf( '%s only accepts methods which are implemented by %s', - $this::class, + self::class, $object::class, )); } diff --git a/src/Psr/CacheItemPool/CacheItem.php b/src/Psr/CacheItemPool/CacheItem.php index 111b8ffb..d30528bc 100644 --- a/src/Psr/CacheItemPool/CacheItem.php +++ b/src/Psr/CacheItemPool/CacheItem.php @@ -24,10 +24,10 @@ final class CacheItem implements CacheItemInterface */ private ?int $expiration = null; - private ClockInterface $clock; + private readonly ClockInterface $clock; public function __construct( - private string $key, + private readonly string $key, private mixed $value, /** * True if the cache item lookup resulted in a cache hit or if they item is deferred or successfully saved diff --git a/src/Service/StorageAdapterFactory.php b/src/Service/StorageAdapterFactory.php index cd54d10f..ef634d0e 100644 --- a/src/Service/StorageAdapterFactory.php +++ b/src/Service/StorageAdapterFactory.php @@ -23,8 +23,8 @@ final class StorageAdapterFactory implements StorageAdapterFactoryInterface public const DEFAULT_PLUGIN_PRIORITY = 1; public function __construct( - private PluginManagerInterface $adapters, - private StoragePluginFactoryInterface $pluginFactory + private readonly PluginManagerInterface $adapters, + private readonly StoragePluginFactoryInterface $pluginFactory ) { } diff --git a/src/Service/StoragePluginFactory.php b/src/Service/StoragePluginFactory.php index 4606fed4..0bd31801 100644 --- a/src/Service/StoragePluginFactory.php +++ b/src/Service/StoragePluginFactory.php @@ -14,7 +14,7 @@ final class StoragePluginFactory implements StoragePluginFactoryInterface { - public function __construct(private PluginManagerInterface $plugins) + public function __construct(private readonly PluginManagerInterface $plugins) { } diff --git a/test/Psr/SimpleCache/SimpleCacheDecoratorTest.php b/test/Psr/SimpleCache/SimpleCacheDecoratorTest.php index 0b8a1fd6..35824f83 100644 --- a/test/Psr/SimpleCache/SimpleCacheDecoratorTest.php +++ b/test/Psr/SimpleCache/SimpleCacheDecoratorTest.php @@ -90,7 +90,7 @@ private static function createCapabilities( bool $ttlSupported = true, int $maxKeyLength = -1 ): Capabilities { - $supportedDataTypes = $supportedDataTypes ?? self::SIMPLE_CACHE_REQUIRED_TYPES; + $supportedDataTypes ??= self::SIMPLE_CACHE_REQUIRED_TYPES; return new Capabilities( maxKeyLength: $maxKeyLength, ttlSupported: $ttlSupported,