mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +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);
|
return empty($conds) ? null : implode(' && ', $conds);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFileDocComment(array $stmts): ?DocComment {
|
/** @return DocComment[] */
|
||||||
|
function getFileDocComments(array $stmts): array {
|
||||||
if (empty($stmts)) {
|
if (empty($stmts)) {
|
||||||
return null;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$comments = $stmts[0]->getComments();
|
$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 $result;
|
||||||
return $comments[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstract $prettyPrinter) {
|
function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstract $prettyPrinter) {
|
||||||
|
@ -4665,9 +4666,9 @@ function parseStubFile(string $code): FileInfo {
|
||||||
$nodeTraverser->traverse($stmts);
|
$nodeTraverser->traverse($stmts);
|
||||||
|
|
||||||
$fileInfo = new FileInfo;
|
$fileInfo = new FileInfo;
|
||||||
$fileDocComment = getFileDocComment($stmts);
|
$fileDocComments = getFileDocComments($stmts);
|
||||||
if ($fileDocComment) {
|
if ($fileDocComments !== []) {
|
||||||
$fileTags = parseDocComment($fileDocComment);
|
$fileTags = parseDocComments($fileDocComments);
|
||||||
foreach ($fileTags as $tag) {
|
foreach ($fileTags as $tag) {
|
||||||
if ($tag->name === 'generate-function-entries') {
|
if ($tag->name === 'generate-function-entries') {
|
||||||
$fileInfo->generateFunctionEntries = true;
|
$fileInfo->generateFunctionEntries = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue