Skip to content

Commit c0b230d

Browse files
committed
Fixed some minor issues related to edge cases
1 parent da18734 commit c0b230d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Generator/JsonGenerator.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,13 @@ private function getMetaEntry(string $parserFilename, bool $throwOnMissing = fal
214214
private function walkTocTreeAndReturnHierarchy(string $filename, array &$walkedFiles): array
215215
{
216216
$hierarchy = [];
217-
foreach ($this->getMetaEntry($filename)->getTocs() as $toc) {
217+
218+
// happens in edge-cases such as empty or not found documents
219+
if (null === $meta = $this->getMetaEntry($filename)) {
220+
return $hierarchy;
221+
}
222+
223+
foreach ($meta->getTocs() as $toc) {
218224
foreach ($toc as $tocFilename) {
219225
// only walk a file one time, the first time you see it
220226
if (in_array($tocFilename, $walkedFiles, true)) {
@@ -273,7 +279,10 @@ private function determineParents(string $parserFilename, array $tocTreeHierarch
273279

274280
private function makeRelativeLink(string $currentFilename, string $filename): array
275281
{
276-
$meta = $this->getMetaEntry($filename);
282+
// happens in edge-cases such as empty or not found documents
283+
if (null === $meta = $this->getMetaEntry($filename)) {
284+
return ['title' => '', 'link' => ''];
285+
}
277286

278287
return [
279288
'title' => $meta->getTitle(),

0 commit comments

Comments
 (0)