mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Support multiple file-level phpdoc blocks in gen_stub.php
This allows writing the following: /** @generate-class-entries */ /** @generate-legacy-arginfo 80000 */
This commit is contained in:
parent
74c887b04e
commit
ec285ff669
1 changed files with 13 additions and 12 deletions
|
@ -4498,21 +4498,22 @@ function handlePreprocessorConditions(array &$conds, Stmt $stmt): ?string {
|
|||
return empty($conds) ? null : implode(' && ', $conds);
|
||||
}
|
||||
|
||||
function getFileDocComment(array $stmts): ?DocComment {
|
||||
/** @return DocComment[] */
|
||||
function getFileDocComments(array $stmts): array {
|
||||
if (empty($stmts)) {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
$comments = $stmts[0]->getComments();
|
||||
if (empty($comments)) {
|
||||
return null;
|
||||
|
||||
$result = [];
|
||||
foreach ($comments as $comment) {
|
||||
if ($comment instanceof DocComment) {
|
||||
$result[] = $comment;
|
||||
}
|
||||
}
|
||||
|
||||
if ($comments[0] instanceof DocComment) {
|
||||
return $comments[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstract $prettyPrinter) {
|
||||
|
@ -4665,9 +4666,9 @@ function parseStubFile(string $code): FileInfo {
|
|||
$nodeTraverser->traverse($stmts);
|
||||
|
||||
$fileInfo = new FileInfo;
|
||||
$fileDocComment = getFileDocComment($stmts);
|
||||
if ($fileDocComment) {
|
||||
$fileTags = parseDocComment($fileDocComment);
|
||||
$fileDocComments = getFileDocComments($stmts);
|
||||
if ($fileDocComments !== []) {
|
||||
$fileTags = parseDocComments($fileDocComments);
|
||||
foreach ($fileTags as $tag) {
|
||||
if ($tag->name === 'generate-function-entries') {
|
||||
$fileInfo->generateFunctionEntries = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue