@@ -58,7 +58,9 @@ discard block |
||
58 | 58 | $this->last = new Last($this->data, $this->result, $this->autoLookup); |
59 | 59 | $this->traversing = false; |
60 | 60 | |
61 | - if (count($tokens) <= 0) return [$data]; |
|
61 | + if (count($tokens) <= 0) { |
|
62 | + return [$data]; |
|
63 | + } |
|
62 | 64 | |
63 | 65 | foreach (new TokenFilterIterator($tokens, [Tokenizer::WHITESPACE, Tokenizer::NEW_LINE]) as $name => $token) { |
64 | 66 | $this->{$this->tokenFuncs[$token['type']]}($token); |
@@ -86,8 +88,7 @@ discard block |
||
86 | 88 | // foo.bar is treated as looking up `bar` in `foo` whereas .foo is treated as the string ".foo" |
87 | 89 | if ($lastResult) { |
88 | 90 | $this->last->makeTraversing(); |
89 | - } |
|
90 | - else if ($this->last->isEmpty()) { |
|
91 | + } else if ($this->last->isEmpty()) { |
|
91 | 92 | $this->processString(['value' => '.']); |
92 | 93 | $this->result->setMode(Tokenizer::CONCAT); |
93 | 94 | } |
@@ -102,11 +103,12 @@ discard block |
||
102 | 103 | private function processSquareBracket($token) { |
103 | 104 | if ($this->hasFunction($this->last->read())) { |
104 | 105 | $this->callTransphpormFunctions($token); |
105 | - } |
|
106 | - else { |
|
106 | + } else { |
|
107 | 107 | $this->last->traverse(); |
108 | 108 | $this->last->set($this->getNewParser()->parseTokens($token['value'], null)[0]); |
109 | - if (!is_bool($this->last->read())) $this->last->makeTraversing(); |
|
109 | + if (!is_bool($this->last->read())) { |
|
110 | + $this->last->makeTraversing(); |
|
111 | + } |
|
110 | 112 | } |
111 | 113 | } |
112 | 114 | |
@@ -129,8 +131,7 @@ discard block |
||
129 | 131 | if ($this->hasFunction($this->last->read()) |
130 | 132 | && !$this->data->methodExists($this->last->read())) { |
131 | 133 | $this->callTransphpormFunctions($token); |
132 | - } |
|
133 | - else { |
|
134 | + } else { |
|
134 | 135 | $this->last->processNested($this->getNewParser(), $token); |
135 | 136 | } |
136 | 137 | } |
@@ -147,8 +148,9 @@ discard block |
||
147 | 148 | $parser = new Value($this->data->getData()); |
148 | 149 | $parsedArr = $parser->parse($val); |
149 | 150 | $parsedVal = isset($parsedArr[0]) ? $parsedArr[0] : null; |
151 | + } else { |
|
152 | + $parsedVal = null; |
|
150 | 153 | } |
151 | - else $parsedVal = null; |
|
152 | 154 | |
153 | 155 | $this->result->postProcess($this->data, $val, $parsedVal, $this->allowNullResult); |
154 | 156 |
@@ -108,7 +108,7 @@ |
||
108 | 108 | |
109 | 109 | //Postprocessing - replace values with null where allowed, or override a value at position |
110 | 110 | public function postProcess(ValueData $data, $val, $overrideVal, $allowNull) { |
111 | - if ($this->getMode() !== Tokenizer::ARG) return; |
|
111 | + if ($this->getMode() !== Tokenizer::ARG) return; |
|
112 | 112 | foreach ($this->getResult() as $i => $value) { |
113 | 113 | if (is_scalar($value)) { |
114 | 114 | $val = ($overrideVal == $val) ? $data->read($value) : $overrideVal; |
@@ -33,14 +33,17 @@ discard block |
||
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 | |
@@ -108,7 +111,9 @@ discard block |
||
108 | 111 | |
109 | 112 | //Postprocessing - replace values with null where allowed, or override a value at position |
110 | 113 | public function postProcess(ValueData $data, $val, $overrideVal, $allowNull) { |
111 | - if ($this->getMode() !== Tokenizer::ARG) return; |
|
114 | + if ($this->getMode() !== Tokenizer::ARG) { |
|
115 | + return; |
|
116 | + } |
|
112 | 117 | foreach ($this->getResult() as $i => $value) { |
113 | 118 | if (is_scalar($value)) { |
114 | 119 | $val = ($overrideVal == $val) ? $data->read($value) : $overrideVal; |