Skip to content

Commit d71a6ee

Browse files
committed
Remove unnecessary type checks in verify_missing_return_type
We don't emit VERIFY_RETURN_TYPE for void functions, so there's no need to check it here. It's always an error.
1 parent 9666d7a commit d71a6ee

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

Zend/zend_execute.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,24 +1211,20 @@ static zend_always_inline void zend_verify_return_type(zend_function *zf, zval *
12111211

12121212
static ZEND_COLD int zend_verify_missing_return_type(const zend_function *zf, void **cache_slot)
12131213
{
1214+
/* VERIFY_RETURN_TYPE is not emitted for "void" functions, so this is always an error. */
12141215
zend_arg_info *ret_info = zf->common.arg_info - 1;
12151216

1216-
if (ZEND_TYPE_IS_SET(ret_info->type)
1217-
&& (!ZEND_TYPE_IS_MASK(ret_info->type)
1218-
|| !(ZEND_TYPE_MASK(ret_info->type) & MAY_BE_VOID))) {
1219-
// TODO: Eliminate this!
1220-
if (ZEND_TYPE_IS_CLASS(ret_info->type)) {
1221-
if (UNEXPECTED(!*cache_slot)) {
1222-
zend_class_entry *ce = zend_fetch_class(ZEND_TYPE_NAME(ret_info->type), (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
1223-
if (ce) {
1224-
*cache_slot = (void *) ce;
1225-
}
1217+
// TODO: Eliminate this!
1218+
if (ZEND_TYPE_IS_CLASS(ret_info->type)) {
1219+
if (UNEXPECTED(!*cache_slot)) {
1220+
zend_class_entry *ce = zend_fetch_class(ZEND_TYPE_NAME(ret_info->type), (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
1221+
if (ce) {
1222+
*cache_slot = (void *) ce;
12261223
}
12271224
}
1228-
zend_verify_return_error(zf, cache_slot, NULL);
1229-
return 0;
12301225
}
1231-
return 1;
1226+
zend_verify_return_error(zf, cache_slot, NULL);
1227+
return 0;
12321228
}
12331229

12341230
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(void)

0 commit comments

Comments
 (0)