diff --git a/src/Generator/JsonGenerator.php b/src/Generator/JsonGenerator.php index 6a087b6..583d365 100644 --- a/src/Generator/JsonGenerator.php +++ b/src/Generator/JsonGenerator.php @@ -214,7 +214,13 @@ private function getMetaEntry(string $parserFilename, bool $throwOnMissing = fal private function walkTocTreeAndReturnHierarchy(string $filename, array &$walkedFiles): array { $hierarchy = []; - foreach ($this->getMetaEntry($filename)->getTocs() as $toc) { + + // happens in edge-cases such as empty or not found documents + if (null === $meta = $this->getMetaEntry($filename)) { + return $hierarchy; + } + + foreach ($meta->getTocs() as $toc) { foreach ($toc as $tocFilename) { // only walk a file one time, the first time you see it if (in_array($tocFilename, $walkedFiles, true)) { @@ -273,7 +279,10 @@ private function determineParents(string $parserFilename, array $tocTreeHierarch private function makeRelativeLink(string $currentFilename, string $filename): array { - $meta = $this->getMetaEntry($filename); + // happens in edge-cases such as empty or not found documents + if (null === $meta = $this->getMetaEntry($filename)) { + return ['title' => '', 'link' => '']; + } return [ 'title' => $meta->getTitle(),