@@ -961,6 +961,10 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
961
961
}
962
962
/* }}} */
963
963
964
+ static zend_always_inline zend_string * func_filename (const zend_function * fn ) {
965
+ return fn -> common .type == ZEND_USER_FUNCTION ? fn -> op_array .filename : NULL ;
966
+ }
967
+
964
968
static zend_always_inline uint32_t func_lineno (const zend_function * fn ) {
965
969
return fn -> common .type == ZEND_USER_FUNCTION ? fn -> op_array .line_start : 0 ;
966
970
}
@@ -979,7 +983,7 @@ static void ZEND_COLD emit_incompatible_method_error(
979
983
} ZEND_HASH_FOREACH_END ();
980
984
ZEND_ASSERT (unresolved_class );
981
985
982
- zend_error_at (E_COMPILE_ERROR , NULL , func_lineno (child ),
986
+ zend_error_at (E_COMPILE_ERROR , func_filename ( child ) , func_lineno (child ),
983
987
"Could not check compatibility between %s and %s, because class %s is not available" ,
984
988
ZSTR_VAL (child_prototype ), ZSTR_VAL (parent_prototype ), ZSTR_VAL (unresolved_class ));
985
989
} else if (status == INHERITANCE_WARNING ) {
@@ -990,7 +994,7 @@ static void ZEND_COLD emit_incompatible_method_error(
990
994
);
991
995
992
996
if (!return_type_will_change_attribute ) {
993
- zend_error_at (E_DEPRECATED , NULL , func_lineno (child ),
997
+ zend_error_at (E_DEPRECATED , func_filename ( child ) , func_lineno (child ),
994
998
"Return type of %s should either be compatible with %s, "
995
999
"or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice" ,
996
1000
ZSTR_VAL (child_prototype ), ZSTR_VAL (parent_prototype ));
@@ -1000,7 +1004,7 @@ static void ZEND_COLD emit_incompatible_method_error(
1000
1004
}
1001
1005
}
1002
1006
} else {
1003
- zend_error_at (E_COMPILE_ERROR , NULL , func_lineno (child ),
1007
+ zend_error_at (E_COMPILE_ERROR , func_filename ( child ) , func_lineno (child ),
1004
1008
"Declaration of %s must be compatible with %s" ,
1005
1009
ZSTR_VAL (child_prototype ), ZSTR_VAL (parent_prototype ));
1006
1010
}
@@ -1047,7 +1051,7 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(
1047
1051
if (check_only ) {
1048
1052
return INHERITANCE_ERROR ;
1049
1053
}
1050
- zend_error_at_noreturn (E_COMPILE_ERROR , NULL , func_lineno (child ),
1054
+ zend_error_at_noreturn (E_COMPILE_ERROR , func_filename ( child ) , func_lineno (child ),
1051
1055
"Cannot override final method %s::%s()" ,
1052
1056
ZEND_FN_SCOPE_NAME (parent ), ZSTR_VAL (child -> common .function_name ));
1053
1057
}
@@ -1060,11 +1064,11 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(
1060
1064
return INHERITANCE_ERROR ;
1061
1065
}
1062
1066
if (child_flags & ZEND_ACC_STATIC ) {
1063
- zend_error_at_noreturn (E_COMPILE_ERROR , NULL , func_lineno (child ),
1067
+ zend_error_at_noreturn (E_COMPILE_ERROR , func_filename ( child ) , func_lineno (child ),
1064
1068
"Cannot make non static method %s::%s() static in class %s" ,
1065
1069
ZEND_FN_SCOPE_NAME (parent ), ZSTR_VAL (child -> common .function_name ), ZEND_FN_SCOPE_NAME (child ));
1066
1070
} else {
1067
- zend_error_at_noreturn (E_COMPILE_ERROR , NULL , func_lineno (child ),
1071
+ zend_error_at_noreturn (E_COMPILE_ERROR , func_filename ( child ) , func_lineno (child ),
1068
1072
"Cannot make static method %s::%s() non static in class %s" ,
1069
1073
ZEND_FN_SCOPE_NAME (parent ), ZSTR_VAL (child -> common .function_name ), ZEND_FN_SCOPE_NAME (child ));
1070
1074
}
@@ -1075,7 +1079,7 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(
1075
1079
if (check_only ) {
1076
1080
return INHERITANCE_ERROR ;
1077
1081
}
1078
- zend_error_at_noreturn (E_COMPILE_ERROR , NULL , func_lineno (child ),
1082
+ zend_error_at_noreturn (E_COMPILE_ERROR , func_filename ( child ) , func_lineno (child ),
1079
1083
"Cannot make non abstract method %s::%s() abstract in class %s" ,
1080
1084
ZEND_FN_SCOPE_NAME (parent ), ZSTR_VAL (child -> common .function_name ), ZEND_FN_SCOPE_NAME (child ));
1081
1085
}
@@ -1119,7 +1123,7 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(
1119
1123
if (check_only ) {
1120
1124
return INHERITANCE_ERROR ;
1121
1125
}
1122
- zend_error_at_noreturn (E_COMPILE_ERROR , NULL , func_lineno (child ),
1126
+ zend_error_at_noreturn (E_COMPILE_ERROR , func_filename ( child ) , func_lineno (child ),
1123
1127
"Access level to %s::%s() must be %s (as in class %s)%s" ,
1124
1128
ZEND_FN_SCOPE_NAME (child ), ZSTR_VAL (child -> common .function_name ), zend_visibility_string (parent_flags ), ZEND_FN_SCOPE_NAME (parent ), (parent_flags & ZEND_ACC_PUBLIC ) ? "" : " or weaker" );
1125
1129
}
0 commit comments