tests: do not depend on ctype
[awesomized/ext-ion] / gen_stub.php.diff
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 {
6 }
7
8 public function getDeclarationName(): string {
9 - return $this->name->getLast();
10 + return strtr($this->name->toString(), "\\", "_");
11 }
12
13 public function getDeclaration(): string {
14 @@ -1152,8 +1152,8 @@ class FuncInfo {
15 if ($namespace) {
16 // Render A\B as "A\\B" in C strings for namespaces
17 return sprintf(
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());
22 } else {
23 return sprintf("\tZEND_FE(%s, %s)\n", $declarationName, $this->getArgInfoName());
24 }
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";
31 } else {
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(
36 Name $class,
37 int $flags,
38 - Stmt\PropertyProperty $property,
39 + Stmt\PropertyProperty|Node\Param $property,
40 ?Node $type,
41 ?DocComment $comment,
42 PrettyPrinterAbstract $prettyPrinter
43 @@ -2404,13 +2404,23 @@ function parseProperty(
44 }
45 }
46
47 + $default = $property->default;
48 + if ($property instanceof Node\Param) {
49 + $name = $property->var->name;
50 + if ($property->flags & Stmt\Class_::MODIFIER_READONLY) {
51 + $default = null;
52 + }
53 + } else {
54 + $name = $property->name;
55 + }
56 +
57 return new PropertyInfo(
58 - new PropertyName($class, $property->name->__toString()),
59 + new PropertyName($class, (string) $name),
60 $flags,
61 $propertyType,
62 $phpDocType ? Type::fromString($phpDocType) : null,
63 - $property->default,
64 - $property->default ? $prettyPrinter->prettyPrintExpr($property->default) : null,
65 + $default,
66 + $default ? $prettyPrinter->prettyPrintExpr($default) : null,
67 $isDocReadonly
68 );
69 }
70 @@ -2594,6 +2604,20 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
71 $classStmt,
72 $cond
73 );
74 + if ($classStmt->name->toString() === "__construct") {
75 + foreach ($classStmt->params as $param) {
76 + if ($param->flags) {
77 + $propertyInfos[] = parseProperty(
78 + $className,
79 + $param->flags,
80 + $param,
81 + $param->type,
82 + $param->getDocComment(),
83 + $prettyPrinter
84 + );
85 + }
86 + }
87 + }
88 } else if ($classStmt instanceof Stmt\EnumCase) {
89 $enumCaseInfos[] = new EnumCaseInfo(
90 $classStmt->name->toString(), $classStmt->expr);