Skip to content

Commit

Permalink
Merge pull request #21 from boesing/refactor/finalize-and-cleanup
Browse files Browse the repository at this point in the history
Mark classes `final`, tighten `ext-redis` dependency and remove `ext-redis` extension checks
  • Loading branch information
boesing authored Oct 12, 2021
2 parents 96bd15c + e6749d8 commit c147cee
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 23 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"license": "BSD-3-Clause",
"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": {
Expand Down
5 changes: 2 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions src/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions src/RedisCluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 0 additions & 5 deletions src/RedisClusterResourceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +14,6 @@

use function array_key_exists;
use function assert;
use function extension_loaded;

/**
* @psalm-type RedisClusterInfoType = array<string,mixed>&array{redis_version:string}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/RedisOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use function sprintf;
use function strlen;

class RedisOptions extends AdapterOptions
final class RedisOptions extends AdapterOptions
{
// @codingStandardsIgnoreStart
/**
Expand Down
2 changes: 1 addition & 1 deletion src/RedisResourceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* This is a resource manager for redis
*/
class RedisResourceManager
final class RedisResourceManager
{
/**
* Registered resources
Expand Down

0 comments on commit c147cee

Please sign in to comment.