]> granicus.if.org Git - php/commitdiff
Properly render 2+ namespaces functions in build/gen_stub.php
authorTyson Andre <tysonandre775@hotmail.com>
Sat, 6 Feb 2021 19:13:22 +0000 (14:13 -0500)
committerTyson Andre <tysonandre775@hotmail.com>
Sat, 6 Feb 2021 19:17:14 +0000 (14:17 -0500)
Affects ZEND_NS_FE

Add test cases of the global function

Backported to php 8.0 from GH-6664

build/gen_stub.php
ext/zend_test/test.c
ext/zend_test/test.stub.php
ext/zend_test/test_arginfo.h

index 6d1ae99ebc837166594f9a39d1095dac6d1a073a..d84851091b6c8f251d77888a22dd7d2f0b4e6691 100755 (executable)
@@ -793,9 +793,10 @@ class FuncInfo {
             }
 
             if ($namespace) {
+                // Render A\B as "A\\B" in C strings for namespaces
                 return sprintf(
                     "\tZEND_NS_FE(\"%s\", %s, %s)\n",
-                    $namespace, $declarationName, $this->getArgInfoName());
+                    addslashes($namespace), $declarationName, $this->getArgInfoName());
             } else {
                 return sprintf("\tZEND_FE(%s, %s)\n", $declarationName, $this->getArgInfoName());
             }
index c44fdb481f3546ad4afbd682ab5c0822b2b6c9b1..bd33e7c331838af0f2af9ead0ce10e8ef1dbe7b3 100644 (file)
@@ -236,6 +236,12 @@ static ZEND_FUNCTION(zend_iterable)
        ZEND_PARSE_PARAMETERS_END();
 }
 
+static ZEND_FUNCTION(namespaced_func)
+{
+       ZEND_PARSE_PARAMETERS_NONE();
+       RETURN_TRUE;
+}
+
 static zend_object *zend_test_class_new(zend_class_entry *class_type) /* {{{ */ {
        zend_object *obj = zend_objects_new(class_type);
        object_properties_init(obj, class_type);
index 91ff78e113e0a8ea4b395b312e30c8f2bb0e8002..486b383e1d1750ce03422c220acf60ea42630884 100644 (file)
@@ -63,3 +63,9 @@ class Foo {
 }
 
 }
+
+namespace ZendTestNS2\ZendSubNS {
+
+function namespaced_func(): bool {}
+
+}
index c1fd6fd202a3e1d887e30c1a400b62f4de6013b1..61039705855f6bddf9ea839291bde0507f1d55fa 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 759463b1adece643974a9c51455789aef11ba935 */
+ * Stub hash: d98281072c6eeb5631dbf3ba975807f49a553b3e */
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0)
 ZEND_END_ARG_INFO()
@@ -51,6 +51,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_iterable, 0, 1, IS_VOID, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arg2, IS_ITERABLE, 1, "null")
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ZendTestNS2_ZendSubNS_namespaced_func, 0, 0, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class__ZendTestClass_is_object, 0, 0, IS_LONG, 0)
 ZEND_END_ARG_INFO()
 
@@ -60,8 +63,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class__ZendTestClass_returnsStatic, 0, 0, IS_STATIC, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class__ZendTestTrait_testMethod, 0, 0, _IS_BOOL, 0)
-ZEND_END_ARG_INFO()
+#define arginfo_class__ZendTestTrait_testMethod arginfo_ZendTestNS2_ZendSubNS_namespaced_func
 
 #define arginfo_class_ZendTestNS_Foo_method arginfo_zend_test_void_return
 
@@ -81,6 +83,7 @@ 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_FUNCTION(namespaced_func);
 static ZEND_METHOD(_ZendTestClass, is_object);
 static ZEND_METHOD(_ZendTestClass, __toString);
 static ZEND_METHOD(_ZendTestClass, returnsStatic);
@@ -103,6 +106,7 @@ static const zend_function_entry ext_functions[] = {
        ZEND_FE(zend_string_or_stdclass, arginfo_zend_string_or_stdclass)
        ZEND_FE(zend_string_or_stdclass_or_null, arginfo_zend_string_or_stdclass_or_null)
        ZEND_FE(zend_iterable, arginfo_zend_iterable)
+       ZEND_NS_FE("ZendTestNS2\\ZendSubNS", namespaced_func, arginfo_ZendTestNS2_ZendSubNS_namespaced_func)
        ZEND_FE_END
 };