Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP8の事を調べてみました / hello-php8

PHP8の事を調べてみました / hello-php8

12月初頭に社内でちょっと話す機会があったので、
「タイミング的にホットじゃない??」ってことでPHP8の事を調べてみました

C90bac78c0fb61105cfd8239767f903d?s=128

hideki kinjyo
PRO

December 12, 2020
Tweet

Transcript

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

    @o0h_ /
  2. ࣗݾ঺հ / GitHub: @o h / Twitter: @o h_ (

    ) RIcky Rubio
  3. PHP etc 視

  4. PHP PHP

  5. $ PHP

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

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

    ͜ͷΞοϓσʔτʹ͸ɺ
 ͨ͘͞Μͷ৽ػೳ΍࠷దԽؚ͕·Ε͍ͯ·͢ɻ
  8. 3 . JIT(Just-In-Time compilation) . Attribute . Union types 3

    3 JIT Uninon Types 複
  9. ( ) `==`

  10. Error ( ) PHP -> !!! ( Error) PHP ->

    ( | )
  11. : Error \Throwable catch https://daisuki.nichiyoubi.land/entry/ / / / [phpconfuk ]

    - YouTube https://www.youtube.com/watch?v=QDbp cR Dc
  12. 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/ .
  13. $ . JIT(Just-In-Time compilation)

  14. JIT (JIT) PHP( ) OP VM PHP

  15. OPCache PHP . OP OP VM

  16. Preload PHP . On server startup ( )

  17. JIT PHP . OP VM

  18. :youtube:

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

    App
  20. $ . Attribute

  21. 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
  22. syntax `#[sukinamono]` class, property, method `#[Attribute]` attribute attribute Re ection

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

    attributeԽ Ҿ਺ΛऔΕΔ Reflectionܦ༝Ͱ
 ΞΫηε ௚Ͱinstanceੜ੒ ෳ਺OK
  24. 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) } }
  25. : PHP PHP Attribute - Shin x Blog https://blog.shin x

    .com/entry/history-of-php -attribute
  26. doc-comment FW AOP JetBrains/phpstorm-attributes https://github.com/JetBrains/phpstorm-attributes

  27. $ . Union Types

  28. Union Types TypeScript union doc comment( )

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

  30. 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
  31. ェ `mixed` IDE TypeError

  32. $ PHP ~ n~

  33. $2

  34. ( PHP

  35. = =

  36. None
  37. None
  38. `$iterator` 釈 視 `$item` `doSome()` ( ) `foreach` `$iterator`

  39. `array_map()` ( ) ( ) `strlen($var)` `str_split + count` (

    ) contable `$var` ( `$var` ) ( )
  40. None
  41. DRY

  42. ( ) ( )

  43. 1 => 100 100 Golang:

  44. PHP

  45. $2 ~ n~

  46. $ PHP

  47. ͜ͷลΓͷ࿩ .constructor property promotion .named arguments .match expression .nullsafe operator

    .throw expression .Non-capturing catches .str_contains(), str_starts_ with(), str_ends_with()
  48. None
  49. constructor property promotion Kotlin ( ) object(Hoge)#1 (2) { ["a":"Hoge":private]=>

    int(10) ["x":protected]=> string(3) "aaa" }
  50. named arguments Python `name:` `method($a, null, null, null, $z)` API

    array(3) { ["a"]=> int(1) ["b"]=> int(2) [“d"]=> int(20) }
  51. match expression switch case switch 釈(= ) (switch ) (`===`)

    OR `,` switch `break` Error string(14) "very happy day"
  52. nullsafe operator JS, Kotlin, Swift, Ruby `->method()` `?->method()` NULL `isset()`

    array(2) { ["x"]=> NULL ["y"]=> NULL }
  53. 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
  54. Non-capturing catches `catch()` OK 視 domain violation

  55. str_contains(), str_starts_with(), str_ends_with() ( 0 false ) `strpos` array(3) {

    [0]=> bool(true) [1]=> bool(true) [2]=> bool(false) }
  56. None
  57. $ PHP ~ n~

  58. $

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

  60. #19-#68

  61. None
  62. ( ) ( ) ( Error ) MUST

  63. PHP

  64. None
  65. 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