mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Improve interface non-public method error message
Currently interface methods with visibility `private` or `protected` fail with an error message: Access type for interface method A::b() must be omitted However, explicitly setting visibility `public` is allowed and often desired. This commit updates the error message to: Access type for interface method A::b() must be public
This commit is contained in:
parent
467801d7bb
commit
a706d7302a
4 changed files with 4 additions and 4 deletions
|
@ -9,4 +9,4 @@ interface test {
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Access type for interface method test::test() must be omitted in %s on line %d
|
||||
Fatal error: Access type for interface method test::test() must be public in %s on line %d
|
||||
|
|
|
@ -9,4 +9,4 @@ interface test {
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Access type for interface method test::test() must be omitted in %s on line %d
|
||||
Fatal error: Access type for interface method test::test() must be public in %s on line %d
|
||||
|
|
|
@ -6945,7 +6945,7 @@ zend_string *zend_begin_method_decl(zend_op_array *op_array, zend_string *name,
|
|||
if (in_interface) {
|
||||
if (!(fn_flags & ZEND_ACC_PUBLIC) || (fn_flags & (ZEND_ACC_FINAL|ZEND_ACC_ABSTRACT))) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Access type for interface method "
|
||||
"%s::%s() must be omitted", ZSTR_VAL(ce->name), ZSTR_VAL(name));
|
||||
"%s::%s() must be public", ZSTR_VAL(ce->name), ZSTR_VAL(name));
|
||||
}
|
||||
op_array->fn_flags |= ZEND_ACC_ABSTRACT;
|
||||
}
|
||||
|
|
|
@ -9,4 +9,4 @@ interface if_a {
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Access type for interface method if_a::err() must be omitted in %s on line %d
|
||||
Fatal error: Access type for interface method if_a::err() must be public in %s on line %d
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue