Completed
Push — master ( 409692...b7c30d )
by Richard
02:24
created
src/Parser/Tokens.php 1 patch
Braces   +25 added lines, -9 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,10 +64,17 @@  discard block
 block discarded – undo
60 64
 
61 65
     private function sliceTokens($tokenType, $type, $increment = false) {
62 66
         $key = $this->getKeyToSlice($tokenType);
63
-        if ($key === false) return new Tokens([]);
64
-        if ($increment) $key++;
65
-        if ($type === "from") return new Tokens(array_slice($this->tokens, $key));
66
-        else return new Tokens(array_slice($this->tokens, $this->iterator, $key));
67
+        if ($key === false) {
68
+        	return new Tokens([]);
69
+        }
70
+        if ($increment) {
71
+        	$key++;
72
+        }
73
+        if ($type === "from") {
74
+        	return new Tokens(array_slice($this->tokens, $key));
75
+        } else {
76
+        	return new Tokens(array_slice($this->tokens, $this->iterator, $key));
77
+        }
67 78
     }
68 79
 
69 80
     public function skip($count) {
@@ -74,8 +85,11 @@  discard block
 block discarded – undo
74 85
         $splitTokens = [];
75 86
 		$i = 0;
76 87
 		foreach ($this->tokens as $token) {
77
-			if ($token['type'] === $tokenType) $i++;
78
-			else $splitTokens[$i][] = $token;
88
+			if ($token['type'] === $tokenType) {
89
+				$i++;
90
+			} else {
91
+				$splitTokens[$i][] = $token;
92
+			}
79 93
 		}
80 94
         return array_map(function ($tokens) {
81 95
             return new Tokens($tokens);
@@ -98,7 +112,9 @@  discard block
 block discarded – undo
98 112
 
99 113
     public function removeLine() {
100 114
         $tokens = $this->tokens;
101
-        foreach ($tokens as &$token) unset($token['line']);
115
+        foreach ($tokens as &$token) {
116
+        	unset($token['line']);
117
+        }
102 118
         return new Tokens($tokens);
103 119
     }
104 120
 
Please login to merge, or discard this patch.