1 | <?php |
||
16 | trait OwnerForwarderTrait |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * Forward to owner |
||
21 | * @param string $name |
||
22 | * @return mixed |
||
23 | */ |
||
24 | public function __get($name) |
||
28 | |||
29 | /** |
||
30 | * Forward to owner |
||
31 | * @param string $name |
||
32 | * @param mixed $value |
||
33 | */ |
||
34 | public function __set($name, $value) |
||
38 | |||
39 | /** |
||
40 | * Forward to owner |
||
41 | * @param string $name |
||
42 | * @param mixed[] $arguments |
||
43 | */ |
||
44 | public function __call($name, $arguments) |
||
48 | |||
49 | /** |
||
50 | * Forward to owner |
||
51 | * @param string $name |
||
52 | * @return bool |
||
53 | */ |
||
54 | public function __isset($name) |
||
58 | |||
59 | /** |
||
60 | * Forward to owner |
||
61 | * @param string $name |
||
62 | */ |
||
63 | public function __unset($name) |
||
67 | |||
68 | /** |
||
69 | * Forward __toString to owner |
||
70 | * @return string |
||
71 | */ |
||
72 | public function __toString() |
||
76 | |||
77 | } |
||
78 |
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: