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