annotate vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 5fb285c0d0e3
children
rev   line source
Chris@13 1 <?php declare(strict_types=1);
Chris@0 2
Chris@0 3 namespace PhpParser\Node\Stmt;
Chris@0 4
Chris@0 5 use PhpParser\Node;
Chris@0 6
Chris@13 7 /**
Chris@13 8 * @property Node\Name $namespacedName Namespaced name (if using NameResolver)
Chris@13 9 */
Chris@13 10 abstract class ClassLike extends Node\Stmt
Chris@13 11 {
Chris@13 12 /** @var Node\Identifier|null Name */
Chris@0 13 public $name;
Chris@13 14 /** @var Node\Stmt[] Statements */
Chris@0 15 public $stmts;
Chris@0 16
Chris@0 17 /**
Chris@0 18 * Gets all methods defined directly in this class/interface/trait
Chris@0 19 *
Chris@0 20 * @return ClassMethod[]
Chris@0 21 */
Chris@13 22 public function getMethods() : array {
Chris@13 23 $methods = [];
Chris@0 24 foreach ($this->stmts as $stmt) {
Chris@0 25 if ($stmt instanceof ClassMethod) {
Chris@0 26 $methods[] = $stmt;
Chris@0 27 }
Chris@0 28 }
Chris@0 29 return $methods;
Chris@0 30 }
Chris@0 31
Chris@0 32 /**
Chris@0 33 * Gets method with the given name defined directly in this class/interface/trait.
Chris@0 34 *
Chris@0 35 * @param string $name Name of the method (compared case-insensitively)
Chris@0 36 *
Chris@0 37 * @return ClassMethod|null Method node or null if the method does not exist
Chris@0 38 */
Chris@13 39 public function getMethod(string $name) {
Chris@0 40 $lowerName = strtolower($name);
Chris@0 41 foreach ($this->stmts as $stmt) {
Chris@13 42 if ($stmt instanceof ClassMethod && $lowerName === $stmt->name->toLowerString()) {
Chris@0 43 return $stmt;
Chris@0 44 }
Chris@0 45 }
Chris@0 46 return null;
Chris@0 47 }
Chris@0 48 }