| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDeveloper\BetterDocs\Dependencies\PhpParser\Node\Stmt; |
| 4 |
|
| 5 |
use WPDeveloper\BetterDocs\Dependencies\PhpParser\Node; |
| 6 |
|
| 7 |
abstract class ClassLike extends Node\Stmt { |
| 8 |
/** @var string|null Name */ |
| 9 |
public $name; |
| 10 |
/** @var Node[] Statements */ |
| 11 |
public $stmts; |
| 12 |
|
| 13 |
/** |
| 14 |
* Gets all methods defined directly in this class/interface/trait |
| 15 |
* |
| 16 |
* @return ClassMethod[] |
| 17 |
*/ |
| 18 |
public function getMethods() { |
| 19 |
$methods = array(); |
| 20 |
foreach ($this->stmts as $stmt) { |
| 21 |
if ($stmt instanceof ClassMethod) { |
| 22 |
$methods[] = $stmt; |
| 23 |
} |
| 24 |
} |
| 25 |
return $methods; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Gets method with the given name defined directly in this class/interface/trait. |
| 30 |
* |
| 31 |
* @param string $name Name of the method (compared case-insensitively) |
| 32 |
* |
| 33 |
* @return ClassMethod|null Method node or null if the method does not exist |
| 34 |
*/ |
| 35 |
public function getMethod($name) { |
| 36 |
$lowerName = strtolower($name); |
| 37 |
foreach ($this->stmts as $stmt) { |
| 38 |
if ($stmt instanceof ClassMethod && $lowerName === strtolower($stmt->name)) { |
| 39 |
return $stmt; |
| 40 |
} |
| 41 |
} |
| 42 |
return null; |
| 43 |
} |
| 44 |
} |
| 45 |
|