diff --git a/src/Reflection/BetterReflection/SourceLocator/ComposerJsonAndInstalledJsonSourceLocatorMaker.php b/src/Reflection/BetterReflection/SourceLocator/ComposerJsonAndInstalledJsonSourceLocatorMaker.php index de2f049b4c..f2eb5b38c5 100644 --- a/src/Reflection/BetterReflection/SourceLocator/ComposerJsonAndInstalledJsonSourceLocatorMaker.php +++ b/src/Reflection/BetterReflection/SourceLocator/ComposerJsonAndInstalledJsonSourceLocatorMaker.php @@ -40,11 +40,20 @@ public function create(string $installationPath): ?SourceLocator return null; } - $composerJsonContents = FileReader::read($composerJsonPath); - $composer = Json::decode($composerJsonContents, Json::FORCE_ARRAY); + try { + $composerJsonContents = FileReader::read($composerJsonPath); + $composer = Json::decode($composerJsonContents, Json::FORCE_ARRAY); + } catch (\PHPStan\File\CouldNotReadFileException | \Nette\Utils\JsonException $e) { + return null; + } + + try { + $installedJsonContents = FileReader::read($installedJsonPath); + $installedJson = Json::decode($installedJsonContents, Json::FORCE_ARRAY); + } catch (\PHPStan\File\CouldNotReadFileException | \Nette\Utils\JsonException $e) { + return null; + } - $installedJsonContents = FileReader::read($installedJsonPath); - $installedJson = Json::decode($installedJsonContents, Json::FORCE_ARRAY); $installed = $installedJson['packages'] ?? $installedJson; $classMapPaths = array_merge(