1 | <?php |
||
49 | trait ApparatObjectTrait |
||
50 | { |
||
51 | /** |
||
52 | * Property mapping |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | protected $mapping = []; |
||
57 | |||
58 | /** |
||
59 | * Generic getter |
||
60 | * |
||
61 | * @param string $method Method name |
||
|
|||
62 | * @param array $arguments Arguments |
||
63 | * @throws \BadMethodCallException If the method is unknown |
||
64 | */ |
||
65 | 1 | public function __call($name, array $arguments) |
|
66 | { |
||
67 | // If a getter was called |
||
68 | 1 | if (!strncmp('get', $name, 3)) { |
|
69 | 1 | $property = lcfirst(substr($name, 3)); |
|
70 | 1 | if (array_key_exists($property, $this->mapping)) { |
|
71 | 1 | $arguments = (array)$this->mapping[$property]; |
|
72 | 1 | $getter = 'get'.ucfirst(array_shift($arguments)); |
|
73 | 1 | return $this->delegateObjectGetter($property, $getter, $arguments); |
|
74 | } |
||
75 | } |
||
76 | |||
77 | // If the method is unknown |
||
78 | 1 | throw new \BadMethodCallException(sprintf('Unknown apparat object method "%s()"', $name)); |
|
79 | } |
||
80 | |||
81 | /** |
||
82 | * Return whether a particular property exists |
||
83 | * |
||
84 | * @param string $offset Property name |
||
85 | */ |
||
86 | 1 | public function offsetExists($offset) |
|
90 | |||
91 | /** |
||
92 | * Return a particular property |
||
93 | * |
||
94 | * @param string $offset Property name |
||
95 | * @return mixed Property value |
||
96 | */ |
||
97 | 2 | public function offsetGet($offset) |
|
112 | |||
113 | /** |
||
114 | * Set a particular property |
||
115 | * |
||
116 | * @param string $offset Property name |
||
117 | * @param mixed $value Property value |
||
118 | */ |
||
119 | 1 | public function offsetSet($offset, $value) |
|
123 | |||
124 | /** |
||
125 | * Unset a particular property |
||
126 | * |
||
127 | * @param string $offset Property name |
||
128 | */ |
||
129 | 1 | public function offsetUnset($offset) |
|
136 | |||
137 | /** |
||
138 | * Delegate the mapped object getter |
||
139 | * |
||
140 | * @param string $property Property name |
||
141 | * @param string $getter Getter name |
||
142 | * @param array $arguments Getter arguments |
||
143 | * @return mixed Property value |
||
144 | * @throws InvalidArgumentException If the property is invalid |
||
145 | */ |
||
146 | 2 | protected function delegateObjectGetter($property, $getter, array $arguments) |
|
158 | } |
||
159 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.