From 354ef2369fb24593ba7b51edd3cc27633823df4f Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Thu, 21 Nov 2024 06:10:57 +0300 Subject: [PATCH 1/6] Update property-hooks.xml Replace 'all' with 'non-static', as not all The word `all` seems to deceive the reader a little :) How about adding some specifics about which properties are allowed to declare hooks for? --- language/oop5/property-hooks.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/oop5/property-hooks.xml b/language/oop5/property-hooks.xml index 18f73ff2ee98..eb688901b88e 100644 --- a/language/oop5/property-hooks.xml +++ b/language/oop5/property-hooks.xml @@ -25,7 +25,7 @@ - There are two hooks available on all properties: get and set. + There are two hooks available on typed or untyped non-static properties: get and set. They allow overriding the read and write behavior of a property, respectively. From 10c9265a7f79fa693c43a6a302e9a5a3529e4eaa Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Thu, 21 Nov 2024 11:16:16 +0300 Subject: [PATCH 2/6] Update property-hooks.xml remove the dot cahr --- language/oop5/property-hooks.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/oop5/property-hooks.xml b/language/oop5/property-hooks.xml index eb688901b88e..38983e24e514 100644 --- a/language/oop5/property-hooks.xml +++ b/language/oop5/property-hooks.xml @@ -95,7 +95,7 @@ print $example->foo; At least one of the hooks references $this->foo, the property itself. - That means the property wll be "backed." + That means the property wll be "backed". When calling $example->foo = 'changed', the provided string will be first cast to lowercase, then saved to the backing value. When reading from the property, the previously saved value may conditionally be appended From 2b69a0b1b93834f96547c264b3e844d5e78b6419 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Fri, 22 Nov 2024 00:04:42 +0300 Subject: [PATCH 3/6] Update property-hooks.xml fix typo --- language/oop5/property-hooks.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/oop5/property-hooks.xml b/language/oop5/property-hooks.xml index 38983e24e514..227eca26a3c9 100644 --- a/language/oop5/property-hooks.xml +++ b/language/oop5/property-hooks.xml @@ -228,7 +228,7 @@ class Example For virtual properties, if a hook is omitted then that operation does - not exist and trying to use it wil produce an error. + not exist and trying to use it will produce an error. Virtual properties take up no memory space in an object. Virtual properties are suited for "derived" properties, such as those that are the combination of two other properties. From 5c406f0390c14ed4d2bbf42fda5a08892b785b06 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Fri, 22 Nov 2024 02:09:28 +0300 Subject: [PATCH 4/6] Update property-hooks.xml Remove extra parentheses --- language/oop5/property-hooks.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/language/oop5/property-hooks.xml b/language/oop5/property-hooks.xml index 227eca26a3c9..273470178057 100644 --- a/language/oop5/property-hooks.xml +++ b/language/oop5/property-hooks.xml @@ -500,16 +500,16 @@ class CaseFoldingStrings extends Strings just like any other normal read/write action. - var_dump(): Use raw value - serialize(): Use raw value - unserialize(): Use raw value + var_dump: Use raw value + serialize: Use raw value + unserialize: Use raw value __serialize()/__unserialize(): Custom logic, uses get/set hook Array casting: Use raw value - var_export(): Use get hook - json_encode(): Use get hook + var_export: Use get hook + json_encode: Use get hook JsonSerializable: Custom logic, uses get hook - get_object_vars(): Use get hook - get_mangled_object_vars(): Use raw value + get_object_vars: Use get hook + get_mangled_object_vars: Use raw value From 49168d03759f3d2fac27dc66e2c4a11a69b9151b Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Sun, 24 Nov 2024 10:18:30 +0300 Subject: [PATCH 5/6] property-hooks.xml move the period back inside the quotation marks, --- language/oop5/property-hooks.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/oop5/property-hooks.xml b/language/oop5/property-hooks.xml index 7643c6eec1bf..a7f929b8fa1b 100644 --- a/language/oop5/property-hooks.xml +++ b/language/oop5/property-hooks.xml @@ -95,7 +95,7 @@ print $example->foo; At least one of the hooks references $this->foo, the property itself. - That means the property wll be "backed". + That means the property wll be "backed." When calling $example->foo = 'changed', the provided string will be first cast to lowercase, then saved to the backing value. When reading from the property, the previously saved value may conditionally be appended From a2aeacc8ca069c38e14b6fc2598e3dba60d745c6 Mon Sep 17 00:00:00 2001 From: Mikhail Alferov Date: Sun, 24 Nov 2024 10:22:57 +0300 Subject: [PATCH 6/6] property-hooks.xml Typed and non-types Specify that hooks are available for both typed and untyped properties --- language/oop5/property-hooks.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/language/oop5/property-hooks.xml b/language/oop5/property-hooks.xml index a7f929b8fa1b..05637fb9751a 100644 --- a/language/oop5/property-hooks.xml +++ b/language/oop5/property-hooks.xml @@ -25,8 +25,9 @@ - There are two hooks available on typed or untyped non-static properties: get and set. + There are two hooks available on non-static properties: get and set. They allow overriding the read and write behavior of a property, respectively. + Hooks are available for both typed and untyped properties. A property may be "backed" or "virtual".