| @@ -34,7 +34,7 @@ | ||
| 34 | 34 | $file = $this->getValues()->current()->getValue(1); | 
| 35 | 35 | |
| 36 | 36 |          foreach (['', '.pp', 'pp2'] as $ext) { | 
| 37 | - $path = \dirname($from->getPathname()) . '/' . $file . $ext; | |
| 37 | + $path = \dirname($from->getPathname()).'/'.$file.$ext; | |
| 38 | 38 | |
| 39 | 39 |              if (\is_file($path)) { | 
| 40 | 40 | return File::fromPathname($path); | 
| @@ -74,7 +74,7 @@ discard block | ||
| 74 | 74 | /** | 
| 75 | 75 | * Build the analyzer of the rules (does not analyze the rules). | 
| 76 | 76 | * | 
| 77 | - * @return Rule[]|\Traversable | |
| 77 | + * @return \Generator | |
| 78 | 78 | * @throws GrammarException | 
| 79 | 79 | */ | 
| 80 | 80 | public function analyze(): iterable | 
| @@ -309,7 +309,7 @@ discard block | ||
| 309 | 309 | * Implementation of “simple”. | 
| 310 | 310 | * | 
| 311 | 311 | * @param LookaheadIterator $tokens | 
| 312 | - * @param int|string|null $pNodeId | |
| 312 | + * @param string|null $pNodeId | |
| 313 | 313 | * @return string|int|null | 
| 314 | 314 | * @throws GrammarException | 
| 315 | 315 | */ | 
| @@ -260,23 +260,23 @@ discard block | ||
| 260 | 260 | break; | 
| 261 | 261 | |
| 262 | 262 | case Parser::T_REPEAT_N_TO_M: | 
| 263 | - $min = (int)$tokens->current()->getValue(1); | |
| 264 | - $max = (int)$tokens->current()->getValue(2); | |
| 263 | + $min = (int) $tokens->current()->getValue(1); | |
| 264 | + $max = (int) $tokens->current()->getValue(2); | |
| 265 | 265 | $tokens->next(); | 
| 266 | 266 | break; | 
| 267 | 267 | |
| 268 | 268 | case Parser::T_REPEAT_ZERO_TO_M: | 
| 269 | - [$min, $max] = [0, (int)$tokens->current()->getValue(1)]; | |
| 269 | + [$min, $max] = [0, (int) $tokens->current()->getValue(1)]; | |
| 270 | 270 | $tokens->next(); | 
| 271 | 271 | break; | 
| 272 | 272 | |
| 273 | 273 | case Parser::T_REPEAT_N_OR_MORE: | 
| 274 | - [$min, $max] = [(int)$tokens->current()->getValue(1), -1]; | |
| 274 | + [$min, $max] = [(int) $tokens->current()->getValue(1), -1]; | |
| 275 | 275 | $tokens->next(); | 
| 276 | 276 | break; | 
| 277 | 277 | |
| 278 | 278 | case Parser::T_REPEAT_EXACTLY_N: | 
| 279 | - $min = $max = (int)$tokens->current()->getValue(1); | |
| 279 | + $min = $max = (int) $tokens->current()->getValue(1); | |
| 280 | 280 | $tokens->next(); | 
| 281 | 281 | break; | 
| 282 | 282 | } | 
| @@ -389,7 +389,7 @@ discard block | ||
| 389 | 389 |      { | 
| 390 | 390 | $tokenName = $tokens->current()->getValue(1); | 
| 391 | 391 | |
| 392 | - $isEmptyRule = ! \array_key_exists($tokenName, $this->rules); | |
| 392 | + $isEmptyRule = !\array_key_exists($tokenName, $this->rules); | |
| 393 | 393 | |
| 394 | 394 |          if ($isEmptyRule) { | 
| 395 | 395 |              $error = \vsprintf('Cannot call rule %s() in rule %s because it does not exist.', [ | 
| @@ -367,7 +367,8 @@ | ||
| 367 | 367 |      { | 
| 368 | 368 | $tokenName = $tokens->current()->getValue(1); | 
| 369 | 369 | |
| 370 | -        if (false) { // TODO | |
| 370 | +        if (false) { | |
| 371 | +// TODO | |
| 371 | 372 |              $error = \sprintf('Token %s does not exist in rule %s.', $tokenName, $this->ruleName); | 
| 372 | 373 | throw new GrammarException($error, 4); | 
| 373 | 374 | } | 
| @@ -39,7 +39,7 @@ | ||
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | 41 | /** | 
| 42 | - * @param RuleInterface|NodeInterface $rule | |
| 42 | + * @param null|NodeInterface $rule | |
| 43 | 43 | * @return \Traversable | 
| 44 | 44 | */ | 
| 45 | 45 | private function getTokens(RuleInterface $rule): \Traversable | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | */ | 
| 29 | 29 | public function getInnerTokens(): iterable | 
| 30 | 30 |      { | 
| 31 | -        return new LookaheadIterator((function () { | |
| 31 | +        return new LookaheadIterator((function() { | |
| 32 | 32 |              yield from $this->getTokens($this->first('RuleProduction')); | 
| 33 | 33 | yield new Eoi(0); | 
| 34 | 34 | })->call($this)); | 
| @@ -66,7 +66,7 @@ discard block | ||
| 66 | 66 | */ | 
| 67 | 67 | public function isKept(): bool | 
| 68 | 68 |      { | 
| 69 | -        return (bool)$this->first('ShouldKeep'); | |
| 69 | +        return (bool) $this->first('ShouldKeep'); | |
| 70 | 70 | } | 
| 71 | 71 | |
| 72 | 72 | /** | 
| @@ -23,12 +23,12 @@ | ||
| 23 | 23 | /** | 
| 24 | 24 | * @var string Default parser output path | 
| 25 | 25 | */ | 
| 26 | - private const PARSER_GRAMMAR = __DIR__ . '/../../resources/grammar.pp2'; | |
| 26 | + private const PARSER_GRAMMAR = __DIR__.'/../../resources/grammar.pp2'; | |
| 27 | 27 | |
| 28 | 28 | /** | 
| 29 | 29 | * @var string Default parser output path | 
| 30 | 30 | */ | 
| 31 | - private const OUT_PATH = __DIR__ . '/../Grammar'; | |
| 31 | + private const OUT_PATH = __DIR__.'/../Grammar'; | |
| 32 | 32 | |
| 33 | 33 | /** | 
| 34 | 34 | * @var string Default generated parser class name | 
| @@ -41,7 +41,7 @@ | ||
| 41 | 41 |              $compiler->setClassName($in->getOption('class')); | 
| 42 | 42 | } | 
| 43 | 43 | |
| 44 | - $cwd = \getcwd() ?: __DIR__ . '/..'; | |
| 44 | + $cwd = \getcwd() ?: __DIR__.'/..'; | |
| 45 | 45 | |
| 46 | 46 |          $compiler->saveTo($in->getOption('dir') ?: $cwd); | 
| 47 | 47 | } | 
| @@ -37,7 +37,7 @@ | ||
| 37 | 37 | |
| 38 | 38 |          $ast = $in->getOption('root') ? $ast->first($in->getOption('root')) : $ast; | 
| 39 | 39 | |
| 40 | - $out->write((string)$ast); | |
| 40 | + $out->write((string) $ast); | |
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | 43 | /** | 
| @@ -111,7 +111,7 @@ | ||
| 111 | 111 | |
| 112 | 112 | case $child instanceof TokenDelegate: | 
| 113 | 113 | $this->lexer->add($child->getTokenName(), $child->getTokenPattern()); | 
| 114 | -                    if (! $child->isKept()) { | |
| 114 | +                    if (!$child->isKept()) { | |
| 115 | 115 | $this->lexer->skip($child->getTokenName()); | 
| 116 | 116 | } | 
| 117 | 117 | break; | 
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 | */ | 
| 81 | 81 | public function saveTo(string $path): void | 
| 82 | 82 |      { | 
| 83 | - $pathName = $path . '/' . $this->class . '.php'; | |
| 83 | + $pathName = $path.'/'.$this->class.'.php'; | |
| 84 | 84 | |
| 85 | 85 | \file_put_contents($pathName, $this->build()); | 
| 86 | 86 | } | 
| @@ -94,7 +94,7 @@ discard block | ||
| 94 | 94 | \ob_start(); | 
| 95 | 95 | |
| 96 | 96 |          try { | 
| 97 | - require __DIR__ . '/../resources/templates/parser.tpl.php'; | |
| 97 | + require __DIR__.'/../resources/templates/parser.tpl.php'; | |
| 98 | 98 | return \ob_get_contents(); | 
| 99 | 99 |          } catch (\Throwable $e) { | 
| 100 | 100 | throw $e; |