annotate vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php @ 0:4c8ae668cc8c

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