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