Completed
Push — master ( 6df84f...409692 )
by Richard
02:18
created
src/Parser/Tokens.php 1 patch
Braces   +22 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,9 +44,13 @@  discard block
 block discarded – undo
44 44
 
45 45
     private function getKeyToSlice($tokenType) {
46 46
         $keys = $this->getKeysOfTokenType($tokenType);
47
-        if (empty($keys)) return false;
47
+        if (empty($keys)) {
48
+        	return false;
49
+        }
48 50
         $key = $keys[0];
49
-        for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) $key = $keys[$i];
51
+        for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) {
52
+        	$key = $keys[$i];
53
+        }
50 54
         return $key;
51 55
     }
52 56
 
@@ -60,9 +64,14 @@  discard block
 block discarded – undo
60 64
 
61 65
     private function sliceTokens($tokenType, $type, $inclusive = false) {
62 66
         $key = $this->getKeyToSlice($tokenType);
63
-        if ($key === false) return new Tokens([]);
64
-        if ($type === "from") return new Tokens(array_slice($this->tokens, $inclusive ? $key : $key+1));
65
-        else return new Tokens(array_slice($this->tokens, $this->iterator, $inclusive ? $key+1 : $key));
67
+        if ($key === false) {
68
+        	return new Tokens([]);
69
+        }
70
+        if ($type === "from") {
71
+        	return new Tokens(array_slice($this->tokens, $inclusive ? $key : $key+1));
72
+        } else {
73
+        	return new Tokens(array_slice($this->tokens, $this->iterator, $inclusive ? $key+1 : $key));
74
+        }
66 75
     }
67 76
 
68 77
     public function skip($count) {
@@ -73,8 +82,11 @@  discard block
 block discarded – undo
73 82
         $splitTokens = [];
74 83
 		$i = 0;
75 84
 		foreach ($this->tokens as $token) {
76
-			if ($token['type'] === $tokenType) $i++;
77
-			else $splitTokens[$i][] = $token;
85
+			if ($token['type'] === $tokenType) {
86
+				$i++;
87
+			} else {
88
+				$splitTokens[$i][] = $token;
89
+			}
78 90
 		}
79 91
         return array_map(function ($tokens) {
80 92
             return new Tokens($tokens);
@@ -97,7 +109,9 @@  discard block
 block discarded – undo
97 109
 
98 110
     public function removeLine() {
99 111
         $tokens = $this->tokens;
100
-        foreach ($tokens as &$token) unset($token['line']);
112
+        foreach ($tokens as &$token) {
113
+        	unset($token['line']);
114
+        }
101 115
         return new Tokens($tokens);
102 116
     }
103 117
 
Please login to merge, or discard this patch.