@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $result = new \SplQueue(); |
53 | 53 | |
54 | - $status = @\preg_replace_callback($this->pattern, function (array $matches) use ($result): void { |
|
54 | + $status = @\preg_replace_callback($this->pattern, function(array $matches) use ($result): void { |
|
55 | 55 | $result->push($matches); |
56 | 56 | }, $this->subject); |
57 | 57 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | case \PREG_BAD_UTF8_OFFSET_ERROR: |
100 | 100 | return self::PREG_BAD_UTF8_OFFSET_ERROR; |
101 | 101 | } |
102 | - return 'Unexpected PCRE error (Code ' . $code . ')'; |
|
102 | + return 'Unexpected PCRE error (Code '.$code.')'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -39,7 +39,7 @@ |
||
39 | 39 | public function __construct(\Traversable $iterator, int $size = 10) |
40 | 40 | { |
41 | 41 | \assert($size > 0, 'Buffer size must be greater than 0'); |
42 | - \assert($size <= \PHP_INT_MAX, 'Buffer size must less than ' . \PHP_INT_MAX); |
|
42 | + \assert($size <= \PHP_INT_MAX, 'Buffer size must less than '.\PHP_INT_MAX); |
|
43 | 43 | |
44 | 44 | $this->size = $size; |
45 | 45 | $this->iterator = $iterator; |
@@ -25,7 +25,7 @@ |
||
25 | 25 | $context = []; |
26 | 26 | |
27 | 27 | foreach (\array_reverse($result) as $index => $body) { |
28 | - if (! \is_string($index)) { |
|
28 | + if (!\is_string($index)) { |
|
29 | 29 | $context[] = $body; |
30 | 30 | continue; |
31 | 31 | } |
@@ -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 | } |
@@ -127,7 +127,7 @@ |
||
127 | 127 | $path = $token->value(1); |
128 | 128 | |
129 | 129 | foreach (self::FILE_EXTENSIONS as $extension) { |
130 | - $file = \dirname($from->getPathname()) . '/' . $path . $extension; |
|
130 | + $file = \dirname($from->getPathname()).'/'.$path.$extension; |
|
131 | 131 | |
132 | 132 | if (\is_file($file)) { |
133 | 133 | return File::fromPathname($file); |
@@ -29,7 +29,7 @@ |
||
29 | 29 | { |
30 | 30 | parent::__construct($name, $offset); |
31 | 31 | |
32 | - $this->value = $value; |
|
32 | + $this->value = $value; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -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; |
@@ -78,14 +78,14 @@ |
||
78 | 78 | $token = $root->createElement(\class_basename($ast), $ast->getValue()); |
79 | 79 | |
80 | 80 | $token->setAttribute('name', $ast->getName()); |
81 | - $token->setAttribute('offset', (string)$ast->getOffset()); |
|
81 | + $token->setAttribute('offset', (string) $ast->getOffset()); |
|
82 | 82 | |
83 | 83 | return $token; |
84 | 84 | } |
85 | 85 | |
86 | 86 | $node = $root->createElement(\class_basename($ast)); |
87 | 87 | $node->setAttribute('name', \ltrim($ast->getName(), '#')); |
88 | - $node->setAttribute('offset', (string)$ast->getOffset()); |
|
88 | + $node->setAttribute('offset', (string) $ast->getOffset()); |
|
89 | 89 | |
90 | 90 | /** @var NodeInterface $child */ |
91 | 91 | foreach ($ast->getChildren() as $child) { |
@@ -57,6 +57,6 @@ |
||
57 | 57 | $this->initialIndention + $this->indention |
58 | 58 | )); |
59 | 59 | |
60 | - return $prefix . $line . \PHP_EOL; |
|
60 | + return $prefix.$line.\PHP_EOL; |
|
61 | 61 | } |
62 | 62 | } |