Skip to content

Commit 4c69362

Browse files
committed
Handle boolean item missing value
Replace RuntimeException thrown by ParsingInput with ParseException
1 parent bb5e723 commit 4c69362

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/Parser.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@ private static function parseKey(ParsingInput $input): string
219219
private static function parseBoolean(ParsingInput $input): bool
220220
{
221221
$input->consumeChar('?');
222-
return match ($input->consumeChar()) {
222+
$value = '';
223+
try {
224+
$value = $input->consumeChar();
225+
} catch (\RuntimeException) {
226+
// Consume may throw if value character is missing at end of string. Fall through to default error.
227+
}
228+
return match ($value) {
223229
'0' => false,
224230
'1' => true,
225231
default => throw new ParseException('Invalid boolean at position ' . $input->position()),

0 commit comments

Comments
 (0)