]> granicus.if.org Git - php/commitdiff
Remove unnecessary type checks in verify_missing_return_type
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 24 Oct 2019 13:52:06 +0000 (15:52 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 24 Oct 2019 13:52:06 +0000 (15:52 +0200)
We don't emit VERIFY_RETURN_TYPE for void functions, so there's
no need to check it here. It's always an error.

Zend/zend_execute.c

index 5ace501cce1c2db6f0b4a12e52e6e0a73316abdf..7544742cd765ce21a80488eed10d61b22fa8c6ee 100644 (file)
@@ -1211,24 +1211,20 @@ static zend_always_inline void zend_verify_return_type(zend_function *zf, zval *
 
 static ZEND_COLD int zend_verify_missing_return_type(const zend_function *zf, void **cache_slot)
 {
+       /* VERIFY_RETURN_TYPE is not emitted for "void" functions, so this is always an error. */
        zend_arg_info *ret_info = zf->common.arg_info - 1;
 
-       if (ZEND_TYPE_IS_SET(ret_info->type)
-                       && (!ZEND_TYPE_IS_MASK(ret_info->type)
-                               || !(ZEND_TYPE_MASK(ret_info->type) & MAY_BE_VOID))) {
-               // TODO: Eliminate this!
-               if (ZEND_TYPE_IS_CLASS(ret_info->type)) {
-                       if (UNEXPECTED(!*cache_slot)) {
-                               zend_class_entry *ce = zend_fetch_class(ZEND_TYPE_NAME(ret_info->type), (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
-                               if (ce) {
-                                       *cache_slot = (void *) ce;
-                               }
+       // TODO: Eliminate this!
+       if (ZEND_TYPE_IS_CLASS(ret_info->type)) {
+               if (UNEXPECTED(!*cache_slot)) {
+                       zend_class_entry *ce = zend_fetch_class(ZEND_TYPE_NAME(ret_info->type), (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
+                       if (ce) {
+                               *cache_slot = (void *) ce;
                        }
                }
-               zend_verify_return_error(zf, cache_slot, NULL);
-               return 0;
        }
-       return 1;
+       zend_verify_return_error(zf, cache_slot, NULL);
+       return 0;
 }
 
 static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(void)