[PRES] [presentations] master: AFUP talk

[email protected] (Derick Rethans) Tue, 8 Oct 2024 17:49:41 +0000
Newsgroups php.pres
Message-ID <[email protected]>
Author: Derick Rethans (derickr)
Date: 2024-10-08T18:46:50+01:00

Commit: https://github.com/php/presentations/commit/6e1e0d88425431539556b032af2675da4ce50dcc
Raw diff: https://github.com/php/presentations/commit/6e1e0d88425431539556b032af2675da4ce50dcc.diff

AFUP talk

Changed paths:
  A  php-afup24.xml
  A  slides/internals/php84-asymmetric-visibility-2.xml
  A  slides/internals/php84-asymmetric-visibility.xml
  A  slides/internals/php84-bcrypt-cost.xml
  A  slides/internals/php84-deprecate-implicitly-nullable-types.xml
  A  slides/internals/php84-deprecated-attribute.xml
  A  slides/internals/php84-dom-callbacks.xml
  A  slides/internals/php84-grapheme-str-split-2.xml
  A  slides/internals/php84-grapheme-str-split-3.xml
  A  slides/internals/php84-grapheme-str-split.xml
  A  slides/internals/php84-lazy-objects.xml
  A  slides/internals/php84-new-without-parentheses.xml
  A  slides/internals/php84-property-hooks-2.xml
  A  slides/internals/php84-property-hooks-example-1.xml
  A  slides/internals/php84-property-hooks-example-2.xml
  A  slides/internals/php84-property-hooks-example-3.xml
  A  slides/internals/php84-property-hooks-example-4.xml
  A  slides/internals/yawn-cat-yawning.gif
  M  slides/internals/php84-policy-repository.xml
  M  slides/internals/php84-round-modes.xml


Diff:

