1 | <?php |
||
21 | trait OwnerForwarderTrait |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * Forward to owner |
||
26 | * @param string $name |
||
27 | * @return mixed |
||
28 | */ |
||
29 | public function __get($name) |
||
33 | |||
34 | /** |
||
35 | * Forward to owner |
||
36 | * @param string $name |
||
37 | * @param mixed $value |
||
38 | */ |
||
39 | public function __set($name, $value) |
||
43 | |||
44 | /** |
||
45 | * Forward to owner |
||
46 | * @param string $name |
||
47 | * @param mixed[] $arguments |
||
48 | */ |
||
49 | public function __call($name, $arguments) |
||
53 | |||
54 | /** |
||
55 | * Forward to owner |
||
56 | * @param string $name |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function __isset($name) |
||
63 | |||
64 | /** |
||
65 | * Forward to owner |
||
66 | * @param string $name |
||
67 | */ |
||
68 | public function __unset($name) |
||
72 | |||
73 | /** |
||
74 | * Forward __toString to owner |
||
75 | * @return string |
||
76 | */ |
||
77 | public function __toString() |
||
81 | |||
82 | } |
||
83 |
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: