@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class Function_ extends MagicConst |
8 | 8 | { |
9 | - public function getName() : string { |
|
10 | - return '__FUNCTION__'; |
|
11 | - } |
|
9 | + public function getName() : string { |
|
10 | + return '__FUNCTION__'; |
|
11 | + } |
|
12 | 12 | |
13 | - public function getType() : string { |
|
14 | - return 'Scalar_MagicConst_Function'; |
|
15 | - } |
|
13 | + public function getType() : string { |
|
14 | + return 'Scalar_MagicConst_Function'; |
|
15 | + } |
|
16 | 16 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class Line extends MagicConst |
8 | 8 | { |
9 | - public function getName() : string { |
|
10 | - return '__LINE__'; |
|
11 | - } |
|
9 | + public function getName() : string { |
|
10 | + return '__LINE__'; |
|
11 | + } |
|
12 | 12 | |
13 | - public function getType() : string { |
|
14 | - return 'Scalar_MagicConst_Line'; |
|
15 | - } |
|
13 | + public function getType() : string { |
|
14 | + return 'Scalar_MagicConst_Line'; |
|
15 | + } |
|
16 | 16 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class Class_ extends MagicConst |
8 | 8 | { |
9 | - public function getName() : string { |
|
10 | - return '__CLASS__'; |
|
11 | - } |
|
9 | + public function getName() : string { |
|
10 | + return '__CLASS__'; |
|
11 | + } |
|
12 | 12 | |
13 | - public function getType() : string { |
|
14 | - return 'Scalar_MagicConst_Class'; |
|
15 | - } |
|
13 | + public function getType() : string { |
|
14 | + return 'Scalar_MagicConst_Class'; |
|
15 | + } |
|
16 | 16 | } |
@@ -6,23 +6,23 @@ |
||
6 | 6 | |
7 | 7 | abstract class MagicConst extends Scalar |
8 | 8 | { |
9 | - /** |
|
10 | - * Constructs a magic constant node. |
|
11 | - * |
|
12 | - * @param array $attributes Additional attributes |
|
13 | - */ |
|
14 | - public function __construct(array $attributes = []) { |
|
15 | - $this->attributes = $attributes; |
|
16 | - } |
|
9 | + /** |
|
10 | + * Constructs a magic constant node. |
|
11 | + * |
|
12 | + * @param array $attributes Additional attributes |
|
13 | + */ |
|
14 | + public function __construct(array $attributes = []) { |
|
15 | + $this->attributes = $attributes; |
|
16 | + } |
|
17 | 17 | |
18 | - public function getSubNodeNames() : array { |
|
19 | - return []; |
|
20 | - } |
|
18 | + public function getSubNodeNames() : array { |
|
19 | + return []; |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Get name of magic constant. |
|
24 | - * |
|
25 | - * @return string Name of magic constant |
|
26 | - */ |
|
27 | - abstract public function getName() : string; |
|
22 | + /** |
|
23 | + * Get name of magic constant. |
|
24 | + * |
|
25 | + * @return string Name of magic constant |
|
26 | + */ |
|
27 | + abstract public function getName() : string; |
|
28 | 28 | } |
@@ -7,135 +7,135 @@ |
||
7 | 7 | |
8 | 8 | class String_ extends Scalar |
9 | 9 | { |
10 | - /* For use in "kind" attribute */ |
|
11 | - const KIND_SINGLE_QUOTED = 1; |
|
12 | - const KIND_DOUBLE_QUOTED = 2; |
|
13 | - const KIND_HEREDOC = 3; |
|
14 | - const KIND_NOWDOC = 4; |
|
10 | + /* For use in "kind" attribute */ |
|
11 | + const KIND_SINGLE_QUOTED = 1; |
|
12 | + const KIND_DOUBLE_QUOTED = 2; |
|
13 | + const KIND_HEREDOC = 3; |
|
14 | + const KIND_NOWDOC = 4; |
|
15 | 15 | |
16 | - /** @var string String value */ |
|
17 | - public $value; |
|
16 | + /** @var string String value */ |
|
17 | + public $value; |
|
18 | 18 | |
19 | - protected static $replacements = [ |
|
20 | - '\\' => '\\', |
|
21 | - '$' => '$', |
|
22 | - 'n' => "\n", |
|
23 | - 'r' => "\r", |
|
24 | - 't' => "\t", |
|
25 | - 'f' => "\f", |
|
26 | - 'v' => "\v", |
|
27 | - 'e' => "\x1B", |
|
28 | - ]; |
|
19 | + protected static $replacements = [ |
|
20 | + '\\' => '\\', |
|
21 | + '$' => '$', |
|
22 | + 'n' => "\n", |
|
23 | + 'r' => "\r", |
|
24 | + 't' => "\t", |
|
25 | + 'f' => "\f", |
|
26 | + 'v' => "\v", |
|
27 | + 'e' => "\x1B", |
|
28 | + ]; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Constructs a string scalar node. |
|
32 | - * |
|
33 | - * @param string $value Value of the string |
|
34 | - * @param array $attributes Additional attributes |
|
35 | - */ |
|
36 | - public function __construct(string $value, array $attributes = []) { |
|
37 | - $this->attributes = $attributes; |
|
38 | - $this->value = $value; |
|
39 | - } |
|
30 | + /** |
|
31 | + * Constructs a string scalar node. |
|
32 | + * |
|
33 | + * @param string $value Value of the string |
|
34 | + * @param array $attributes Additional attributes |
|
35 | + */ |
|
36 | + public function __construct(string $value, array $attributes = []) { |
|
37 | + $this->attributes = $attributes; |
|
38 | + $this->value = $value; |
|
39 | + } |
|
40 | 40 | |
41 | - public function getSubNodeNames() : array { |
|
42 | - return ['value']; |
|
43 | - } |
|
41 | + public function getSubNodeNames() : array { |
|
42 | + return ['value']; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @internal |
|
47 | - * |
|
48 | - * Parses a string token. |
|
49 | - * |
|
50 | - * @param string $str String token content |
|
51 | - * @param bool $parseUnicodeEscape Whether to parse PHP 7 \u escapes |
|
52 | - * |
|
53 | - * @return string The parsed string |
|
54 | - */ |
|
55 | - public static function parse(string $str, bool $parseUnicodeEscape = true) : string { |
|
56 | - $bLength = 0; |
|
57 | - if ('b' === $str[0] || 'B' === $str[0]) { |
|
58 | - $bLength = 1; |
|
59 | - } |
|
45 | + /** |
|
46 | + * @internal |
|
47 | + * |
|
48 | + * Parses a string token. |
|
49 | + * |
|
50 | + * @param string $str String token content |
|
51 | + * @param bool $parseUnicodeEscape Whether to parse PHP 7 \u escapes |
|
52 | + * |
|
53 | + * @return string The parsed string |
|
54 | + */ |
|
55 | + public static function parse(string $str, bool $parseUnicodeEscape = true) : string { |
|
56 | + $bLength = 0; |
|
57 | + if ('b' === $str[0] || 'B' === $str[0]) { |
|
58 | + $bLength = 1; |
|
59 | + } |
|
60 | 60 | |
61 | - if ('\'' === $str[$bLength]) { |
|
62 | - return str_replace( |
|
63 | - ['\\\\', '\\\''], |
|
64 | - ['\\', '\''], |
|
65 | - substr($str, $bLength + 1, -1) |
|
66 | - ); |
|
67 | - } else { |
|
68 | - return self::parseEscapeSequences( |
|
69 | - substr($str, $bLength + 1, -1), '"', $parseUnicodeEscape |
|
70 | - ); |
|
71 | - } |
|
72 | - } |
|
61 | + if ('\'' === $str[$bLength]) { |
|
62 | + return str_replace( |
|
63 | + ['\\\\', '\\\''], |
|
64 | + ['\\', '\''], |
|
65 | + substr($str, $bLength + 1, -1) |
|
66 | + ); |
|
67 | + } else { |
|
68 | + return self::parseEscapeSequences( |
|
69 | + substr($str, $bLength + 1, -1), '"', $parseUnicodeEscape |
|
70 | + ); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @internal |
|
76 | - * |
|
77 | - * Parses escape sequences in strings (all string types apart from single quoted). |
|
78 | - * |
|
79 | - * @param string $str String without quotes |
|
80 | - * @param null|string $quote Quote type |
|
81 | - * @param bool $parseUnicodeEscape Whether to parse PHP 7 \u escapes |
|
82 | - * |
|
83 | - * @return string String with escape sequences parsed |
|
84 | - */ |
|
85 | - public static function parseEscapeSequences(string $str, $quote, bool $parseUnicodeEscape = true) : string { |
|
86 | - if (null !== $quote) { |
|
87 | - $str = str_replace('\\' . $quote, $quote, $str); |
|
88 | - } |
|
74 | + /** |
|
75 | + * @internal |
|
76 | + * |
|
77 | + * Parses escape sequences in strings (all string types apart from single quoted). |
|
78 | + * |
|
79 | + * @param string $str String without quotes |
|
80 | + * @param null|string $quote Quote type |
|
81 | + * @param bool $parseUnicodeEscape Whether to parse PHP 7 \u escapes |
|
82 | + * |
|
83 | + * @return string String with escape sequences parsed |
|
84 | + */ |
|
85 | + public static function parseEscapeSequences(string $str, $quote, bool $parseUnicodeEscape = true) : string { |
|
86 | + if (null !== $quote) { |
|
87 | + $str = str_replace('\\' . $quote, $quote, $str); |
|
88 | + } |
|
89 | 89 | |
90 | - $extra = ''; |
|
91 | - if ($parseUnicodeEscape) { |
|
92 | - $extra = '|u\{([0-9a-fA-F]+)\}'; |
|
93 | - } |
|
90 | + $extra = ''; |
|
91 | + if ($parseUnicodeEscape) { |
|
92 | + $extra = '|u\{([0-9a-fA-F]+)\}'; |
|
93 | + } |
|
94 | 94 | |
95 | - return preg_replace_callback( |
|
96 | - '~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3}' . $extra . ')~', |
|
97 | - function($matches) { |
|
98 | - $str = $matches[1]; |
|
95 | + return preg_replace_callback( |
|
96 | + '~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3}' . $extra . ')~', |
|
97 | + function($matches) { |
|
98 | + $str = $matches[1]; |
|
99 | 99 | |
100 | - if (isset(self::$replacements[$str])) { |
|
101 | - return self::$replacements[$str]; |
|
102 | - } elseif ('x' === $str[0] || 'X' === $str[0]) { |
|
103 | - return chr(hexdec(substr($str, 1))); |
|
104 | - } elseif ('u' === $str[0]) { |
|
105 | - return self::codePointToUtf8(hexdec($matches[2])); |
|
106 | - } else { |
|
107 | - return chr(octdec($str)); |
|
108 | - } |
|
109 | - }, |
|
110 | - $str |
|
111 | - ); |
|
112 | - } |
|
100 | + if (isset(self::$replacements[$str])) { |
|
101 | + return self::$replacements[$str]; |
|
102 | + } elseif ('x' === $str[0] || 'X' === $str[0]) { |
|
103 | + return chr(hexdec(substr($str, 1))); |
|
104 | + } elseif ('u' === $str[0]) { |
|
105 | + return self::codePointToUtf8(hexdec($matches[2])); |
|
106 | + } else { |
|
107 | + return chr(octdec($str)); |
|
108 | + } |
|
109 | + }, |
|
110 | + $str |
|
111 | + ); |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * Converts a Unicode code point to its UTF-8 encoded representation. |
|
116 | - * |
|
117 | - * @param int $num Code point |
|
118 | - * |
|
119 | - * @return string UTF-8 representation of code point |
|
120 | - */ |
|
121 | - private static function codePointToUtf8(int $num) : string { |
|
122 | - if ($num <= 0x7F) { |
|
123 | - return chr($num); |
|
124 | - } |
|
125 | - if ($num <= 0x7FF) { |
|
126 | - return chr(($num>>6) + 0xC0) . chr(($num&0x3F) + 0x80); |
|
127 | - } |
|
128 | - if ($num <= 0xFFFF) { |
|
129 | - return chr(($num>>12) + 0xE0) . chr((($num>>6)&0x3F) + 0x80) . chr(($num&0x3F) + 0x80); |
|
130 | - } |
|
131 | - if ($num <= 0x1FFFFF) { |
|
132 | - return chr(($num>>18) + 0xF0) . chr((($num>>12)&0x3F) + 0x80) |
|
133 | - . chr((($num>>6)&0x3F) + 0x80) . chr(($num&0x3F) + 0x80); |
|
134 | - } |
|
135 | - throw new Error('Invalid UTF-8 codepoint escape sequence: Codepoint too large'); |
|
136 | - } |
|
114 | + /** |
|
115 | + * Converts a Unicode code point to its UTF-8 encoded representation. |
|
116 | + * |
|
117 | + * @param int $num Code point |
|
118 | + * |
|
119 | + * @return string UTF-8 representation of code point |
|
120 | + */ |
|
121 | + private static function codePointToUtf8(int $num) : string { |
|
122 | + if ($num <= 0x7F) { |
|
123 | + return chr($num); |
|
124 | + } |
|
125 | + if ($num <= 0x7FF) { |
|
126 | + return chr(($num>>6) + 0xC0) . chr(($num&0x3F) + 0x80); |
|
127 | + } |
|
128 | + if ($num <= 0xFFFF) { |
|
129 | + return chr(($num>>12) + 0xE0) . chr((($num>>6)&0x3F) + 0x80) . chr(($num&0x3F) + 0x80); |
|
130 | + } |
|
131 | + if ($num <= 0x1FFFFF) { |
|
132 | + return chr(($num>>18) + 0xF0) . chr((($num>>12)&0x3F) + 0x80) |
|
133 | + . chr((($num>>6)&0x3F) + 0x80) . chr(($num&0x3F) + 0x80); |
|
134 | + } |
|
135 | + throw new Error('Invalid UTF-8 codepoint escape sequence: Codepoint too large'); |
|
136 | + } |
|
137 | 137 | |
138 | - public function getType() : string { |
|
139 | - return 'Scalar_String'; |
|
140 | - } |
|
138 | + public function getType() : string { |
|
139 | + return 'Scalar_String'; |
|
140 | + } |
|
141 | 141 | } |
@@ -6,38 +6,38 @@ |
||
6 | 6 | |
7 | 7 | interface FunctionLike extends Node |
8 | 8 | { |
9 | - /** |
|
10 | - * Whether to return by reference |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function returnsByRef() : bool; |
|
9 | + /** |
|
10 | + * Whether to return by reference |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function returnsByRef() : bool; |
|
15 | 15 | |
16 | - /** |
|
17 | - * List of parameters |
|
18 | - * |
|
19 | - * @return Param[] |
|
20 | - */ |
|
21 | - public function getParams() : array; |
|
16 | + /** |
|
17 | + * List of parameters |
|
18 | + * |
|
19 | + * @return Param[] |
|
20 | + */ |
|
21 | + public function getParams() : array; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Get the declared return type or null |
|
25 | - * |
|
26 | - * @return null|Identifier|Name|ComplexType |
|
27 | - */ |
|
28 | - public function getReturnType(); |
|
23 | + /** |
|
24 | + * Get the declared return type or null |
|
25 | + * |
|
26 | + * @return null|Identifier|Name|ComplexType |
|
27 | + */ |
|
28 | + public function getReturnType(); |
|
29 | 29 | |
30 | - /** |
|
31 | - * The function body |
|
32 | - * |
|
33 | - * @return Stmt[]|null |
|
34 | - */ |
|
35 | - public function getStmts(); |
|
30 | + /** |
|
31 | + * The function body |
|
32 | + * |
|
33 | + * @return Stmt[]|null |
|
34 | + */ |
|
35 | + public function getStmts(); |
|
36 | 36 | |
37 | - /** |
|
38 | - * Get PHP attribute groups. |
|
39 | - * |
|
40 | - * @return AttributeGroup[] |
|
41 | - */ |
|
42 | - public function getAttrGroups() : array; |
|
37 | + /** |
|
38 | + * Get PHP attribute groups. |
|
39 | + * |
|
40 | + * @return AttributeGroup[] |
|
41 | + */ |
|
42 | + public function getAttrGroups() : array; |
|
43 | 43 | } |
@@ -8,20 +8,20 @@ |
||
8 | 8 | * Represents the "..." in "foo(...)" of the first-class callable syntax. |
9 | 9 | */ |
10 | 10 | class VariadicPlaceholder extends NodeAbstract { |
11 | - /** |
|
12 | - * Create a variadic argument placeholder (first-class callable syntax). |
|
13 | - * |
|
14 | - * @param array $attributes Additional attributes |
|
15 | - */ |
|
16 | - public function __construct(array $attributes = []) { |
|
17 | - $this->attributes = $attributes; |
|
18 | - } |
|
11 | + /** |
|
12 | + * Create a variadic argument placeholder (first-class callable syntax). |
|
13 | + * |
|
14 | + * @param array $attributes Additional attributes |
|
15 | + */ |
|
16 | + public function __construct(array $attributes = []) { |
|
17 | + $this->attributes = $attributes; |
|
18 | + } |
|
19 | 19 | |
20 | - public function getType(): string { |
|
21 | - return 'VariadicPlaceholder'; |
|
22 | - } |
|
20 | + public function getType(): string { |
|
21 | + return 'VariadicPlaceholder'; |
|
22 | + } |
|
23 | 23 | |
24 | - public function getSubNodeNames(): array { |
|
25 | - return []; |
|
26 | - } |
|
24 | + public function getSubNodeNames(): array { |
|
25 | + return []; |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -7,25 +7,25 @@ |
||
7 | 7 | |
8 | 8 | class MatchArm extends NodeAbstract |
9 | 9 | { |
10 | - /** @var null|Node\Expr[] */ |
|
11 | - public $conds; |
|
12 | - /** @var Node\Expr */ |
|
13 | - public $body; |
|
10 | + /** @var null|Node\Expr[] */ |
|
11 | + public $conds; |
|
12 | + /** @var Node\Expr */ |
|
13 | + public $body; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @param null|Node\Expr[] $conds |
|
17 | - */ |
|
18 | - public function __construct($conds, Node\Expr $body, array $attributes = []) { |
|
19 | - $this->conds = $conds; |
|
20 | - $this->body = $body; |
|
21 | - $this->attributes = $attributes; |
|
22 | - } |
|
15 | + /** |
|
16 | + * @param null|Node\Expr[] $conds |
|
17 | + */ |
|
18 | + public function __construct($conds, Node\Expr $body, array $attributes = []) { |
|
19 | + $this->conds = $conds; |
|
20 | + $this->body = $body; |
|
21 | + $this->attributes = $attributes; |
|
22 | + } |
|
23 | 23 | |
24 | - public function getSubNodeNames() : array { |
|
25 | - return ['conds', 'body']; |
|
26 | - } |
|
24 | + public function getSubNodeNames() : array { |
|
25 | + return ['conds', 'body']; |
|
26 | + } |
|
27 | 27 | |
28 | - public function getType() : string { |
|
29 | - return 'MatchArm'; |
|
30 | - } |
|
28 | + public function getType() : string { |
|
29 | + return 'MatchArm'; |
|
30 | + } |
|
31 | 31 | } |
@@ -4,25 +4,25 @@ |
||
4 | 4 | |
5 | 5 | class NullableType extends ComplexType |
6 | 6 | { |
7 | - /** @var Identifier|Name Type */ |
|
8 | - public $type; |
|
7 | + /** @var Identifier|Name Type */ |
|
8 | + public $type; |
|
9 | 9 | |
10 | - /** |
|
11 | - * Constructs a nullable type (wrapping another type). |
|
12 | - * |
|
13 | - * @param string|Identifier|Name $type Type |
|
14 | - * @param array $attributes Additional attributes |
|
15 | - */ |
|
16 | - public function __construct($type, array $attributes = []) { |
|
17 | - $this->attributes = $attributes; |
|
18 | - $this->type = \is_string($type) ? new Identifier($type) : $type; |
|
19 | - } |
|
10 | + /** |
|
11 | + * Constructs a nullable type (wrapping another type). |
|
12 | + * |
|
13 | + * @param string|Identifier|Name $type Type |
|
14 | + * @param array $attributes Additional attributes |
|
15 | + */ |
|
16 | + public function __construct($type, array $attributes = []) { |
|
17 | + $this->attributes = $attributes; |
|
18 | + $this->type = \is_string($type) ? new Identifier($type) : $type; |
|
19 | + } |
|
20 | 20 | |
21 | - public function getSubNodeNames() : array { |
|
22 | - return ['type']; |
|
23 | - } |
|
21 | + public function getSubNodeNames() : array { |
|
22 | + return ['type']; |
|
23 | + } |
|
24 | 24 | |
25 | - public function getType() : string { |
|
26 | - return 'NullableType'; |
|
27 | - } |
|
25 | + public function getType() : string { |
|
26 | + return 'NullableType'; |
|
27 | + } |
|
28 | 28 | } |