annotate vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.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@13 2
Chris@13 3 namespace PhpParser\Node;
Chris@13 4
Chris@13 5 use PhpParser\NodeAbstract;
Chris@13 6
Chris@13 7 /**
Chris@13 8 * Represents a non-namespaced name. Namespaced names are represented using Name nodes.
Chris@13 9 */
Chris@13 10 class Identifier extends NodeAbstract
Chris@13 11 {
Chris@13 12 /** @var string Identifier as string */
Chris@13 13 public $name;
Chris@13 14
Chris@13 15 private static $specialClassNames = [
Chris@13 16 'self' => true,
Chris@13 17 'parent' => true,
Chris@13 18 'static' => true,
Chris@13 19 ];
Chris@13 20
Chris@13 21 /**
Chris@13 22 * Constructs an identifier node.
Chris@13 23 *
Chris@13 24 * @param string $name Identifier as string
Chris@13 25 * @param array $attributes Additional attributes
Chris@13 26 */
Chris@13 27 public function __construct(string $name, array $attributes = []) {
Chris@13 28 parent::__construct($attributes);
Chris@13 29 $this->name = $name;
Chris@13 30 }
Chris@13 31
Chris@13 32 public function getSubNodeNames() : array {
Chris@13 33 return ['name'];
Chris@13 34 }
Chris@13 35
Chris@13 36 /**
Chris@13 37 * Get identifier as string.
Chris@13 38 *
Chris@13 39 * @return string Identifier as string.
Chris@13 40 */
Chris@13 41 public function toString() : string {
Chris@13 42 return $this->name;
Chris@13 43 }
Chris@13 44
Chris@13 45 /**
Chris@13 46 * Get lowercased identifier as string.
Chris@13 47 *
Chris@13 48 * @return string Lowercased identifier as string
Chris@13 49 */
Chris@13 50 public function toLowerString() : string {
Chris@13 51 return strtolower($this->name);
Chris@13 52 }
Chris@13 53
Chris@13 54 /**
Chris@13 55 * Checks whether the identifier is a special class name (self, parent or static).
Chris@13 56 *
Chris@13 57 * @return bool Whether identifier is a special class name
Chris@13 58 */
Chris@13 59 public function isSpecialClassName() : bool {
Chris@13 60 return isset(self::$specialClassNames[strtolower($this->name)]);
Chris@13 61 }
Chris@13 62
Chris@13 63 /**
Chris@13 64 * Get identifier as string.
Chris@13 65 *
Chris@13 66 * @return string Identifier as string
Chris@13 67 */
Chris@13 68 public function __toString() : string {
Chris@13 69 return $this->name;
Chris@13 70 }
Chris@13 71
Chris@13 72 public function getType() : string {
Chris@13 73 return 'Identifier';
Chris@13 74 }
Chris@13 75 }