diff --git a/lib/Phpfastcache/Config/ConfigurationOption.php b/lib/Phpfastcache/Config/ConfigurationOption.php index 2392f747b..cecfdd5d2 100644 --- a/lib/Phpfastcache/Config/ConfigurationOption.php +++ b/lib/Phpfastcache/Config/ConfigurationOption.php @@ -142,14 +142,24 @@ public function __construct(...$args) $typeHintGot = \is_object($value) ? \get_class($value) : \gettype($value); $reflectionMethod = new \ReflectionMethod($this, $method); $parameter = $reflectionMethod->getParameters()[0] ?? null; - $typeHintExpected = ($parameter instanceof \ReflectionParameter ? ($parameter->getType() === 'object' ? $parameter->getClass() : $parameter->getType()) : 'Unknown type'); - - throw new PhpfastcacheInvalidConfigurationException(\sprintf( - 'Invalid type hint found for "%s", expected "%s" got "%s"', - \lcfirst(\substr($method, 3)), - $typeHintExpected, - $typeHintGot - )); + $paraReflectionType = $parameter->getType(); + if(method_exists($paraReflectionType, "getName")) { + $typeHintExpected = ($parameter instanceof \ReflectionParameter ? ($paraReflectionType->getName() === 'object' ? $parameter->getClass() : $paraReflectionType->getName()) : 'Unknown type'); + throw new PhpfastcacheInvalidConfigurationException(\sprintf( + 'Invalid type hint found for "%s", expected "%s" got "%s"', + \lcfirst(\substr($method, 3)), + $typeHintExpected, + $typeHintGot + )); + } else { + $typeHintExpected = ($parameter instanceof \ReflectionParameter ? ($paraReflectionType === 'object' ? $parameter->getClass() : $paraReflectionType) : 'Unknown type'); + throw new PhpfastcacheInvalidConfigurationException(\sprintf( + 'Invalid type hint found for "%s", expected "%s" got "%s"', + \lcfirst(\substr($method, 3)), + $typeHintExpected, + $typeHintGot + )); + } } } } @@ -447,4 +457,4 @@ public function setCacheSlamsTimeout(int $cacheSlamsTimeout): self $this->cacheSlamsTimeout = $cacheSlamsTimeout; return $this; } -} \ No newline at end of file +}