Skip to content

Commit

Permalink
TASK: Add suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Nov 10, 2022
1 parent 5819eb7 commit 62965ec
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Parser/Tokenizer/Tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,18 @@ private static function string(\Iterator $fragments): \Iterator
$buffer->append($fragments->current());
$fragments->next();

if (!$fragments->valid()) {
throw new \Exception("@TODO: Unexpected end of input");
}

$buffer->append($fragments->current());
$fragments->next();
break;

default:
$buffer->append($fragments->current());
$fragments->next();
break;
}
}
}
Expand Down Expand Up @@ -176,6 +181,11 @@ public static function templateLiteral(\Iterator $fragments): \Iterator
case '$':
$dollarSignBuffer = Buffer::empty()->append($fragments->current());
$fragments->next();

if (!$fragments->valid()) {
throw new \Exception("@TODO: Unexpected end of input");
}

$nextFragment = $fragments->current();

if ($nextFragment->value === '{') {
Expand All @@ -189,13 +199,18 @@ public static function templateLiteral(\Iterator $fragments): \Iterator
$buffer->append($fragments->current());
$fragments->next();

if (!$fragments->valid()) {
throw new \Exception("@TODO: Unexpected end of input");
}

$buffer->append($fragments->current());
$fragments->next();
break;

default:
$buffer->append($fragments->current());
$fragments->next();
break;
}
}
}
Expand Down

0 comments on commit 62965ec

Please sign in to comment.