Skip to content

Commit 9044a89

Browse files
committed
Properly render 2+ namespaces functions in build/gen_stub.php
Affects both INIT_NS_CLASS_ENTRY and ZEND_NS_FE
1 parent 286f638 commit 9044a89

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

build/gen_stub.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,10 @@ public function getFunctionEntry(): string {
818818
}
819819

820820
if ($namespace) {
821+
// Render A\B as "A\\B" in C strings for namespaces
821822
return sprintf(
822823
"\tZEND_NS_FE(\"%s\", %s, %s)\n",
823-
$namespace, $declarationName, $this->getArgInfoName());
824+
addslashes($namespace), $declarationName, $this->getArgInfoName());
824825
} else {
825826
return sprintf("\tZEND_FE(%s, %s)\n", $declarationName, $this->getArgInfoName());
826827
}
@@ -1222,7 +1223,7 @@ public function getRegistration(): string
12221223
$code .= "\tzend_class_entry ce, *class_entry;\n\n";
12231224
if (count($this->name->parts) > 1) {
12241225
$className = $this->name->getLast();
1225-
$namespace = $this->name->slice(0, -1);
1226+
$namespace = addslashes($this->name->slice(0, -1));
12261227

12271228
$code .= "\tINIT_NS_CLASS_ENTRY(ce, \"$namespace\", \"$className\", class_{$escapedName}_methods);\n";
12281229
} else {

0 commit comments

Comments
 (0)