From 7f0d2574f0172068ac6907d0d21f815a41da3388 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 3 Sep 2024 12:18:07 +0200 Subject: [PATCH] Simplify a-vis error message --- Zend/tests/asymmetric_visibility/virtual_get_only.phpt | 2 +- Zend/tests/asymmetric_visibility/virtual_set_only.phpt | 2 +- Zend/zend_inheritance.c | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Zend/tests/asymmetric_visibility/virtual_get_only.phpt b/Zend/tests/asymmetric_visibility/virtual_get_only.phpt index 53a293b021a..3eaada70329 100644 --- a/Zend/tests/asymmetric_visibility/virtual_get_only.phpt +++ b/Zend/tests/asymmetric_visibility/virtual_get_only.phpt @@ -11,4 +11,4 @@ class Foo { ?> --EXPECTF-- -Fatal error: Unilateral virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d +Fatal error: Read-only virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d diff --git a/Zend/tests/asymmetric_visibility/virtual_set_only.phpt b/Zend/tests/asymmetric_visibility/virtual_set_only.phpt index a9618cb65c2..18abb7ac046 100644 --- a/Zend/tests/asymmetric_visibility/virtual_set_only.phpt +++ b/Zend/tests/asymmetric_visibility/virtual_set_only.phpt @@ -11,4 +11,4 @@ class Foo { ?> --EXPECTF-- -Fatal error: Unilateral virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d +Fatal error: Write-only virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index e3de40778cb..732eb141eb2 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1709,8 +1709,11 @@ ZEND_API void zend_verify_hooked_property(zend_class_entry *ce, zend_property_in if ((prop_info->flags & ZEND_ACC_VIRTUAL) && (prop_info->flags & ZEND_ACC_PPP_SET_MASK) && (!prop_info->hooks[ZEND_PROPERTY_HOOK_GET] || !prop_info->hooks[ZEND_PROPERTY_HOOK_SET])) { + const char *prefix = !prop_info->hooks[ZEND_PROPERTY_HOOK_GET] + ? "Write-only" : "Read-only"; zend_error_noreturn(E_COMPILE_ERROR, - "Unilateral virtual property %s::$%s must not specify asymmetric visibility", ZSTR_VAL(ce->name), ZSTR_VAL(prop_name)); + "%s virtual property %s::$%s must not specify asymmetric visibility", + prefix, ZSTR_VAL(ce->name), ZSTR_VAL(prop_name)); } }