mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Update gen_stub to avoid compile errors on duplicate function names
Closes GH-9406
This commit is contained in:
parent
e3034dba3e
commit
f7d42f646b
5 changed files with 144 additions and 27 deletions
|
@ -63,6 +63,11 @@ PHP 8.2 INTERNALS UPGRADE NOTES
|
|||
========================
|
||||
|
||||
* Unsupported libxml2 2.10.0 symbols are no longer exported on Windows.
|
||||
* Identifier names for namespaced functions generated from stub files through
|
||||
gen_stub.php have been changed. This requires that namespaced functions
|
||||
should be declared via the PHP_FUNCTION macro by using the fully qualified
|
||||
function name (whereas each part is separated by "_") instead of just the
|
||||
function name itself.
|
||||
|
||||
========================
|
||||
3. Module changes
|
||||
|
|
|
@ -1037,6 +1037,10 @@ class FunctionName implements FunctionOrMethodName {
|
|||
}
|
||||
|
||||
public function getDeclarationName(): string {
|
||||
return implode('_', $this->name->parts);
|
||||
}
|
||||
|
||||
public function getFunctionName(): string {
|
||||
return $this->name->getLast();
|
||||
}
|
||||
|
||||
|
@ -1380,39 +1384,42 @@ class FuncInfo {
|
|||
}
|
||||
} else if ($this->name instanceof FunctionName) {
|
||||
$namespace = $this->name->getNamespace();
|
||||
$declarationName = $this->name->getDeclarationName();
|
||||
$functionName = $this->name->getFunctionName();
|
||||
$declarationName = $this->alias ? $this->alias->getNonNamespacedName() : $this->name->getDeclarationName();
|
||||
|
||||
if ($this->alias && $this->isDeprecated) {
|
||||
if ($namespace) {
|
||||
// Namespaced functions are always declared as aliases to avoid name conflicts when two functions with
|
||||
// the same name exist in separate namespaces
|
||||
$macro = $this->isDeprecated ? 'ZEND_NS_DEP_FALIAS' : 'ZEND_NS_FALIAS';
|
||||
|
||||
// Render A\B as "A\\B" in C strings for namespaces
|
||||
return sprintf(
|
||||
"\tZEND_DEP_FALIAS(%s, %s, %s)\n",
|
||||
$declarationName, $this->alias->getNonNamespacedName(), $this->getArgInfoName()
|
||||
"\t%s(\"%s\", %s, %s, %s)\n",
|
||||
$macro, addslashes($namespace), $this->name->getFunctionName(), $declarationName, $this->getArgInfoName()
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->alias) {
|
||||
$macro = $this->isDeprecated ? 'ZEND_DEP_FALIAS' : 'ZEND_FALIAS';
|
||||
|
||||
return sprintf(
|
||||
"\tZEND_FALIAS(%s, %s, %s)\n",
|
||||
$declarationName, $this->alias->getNonNamespacedName(), $this->getArgInfoName()
|
||||
"\t%s(%s, %s, %s)\n",
|
||||
$macro, $functionName, $declarationName, $this->getArgInfoName()
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->isDeprecated) {
|
||||
return sprintf(
|
||||
"\tZEND_DEP_FE(%s, %s)\n", $declarationName, $this->getArgInfoName());
|
||||
switch (true) {
|
||||
case $this->isDeprecated:
|
||||
$macro = 'ZEND_DEP_FE';
|
||||
break;
|
||||
case $this->supportsCompileTimeEval:
|
||||
$macro = 'ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE';
|
||||
break;
|
||||
default:
|
||||
$macro = 'ZEND_FE';
|
||||
}
|
||||
|
||||
if ($namespace) {
|
||||
// Render A\B as "A\\B" in C strings for namespaces
|
||||
return sprintf(
|
||||
"\tZEND_NS_FE(\"%s\", %s, %s)\n",
|
||||
addslashes($namespace), $declarationName, $this->getArgInfoName());
|
||||
} else {
|
||||
if ($this->supportsCompileTimeEval) {
|
||||
return sprintf(
|
||||
"\tZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(%s, %s)\n", $declarationName, $this->getArgInfoName());
|
||||
}
|
||||
return sprintf("\tZEND_FE(%s, %s)\n", $declarationName, $this->getArgInfoName());
|
||||
}
|
||||
return sprintf("\t%s(%s, %s)\n", $macro, $functionName, $this->getArgInfoName());
|
||||
} else {
|
||||
throw new Error("Cannot happen");
|
||||
}
|
||||
|
|
|
@ -95,6 +95,16 @@ static ZEND_FUNCTION(zend_test_deprecated)
|
|||
zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &arg1);
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(zend_test_alias)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(zend_test_deprecated_alias)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
}
|
||||
|
||||
/* Create a string without terminating null byte. Must be terminated with
|
||||
* zend_terminate_string() before destruction, otherwise a warning is issued
|
||||
* in debug builds. */
|
||||
|
@ -415,12 +425,38 @@ static ZEND_FUNCTION(zend_test_zend_ini_parse_uquantity)
|
|||
}
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(namespaced_func)
|
||||
static ZEND_FUNCTION(ZendTestNS2_namespaced_func)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(ZendTestNS2_namespaced_deprecated_func)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(ZendTestNS2_ZendSubNS_namespaced_func)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(ZendTestNS2_ZendSubNS_namespaced_deprecated_func)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(namespaced_alias_func)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(namespaced_deprecated_alias_func)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
}
|
||||
|
||||
static ZEND_FUNCTION(zend_test_parameter_with_attribute)
|
||||
{
|
||||
zend_string *parameter;
|
||||
|
|
|
@ -109,6 +109,15 @@ namespace {
|
|||
/** @deprecated */
|
||||
function zend_test_deprecated(mixed $arg = null): void {}
|
||||
|
||||
/** @alias zend_test_alias */
|
||||
function zend_test_aliased(): void {}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @alias zend_test_deprecated_alias
|
||||
*/
|
||||
function zend_test_deprecated_aliased(): void {}
|
||||
|
||||
function zend_create_unterminated_string(string $str): string {}
|
||||
|
||||
function zend_terminate_string(string &$str): void {}
|
||||
|
@ -168,6 +177,20 @@ namespace ZendTestNS2 {
|
|||
public function method(): void {}
|
||||
}
|
||||
|
||||
function namespaced_func(): bool {}
|
||||
|
||||
/** @deprecated */
|
||||
function namespaced_deprecated_func(): void {}
|
||||
|
||||
/** @alias namespaced_alias_func */
|
||||
function namespaced_aliased_func(): void {}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @alias namespaced_deprecated_alias_func
|
||||
*/
|
||||
function namespaced_deprecated_aliased_func(): void {}
|
||||
|
||||
}
|
||||
|
||||
namespace ZendTestNS2\ZendSubNS {
|
||||
|
@ -178,4 +201,16 @@ namespace ZendTestNS2\ZendSubNS {
|
|||
|
||||
function namespaced_func(): bool {}
|
||||
|
||||
/** @deprecated */
|
||||
function namespaced_deprecated_func(): void {}
|
||||
|
||||
/** @alias namespaced_alias_func */
|
||||
function namespaced_aliased_func(): void {}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @alias namespaced_deprecated_alias_func
|
||||
*/
|
||||
function namespaced_deprecated_aliased_func(): void {}
|
||||
|
||||
}
|
||||
|
|
44
ext/zend_test/test_arginfo.h
generated
44
ext/zend_test/test_arginfo.h
generated
|
@ -1,5 +1,5 @@
|
|||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: daa7be53e9009c66c814fb5b0407a6dfbe09679a */
|
||||
* Stub hash: 0c3e4da20bf5b32e289a795e0beac649294e83f3 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
@ -20,6 +20,10 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_deprecated, 0, 0, IS_V
|
|||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arg, IS_MIXED, 0, "null")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_zend_test_aliased arginfo_zend_test_void_return
|
||||
|
||||
#define arginfo_zend_test_deprecated_aliased arginfo_zend_test_void_return
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_create_unterminated_string, 0, 1, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
@ -91,9 +95,23 @@ ZEND_END_ARG_INFO()
|
|||
|
||||
#define arginfo_zend_test_zend_ini_parse_uquantity arginfo_zend_test_zend_ini_parse_quantity
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ZendTestNS2_ZendSubNS_namespaced_func, 0, 0, _IS_BOOL, 0)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ZendTestNS2_namespaced_func, 0, 0, _IS_BOOL, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_ZendTestNS2_namespaced_deprecated_func arginfo_zend_test_void_return
|
||||
|
||||
#define arginfo_ZendTestNS2_namespaced_aliased_func arginfo_zend_test_void_return
|
||||
|
||||
#define arginfo_ZendTestNS2_namespaced_deprecated_aliased_func arginfo_zend_test_void_return
|
||||
|
||||
#define arginfo_ZendTestNS2_ZendSubNS_namespaced_func arginfo_ZendTestNS2_namespaced_func
|
||||
|
||||
#define arginfo_ZendTestNS2_ZendSubNS_namespaced_deprecated_func arginfo_zend_test_void_return
|
||||
|
||||
#define arginfo_ZendTestNS2_ZendSubNS_namespaced_aliased_func arginfo_zend_test_void_return
|
||||
|
||||
#define arginfo_ZendTestNS2_ZendSubNS_namespaced_deprecated_aliased_func arginfo_zend_test_void_return
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class__ZendTestClass_is_object, 0, 0, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
|
@ -108,7 +126,7 @@ ZEND_END_ARG_INFO()
|
|||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class__ZendTestChildClass_returnsThrowable, 0, 0, Exception, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_class__ZendTestTrait_testMethod arginfo_ZendTestNS2_ZendSubNS_namespaced_func
|
||||
#define arginfo_class__ZendTestTrait_testMethod arginfo_ZendTestNS2_namespaced_func
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZendTestParameterAttribute___construct, 0, 0, 1)
|
||||
ZEND_ARG_TYPE_INFO(0, parameter, IS_STRING, 0)
|
||||
|
@ -144,6 +162,8 @@ static ZEND_FUNCTION(zend_test_nullable_array_return);
|
|||
static ZEND_FUNCTION(zend_test_void_return);
|
||||
static ZEND_FUNCTION(zend_test_compile_string);
|
||||
static ZEND_FUNCTION(zend_test_deprecated);
|
||||
static ZEND_FUNCTION(zend_test_alias);
|
||||
static ZEND_FUNCTION(zend_test_deprecated_alias);
|
||||
static ZEND_FUNCTION(zend_create_unterminated_string);
|
||||
static ZEND_FUNCTION(zend_terminate_string);
|
||||
static ZEND_FUNCTION(zend_leak_variable);
|
||||
|
@ -162,7 +182,12 @@ static ZEND_FUNCTION(zend_get_current_func_name);
|
|||
static ZEND_FUNCTION(zend_call_method);
|
||||
static ZEND_FUNCTION(zend_test_zend_ini_parse_quantity);
|
||||
static ZEND_FUNCTION(zend_test_zend_ini_parse_uquantity);
|
||||
static ZEND_FUNCTION(namespaced_func);
|
||||
static ZEND_FUNCTION(ZendTestNS2_namespaced_func);
|
||||
static ZEND_FUNCTION(ZendTestNS2_namespaced_deprecated_func);
|
||||
static ZEND_FUNCTION(namespaced_alias_func);
|
||||
static ZEND_FUNCTION(namespaced_deprecated_alias_func);
|
||||
static ZEND_FUNCTION(ZendTestNS2_ZendSubNS_namespaced_func);
|
||||
static ZEND_FUNCTION(ZendTestNS2_ZendSubNS_namespaced_deprecated_func);
|
||||
static ZEND_METHOD(_ZendTestClass, is_object);
|
||||
static ZEND_METHOD(_ZendTestClass, __toString);
|
||||
static ZEND_METHOD(_ZendTestClass, returnsStatic);
|
||||
|
@ -187,6 +212,8 @@ static const zend_function_entry ext_functions[] = {
|
|||
ZEND_FE(zend_test_void_return, arginfo_zend_test_void_return)
|
||||
ZEND_FE(zend_test_compile_string, arginfo_zend_test_compile_string)
|
||||
ZEND_DEP_FE(zend_test_deprecated, arginfo_zend_test_deprecated)
|
||||
ZEND_FALIAS(zend_test_aliased, zend_test_alias, arginfo_zend_test_aliased)
|
||||
ZEND_DEP_FALIAS(zend_test_deprecated_aliased, zend_test_deprecated_alias, arginfo_zend_test_deprecated_aliased)
|
||||
ZEND_FE(zend_create_unterminated_string, arginfo_zend_create_unterminated_string)
|
||||
ZEND_FE(zend_terminate_string, arginfo_zend_terminate_string)
|
||||
ZEND_FE(zend_leak_variable, arginfo_zend_leak_variable)
|
||||
|
@ -205,7 +232,14 @@ static const zend_function_entry ext_functions[] = {
|
|||
ZEND_FE(zend_call_method, arginfo_zend_call_method)
|
||||
ZEND_FE(zend_test_zend_ini_parse_quantity, arginfo_zend_test_zend_ini_parse_quantity)
|
||||
ZEND_FE(zend_test_zend_ini_parse_uquantity, arginfo_zend_test_zend_ini_parse_uquantity)
|
||||
ZEND_NS_FE("ZendTestNS2\\ZendSubNS", namespaced_func, arginfo_ZendTestNS2_ZendSubNS_namespaced_func)
|
||||
ZEND_NS_FALIAS("ZendTestNS2", namespaced_func, ZendTestNS2_namespaced_func, arginfo_ZendTestNS2_namespaced_func)
|
||||
ZEND_NS_DEP_FALIAS("ZendTestNS2", namespaced_deprecated_func, ZendTestNS2_namespaced_deprecated_func, arginfo_ZendTestNS2_namespaced_deprecated_func)
|
||||
ZEND_NS_FALIAS("ZendTestNS2", namespaced_aliased_func, namespaced_alias_func, arginfo_ZendTestNS2_namespaced_aliased_func)
|
||||
ZEND_NS_DEP_FALIAS("ZendTestNS2", namespaced_deprecated_aliased_func, namespaced_deprecated_alias_func, arginfo_ZendTestNS2_namespaced_deprecated_aliased_func)
|
||||
ZEND_NS_FALIAS("ZendTestNS2\\ZendSubNS", namespaced_func, ZendTestNS2_ZendSubNS_namespaced_func, arginfo_ZendTestNS2_ZendSubNS_namespaced_func)
|
||||
ZEND_NS_DEP_FALIAS("ZendTestNS2\\ZendSubNS", namespaced_deprecated_func, ZendTestNS2_ZendSubNS_namespaced_deprecated_func, arginfo_ZendTestNS2_ZendSubNS_namespaced_deprecated_func)
|
||||
ZEND_NS_FALIAS("ZendTestNS2\\ZendSubNS", namespaced_aliased_func, namespaced_alias_func, arginfo_ZendTestNS2_ZendSubNS_namespaced_aliased_func)
|
||||
ZEND_NS_DEP_FALIAS("ZendTestNS2\\ZendSubNS", namespaced_deprecated_aliased_func, namespaced_deprecated_alias_func, arginfo_ZendTestNS2_ZendSubNS_namespaced_deprecated_aliased_func)
|
||||
ZEND_FE_END
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue