diff --git a/src/Tokens/Lexer.php b/src/Tokens/Lexer.php index e0677a7..267b2e4 100644 --- a/src/Tokens/Lexer.php +++ b/src/Tokens/Lexer.php @@ -47,7 +47,7 @@ final class Lexer implements IteratorAggregate /** * Retrieve the JSON fragments * - * @return Traversable + * @return \Generator */ public function getIterator(): Traversable { @@ -56,10 +56,8 @@ final class Lexer implements IteratorAggregate foreach ($this->source as $chunk) { for ($i = 0, $size = strlen($chunk); $i < $size; $i++, $this->position++) { - $character = $chunk[$i]; - $inString = ($character == '"' && $inString && $isEscaping) - || ($character != '"' && $inString) - || ($character == '"' && !$inString); + $isQuote = '"' == $character = $chunk[$i]; + $inString = $isQuote != $inString || ($isQuote && $inString && $isEscaping); $isEscaping = $character == '\\' && !$isEscaping; $shouldBuffer = $inString || !isset(Tokens::BOUNDARIES[$character]);