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