Skip to content

Commit 364cf39

Browse files
committed
Silencing errors related to composer.json reading
1 parent 28ed924 commit 364cf39

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/Reflection/BetterReflection/SourceLocator/ComposerJsonAndInstalledJsonSourceLocatorMaker.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,20 @@ public function create(string $installationPath): ?SourceLocator
4040
return null;
4141
}
4242

43-
$composerJsonContents = FileReader::read($composerJsonPath);
44-
$composer = Json::decode($composerJsonContents, Json::FORCE_ARRAY);
43+
try {
44+
$composerJsonContents = FileReader::read($composerJsonPath);
45+
$composer = Json::decode($composerJsonContents, Json::FORCE_ARRAY);
46+
} catch (\PHPStan\File\CouldNotReadFileException | \Nette\Utils\JsonException $e) {
47+
return null;
48+
}
49+
50+
try {
51+
$installedJsonContents = FileReader::read($installedJsonPath);
52+
$installedJson = Json::decode($installedJsonContents, Json::FORCE_ARRAY);
53+
} catch (\PHPStan\File\CouldNotReadFileException | \Nette\Utils\JsonException $e) {
54+
return null;
55+
}
4556

46-
$installedJsonContents = FileReader::read($installedJsonPath);
47-
$installedJson = Json::decode($installedJsonContents, Json::FORCE_ARRAY);
4857
$installed = $installedJson['packages'] ?? $installedJson;
4958

5059
$classMapPaths = array_merge(

0 commit comments

Comments
 (0)