Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions lib/Phpfastcache/Config/ConfigurationOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
}
}
}
}
Expand Down Expand Up @@ -447,4 +457,4 @@ public function setCacheSlamsTimeout(int $cacheSlamsTimeout): self
$this->cacheSlamsTimeout = $cacheSlamsTimeout;
return $this;
}
}
}