[PRES] [presentations] master: Merge branch 'master' of github.com:php/presentations

[email protected] (Derick Rethans) Tue, 12 Mar 2024 16:26:16 +0000
Newsgroups php.pres
Message-ID <[email protected]>
Author: Derick Rethans (derickr)
Date: 2024-03-12T14:57:00Z

Commit: https://github.com/php/presentations/commit/11b924d6c19b162ecddd8aef59397f34e7d2e8df
Raw diff: https://github.com/php/presentations/commit/11b924d6c19b162ecddd8aef59397f34e7d2e8df.diff

Merge branch 'master' of github.com:php/presentations

Changed paths:
  A  slides/internals/php84-property-hooks.xml


Diff:

diff --git a/slides/internals/php84-property-hooks.xml b/slides/internals/php84-property-hooks.xml
new file mode 100644
index 00000000..0790ad43
--- /dev/null
+++ b/slides/internals/php84-property-hooks.xml
@@ -0,0 +1,24 @@
+<slide>
+<title>PHP 8.4: Property Hooks</title>
+
+<example inline="1"><![CDATA[&lt;?php
+class User implements Named
+{
+    private bool $isModified = false;
+
+    public function __construct(private string $first, private string $last) {}
+
+    public string $fullName {
+        // Override the "read" action with arbitrary logic.
+        *get* *=>* $this->first . " " . $this->last;
+
+        // Override the "write" action with arbitrary logic.
+        *set {*
+            [$this->first, $this->last] = explode(' ', $value);
+            $this->isModified = true;
+        }
+    }
+}
+?>]]></example>
+
+</slide>