19declare(strict_types=1);
24use ReflectionFunction;
25use ReflectionException;
61 throw new LogicException(
"\$priority MUST be between LayoutModification::PRIORITY_LOW, LayoutModification::PRIORITY_MEDIUM or LayoutModification::PRIORITY_HIGH");
98 $clone->modification = $closure;
118 }
catch (\Throwable
$e) {
119 if (defined(
'DEVMODE') && ((
bool) DEVMODE) ===
true) {
132 if (!$closure instanceof Closure) {
138 $r =
new ReflectionFunction($closure);
144 $param = $r->getParameters()[0] ??
null;
154 if (
$param->getType()->getName() !== $requested_first_argument_type) {
155 throw new InvalidModification($this,
"Modification's first parameter does not match the requested type");
165 if (!$r->hasReturnType()) {
169 if ($r->getReturnType()->getName() !== $requested_return_type) {
170 throw new InvalidModification($this,
"Modification's return type does not match the requested type");
177 }
catch (ReflectionException
$e) {
178 throw new InvalidModification($this,
"Modification threw an exception while checking the closure");
An exception for terminatinating execution or to throw for unit testing.
withHighPriority()
@inheritDoc
withLowPriority()
@inheritDoc
getModification()
@inheritDoc
withPriority(int $priority)
@inheritDoc
hasValidModification()
@inheritDoc
withModification(Closure $closure)
Class LayoutModification.
getClosureFirstArgumentType()
firstArgumentAllowsNull()