@@ -83,8 +83,11 @@ discard block |
||
83 | 83 | $i += $this->doBrackets($tokens, $char, $i); |
84 | 84 | |
85 | 85 | } |
86 | - if ($returnObj) return new Tokens($tokens); |
|
87 | - else return $tokens; |
|
86 | + if ($returnObj) { |
|
87 | + return new Tokens($tokens); |
|
88 | + } else { |
|
89 | + return $tokens; |
|
90 | + } |
|
88 | 91 | } |
89 | 92 | |
90 | 93 | private function doSingleLineComments(&$tokens, $char, $i) { |
@@ -135,10 +138,15 @@ discard block |
||
135 | 138 | } |
136 | 139 | |
137 | 140 | private function processLiterals(&$tokens, $name) { |
138 | - if (is_numeric($name)) $tokens[] = ['type' => self::NUMERIC, 'value' => $name]; |
|
139 | - else if ($name == 'true') $tokens[] = ['type' => self::BOOL, 'value' => true]; |
|
140 | - else if ($name == 'false') $tokens[] = ['type' => self::BOOL, 'value' => false]; |
|
141 | - else $tokens[] = ['type' => self::NAME, 'value' => $name, 'line' => $this->lineNo]; |
|
141 | + if (is_numeric($name)) { |
|
142 | + $tokens[] = ['type' => self::NUMERIC, 'value' => $name]; |
|
143 | + } else if ($name == 'true') { |
|
144 | + $tokens[] = ['type' => self::BOOL, 'value' => true]; |
|
145 | + } else if ($name == 'false') { |
|
146 | + $tokens[] = ['type' => self::BOOL, 'value' => false]; |
|
147 | + } else { |
|
148 | + $tokens[] = ['type' => self::NAME, 'value' => $name, 'line' => $this->lineNo]; |
|
149 | + } |
|
142 | 150 | } |
143 | 151 | |
144 | 152 | private function doBrackets(&$tokens, $char, $i) { |
@@ -171,7 +179,9 @@ discard block |
||
171 | 179 | private function extractString($pos) { |
172 | 180 | $char = $this->str[$pos]; |
173 | 181 | $end = strpos($this->str, $char, $pos+1); |
174 | - while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1); |
|
182 | + while ($end !== false && $this->str[$end-1] == '\\') { |
|
183 | + $end = strpos($this->str, $char, $end+1); |
|
184 | + } |
|
175 | 185 | |
176 | 186 | return substr($this->str, $pos+1, $end-$pos-1); |
177 | 187 | } |
@@ -180,18 +190,26 @@ discard block |
||
180 | 190 | $close = strpos($this->str, $closeBracket, $open); |
181 | 191 | |
182 | 192 | $cPos = $open+1; |
183 | - while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) $close = strpos($this->str, $closeBracket, $close+1); |
|
193 | + while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) { |
|
194 | + $close = strpos($this->str, $closeBracket, $close+1); |
|
195 | + } |
|
184 | 196 | return substr($this->str, $open+1, $close-$open-1); |
185 | 197 | } |
186 | 198 | |
187 | 199 | private function identifyChar($chr) { |
188 | - if (isset($this->chars[$chr])) return $this->chars[$chr]; |
|
189 | - else return self::NAME; |
|
200 | + if (isset($this->chars[$chr])) { |
|
201 | + return $this->chars[$chr]; |
|
202 | + } else { |
|
203 | + return self::NAME; |
|
204 | + } |
|
190 | 205 | } |
191 | 206 | |
192 | 207 | private function getChar($num) { |
193 | 208 | $chars = array_reverse($this->chars); |
194 | - if (isset($chars[$num])) return $chars[$num]; |
|
195 | - else return false; |
|
209 | + if (isset($chars[$num])) { |
|
210 | + return $chars[$num]; |
|
211 | + } else { |
|
212 | + return false; |
|
213 | + } |
|
196 | 214 | } |
197 | 215 | } |