Skip to content

Commit 3ab42e6

Browse files
gen_stub: move getFileDocComments() into FileInfo
Reduce the number of global functions by moving it to static method `FileInfo::getFileDocComments()`. Since it is only used by `FileInfo::parseStubFile()`, also make it private.
1 parent f1d533d commit 3ab42e6

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

build/gen_stub.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4344,13 +4344,25 @@ protected function pName_FullyQualified(Name\FullyQualified $node): string {
43444344
$stmts = $parser->parse($code);
43454345
$nodeTraverser->traverse($stmts);
43464346

4347-
$fileTags = DocCommentTag::parseDocComments(getFileDocComments($stmts));
4347+
$fileTags = DocCommentTag::parseDocComments(self::getFileDocComments($stmts));
43484348
$fileInfo = new FileInfo($fileTags);
43494349

43504350
$fileInfo->handleStatements($stmts, $prettyPrinter);
43514351
return $fileInfo;
43524352
}
43534353

4354+
/** @return DocComment[] */
4355+
private static function getFileDocComments(array $stmts): array {
4356+
if (empty($stmts)) {
4357+
return [];
4358+
}
4359+
4360+
return array_filter(
4361+
$stmts[0]->getComments(),
4362+
static fn ( $comment ): bool => $comment instanceof DocComment
4363+
);
4364+
}
4365+
43544366
private function handleStatements(array $stmts, PrettyPrinterAbstract $prettyPrinter): void {
43554367
$conds = [];
43564368
foreach ($stmts as $stmt) {
@@ -5086,18 +5098,6 @@ function parseClass(
50865098
);
50875099
}
50885100

5089-
/** @return DocComment[] */
5090-
function getFileDocComments(array $stmts): array {
5091-
if (empty($stmts)) {
5092-
return [];
5093-
}
5094-
5095-
return array_filter(
5096-
$stmts[0]->getComments(),
5097-
static fn ( $comment ): bool => $comment instanceof DocComment
5098-
);
5099-
}
5100-
51015101
/**
51025102
* @template T
51035103
* @param iterable<T> $infos

0 commit comments

Comments
 (0)