diff --git a/build/gen_stub.php b/build/gen_stub.php index 84d7944a786..2747c53d486 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -524,10 +524,10 @@ class SimpleType { } public function toEscapedName(): string { - // Escape backslashes, and also encode \u and \U to avoid compilation errors in generated macros + // Escape backslashes, and also encode \u, \U, and \N to avoid compilation errors in generated macros return str_replace( - ['\\', '\\u', '\\U'], - ['\\\\', '\\\\165', '\\\\125'], + ['\\', '\\u', '\\U', '\\N'], + ['\\\\', '\\\\165', '\\\\125', '\\\\116'], $this->name ); } diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 6e78fb016a1..bca307f8ebe 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -57,6 +57,7 @@ static zend_class_entry *zend_test_class_with_property_attribute; static zend_class_entry *zend_test_forbid_dynamic_call; static zend_class_entry *zend_test_ns_foo_class; static zend_class_entry *zend_test_ns_unlikely_compile_error_class; +static zend_class_entry *zend_test_ns_not_unlikely_compile_error_class; static zend_class_entry *zend_test_ns2_foo_class; static zend_class_entry *zend_test_ns2_ns_foo_class; static zend_class_entry *zend_test_unit_enum; @@ -796,6 +797,13 @@ static ZEND_METHOD(ZendTestNS_UnlikelyCompileError, method) RETURN_NULL(); } +static ZEND_METHOD(ZendTestNS_NotUnlikelyCompileError, method) +{ + ZEND_PARSE_PARAMETERS_NONE(); + + RETURN_NULL(); +} + static ZEND_METHOD(ZendTestNS2_Foo, method) { ZEND_PARSE_PARAMETERS_NONE(); @@ -1050,6 +1058,7 @@ PHP_MINIT_FUNCTION(zend_test) zend_test_ns_foo_class = register_class_ZendTestNS_Foo(); zend_test_ns_unlikely_compile_error_class = register_class_ZendTestNS_UnlikelyCompileError(); + zend_test_ns_not_unlikely_compile_error_class = register_class_ZendTestNS_NotUnlikelyCompileError(); zend_test_ns2_foo_class = register_class_ZendTestNS2_Foo(); zend_test_ns2_ns_foo_class = register_class_ZendTestNS2_ZendSubNS_Foo(); diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index cc76a3a7395..2b4f29581d2 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -254,6 +254,11 @@ namespace ZendTestNS { public function method(): ?UnlikelyCompileError {} } + class NotUnlikelyCompileError { + /* This method signature would create a compile error due to the string + * "ZendTestNS\NotUnlikelyCompileError" in the generated macro call */ + public function method(): ?NotUnlikelyCompileError {} + } } namespace ZendTestNS2 { diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 1598443e41d..5f7cba8a94f 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: 06ac12255321035a2669fbc5abf2f3fda4c6ad76 */ + * Stub hash: fe312caaaedac29794ab90e4210eaaad667c391c */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0) ZEND_END_ARG_INFO() @@ -209,6 +209,9 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_ZendTestNS_UnlikelyCompileError_method, 0, 0, ZendTestNS\\\125nlikelyCompileError, 1) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_ZendTestNS_NotUnlikelyCompileError_method, 0, 0, ZendTestNS\\\116otUnlikelyCompileError, 1) +ZEND_END_ARG_INFO() + #define arginfo_class_ZendTestNS2_Foo_method arginfo_zend_test_void_return #define arginfo_class_ZendTestNS2_ZendSubNS_Foo_method arginfo_zend_test_void_return @@ -277,6 +280,7 @@ static ZEND_METHOD(ZendTestForbidDynamicCall, call); static ZEND_METHOD(ZendTestForbidDynamicCall, callStatic); static ZEND_METHOD(ZendTestNS_Foo, method); static ZEND_METHOD(ZendTestNS_UnlikelyCompileError, method); +static ZEND_METHOD(ZendTestNS_NotUnlikelyCompileError, method); static ZEND_METHOD(ZendTestNS2_Foo, method); static ZEND_METHOD(ZendTestNS2_ZendSubNS_Foo, method); @@ -445,6 +449,12 @@ static const zend_function_entry class_ZendTestNS_UnlikelyCompileError_methods[] }; +static const zend_function_entry class_ZendTestNS_NotUnlikelyCompileError_methods[] = { + ZEND_ME(ZendTestNS_NotUnlikelyCompileError, method, arginfo_class_ZendTestNS_NotUnlikelyCompileError_method, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + + static const zend_function_entry class_ZendTestNS2_Foo_methods[] = { ZEND_ME(ZendTestNS2_Foo, method, arginfo_class_ZendTestNS2_Foo_method, ZEND_ACC_PUBLIC) ZEND_FE_END @@ -926,6 +936,16 @@ static zend_class_entry *register_class_ZendTestNS_UnlikelyCompileError(void) return class_entry; } +static zend_class_entry *register_class_ZendTestNS_NotUnlikelyCompileError(void) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "ZendTestNS", "NotUnlikelyCompileError", class_ZendTestNS_NotUnlikelyCompileError_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + + return class_entry; +} + static zend_class_entry *register_class_ZendTestNS2_Foo(void) { zend_class_entry ce, *class_entry; diff --git a/ext/zend_test/tests/gen_stub_test_01.phpt b/ext/zend_test/tests/gen_stub_test_01.phpt index 0a020a6f345..0f5d525322d 100644 --- a/ext/zend_test/tests/gen_stub_test_01.phpt +++ b/ext/zend_test/tests/gen_stub_test_01.phpt @@ -11,6 +11,8 @@ $foo->foo = new \ZendTestNS2\ZendSubNS\Foo(); var_dump($foo); $foo = new \ZendTestNS\UnlikelyCompileError(); var_dump($foo); +$foo = new \ZendTestNS\NotUnlikelyCompileError(); +var_dump($foo); ?> --EXPECTF-- object(ZendTestNS2\Foo)#%d (%d) { @@ -24,3 +26,5 @@ object(ZendTestNS2\Foo)#%d (%d) { } object(ZendTestNS\UnlikelyCompileError)#%d (%d) { } +object(ZendTestNS\NotUnlikelyCompileError)#%d (%d) { +}