mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-01-17 04:58:15 +01:00
Traverse key before buffering token
This commit is contained in:
parent
fa4e71f111
commit
d4b8b5037b
@ -37,13 +37,7 @@ class ScalarString extends Token
|
||||
{
|
||||
parent::mutateState($state);
|
||||
|
||||
$this->isKey = $state->expectsKey();
|
||||
|
||||
if ($this->isKey && $state->shouldTrackTree()) {
|
||||
$state->traverseKey($this);
|
||||
}
|
||||
|
||||
if ($this->isKey) {
|
||||
if ($this->isKey = $state->expectsKey()) {
|
||||
$state->doNotExpectKey();
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,16 @@ abstract class Token implements Stringable
|
||||
return ($this->type() | Tokens::VALUE_SCALAR) == Tokens::VALUE_SCALAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the token is a string
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isString(): bool
|
||||
{
|
||||
return ($this->type() | Tokens::SCALAR_STRING) == Tokens::SCALAR_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutate the given state
|
||||
*
|
||||
@ -72,6 +82,10 @@ abstract class Token implements Stringable
|
||||
$state->traverseArray();
|
||||
}
|
||||
|
||||
if ($this->isString() && $state->expectsKey() && $state->shouldTrackTree()) {
|
||||
$state->traverseKey($this);
|
||||
}
|
||||
|
||||
if ($state->inRoot() && $state->shouldBufferToken($this)) {
|
||||
$state->bufferToken($this);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user