From 690fb2c0bcda28a5be1f0c53878196a0bfbb397a Mon Sep 17 00:00:00 2001 From: Andrea Marco Sartori Date: Sat, 3 Dec 2022 13:49:55 +1000 Subject: [PATCH] Move logic to traverse a key to the string token --- src/Tokens/ScalarString.php | 4 ++++ src/Tokens/Token.php | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Tokens/ScalarString.php b/src/Tokens/ScalarString.php index 302abe6..05f008d 100644 --- a/src/Tokens/ScalarString.php +++ b/src/Tokens/ScalarString.php @@ -37,6 +37,10 @@ class ScalarString extends Token { parent::mutateState($state); + if ($state->expectsKey() && $state->shouldTrackTree()) { + $state->traverseKey($this); + } + if ($this->isKey = $state->expectsKey()) { $state->doNotExpectKey(); } diff --git a/src/Tokens/Token.php b/src/Tokens/Token.php index bb6797d..50b7ef5 100644 --- a/src/Tokens/Token.php +++ b/src/Tokens/Token.php @@ -82,11 +82,7 @@ abstract class Token implements Stringable $state->traverseArray(); } - if ($this->isString() && $state->expectsKey() && $state->shouldTrackTree()) { - $state->traverseKey($this); - } - - if ($state->inRoot() && $state->shouldBufferToken($this)) { + if ($state->shouldBufferToken($this)) { $state->bufferToken($this); } }