Set UNION bit for internal class union return type

Fixes assertion failure reported in:
https://github.com/php/php-src/pull/7115#issuecomment-882580767
This commit is contained in:
Nikita Popov 2021-07-19 16:24:19 +02:00
parent a4db74364d
commit 084d49a262
2 changed files with 26 additions and 18 deletions

View file

@ -2806,6 +2806,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
zend_type_list *list = malloc(ZEND_TYPE_LIST_SIZE(num_types)); zend_type_list *list = malloc(ZEND_TYPE_LIST_SIZE(num_types));
list->num_types = num_types; list->num_types = num_types;
ZEND_TYPE_SET_LIST(new_arg_info[i].type, list); ZEND_TYPE_SET_LIST(new_arg_info[i].type, list);
ZEND_TYPE_FULL_MASK(new_arg_info[i].type) |= _ZEND_TYPE_UNION_BIT;
const char *start = class_name; const char *start = class_name;
uint32_t j = 0; uint32_t j = 0;

View file

@ -12,29 +12,24 @@ class MyDateTimeZone extends DateTimeZone
} }
} }
$methodInfo = new ReflectionMethod(DateTimeZone::class, 'listIdentifiers'); function printInfo(ReflectionMethod $methodInfo) {
var_dump($methodInfo->hasReturnType());
var_dump($methodInfo->hasTentativeReturnType());
var_dump((string) $methodInfo->getReturnType());
var_dump((string) $methodInfo->getTentativeReturnType());
var_dump((string) $methodInfo);
echo "\n";
}
var_dump($methodInfo->hasReturnType()); printInfo(new ReflectionMethod(DateTimeZone::class, 'listIdentifiers'));
var_dump($methodInfo->hasTentativeReturnType()); printInfo(new ReflectionMethod(MyDateTimeZone::class, 'listIdentifiers'));
var_dump($methodInfo->getReturnType()); printInfo(new ReflectionMethod(FileSystemIterator::class, 'current'));
var_dump((string) $methodInfo->getTentativeReturnType());
var_dump((string) $methodInfo);
echo "\n";
$methodInfo = new ReflectionMethod(MyDateTimeZone::class, 'listIdentifiers');
var_dump($methodInfo->hasReturnType());
var_dump($methodInfo->hasTentativeReturnType());
var_dump((string) $methodInfo->getReturnType());
var_dump($methodInfo->getTentativeReturnType());
var_dump((string) $methodInfo);
echo "\n";
?> ?>
--EXPECTF-- --EXPECTF--
bool(false) bool(false)
bool(true) bool(true)
NULL string(0) ""
string(5) "array" string(5) "array"
string(%d) "Method [ <internal:date> static public method listIdentifiers ] { string(%d) "Method [ <internal:date> static public method listIdentifiers ] {
@ -49,7 +44,7 @@ string(%d) "Method [ <internal:date> static public method listIdentifiers ] {
bool(true) bool(true)
bool(false) bool(false)
string(6) "string" string(6) "string"
NULL string(0) ""
string(%d) "Method [ <user, overwrites DateTimeZone, prototype DateTimeZone> static public method listIdentifiers ] { string(%d) "Method [ <user, overwrites DateTimeZone, prototype DateTimeZone> static public method listIdentifiers ] {
@@ %s @@ %s
@ -60,3 +55,15 @@ string(%d) "Method [ <user, overwrites DateTimeZone, prototype DateTimeZone> sta
- Return [ string ] - Return [ string ]
} }
" "
bool(false)
bool(true)
string(0) ""
string(37) "SplFileInfo|FilesystemIterator|string"
string(191) "Method [ <internal:SPL, overwrites DirectoryIterator, prototype Iterator> public method current ] {
- Parameters [0] {
}
- Tentative return [ SplFileInfo|FilesystemIterator|string ]
}
"