Slide 1

Slide 1 text

·ͩࢲ͸ PHP8Λ஌Βͳ͍ͷͰ
 ௐ΂ͯΈΔձ ࣾ಺ษڧձ༻εϥΠυ Hideki Kinjyo GitHub: o0h / Twitter: @o0h_ /

Slide 2

Slide 2 text

ࣗݾ঺հ / GitHub: @o h / Twitter: @o h_ ( ) RIcky Rubio

Slide 3

Slide 3 text

PHP etc 視

Slide 4

Slide 4 text

PHP PHP

Slide 5

Slide 5 text

$ PHP

Slide 6

Slide 6 text

cite from [PHP: PHP \. \. Release Announcement](https://www.php.net/releases/ . /en.php)

Slide 7

Slide 7 text

cite from [PHP: PHP \. \. Release Announcement](https://www.php.net/releases/ . /en.php) ͜ͷΞοϓσʔτʹ͸ɺ
 ͨ͘͞Μͷ৽ػೳ΍࠷దԽؚ͕·Ε͍ͯ·͢ɻ

Slide 8

Slide 8 text

3 . JIT(Just-In-Time compilation) . Attribute . Union types 3 3 JIT Uninon Types 複

Slide 9

Slide 9 text

( ) `==`

Slide 10

Slide 10 text

Error ( ) PHP -> !!! ( Error) PHP -> ( | )

Slide 11

Slide 11 text

: Error \Throwable catch https://daisuki.nichiyoubi.land/entry/ / / / [phpconfuk ] - YouTube https://www.youtube.com/watch?v=QDbp cR Dc

Slide 12

Slide 12 text

migration guide PHP: PHP . .x PHP . .x - Manual https://www.php.net/manual/ja/migration .php @rana_kualu PHP . PHP . - Qiita https://qiita.com/rana_kualu/items/fe fbe d d PHP . - Qiita https://qiita.com/rana_kualu/items/c cb c ee c php.watch PHP . : What's New and Changed PHP.Watch https://php.watch/versions/ .

Slide 13

Slide 13 text

$ . JIT(Just-In-Time compilation)

Slide 14

Slide 14 text

JIT (JIT) PHP( ) OP VM PHP

Slide 15

Slide 15 text

OPCache PHP . OP OP VM

Slide 16

Slide 16 text

Preload PHP . On server startup ( )

Slide 17

Slide 17 text

JIT PHP . OP VM

Slide 18

Slide 18 text

:youtube:

Slide 19

Slide 19 text

Web JIT (bench.php) 2.78 PHP-Parser 2.11 WordPress 1.05 IMO: Web App

Slide 20

Slide 20 text

$ . Attribute

Slide 21

Slide 21 text

Attribute PHP Similar concepts exist in other languages named Annotations in Java, Attributes in C#, C++, Rust, Hack and Decorators in Python, Javascript. https://wiki.php.net/rfc/attributes_v doc-comment

Slide 22

Slide 22 text

syntax `#[sukinamono]` class, property, method `#[Attribute]` attribute attribute Re ection

Slide 23

Slide 23 text

syntax `#[sukinamono]` class, property, method `#[Attribute]` attribute attribute Re ection attributeԽ Ҿ਺ΛऔΕΔ Reflectionܦ༝Ͱ
 ΞΫηε ௚Ͱinstanceੜ੒ ෳ਺OK

Slide 24

Slide 24 text

syntax `#[sukinamono]` class, property, method `#[Attribute]` attribute attribute Re ection array(3) { ["name"]=> string(10) "MyNs\Attr1" ["args"]=> array(0) { } ["instance"]=> object(MyNs\Attr1)#4 (0) { } } array(3) { ["name"]=> string(10) "MyNs\Attr2" ["args"]=> array(1) { [0]=> int(10) } ["instance"]=> object(MyNs\Attr2)#4 (1) { ["value":"MyNs\Attr2":private]=> int(10) } }

Slide 25

Slide 25 text

: PHP PHP Attribute - Shin x Blog https://blog.shin x .com/entry/history-of-php -attribute

Slide 26

Slide 26 text

doc-comment FW AOP JetBrains/phpstorm-attributes https://github.com/JetBrains/phpstorm-attributes

Slide 27

Slide 27 text

$ . Union Types

Slide 28

Slide 28 text

Union Types TypeScript union doc comment( )

Slide 29

Slide 29 text

syntax `A|B|C` `void` false `A|false` `true` `A|true` (`bool` ) ҧ൓

Slide 30

Slide 30 text

syntax `A|B|C` `void` false `A|false` `true` `A|true` (`bool` ) object(SpecialDay)#1 (0) { } object(SpecialDay)#1 (0) { } Fatal error: Uncaught TypeError: SpecialDay::create(): Argument #1 ($dow) must be of type string|int, bool given, called in /in/oPlMf on line 17 and defined in /in/oPlMf:5 Stack trace: #0 /in/oPlMf(17): SpecialDay::create(false) #1 {main} thrown in /in/oPlMf on line 5

Slide 31

Slide 31 text

ェ `mixed` IDE TypeError

Slide 32

Slide 32 text

$ PHP ~ n~

Slide 33

Slide 33 text

$2

Slide 34

Slide 34 text

( PHP

Slide 35

Slide 35 text

= =

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

`$iterator` 釈 視 `$item` `doSome()` ( ) `foreach` `$iterator`

Slide 39

Slide 39 text

`array_map()` ( ) ( ) `strlen($var)` `str_split + count` ( ) contable `$var` ( `$var` ) ( )

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

DRY

Slide 42

Slide 42 text

( ) ( )

Slide 43

Slide 43 text

1 => 100 100 Golang:

Slide 44

Slide 44 text

PHP

Slide 45

Slide 45 text

$2 ~ n~

Slide 46

Slide 46 text

$ PHP

Slide 47

Slide 47 text

͜ͷลΓͷ࿩ .constructor property promotion .named arguments .match expression .nullsafe operator .throw expression .Non-capturing catches .str_contains(), str_starts_ with(), str_ends_with()

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

constructor property promotion Kotlin ( ) object(Hoge)#1 (2) { ["a":"Hoge":private]=> int(10) ["x":protected]=> string(3) "aaa" }

Slide 50

Slide 50 text

named arguments Python `name:` `method($a, null, null, null, $z)` API array(3) { ["a"]=> int(1) ["b"]=> int(2) [“d"]=> int(20) }

Slide 51

Slide 51 text

match expression switch case switch 釈(= ) (switch ) (`===`) OR `,` switch `break` Error string(14) "very happy day"

Slide 52

Slide 52 text

nullsafe operator JS, Kotlin, Swift, Ruby `->method()` `?->method()` NULL `isset()` array(2) { ["x"]=> NULL ["y"]=> NULL }

Slide 53

Slide 53 text

throw expression C# `throw` NULL match Fatal error: Uncaught NotFoundException in /in/5NOp3:9 Stack trace: #0 {main} thrown in /in/5NOp3 on line 9

Slide 54

Slide 54 text

Non-capturing catches `catch()` OK 視 domain violation

Slide 55

Slide 55 text

str_contains(), str_starts_with(), str_ends_with() ( 0 false ) `strpos` array(3) { [0]=> bool(true) [1]=> bool(true) [2]=> bool(false) }

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

$ PHP ~ n~

Slide 58

Slide 58 text

$

Slide 59

Slide 59 text

PHP Type/ Error JIT 7.4 8 `curl_init()` `resource` `CurlHandle` `==`

Slide 60

Slide 60 text

#19-#68

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

( ) ( ) ( Error ) MUST

Slide 63

Slide 63 text

PHP

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

PHP8จݙ • ެࣜͷmigration guide ◦ PHP: PHP 7.4.x ͔Β PHP 8.0.x ΁ͷҠߦ - Manual https://www.php.net/manual/ja/ migration80.php • ͓ͳ͡Έ @rana_kualu͞Μ ◦ ʲPHP8.0ʳPHP8.0ͷ৽ػೳ - Qiita https://qiita.com/ rana_kualu/items/fe7998fbe773544d5d25] ◦ ΋͏1ͭ PHP8.0͕ϦϦʔε͞ΕͨͷͰ৽ػೳશ෦΍ Δ - Qiita https://qiita.com/rana_kualu/items/ c110cb244c3ee38c6859 • php.watch ◦ PHP 8.0: What's New and Changed • PHP.Watch https://php.watch/versions/8.0 • stitcher.io ◦ What's new in PHP 8 - stitcher.io https://stitcher.io/ blog/new-in-php-8 JIT • https://wiki.php.net/rfc/jit PHP: rfc:jit • https://hackmd.io/@hrxVDayfRGeTR-1JBV3QLA/Hk5oOkp4w ShowNoteɿʲΦϯϥΠϯʳPHPerʹΑΔ PHPerͷͨΊͷʮʰPHP8ʱͷχϡʔε΍هࣄΛޠΓ߹͏ʯTechCafe @ RAKUS 9݄ - HackMD • https://www.php.net/manual/ja/opcache.preloading.php PHP: ίʔυͷࣄલϩʔυ - Manual • https://www.slideshare.net/hnw/zend-opcache Zend OPcacheͷ଎͞ͷൿີΛ୳Δ • https://www.slideshare.net/hnw/opcache OPcacheͷ৽ػೳϑΝΠϧϕʔεΩϟογϡͷ಺෦࣮૷ΛಡΜͰ Έͨ • https://www.unitrust.co.jp/8752 PHP7.4Ͱಋೖ͞ΕΔPreload(ϓϦϩʔυ)ͬͯԿʁ | UNITRUST • https://tech.akat.info/?p=1371 PHP࣮ߦ·ͰͷྲྀΕͱOPcache – ๨ΕΔͨΊʹه͢ • https://www.slideshare.net/hirokawa/php2019-202563364 PHPͷࠓͱ͜Ε͔Β2019(ͷ#24ʙ) • https://japan.zdnet.com/article/35163100/ ʮPHP 8ʯϦϦʔεɺJITίϯύΠϥʔಋೖ͸ੋ͔ඇ͔ - ZDNet Japan • https://qiita.com/rana_kualu/items/ba312d2789bd228f887a ʲPHP8.0ʳPHPͰJIT͕࢖͑ΔΑ͏ʹͳΔ - Qiita • https://qiita.com/rana_kualu/items/73c346b3feadfa3a5b21 PHP8.0.0α1͕ϦϦʔε͞ΕͨͷͰͬͦ͘͞JIT ͷҖྗΛମײ͢Δ(ͨ͠) - Qiita • https://stitcher.io/blog/php-jit PHP 8: The JIT - stitcher.io • https://tech.fusic.co.jp/posts/2020-11-28-php8-jit-compared-speed-with-php7/ PHP8ͷJITΛ༗ޮʹͯ͠ɺ PHP7ͱ଎౓ൺֱ͢Δ - Fusic Tech Blog • https://php.watch/versions/8.0/JIT JIT - PHP 8.0 • PHP.Watch Attribute • https://tadsan.fanbox.cc/posts/1052551 PHP8 <>ΛޠΖ͏ #phpkansai ʛtadsanʛpixivFANBOX • https://stitcher.io/blog/attributes-in-php-8 PHP 8: Attributes - stitcher.io • https://qiita.com/rana_kualu/items/749c389a275f207a8e58 ʲPHP8.0ʳPHPͰΞτϦϏϡʔτ/Ξϊςʔ γϣϯ/σίϨʔλ͕ॻ͚ΔΑ͏ʹͳΔ - Qiita