@@ 184-212 (lines=29) @@ | ||
181 | * |
|
182 | * @return bool |
|
183 | */ |
|
184 | public function hasMethod($name, $traverse = true) |
|
185 | { |
|
186 | foreach ($this->methods as $method) { |
|
187 | ||
188 | if ($name === $method->getName()) { |
|
189 | return true; |
|
190 | } |
|
191 | } |
|
192 | ||
193 | if ($traverse && $this->hasTraits()) { |
|
194 | ||
195 | /** |
|
196 | * @var TraitMetadata $trait |
|
197 | */ |
|
198 | foreach ($this->traits as $trait) { |
|
199 | ||
200 | if ($trait->hasMethod($name, $traverse)) { |
|
201 | return true; |
|
202 | } |
|
203 | } |
|
204 | } |
|
205 | ||
206 | ||
207 | if ($traverse && $this->hasParent()) { |
|
208 | return $this->getParent()->hasMethod($name, $traverse); |
|
209 | } |
|
210 | ||
211 | return false; |
|
212 | } |
|
213 | ||
214 | /** |
|
215 | * Check if class has public method, with optional inheritance tree and trait traverse. |
|
@@ 222-249 (lines=28) @@ | ||
219 | * |
|
220 | * @return bool |
|
221 | */ |
|
222 | public function hasPublicMethod($name, $traverse = true) |
|
223 | { |
|
224 | foreach ($this->methods as $method) { |
|
225 | ||
226 | if ($name === $method->getName()) { |
|
227 | return $method->isPublic(); |
|
228 | } |
|
229 | } |
|
230 | ||
231 | if ($traverse && $this->hasTraits()) { |
|
232 | ||
233 | /** |
|
234 | * @var TraitMetadata $trait |
|
235 | */ |
|
236 | foreach ($this->traits as $trait) { |
|
237 | ||
238 | if ($trait->hasPublicMethod($name, $traverse)) { |
|
239 | return true; |
|
240 | } |
|
241 | } |
|
242 | } |
|
243 | ||
244 | if ($traverse && $this->hasParent()) { |
|
245 | return $this->getParent()->hasPublicMethod($name, $traverse); |
|
246 | } |
|
247 | ||
248 | return false; |
|
249 | } |
|
250 | ||
251 | /** |
|
252 | * Get public method for class, with optional inheritance tree and trait traverse. |