Skip to content

Commit ca7d0e0

Browse files
committed
Rebase fixup
RepresentableType has been replaced by ArginfoType. This is only a partial fix, in that we still need to handle class union types.
1 parent 56ac2b3 commit ca7d0e0

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

build/gen_stub.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,21 +1033,16 @@ function (Expr $expr) use (&$defaultValueConstant) {
10331033
}
10341034

10351035
if ($this->type) {
1036-
$typeFlags = $this->type->tryToRepresentableType();
1037-
if ($typeFlags === null) {
1038-
echo "Skipping code generation for property $this->name, because it has an unimplemented type\n";
1039-
return "";
1040-
}
1041-
1042-
if ($typeFlags->classType) {
1036+
$arginfoType = $this->type->toArginfoType();
1037+
if ($arginfoType->hasClassType()) {
10431038
$simpleType = $this->type->tryToSimpleType();
10441039
if ($simpleType) {
1045-
$typeCode = "(zend_type) ZEND_TYPE_INIT_CE(class_entry_" . str_replace("\\", "_", $typeFlags->classType->name) . ", " . ((int) $this->type->isNullable()) . ", 0)";
1040+
$typeCode = "(zend_type) ZEND_TYPE_INIT_CE(class_entry_" . str_replace("\\", "_", $arginfoType->classTypes[0]->name) . ", " . ((int) $this->type->isNullable()) . ", 0)";
10461041
} else {
10471042
throw new Exception("Property $this->name has an unsupported union type");
10481043
}
10491044
} else {
1050-
$typeCode = "(zend_type) ZEND_TYPE_INIT_MASK(" . $typeFlags->toTypeMask() . ")";
1045+
$typeCode = "(zend_type) ZEND_TYPE_INIT_MASK(" . $arginfoType->toTypeMask() . ")";
10511046
}
10521047

10531048
$code .= $this->initializeValue($defaultValueType, $defaultValue);
@@ -1261,9 +1256,9 @@ public function getRegistration(): string
12611256
continue;
12621257
}
12631258

1264-
$representableType = $type->tryToRepresentableType();
1265-
if ($representableType && $representableType->classType) {
1266-
$params[] = "zend_class_entry *class_entry_" . str_replace("\\", "_", $representableType->classType->name);
1259+
$arginfoType = $type->toArginfoType();
1260+
if (count($arginfoType->classTypes) == 1) {
1261+
$params[] = "zend_class_entry *class_entry_" . str_replace("\\", "_", $arginfoType->classTypes[0]->name);
12671262
}
12681263
}
12691264
$params = array_unique($params);

ext/zend_test/test.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class _ZendTestClass implements _ZendTestInterface {
1919

2020
public int $intProp = 123;
2121
public ?stdClass $classProp = null;
22-
public stdClass|Iterator|null $classUnionProp = null;
22+
//public stdClass|Iterator|null $classUnionProp = null;
2323

2424
public static function is_object(): int {}
2525

ext/zend_test/test_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 520097c67aab4b8f2f6c641be4816fb4e06e7e99 */
2+
* Stub hash: 950679cde15789a9060d4798dc35dc5a590fd8b2 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0)
55
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)