Skip to content

Commit 4779bcc

Browse files
committed
handle invalid json files
1 parent bbe6b5b commit 4779bcc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/GettextPOGenerator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ private function addStringsFromJsonFiles($translations)
180180
// Load each JSON file to get source strings
181181
foreach ($this->JsonFiles() as $jsonFile) {
182182
$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)