PluginProbe
WPIDE – File Manager & Code Editor / 3.5.9
WPIDE – File Manager & Code Editor v3.5.9
3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 All 55 releases
wpide / vendor / nikic / php-parser / lib / PhpParser / Node / Stmt / ClassMethod.php

ClassMethod.php in WPIDE – File Manager & Code Editor 3.5.9, at vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php

162 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace PhpParser\Node\Stmt;
4
5 use PhpParser\Node;
6 use PhpParser\Node\FunctionLike;
7
8 class ClassMethod extends Node\Stmt implements FunctionLike
9 {
10 /** @var int Flags */
11 public $flags;
12 /** @var bool Whether to return by reference */
13 public $byRef;
14 /** @var Node\Identifier Name */
15 public $name;
16 /** @var Node\Param[] Parameters */
17 public $params;
18 /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */
19 public $returnType;
20 /** @var Node\Stmt[]|null Statements */
21 public $stmts;
22 /** @var Node\AttributeGroup[] PHP attribute groups */
23 public $attrGroups;
24
25 private static $magicNames = [
26 '__construct' => true,
27 '__destruct' => true,
28 '__call' => true,
29 '__callstatic' => true,
30 '__get' => true,
31 '__set' => true,
32 '__isset' => true,
33 '__unset' => true,
34 '__sleep' => true,
35 '__wakeup' => true,
36 '__tostring' => true,
37 '__set_state' => true,
38 '__clone' => true,
39 '__invoke' => true,
40 '__debuginfo' => true,
41 '__serialize' => true,
42 '__unserialize' => true,
43 ];
44
45 /**
46 * Constructs a class method node.
47 *
48 * @param string|Node\Identifier $name Name
49 * @param array $subNodes Array of the following optional subnodes:
50 * 'flags => MODIFIER_PUBLIC: Flags
51 * 'byRef' => false : Whether to return by reference
52 * 'params' => array() : Parameters
53 * 'returnType' => null : Return type
54 * 'stmts' => array() : Statements
55 * 'attrGroups' => array() : PHP attribute groups
56 * @param array $attributes Additional attributes
57 */
58 public function __construct($name, array $subNodes = [], array $attributes = []) {
59 $this->attributes = $attributes;
60 $this->flags = $subNodes['flags'] ?? $subNodes['type'] ?? 0;
61 $this->byRef = $subNodes['byRef'] ?? false;
62 $this->name = \is_string($name) ? new Node\Identifier($name) : $name;
63 $this->params = $subNodes['params'] ?? [];
64 $returnType = $subNodes['returnType'] ?? null;
65 $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType;
66 $this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : [];
67 $this->attrGroups = $subNodes['attrGroups'] ?? [];
68 }
69
70 public function getSubNodeNames() : array {
71 return ['attrGroups', 'flags', 'byRef', 'name', 'params', 'returnType', 'stmts'];
72 }
73
74 public function returnsByRef() : bool {
75 return $this->byRef;
76 }
77
78 public function getParams() : array {
79 return $this->params;
80 }
81
82 public function getReturnType() {
83 return $this->returnType;
84 }
85
86 public function getStmts() {
87 return $this->stmts;
88 }
89
90 public function getAttrGroups() : array {
91 return $this->attrGroups;
92 }
93
94 /**
95 * Whether the method is explicitly or implicitly public.
96 *
97 * @return bool
98 */
99 public function isPublic() : bool {
100 return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
101 || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
102 }
103
104 /**
105 * Whether the method is protected.
106 *
107 * @return bool
108 */
109 public function isProtected() : bool {
110 return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
111 }
112
113 /**
114 * Whether the method is private.
115 *
116 * @return bool
117 */
118 public function isPrivate() : bool {
119 return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
120 }
121
122 /**
123 * Whether the method is abstract.
124 *
125 * @return bool
126 */
127 public function isAbstract() : bool {
128 return (bool) ($this->flags & Class_::MODIFIER_ABSTRACT);
129 }
130
131 /**
132 * Whether the method is final.
133 *
134 * @return bool
135 */
136 public function isFinal() : bool {
137 return (bool) ($this->flags & Class_::MODIFIER_FINAL);
138 }
139
140 /**
141 * Whether the method is static.
142 *
143 * @return bool
144 */
145 public function isStatic() : bool {
146 return (bool) ($this->flags & Class_::MODIFIER_STATIC);
147 }
148
149 /**
150 * Whether the method is magic.
151 *
152 * @return bool
153 */
154 public function isMagic() : bool {
155 return isset(self::$magicNames[$this->name->toLowerString()]);
156 }
157
158 public function getType() : string {
159 return 'Stmt_ClassMethod';
160 }
161 }
162