@@ -13,13 +13,13 @@ |
||
13 | 13 | * @param string|Identifier|Name $type Type |
14 | 14 | * @param array $attributes Additional attributes |
15 | 15 | */ |
16 | - public function __construct($type, array $attributes = []) { |
|
16 | + public function __construct( $type, array $attributes = [ ] ) { |
|
17 | 17 | $this->attributes = $attributes; |
18 | - $this->type = \is_string($type) ? new Identifier($type) : $type; |
|
18 | + $this->type = \is_string( $type ) ? new Identifier( $type ) : $type; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function getSubNodeNames() : array { |
22 | - return ['type']; |
|
22 | + return [ 'type' ]; |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function getType() : string { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param Identifier|null $name Parameter name (for named parameters) |
27 | 27 | */ |
28 | 28 | public function __construct( |
29 | - Expr $value, bool $byRef = false, bool $unpack = false, array $attributes = [], |
|
29 | + Expr $value, bool $byRef = false, bool $unpack = false, array $attributes = [ ], |
|
30 | 30 | Identifier $name = null |
31 | 31 | ) { |
32 | 32 | $this->attributes = $attributes; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | public function getSubNodeNames() : array { |
40 | - return ['name', 'value', 'byRef', 'unpack']; |
|
40 | + return [ 'name', 'value', 'byRef', 'unpack' ]; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function getType() : string { |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | * @param string|string[]|self $name Name as string, part array or Name instance (copy ctor) |
22 | 22 | * @param array $attributes Additional attributes |
23 | 23 | */ |
24 | - public function __construct($name, array $attributes = []) { |
|
24 | + public function __construct( $name, array $attributes = [ ] ) { |
|
25 | 25 | $this->attributes = $attributes; |
26 | - $this->parts = self::prepareName($name); |
|
26 | + $this->parts = self::prepareName( $name ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public function getSubNodeNames() : array { |
30 | - return ['parts']; |
|
30 | + return [ 'parts' ]; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @return string First part of the name |
37 | 37 | */ |
38 | 38 | public function getFirst() : string { |
39 | - return $this->parts[0]; |
|
39 | + return $this->parts[ 0 ]; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @return string Last part of the name |
46 | 46 | */ |
47 | 47 | public function getLast() : string { |
48 | - return $this->parts[count($this->parts) - 1]; |
|
48 | + return $this->parts[ count( $this->parts ) - 1 ]; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return bool Whether the name is unqualified |
55 | 55 | */ |
56 | 56 | public function isUnqualified() : bool { |
57 | - return 1 === count($this->parts); |
|
57 | + return 1 === count( $this->parts ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return bool Whether the name is qualified |
64 | 64 | */ |
65 | 65 | public function isQualified() : bool { |
66 | - return 1 < count($this->parts); |
|
66 | + return 1 < count( $this->parts ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return string String representation |
92 | 92 | */ |
93 | 93 | public function toString() : string { |
94 | - return implode('\\', $this->parts); |
|
94 | + return implode( '\\', $this->parts ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return string Lowercased string representation |
112 | 112 | */ |
113 | 113 | public function toLowerString() : string { |
114 | - return strtolower(implode('\\', $this->parts)); |
|
114 | + return strtolower( implode( '\\', $this->parts ) ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @return bool Whether identifier is a special class name |
121 | 121 | */ |
122 | 122 | public function isSpecialClassName() : bool { |
123 | - return count($this->parts) === 1 |
|
124 | - && isset(self::$specialClassNames[strtolower($this->parts[0])]); |
|
123 | + return count( $this->parts ) === 1 |
|
124 | + && isset( self::$specialClassNames[ strtolower( $this->parts[ 0 ] ) ] ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return string String representation |
132 | 132 | */ |
133 | 133 | public function __toString() : string { |
134 | - return implode('\\', $this->parts); |
|
134 | + return implode( '\\', $this->parts ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -150,29 +150,29 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return static|null Sliced name |
152 | 152 | */ |
153 | - public function slice(int $offset, int $length = null) { |
|
154 | - $numParts = count($this->parts); |
|
153 | + public function slice( int $offset, int $length = null ) { |
|
154 | + $numParts = count( $this->parts ); |
|
155 | 155 | |
156 | 156 | $realOffset = $offset < 0 ? $offset + $numParts : $offset; |
157 | - if ($realOffset < 0 || $realOffset > $numParts) { |
|
158 | - throw new \OutOfBoundsException(sprintf('Offset %d is out of bounds', $offset)); |
|
157 | + if ( $realOffset < 0 || $realOffset > $numParts ) { |
|
158 | + throw new \OutOfBoundsException( sprintf( 'Offset %d is out of bounds', $offset ) ); |
|
159 | 159 | } |
160 | 160 | |
161 | - if (null === $length) { |
|
161 | + if ( null === $length ) { |
|
162 | 162 | $realLength = $numParts - $realOffset; |
163 | 163 | } else { |
164 | 164 | $realLength = $length < 0 ? $length + $numParts - $realOffset : $length; |
165 | - if ($realLength < 0 || $realLength > $numParts) { |
|
166 | - throw new \OutOfBoundsException(sprintf('Length %d is out of bounds', $length)); |
|
165 | + if ( $realLength < 0 || $realLength > $numParts ) { |
|
166 | + throw new \OutOfBoundsException( sprintf( 'Length %d is out of bounds', $length ) ); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - if ($realLength === 0) { |
|
170 | + if ( $realLength === 0 ) { |
|
171 | 171 | // Empty slice is represented as null |
172 | 172 | return null; |
173 | 173 | } |
174 | 174 | |
175 | - return new static(array_slice($this->parts, $realOffset, $realLength), $this->attributes); |
|
175 | + return new static( array_slice( $this->parts, $realOffset, $realLength ), $this->attributes ); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -192,16 +192,16 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return static|null Concatenated name |
194 | 194 | */ |
195 | - public static function concat($name1, $name2, array $attributes = []) { |
|
196 | - if (null === $name1 && null === $name2) { |
|
195 | + public static function concat( $name1, $name2, array $attributes = [ ] ) { |
|
196 | + if ( null === $name1 && null === $name2 ) { |
|
197 | 197 | return null; |
198 | - } elseif (null === $name1) { |
|
199 | - return new static(self::prepareName($name2), $attributes); |
|
200 | - } elseif (null === $name2) { |
|
201 | - return new static(self::prepareName($name1), $attributes); |
|
198 | + } elseif ( null === $name1 ) { |
|
199 | + return new static( self::prepareName( $name2 ), $attributes ); |
|
200 | + } elseif ( null === $name2 ) { |
|
201 | + return new static( self::prepareName( $name1 ), $attributes ); |
|
202 | 202 | } else { |
203 | 203 | return new static( |
204 | - array_merge(self::prepareName($name1), self::prepareName($name2)), $attributes |
|
204 | + array_merge( self::prepareName( $name1 ), self::prepareName( $name2 ) ), $attributes |
|
205 | 205 | ); |
206 | 206 | } |
207 | 207 | } |
@@ -214,20 +214,20 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return string[] Prepared name |
216 | 216 | */ |
217 | - private static function prepareName($name) : array { |
|
218 | - if (\is_string($name)) { |
|
219 | - if ('' === $name) { |
|
220 | - throw new \InvalidArgumentException('Name cannot be empty'); |
|
217 | + private static function prepareName( $name ) : array { |
|
218 | + if ( \is_string( $name ) ) { |
|
219 | + if ( '' === $name ) { |
|
220 | + throw new \InvalidArgumentException( 'Name cannot be empty' ); |
|
221 | 221 | } |
222 | 222 | |
223 | - return explode('\\', $name); |
|
224 | - } elseif (\is_array($name)) { |
|
225 | - if (empty($name)) { |
|
226 | - throw new \InvalidArgumentException('Name cannot be empty'); |
|
223 | + return explode( '\\', $name ); |
|
224 | + } elseif ( \is_array( $name ) ) { |
|
225 | + if ( empty( $name ) ) { |
|
226 | + throw new \InvalidArgumentException( 'Name cannot be empty' ); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | return $name; |
230 | - } elseif ($name instanceof self) { |
|
230 | + } elseif ( $name instanceof self ) { |
|
231 | 231 | return $name->parts; |
232 | 232 | } |
233 | 233 |
@@ -21,14 +21,14 @@ |
||
21 | 21 | * @param Expr $value Value |
22 | 22 | * @param array $attributes Additional attributes |
23 | 23 | */ |
24 | - public function __construct($name, Expr $value, array $attributes = []) { |
|
24 | + public function __construct( $name, Expr $value, array $attributes = [ ] ) { |
|
25 | 25 | $this->attributes = $attributes; |
26 | - $this->name = \is_string($name) ? new Identifier($name) : $name; |
|
26 | + $this->name = \is_string( $name ) ? new Identifier( $name ) : $name; |
|
27 | 27 | $this->value = $value; |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function getSubNodeNames() : array { |
31 | - return ['name', 'value']; |
|
31 | + return [ 'name', 'value' ]; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function getType() : string { |
@@ -15,13 +15,13 @@ |
||
15 | 15 | * @param Expr $expr Expression |
16 | 16 | * @param array $attributes Additional attributes |
17 | 17 | */ |
18 | - public function __construct(Expr $expr, array $attributes = []) { |
|
18 | + public function __construct( Expr $expr, array $attributes = [ ] ) { |
|
19 | 19 | $this->attributes = $attributes; |
20 | 20 | $this->expr = $expr; |
21 | 21 | } |
22 | 22 | |
23 | 23 | public function getSubNodeNames() : array { |
24 | - return ['expr']; |
|
24 | + return [ 'expr' ]; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function getType() : string { |
@@ -19,14 +19,14 @@ |
||
19 | 19 | * @param string|Identifier|Expr $name Property name |
20 | 20 | * @param array $attributes Additional attributes |
21 | 21 | */ |
22 | - public function __construct(Expr $var, $name, array $attributes = []) { |
|
22 | + public function __construct( Expr $var, $name, array $attributes = [ ] ) { |
|
23 | 23 | $this->attributes = $attributes; |
24 | 24 | $this->var = $var; |
25 | - $this->name = \is_string($name) ? new Identifier($name) : $name; |
|
25 | + $this->name = \is_string( $name ) ? new Identifier( $name ) : $name; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function getSubNodeNames() : array { |
29 | - return ['var', 'name']; |
|
29 | + return [ 'var', 'name' ]; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function getType() : string { |
@@ -19,14 +19,14 @@ |
||
19 | 19 | * @param array<Node\Arg|Node\VariadicPlaceholder> $args Arguments |
20 | 20 | * @param array $attributes Additional attributes |
21 | 21 | */ |
22 | - public function __construct($name, array $args = [], array $attributes = []) { |
|
22 | + public function __construct( $name, array $args = [ ], array $attributes = [ ] ) { |
|
23 | 23 | $this->attributes = $attributes; |
24 | 24 | $this->name = $name; |
25 | 25 | $this->args = $args; |
26 | 26 | } |
27 | 27 | |
28 | 28 | public function getSubNodeNames() : array { |
29 | - return ['name', 'args']; |
|
29 | + return [ 'name', 'args' ]; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function getType() : string { |
@@ -18,14 +18,14 @@ |
||
18 | 18 | * @param Expr $expr Expression |
19 | 19 | * @param array $attributes Additional attributes |
20 | 20 | */ |
21 | - public function __construct(Expr $var, Expr $expr, array $attributes = []) { |
|
21 | + public function __construct( Expr $var, Expr $expr, array $attributes = [ ] ) { |
|
22 | 22 | $this->attributes = $attributes; |
23 | 23 | $this->var = $var; |
24 | 24 | $this->expr = $expr; |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function getSubNodeNames() : array { |
28 | - return ['var', 'expr']; |
|
28 | + return [ 'var', 'expr' ]; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public function getType() : string { |
@@ -20,14 +20,14 @@ |
||
20 | 20 | * @param string|Identifier|Error $name Constant name |
21 | 21 | * @param array $attributes Additional attributes |
22 | 22 | */ |
23 | - public function __construct($class, $name, array $attributes = []) { |
|
23 | + public function __construct( $class, $name, array $attributes = [ ] ) { |
|
24 | 24 | $this->attributes = $attributes; |
25 | 25 | $this->class = $class; |
26 | - $this->name = \is_string($name) ? new Identifier($name) : $name; |
|
26 | + $this->name = \is_string( $name ) ? new Identifier( $name ) : $name; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public function getSubNodeNames() : array { |
30 | - return ['class', 'name']; |
|
30 | + return [ 'class', 'name' ]; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function getType() : string { |