diff options
-rwxr-xr-x | build/gen_stub.php | 15 | ||||
-rw-r--r-- | ext/zend_test/test.c | 34 | ||||
-rw-r--r-- | ext/zend_test/test.stub.php | 2 | ||||
-rw-r--r-- | ext/zend_test/test_arginfo.h | 34 |
4 files changed, 45 insertions, 40 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(); } ); diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 92b8e4cf6a..13781e32be 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -51,7 +51,7 @@ static zend_class_entry *zend_test_trait; static zend_class_entry *zend_test_attribute; static zend_object_handlers zend_test_class_handlers; -ZEND_FUNCTION(zend_test_func) +static ZEND_FUNCTION(zend_test_func) { RETVAL_STR_COPY(EX(func)->common.function_name); @@ -62,23 +62,23 @@ ZEND_FUNCTION(zend_test_func) EX(func) = NULL; } -ZEND_FUNCTION(zend_test_array_return) +static ZEND_FUNCTION(zend_test_array_return) { ZEND_PARSE_PARAMETERS_NONE(); } -ZEND_FUNCTION(zend_test_nullable_array_return) +static ZEND_FUNCTION(zend_test_nullable_array_return) { ZEND_PARSE_PARAMETERS_NONE(); } -ZEND_FUNCTION(zend_test_void_return) +static ZEND_FUNCTION(zend_test_void_return) { /* dummy */ ZEND_PARSE_PARAMETERS_NONE(); } -ZEND_FUNCTION(zend_test_deprecated) +static ZEND_FUNCTION(zend_test_deprecated) { zval *arg1; @@ -88,7 +88,7 @@ ZEND_FUNCTION(zend_test_deprecated) /* Create a string without terminating null byte. Must be terminated with * zend_terminate_string() before destruction, otherwise a warning is issued * in debug builds. */ -ZEND_FUNCTION(zend_create_unterminated_string) +static ZEND_FUNCTION(zend_create_unterminated_string) { zend_string *str, *res; @@ -104,7 +104,7 @@ ZEND_FUNCTION(zend_create_unterminated_string) } /* Enforce terminate null byte on string. This avoids a warning in debug builds. */ -ZEND_FUNCTION(zend_terminate_string) +static ZEND_FUNCTION(zend_terminate_string) { zend_string *str; @@ -116,7 +116,7 @@ ZEND_FUNCTION(zend_terminate_string) } /* {{{ Cause an intentional memory leak, for testing/debugging purposes */ -ZEND_FUNCTION(zend_leak_bytes) +static ZEND_FUNCTION(zend_leak_bytes) { zend_long leakbytes = 3; @@ -129,7 +129,7 @@ ZEND_FUNCTION(zend_leak_bytes) /* }}} */ /* {{{ Leak a refcounted variable */ -ZEND_FUNCTION(zend_leak_variable) +static ZEND_FUNCTION(zend_leak_variable) { zval *zv; @@ -147,7 +147,7 @@ ZEND_FUNCTION(zend_leak_variable) /* }}} */ /* Tests Z_PARAM_OBJ_OR_STR */ -ZEND_FUNCTION(zend_string_or_object) +static ZEND_FUNCTION(zend_string_or_object) { zend_string *str; zend_object *object; @@ -165,7 +165,7 @@ ZEND_FUNCTION(zend_string_or_object) /* }}} */ /* Tests Z_PARAM_OBJ_OR_STR_OR_NULL */ -ZEND_FUNCTION(zend_string_or_object_or_null) +static ZEND_FUNCTION(zend_string_or_object_or_null) { zend_string *str; zend_object *object; @@ -185,7 +185,7 @@ ZEND_FUNCTION(zend_string_or_object_or_null) /* }}} */ /* Tests Z_PARAM_OBJ_OF_CLASS_OR_STR */ -ZEND_FUNCTION(zend_string_or_stdclass) +static ZEND_FUNCTION(zend_string_or_stdclass) { zend_string *str; zend_object *object; @@ -203,7 +203,7 @@ ZEND_FUNCTION(zend_string_or_stdclass) /* }}} */ /* Tests Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL */ -ZEND_FUNCTION(zend_string_or_stdclass_or_null) +static ZEND_FUNCTION(zend_string_or_stdclass_or_null) { zend_string *str; zend_object *object; @@ -223,7 +223,7 @@ ZEND_FUNCTION(zend_string_or_stdclass_or_null) /* }}} */ /* TESTS Z_PARAM_ITERABLE and Z_PARAM_ITERABLE_OR_NULL */ -ZEND_FUNCTION(zend_iterable) +static ZEND_FUNCTION(zend_iterable) { zval *arg1, *arg2; @@ -292,18 +292,18 @@ void zend_attribute_validate_zendtestattribute(zend_attribute *attr, uint32_t ta } } -ZEND_METHOD(_ZendTestClass, __toString) /* {{{ */ { +static ZEND_METHOD(_ZendTestClass, __toString) /* {{{ */ { RETURN_EMPTY_STRING(); } /* }}} */ /* Internal function returns bool, we return int. */ -ZEND_METHOD(_ZendTestClass, is_object) /* {{{ */ { +static ZEND_METHOD(_ZendTestClass, is_object) /* {{{ */ { RETURN_LONG(42); } /* }}} */ -ZEND_METHOD(_ZendTestTrait, testMethod) /* {{{ */ { +static ZEND_METHOD(_ZendTestTrait, testMethod) /* {{{ */ { RETURN_TRUE; } /* }}} */ diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 1dd0cfec4e..96e7b56921 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -1,6 +1,6 @@ <?php -/** @generate-function-entries */ +/** @generate-function-entries static */ class _ZendTestClass { public static function is_object(): int {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index bd8d477b42..80e89c6fe0 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 87c9d71b08c538c28b4f9bad01d7a7a3a3b191ef */ + * Stub hash: 1aa8e876ff9efb99c61603216eed267b0d225221 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0) ZEND_END_ARG_INFO() @@ -61,22 +61,22 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class__ZendTestTrait_testMethod, ZEND_END_ARG_INFO() -ZEND_FUNCTION(zend_test_array_return); -ZEND_FUNCTION(zend_test_nullable_array_return); -ZEND_FUNCTION(zend_test_void_return); -ZEND_FUNCTION(zend_test_deprecated); -ZEND_FUNCTION(zend_create_unterminated_string); -ZEND_FUNCTION(zend_terminate_string); -ZEND_FUNCTION(zend_leak_variable); -ZEND_FUNCTION(zend_leak_bytes); -ZEND_FUNCTION(zend_string_or_object); -ZEND_FUNCTION(zend_string_or_object_or_null); -ZEND_FUNCTION(zend_string_or_stdclass); -ZEND_FUNCTION(zend_string_or_stdclass_or_null); -ZEND_FUNCTION(zend_iterable); -ZEND_METHOD(_ZendTestClass, is_object); -ZEND_METHOD(_ZendTestClass, __toString); -ZEND_METHOD(_ZendTestTrait, testMethod); +static ZEND_FUNCTION(zend_test_array_return); +static ZEND_FUNCTION(zend_test_nullable_array_return); +static ZEND_FUNCTION(zend_test_void_return); +static ZEND_FUNCTION(zend_test_deprecated); +static ZEND_FUNCTION(zend_create_unterminated_string); +static ZEND_FUNCTION(zend_terminate_string); +static ZEND_FUNCTION(zend_leak_variable); +static ZEND_FUNCTION(zend_leak_bytes); +static ZEND_FUNCTION(zend_string_or_object); +static ZEND_FUNCTION(zend_string_or_object_or_null); +static ZEND_FUNCTION(zend_string_or_stdclass); +static ZEND_FUNCTION(zend_string_or_stdclass_or_null); +static ZEND_FUNCTION(zend_iterable); +static ZEND_METHOD(_ZendTestClass, is_object); +static ZEND_METHOD(_ZendTestClass, __toString); +static ZEND_METHOD(_ZendTestTrait, testMethod); static const zend_function_entry ext_functions[] = { |