From 0813c86870c33997bee793ae9d1d82461035d623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Fri, 24 Sep 2021 01:05:04 +0200 Subject: [PATCH 1/2] refactor: mark classes `final`, tighten `ext-redis` dependency and remove `ext-redis` extension checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 4 ++-- src/Redis.php | 7 +------ src/RedisCluster.php | 5 ----- src/RedisClusterResourceManager.php | 5 ----- src/RedisOptions.php | 2 +- src/RedisResourceManager.php | 2 +- 7 files changed, 6 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 46a67da..33cbdf1 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "require": { "php": "^7.3 || ~8.0.0 || ~8.1.0", "ext-posix": "*", - "ext-redis": "*", + "ext-redis": "^4.3 || ^5.0.2", "laminas/laminas-cache": "^3.0" }, "provide": { diff --git a/composer.lock b/composer.lock index 4010621..bed349a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bb2f57f3d9da5d103d860b653ca32903", + "content-hash": "f5e66f4138927e328ca9980281ceaac0", "packages": [ { "name": "container-interop/container-interop", @@ -5681,7 +5681,7 @@ "platform": { "php": "^7.3 || ~8.0.0 || ~8.1.0", "ext-posix": "*", - "ext-redis": "*" + "ext-redis": "^4.3 || ^5.0.2" }, "platform-dev": [], "plugin-api-version": "2.1.0" diff --git a/src/Redis.php b/src/Redis.php index 21f77ca..03654db 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -15,10 +15,9 @@ use function array_combine; use function array_filter; -use function extension_loaded; use function version_compare; -class Redis extends AbstractAdapter implements +final class Redis extends AbstractAdapter implements ClearByNamespaceInterface, ClearByPrefixInterface, FlushableInterface, @@ -61,10 +60,6 @@ class Redis extends AbstractAdapter implements */ public function __construct($options = null) { - if (! extension_loaded('redis')) { - throw new Exception\ExtensionNotLoadedException("Redis extension is not loaded"); - } - parent::__construct($options); // reset initialized flag on update option(s) diff --git a/src/RedisCluster.php b/src/RedisCluster.php index aa9b9be..db116d0 100644 --- a/src/RedisCluster.php +++ b/src/RedisCluster.php @@ -21,7 +21,6 @@ use function array_key_exists; use function array_values; use function count; -use function extension_loaded; use function in_array; use function sprintf; use function version_compare; @@ -49,10 +48,6 @@ final class RedisCluster extends AbstractAdapter implements */ public function __construct($options = null) { - if (! extension_loaded('redis')) { - throw new Exception\ExtensionNotLoadedException("Redis extension is not loaded"); - } - /** @psalm-suppress PossiblyInvalidArgument */ parent::__construct($options); $eventManager = $this->getEventManager(); diff --git a/src/RedisClusterResourceManager.php b/src/RedisClusterResourceManager.php index 96c008e..ef6dae5 100644 --- a/src/RedisClusterResourceManager.php +++ b/src/RedisClusterResourceManager.php @@ -4,7 +4,6 @@ namespace Laminas\Cache\Storage\Adapter; -use Laminas\Cache\Exception\ExtensionNotLoadedException; use Laminas\Cache\Exception\RuntimeException; use Laminas\Cache\Storage\Adapter\Exception\RedisRuntimeException; use Laminas\Cache\Storage\Plugin\PluginInterface; @@ -15,7 +14,6 @@ use function array_key_exists; use function assert; -use function extension_loaded; /** * @psalm-type RedisClusterInfoType = array&array{redis_version:string} @@ -31,9 +29,6 @@ final class RedisClusterResourceManager implements RedisClusterResourceManagerIn public function __construct(RedisClusterOptions $options) { $this->options = $options; - if (! extension_loaded('redis')) { - throw new ExtensionNotLoadedException('Redis extension is not loaded'); - } } public function getVersion(): string diff --git a/src/RedisOptions.php b/src/RedisOptions.php index 5334b02..66f4788 100644 --- a/src/RedisOptions.php +++ b/src/RedisOptions.php @@ -7,7 +7,7 @@ use function sprintf; use function strlen; -class RedisOptions extends AdapterOptions +final class RedisOptions extends AdapterOptions { // @codingStandardsIgnoreStart /** diff --git a/src/RedisResourceManager.php b/src/RedisResourceManager.php index 621302e..e4f55cb 100644 --- a/src/RedisResourceManager.php +++ b/src/RedisResourceManager.php @@ -23,7 +23,7 @@ /** * This is a resource manager for redis */ -class RedisResourceManager +final class RedisResourceManager { /** * Registered resources From e6749d852aa1c37f7777168dc1857c0bf41f6955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Fri, 24 Sep 2021 01:08:51 +0200 Subject: [PATCH 2/2] qa: remove `ext-posix` as it is not used here MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- composer.json | 1 - composer.lock | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 33cbdf1..641bd48 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,6 @@ "license": "BSD-3-Clause", "require": { "php": "^7.3 || ~8.0.0 || ~8.1.0", - "ext-posix": "*", "ext-redis": "^4.3 || ^5.0.2", "laminas/laminas-cache": "^3.0" }, diff --git a/composer.lock b/composer.lock index bed349a..8f9796e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f5e66f4138927e328ca9980281ceaac0", + "content-hash": "eee92ab22c84f75e29b1f2bc0898f37c", "packages": [ { "name": "container-interop/container-interop", @@ -5680,7 +5680,6 @@ "prefer-lowest": false, "platform": { "php": "^7.3 || ~8.0.0 || ~8.1.0", - "ext-posix": "*", "ext-redis": "^4.3 || ^5.0.2" }, "platform-dev": [],