@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | if (is_string($tokens)) { |
| 74 | 74 | $tokens = $this->tokenize($tokens, $additional); |
| 75 | - } elseif(!$tokens instanceof TokenIterator) { |
|
| 75 | + } elseif (!$tokens instanceof TokenIterator) { |
|
| 76 | 76 | throw new \InvalidArgumentException('$tokens must be string or TokenIterator'); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $all = []; |
| 86 | 86 | |
| 87 | 87 | /** @var Token $token */ |
| 88 | - for($tokens->next(); $tokens->valid(); $tokens->next()) { |
|
| 88 | + for ($tokens->next(); $tokens->valid(); $tokens->next()) { |
|
| 89 | 89 | $token = $tokens->current(); |
| 90 | 90 | |
| 91 | 91 | if (!$token->isValid($this, $context)) { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if ($token instanceof LanguageToken && $token->getRule()->getLanguage() === $this) { |
| 110 | 110 | $result[0]->setEnd($token); |
| 111 | 111 | |
| 112 | - if($result[0]->getRule()->postProcess) { |
|
| 112 | + if ($result[0]->getRule()->postProcess) { |
|
| 113 | 113 | $source = substr($tokens->getSource(), $result[0]->pos, $result[0]->getLength()); |
| 114 | 114 | |
| 115 | 115 | $tokens = $this->tokenize($source, $result, $result[0]->pos); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | # closing unclosed tokens |
| 120 | - foreach(array_reverse($context) as $hash => $name) { |
|
| 120 | + foreach (array_reverse($context) as $hash => $name) { |
|
| 121 | 121 | $result[$hash]->setEnd(new Token([$name, 'pos' => $token->pos])); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | unset($context[spl_object_hash($start)]); |
| 129 | 129 | } else { |
| 130 | 130 | /** @noinspection PhpUnusedParameterInspection */ |
| 131 | - $start = ArrayHelper::find(array_reverse($context), function ($k, $v) use ($token) { |
|
| 131 | + $start = ArrayHelper::find(array_reverse($context), function($k, $v) use ($token) { |
|
| 132 | 132 | return $v === $token->name; |
| 133 | 133 | }); |
| 134 | 134 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | /** @var Rule $rule */ |
| 167 | 167 | foreach ($rules as $rule) { |
| 168 | - if($rule->getLanguage() === false) { |
|
| 168 | + if ($rule->getLanguage() === false) { |
|
| 169 | 169 | $rule->setLanguage($this); |
| 170 | 170 | } |
| 171 | 171 | |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - foreach($this->getEmbedded() as $language) { |
|
| 177 | + foreach ($this->getEmbedded() as $language) { |
|
| 178 | 178 | $result = array_merge($result, $language->_tokens($source)); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Array map would be cool, but is a lot slower |
| 182 | - if($offset) { |
|
| 182 | + if ($offset) { |
|
| 183 | 183 | foreach ($result as $item) { |
| 184 | 184 | $item->pos += $offset; |
| 185 | 185 | } |