mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Tweak get/set-only hook error messages
Fixes GH-19845 Closes GH-19916
This commit is contained in:
@@ -11,4 +11,4 @@ class Foo {
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Fatal error: Read-only virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d
|
Fatal error: get-only virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ class Foo {
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Fatal error: Write-only virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d
|
Fatal error: set-only virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d
|
||||||
|
|||||||
@@ -27,4 +27,4 @@ try {
|
|||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
bool(true)
|
bool(true)
|
||||||
Property C::$x is read-only
|
Cannot write to get-only virtual property C::$x
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ $foo->bar = 'bar';
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Fatal error: Uncaught Error: Property Foo::$bar is read-only in %s:%d
|
Fatal error: Uncaught Error: Cannot write to get-only virtual property Foo::$bar in %s:%d
|
||||||
Stack trace:
|
Stack trace:
|
||||||
#0 {main}
|
#0 {main}
|
||||||
thrown in %s on line %d
|
thrown in %s on line %d
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ try {
|
|||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
int(42)
|
int(42)
|
||||||
Property Test::$prop is read-only
|
Cannot write to get-only virtual property Test::$prop
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ var_dump($b->prop);
|
|||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
A::A::$prop::set
|
A::A::$prop::set
|
||||||
Property A::$prop is write-only
|
Cannot read from set-only virtual property A::$prop
|
||||||
B::B::$prop::set
|
B::B::$prop::set
|
||||||
B::B::$prop::get
|
B::B::$prop::get
|
||||||
int(42)
|
int(42)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ var_dump($b->prop);
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Property A::$prop is read-only
|
Cannot write to get-only virtual property A::$prop
|
||||||
A::A::$prop::get
|
A::A::$prop::get
|
||||||
int(42)
|
int(42)
|
||||||
B::B::$prop::set
|
B::B::$prop::set
|
||||||
|
|||||||
@@ -28,5 +28,5 @@ try {
|
|||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
int(42)
|
int(42)
|
||||||
Property Test::$prop is write-only
|
Cannot read from set-only virtual property Test::$prop
|
||||||
Property Test::$prop is write-only
|
Cannot read from set-only virtual property Test::$prop
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
--TEST--
|
--TEST--
|
||||||
Relaxed type compatibility for read-only and write-only properties
|
Relaxed type compatibility for get-only and set-only properties
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
--TEST--
|
--TEST--
|
||||||
Invalid type compatibility for read-only property
|
Invalid type compatibility for get-only property
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|||||||
@@ -1784,7 +1784,7 @@ ZEND_API void zend_verify_hooked_property(const zend_class_entry *ce, zend_prope
|
|||||||
&& (prop_info->flags & ZEND_ACC_PPP_SET_MASK)
|
&& (prop_info->flags & ZEND_ACC_PPP_SET_MASK)
|
||||||
&& (!prop_info->hooks[ZEND_PROPERTY_HOOK_GET] || !prop_info->hooks[ZEND_PROPERTY_HOOK_SET])) {
|
&& (!prop_info->hooks[ZEND_PROPERTY_HOOK_GET] || !prop_info->hooks[ZEND_PROPERTY_HOOK_SET])) {
|
||||||
const char *prefix = !prop_info->hooks[ZEND_PROPERTY_HOOK_GET]
|
const char *prefix = !prop_info->hooks[ZEND_PROPERTY_HOOK_GET]
|
||||||
? "Write-only" : "Read-only";
|
? "set-only" : "get-only";
|
||||||
zend_error_noreturn(E_COMPILE_ERROR,
|
zend_error_noreturn(E_COMPILE_ERROR,
|
||||||
"%s virtual property %s::$%s must not specify asymmetric visibility",
|
"%s virtual property %s::$%s must not specify asymmetric visibility",
|
||||||
prefix, ZSTR_VAL(ce->name), ZSTR_VAL(prop_name));
|
prefix, ZSTR_VAL(ce->name), ZSTR_VAL(prop_name));
|
||||||
|
|||||||
@@ -809,7 +809,7 @@ try_again:
|
|||||||
zend_function *get = prop_info->hooks[ZEND_PROPERTY_HOOK_GET];
|
zend_function *get = prop_info->hooks[ZEND_PROPERTY_HOOK_GET];
|
||||||
if (!get) {
|
if (!get) {
|
||||||
if (prop_info->flags & ZEND_ACC_VIRTUAL) {
|
if (prop_info->flags & ZEND_ACC_VIRTUAL) {
|
||||||
zend_throw_error(NULL, "Property %s::$%s is write-only",
|
zend_throw_error(NULL, "Cannot read from set-only virtual property %s::$%s",
|
||||||
ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
|
ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
|
||||||
return &EG(uninitialized_zval);
|
return &EG(uninitialized_zval);
|
||||||
}
|
}
|
||||||
@@ -1150,7 +1150,7 @@ found:;
|
|||||||
|
|
||||||
if (!set) {
|
if (!set) {
|
||||||
if (prop_info->flags & ZEND_ACC_VIRTUAL) {
|
if (prop_info->flags & ZEND_ACC_VIRTUAL) {
|
||||||
zend_throw_error(NULL, "Property %s::$%s is read-only", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
|
zend_throw_error(NULL, "Cannot write to get-only virtual property %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
|
||||||
variable_ptr = &EG(error_zval);
|
variable_ptr = &EG(error_zval);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@@ -2343,7 +2343,7 @@ found:
|
|||||||
|
|
||||||
if (!get) {
|
if (!get) {
|
||||||
if (prop_info->flags & ZEND_ACC_VIRTUAL) {
|
if (prop_info->flags & ZEND_ACC_VIRTUAL) {
|
||||||
zend_throw_error(NULL, "Property %s::$%s is write-only",
|
zend_throw_error(NULL, "Cannot read from set-only virtual property %s::$%s",
|
||||||
ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
|
ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user