Completed
Push — master ( 6f5ff9...148f08 )
by Tom
02:36
created
src/Parser/Tokens.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	}
40 40
 
41 41
 	public function add($token) {
42
-		if ($token instanceof Tokens) $this->tokens = array_merge($this->tokens,  $token->tokens);
42
+		if ($token instanceof Tokens) $this->tokens = array_merge($this->tokens, $token->tokens);
43 43
 		else $this->tokens[] = $token;
44 44
 	}
45 45
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			if ($token['type'] === $tokenType) $i++;
88 88
 			else $splitTokens[$i][] = $token;
89 89
 		}
90
-		return array_map(function ($tokens) {
90
+		return array_map(function($tokens) {
91 91
 			return new Tokens($tokens);
92 92
 		}, $splitTokens);
93 93
 		//return $splitTokens;
Please login to merge, or discard this patch.
Braces   +30 added lines, -11 removed lines patch added patch discarded remove patch
@@ -39,8 +39,11 @@  discard block
 block discarded – undo
39 39
 	}
40 40
 
41 41
 	public function add($token) {
42
-		if ($token instanceof Tokens) $this->tokens = array_merge($this->tokens,  $token->tokens);
43
-		else $this->tokens[] = $token;
42
+		if ($token instanceof Tokens) {
43
+			$this->tokens = array_merge($this->tokens,  $token->tokens);
44
+		} else {
45
+			$this->tokens[] = $token;
46
+		}
44 47
 	}
45 48
 
46 49
 
@@ -54,9 +57,13 @@  discard block
 block discarded – undo
54 57
 
55 58
 	private function getKeyToSlice($tokenType) {
56 59
 		$keys = $this->getKeysOfTokenType($tokenType);
57
-		if (empty($keys)) return false;
60
+		if (empty($keys)) {
61
+			return false;
62
+		}
58 63
 		$key = $keys[0];
59
-		for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) $key = $keys[$i];
64
+		for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) {
65
+			$key = $keys[$i];
66
+		}
60 67
 		return $key;
61 68
 	}
62 69
 
@@ -70,10 +77,17 @@  discard block
 block discarded – undo
70 77
 
71 78
 	private function sliceTokens($tokenType, $type, $increment = false) {
72 79
 		$key = $this->getKeyToSlice($tokenType);
73
-		if ($key === false) return new Tokens([]);
74
-		if ($increment) $key++;
75
-		if ($type === "from") return new Tokens(array_slice($this->tokens, $key));
76
-		else return new Tokens(array_slice($this->tokens, $this->iterator, $key));
80
+		if ($key === false) {
81
+			return new Tokens([]);
82
+		}
83
+		if ($increment) {
84
+			$key++;
85
+		}
86
+		if ($type === "from") {
87
+			return new Tokens(array_slice($this->tokens, $key));
88
+		} else {
89
+			return new Tokens(array_slice($this->tokens, $this->iterator, $key));
90
+		}
77 91
 	}
78 92
 
79 93
 	public function skip($count) {
@@ -84,8 +98,11 @@  discard block
 block discarded – undo
84 98
 		$splitTokens = [];
85 99
 		$i = 0;
86 100
 		foreach ($this->tokens as $token) {
87
-			if ($token['type'] === $tokenType) $i++;
88
-			else $splitTokens[$i][] = $token;
101
+			if ($token['type'] === $tokenType) {
102
+				$i++;
103
+			} else {
104
+				$splitTokens[$i][] = $token;
105
+			}
89 106
 		}
90 107
 		return array_map(function ($tokens) {
91 108
 			return new Tokens($tokens);
@@ -109,7 +126,9 @@  discard block
 block discarded – undo
109 126
 
110 127
 	public function removeLine() {
111 128
 		$tokens = $this->tokens;
112
-		foreach ($tokens as &$token) unset($token['line']);
129
+		foreach ($tokens as &$token) {
130
+			unset($token['line']);
131
+		}
113 132
 		return new Tokens($tokens);
114 133
 	}
115 134
 
Please login to merge, or discard this patch.