19declare(strict_types=1);
26use ReflectionFunction;
41 private $component_decorator;
50 throw new LogicException(
'first argument and return value of closure must be type-hinted to \ILIAS\UI\Component\Component');
52 if ($this->component_decorator instanceof Closure) {
53 $existing = $this->component_decorator;
54 $this->component_decorator =
static function (
Component $c) use ($component_decorator, $existing) :
Component {
55 $component = $existing(
$c);
57 return $component_decorator($component);
60 $this->component_decorator = $component_decorator;
71 return $this->component_decorator;
77 $r =
new ReflectionFunction(
$c);
78 if (count($r->getParameters()) !== 1) {
81 $first_param_type = $r->getParameters()[0]->getType();
82 if ($first_param_type instanceof ReflectionType && $first_param_type->getName() !== Component::class) {
85 $return_type = $r->getReturnType();
86 if ($return_type ===
null) {
89 if ($return_type->getName() !== Component::class) {
94 }
catch (Throwable
$i) {
An exception for terminatinating execution or to throw for unit testing.
Interface isGlobalScreenItem.
A component is the most general form of an entity in the UI.
trait ComponentDecoratorTrait
addComponentDecorator(Closure $component_decorator)