[presentations] master: Updated PHP UK talk, and added ModXpo and PHP London talks
[email protected] (Derick Rethans) Wed, 20 Jul 2022 15:38:05 +0000
| Newsgroups | php.pres |
|---|---|
| Message-ID | <[email protected]> |
Author: Derick Rethans (derickr) Date: 2022-07-20T16:31:17+01:00 Commit: https://github.com/php/presentations/commit/e19a07d72d147d13dd93347ed0e6af23f1e4f85f Raw diff: https://github.com/php/presentations/commit/e19a07d72d147d13dd93347ed0e6af23f1e4f85f.diff Updated PHP UK talk, and added ModXpo and PHP London talks Changed paths: A php-london22.xml A php-modxpo22.xml A slides/internals/barbara-liskov.jpg A slides/internals/lsp.xml A slides/internals/php74-untyped-properties.xml A slides/internals/php80-static-return.xml A slides/internals/php82-deprecate-dynamic-properties.xml A slides/internals/php82-dnf-types.xml A slides/internals/php82-enums-1.xml A slides/internals/php82-null-false-standalone.xml A slides/internals/php82-readonly.xml A slides/internals/php82-redact-parameters.xml A slides/internals/php82-true.xml A slides/internals/type-history.xml M php-phpuk22.xml M slides/internals/php74-typed-properties-read.xml M slides/internals/php74-typed-properties-write-coersive.xml M slides/internals/php74-typed-properties-write-strict.xml M slides/internals/php74-typed-properties-write.xml M slides/internals/php74-typed-properties.xml M slides/internals/php74-variance-argument-ok.xml M slides/internals/php74-variance-argument-wrong.xml M slides/internals/php74-variance-properties-ok.xml M slides/internals/php74-variance-properties-wrong.xml M slides/internals/php74-variance-return-ok.xml M slides/internals/php74-variance-return-wrong.xml M slides/internals/php80-named-with.xml M slides/internals/php80-named-without.xml M slides/internals/php80-union-types-coercive.xml Diff: diff --git a/php-london22.xml b/php-london22.xml new file mode 100644 index 00000000..c3891aff --- /dev/null +++ b/php-london22.xml @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="utf-8"?> +<presentation css="derick.css"> +<topic>PHP</topic> +<title>What's New in PHP 8.x</title> +<event>PHP London</event> +<location>London, United Kingdom</location> +<date>July 21st, 2022</date> +<speaker>Derick Rethans</speaker> +<email>[email protected]</email> +<twitter>derickr</twitter> +<url>https://derickrethans.nl/talks/php-london22</url> +<joindin></joindin> +<slide>slides/xdebug/title.xml</slide> +<slide>slides/mongodb/me.xml</slide> + +<slide>slides/internals/php80-union-types.xml</slide> +<slide>slides/internals/php80-union-types-phpdoc.xml</slide> +<slide>slides/internals/php80-union-types-new.xml</slide> +<slide>slides/internals/php80-union-types-examples.xml</slide> +<slide>slides/internals/php80-union-types-law.xml</slide> +<slide>slides/internals/php80-union-types-coercive.xml</slide> + +Readonly properties 2.0 (https://wiki.php.net/rfc/readonly_properties_v2) +<slide>slides/internals/php81-readonly.xml</slide> + +https://wiki.php.net/rfc/readonly_classes +<slide>slides/internals/php82-readonly.xml</slide> + +Mixed Type v2 +<slide>slides/internals/php80-mixed-types.xml</slide> + +PHP 8.0: +https://wiki.php.net/rfc/static_return_type +static return type +<slide>slides/internals/php80-static-return.xml</slide> + +Constructor Property Promotion +<slide>slides/internals/php80-cpp-without.xml</slide> +<slide>slides/internals/php80-cpp-with.xml</slide> + +<slide>slides/internals/php80-named-without.xml</slide> +<slide>slides/internals/php80-named-with.xml</slide> + +<!-- BIG NEW FEATURES --> +Enumerations (https://wiki.php.net/rfc/enumerations) +<slide>slides/internals/php81-enums-1.xml</slide> +<slide>slides/internals/php81-enums-2.xml</slide> +<slide>slides/internals/php81-enums-3.xml</slide> +<slide>slides/internals/php81-enums-4.xml</slide> +<slide>slides/internals/php81-enums-5.xml</slide> +<slide>slides/internals/php81-enums-6.xml</slide> +<slide>slides/internals/php81-enums-7.xml</slide> + +https://wiki.php.net/rfc/fetch_property_in_const_expressions +<slide>slides/internals/php82-enums-1.xml</slide> + +Noreturn type (https://wiki.php.net/rfc/noreturn_type) (never) +<slide>slides/internals/php81-never-type.xml</slide> + +Pure Intersection Types (https://wiki.php.net/rfc/pure-intersection-types) +<slide>slides/internals/php81-pure-intersection.xml</slide> + +Array unpacking with string keys (https://wiki.php.net/rfc/array_unpacking_string_keys) +<slide>slides/internals/php81-array-unpacking.xml</slide> + +Fibers (https://wiki.php.net/rfc/fibers) +<slide>slides/internals/php81-fibers.xml</slide> + +PHP 8.2: + +https://wiki.php.net/rfc/null-false-standalone-types +'null' and 'false' as standalone +<slide>slides/internals/php82-null-false-standalone.xml</slide> + +https://wiki.php.net/rfc/true-type +'true' type +<slide>slides/internals/php82-true.xml</slide> + +https://wiki.php.net/rfc/dnf_types +? Disjunctive Normal Form Types +<slide>slides/internals/php82-dnf-types.xml</slide> + +https://wiki.php.net/rfc/deprecate_dynamic_properties +<slide>slides/internals/php82-deprecate-dynamic-properties.xml</slide> + +https://wiki.php.net/rfc/redact_parameters_in_back_traces +<slide>slides/internals/php82-redact-parameters.xml</slide> + +<slide>slides/xdebug/phpinternalsnews.xml</slide> + +<slide>slides/internals/questions-new.xml</slide> +<slide>slides/xdebug/resources.xml</slide> + +</presentation> diff --git a/php-modxpo22.xml b/php-modxpo22.xml new file mode 100644 index 00000000..9c807cea --- /dev/null +++ b/php-modxpo22.xml @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="utf-8"?> +<presentation css="derick.css"> +<topic>PHP</topic> +<title>PHP's Type System Updates</title> +<event>MODXpo'22</event> +<location>Arnhem, The Netherlands</location> +<date>July 8th, 2022</date> +<speaker>Derick Rethans</speaker> +<email>[email protected]</email> +<twitter>derickr</twitter> +<url>https://derickrethans.nl/talks/php-modxpo22</url> +<joindin></joindin> +<slide>slides/xdebug/title.xml</slide> +<slide>slides/mongodb/me.xml</slide> + +<slide>slides/internals/type-history.xml</slide> + +<!-- TYPES --> +<slide>slides/internals/php74-untyped-properties.xml</slide> +<slide>slides/internals/php74-typed-properties.xml</slide> +<slide>slides/internals/php74-typed-properties-read.xml</slide> +<slide>slides/internals/php74-typed-properties-write.xml</slide> +<slide>slides/internals/php74-typed-properties-write-coersive.xml</slide> +<slide>slides/internals/php74-typed-properties-write-strict.xml</slide> + +<slide>slides/internals/lsp.xml</slide> + +<!-- VARIANCE --> +https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters +<slide>slides/internals/php74-variance-return-ok.xml</slide> +<slide>slides/internals/php74-variance-return-wrong.xml</slide> +<slide>slides/internals/php74-variance-argument-ok.xml</slide> +<slide>slides/internals/php74-variance-argument-wrong.xml</slide> +<slide>slides/internals/php74-variance-properties-ok.xml</slide> +<slide>slides/internals/php74-variance-properties-wrong.xml</slide> + +<slide>slides/internals/php80-union-types.xml</slide> +<slide>slides/internals/php80-union-types-phpdoc.xml</slide> +<slide>slides/internals/php80-union-types-new.xml</slide> +<slide>slides/internals/php80-union-types-examples.xml</slide> +<slide>slides/internals/php80-union-types-law.xml</slide> +<slide>slides/internals/php80-union-types-coercive.xml</slide> + +<!-- +Readonly properties 2.0 (https://wiki.php.net/rfc/readonly_properties_v2) +<s lide>slides/internals/php81-readonly.xml</slide> +--> + +Mixed Type v2 +<slide>slides/internals/php80-mixed-types.xml</slide> + +PHP 8.0: +https://wiki.php.net/rfc/static_return_type +static return type +<slide>slides/internals/php80-static-return.xml</slide> + + +Noreturn type (https://wiki.php.net/rfc/noreturn_type) (never) +<slide>slides/internals/php81-never-type.xml</slide> + +Pure Intersection Types (https://wiki.php.net/rfc/pure-intersection-types) +<slide>slides/internals/php81-pure-intersection.xml</slide> + +<!-- +Constructor Property Promotion +<s lide>slides/internals/php80-cpp-without.xml</slide> +<s lide>slides/internals/php80-cpp-with.xml</slide> + +<s lide>slides/internals/php80-named-without.xml</slide> +<s lide>slides/internals/php80-named-with.xml</slide> +--> + +<!-- BIG NEW FEATURES --> +Enumerations (https://wiki.php.net/rfc/enumerations) +<slide>slides/internals/php81-enums-1.xml</slide> +<slide>slides/internals/php81-enums-2.xml</slide> +<slide>slides/internals/php81-enums-3.xml</slide> +<slide>slides/internals/php81-enums-4.xml</slide> +<slide>slides/internals/php81-enums-5.xml</slide> +<slide>slides/internals/php81-enums-6.xml</slide> +<slide>slides/internals/php81-enums-7.xml</slide> + +PHP 8.2: + +https://wiki.php.net/rfc/null-false-standalone-types +'null' and 'false' as standalone +<slide>slides/internals/php82-null-false-standalone.xml</slide> + +https://wiki.php.net/rfc/true-type +'true' type +<slide>slides/internals/php82-true.xml</slide> + +https://wiki.php.net/rfc/dnf_types +? Disjunctive Normal Form Types +<slide>slides/internals/php82-dnf-types.xml</slide> + +<slide>slides/xdebug/phpinternalsnews.xml</slide> + +<slide>slides/internals/questions-new.xml</slide> +<slide>slides/xdebug/resources.xml</slide> + +</presentation> diff --git a/php-phpuk22.xml b/php-phpuk22.xml index 464bf28c..92bf4918 100644 --- a/php-phpuk22.xml +++ b/php-phpuk22.xml @@ -8,7 +8,7 @@ <speaker>Derick Rethans</speaker> <email>[email protected]</email> <twitter>derickr</twitter> -<url></url> +<url>https://derickrethans.nl/talks/php-phpuk22</url> <joindin></joindin> <slide>slides/xdebug/title.xml</slide> <slide>slides/mongodb/me.xml</slide> @@ -47,19 +47,6 @@ New in Initialisers (https://wiki.php.net/rfc/new_in_initializers) <slide>slides/internals/php81-new-in-initialisers.xml</slide> <slide>slides/internals/php81-new-in-initialisers-locations.xml</slide> -<!-- -Auto-capturing multi-statement closures (https://wiki.php.net/rfc/auto-capture-closure) -<slide>slides/internals/php81-auto-capture-multi-statement-closures.xml</slide> ---> - -<!-- -Property Accessors (https://wiki.php.net/rfc/property_accessors) -<slide>slides/internals/php81-property-accessors.xml</slide> -<slide>slides/internals/php81-property-accessors-implicit.xml</slide> -<slide>slides/internals/php81-property-accessors-explicit.xml</slide> -<slide>slides/internals/php81-property-accessors-interface.xml</slide> ---> - Readonly properties 2.0 (https://wiki.php.net/rfc/readonly_properties_v2) <slide>slides/internals/php81-readonly.xml</slide> diff --git a/slides/internals/barbara-liskov.jpg b/slides/internals/barbara-liskov.jpg new file mode 100644 index 00000000..0630a4ef Binary files /dev/null and b/slides/internals/barbara-liskov.jpg differ diff --git a/slides/internals/lsp.xml b/slides/internals/lsp.xml new file mode 100644 index 00000000..12027fdc --- /dev/null +++ b/slides/internals/lsp.xml @@ -0,0 +1,15 @@ +<slide> +<title>Liskov Substitution Principle</title> + +<image align="right" attr="By Kenneth C. Zirkel - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=32799771" filename="barbara-liskov.jpg"/> +<blurb>Introduced by Barbara Liskov</blurb> +<break lines="3"/> + +<blurb>A child class must be able to be used in place of a parent class</blurb> + +<list> + <bullet>Return types can return a more specific (narrower) type ~(covariance)~</bullet> + <bullet>Argument types can accept a more restricted (wider) type ~(contravariance)~</bullet> + <bullet>Property types can not change ~(invariance)~</bullet> +</list> +</slide> diff --git a/slides/internals/php74-typed-properties-read.xml b/slides/internals/php74-typed-properties-read.xml index fc31b8cf..a4986d16 100644 --- a/slides/internals/php74-typed-properties-read.xml +++ b/slides/internals/php74-typed-properties-read.xml @@ -5,20 +5,21 @@ <?php class 🥃whisky { - public int $age; - protected Distillery $distillery; + public string $name; + private int $age; + private Distillery $distillery; private ?Bottler $bottler; } $whisky = new 🥃whisky; -echo $whisky->age; +echo $whisky->name; ?> </example> <break/> <div effect="fade-in"> <blurb class="error"> -Error: Typed property 🥃whisky::$age must not be accessed before initialization +Error: Typed property 🥃whisky::$name must not be accessed before initialization </blurb> <break lines="2"/> diff --git a/slides/internals/php74-typed-properties-write-coersive.xml b/slides/internals/php74-typed-properties-write-coersive.xml index 4fc95766..94cf4ea4 100644 --- a/slides/internals/php74-typed-properties-write-coersive.xml +++ b/slides/internals/php74-typed-properties-write-coersive.xml @@ -5,9 +5,9 @@ <?php class 🥃whisky { + public string $name; public int $age; - protected Distillery $distillery; - private ?Bottler $bottler; + private Distillery $distillery; } $whisky = new 🥃whisky; diff --git a/slides/internals/php74-typed-properties-write-strict.xml b/slides/internals/php74-typed-properties-write-strict.xml index b8de11ff..45dec137 100644 --- a/slides/internals/php74-typed-properties-write-strict.xml +++ b/slides/internals/php74-typed-properties-write-strict.xml @@ -7,9 +7,9 @@ declare(strict_types=1); class 🥃whisky { + public string $name; public int $age; - public Distillery $distillery; - private ?Bottler $bottler; + private Distillery $distillery; } $whisky = new 🥃whisky; diff --git a/slides/internals/php74-typed-properties-write.xml b/slides/internals/php74-typed-properties-write.xml index 7fe5a44e..2c8b8052 100644 --- a/slides/internals/php74-typed-properties-write.xml +++ b/slides/internals/php74-typed-properties-write.xml @@ -5,7 +5,8 @@ <?php class 🥃whisky { - public int $age; + public string $name; + private int $age; public Distillery $distillery; private ?Bottler $bottler; } diff --git a/slides/internals/php74-typed-properties.xml b/slides/internals/php74-typed-properties.xml index 7f7f2ca5..5f3496ae 100644 --- a/slides/internals/php74-typed-properties.xml +++ b/slides/internals/php74-typed-properties.xml @@ -13,8 +13,9 @@ class 🥃whisky All types with the exception of %void% and %callable% are supported: </blurb> <example> - public int $age; - protected Distillery $distillery; + public string $name; + private int $age; + private Distillery $distillery; private ?Bottler $bottler; </example> </div> @@ -23,7 +24,10 @@ All types with the exception of %void% and %callable% are supported: Types are also legal on static properties: </blurb> <example> - public static iterable $tastingNotes; + /** + * @var TastingNote[] + */ + public static array $tastingNotes; </example> </div> <div effect="fade-in"> @@ -32,15 +36,6 @@ All types with the exception of %void% and %callable% are supported: </blurb> <example> public int $rating = 92; - public ?string $nullableStr = null; -</example> -</div> -<div effect="fade-in"> -<blurb> - The type applies to all properties in one declaration: -</blurb> -<example> - public bool $chillFiltered, $colouringAdded; } </example> </div> diff --git a/slides/internals/php74-untyped-properties.xml b/slides/internals/php74-untyped-properties.xml new file mode 100644 index 00000000..979950b2 --- /dev/null +++ b/slides/internals/php74-untyped-properties.xml @@ -0,0 +1,29 @@ +<slide> +<title>Example Class</title> + +<example> +<?php +class 🥃whisky +{ + /** + * @var string + */ + public $name; + + /** + * @var Distillery + */ + private $distillery; + + /** + * @var Bottler|null + */ + private $bottler; + + /** + * @var TastingNote[] + */ + public $tastingNotes; +} +</example> +</slide> diff --git a/slides/internals/php74-variance-argument-ok.xml b/slides/internals/php74-variance-argument-ok.xml index 14793d6e..1fce17f4 100644 --- a/slides/internals/php74-variance-argument-ok.xml +++ b/slides/internals/php74-variance-argument-ok.xml @@ -19,6 +19,6 @@ class Gauls extends Asterix </example> <break lines="2"/> -<blurb class="center">Arguments types are *contra-variant*:<br/>~they can accept a more broad type~</blurb> +<blurb class="center">Arguments types are *contra-variant*:<br/><br/>~they can accept a wider type~</blurb> </slide> diff --git a/slides/internals/php74-variance-argument-wrong.xml b/slides/internals/php74-variance-argument-wrong.xml index 55ea8ff6..5600c28f 100644 --- a/slides/internals/php74-variance-argument-wrong.xml +++ b/slides/internals/php74-variance-argument-wrong.xml @@ -20,6 +20,6 @@ class Gauls extends Asterix <blurb class="error">Warning: Declaration of Gauls::hunt(🐗boar $animal) should be compatible with Asterix::hunt(🐖pig $animal)</blurb> <break lines="2"/> -<blurb class="center">Arguments types are *contra-variant*:<br/>~they can *not* accept a more specific type~</blurb> +<blurb class="center">Arguments types are *contra-variant*:<br/><br/>~they can *not* accept a narrower type~</blurb> </slide> diff --git a/slides/internals/php74-variance-properties-ok.xml b/slides/internals/php74-variance-properties-ok.xml index 65380820..ca734880 100644 --- a/slides/internals/php74-variance-properties-ok.xml +++ b/slides/internals/php74-variance-properties-ok.xml @@ -24,6 +24,6 @@ class Galileo extends Copernicus </example> <break lines="2"/> -<blurb class="center">Property types are *in-variant*:<br/>~they can *not* represent a more specific or a more broad type~</blurb> +<blurb class="center">Property types are *in-variant*:<br/><br/>~they can *not* represent a more specific or a more broad type~</blurb> </slide> diff --git a/slides/internals/php74-variance-properties-wrong.xml b/slides/internals/php74-variance-properties-wrong.xml index 4f18741f..a3228211 100644 --- a/slides/internals/php74-variance-properties-wrong.xml +++ b/slides/internals/php74-variance-properties-wrong.xml @@ -25,6 +25,6 @@ class Galileo extends Copernicus <blurb class="error">Fatal error: Type of Galileo::$gravity must be 🌐sphere (as in class Copernicus)</blurb> <break lines="2"/> -<blurb class="center">Property types are *in-variant*:<br/>~they can *not* represent a more specific or a more broad type~</blurb> +<blurb class="center">Property types are *in-variant*:<br/><br/>~they can *not* represent a more specific or a more broad type~</blurb> </slide> diff --git a/slides/internals/php74-variance-return-ok.xml b/slides/internals/php74-variance-return-ok.xml index 4f2f5abc..e718f82a 100644 --- a/slides/internals/php74-variance-return-ok.xml +++ b/slides/internals/php74-variance-return-ok.xml @@ -24,6 +24,9 @@ class Patisserie extends Bakery </example> <break lines="2"/> -<blurb class="center">Return types are *co-variant*:<br/>~they can return a more specific type~</blurb> +<blurb class="center"> + Return types are *co-variant*:<br/><br/> + ~they can return a more specific (narrower) type~ +</blurb> </slide> diff --git a/slides/internals/php74-variance-return-wrong.xml b/slides/internals/php74-variance-return-wrong.xml index 736d976d..abe58e91 100644 --- a/slides/internals/php74-variance-return-wrong.xml +++ b/slides/internals/php74-variance-return-wrong.xml @@ -25,6 +25,6 @@ class Patisserie extends Bakery <blurb class="error">Fatal error: Declaration of Patisserie::gimme(): 🍞bread must be compatible with Bakery::gimme(): 🥖baguette</blurb> <break lines="2"/> -<blurb class="center">Return types are *co-variant*:<br/>~they can *not* return a more broad type~</blurb> +<blurb class="center">Return types are *co-variant*:<br/><br/>~they can *not* return a wider type~</blurb> </slide> diff --git a/slides/internals/php80-named-with.xml b/slides/internals/php80-named-with.xml index 5a8d53c8..885a4cf8 100644 --- a/slides/internals/php80-named-with.xml +++ b/slides/internals/php80-named-with.xml @@ -6,11 +6,11 @@ class Settings { function __construct( - public $includeDistillery = true, - public $includeDescription = true, - public $includeTastingNotes = false, - public $pageSize = 64, - public $sortByField = 'whisky', + public bool $includeDistillery = true, + public bool $includeDescription = true, + public bool $includeTastingNotes = false, + public int $pageSize = 64, + public string $sortByField = 'whisky', ) {} } </example> diff --git a/slides/internals/php80-named-without.xml b/slides/internals/php80-named-without.xml index c6ad9072..8cbc9d80 100644 --- a/slides/internals/php80-named-without.xml +++ b/slides/internals/php80-named-without.xml @@ -6,11 +6,11 @@ class Settings { function __construct( - public $includeDistillery = true, - public $includeDescription = true, - public $includeTastingNotes = false, - public $pageSize = 64, - public $sortByField = 'whisky', + public bool $includeDistillery = true, + public bool $includeDescription = true, + public bool $includeTastingNotes = false, + public int $pageSize = 64, + public string $sortByField = 'whisky', ) {} } </example> diff --git a/slides/internals/php80-static-return.xml b/slides/internals/php80-static-return.xml new file mode 100644 index 00000000..bd6ec2e1 --- /dev/null +++ b/slides/internals/php80-static-return.xml @@ -0,0 +1,29 @@ +<slide> +<title>%static% return type</title> + +<blurb>%self% is a special keyword that refers to the class that the method was *defined* on</blurb> +<blurb>%static% is a special keyword that refers to the class that the method was *called* on</blurb> + +<example inline="1"> +<![CDATA[<?php +class Article +{ + private function __construct(private string $title) {} + + static function createWithTitle(string $title) : *static* { + return new *static*("A: {$title}"); + } +} + +class Document extends Article +{ +} + +$a = Article::createWithTitle('Article'); +$d = Document::createWithTitle('Document'); + +var_dump($a, $d); + +?>]]></example> +</slide> + diff --git a/slides/internals/php80-union-types-coercive.xml b/slides/internals/php80-union-types-coercive.xml index c6e4a8ba..630d42c1 100644 --- a/slides/internals/php80-union-types-coercive.xml +++ b/slides/internals/php80-union-types-coercive.xml @@ -12,7 +12,7 @@ <example inline="1"> // type: *int|string* 42.0 → 42 // *float* compatible with *int* -42.1 → 42 // *float* compatible with *int* +42.1 → 42 // *float* compatible with int *(deprecated in PHP 8.1)* 1e100 → "1.0E+100" // *float* too large for *int* type, fall back to *string* INF → "INF" // *float* too large for *int* type, fall back to *string* true → 1 // *bool* compatible with *int* diff --git a/slides/internals/php82-deprecate-dynamic-properties.xml b/slides/internals/php82-deprecate-dynamic-properties.xml new file mode 100644 index 00000000..5201de8a --- /dev/null +++ b/slides/internals/php82-deprecate-dynamic-properties.xml @@ -0,0 +1,42 @@ +<slide> +<title>Deprecating Dynamic Properties</title> + +<example> +<![CDATA[<?php +class ezcGraphDataSet +{ + protected $pallet; + + function setPalette( $palette ) + { + $this->palette = $palette; + } +} + +$e = new ezcGraphDataSet; +$e->setPalette( 'rgb' ); +]]></example> + +<div effect="fade-in"> +<example class="error"> +Deprecated: Creation of dynamic property ezcGraphDataSet::$palette is deprecated +</example> +</div> + +<div effect="fade-in"> +<example class="small"> +--- src/datasets/base.php ++++ src/datasets/base.php +@@ -83,7 +83,7 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable + * + * @var ezcGraphPalette + */ +- protected $pallet; ++ protected $palette; + + /** + * Array keys +</example> +</div> + +</slide> diff --git a/slides/internals/php82-dnf-types.xml b/slides/internals/php82-dnf-types.xml new file mode 100644 index 00000000..33255c32 --- /dev/null +++ b/slides/internals/php82-dnf-types.xml @@ -0,0 +1,59 @@ +<slide> +<title>PHP 8.2: DNF Types</title> + +<blurb class="centre">Union Types: *%X|Y%*</blurb> + +<div effect="fade-in-out"> +<example inline="1"><![CDATA[ +class Number { + private *int|float* $number; + + public function setNumber(*int|float* $number): void { + $this->number = $number; + } + + public function getNumber(): *int|float* { + return $this->number; + } +} +]]></example> +</div> + +<blurb class="centre">(Pure) Intersection Types: *%X&Y%*</blurb> + +<div effect="fade-in-out"> +<example inline="1"><![CDATA[ +class Iteraty { + private *Traversable&Countable* $countableIterator; + + public function setIterator(*Traversable&Countable* $countableIterator): void { + $this->countableIterator = $countableIterator; + } + + public function getIterator(): *Traversable&Countable* { + return $this->countableIterator; + } +} +]]></example> +</div> + +<blurb class="centre">Disjunctive Normal Form Types: *%(X&A)|(Y&B)%*</blurb> + +<div effect="fade-in-out"> +<example inline="1"><![CDATA[ +class Foreachy { + private *array|(Traversable&Countable)* $foreachableData; + + public function setIterator(*array|(Traversable&Countable)* $foreachable): void { + $this->foreachableData = $foreachable; + } + + public function getIterator(): *array(Traversable&Countable)* { + return $this->foreachableData; + } +} +]]></example> +</div> + +</slide> + diff --git a/slides/internals/php82-enums-1.xml b/slides/internals/php82-enums-1.xml new file mode 100644 index 00000000..bd46a347 --- /dev/null +++ b/slides/internals/php82-enums-1.xml @@ -0,0 +1,40 @@ +<slide> +<title>Enumerations — Fetch Properties</title> + +<div effect="fade-out"> +<example><![CDATA[<?php +enum Currency: string { + case GBP = '£'; + case EUR = '€'; +} + +const PRICES = [ + Currency::EUR => 19.99, + Currency::GBP => 17.99, +]; +]]></example> + +<blurb>PHP 8.1:</blurb> +<example class="result"> +Fatal error: Constant expression contains invalid operations +</example> +<blurb>PHP 8.2:</blurb> +<example class="result"> +Fatal error: Constant expression contains invalid operations +</example> +</div> + +<div effect="fade-in"> +<example inline="1"><![CDATA[<?php +enum Currency: string { + case GBP = '£'; + case EUR = '€'; +} + +const PRICES = [ + Currency::EUR*->value* => 19.99, + Currency::GBP*->value* => 17.99, +];]]></example> +</div> + +</slide> diff --git a/slides/internals/php82-null-false-standalone.xml b/slides/internals/php82-null-false-standalone.xml new file mode 100644 index 00000000..a44005f8 --- /dev/null +++ b/slides/internals/php82-null-false-standalone.xml @@ -0,0 +1,25 @@ +<slide> +<title>PHP 8.2: %null% and %false% types</title> + +<list> +<bullet>%false% could only be used as part of a union (i.e. %string|false%)</bullet> +<bullet>But not as %null|false% and had to use %null|bool%</bullet> +<bullet>You could not use %null% standalone, even though it's a narrower type: +<example inline="1"><![CDATA[<?php +class User {} + +class UserFinder { + function findUserByEmail(string $email) : User|null {} +} + +class AlwaysNullUserFinder extends UserFinder { + function findUserByEmail(string $email) : ---null--- {} +} +?>]]></example> +</bullet> +</list> + +<blurb>%void% means: Does not return *anything*</blurb> +<blurb>%null% means: Does return the *null* value</blurb> +</slide> + diff --git a/slides/internals/php82-readonly.xml b/slides/internals/php82-readonly.xml new file mode 100644 index 00000000..c63a3f3e --- /dev/null +++ b/slides/internals/php82-readonly.xml @@ -0,0 +1,21 @@ +<slide> +<title>Readonly Classes</title> + +<blurb>From PHP 8.2, marking all properties as %readonly%:</blurb> +<example inline="1"><![CDATA[<?php +*readonly* class User +{ + public function __construct(public string $name) {} +} +]]></example> + +<div effect="fade-in"> +<break lines="2"/> +<blurb>Additionally:</blurb> +<list> + <bullet>Prevents dynamic properties from being created</bullet> + <bullet>Can't be used if there are untyped or static properties</bullet> +</list> +</div> + +</slide> diff --git a/slides/internals/php82-redact-parameters.xml b/slides/internals/php82-redact-parameters.xml new file mode 100644 index 00000000..1f27a758 --- /dev/null +++ b/slides/internals/php82-redact-parameters.xml @@ -0,0 +1,37 @@ +<slide> +<title>Sensitive Parameters</title> + +<example><![CDATA[<?php +function logIn($userName, #[\SensitiveParameter] $password) { + throw new \Exception('Error'); +} + +logIn( 'derick', 'secret-elephpant' );]]></example> + +<div effect="fade-in-out"> +<break/> +<blurb>Without Xdebug:</blurb> +<example class="error" inline="1"> +Fatal error: Uncaught Exception: Error in Standard input code:4 +Stack trace: +#0 Standard input code(7): logIn('derick', *Object(SensitiveParameterValue)*) +#1 {main} + thrown in Standard input code on line 4 +</example> +</div> + +<div effect="fade-in"> +<break/> +<blurb>With Xdebug:</blurb> +<example class="error" inline="1"> +Fatal error: Uncaught Exception: Error in Standard input code on line 4 + +Exception: Error in Standard input code on line 4 + +Call Stack: + 4.8626 399576 1. {main}() Standard input code:0 + 4.8626 399576 2. logIn($userName = 'derick', $password = *'[Sensitive Parameter]'*) Standard input code:7 +</example> +</div> + +</slide> diff --git a/slides/internals/php82-true.xml b/slides/internals/php82-true.xml new file mode 100644 index 00000000..f04bcaba --- /dev/null +++ b/slides/internals/php82-true.xml @@ -0,0 +1,10 @@ +<slide> +<title>PHP 8.2: %true% type</title> + +<break lines="5"/> +<blurb class="center">We had %false% and %null%, but not %true%</blurb> + +<blurb class="emoji">🤦</blurb> + +</slide> + diff --git a/slides/internals/type-history.xml b/slides/internals/type-history.xml new file mode 100644 index 00000000..308e5658 --- /dev/null +++ b/slides/internals/type-history.xml @@ -0,0 +1,281 @@ +<slide> +<title>Type Safety</title> + +<div effect="fade-out"> +<break lines="5"/> +<blurb class="big-centre">~the extent to which a programming language~<br/>~*discourages* or *prevents* type errors~</blurb> +</div> + +<div effect="fade-in-out"> + <blurb>*PHP 5.0*: Class name hints</blurb> + <table class="two"><tr> + <td><example><![CDATA[ +<?php +class Whisky +{ +} + +function drink($whisky) +{ +} + +$w = new Whisky; +drink($w); +?> + ]]></example></td> + <td><example inline="1"><![CDATA[ +<?php +class Whisky +{ +} + +function drink(*Whisky* $whisky) +{ +} + +$w = new Whisky; +drink($w); +?> + ]]></example></td> + </tr></table> +</div> + +<div effect="fade-in-out"> + <blurb>*PHP 5.1*: array typehint</blurb> + <table class="two"><tr> + <td><example><![CDATA[ +<?php +class Article +{ + public function renderNotes($notes) + { + foreach ($notes as $note) + { + } + } +} + +$a = new Article; + +$a->renderNotes( + array( + 'This was helpful', + 'This was really helpful' + ) +); +?> + ]]></example></td> + <td><example inline="1"><![CDATA[ +<?php +class Article +{ + public function renderNotes(*array* $notes) + { + foreach ($notes as $note) + { + } + } +} + +$a = new Article; + +$a->renderNotes( + array( + 'This was helpful', + 'This was really helpful' + ) +); +?> + ]]></example></td> + </tr></table> +</div> +<!-- +<div effect="fade-in-out"> + https://wiki.php.net/rfc/callable + <blurb>*PHP 5.4*: callable typehint</blurb> + <table class="two"><tr> + <td><example><![CDATA[ + ]]></example></td> + <td><example><![CDATA[ + ]]></example></td> + </tr></table> +</div> +--> +<div effect="fade-in-out"> + https://wiki.php.net/rfc/scalar_type_hints_v5 + <blurb>*PHP 7.0*: Scalar Type Declarations (v5)</blurb> + <table class="two"><tr> + <td><example><![CDATA[ +<?php +function getObject($oid) +{ +} + +getObject("12"); +?> + ]]></example></td> + <td><example inline="1"><![CDATA[ +<?php +*declare(strict_types=1);* +function getObject(*int* $oid) +{ +} + +getObject("12"); +?> + ]]></example> + <example>Uncaught TypeError: getObject(): + Argument #1 ($oid) must be of type int, string given</example></td> + </tr></table> +</div> + +<div effect="fade-in-out"> + https://wiki.php.net/rfc/return_types + <blurb>*PHP 7.0*: Return type declarations</blurb> + <table class="two"><tr> + <td><example><![CDATA[ +<?php +class Article +{ + public function getComments() + { + return array(); + } +} + ]]></example></td> + <td><example inline="1"><![CDATA[ +<?php +class Article +{ + public function getComments() *: array* + { + return array(); + } +} + ]]></example></td> + </tr></table> +</div> + +<div effect="fade-in-out"> + https://wiki.php.net/rfc/nullable_types + <blurb>*PHP 7.1*: Nullable types</blurb> + <table class="two"><tr> + <td><example><![CDATA[ +<?php +declare(strict_types=1); +function getObject(int $oid) +{ +} + +getObject(12); +getObject(null); +?> + ]]></example></td> + <td><example inline="1"><![CDATA[ +<?php +declare(strict_types=1); +function getObject(*?*int $oid) +{ +} + +getObject(12); +getObject(null); +?> + ]]></example></td> + </tr></table> +</div> + +<div effect="fade-in-out"> + https://wiki.php.net/rfc/void_return_type + <blurb>*PHP 7.1*: Void return type</blurb> + <table class="two"><tr> + <td><example><![CDATA[ +<?php declare(strict_types=1); + +class Article +{ + public function addNote(Note $n) + { + } +} + +$a = new Article; +$a->addNote(new Note("It was lovely")); +?> + ]]></example></td> + <td><example inline="1"><![CDATA[ +<?php declare(strict_types=1); + +class Article +{ + public function addNote(Note $n) *: null* + { + } +} + +$a = new Article; +$a->addNote(new Note("It was lovely")); +?> + ]]></example></td> + </tr></table> +</div> + +<!-- +<div effect="fade-in-out"> + https://wiki.php.net/rfc/object-typehint + <blurb>*PHP 7.2*: %object% Type Hint</blurb> + <table class="two"><tr> + <td><example><![CDATA[ + ]]></example></td> + <td><example><![CDATA[ + ]]></example></td> + </tr></table> +</div> +--> + +<div effect="fade-in-out"> + https://wiki.php.net/rfc/parameter-no-type-variance + <blurb>*PHP 7.2*: Parameter type widening</blurb> + <table class="two"><tr> + <td><example inline="1"><![CDATA[ +<?php +class LibraryArticle +{ + public function getSlug(string $title) : void + { + } +} + +class MyArticle extends Article +{ + public function getSlug($title) : void + { + } +} + ]]></example> + <example> +Warning: Declaration of + MyArticle::getSlug($title): void + should be compatible with + LibraryArticle::getSlug(string $title): void + </example></td> + <td><example inline="1"><![CDATA[ +<?php +class LibraryArticle +{ + public function getSlug(string $title) : void + { + } +} + +class MyArticle extends Article +{ + public function getSlug($title) : void + { + } +} + ]]></example></td> + </tr></table> +</div> + +</slide>