| 1 | <?php |
||
| 13 | trait DIMagicTrait |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Magic method to get a service. |
||
| 17 | * |
||
| 18 | * @param string $service name of the service. |
||
| 19 | * |
||
| 20 | * @return mixed as the service requested. |
||
| 21 | */ |
||
| 22 | public function __get($service) |
||
| 26 | |||
| 27 | |||
| 28 | |||
| 29 | /** |
||
| 30 | * Magic method to get and call a service. |
||
| 31 | * |
||
| 32 | * @param string $service name of the service. |
||
| 33 | * @param array $arguments currently NOT USED. |
||
| 34 | * |
||
| 35 | * @return mixed as the service requested. |
||
| 36 | */ |
||
| 37 | 1 | public function __call($service, $arguments = []) |
|
| 41 | } |
||
| 42 |
If you implement
__calland 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
__callis implemented by a parent class and only the child class knows which methods exist: