From 69f248e188a3f82468c6182959dc7f6533be25f4 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Fri, 3 Oct 2025 09:03:03 -0500 Subject: [PATCH 1/2] 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 +?> ]]> From 2218771410495887610ea106c8e62b729c4960ae Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Wed, 29 Oct 2025 09:31:51 -0500 Subject: [PATCH 2/2] Formatting fixes Co-authored-by: Gina Peter Banyard --- language/oop5/visibility.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/language/oop5/visibility.xml b/language/oop5/visibility.xml index fee08cbd60cb..584cf9c6de25 100644 --- a/language/oop5/visibility.xml +++ b/language/oop5/visibility.xml @@ -122,11 +122,13 @@ $b->pubYear = 2023; // Fatal Error ]]> - As of PHP 8.5, set visibility may also be applied to static properties of classes. + + 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 +echo Manager::$calls; // Works Manager::$calls = 5; // Fatal error ?> ]]>