|   1:  | <?php declare(strict_types=1); | 
|   2:  |  | 
|   3:  | namespace PhpParser\Node\Stmt; | 
|   4:  |  | 
|   5:  | use PhpParser\Node; | 
|   6:  | use PhpParser\Node\PropertyItem; | 
|   7:  |  | 
|   8:  | abstract class ClassLike extends Node\Stmt { | 
|   9:  |      | 
|  10:  |     public ?Node\Identifier $name; | 
|  11:  |      | 
|  12:  |     public array $stmts; | 
|  13:  |      | 
|  14:  |     public array $attrGroups; | 
|  15:  |  | 
|  16:  |      | 
|  17:  |     public ?Node\Name $namespacedName; | 
|  18:  |  | 
|  19:  |      | 
|  20:  |  | 
|  21:  |  | 
|  22:  |     public function getTraitUses(): array { | 
|  23:  |         $traitUses = []; | 
|  24:  |         foreach ($this->stmts as $stmt) { | 
|  25:  |             if ($stmt instanceof TraitUse) { | 
|  26:  |                 $traitUses[] = $stmt; | 
|  27:  |             } | 
|  28:  |         } | 
|  29:  |         return $traitUses; | 
|  30:  |     } | 
|  31:  |  | 
|  32:  |      | 
|  33:  |  | 
|  34:  |  | 
|  35:  |     public function getConstants(): array { | 
|  36:  |         $constants = []; | 
|  37:  |         foreach ($this->stmts as $stmt) { | 
|  38:  |             if ($stmt instanceof ClassConst) { | 
|  39:  |                 $constants[] = $stmt; | 
|  40:  |             } | 
|  41:  |         } | 
|  42:  |         return $constants; | 
|  43:  |     } | 
|  44:  |  | 
|  45:  |      | 
|  46:  |  | 
|  47:  |  | 
|  48:  |     public function getProperties(): array { | 
|  49:  |         $properties = []; | 
|  50:  |         foreach ($this->stmts as $stmt) { | 
|  51:  |             if ($stmt instanceof Property) { | 
|  52:  |                 $properties[] = $stmt; | 
|  53:  |             } | 
|  54:  |         } | 
|  55:  |         return $properties; | 
|  56:  |     } | 
|  57:  |  | 
|  58:  |      | 
|  59:  |  | 
|  60:  |  | 
|  61:  |  | 
|  62:  |  | 
|  63:  |  | 
|  64:  |  | 
|  65:  |     public function getProperty(string $name): ?Property { | 
|  66:  |         foreach ($this->stmts as $stmt) { | 
|  67:  |             if ($stmt instanceof Property) { | 
|  68:  |                 foreach ($stmt->props as $prop) { | 
|  69:  |                     if ($prop instanceof PropertyItem && $name === $prop->name->toString()) { | 
|  70:  |                         return $stmt; | 
|  71:  |                     } | 
|  72:  |                 } | 
|  73:  |             } | 
|  74:  |         } | 
|  75:  |         return null; | 
|  76:  |     } | 
|  77:  |  | 
|  78:  |      | 
|  79:  |  | 
|  80:  |  | 
|  81:  |  | 
|  82:  |  | 
|  83:  |     public function getMethods(): array { | 
|  84:  |         $methods = []; | 
|  85:  |         foreach ($this->stmts as $stmt) { | 
|  86:  |             if ($stmt instanceof ClassMethod) { | 
|  87:  |                 $methods[] = $stmt; | 
|  88:  |             } | 
|  89:  |         } | 
|  90:  |         return $methods; | 
|  91:  |     } | 
|  92:  |  | 
|  93:  |      | 
|  94:  |  | 
|  95:  |  | 
|  96:  |  | 
|  97:  |  | 
|  98:  |  | 
|  99:  |  | 
| 100:  |     public function getMethod(string $name): ?ClassMethod { | 
| 101:  |         $lowerName = strtolower($name); | 
| 102:  |         foreach ($this->stmts as $stmt) { | 
| 103:  |             if ($stmt instanceof ClassMethod && $lowerName === $stmt->name->toLowerString()) { | 
| 104:  |                 return $stmt; | 
| 105:  |             } | 
| 106:  |         } | 
| 107:  |         return null; | 
| 108:  |     } | 
| 109:  | } | 
| 110:  |  |