Completed
Push — master ( 0c05fb...d365e4 )
by Richard
02:18
created
src/Parser/Tokenizer.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 		for ($i = 0; $i < strlen($this->str); $i++) {
74 74
 			$char = $this->identifyChar($this->str[$i]);
75 75
 			if ($commentChangeI = $this->doComments($tokens, $char, $i)) {
76
-                $i = $commentChangeI;
77
-                continue;
78
-            }
76
+				$i = $commentChangeI;
77
+				continue;
78
+			}
79 79
 
80 80
 			$this->doNewLine($tokens, $char);
81 81
 			$this->doSimpleTokens($tokens, $char);
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 		else return $tokens;
89 89
 	}
90 90
 
91
-    private function doComments(&$tokens, $char, $i) {
92
-        return $this->doSingleLineComments($tokens, $char, $i) +
93
-               $this->doMultiLineComments($tokens, $char, $i);
94
-    }
91
+	private function doComments(&$tokens, $char, $i) {
92
+		return $this->doSingleLineComments($tokens, $char, $i) +
93
+			   $this->doMultiLineComments($tokens, $char, $i);
94
+	}
95 95
 
96 96
 	private function doSingleLineComments(&$tokens, $char, $i) {
97 97
 		if ($char == Tokenizer::DIVIDE && isset($this->str[$i+1]) && $this->identifyChar($this->str[$i+1]) == Tokenizer::DIVIDE) {
Please login to merge, or discard this patch.
Braces   +33 added lines, -13 removed lines patch added patch discarded remove patch
@@ -84,8 +84,11 @@  discard block
 block discarded – undo
84 84
 			$i += $this->doBrackets($tokens, $char, $i);
85 85
 
86 86
 		}
87
-		if ($returnObj) return new Tokens($tokens);
88
-		else return $tokens;
87
+		if ($returnObj) {
88
+			return new Tokens($tokens);
89
+		} else {
90
+			return $tokens;
91
+		}
89 92
 	}
90 93
 
91 94
     private function doComments(&$tokens, $char, $i) {
@@ -103,7 +106,9 @@  discard block
 block discarded – undo
103 106
 	private function doMultiLineComments(&$tokens, $char, $i) {
104 107
 		if ($char == Tokenizer::DIVIDE && isset($this->str[$i+1]) && $this->identifyChar($this->str[$i+1]) == Tokenizer::MULTIPLY) {
105 108
 			$pos = strpos($this->str, '*/', $i)+2;
106
-			if ($this->str[$pos] == "\n") $pos++;
109
+			if ($this->str[$pos] == "\n") {
110
+				$pos++;
111
+			}
107 112
 			return $pos ? $pos : 0;
108 113
 		}
109 114
 	}
@@ -142,10 +147,15 @@  discard block
 block discarded – undo
142 147
 	}
143 148
 
144 149
 	private function processLiterals(&$tokens, $name) {
145
-		if (is_numeric($name)) $tokens[] = ['type' => self::NUMERIC, 'value' => $name];
146
-		else if ($name == 'true') $tokens[] = ['type' => self::BOOL, 'value' => true];
147
-		else if ($name == 'false') $tokens[] = ['type' => self::BOOL, 'value' => false];
148
-		else $tokens[] = ['type' => self::NAME, 'value' => $name, 'line' => $this->lineNo];
150
+		if (is_numeric($name)) {
151
+			$tokens[] = ['type' => self::NUMERIC, 'value' => $name];
152
+		} else if ($name == 'true') {
153
+			$tokens[] = ['type' => self::BOOL, 'value' => true];
154
+		} else if ($name == 'false') {
155
+			$tokens[] = ['type' => self::BOOL, 'value' => false];
156
+		} else {
157
+			$tokens[] = ['type' => self::NAME, 'value' => $name, 'line' => $this->lineNo];
158
+		}
149 159
 	}
150 160
 
151 161
 	private function doBrackets(&$tokens, $char, $i) {
@@ -178,7 +188,9 @@  discard block
 block discarded – undo
178 188
 	private function extractString($pos) {
179 189
 		$char = $this->str[$pos];
180 190
 		$end = strpos($this->str, $char, $pos+1);
181
-		while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1);
191
+		while ($end !== false && $this->str[$end-1] == '\\') {
192
+			$end = strpos($this->str, $char, $end+1);
193
+		}
182 194
 
183 195
 		return substr($this->str, $pos+1, $end-$pos-1);
184 196
 	}
@@ -187,18 +199,26 @@  discard block
 block discarded – undo
187 199
 		$close = strpos($this->str, $closeBracket, $open);
188 200
 
189 201
 		$cPos = $open+1;
190
-		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) $close = strpos($this->str, $closeBracket, $close+1);
202
+		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) {
203
+			$close = strpos($this->str, $closeBracket, $close+1);
204
+		}
191 205
 		return substr($this->str, $open+1, $close-$open-1);
192 206
 	}
193 207
 
194 208
 	private function identifyChar($chr) {
195
-		if (isset($this->chars[$chr])) return $this->chars[$chr];
196
-		else return self::NAME;
209
+		if (isset($this->chars[$chr])) {
210
+			return $this->chars[$chr];
211
+		} else {
212
+			return self::NAME;
213
+		}
197 214
 	}
198 215
 
199 216
 	private function getChar($num) {
200 217
 		$chars = array_reverse($this->chars);
201
-		if (isset($chars[$num])) return $chars[$num];
202
-		else return false;
218
+		if (isset($chars[$num])) {
219
+			return $chars[$num];
220
+		} else {
221
+			return false;
222
+		}
203 223
 	}
204 224
 }
Please login to merge, or discard this patch.