@@ -49,7 +49,9 @@ discard block |
||
49 | 49 | $this->data = new ValueData($data ? $data : $this->baseData); |
50 | 50 | $this->last = null; |
51 | 51 | |
52 | - if (count($tokens) <= 0) return [$data]; |
|
52 | + if (count($tokens) <= 0) { |
|
53 | + return [$data]; |
|
54 | + } |
|
53 | 55 | |
54 | 56 | foreach (new TokenFilterIterator($tokens, [Tokenizer::WHITESPACE, Tokenizer::NEW_LINE]) as $token) { |
55 | 57 | $this->{$this->tokenFuncs[$token['type']]}($token); |
@@ -71,13 +73,15 @@ discard block |
||
71 | 73 | //Reads the last selected value from $data regardless if it's an array or object and overrides $this->data with the new value |
72 | 74 | //Dot moves $data to the next object in $data foo.bar moves the $data pointer from `foo` to `bar` |
73 | 75 | private function processDot($token) { |
74 | - if ($this->last !== null) $this->data->traverse($this->last); |
|
75 | - else { |
|
76 | + if ($this->last !== null) { |
|
77 | + $this->data->traverse($this->last); |
|
78 | + } else { |
|
76 | 79 | //When . is not preceeded by anything, treat it as part of the string instead of an operator |
77 | 80 | // foo.bar is treated as looking up `bar` in `foo` whereas .foo is treated as the string ".foo" |
78 | 81 | $lastResult = $this->result->pop(); |
79 | - if ($lastResult) $this->data = new ValueData($lastResult); |
|
80 | - else { |
|
82 | + if ($lastResult) { |
|
83 | + $this->data = new ValueData($lastResult); |
|
84 | + } else { |
|
81 | 85 | $this->processString(['value' => '.']); |
82 | 86 | $this->result->setMode(Tokenizer::CONCAT); |
83 | 87 | } |
@@ -90,12 +94,14 @@ discard block |
||
90 | 94 | $parser = new Value($this->baseData, $this->autoLookup); |
91 | 95 | if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)) { |
92 | 96 | $this->callTransphpormFunctions($token); |
93 | - } |
|
94 | - else { |
|
95 | - if ($this->last !== null) $this->data->traverse($this->last); |
|
96 | - else { |
|
97 | + } else { |
|
98 | + if ($this->last !== null) { |
|
99 | + $this->data->traverse($this->last); |
|
100 | + } else { |
|
97 | 101 | $lastResult = $this->result->pop(); |
98 | - if ($lastResult) $this->data = new ValueData($lastResult); |
|
102 | + if ($lastResult) { |
|
103 | + $this->data = new ValueData($lastResult); |
|
104 | + } |
|
99 | 105 | } |
100 | 106 | $this->last = $parser->parseTokens($token['value'], null)[0]; |
101 | 107 | } |
@@ -116,8 +122,7 @@ discard block |
||
116 | 122 | private function processBrackets($token) { |
117 | 123 | if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)) { |
118 | 124 | $this->callTransphpormFunctions($token); |
119 | - } |
|
120 | - else { |
|
125 | + } else { |
|
121 | 126 | $this->processNested($token); |
122 | 127 | } |
123 | 128 | } |
@@ -134,7 +139,9 @@ discard block |
||
134 | 139 | foreach ($this->result->getResult() as $i => $value) { |
135 | 140 | if (is_scalar($value)) { |
136 | 141 | $val = $this->data->read($value); |
137 | - if ($val) $this->result[$i] = $val; |
|
142 | + if ($val) { |
|
143 | + $this->result[$i] = $val; |
|
144 | + } |
|
138 | 145 | } |
139 | 146 | } |
140 | 147 | $this->last = null; |
@@ -146,12 +153,10 @@ discard block |
||
146 | 153 | try { |
147 | 154 | $value = $this->data->extract($this->last, $this->autoLookup); |
148 | 155 | $this->result->processValue($value); |
149 | - } |
|
150 | - catch (\UnexpectedValueException $e) { |
|
156 | + } catch (\UnexpectedValueException $e) { |
|
151 | 157 | if (!$this->autoLookup) { |
152 | 158 | $this->result->processValue($this->last); |
153 | - } |
|
154 | - else { |
|
159 | + } else { |
|
155 | 160 | $this->result->clear(); |
156 | 161 | $this->result[0] = false; |
157 | 162 | } |