Skip to content

Commit 084d49a

Browse files
committed
Set UNION bit for internal class union return type
Fixes assertion failure reported in: php#7115 (comment)
1 parent a4db743 commit 084d49a

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

Zend/zend_API.c

+1
Original file line numberDiff line numberDiff line change
@@ -2806,6 +2806,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
28062806
zend_type_list *list = malloc(ZEND_TYPE_LIST_SIZE(num_types));
28072807
list->num_types = num_types;
28082808
ZEND_TYPE_SET_LIST(new_arg_info[i].type, list);
2809+
ZEND_TYPE_FULL_MASK(new_arg_info[i].type) |= _ZEND_TYPE_UNION_BIT;
28092810

28102811
const char *start = class_name;
28112812
uint32_t j = 0;

ext/reflection/tests/ReflectionMethod_tentative_return_type.phpt

+25-18
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,24 @@ class MyDateTimeZone extends DateTimeZone
1212
}
1313
}
1414

15-
$methodInfo = new ReflectionMethod(DateTimeZone::class, 'listIdentifiers');
16-
17-
var_dump($methodInfo->hasReturnType());
18-
var_dump($methodInfo->hasTentativeReturnType());
19-
var_dump($methodInfo->getReturnType());
20-
var_dump((string) $methodInfo->getTentativeReturnType());
21-
var_dump((string) $methodInfo);
22-
echo "\n";
23-
24-
$methodInfo = new ReflectionMethod(MyDateTimeZone::class, 'listIdentifiers');
15+
function printInfo(ReflectionMethod $methodInfo) {
16+
var_dump($methodInfo->hasReturnType());
17+
var_dump($methodInfo->hasTentativeReturnType());
18+
var_dump((string) $methodInfo->getReturnType());
19+
var_dump((string) $methodInfo->getTentativeReturnType());
20+
var_dump((string) $methodInfo);
21+
echo "\n";
22+
}
2523

26-
var_dump($methodInfo->hasReturnType());
27-
var_dump($methodInfo->hasTentativeReturnType());
28-
var_dump((string) $methodInfo->getReturnType());
29-
var_dump($methodInfo->getTentativeReturnType());
30-
var_dump((string) $methodInfo);
31-
echo "\n";
24+
printInfo(new ReflectionMethod(DateTimeZone::class, 'listIdentifiers'));
25+
printInfo(new ReflectionMethod(MyDateTimeZone::class, 'listIdentifiers'));
26+
printInfo(new ReflectionMethod(FileSystemIterator::class, 'current'));
3227

3328
?>
3429
--EXPECTF--
3530
bool(false)
3631
bool(true)
37-
NULL
32+
string(0) ""
3833
string(5) "array"
3934
string(%d) "Method [ <internal:date> static public method listIdentifiers ] {
4035

@@ -49,7 +44,7 @@ string(%d) "Method [ <internal:date> static public method listIdentifiers ] {
4944
bool(true)
5045
bool(false)
5146
string(6) "string"
52-
NULL
47+
string(0) ""
5348
string(%d) "Method [ <user, overwrites DateTimeZone, prototype DateTimeZone> static public method listIdentifiers ] {
5449
@@ %s
5550

@@ -60,3 +55,15 @@ string(%d) "Method [ <user, overwrites DateTimeZone, prototype DateTimeZone> sta
6055
- Return [ string ]
6156
}
6257
"
58+
59+
bool(false)
60+
bool(true)
61+
string(0) ""
62+
string(37) "SplFileInfo|FilesystemIterator|string"
63+
string(191) "Method [ <internal:SPL, overwrites DirectoryIterator, prototype Iterator> public method current ] {
64+
65+
- Parameters [0] {
66+
}
67+
- Tentative return [ SplFileInfo|FilesystemIterator|string ]
68+
}
69+
"

0 commit comments

Comments
 (0)