Skip to content

Commit 2734da2

Browse files
committed
handle malformed json
1 parent 8056754 commit 2734da2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/GettextPOGenerator.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ private function addStringsFromJsonFiles($translations)
179179

180180
// Load each JSON file to get source strings
181181
foreach ($this->JsonFiles() as $jsonFile) {
182-
$jsonTranslations = json_decode(file_get_contents($jsonFile), true);
182+
$jsonTranslations = json_decode(file_get_contents($jsonFile), true);
183+
if (!is_array($jsonTranslations)) {
184+
throw new \Exception("The file '$jsonFile' is not valid JSON.'");
185+
}
183186

184187
foreach ($jsonTranslations as $key => $value) {
185188
$sourceStrings[] = $key;

0 commit comments

Comments
 (0)