@@ -90,6 +90,7 @@ |
||
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @param string ...$lines |
93 | + * @param string[] $lines |
|
93 | 94 | * @return CodeGenerator |
94 | 95 | */ |
95 | 96 | public function header(string ...$lines): CodeGenerator |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * For the full copyright and license information, please view the LICENSE |
6 | 6 | * file that was distributed with this source code. |
7 | 7 | */ |
8 | -declare(strict_types=1); |
|
8 | +declare(strict_types = 1); |
|
9 | 9 | |
10 | 10 | namespace Railt\Compiler\Generator; |
11 | 11 |
@@ -44,7 +44,7 @@ |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | - * @return \Generator|TwigFilter[] |
|
47 | + * @return \Generator |
|
48 | 48 | */ |
49 | 49 | private function bootFilters(): \Generator |
50 | 50 | { |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * For the full copyright and license information, please view the LICENSE |
6 | 6 | * file that was distributed with this source code. |
7 | 7 | */ |
8 | -declare(strict_types=1); |
|
8 | +declare(strict_types = 1); |
|
9 | 9 | |
10 | 10 | namespace Railt\Compiler\Generator\Renderer; |
11 | 11 | |
@@ -48,19 +48,19 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private function bootFilters(): \Generator |
50 | 50 | { |
51 | - yield new TwigFilter('string', function (string $string): string { |
|
51 | + yield new TwigFilter('string', function(string $string): string { |
|
52 | 52 | $generator = new ValueGenerator($string, ValueGenerator::TYPE_STRING); |
53 | 53 | |
54 | 54 | return $generator->generate(); |
55 | 55 | }); |
56 | 56 | |
57 | - yield new TwigFilter('boolean', function (string $string): string { |
|
57 | + yield new TwigFilter('boolean', function(string $string): string { |
|
58 | 58 | $generator = new ValueGenerator($string, ValueGenerator::TYPE_BOOL); |
59 | 59 | |
60 | 60 | return $generator->generate(); |
61 | 61 | }); |
62 | 62 | |
63 | - yield new TwigFilter('array', function (array $items, int $depth = 0): string { |
|
63 | + yield new TwigFilter('array', function(array $items, int $depth = 0): string { |
|
64 | 64 | $generator = new ValueGenerator($items, ValueGenerator::TYPE_ARRAY_SHORT); |
65 | 65 | |
66 | 66 | $generator->setArrayDepth($depth); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | return $generator->generate(); |
69 | 69 | }); |
70 | 70 | |
71 | - yield new TwigFilter('class', function ($object): string { |
|
71 | + yield new TwigFilter('class', function($object): string { |
|
72 | 72 | if (\is_object($object)) { |
73 | 73 | return \get_class($object); |
74 | 74 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | return \json_encode($object); |
77 | 77 | }); |
78 | 78 | |
79 | - yield new TwigFilter('value', function ($value): string { |
|
79 | + yield new TwigFilter('value', function($value): string { |
|
80 | 80 | return (new ValueGenerator($value))->generate(); |
81 | 81 | }); |
82 | 82 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | { |
17 | 17 | /** |
18 | 18 | * @param string|int $to |
19 | - * @return Buildable |
|
19 | + * @return Movable |
|
20 | 20 | */ |
21 | 21 | public function move($to): Buildable |
22 | 22 | { |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * For the full copyright and license information, please view the LICENSE |
6 | 6 | * file that was distributed with this source code. |
7 | 7 | */ |
8 | -declare(strict_types=1); |
|
8 | +declare(strict_types = 1); |
|
9 | 9 | |
10 | 10 | namespace Railt\Compiler\Grammar\Builder; |
11 | 11 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | { |
19 | 19 | /** |
20 | 20 | * @param string $name |
21 | - * @return Production |
|
21 | + * @return Renameable |
|
22 | 22 | */ |
23 | 23 | public function rename(?string $name): Production |
24 | 24 | { |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * For the full copyright and license information, please view the LICENSE |
6 | 6 | * file that was distributed with this source code. |
7 | 7 | */ |
8 | -declare(strict_types=1); |
|
8 | +declare(strict_types = 1); |
|
9 | 9 | |
10 | 10 | namespace Railt\Compiler\Grammar\Builder; |
11 | 11 |
@@ -112,7 +112,7 @@ |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | - * @return LexerInterface|Lexer |
|
115 | + * @return Lexer\Stateless |
|
116 | 116 | */ |
117 | 117 | public static function new(): LexerInterface |
118 | 118 | { |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * For the full copyright and license information, please view the LICENSE |
6 | 6 | * file that was distributed with this source code. |
7 | 7 | */ |
8 | -declare(strict_types=1); |
|
8 | +declare(strict_types = 1); |
|
9 | 9 | |
10 | 10 | namespace Railt\Compiler\Grammar\Lexer; |
11 | 11 |
@@ -308,7 +308,7 @@ |
||
308 | 308 | /** |
309 | 309 | * Implementation of “simple”. |
310 | 310 | * |
311 | - * @param int|string|null $pNodeId |
|
311 | + * @param string|null $pNodeId |
|
312 | 312 | * @return string|int|null |
313 | 313 | */ |
314 | 314 | protected function simple(&$pNodeId) |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * For the full copyright and license information, please view the LICENSE |
6 | 6 | * file that was distributed with this source code. |
7 | 7 | */ |
8 | -declare(strict_types=1); |
|
8 | +declare(strict_types = 1); |
|
9 | 9 | |
10 | 10 | namespace Railt\Compiler\Grammar\Reader\Analyzer; |
11 | 11 | |
@@ -257,26 +257,26 @@ discard block |
||
257 | 257 | case T::T_N_TO_M: |
258 | 258 | $handle = \trim($this->lookahead->current()->value(), '{}'); |
259 | 259 | $nm = \explode(',', $handle); |
260 | - $min = (int)\trim($nm[0]); |
|
261 | - $max = (int)\trim($nm[1]); |
|
260 | + $min = (int) \trim($nm[0]); |
|
261 | + $max = (int) \trim($nm[1]); |
|
262 | 262 | $this->lookahead->next(); |
263 | 263 | break; |
264 | 264 | |
265 | 265 | case T::T_ZERO_TO_M: |
266 | 266 | $min = 0; |
267 | - $max = (int)\trim($this->lookahead->current()->value(), '{,}'); |
|
267 | + $max = (int) \trim($this->lookahead->current()->value(), '{,}'); |
|
268 | 268 | $this->lookahead->next(); |
269 | 269 | break; |
270 | 270 | |
271 | 271 | case T::T_N_OR_MORE: |
272 | - $min = (int)\trim($this->lookahead->current()->value(), '{,}'); |
|
272 | + $min = (int) \trim($this->lookahead->current()->value(), '{,}'); |
|
273 | 273 | $max = -1; |
274 | 274 | $this->lookahead->next(); |
275 | 275 | break; |
276 | 276 | |
277 | 277 | case T::T_EXACTLY_N: |
278 | 278 | $handle = \trim($this->lookahead->current()->value(), '{}'); |
279 | - $min = (int)$handle; |
|
279 | + $min = (int) $handle; |
|
280 | 280 | $max = $min; |
281 | 281 | $this->lookahead->next(); |
282 | 282 | break; |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | |
301 | 301 | $name = $this->transitionalRuleCounter++; |
302 | 302 | |
303 | - $this->parsedRules[$name] = new RepetitionBuilder($name, $min, $max, (array)$children); |
|
303 | + $this->parsedRules[$name] = new RepetitionBuilder($name, $min, $max, (array) $children); |
|
304 | 304 | |
305 | 305 | return $name; |
306 | 306 | } |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | { |
340 | 340 | $tokenName = \rtrim($this->lookahead->current()->value(), '()'); |
341 | 341 | |
342 | - $isEmptyRule = ! \array_key_exists($tokenName, $this->rules) && |
|
343 | - ! \array_key_exists('#' . $tokenName, $this->rules); |
|
342 | + $isEmptyRule = !\array_key_exists($tokenName, $this->rules) && |
|
343 | + !\array_key_exists('#'.$tokenName, $this->rules); |
|
344 | 344 | |
345 | 345 | if ($isEmptyRule) { |
346 | 346 | $error = \vsprintf('Cannot call rule %s() in rule %s because it does not exist.', [ |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | ) { |
358 | 358 | $name = $this->transitionalRuleCounter++; |
359 | 359 | |
360 | - $this->parsedRules[$name] = new ConcatenationBuilder($name, (array)$tokenName); |
|
360 | + $this->parsedRules[$name] = new ConcatenationBuilder($name, (array) $tokenName); |
|
361 | 361 | } else { |
362 | 362 | $name = $tokenName; |
363 | 363 | } |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | { |
377 | 377 | $tokenName = \trim($this->lookahead->current()->value(), $kept ? '<>' : ':'); |
378 | 378 | |
379 | - if (! $this->getLexer()->has($tokenName)) { |
|
379 | + if (!$this->getLexer()->has($tokenName)) { |
|
380 | 380 | $error = \sprintf('Token %s does not exist in rule %s.', $tokenName, $this->ruleName); |
381 | 381 | throw new GrammarException($error, 4); |
382 | 382 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
102 | - * @return iterable |
|
102 | + * @return \Generator |
|
103 | 103 | */ |
104 | 104 | public function getTokens(): iterable |
105 | 105 | { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | /** |
125 | 125 | * @param Readable $input |
126 | - * @return \Traversable|TokenInterface[] |
|
126 | + * @return \Generator |
|
127 | 127 | */ |
128 | 128 | private function exec(Readable $input): \Traversable |
129 | 129 | { |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * For the full copyright and license information, please view the LICENSE |
6 | 6 | * file that was distributed with this source code. |
7 | 7 | */ |
8 | -declare(strict_types=1); |
|
8 | +declare(strict_types = 1); |
|
9 | 9 | |
10 | 10 | namespace Railt\Compiler\Lexer; |
11 | 11 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function __construct() |
58 | 58 | { |
59 | - if (! \class_exists(Lexer::class)) { |
|
59 | + if (!\class_exists(Lexer::class)) { |
|
60 | 60 | throw new UnsupportedLexerRuntimeException('This runtime required parle extension'); |
61 | 61 | } |
62 | 62 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $this->map[$this->id] = $name; |
78 | 78 | $this->tokens[$this->id] = $pcre; |
79 | 79 | } catch (LexerException $e) { |
80 | - $message = \preg_replace('/rule\h+id\h+\d+/iu', 'token ' . $name, $e->getMessage()); |
|
80 | + $message = \preg_replace('/rule\h+id\h+\d+/iu', 'token '.$name, $e->getMessage()); |
|
81 | 81 | |
82 | 82 | throw new BadLexemeException($message); |
83 | 83 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public function lex(Readable $input): \Traversable |
116 | 116 | { |
117 | 117 | foreach ($this->exec($input) as $token) { |
118 | - if (! \in_array($token->name(), $this->skip, true)) { |
|
118 | + if (!\in_array($token->name(), $this->skip, true)) { |
|
119 | 119 | yield $token; |
120 | 120 | } |
121 | 121 | } |
@@ -162,7 +162,7 @@ |
||
162 | 162 | /** |
163 | 163 | * Unfold trace |
164 | 164 | * @param BufferInterface $buffer |
165 | - * @return mixed |
|
165 | + * @return null|boolean |
|
166 | 166 | */ |
167 | 167 | protected function unfold(BufferInterface $buffer) |
168 | 168 | { |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * For the full copyright and license information, please view the LICENSE |
6 | 6 | * file that was distributed with this source code. |
7 | 7 | */ |
8 | -declare(strict_types=1); |
|
8 | +declare(strict_types = 1); |
|
9 | 9 | |
10 | 10 | namespace Railt\Compiler\Parser; |
11 | 11 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | $ast = $this->buildTree(); |
121 | 121 | |
122 | - if (! ($ast instanceof NodeInterface)) { |
|
122 | + if (!($ast instanceof NodeInterface)) { |
|
123 | 123 | throw new ParserException('Parsing error: cannot build AST, the trace is corrupted.', 1); |
124 | 124 | } |
125 | 125 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | continue; |
411 | 411 | } |
412 | 412 | |
413 | - $rule = new AstRule((string)($id ?: $cId), \array_reverse($handle), $offset); |
|
413 | + $rule = new AstRule((string) ($id ?: $cId), \array_reverse($handle), $offset); |
|
414 | 414 | $children[] = $rule; |
415 | 415 | } elseif ($trace instanceof Escape) { |
416 | 416 | return $i + 1; |
@@ -59,7 +59,7 @@ |
||
59 | 59 | * Constructor. |
60 | 60 | * |
61 | 61 | * @param string|int $rule Rule name. |
62 | - * @param mixed $data Data. |
|
62 | + * @param integer $data Data. |
|
63 | 63 | * @param array $then Next step jumpers |
64 | 64 | * @param int $depth Depth. |
65 | 65 | */ |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * For the full copyright and license information, please view the LICENSE |
6 | 6 | * file that was distributed with this source code. |
7 | 7 | */ |
8 | -declare(strict_types=1); |
|
8 | +declare(strict_types = 1); |
|
9 | 9 | |
10 | 10 | namespace Railt\Compiler\Parser\Trace; |
11 | 11 |