@@ -91,6 +91,10 @@ |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | //Postprocessing - replace values with null where allowed, or override a value at position |
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @param boolean $allowNull |
|
| 97 | + */ |
|
| 94 | 98 | public function postProcess(ValueData $data, $val, $overrideVal, $allowNull) { |
| 95 | 99 | foreach ($this->getResult() as $i => $value) { |
| 96 | 100 | if (is_scalar($value)) { |
@@ -56,7 +56,9 @@ discard block |
||
| 56 | 56 | $this->last = null; |
| 57 | 57 | $this->traversing = false; |
| 58 | 58 | |
| 59 | - if (count($tokens) <= 0) return [$data]; |
|
| 59 | + if (count($tokens) <= 0) { |
|
| 60 | + return [$data]; |
|
| 61 | + } |
|
| 60 | 62 | |
| 61 | 63 | foreach (new TokenFilterIterator($tokens, [Tokenizer::WHITESPACE, Tokenizer::NEW_LINE]) as $token) { |
| 62 | 64 | $this->{$this->tokenFuncs[$token['type']]}($token); |
@@ -84,8 +86,7 @@ discard block |
||
| 84 | 86 | // foo.bar is treated as looking up `bar` in `foo` whereas .foo is treated as the string ".foo" |
| 85 | 87 | if ($lastResult) { |
| 86 | 88 | $this->traversing = true; |
| 87 | - } |
|
| 88 | - else if ($this->last === null) { |
|
| 89 | + } else if ($this->last === null) { |
|
| 89 | 90 | $this->processString(['value' => '.']); |
| 90 | 91 | $this->result->setMode(Tokenizer::CONCAT); |
| 91 | 92 | } |
@@ -101,11 +102,12 @@ discard block |
||
| 101 | 102 | $parser = new Value($this->baseData, $this->autoLookup); |
| 102 | 103 | if ($this->hasFunction($this->last)) { |
| 103 | 104 | $this->callTransphpormFunctions($token); |
| 104 | - } |
|
| 105 | - else { |
|
| 105 | + } else { |
|
| 106 | 106 | $this->data->traverse($this->last, $this->result); |
| 107 | 107 | $this->last = $parser->parseTokens($token['value'], null)[0]; |
| 108 | - if (!is_bool($this->last)) $this->traversing = true; |
|
| 108 | + if (!is_bool($this->last)) { |
|
| 109 | + $this->traversing = true; |
|
| 110 | + } |
|
| 109 | 111 | } |
| 110 | 112 | } |
| 111 | 113 | |
@@ -128,8 +130,7 @@ discard block |
||
| 128 | 130 | if ($this->hasFunction($this->last) |
| 129 | 131 | && !$this->data->methodExists($this->last)) { |
| 130 | 132 | $this->callTransphpormFunctions($token); |
| 131 | - } |
|
| 132 | - else { |
|
| 133 | + } else { |
|
| 133 | 134 | $this->processNested($token); |
| 134 | 135 | } |
| 135 | 136 | } |
@@ -149,8 +150,7 @@ discard block |
||
| 149 | 150 | $parser = new Value($this->data->getData()); |
| 150 | 151 | $parsedVal = $parser->parse($val)[0] ?? null; |
| 151 | 152 | $this->result->postProcess($this->data, $val, $parsedVal, $this->allowNullResult); |
| 152 | - } |
|
| 153 | - else { |
|
| 153 | + } else { |
|
| 154 | 154 | $this->result->postProcess($this->data, $val, null, $this->allowNullResult); |
| 155 | 155 | } |
| 156 | 156 | |
@@ -163,8 +163,7 @@ discard block |
||
| 163 | 163 | try { |
| 164 | 164 | $value = $this->data->extract($this->last, $this->autoLookup, $this->traversing); |
| 165 | 165 | $this->result->processValue($value); |
| 166 | - } |
|
| 167 | - catch (\UnexpectedValueException $e) { |
|
| 166 | + } catch (\UnexpectedValueException $e) { |
|
| 168 | 167 | $this->processLastUnexpected(); |
| 169 | 168 | } |
| 170 | 169 | } |
@@ -173,8 +172,7 @@ discard block |
||
| 173 | 172 | private function processLastUnexpected() { |
| 174 | 173 | if (!($this->autoLookup || $this->traversing)) { |
| 175 | 174 | $this->result->processValue($this->last); |
| 176 | - } |
|
| 177 | - else { |
|
| 175 | + } else { |
|
| 178 | 176 | $this->result->clear(); |
| 179 | 177 | $this->result->processValue(false); |
| 180 | 178 | } |