diff --git a/php-afup24.xml b/php-afup24.xml
new file mode 100644
index 00000000..07b9841d
--- /dev/null
+++ b/php-afup24.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+<presentation css="derick.css">
+<topic>PHP</topic>
+<title>What's New in PHP 8.4?</title>
+<event>Forum PHP 2024</event>
+<location>Disneyland, Paris, France</location>
+<date>Oct 10th, 2024</date>
+<speaker>Derick Rethans</speaker>
+<email>[email protected]</email>
+<twitter>derickr</twitter>
+<mastodon>@[email protected]</mastodon>
+<url>https://derickrethans.nl/talks/php-afup24</url>
+<joindin></joindin>
+<slide>slides/xdebug/title.xml</slide>
+<slide>slides/mongodb/me.xml</slide>
+
+
+Syntax:
+
+https://wiki.php.net/rfc/asymmetric-visibility-v2
+<slide>slides/internals/php84-asymmetric-visibility.xml</slide>
+<slide>slides/internals/php84-asymmetric-visibility-2.xml</slide>
+
+https://wiki.php.net/rfc/property-hooks
+<slide>slides/internals/php84-property-hooks.xml</slide>
+<slide>slides/internals/php84-property-hooks-example-1.xml</slide>
+<slide>slides/internals/php84-property-hooks-example-2.xml</slide>
+<slide>slides/internals/php84-property-hooks-example-3.xml</slide>
+<slide>slides/internals/php84-property-hooks-example-4.xml</slide>
+
+https://wiki.php.net/rfc/new_without_parentheses
+<slide>slides/internals/php84-new-without-parentheses.xml</slide>
+
+
+
+Major additions:
+
+https://wiki.php.net/rfc/domdocument_html5_parser
+<slide>slides/internals/php84-dom-html5.xml</slide>
+
+<!--
+https://wiki.php.net/rfc/improve_callbacks_dom_and_xsl
+<sl ide>slides/internals/php84-dom-callbacks.xml</slide>
+-->
+
+https://wiki.php.net/rfc/lazy-objects
+<slide>slides/internals/php84-lazy-objects.xml</slide>
+
+
+https://wiki.php.net/rfc/jit-ir
+<slide>slides/internals/php80-jit.xml</slide>
+<slide>slides/internals/php84-jit.xml</slide>
+
+Minor additions:
+
+https://wiki.php.net/rfc/deprecated_attribute
+<slide>slides/internals/php84-deprecated-attribute.xml</slide>
+
+https://wiki.php.net/rfc/pdo_driver_specific_subclasses
+<slide>slides/internals/php84-pdo-subclass.xml</slide>
+
+https://wiki.php.net/rfc/new_rounding_modes_to_round_function
+<slide>slides/internals/php84-round-modes.xml</slide>
+
+https://wiki.php.net/rfc/bcrypt_cost_2023
+<slide>slides/internals/php84-bcrypt-cost.xml</slide>
+
+https://wiki.php.net/rfc/grapheme_str_split
+<slide>slides/internals/php84-grapheme-str-split.xml</slide>
+<slide>slides/internals/php84-grapheme-str-split-2.xml</slide>
+<slide>slides/internals/php84-grapheme-str-split-3.xml</slide>
+
+Deprecations:
+
+https://wiki.php.net/rfc/deprecate-implicitly-nullable-types
+<slide>slides/internals/php84-deprecate-implicitly-nullable-types.xml</slide>
+
+https://wiki.php.net/rfc/unbundle_imap_pspell_oci8
+
+
+Policy:
+
+https://wiki.php.net/rfc/policy-repository
+<slide>slides/internals/php84-policy-repository.xml</slide>
+
+https://wiki.php.net/rfc/release_cycle_update
+<slide>slides/internals/php84-release-cycle.xml</slide>
+
+<slide>slides/internals/questions-new.xml</slide>
+<slide>slides/xdebug/resources.xml</slide>
+
+</presentation>
diff --git a/slides/internals/php84-asymmetric-visibility-2.xml b/slides/internals/php84-asymmetric-visibility-2.xml
new file mode 100644
index 00000000..c7a72f32
--- /dev/null
+++ b/slides/internals/php84-asymmetric-visibility-2.xml
@@ -0,0 +1,13 @@
+<slide>
+<title>PHP 8.4: Asymmetric Visibility</title>
+
+<list>
+	<bullet>Only works on typed properties</bullet>
+	<bullet>%set% visibility must be equal or lesser than main (%get%) visbility</bullet>
+	<bullet>Using %$obj->array[]% follows %set% visibility</bullet>
+	<bullet>Inherited properties must have the same time, and might have a wider visibility</bullet>
+	<bullet>%private(set)% also implies %final%</bullet>
+	<bullet>%readonly% (without %private(set)%) is analogous to %protected(set)% (+ write once semantics)</bullet>
+</list>
+
+</slide>
diff --git a/slides/internals/php84-asymmetric-visibility.xml b/slides/internals/php84-asymmetric-visibility.xml
new file mode 100644
index 00000000..ee3bae76
--- /dev/null
+++ b/slides/internals/php84-asymmetric-visibility.xml
@@ -0,0 +1,85 @@
+<slide>
+<title>PHP 8.4: Asymmetric Visibility</title>
+
+<div effect="fade-out">
+<example inline="2"><![CDATA[&lt;?php
+class Reader
+{
+    /**
+     * @var array[Track]
+     */
+    *private array $tracks;*
+
+    function __construct( string $fileName )
+    {
+        $this->parseGpx( $fileName );
+    }
+
+    private function parseGpx( $fileName )
+    {
+        // sets $this->tracks
+    }
+
+    *public function getTracks() : array*
+    {
+        return $this->tracks;
+    }
+}
+?>]]></example>
+</div>
+
+<div effect="fade-in-out">
+<example inline="2"><![CDATA[&lt;?php
+class Reader
+{
+    /**
+     * @var array[Track]
+     */
+    *public private(set)* array $tracks;
+
+    function __construct( string $fileName )
+    {
+        $this->parseGpx( $fileName );
+    }
+
+    private function parseGpx( $fileName )
+    {
+        // sets $this->tracks
+    }
+
+
+
+
+
+}
+?>]]></example>
+</div>
+
+<div effect="fade-in">
+<example inline="2"><![CDATA[&lt;?php
+class Reader
+{
+    /**
+     * @var array[Track]
+     */
+    *private(set)* array $tracks;
+
+    function __construct( string $fileName )
+    {
+        $this->parseGpx( $fileName );
+    }
+
+    private function parseGpx( $fileName )
+    {
+        // sets $this->tracks
+    }
+
+
+
+
+
+}
+?>]]></example>
+</div>
+
+</slide>
diff --git a/slides/internals/php84-bcrypt-cost.xml b/slides/internals/php84-bcrypt-cost.xml
new file mode 100644
index 00000000..d2ce46b5
--- /dev/null
+++ b/slides/internals/php84-bcrypt-cost.xml
@@ -0,0 +1,12 @@
+<slide>
+<title>PHP 8.4: BCrypt Cost</title>
+
+<blurb>PHP's default BCrypt cost for %password_hash()% is unchanged since the addition of the password hashing API in PHP 5.5 which was 11 years ago.</blurb>
+
+<list>
+    <bullet>The current cost is %10%</bullet>
+    <bullet>Increasing the cost by one, doubles the time</bullet>
+    <bullet>New cost in PHP 8.4: %12% (~less than 330ms per hash)</bullet>
+</list>
+
+</slide>
diff --git a/slides/internals/php84-deprecate-implicitly-nullable-types.xml b/slides/internals/php84-deprecate-implicitly-nullable-types.xml
new file mode 100644
index 00000000..7f448f17
--- /dev/null
+++ b/slides/internals/php84-deprecate-implicitly-nullable-types.xml
@@ -0,0 +1,48 @@
+<slide>
+<title>PHP 8.4: Deprecate Implicit Nullability</title>
+
+<example><![CDATA[<?php
+class Rst
+{
+    public function __construct( RstOptions $options = null )
+    {
+    }
+}]]></example>
+
+<div effect="fade-in">
+<example class="error small">
+Deprecated: Rst::__construct(): Implicitly marking parameter $options as nullable is deprecated, the explicit nullable type must be used instead
+</example>
+</div>
+
+<div effect="fade-in-out">
+<example inline="2"><![CDATA[&lt;?php
+class Rst
+{
+    public function __construct( RstOptions $options *= null* )
+    {
+    }
+}]]></example>
+</div>
+
+<div effect="fade-in">
+<example inline="2"><![CDATA[&lt;?php
+class Rst
+{
+    public function __construct( *?*RstOptions $options = null )
+    {
+    }
+}]]></example>
+</div>
+
+<div effect="fade-in">
+<example inline="2"><![CDATA[&lt;?php
+class Rst
+{
+    public function __construct( RstOptions*|null* $options = null )
+    {
+    }
+}]]></example>
+</div>
+
+</slide>
diff --git a/slides/internals/php84-deprecated-attribute.xml b/slides/internals/php84-deprecated-attribute.xml
new file mode 100644
index 00000000..644d058a
--- /dev/null
+++ b/slides/internals/php84-deprecated-attribute.xml
@@ -0,0 +1,49 @@
+<slide>
+<title>PHP 8.4: #[Deprecated] Attribute</title>
+
+<div effect="fade-out">
+<example result="3"><![CDATA[<?php
+#[\Deprecated("use test() instead", since: "2.4")]
+function test3() {
+}
+
+test3();
+?>]]></example>
+</div>
+
+<div effect="fade-in-out">
+<example result="3"><![CDATA[<?php
+class Clazz {
+    #[\Deprecated]
+    public const OLD_WAY = 'foo';
+ 
+    #[\Deprecated("use test() instead", since: "2024-10-08")]
+    function test2() {
+    }
+}
+
+$c = new Clazz()->test2();
+echo Clazz::OLD_WAY, "\n";
+?>]]></example>
+</div>
+
+<div effect="fade-in">
+<example result="3"><![CDATA[<?php
+enum MyEnum {
+    #[\Deprecated]
+    case OldCase;
+}
+
+var_dump(MyEnum::OldCase);
+?>]]></example>
+</div>
+
+<div effect="fade-in">
+<break lines="2"/>
+<list>
+    <bullet>Can be set on: Methods, Functions, Constants</bullet>
+    <bullet>The %since% parameter is a free-form string</bullet>
+    <bullet>Can also be used by PHP's internals</bullet>
+</list>
+</div>
+</slide>
diff --git a/slides/internals/php84-dom-callbacks.xml b/slides/internals/php84-dom-callbacks.xml
new file mode 100644
index 00000000..d6452e59
--- /dev/null
+++ b/slides/internals/php84-dom-callbacks.xml
@@ -0,0 +1,4 @@
+<slide>
+<title>PHP 8.4: DOM and XSL Callback Improvements</title>
+
+</slide>
diff --git a/slides/internals/php84-grapheme-str-split-2.xml b/slides/internals/php84-grapheme-str-split-2.xml
new file mode 100644
index 00000000..60b0169f
--- /dev/null
+++ b/slides/internals/php84-grapheme-str-split-2.xml
@@ -0,0 +1,10 @@
+<slide>
+<title>PHP 8.4: grapheme_str_split</title>
+
+<example result="1"><![CDATA[<?php
+foreach (mb_str_split("🙇‍♂️") as $element) {
+    printf("%8s : %s\n", bin2hex($element), $element);
+}
+?>]]></example>
+
+</slide>
diff --git a/slides/internals/php84-grapheme-str-split-3.xml b/slides/internals/php84-grapheme-str-split-3.xml
new file mode 100644
index 00000000..a4f601bd
--- /dev/null
+++ b/slides/internals/php84-grapheme-str-split-3.xml
@@ -0,0 +1,18 @@
+<slide>
+<title>PHP 8.4: grapheme_str_split</title>
+
+<example result="1"><![CDATA[<?php
+foreach (grapheme_str_split("🙇‍♂️") as $element) {
+    printf("%8s : %s\n", bin2hex($element), $element);
+}
+?>]]></example>
+
+<div effect="fade-in">
+<example result="1"><![CDATA[<?php
+foreach (grapheme_str_split("Hḁ̢̆llo 🇫🇷!") as $element) {
+    printf("%20s : %s\n", bin2hex($element), $element);
+}
+?>]]></example>
+</div>
+
+</slide>
diff --git a/slides/internals/php84-grapheme-str-split.xml b/slides/internals/php84-grapheme-str-split.xml
new file mode 100644
index 00000000..69343c29
--- /dev/null
+++ b/slides/internals/php84-grapheme-str-split.xml
@@ -0,0 +1,10 @@
+<slide>
+<title>PHP 8.4: grapheme_str_split</title>
+
+<example result="1"><![CDATA[<?php
+foreach (str_split("🙇‍♂️") as $element) {
+    printf("%8s : %s\n", bin2hex($element), $element);
+}
+?>]]></example>
+
+</slide>
diff --git a/slides/internals/php84-lazy-objects.xml b/slides/internals/php84-lazy-objects.xml
new file mode 100644
index 00000000..22e7a9dd
--- /dev/null
+++ b/slides/internals/php84-lazy-objects.xml
@@ -0,0 +1,9 @@
+<slide>
+<title>PHP 8.4: Lazy Objects</title>
+
+<div effect="fade-in">
+<break lines="5"/>
+<image filename="yawn-cat-yawning.gif" attr="https://tenor.com/view/yawn-cat-yawning-yawning-cats-cat-gif-17596768"/>
+</div>
+
+</slide>
diff --git a/slides/internals/php84-new-without-parentheses.xml b/slides/internals/php84-new-without-parentheses.xml
new file mode 100644
index 00000000..dfc3ead5
--- /dev/null
+++ b/slides/internals/php84-new-without-parentheses.xml
@@ -0,0 +1,49 @@
+<slide>
+<title>PHP 8.4: New Without Parentheses</title>
+
+<div effect="fade-out">
+<example inline="2"><![CDATA[&lt;?php
+class Request implements Psr\Http\Message\RequestInterface
+{
+    // ...
+}
+
+$request = *(*new Request()*)*->withMethod('GET')->withUri('/hello-world');
+?>]]></example>
+</div>
+
+<div effect="fade-in-out">
+<example><![CDATA[<?php
+class Request implements Psr\Http\Message\RequestInterface
+{
+    // ...
+}
+
+$request = new Request()->withMethod('GET')->withUri('/hello-world');
+?>]]></example>
+</div>
+
+<div effect="fade-in">
+<example><![CDATA[<?php
+class MyClass extends ArrayObject
+{
+    const CONSTANT = 'constant';
+    public static $staticProperty = 'staticProperty';
+    public static function staticMethod(): string { return 'staticMethod'; }
+    public $property = 'property';
+    public function method(): string { return 'method'; }
+    public function __invoke(): string { return '__invoke'; }
+}
+
+var_dump(
+    new MyClass()::CONSTANT,        // string(8)  "constant"
+    new MyClass()::$staticProperty, // string(14) "staticProperty"
+    new MyClass()::staticMethod(),  // string(12) "staticMethod"
+    new MyClass()->property,        // string(8)  "property"
+    new MyClass()->method(),        // string(6)  "method"
+    new MyClass()(),                // string(8)  "__invoke"
+    new MyClass(['value'])[0],      // string(5)  "value"
+);
+?>]]></example>
+</div>
+</slide>
diff --git a/slides/internals/php84-policy-repository.xml b/slides/internals/php84-policy-repository.xml
index 216b1763..781f632d 100644
--- a/slides/internals/php84-policy-repository.xml
+++ b/slides/internals/php84-policy-repository.xml
@@ -18,7 +18,7 @@
 
 <list>
 	<bullet>Rewrite documents to be statements of facts instead of intent</bullet>
