From 69f248e188a3f82468c6182959dc7f6533be25f4 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Fri, 3 Oct 2025 09:03:03 -0500 Subject: [PATCH] Document static asymmetric visibility. --- language/oop5/visibility.xml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/language/oop5/visibility.xml b/language/oop5/visibility.xml index 8898d01becfd..fee08cbd60cb 100644 --- a/language/oop5/visibility.xml +++ b/language/oop5/visibility.xml @@ -79,7 +79,7 @@ $obj2->printHello(); // Shows Public2, Protected2, Undefined Asymmetric Property Visibility - As of PHP 8.4, properties may also have their + As of PHP 8.4, object properties may also have their visibility set asymmetrically, with a different scope for reading (get) and writing (set). Specifically, the set visibility may be @@ -119,6 +119,33 @@ $b->title = 'How not to PHP'; // Fatal Error $b->author = 'Pedro H. Peterson'; // Fatal Error $b->pubYear = 2023; // Fatal Error ?> +]]> + + + As of PHP 8.5, set visibility may also be applied to static properties of classes. + + Asymmetric Property visibility + + doAThing(); // Works +print Manager::$calls; // Works +Manager::$calls = 5; // Fatal error +?> ]]>