@@ -2049,6 +2049,15 @@ static void zend_check_magic_method_static(
2049
2049
}
2050
2050
}
2051
2051
2052
+ static void zend_check_magic_method_no_return_type (
2053
+ const char * name , const zend_class_entry * ce , const zend_function * fptr , int error_type )
2054
+ {
2055
+ if (fptr -> common .fn_flags & ZEND_ACC_HAS_RETURN_TYPE ) {
2056
+ zend_error_noreturn (error_type , "Method %s::%s() cannot declare a return type" ,
2057
+ ZSTR_VAL (ce -> name ), name );
2058
+ }
2059
+ }
2060
+
2052
2061
ZEND_API void zend_check_magic_method_implementation (const zend_class_entry * ce , const zend_function * fptr , zend_string * lcname , int error_type ) /* {{{ */
2053
2062
{
2054
2063
if (ZSTR_VAL (fptr -> common .function_name )[0 ] != '_'
@@ -2058,12 +2067,15 @@ ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce,
2058
2067
2059
2068
if (zend_string_equals_literal (lcname , ZEND_CONSTRUCTOR_FUNC_NAME )) {
2060
2069
zend_check_magic_method_non_static ("__construct" , ce , fptr , error_type );
2070
+ zend_check_magic_method_no_return_type ("__construct" , ce , fptr , error_type );
2061
2071
} else if (zend_string_equals_literal (lcname , ZEND_DESTRUCTOR_FUNC_NAME )) {
2062
2072
zend_check_magic_method_args (0 , "__destruct" , ce , fptr , error_type );
2063
2073
zend_check_magic_method_non_static ("__destruct" , ce , fptr , error_type );
2074
+ zend_check_magic_method_no_return_type ("__destruct" , ce , fptr , error_type );
2064
2075
} else if (zend_string_equals_literal (lcname , ZEND_CLONE_FUNC_NAME )) {
2065
2076
zend_check_magic_method_args (0 , "__clone" , ce , fptr , error_type );
2066
2077
zend_check_magic_method_non_static ("__clone" , ce , fptr , error_type );
2078
+ zend_check_magic_method_no_return_type ("__clone" , ce , fptr , error_type );
2067
2079
} else if (zend_string_equals_literal (lcname , ZEND_GET_FUNC_NAME )) {
2068
2080
zend_check_magic_method_args (1 , "__get" , ce , fptr , error_type );
2069
2081
zend_check_magic_method_non_static ("__get" , ce , fptr , error_type );
@@ -2359,17 +2371,6 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
2359
2371
if (ctor ) {
2360
2372
ctor -> common .fn_flags |= ZEND_ACC_CTOR ;
2361
2373
}
2362
- if (ctor && (ctor -> common .fn_flags & ZEND_ACC_HAS_RETURN_TYPE )) {
2363
- zend_error_noreturn (E_CORE_ERROR , "Constructor %s::%s() cannot declare a return type" , ZSTR_VAL (scope -> name ), ZSTR_VAL (ctor -> common .function_name ));
2364
- }
2365
-
2366
- if (dtor && (dtor -> common .fn_flags & ZEND_ACC_HAS_RETURN_TYPE )) {
2367
- zend_error_noreturn (E_CORE_ERROR , "Destructor %s::%s() cannot declare a return type" , ZSTR_VAL (scope -> name ), ZSTR_VAL (dtor -> common .function_name ));
2368
- }
2369
-
2370
- if (clone && (clone -> common .fn_flags & ZEND_ACC_HAS_RETURN_TYPE )) {
2371
- zend_error_noreturn (E_CORE_ERROR , "%s::%s() cannot declare a return type" , ZSTR_VAL (scope -> name ), ZSTR_VAL (clone -> common .function_name ));
2372
- }
2373
2374
efree ((char * )lc_class_name );
2374
2375
}
2375
2376
return SUCCESS ;
0 commit comments