diff --git a/src/Pattern/CallbackCache.php b/src/Pattern/CallbackCache.php index cc3dd7b0..4a2d7a61 100644 --- a/src/Pattern/CallbackCache.php +++ b/src/Pattern/CallbackCache.php @@ -111,6 +111,9 @@ public function generateKey(callable $callback, array $args = []): string */ protected function generateCallbackKey(callable $callback, array $args): string { + if (! is_callable($callback, false, $callbackKey)) { + throw new Exception\InvalidArgumentException('Invalid callback'); + } // Create a cache key for the ObjectCache use case. $options = $this->getOptions(); @@ -120,9 +123,6 @@ protected function generateCallbackKey(callable $callback, array $args): string return $callbackKey . $argumentKey; } - if (! is_callable($callback, false, $callbackKey)) { - throw new Exception\InvalidArgumentException('Invalid callback'); - } // functions, methods and classnames are case-insensitive $callbackKey = strtolower($callbackKey); diff --git a/test/Pattern/TestAsset/TestObjectCache.php b/test/Pattern/TestAsset/TestObjectCache.php index ec4e0bda..68f10356 100644 --- a/test/Pattern/TestAsset/TestObjectCache.php +++ b/test/Pattern/TestAsset/TestObjectCache.php @@ -4,6 +4,8 @@ namespace LaminasTest\Cache\Pattern\TestAsset; +use Closure; + use function func_get_args; use function implode; @@ -22,7 +24,7 @@ final class TestObjectCache /** @var string */ public $property = 'testProperty'; - private \Closure $closure; + private Closure $closure; public function __construct() {