@@ -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]) 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,9 +94,10 @@ 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); |
|
97 | + } else { |
|
98 | + if ($this->last !== null) { |
|
99 | + $this->data->traverse($this->last); |
|
100 | + } |
|
96 | 101 | $this->last = $parser->parseTokens($token['value'], null)[0]; |
97 | 102 | } |
98 | 103 | } |
@@ -112,8 +117,7 @@ discard block |
||
112 | 117 | private function processBrackets($token) { |
113 | 118 | if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)) { |
114 | 119 | $this->callTransphpormFunctions($token); |
115 | - } |
|
116 | - else { |
|
120 | + } else { |
|
117 | 121 | $this->processNested($token); |
118 | 122 | } |
119 | 123 | } |
@@ -130,7 +134,9 @@ discard block |
||
130 | 134 | foreach ($this->result->getResult() as $i => $value) { |
131 | 135 | if (is_scalar($value)) { |
132 | 136 | $val = $this->data->read($value); |
133 | - if ($val) $this->result[$i] = $val; |
|
137 | + if ($val) { |
|
138 | + $this->result[$i] = $val; |
|
139 | + } |
|
134 | 140 | } |
135 | 141 | } |
136 | 142 | $this->last = null; |
@@ -142,12 +148,10 @@ discard block |
||
142 | 148 | try { |
143 | 149 | $value = $this->data->extract($this->last, $this->autoLookup); |
144 | 150 | $this->result->processValue($value); |
145 | - } |
|
146 | - catch (\UnexpectedValueException $e) { |
|
151 | + } catch (\UnexpectedValueException $e) { |
|
147 | 152 | if (!$this->autoLookup) { |
148 | 153 | $this->result->processValue($this->last); |
149 | - } |
|
150 | - else { |
|
154 | + } else { |
|
151 | 155 | $this->result->clear(); |
152 | 156 | $this->result[0] = false; |
153 | 157 | } |