1 | <?php |
||
12 | trait DIMagicTrait |
||
13 | { |
||
14 | /** |
||
15 | * Magic method to get a service. |
||
16 | * |
||
17 | * @param string $service name of the service. |
||
18 | * |
||
19 | * @return mixed as the service requested. |
||
20 | */ |
||
21 | 1 | public function __get($service) |
|
25 | |||
26 | |||
27 | |||
28 | /** |
||
29 | * Magic method to get and call a service. |
||
30 | * |
||
31 | * @param string $service name of the service. |
||
32 | * @param array $arguments currently NOT USED. |
||
33 | * |
||
34 | * @return mixed as the service requested. |
||
35 | */ |
||
36 | 1 | public function __call($service, $arguments = []) |
|
40 | } |
||
41 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: