Skip to content

Commit 30c8480

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 24d9419 commit 30c8480

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
@@ -4401,13 +4401,25 @@ protected function pName_FullyQualified(Name\FullyQualified $node): string {
44014401
$stmts = $parser->parse($code);
44024402
$nodeTraverser->traverse($stmts);
44034403

4404-
$fileTags = DocCommentTag::parseDocComments(getFileDocComments($stmts));
4404+
$fileTags = DocCommentTag::parseDocComments(self::getFileDocComments($stmts));
44054405
$fileInfo = new FileInfo($fileTags);
44064406

44074407
$fileInfo->handleStatements($stmts, $prettyPrinter);
44084408
return $fileInfo;
44094409
}
44104410

4411+
/** @return DocComment[] */
4412+
private static function getFileDocComments(array $stmts): array {
4413+
if (empty($stmts)) {
4414+
return [];
4415+
}
4416+
4417+
return array_filter(
4418+
$stmts[0]->getComments(),
4419+
static fn ($comment): bool => $comment instanceof DocComment
4420+
);
4421+
}
4422+
44114423
private function handleStatements(array $stmts, PrettyPrinterAbstract $prettyPrinter): void {
44124424
$conds = [];
44134425
foreach ($stmts as $stmt) {
@@ -5143,18 +5155,6 @@ function parseClass(
51435155
);
51445156
}
51455157

5146-
/** @return DocComment[] */
5147-
function getFileDocComments(array $stmts): array {
5148-
if (empty($stmts)) {
5149-
return [];
5150-
}
5151-
5152-
return array_filter(
5153-
$stmts[0]->getComments(),
5154-
static fn ( $comment ): bool => $comment instanceof DocComment
5155-
);
5156-
}
5157-
51585158
/**
51595159
* @template T
51605160
* @param iterable<T> $infos

0 commit comments

Comments
 (0)