diff --git a/composer.json b/composer.json index e1ff8e96..6f7b6663 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "symfony/expression-language": "^4.4", "symfony/finder": "^4.4", "symfony/yaml": "^4.4", - "twig/twig": "^2.13" + "twig/twig": "^2.13", + "ext-json": "*" }, "require-dev": { "phpunit/phpunit": "^9.5", diff --git a/src/Types/Harness/Repository/Repository.php b/src/Types/Harness/Repository/Repository.php index 668263d8..91756564 100644 --- a/src/Types/Harness/Repository/Repository.php +++ b/src/Types/Harness/Repository/Repository.php @@ -75,7 +75,13 @@ private function importPackagesFromSources() continue; } - $this->packages = array_merge($this->packages, json_decode(file_get_contents($source['url']), true)); + $packages = json_decode(file_get_contents($source['url']), true, JSON_THROW_ON_ERROR); + + if ($packages === null) { + throw new Exception(sprintf('Response of %s can\'t be decoded as json.', $source['url'])); + } + + $this->packages = array_merge($this->packages, $packages); $this->sources[$k]['imported'] = true; } }