Mercurial > hg > cmmr2012-drupal-site
comparison vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php declare(strict_types=1); | |
2 | |
3 namespace PhpParser\Node\Stmt; | |
4 | |
5 use PhpParser\Node; | |
6 | |
7 /** | |
8 * @property Node\Name $namespacedName Namespaced name (if using NameResolver) | |
9 */ | |
10 abstract class ClassLike extends Node\Stmt | |
11 { | |
12 /** @var Node\Identifier|null Name */ | |
13 public $name; | |
14 /** @var Node\Stmt[] Statements */ | |
15 public $stmts; | |
16 | |
17 /** | |
18 * Gets all methods defined directly in this class/interface/trait | |
19 * | |
20 * @return ClassMethod[] | |
21 */ | |
22 public function getMethods() : array { | |
23 $methods = []; | |
24 foreach ($this->stmts as $stmt) { | |
25 if ($stmt instanceof ClassMethod) { | |
26 $methods[] = $stmt; | |
27 } | |
28 } | |
29 return $methods; | |
30 } | |
31 | |
32 /** | |
33 * Gets method with the given name defined directly in this class/interface/trait. | |
34 * | |
35 * @param string $name Name of the method (compared case-insensitively) | |
36 * | |
37 * @return ClassMethod|null Method node or null if the method does not exist | |
38 */ | |
39 public function getMethod(string $name) { | |
40 $lowerName = strtolower($name); | |
41 foreach ($this->stmts as $stmt) { | |
42 if ($stmt instanceof ClassMethod && $lowerName === $stmt->name->toLowerString()) { | |
43 return $stmt; | |
44 } | |
45 } | |
46 return null; | |
47 } | |
48 } |