-	<bullet>Figure out which information isn't written down authoritively yet</bullet>
+	<bullet>Figure out which information isn't written down authoritativily yet</bullet>
 </list>
 </div>
 </slide>
diff --git a/slides/internals/php84-property-hooks-2.xml b/slides/internals/php84-property-hooks-2.xml
new file mode 100644
index 00000000..c6aebd03
--- /dev/null
+++ b/slides/internals/php84-property-hooks-2.xml
@@ -0,0 +1,4 @@
+<slide>
+<title>PHP 8.4: Property Hook Improvements</title>
+
+</slide>
diff --git a/slides/internals/php84-property-hooks-example-1.xml b/slides/internals/php84-property-hooks-example-1.xml
new file mode 100644
index 00000000..4d2e0bb7
--- /dev/null
+++ b/slides/internals/php84-property-hooks-example-1.xml
@@ -0,0 +1,41 @@
+<slide>
+<title>PHP 7.4: Typed Properties</title>
+
+<example><![CDATA[<?php
+class ezcMailImapTransportOptions 
+{
+    protected $properties;
+
+    public function __construct( array $options = array() )
+    {
+        $this->uidReferencing = false;
+    }
+
+    public function __set( $name, $value )
+    {
+        switch ( $name ) {
+            case 'uidReferencing':
+                if ( !is_bool( $value ) ) {
+                    throw new ezcBaseValueException( $name, $value, 'bool' );
+                }
+                $this->properties[$name] = $value;
+                break;
+        }
+    }
+
+    public function __isset( $propertyName )
+    {
+        return array_key_exists( $propertyName, $this->properties );
+    }
+
+    public function __get( $propertyName )
+    {
+        if ( $this->__isset( $propertyName ) === true ) {
+            return $this->properties[$propertyName];
+        }
+        throw new ezcBasePropertyNotFoundException( $propertyName );
+    }
+}
+?>]]></example>
+
+</slide>
diff --git a/slides/internals/php84-property-hooks-example-2.xml b/slides/internals/php84-property-hooks-example-2.xml
new file mode 100644
index 00000000..ed9f13e9
--- /dev/null
+++ b/slides/internals/php84-property-hooks-example-2.xml
@@ -0,0 +1,16 @@
+<slide>
+<title>PHP 7.4: Typed Properties</title>
+
+<example inline="2"><![CDATA[&lt;?php
+class ezcMailImapTransportOptions 
+{
+    *public bool $uidReferencing;*
+
+    public function __construct( array $options = array() )
+    {
+        $this->uidReferencing = false;
+    }
+
+?>]]></example>
+
+</slide>
diff --git a/slides/internals/php84-property-hooks-example-3.xml b/slides/internals/php84-property-hooks-example-3.xml
new file mode 100644
index 00000000..e953cdc6
--- /dev/null
+++ b/slides/internals/php84-property-hooks-example-3.xml
@@ -0,0 +1,41 @@
+<slide>
+<title>PHP 8.4: Real Life Example with Property Hooks</title>
+
+<example><![CDATA[<?php
+class ezcMailImapTransportOptions 
+{
+    protected $properties;
+
+    public function __construct( array $options = array() )
+    {
+        $this->listLimit = 0;
+    }
+
+    public function __set( $name, $value )
+    {
+        switch ( $name ) {
+            case 'listLimit': 
+                if ( !is_int( $value ) || $value < 0 ) {
+                    throw new ezcBaseValueException( $name, $value, 'int >= 0' );
+                }
+                $this->properties[$name] = $value;
+                break;
+        }
+    }
+
+    public function __isset( $propertyName )
+    {
+        return array_key_exists( $propertyName, $this->properties );
+    }
+
+    public function __get( $propertyName )
+    {
+        if ( $this->__isset( $propertyName ) === true ) {
+            return $this->properties[$propertyName];
+        }
+        throw new ezcBasePropertyNotFoundException( $propertyName );
+    }
+}
+?>]]></example>
+
+</slide>
diff --git a/slides/internals/php84-property-hooks-example-4.xml b/slides/internals/php84-property-hooks-example-4.xml
new file mode 100644
index 00000000..be7ae6f5
--- /dev/null
+++ b/slides/internals/php84-property-hooks-example-4.xml
@@ -0,0 +1,22 @@
+<slide>
+<title>PHP 8.4: Real Life Example with Property Hooks</title>
+
+<example><![CDATA[<?php
+class ezcMailImapTransportOptions 
+{
+    public int $listLimit {
+        set {
+            if ( $value < 0 ) {
+                throw new ValueError( "listLimit was set to <{$value}>, but must be >= 0" );
+            }
+        }
+    }
+
+    public function __construct( array $options = array() )
+    {
+        $this->listLimit = 0;
+    }
+}
+?>]]></example>
+
+</slide>
diff --git a/slides/internals/php84-round-modes.xml b/slides/internals/php84-round-modes.xml
index 2ef33655..35a3b8ee 100644
--- a/slides/internals/php84-round-modes.xml
+++ b/slides/internals/php84-round-modes.xml
@@ -2,21 +2,18 @@
 <title>PHP 8.4: Rounding Modes</title>
 
 <example result="1"><![CDATA[<?php
-$modes = [
-    PHP_ROUND_CEILING, PHP_ROUND_FLOOR,
-    PHP_ROUND_AWAY_FROM_ZERO, PHP_ROUND_TOWARD_ZERO,
-];
+$values = [ -8.5, -8.45, 8.45, 8.5 ];
 
-// 8.45
-foreach ($modes as $mode) {
-    echo ' ' . round(8.45, 1, $mode), " ";
-}
-echo "\n";
+foreach (RoundingMode::cases() as $mode) {
+    printf( '%20s: ', $mode->name );
 
-// -8.45
-foreach ($modes as $mode) {
-    echo round(-8.45, 1, $mode), " ";
+    foreach ($values as $value) {
+        printf( '%5s', round($value, 1, $mode) );
+    }
+    foreach ($values as $value) {
+        printf( '%5s', round($value, 0, $mode) );
+    }
+    echo "\n";
 }
-echo "\n";
 ]]></example>
 </slide>
diff --git a/slides/internals/yawn-cat-yawning.gif b/slides/internals/yawn-cat-yawning.gif
new file mode 100644
index 00000000..98f17ef6
Binary files /dev/null and b/slides/internals/yawn-cat-yawning.gif differ