Skip to content

Commit 98e8e27

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-12558 Escape \N in generated stubs
2 parents cefe9e4 + d4e40dc commit 98e8e27

File tree

6 files changed

+44
-4
lines changed

6 files changed

+44
-4
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PHP NEWS
1010
property via trait). (ilutov)
1111
. Fixed segfault caused by weak references to FFI objects. (sj-i)
1212
. Fixed max_execution_time: don't delete an unitialized timer. (Kévin Dunglas)
13+
. Fixed bug GH-12558 (Arginfo soft-breaks with namespaced class return type
14+
if the class name starts with N). (kocsismate)
1315

1416
- DOM:
1517
. Fix registerNodeClass with abstract class crashing. (nielsdos)

build/gen_stub.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,10 @@ public function toOptimizerTypeMask(): string {
524524
}
525525

526526
public function toEscapedName(): string {
527-
// Escape backslashes, and also encode \u and \U to avoid compilation errors in generated macros
527+
// Escape backslashes, and also encode \u, \U, and \N to avoid compilation errors in generated macros
528528
return str_replace(
529-
['\\', '\\u', '\\U'],
530-
['\\\\', '\\\\165', '\\\\125'],
529+
['\\', '\\u', '\\U', '\\N'],
530+
['\\\\', '\\\\165', '\\\\125', '\\\\116'],
531531
$this->name
532532
);
533533
}

ext/zend_test/test.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static zend_class_entry *zend_test_class_with_property_attribute;
5757
static zend_class_entry *zend_test_forbid_dynamic_call;
5858
static zend_class_entry *zend_test_ns_foo_class;
5959
static zend_class_entry *zend_test_ns_unlikely_compile_error_class;
60+
static zend_class_entry *zend_test_ns_not_unlikely_compile_error_class;
6061
static zend_class_entry *zend_test_ns2_foo_class;
6162
static zend_class_entry *zend_test_ns2_ns_foo_class;
6263
static zend_class_entry *zend_test_unit_enum;
@@ -796,6 +797,13 @@ static ZEND_METHOD(ZendTestNS_UnlikelyCompileError, method)
796797
RETURN_NULL();
797798
}
798799

800+
static ZEND_METHOD(ZendTestNS_NotUnlikelyCompileError, method)
801+
{
802+
ZEND_PARSE_PARAMETERS_NONE();
803+
804+
RETURN_NULL();
805+
}
806+
799807
static ZEND_METHOD(ZendTestNS2_Foo, method)
800808
{
801809
ZEND_PARSE_PARAMETERS_NONE();
@@ -1050,6 +1058,7 @@ PHP_MINIT_FUNCTION(zend_test)
10501058

10511059
zend_test_ns_foo_class = register_class_ZendTestNS_Foo();
10521060
zend_test_ns_unlikely_compile_error_class = register_class_ZendTestNS_UnlikelyCompileError();
1061+
zend_test_ns_not_unlikely_compile_error_class = register_class_ZendTestNS_NotUnlikelyCompileError();
10531062
zend_test_ns2_foo_class = register_class_ZendTestNS2_Foo();
10541063
zend_test_ns2_ns_foo_class = register_class_ZendTestNS2_ZendSubNS_Foo();
10551064

ext/zend_test/test.stub.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ class UnlikelyCompileError {
254254
public function method(): ?UnlikelyCompileError {}
255255
}
256256

257+
class NotUnlikelyCompileError {
258+
/* This method signature would create a compile error due to the string
259+
* "ZendTestNS\NotUnlikelyCompileError" in the generated macro call */
260+
public function method(): ?NotUnlikelyCompileError {}
261+
}
257262
}
258263

259264
namespace ZendTestNS2 {

ext/zend_test/test_arginfo.h

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zend_test/tests/gen_stub_test_01.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ $foo->foo = new \ZendTestNS2\ZendSubNS\Foo();
1111
var_dump($foo);
1212
$foo = new \ZendTestNS\UnlikelyCompileError();
1313
var_dump($foo);
14+
$foo = new \ZendTestNS\NotUnlikelyCompileError();
15+
var_dump($foo);
1416
?>
1517
--EXPECTF--
1618
object(ZendTestNS2\Foo)#%d (%d) {
@@ -24,3 +26,5 @@ object(ZendTestNS2\Foo)#%d (%d) {
2426
}
2527
object(ZendTestNS\UnlikelyCompileError)#%d (%d) {
2628
}
29+
object(ZendTestNS\NotUnlikelyCompileError)#%d (%d) {
30+
}

0 commit comments

Comments
 (0)