summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-10-02 17:21:16 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-10-02 17:21:16 +0200
commitdfa6d1c22ef55a9e288a63a20a869f218fb7a7a6 (patch)
tree080ad733d5b5026baec342316e97bbbb32b06098 /build
parent924ac2b98ae558617708180767ae512aa0c13f7a (diff)
downloadphp-git-dfa6d1c22ef55a9e288a63a20a869f218fb7a7a6.tar.gz
Support specifying linkage for generate-function-entries
The linkage can be specified as the argument to the @generate-function-entries tag. Test this on zend_test.
Diffstat (limited to 'build')
-rwxr-xr-xbuild/gen_stub.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/build/gen_stub.php b/build/gen_stub.php
index e2c6bb2eb2..56106dec90 100755
--- a/build/gen_stub.php
+++ b/build/gen_stub.php
@@ -624,6 +624,8 @@ class FileInfo {
public $classInfos = [];
/** @var bool */
public $generateFunctionEntries = false;
+ /** @var string */
+ public $declarationPrefix = "";
/**
* @return iterable<FuncInfo>
@@ -941,8 +943,12 @@ function parseStubFile(string $code): FileInfo {
$fileInfo = new FileInfo;
$fileDocComment = getFileDocComment($stmts);
if ($fileDocComment) {
- if (strpos($fileDocComment->getText(), '@generate-function-entries') !== false) {
- $fileInfo->generateFunctionEntries = true;
+ $fileTags = parseDocComment($fileDocComment);
+ foreach ($fileTags as $tag) {
+ if ($tag->name === 'generate-function-entries') {
+ $fileInfo->generateFunctionEntries = true;
+ $fileInfo->declarationPrefix = $tag->value ? $tag->value . " " : "";
+ }
}
}
@@ -1110,15 +1116,14 @@ function generateArgInfoCode(FileInfo $fileInfo, string $stubHash): string {
$generatedFunctionDeclarations = [];
$code .= generateCodeWithConditions(
$fileInfo->getAllFuncInfos(), "",
- function (FuncInfo $funcInfo) use(&$generatedFunctionDeclarations) {
+ function (FuncInfo $funcInfo) use($fileInfo, &$generatedFunctionDeclarations) {
$key = $funcInfo->getDeclarationKey();
if (isset($generatedFunctionDeclarations[$key])) {
return null;
}
$generatedFunctionDeclarations[$key] = true;
-
- return $funcInfo->getDeclaration();
+ return $fileInfo->declarationPrefix . $funcInfo->getDeclaration();
}
);