diff --git a/packages/framework/src/Framework/Actions/GeneratesTableOfContents.php b/packages/framework/src/Framework/Actions/GeneratesTableOfContents.php index ca06d36a3a0..8f8b605c215 100644 --- a/packages/framework/src/Framework/Actions/GeneratesTableOfContents.php +++ b/packages/framework/src/Framework/Actions/GeneratesTableOfContents.php @@ -26,17 +26,13 @@ public function __construct(Markdown|string $markdown) $this->maxHeadingLevel = Config::getInt('docs.sidebar.table_of_contents.max_heading_level', 4); } - /** - * @return array - */ + /** @return array */ public function execute(): array { return $this->buildTableOfContents($this->parseHeadings()); } - /** - * @return array - */ + /** @return array */ protected function parseHeadings(): array { $matches = $this->matchHeadingPatterns(); @@ -55,9 +51,7 @@ protected function parseHeadings(): array return $headings; } - /** - * @return array{0: array, 1: array, 2: array, 3: array} - */ + /** @return array{0: array, 1: array, 2: array, 3: array} */ protected function matchHeadingPatterns(): array { // Match both ATX-style (###) and Setext-style (===, ---) headers @@ -80,9 +74,7 @@ protected function parseHeadingData(string $heading, array $matches, int $index) return $this->parseSetextHeading($matches[2][$index], $matches[3][$index]); } - /** - * @return array{level: int, title: string} - */ + /** @return array{level: int, title: string} */ protected function parseAtxHeading(string $heading, string $title): array { return [ @@ -91,9 +83,7 @@ protected function parseAtxHeading(string $heading, string $title): array ]; } - /** - * @return array{level: int, title: string}|null - */ + /** @return array{level: int, title: string}|null */ protected function parseSetextHeading(string $title, string $marker): ?array { $level = $marker === '=' ? 1 : 2; @@ -144,9 +134,7 @@ protected function buildTableOfContents(array $headings): array return $items; } - /** - * @param array{level: int, title: string, identifier: string} $heading - */ + /** @param array{level: int, title: string, identifier: string} $heading */ protected function isHeadingWithinBounds(array $heading): bool { return $heading['level'] >= $this->minHeadingLevel && @@ -166,9 +154,7 @@ protected function createTableItem(array $heading): array ]; } - /** - * @param array> $stack - */ + /** @param array> $stack */ protected function updateStackForHeadingLevel(array &$stack, int $currentLevel, int $previousLevel): void { if ($currentLevel > $previousLevel) { @@ -180,9 +166,7 @@ protected function updateStackForHeadingLevel(array &$stack, int $currentLevel, } } - /** - * @param array> $stack - */ + /** @param array> $stack */ protected function nestNewLevel(array &$stack): void { $lastStackIndex = count($stack) - 1; @@ -191,9 +175,7 @@ protected function nestNewLevel(array &$stack): void $stack[] = &$stack[$lastStackIndex][$lastItemIndex]['children']; } - /** - * @param array> $stack - */ + /** @param array> $stack */ protected function unwindStack(array &$stack, int $currentLevel): void { array_splice($stack, $currentLevel - $this->minHeadingLevel + 1);