@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | protected function reduce(int $followingPrecedence): void |
| 84 | 84 | { |
| 85 | - $i = count($this->resultStack) - 1; // `i` always equals the index of the last node. |
|
| 86 | - for ($opIndex = count($this->opStack); $opIndex--; ) { |
|
| 85 | + $i = count($this->resultStack)-1; // `i` always equals the index of the last node. |
|
| 86 | + for ($opIndex = count($this->opStack); $opIndex--;) { |
|
| 87 | 87 | $op = $this->opStack[$opIndex]; |
| 88 | 88 | if (!$this->shouldReduce($op, $followingPrecedence)) { |
| 89 | 89 | return; // Reduction stops here. |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | protected function finishCircumfixOp($token): bool |
| 136 | 136 | { |
| 137 | - if (!(bool)$this->acceptorStack) { |
|
| 137 | + if (!(bool) $this->acceptorStack) { |
|
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | // Check the token with the most deeply nested operator. |
| 141 | - $factory = $this->acceptorStack[count($this->acceptorStack) - 1]->accept($token); |
|
| 141 | + $factory = $this->acceptorStack[count($this->acceptorStack)-1]->accept($token); |
|
| 142 | 142 | if ($factory === null) { |
| 143 | 143 | return false; |
| 144 | 144 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | }; |
| 181 | 181 | } else { |
| 182 | 182 | // A circumfix operator does not have precedence. Reduce it right away. |
| 183 | - $i = count($this->resultStack) - 1; |
|
| 183 | + $i = count($this->resultStack)-1; |
|
| 184 | 184 | /** @var callable(Result): Result $factory */ |
| 185 | 185 | $this->resultStack[$i] = $factory($this->resultStack[$i]); |
| 186 | 186 | } |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function parse(iterable $tokens) |
| 230 | 230 | { |
| 231 | - assert(!(bool)$this->resultStack); // We are not reenterable. |
|
| 232 | - assert(!(bool)$this->opStack); |
|
| 231 | + assert(!(bool) $this->resultStack); // We are not reenterable. |
|
| 232 | + assert(!(bool) $this->opStack); |
|
| 233 | 233 | $waitingForTerm = true; |
| 234 | 234 | try { |
| 235 | 235 | foreach ($tokens as $this->position => $token) { |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | ) : new MissingOperandException(); |
| 249 | 249 | } |
| 250 | 250 | $this->reduce(PHP_INT_MIN); |
| 251 | - if ((bool)$this->opStack) { |
|
| 251 | + if ((bool) $this->opStack) { |
|
| 252 | 252 | throw new UnclosedBracketException(); |
| 253 | 253 | } |
| 254 | 254 | } catch (\Throwable $e) { |