Skip to content

Improve readonly avis error #15618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Zend/tests/asymmetric_visibility/readonly.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ test();
?>
--EXPECT--
Cannot modify private(set) property P::$pPrivate from scope C
Cannot modify protected(set) property P::$pDefault from global scope
Cannot modify protected(set) readonly property P::$pDefault from global scope
Cannot modify private(set) property P::$pPrivate from global scope
Cannot modify protected(set) property P::$pProtected from global scope
Cannot modify protected(set) readonly property P::$pProtected from global scope
2 changes: 1 addition & 1 deletion Zend/tests/readonly_props/initialization_scope.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var_dump($test);

?>
--EXPECTF--
Cannot modify protected(set) property A::$prop from global scope
Cannot modify protected(set) readonly property A::$prop from global scope
object(B)#%d (1) {
["prop"]=>
int(2)
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/readonly_props/magic_get_set.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ try {
--EXPECT--
bool(false)
Typed property Test::$prop must not be accessed before initialization
Cannot modify protected(set) property Test::$prop from global scope
Cannot unset protected(set) property Test::$prop from global scope
Cannot modify protected(set) readonly property Test::$prop from global scope
Cannot unset protected(set) readonly property Test::$prop from global scope
Test::__isset(prop)
bool(true)
Test::__get(prop)
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/readonly_props/unset.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ Test2::__get
int(1)
int(1)
Cannot unset readonly property Test2::$prop
Cannot unset protected(set) property Test3::$prop from global scope
Cannot unset protected(set) readonly property Test3::$prop from global scope
4 changes: 2 additions & 2 deletions Zend/tests/readonly_props/variation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ Init: 0, scope: 1, op: is: 0
Init: 0, scope: 1, op: us: done
Init: 0, scope: 1, op: us_dim: done
Init: 0, scope: 0, op: r: Typed property Test::$prop must not be accessed before initialization
Init: 0, scope: 0, op: w: Cannot modify protected(set) property Test::$prop from global scope
Init: 0, scope: 0, op: w: Cannot modify protected(set) readonly property Test::$prop from global scope
Init: 0, scope: 0, op: rw: Typed property Test::$prop must not be accessed before initialization
Init: 0, scope: 0, op: im: Cannot indirectly modify readonly property Test::$prop
Init: 0, scope: 0, op: is: 0
Init: 0, scope: 0, op: us: Cannot unset protected(set) property Test::$prop from global scope
Init: 0, scope: 0, op: us: Cannot unset protected(set) readonly property Test::$prop from global scope
Init: 0, scope: 0, op: us_dim: done
6 changes: 5 additions & 1 deletion Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,11 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_asymmetric_visibility_property_modifi
visibility = "private(set)";
} else {
ZEND_ASSERT(prop_info->flags & ZEND_ACC_PROTECTED_SET);
visibility = "protected(set)";
if (prop_info->flags & ZEND_ACC_READONLY) {
visibility = "protected(set) readonly";
} else {
visibility = "protected(set)";
}
}

zend_throw_error(NULL, "Cannot %s %s property %s::$%s from %s%s",
Expand Down
Loading