Add being in root to conditions to buffer a token

This commit is contained in:
Andrea Marco Sartori 2022-12-03 13:51:04 +10:00
parent 690fb2c0bc
commit 419ced2621

View File

@ -202,7 +202,8 @@ class State
*/
public function shouldBufferToken(Token $token): bool
{
return $this->pointerMatchesTree()
return $this->tree->depth() >= 0
&& $this->pointerMatchesTree()
&& ($this->treeIsDeep() || ($token->isValue() && !$this->expectsKey()));
}
@ -270,14 +271,4 @@ class State
{
return $this->tree->inObject();
}
/**
* Determine whether the tree is within the JSON root
*
* @return bool
*/
public function inRoot(): bool
{
return $this->tree->depth() >= 0;
}
}