Completed
Push — master ( 319ec0...35ed97 )
by Tom
10:12 queued 03:00
created
src/Parser/Tokenizer/Literals.php 1 patch
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,10 +37,16 @@
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	private function processLiterals($tokens, $name, $str) {
40
-		if (is_numeric($name)) $tokens->add(['type' => Tokenizer::NUMERIC, 'value' => $name]);
41
-		else if ($name == 'true') $tokens->add(['type' => Tokenizer::BOOL, 'value' => true]);
42
-		else if ($name == 'false') $tokens->add(['type' => Tokenizer::BOOL, 'value' => false]);
43
-		else if ($name == 'in') $tokens->add(['type' => Tokenizer::IN, 'value' => 'in']);
44
-		else $tokens->add(['type' => Tokenizer::NAME, 'value' => $name, 'line' => $str->lineNo()]);
40
+		if (is_numeric($name)) {
41
+			$tokens->add(['type' => Tokenizer::NUMERIC, 'value' => $name]);
42
+		} else if ($name == 'true') {
43
+			$tokens->add(['type' => Tokenizer::BOOL, 'value' => true]);
44
+		} else if ($name == 'false') {
45
+			$tokens->add(['type' => Tokenizer::BOOL, 'value' => false]);
46
+		} else if ($name == 'in') {
47
+			$tokens->add(['type' => Tokenizer::IN, 'value' => 'in']);
48
+		} else {
49
+			$tokens->add(['type' => Tokenizer::NAME, 'value' => $name, 'line' => $str->lineNo()]);
50
+		}
45 51
 	}
46 52
 }
47 53
\ No newline at end of file
Please login to merge, or discard this patch.
src/Parser/Value.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -59,7 +59,9 @@  discard block
 block discarded – undo
59 59
 		$this->last = new Last($this->data, $this->result, $this->autoLookup);
60 60
 		$this->traversing = false;
61 61
 
62
-		if (count($tokens) <= 0) return [$data];
62
+		if (count($tokens) <= 0) {
63
+			return [$data];
64
+		}
63 65
 
64 66
 		foreach (new TokenFilterIterator($tokens, [Tokenizer::WHITESPACE, Tokenizer::NEW_LINE]) as $name => $token) {
65 67
 			$this->{$this->tokenFuncs[$token['type']]}($token);
@@ -92,8 +94,7 @@  discard block
 block discarded – undo
92 94
 		// foo.bar is treated as looking up `bar` in `foo` whereas .foo is treated as the string ".foo"
93 95
 		if ($lastResult) {
94 96
 			$this->last->makeTraversing();
95
-		}
96
-		else if ($this->last->isEmpty())  {
97
+		} else if ($this->last->isEmpty())  {
97 98
 			$this->processString(['value' => '.']);
98 99
 			$this->result->setMode(Tokenizer::CONCAT);
99 100
 		}
@@ -108,11 +109,12 @@  discard block
 block discarded – undo
108 109
 	private function processSquareBracket($token) {
109 110
 		if ($this->hasFunction($this->last->read())) {
110 111
 			$this->callTransphpormFunctions($token);
111
-		}
112
-		else {
112
+		} else {
113 113
 			$this->last->traverse();
114 114
 			$this->last->set($this->getNewParser()->parseTokens($token['value'], null)[0]);
115
-			if (!is_bool($this->last->read())) $this->last->makeTraversing();
115
+			if (!is_bool($this->last->read())) {
116
+				$this->last->makeTraversing();
117
+			}
116 118
 		}
117 119
 	}
118 120
 
@@ -135,8 +137,7 @@  discard block
 block discarded – undo
135 137
 		if ($this->hasFunction($this->last->read())
136 138
 			&& !$this->data->methodExists($this->last->read())) {
137 139
 			$this->callTransphpormFunctions($token);
138
-		}
139
-		else {
140
+		} else {
140 141
 			$this->last->processNested($this->getNewParser(), $token);
141 142
 		}
142 143
 	}
@@ -154,10 +155,12 @@  discard block
 block discarded – undo
154 155
 				$parser = new Value($this->data->getData());
155 156
 				$parsedArr = $parser->parse($val);
156 157
 				$parsedVal = isset($parsedArr[0]) ? $parsedArr[0] : null;
158
+			} else {
159
+				$parsedVal = $val;
157 160
 			}
158
-			else $parsedVal = $val;
161
+		} else {
162
+			$parsedVal = null;
159 163
 		}
160
-		else $parsedVal = null;
161 164
 
162 165
         $this->result->postProcess($this->data, $val, $parsedVal, $this->allowNullResult);
163 166
 
Please login to merge, or discard this patch.
src/Parser/ValueResult.php 1 patch
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,14 +33,17 @@
 block discarded – undo
33 33
 		];
34 34
 
35 35
 		if ($funcs[$this->mode] === 'concat' && is_numeric($newValue)
36
-			&& is_numeric($this->result[count($this->result)-1]))
37
-			$this->add($newValue);
38
-		else
39
-			$this->{$funcs[$this->mode]}($newValue);
36
+			&& is_numeric($this->result[count($this->result)-1])) {
37
+					$this->add($newValue);
38
+		} else {
39
+					$this->{$funcs[$this->mode]}($newValue);
40
+		}
40 41
 	}
41 42
 
42 43
 	public function in($value) {
43
-		if (!is_array($value)) throw new \Exception(' `in` can only be used with arrays');
44
+		if (!is_array($value)) {
45
+			throw new \Exception(' `in` can only be used with arrays');
46
+		}
44 47
 		$this->result[count($this->result)-1] = in_array($this->result[count($this->result)-1], $value);
45 48
 	}
46 49
 
Please login to merge, or discard this patch.