19declare(strict_types=1);
25use ReflectionFunction;
26use ReflectionException;
56 throw new LogicException(
"\$priority MUST be between LayoutModification::PRIORITY_LOW, LayoutModification::PRIORITY_MEDIUM or LayoutModification::PRIORITY_HIGH");
93 $clone->modification = $closure;
113 }
catch (\Throwable
$e) {
114 if (defined(
'DEVMODE') && (
bool) DEVMODE) {
127 if (!$closure instanceof Closure) {
133 $r =
new ReflectionFunction($closure);
139 $param = $r->getParameters()[0] ??
null;
149 if (
$param->getType()->getName() !== $requested_first_argument_type) {
150 throw new InvalidModification($this,
"Modification's first parameter does not match the requested type");
160 if (!$r->hasReturnType()) {
164 if ($r->getReturnType()->getName() !== $requested_return_type) {
165 throw new InvalidModification($this,
"Modification's return type does not match the requested type");
172 }
catch (ReflectionException) {
173 throw new InvalidModification($this,
"Modification threw an exception while checking the closure");
withHighPriority()
@inheritDoc
withLowPriority()
@inheritDoc
getModification()
@inheritDoc
withPriority(int $priority)
@inheritDoc
hasValidModification()
@inheritDoc
withModification(Closure $closure)
Class LayoutModification.
getClosureFirstArgumentType()
firstArgumentAllowsNull()