@@ -530,6 +530,12 @@ ZEND_API bool zend_is_compiling(void) /* {{{ */
530530}
531531/* }}} */
532532
533+ static bool zend_is_constructor (const zend_string * name ) /* {{{ */
534+ {
535+ return zend_string_equals_literal_ci (name , ZEND_CONSTRUCTOR_FUNC_NAME );
536+ }
537+ /* }}} */
538+
533539static zend_always_inline uint32_t get_temporary_variable (void ) /* {{{ */
534540{
535541 return (uint32_t )CG (active_op_array )-> T ++ ;
@@ -5549,12 +5555,6 @@ static void zend_compile_method_call(znode *result, zend_ast *ast, uint32_t type
55495555}
55505556/* }}} */
55515557
5552- static bool zend_is_constructor (const zend_string * name ) /* {{{ */
5553- {
5554- return zend_string_equals_literal_ci (name , ZEND_CONSTRUCTOR_FUNC_NAME );
5555- }
5556- /* }}} */
5557-
55585558static bool is_func_accessible (const zend_function * fbc )
55595559{
55605560 if ((fbc -> common .fn_flags & ZEND_ACC_PUBLIC ) || fbc -> common .scope == CG (active_class_entry )) {
@@ -5993,6 +5993,16 @@ static void zend_compile_return(const zend_ast *ast) /* {{{ */
59935993 zend_compile_expr (& expr_node , expr_ast );
59945994 }
59955995
5996+ if (expr_ast ) {
5997+ if (CG (active_class_entry ) != NULL ) {
5998+ if (zend_is_constructor (CG (active_op_array )-> function_name )) {
5999+ zend_error (E_DEPRECATED , "Returning a value from a constructor is deprecated" );
6000+ } else if (zend_string_equals_literal_ci (CG (active_op_array )-> function_name , ZEND_DESTRUCTOR_FUNC_NAME )) {
6001+ zend_error (E_DEPRECATED , "Returning a value from a destructor is deprecated" );
6002+ }
6003+ }
6004+ }
6005+
59966006 if ((CG (active_op_array )-> fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK )
59976007 && (expr_node .op_type == IS_CV || (by_ref && expr_node .op_type == IS_VAR ))
59986008 && zend_has_finally ()) {
0 commit comments