@@ -39,7 +39,7 @@ |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | throw new LanguageException(sprintf('Invalid AST Node: %s', |
42 | - (string)$node)); |
|
42 | + (string)$node)); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @throws SyntaxErrorException |
16 | 16 | */ |
17 | 17 | protected function expectKeyword( |
18 | - LexerInterface $lexer, |
|
19 | - string $value |
|
18 | + LexerInterface $lexer, |
|
19 | + string $value |
|
20 | 20 | ): Token { |
21 | 21 | $token = $lexer->getToken(); |
22 | 22 | |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | throw new SyntaxErrorException( |
29 | - $lexer->getSource(), |
|
30 | - $token->getStart(), |
|
31 | - sprintf('Expected %s, found %s', $value, $token) |
|
29 | + $lexer->getSource(), |
|
30 | + $token->getStart(), |
|
31 | + sprintf('Expected %s, found %s', $value, $token) |
|
32 | 32 | ); |
33 | 33 | } |
34 | 34 | |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | * @return SyntaxErrorException |
43 | 43 | */ |
44 | 44 | protected function unexpected( |
45 | - LexerInterface $lexer, |
|
45 | + LexerInterface $lexer, |
|
46 | 46 | ?Token $atToken = null |
47 | 47 | ): SyntaxErrorException { |
48 | 48 | $token = $atToken ?: $lexer->getToken(); |
49 | 49 | |
50 | 50 | return new SyntaxErrorException( |
51 | - $lexer->getSource(), |
|
52 | - $token->getStart(), |
|
53 | - sprintf('Unexpected %s', $token) |
|
51 | + $lexer->getSource(), |
|
52 | + $token->getStart(), |
|
53 | + sprintf('Unexpected %s', $token) |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @throws SyntaxErrorException |
70 | 70 | */ |
71 | 71 | protected function any( |
72 | - LexerInterface $lexer, |
|
73 | - string $openKind, |
|
74 | - callable $parseFunction, |
|
75 | - string $closeKind |
|
72 | + LexerInterface $lexer, |
|
73 | + string $openKind, |
|
74 | + callable $parseFunction, |
|
75 | + string $closeKind |
|
76 | 76 | ): array { |
77 | 77 | $this->expect($lexer, $openKind); |
78 | 78 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | throw new SyntaxErrorException( |
108 | - $lexer->getSource(), |
|
109 | - $token->getStart(), |
|
110 | - sprintf('Expected %s, found %s.', $kind, $token) |
|
108 | + $lexer->getSource(), |
|
109 | + $token->getStart(), |
|
110 | + sprintf('Expected %s, found %s.', $kind, $token) |
|
111 | 111 | ); |
112 | 112 | } |
113 | 113 | |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | * @throws SyntaxErrorException |
158 | 158 | */ |
159 | 159 | protected function many( |
160 | - LexerInterface $lexer, |
|
161 | - string $openKind, |
|
162 | - callable $parseFunction, |
|
163 | - string $closeKind |
|
160 | + LexerInterface $lexer, |
|
161 | + string $openKind, |
|
162 | + callable $parseFunction, |
|
163 | + string $closeKind |
|
164 | 164 | ): array { |
165 | 165 | $this->expect($lexer, $openKind); |
166 | 166 | |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | * @return array|null |
192 | 192 | */ |
193 | 193 | protected function buildLocation( |
194 | - LexerInterface $lexer, |
|
195 | - Token $startToken |
|
194 | + LexerInterface $lexer, |
|
195 | + Token $startToken |
|
196 | 196 | ): ?array |
197 | 197 | { |
198 | 198 | return !$lexer->getOption('noLocation', false) ? [ |
199 | - 'start' => $startToken->getStart(), |
|
200 | - 'end' => $lexer->getLastToken()->getEnd(), |
|
201 | - 'source' => $lexer->getSource(), |
|
199 | + 'start' => $startToken->getStart(), |
|
200 | + 'end' => $lexer->getLastToken()->getEnd(), |
|
201 | + 'source' => $lexer->getSource(), |
|
202 | 202 | ] : null; |
203 | 203 | } |
204 | 204 | } |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | * @inheritdoc |
15 | 15 | */ |
16 | 16 | public function read( |
17 | - int $code, |
|
18 | - int $pos, |
|
19 | - int $line, |
|
20 | - int $col, |
|
21 | - Token $prev |
|
17 | + int $code, |
|
18 | + int $pos, |
|
19 | + int $line, |
|
20 | + int $col, |
|
21 | + Token $prev |
|
22 | 22 | ): Token { |
23 | 23 | $body = $this->lexer->getBody(); |
24 | 24 | $start = $pos; |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | } while ($code !== null && ($code > 0x001f || $code === 0x0009)); // SourceCharacter but not LineTerminator |
29 | 29 | |
30 | 30 | return new Token( |
31 | - TokenKindEnum::COMMENT, |
|
32 | - $start, |
|
33 | - $pos, |
|
34 | - $line, |
|
35 | - $col, |
|
36 | - $prev, |
|
37 | - sliceString($body, $start + 1, $pos) |
|
31 | + TokenKindEnum::COMMENT, |
|
32 | + $start, |
|
33 | + $pos, |
|
34 | + $line, |
|
35 | + $col, |
|
36 | + $prev, |
|
37 | + sliceString($body, $start + 1, $pos) |
|
38 | 38 | ); |
39 | 39 | } |
40 | 40 |
@@ -12,14 +12,14 @@ |
||
12 | 12 | * @inheritdoc |
13 | 13 | */ |
14 | 14 | public function read( |
15 | - int $code, |
|
16 | - int $pos, |
|
17 | - int $line, |
|
18 | - int $col, |
|
19 | - Token $prev |
|
15 | + int $code, |
|
16 | + int $pos, |
|
17 | + int $line, |
|
18 | + int $col, |
|
19 | + Token $prev |
|
20 | 20 | ): Token { |
21 | 21 | return new Token(TokenKindEnum::PIPE, $pos, $pos + 1, $line, $col, |
22 | - $prev); |
|
22 | + $prev); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | * @inheritdoc |
26 | 26 | */ |
27 | 27 | public function read( |
28 | - int $code, |
|
29 | - int $pos, |
|
30 | - int $line, |
|
31 | - int $col, |
|
32 | - Token $prev |
|
28 | + int $code, |
|
29 | + int $pos, |
|
30 | + int $line, |
|
31 | + int $col, |
|
32 | + Token $prev |
|
33 | 33 | ): Token { |
34 | 34 | $body = $this->lexer->getBody(); |
35 | 35 | $bodyLength = mb_strlen($body); |
@@ -45,21 +45,21 @@ discard block |
||
45 | 45 | $rawValue .= sliceString($body, $chunkStart, $pos); |
46 | 46 | |
47 | 47 | return new Token( |
48 | - TokenKindEnum::BLOCK_STRING, |
|
49 | - $start, |
|
50 | - $pos + 3, |
|
51 | - $line, |
|
52 | - $col, |
|
53 | - $prev, |
|
54 | - blockStringValue($rawValue) |
|
48 | + TokenKindEnum::BLOCK_STRING, |
|
49 | + $start, |
|
50 | + $pos + 3, |
|
51 | + $line, |
|
52 | + $col, |
|
53 | + $prev, |
|
54 | + blockStringValue($rawValue) |
|
55 | 55 | ); |
56 | 56 | } |
57 | 57 | |
58 | 58 | if (isSourceCharacter($code)) { |
59 | 59 | throw new SyntaxErrorException( |
60 | - $this->lexer->getSource(), |
|
61 | - $pos, |
|
62 | - sprintf('Invalid character within String: %s', |
|
60 | + $this->lexer->getSource(), |
|
61 | + $pos, |
|
62 | + sprintf('Invalid character within String: %s', |
|
63 | 63 | printCharCode($code)) |
64 | 64 | ); |
65 | 65 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | throw new SyntaxErrorException($this->lexer->getSource(), $pos, |
77 | - 'Unterminated string.'); |
|
77 | + 'Unterminated string.'); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | * @return bool |
99 | 99 | */ |
100 | 100 | protected function isEscapedTripleQuote( |
101 | - string $body, |
|
102 | - int $code, |
|
103 | - int $pos |
|
101 | + string $body, |
|
102 | + int $code, |
|
103 | + int $pos |
|
104 | 104 | ): bool { |
105 | 105 | return $code === 92 && |
106 | 106 | charCodeAt($body, $pos + 1) === 34 && |
@@ -15,11 +15,11 @@ |
||
15 | 15 | * @return Token |
16 | 16 | */ |
17 | 17 | public function read( |
18 | - int $code, |
|
19 | - int $pos, |
|
20 | - int $line, |
|
21 | - int $col, |
|
22 | - Token $prev |
|
18 | + int $code, |
|
19 | + int $pos, |
|
20 | + int $line, |
|
21 | + int $col, |
|
22 | + Token $prev |
|
23 | 23 | ): Token; |
24 | 24 | |
25 | 25 | /** |
@@ -13,14 +13,14 @@ |
||
13 | 13 | * @inheritdoc |
14 | 14 | */ |
15 | 15 | public function read( |
16 | - int $code, |
|
17 | - int $pos, |
|
18 | - int $line, |
|
19 | - int $col, |
|
20 | - Token $prev |
|
16 | + int $code, |
|
17 | + int $pos, |
|
18 | + int $line, |
|
19 | + int $col, |
|
20 | + Token $prev |
|
21 | 21 | ): Token { |
22 | 22 | return new Token(TokenKindEnum::SPREAD, $pos, $pos + 3, $line, $col, |
23 | - $prev); |
|
23 | + $prev); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -12,14 +12,14 @@ |
||
12 | 12 | * @inheritdoc |
13 | 13 | */ |
14 | 14 | public function read( |
15 | - int $code, |
|
16 | - int $pos, |
|
17 | - int $line, |
|
18 | - int $col, |
|
19 | - Token $prev |
|
15 | + int $code, |
|
16 | + int $pos, |
|
17 | + int $line, |
|
18 | + int $col, |
|
19 | + Token $prev |
|
20 | 20 | ): Token { |
21 | 21 | return new Token(TokenKindEnum::AMP, $pos, $pos + 1, $line, $col, |
22 | - $prev); |
|
22 | + $prev); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -12,11 +12,11 @@ |
||
12 | 12 | * @inheritdoc |
13 | 13 | */ |
14 | 14 | public function read( |
15 | - int $code, |
|
16 | - int $pos, |
|
17 | - int $line, |
|
18 | - int $col, |
|
19 | - Token $prev |
|
15 | + int $code, |
|
16 | + int $pos, |
|
17 | + int $line, |
|
18 | + int $col, |
|
19 | + Token $prev |
|
20 | 20 | ): Token { |
21 | 21 | return $code === 91 |
22 | 22 | ? new Token(TokenKindEnum::BRACKET_L, $pos, $pos + 1, $line, $col, |