1 diff --git a/build/gen_stub.php b/build/gen_stub.php
2 index 5f74d26dbc3..01a19988161 100755
3 --- a/build/gen_stub.php
4 +++ b/build/gen_stub.php
5 @@ -793,7 +793,7 @@ class FunctionName implements FunctionOrMethodName {
8 public function getDeclarationName(): string {
9 - return $this->name->getLast();
10 + return strtr($this->name->toString(), "\\", "_");
13 public function getDeclaration(): string {
14 @@ -1152,8 +1152,8 @@ class FuncInfo {
16 // Render A\B as "A\\B" in C strings for namespaces
18 - "\tZEND_NS_FE(\"%s\", %s, %s)\n",
19 - addslashes($namespace), $declarationName, $this->getArgInfoName());
20 + "\tZEND_NS_RAW_FENTRY(\"%s\", \"%s\", ZEND_FN(%s), %s, 0)\n",
21 + addslashes($namespace), substr((string)$this->name, strlen($namespace)+1), $declarationName, $this->getArgInfoName());
23 return sprintf("\tZEND_FE(%s, %s)\n", $declarationName, $this->getArgInfoName());
25 @@ -1608,7 +1608,7 @@ class EnumCaseInfo {
26 public function getDeclaration(): string {
27 $escapedName = addslashes($this->name);
28 if ($this->value === null) {
29 - $code = "\n\tzend_enum_add_case_cstr(class_entry, \"$escapedName\", NULL);\n";
30 + $code = "\tzend_enum_add_case_cstr(class_entry, \"$escapedName\", NULL);\n";
32 $evaluator = new ConstExprEvaluator(function (Expr $expr) {
33 throw new Exception("Enum case $this->name has an unsupported value");
34 @@ -2369,7 +2369,7 @@ function parseFunctionLike(
35 function parseProperty(
38 - Stmt\PropertyProperty $property,
39 + Stmt\PropertyProperty|Node\Param $property,
42 PrettyPrinterAbstract $prettyPrinter
43 @@ -2404,13 +2404,23 @@ function parseProperty(
47 + $default = $property->default;
48 + if ($property instanceof Node\Param) {
49 + $name = $property->var->name;
50 + if ($property->flags & Stmt\Class_::MODIFIER_READONLY) {
54 + $name = $property->name;
57 return new PropertyInfo(
58 - new PropertyName($class, $property->name->__toString()),
59 + new PropertyName($class, (string) $name),
62 $phpDocType ? Type::fromString($phpDocType) : null,
64 - $property->default ? $prettyPrinter->prettyPrintExpr($property->default) : null,
66 + $default ? $prettyPrinter->prettyPrintExpr($default) : null,
70 @@ -2594,6 +2604,20 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
74 + if ($classStmt->name->toString() === "__construct") {
75 + foreach ($classStmt->params as $param) {
76 + if ($param->flags) {
77 + $propertyInfos[] = parseProperty(
82 + $param->getDocComment(),
88 } else if ($classStmt instanceof Stmt\EnumCase) {
89 $enumCaseInfos[] = new EnumCaseInfo(
90 $classStmt->name->toString(), $classStmt->expr);