Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit b618b82

Browse files
committed
Merge pull request #70 from codeclimate/will/json-octet-error
Emit JSON errors from PHP Parser
2 parents 7b5a477 + 6577ca1 commit b618b82

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎vendor/php-parser/parser.php‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313

1414
$serializer = new PhpParser\Serializer\JSON;
1515
$nodes = $serializer->serialize($stmts);
16-
echo json_encode($nodes);
17-
16+
$json = json_encode($nodes);
17+
if (false === $json) {
18+
fwrite(STDERR, "Parse Error: JSON encoding failed: ".json_last_error_msg()."\n");
19+
exit(1);
20+
} else {
21+
echo $json;
22+
}
1823
} catch (PHPParser\Error $e) {
1924
fwrite(STDERR, "Parse Error: ".$e->getMessage()."\n");
2025
exit(1);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /