Move logic to traverse a key to the string token

This commit is contained in:
Andrea Marco Sartori 2022-12-03 13:49:55 +10:00
parent 72c61d55cb
commit 690fb2c0bc
2 changed files with 5 additions and 5 deletions

View File

@ -37,6 +37,10 @@ class ScalarString extends Token
{ {
parent::mutateState($state); parent::mutateState($state);
if ($state->expectsKey() && $state->shouldTrackTree()) {
$state->traverseKey($this);
}
if ($this->isKey = $state->expectsKey()) { if ($this->isKey = $state->expectsKey()) {
$state->doNotExpectKey(); $state->doNotExpectKey();
} }

View File

@ -82,11 +82,7 @@ abstract class Token implements Stringable
$state->traverseArray(); $state->traverseArray();
} }
if ($this->isString() && $state->expectsKey() && $state->shouldTrackTree()) { if ($state->shouldBufferToken($this)) {
$state->traverseKey($this);
}
if ($state->inRoot() && $state->shouldBufferToken($this)) {
$state->bufferToken($this); $state->bufferToken($this);
} }
} }