1 diff --git a/build/gen_stub.php b/build/gen_stub.php
2 index 486ff67949..71265c12fa 100755
3 --- a/build/gen_stub.php
4 +++ b/build/gen_stub.php
5 @@ -733,10 +733,6 @@ class ArgInfo {
7 private function setTypes(?Type $type, ?Type $phpDocType): void
9 - if ($phpDocType !== null && Type::equals($type, $phpDocType)) {
10 - throw new Exception('PHPDoc param type "' . $phpDocType->__toString() . '" is unnecessary');
14 $this->phpDocType = $phpDocType;
16 @@ -793,7 +789,7 @@ class FunctionName implements FunctionOrMethodName {
19 public function getDeclarationName(): string {
20 - return $this->name->getLast();
21 + return strtr($this->name->toString(), "\\", "_");
24 public function getDeclaration(): string {
25 @@ -910,10 +906,6 @@ class ReturnInfo {
27 private function setTypes(?Type $type, ?Type $phpDocType, bool $tentativeReturnType): void
29 - if ($phpDocType !== null && Type::equals($type, $phpDocType)) {
30 - throw new Exception('PHPDoc return type "' . $phpDocType->__toString() . '" is unnecessary');
34 $this->phpDocType = $phpDocType;
35 $this->tentativeReturnType = $tentativeReturnType;
36 @@ -1152,8 +1144,8 @@ class FuncInfo {
38 // Render A\B as "A\\B" in C strings for namespaces
40 - "\tZEND_NS_FE(\"%s\", %s, %s)\n",
41 - addslashes($namespace), $declarationName, $this->getArgInfoName());
42 + "\tZEND_NS_RAW_FENTRY(\"%s\", \"%s\", ZEND_FN(%s), %s, 0)\n",
43 + addslashes($namespace), substr((string)$this->name, strlen($namespace)+1), $declarationName, $this->getArgInfoName());
45 return sprintf("\tZEND_FE(%s, %s)\n", $declarationName, $this->getArgInfoName());
47 @@ -1616,7 +1608,7 @@ class EnumCaseInfo {
48 public function getDeclaration(): string {
49 $escapedName = addslashes($this->name);
50 if ($this->value === null) {
51 - $code = "\n\tzend_enum_add_case_cstr(class_entry, \"$escapedName\", NULL);\n";
52 + $code = "\tzend_enum_add_case_cstr(class_entry, \"$escapedName\", NULL);\n";
54 $evaluator = new ConstExprEvaluator(function (Expr $expr) {
55 throw new Exception("Enum case $this->name has an unsupported value");
56 @@ -2373,7 +2365,7 @@ function parseFunctionLike(
57 function parseProperty(
60 - Stmt\PropertyProperty $property,
61 + Stmt\PropertyProperty|Node\Param $property,
64 PrettyPrinterAbstract $prettyPrinter
65 @@ -2411,13 +2403,23 @@ function parseProperty(
69 + $default = $property->default;
70 + if ($property instanceof Node\Param) {
71 + $name = $property->var->name;
72 + if ($property->flags & Stmt\Class_::MODIFIER_READONLY) {
76 + $name = $property->name;
79 return new PropertyInfo(
80 - new PropertyName($class, $property->name->__toString()),
81 + new PropertyName($class, (string) $name),
84 $phpDocType ? Type::fromString($phpDocType) : null,
86 - $property->default ? $prettyPrinter->prettyPrintExpr($property->default) : null,
88 + $default ? $prettyPrinter->prettyPrintExpr($default) : null,
92 @@ -2602,6 +2604,20 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
96 + if ($classStmt->name->toString() === "__construct") {
97 + foreach ($classStmt->params as $param) {
98 + if ($param->flags) {
99 + $propertyInfos[] = parseProperty(
104 + $param->getDocComment(),
110 } else if ($classStmt instanceof Stmt\EnumCase) {
111 $enumCaseInfos[] = new EnumCaseInfo(
112 $classStmt->name->toString(), $classStmt->expr);
113 @@ -2829,7 +2845,9 @@ function generateArgInfoCode(FileInfo $fileInfo, string $stubHash): string {
116 $generatedFunctionDeclarations[$key] = true;
117 - return $fileInfo->declarationPrefix . $funcInfo->getDeclaration();
118 + if ($decl = $funcInfo->getDeclaration()) {
119 + return $fileInfo->declarationPrefix . $decl;
124 @@ -3275,7 +3293,7 @@ function initPhpParser() {
127 $isInitialized = true;
128 - $version = "4.13.0";
129 + $version = "4.13.2";
130 $phpParserDir = __DIR__ . "/PHP-Parser-$version";
131 if (!is_dir($phpParserDir)) {
132 installPhpParser($version, $phpParserDir);