1 | <?php |
||
53 | class CallableDefinition extends AbstractArgsDefinition implements DefinitionInterface |
||
54 | { |
||
55 | /** |
||
56 | * The callable function |
||
57 | * @var callable |
||
58 | */ |
||
59 | protected $callable; |
||
60 | |||
61 | /** |
||
62 | * Constructor |
||
63 | * |
||
64 | * @param callable $callable The function to be called |
||
65 | * @param array<mixed> $arguments List of arguments |
||
66 | * |
||
67 | * @return void |
||
|
|||
68 | */ |
||
69 | 30 | public function __construct($callable, array $arguments = array()) |
|
74 | |||
75 | /** |
||
76 | * Calls $this->callable and return its value |
||
77 | * |
||
78 | * @param Container $container The Di Container |
||
79 | * @param null|string $name Name of the definition (if any) |
||
80 | * |
||
81 | * @return mixed |
||
82 | * @throws Exceptions\InvalidCallableDefinitionException |
||
83 | */ |
||
84 | 14 | public function invoke(Container $container, $name = null) |
|
99 | |||
100 | /** |
||
101 | * Returns the callable function |
||
102 | * |
||
103 | * @return callable |
||
104 | */ |
||
105 | 4 | public function getCallable() |
|
109 | |||
110 | /** |
||
111 | * Defines the callable function |
||
112 | * |
||
113 | * @param callable $callable The callable function |
||
114 | * |
||
115 | * @return void |
||
116 | */ |
||
117 | 6 | public function setCallable($callable) |
|
121 | } |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.