@@ -4,25 +4,25 @@ |
||
4 | 4 | |
5 | 5 | class UnionType extends ComplexType |
6 | 6 | { |
7 | - /** @var (Identifier|Name)[] Types */ |
|
8 | - public $types; |
|
7 | + /** @var (Identifier|Name)[] Types */ |
|
8 | + public $types; |
|
9 | 9 | |
10 | - /** |
|
11 | - * Constructs a union type. |
|
12 | - * |
|
13 | - * @param (Identifier|Name)[] $types Types |
|
14 | - * @param array $attributes Additional attributes |
|
15 | - */ |
|
16 | - public function __construct(array $types, array $attributes = []) { |
|
17 | - $this->attributes = $attributes; |
|
18 | - $this->types = $types; |
|
19 | - } |
|
10 | + /** |
|
11 | + * Constructs a union type. |
|
12 | + * |
|
13 | + * @param (Identifier|Name)[] $types Types |
|
14 | + * @param array $attributes Additional attributes |
|
15 | + */ |
|
16 | + public function __construct(array $types, array $attributes = []) { |
|
17 | + $this->attributes = $attributes; |
|
18 | + $this->types = $types; |
|
19 | + } |
|
20 | 20 | |
21 | - public function getSubNodeNames() : array { |
|
22 | - return ['types']; |
|
23 | - } |
|
21 | + public function getSubNodeNames() : array { |
|
22 | + return ['types']; |
|
23 | + } |
|
24 | 24 | |
25 | - public function getType() : string { |
|
26 | - return 'UnionType'; |
|
27 | - } |
|
25 | + public function getType() : string { |
|
26 | + return 'UnionType'; |
|
27 | + } |
|
28 | 28 | } |
@@ -7,25 +7,25 @@ |
||
7 | 7 | |
8 | 8 | class Encapsed extends Scalar |
9 | 9 | { |
10 | - /** @var Expr[] list of string parts */ |
|
11 | - public $parts; |
|
10 | + /** @var Expr[] list of string parts */ |
|
11 | + public $parts; |
|
12 | 12 | |
13 | - /** |
|
14 | - * Constructs an encapsed string node. |
|
15 | - * |
|
16 | - * @param Expr[] $parts Encaps list |
|
17 | - * @param array $attributes Additional attributes |
|
18 | - */ |
|
19 | - public function __construct(array $parts, array $attributes = []) { |
|
20 | - $this->attributes = $attributes; |
|
21 | - $this->parts = $parts; |
|
22 | - } |
|
13 | + /** |
|
14 | + * Constructs an encapsed string node. |
|
15 | + * |
|
16 | + * @param Expr[] $parts Encaps list |
|
17 | + * @param array $attributes Additional attributes |
|
18 | + */ |
|
19 | + public function __construct(array $parts, array $attributes = []) { |
|
20 | + $this->attributes = $attributes; |
|
21 | + $this->parts = $parts; |
|
22 | + } |
|
23 | 23 | |
24 | - public function getSubNodeNames() : array { |
|
25 | - return ['parts']; |
|
26 | - } |
|
24 | + public function getSubNodeNames() : array { |
|
25 | + return ['parts']; |
|
26 | + } |
|
27 | 27 | |
28 | - public function getType() : string { |
|
29 | - return 'Scalar_Encapsed'; |
|
30 | - } |
|
28 | + public function getType() : string { |
|
29 | + return 'Scalar_Encapsed'; |
|
30 | + } |
|
31 | 31 | } |
@@ -6,65 +6,65 @@ |
||
6 | 6 | |
7 | 7 | class DNumber extends Scalar |
8 | 8 | { |
9 | - /** @var float Number value */ |
|
10 | - public $value; |
|
9 | + /** @var float Number value */ |
|
10 | + public $value; |
|
11 | 11 | |
12 | - /** |
|
13 | - * Constructs a float number scalar node. |
|
14 | - * |
|
15 | - * @param float $value Value of the number |
|
16 | - * @param array $attributes Additional attributes |
|
17 | - */ |
|
18 | - public function __construct(float $value, array $attributes = []) { |
|
19 | - $this->attributes = $attributes; |
|
20 | - $this->value = $value; |
|
21 | - } |
|
12 | + /** |
|
13 | + * Constructs a float number scalar node. |
|
14 | + * |
|
15 | + * @param float $value Value of the number |
|
16 | + * @param array $attributes Additional attributes |
|
17 | + */ |
|
18 | + public function __construct(float $value, array $attributes = []) { |
|
19 | + $this->attributes = $attributes; |
|
20 | + $this->value = $value; |
|
21 | + } |
|
22 | 22 | |
23 | - public function getSubNodeNames() : array { |
|
24 | - return ['value']; |
|
25 | - } |
|
23 | + public function getSubNodeNames() : array { |
|
24 | + return ['value']; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @internal |
|
29 | - * |
|
30 | - * Parses a DNUMBER token like PHP would. |
|
31 | - * |
|
32 | - * @param string $str A string number |
|
33 | - * |
|
34 | - * @return float The parsed number |
|
35 | - */ |
|
36 | - public static function parse(string $str) : float { |
|
37 | - $str = str_replace('_', '', $str); |
|
27 | + /** |
|
28 | + * @internal |
|
29 | + * |
|
30 | + * Parses a DNUMBER token like PHP would. |
|
31 | + * |
|
32 | + * @param string $str A string number |
|
33 | + * |
|
34 | + * @return float The parsed number |
|
35 | + */ |
|
36 | + public static function parse(string $str) : float { |
|
37 | + $str = str_replace('_', '', $str); |
|
38 | 38 | |
39 | - // if string contains any of .eE just cast it to float |
|
40 | - if (false !== strpbrk($str, '.eE')) { |
|
41 | - return (float) $str; |
|
42 | - } |
|
39 | + // if string contains any of .eE just cast it to float |
|
40 | + if (false !== strpbrk($str, '.eE')) { |
|
41 | + return (float) $str; |
|
42 | + } |
|
43 | 43 | |
44 | - // otherwise it's an integer notation that overflowed into a float |
|
45 | - // if it starts with 0 it's one of the special integer notations |
|
46 | - if ('0' === $str[0]) { |
|
47 | - // hex |
|
48 | - if ('x' === $str[1] || 'X' === $str[1]) { |
|
49 | - return hexdec($str); |
|
50 | - } |
|
44 | + // otherwise it's an integer notation that overflowed into a float |
|
45 | + // if it starts with 0 it's one of the special integer notations |
|
46 | + if ('0' === $str[0]) { |
|
47 | + // hex |
|
48 | + if ('x' === $str[1] || 'X' === $str[1]) { |
|
49 | + return hexdec($str); |
|
50 | + } |
|
51 | 51 | |
52 | - // bin |
|
53 | - if ('b' === $str[1] || 'B' === $str[1]) { |
|
54 | - return bindec($str); |
|
55 | - } |
|
52 | + // bin |
|
53 | + if ('b' === $str[1] || 'B' === $str[1]) { |
|
54 | + return bindec($str); |
|
55 | + } |
|
56 | 56 | |
57 | - // oct |
|
58 | - // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit (8 or 9) |
|
59 | - // so that only the digits before that are used |
|
60 | - return octdec(substr($str, 0, strcspn($str, '89'))); |
|
61 | - } |
|
57 | + // oct |
|
58 | + // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit (8 or 9) |
|
59 | + // so that only the digits before that are used |
|
60 | + return octdec(substr($str, 0, strcspn($str, '89'))); |
|
61 | + } |
|
62 | 62 | |
63 | - // dec |
|
64 | - return (float) $str; |
|
65 | - } |
|
63 | + // dec |
|
64 | + return (float) $str; |
|
65 | + } |
|
66 | 66 | |
67 | - public function getType() : string { |
|
68 | - return 'Scalar_DNumber'; |
|
69 | - } |
|
67 | + public function getType() : string { |
|
68 | + return 'Scalar_DNumber'; |
|
69 | + } |
|
70 | 70 | } |
@@ -7,72 +7,72 @@ |
||
7 | 7 | |
8 | 8 | class LNumber extends Scalar |
9 | 9 | { |
10 | - /* For use in "kind" attribute */ |
|
11 | - const KIND_BIN = 2; |
|
12 | - const KIND_OCT = 8; |
|
13 | - const KIND_DEC = 10; |
|
14 | - const KIND_HEX = 16; |
|
10 | + /* For use in "kind" attribute */ |
|
11 | + const KIND_BIN = 2; |
|
12 | + const KIND_OCT = 8; |
|
13 | + const KIND_DEC = 10; |
|
14 | + const KIND_HEX = 16; |
|
15 | 15 | |
16 | - /** @var int Number value */ |
|
17 | - public $value; |
|
16 | + /** @var int Number value */ |
|
17 | + public $value; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Constructs an integer number scalar node. |
|
21 | - * |
|
22 | - * @param int $value Value of the number |
|
23 | - * @param array $attributes Additional attributes |
|
24 | - */ |
|
25 | - public function __construct(int $value, array $attributes = []) { |
|
26 | - $this->attributes = $attributes; |
|
27 | - $this->value = $value; |
|
28 | - } |
|
19 | + /** |
|
20 | + * Constructs an integer number scalar node. |
|
21 | + * |
|
22 | + * @param int $value Value of the number |
|
23 | + * @param array $attributes Additional attributes |
|
24 | + */ |
|
25 | + public function __construct(int $value, array $attributes = []) { |
|
26 | + $this->attributes = $attributes; |
|
27 | + $this->value = $value; |
|
28 | + } |
|
29 | 29 | |
30 | - public function getSubNodeNames() : array { |
|
31 | - return ['value']; |
|
32 | - } |
|
30 | + public function getSubNodeNames() : array { |
|
31 | + return ['value']; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructs an LNumber node from a string number literal. |
|
36 | - * |
|
37 | - * @param string $str String number literal (decimal, octal, hex or binary) |
|
38 | - * @param array $attributes Additional attributes |
|
39 | - * @param bool $allowInvalidOctal Whether to allow invalid octal numbers (PHP 5) |
|
40 | - * |
|
41 | - * @return LNumber The constructed LNumber, including kind attribute |
|
42 | - */ |
|
43 | - public static function fromString(string $str, array $attributes = [], bool $allowInvalidOctal = false) : LNumber { |
|
44 | - $str = str_replace('_', '', $str); |
|
34 | + /** |
|
35 | + * Constructs an LNumber node from a string number literal. |
|
36 | + * |
|
37 | + * @param string $str String number literal (decimal, octal, hex or binary) |
|
38 | + * @param array $attributes Additional attributes |
|
39 | + * @param bool $allowInvalidOctal Whether to allow invalid octal numbers (PHP 5) |
|
40 | + * |
|
41 | + * @return LNumber The constructed LNumber, including kind attribute |
|
42 | + */ |
|
43 | + public static function fromString(string $str, array $attributes = [], bool $allowInvalidOctal = false) : LNumber { |
|
44 | + $str = str_replace('_', '', $str); |
|
45 | 45 | |
46 | - if ('0' !== $str[0] || '0' === $str) { |
|
47 | - $attributes['kind'] = LNumber::KIND_DEC; |
|
48 | - return new LNumber((int) $str, $attributes); |
|
49 | - } |
|
46 | + if ('0' !== $str[0] || '0' === $str) { |
|
47 | + $attributes['kind'] = LNumber::KIND_DEC; |
|
48 | + return new LNumber((int) $str, $attributes); |
|
49 | + } |
|
50 | 50 | |
51 | - if ('x' === $str[1] || 'X' === $str[1]) { |
|
52 | - $attributes['kind'] = LNumber::KIND_HEX; |
|
53 | - return new LNumber(hexdec($str), $attributes); |
|
54 | - } |
|
51 | + if ('x' === $str[1] || 'X' === $str[1]) { |
|
52 | + $attributes['kind'] = LNumber::KIND_HEX; |
|
53 | + return new LNumber(hexdec($str), $attributes); |
|
54 | + } |
|
55 | 55 | |
56 | - if ('b' === $str[1] || 'B' === $str[1]) { |
|
57 | - $attributes['kind'] = LNumber::KIND_BIN; |
|
58 | - return new LNumber(bindec($str), $attributes); |
|
59 | - } |
|
56 | + if ('b' === $str[1] || 'B' === $str[1]) { |
|
57 | + $attributes['kind'] = LNumber::KIND_BIN; |
|
58 | + return new LNumber(bindec($str), $attributes); |
|
59 | + } |
|
60 | 60 | |
61 | - if (!$allowInvalidOctal && strpbrk($str, '89')) { |
|
62 | - throw new Error('Invalid numeric literal', $attributes); |
|
63 | - } |
|
61 | + if (!$allowInvalidOctal && strpbrk($str, '89')) { |
|
62 | + throw new Error('Invalid numeric literal', $attributes); |
|
63 | + } |
|
64 | 64 | |
65 | - // Strip optional explicit octal prefix. |
|
66 | - if ('o' === $str[1] || 'O' === $str[1]) { |
|
67 | - $str = substr($str, 2); |
|
68 | - } |
|
65 | + // Strip optional explicit octal prefix. |
|
66 | + if ('o' === $str[1] || 'O' === $str[1]) { |
|
67 | + $str = substr($str, 2); |
|
68 | + } |
|
69 | 69 | |
70 | - // use intval instead of octdec to get proper cutting behavior with malformed numbers |
|
71 | - $attributes['kind'] = LNumber::KIND_OCT; |
|
72 | - return new LNumber(intval($str, 8), $attributes); |
|
73 | - } |
|
70 | + // use intval instead of octdec to get proper cutting behavior with malformed numbers |
|
71 | + $attributes['kind'] = LNumber::KIND_OCT; |
|
72 | + return new LNumber(intval($str, 8), $attributes); |
|
73 | + } |
|
74 | 74 | |
75 | - public function getType() : string { |
|
76 | - return 'Scalar_LNumber'; |
|
77 | - } |
|
75 | + public function getType() : string { |
|
76 | + return 'Scalar_LNumber'; |
|
77 | + } |
|
78 | 78 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class EncapsedStringPart extends Scalar |
8 | 8 | { |
9 | - /** @var string String value */ |
|
10 | - public $value; |
|
9 | + /** @var string String value */ |
|
10 | + public $value; |
|
11 | 11 | |
12 | - /** |
|
13 | - * Constructs a node representing a string part of an encapsed string. |
|
14 | - * |
|
15 | - * @param string $value String value |
|
16 | - * @param array $attributes Additional attributes |
|
17 | - */ |
|
18 | - public function __construct(string $value, array $attributes = []) { |
|
19 | - $this->attributes = $attributes; |
|
20 | - $this->value = $value; |
|
21 | - } |
|
12 | + /** |
|
13 | + * Constructs a node representing a string part of an encapsed string. |
|
14 | + * |
|
15 | + * @param string $value String value |
|
16 | + * @param array $attributes Additional attributes |
|
17 | + */ |
|
18 | + public function __construct(string $value, array $attributes = []) { |
|
19 | + $this->attributes = $attributes; |
|
20 | + $this->value = $value; |
|
21 | + } |
|
22 | 22 | |
23 | - public function getSubNodeNames() : array { |
|
24 | - return ['value']; |
|
25 | - } |
|
23 | + public function getSubNodeNames() : array { |
|
24 | + return ['value']; |
|
25 | + } |
|
26 | 26 | |
27 | - public function getType() : string { |
|
28 | - return 'Scalar_EncapsedStringPart'; |
|
29 | - } |
|
27 | + public function getType() : string { |
|
28 | + return 'Scalar_EncapsedStringPart'; |
|
29 | + } |
|
30 | 30 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class Namespace_ extends MagicConst |
8 | 8 | { |
9 | - public function getName() : string { |
|
10 | - return '__NAMESPACE__'; |
|
11 | - } |
|
9 | + public function getName() : string { |
|
10 | + return '__NAMESPACE__'; |
|
11 | + } |
|
12 | 12 | |
13 | - public function getType() : string { |
|
14 | - return 'Scalar_MagicConst_Namespace'; |
|
15 | - } |
|
13 | + public function getType() : string { |
|
14 | + return 'Scalar_MagicConst_Namespace'; |
|
15 | + } |
|
16 | 16 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class Dir extends MagicConst |
8 | 8 | { |
9 | - public function getName() : string { |
|
10 | - return '__DIR__'; |
|
11 | - } |
|
9 | + public function getName() : string { |
|
10 | + return '__DIR__'; |
|
11 | + } |
|
12 | 12 | |
13 | - public function getType() : string { |
|
14 | - return 'Scalar_MagicConst_Dir'; |
|
15 | - } |
|
13 | + public function getType() : string { |
|
14 | + return 'Scalar_MagicConst_Dir'; |
|
15 | + } |
|
16 | 16 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class File extends MagicConst |
8 | 8 | { |
9 | - public function getName() : string { |
|
10 | - return '__FILE__'; |
|
11 | - } |
|
9 | + public function getName() : string { |
|
10 | + return '__FILE__'; |
|
11 | + } |
|
12 | 12 | |
13 | - public function getType() : string { |
|
14 | - return 'Scalar_MagicConst_File'; |
|
15 | - } |
|
13 | + public function getType() : string { |
|
14 | + return 'Scalar_MagicConst_File'; |
|
15 | + } |
|
16 | 16 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class Trait_ extends MagicConst |
8 | 8 | { |
9 | - public function getName() : string { |
|
10 | - return '__TRAIT__'; |
|
11 | - } |
|
9 | + public function getName() : string { |
|
10 | + return '__TRAIT__'; |
|
11 | + } |
|
12 | 12 | |
13 | - public function getType() : string { |
|
14 | - return 'Scalar_MagicConst_Trait'; |
|
15 | - } |
|
13 | + public function getType() : string { |
|
14 | + return 'Scalar_MagicConst_Trait'; |
|
15 | + } |
|
16 | 16 | } |