#phpcon 良いコードを書けるようになるコツは「エラーを気にする」 〜プログラマにとってエラーとは何なのか〜
by
hideki kinjyo
×
Copy
Open
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Slide 1
Slide 1 text
PHP Conference 2023 Hideki Kinjyo GitHub: o0h / Twitter: @o0h_ [ൃද൛]
Slide 2
Slide 2 text
ࣗݾհ / GitHub: @o0h / X: @o0h_ FW CakePHP
Slide 3
Slide 3 text
⏳estimate: 0 1 /25
Slide 4
Slide 4 text
⏳estimate: 0 1 /25
Slide 5
Slide 5 text
⏳estimate: 0 1 /25
Slide 6
Slide 6 text
ҧ͏ʂʂ Τϥʔఢ͡Όͳ͍ɺ ༑ୡͳΜͩʂʂ ⏳estimate: 1 /25
Slide 7
Slide 7 text
͜ΜͳࣄΛ͍͖ͯ͠·͢ PHP ⏳estimate: 1 2 /25 ˒খ͞ͳએίʔφʔ˒
Slide 8
Slide 8 text
͜ΜͳͷΛ࣋ͬͯؼͬͯΒ͍͍ͨ PHP ⏳estimate: 1 2 /25
Slide 9
Slide 9 text
͓͠ͳ͕͖ 1. 2. PHP 3. 4. PRO 5. PHP ⏳estimate: 1 2 /25
Slide 10
Slide 10 text
§1
Slide 11
Slide 11 text
ϓϩάϥϛϯάݴޠͳͥʮΤϥʔʯΛݴͬͯ͘Δͷʁ = ⏳estimate: 1 2 /25
Slide 12
Slide 12 text
PHP Software Developers ⏳estimate: 1 2 /25
Slide 13
Slide 13 text
PHP Software Developers ͍ ⏳estimate: 2 /25
Slide 14
Slide 14 text
⏳estimate: 2 /25
Slide 15
Slide 15 text
⏳estimate: 2 /25
Slide 16
Slide 16 text
Τϥʔͷ͋Δੈքɺͳ͍ੈքɾɾɾͲ͕ͬͪྑ͍Ͱ͔͢ʁ : 31 : : : ⏳estimate: 2~3 /25
Slide 17
Slide 17 text
Τϥʔͷ͋Δੈքɺͳ͍ੈքɾɾɾͲ͕ͬͪྑ͍Ͱ͔͢ʁ (= ) => => => ⏳estimate: 2~3 /25
Slide 18
Slide 18 text
Τϥʔͷ͋Δੈքͷํ͕ɺ༏͍͠ੈք 2 ⏳estimate: 2~3 /25
Slide 19
Slide 19 text
PHP 👀 ⏳estimate: 2~3 /25
Slide 20
Slide 20 text
ྫ͑sprintf()ͷྫ (% ) switch src: IUUQTHJUIVCDPNQIQQIQTSDCMPCQIQFYUTUBOEBSEGPSNBUUFE@QSJOUD--
Slide 21
Slide 21 text
ྫ͑sprintf()ͷྫ case (default ) ⏳estimate: 3 /25
Slide 22
Slide 22 text
ྫ͑sprintf()ͷྫ src: IUUQTHJUIVCDPNQIQQIQTSDCMPCQIQFYUTUBOEBSEGPSNBUUFE@QSJOUD-- (% )
Slide 23
Slide 23 text
⏳estimate: 3 /25
Slide 24
Slide 24 text
Τϥʔɺ͑Βʙ͍👏 : : ⏳estimate: 3~4 /25
Slide 25
Slide 25 text
§2 PHP
Slide 26
Slide 26 text
§2 PHP .1 .2 PHP
Slide 27
Slide 27 text
Τϥʔʹʮఔʯ͕͋Δͧ ( ) ⏳estimate: 4 /25
Slide 28
Slide 28 text
[ࣸਅ] (্) ҹ ενʔϜࣜՃ࣪ث EE-RQ35ܕ/EE-RQ50ܕ औѻઆ໌ॻ (Լ) ΞΠϦεΦʔϠϚ ਅۭอଘϑʔυγʔϥʔ VPF-385T औѻઆ໌ॻ ࢀߟ: ՈిΛ҆શʹ͏ͨΊͷϚʔΫʛҰൠࡒஂ๏ਓՈిڠձ https://aeha.or.jp/safety/mark/index.html ใͷྨͷྫ: ՈిͷϚχϡΞϧ : :
Slide 29
Slide 29 text
ใͷྨͷྫ: ՈిͷϚχϡΞϧ [ࣸਅ] ҹ ενʔϜࣜՃ࣪ث EE-RQ35ܕ/EE-RQ50ܕ औѻઆ໌ॻ
Slide 30
Slide 30 text
ใ͕ྨ͞Ε͍ͯΔͱศརͰ͢Ͷʂ ⏳estimate: 5 /25
Slide 31
Slide 31 text
ͲΜͳʮఔʯ͕͋Δʁ : : ( ): : ⏳estimate: 5~6 /25
Slide 32
Slide 32 text
§2 PHP .1 .2 PHP ⏳estimate: 5~6 /25
Slide 33
Slide 33 text
PHPʹ͓͚ΔΤϥʔఆ(ΤϥʔϨϕϧ) IUUQTXXXQIQOFUNBOVBMKBFSSPSGVODDPOTUBOUTQIQ
Slide 34
Slide 34 text
PHPͷΤϥʔܥ౷
Slide 35
Slide 35 text
PHPͷΤϥʔܥ౷ ͦΕͧΕɺ͑Α͏ͱ͍ͯ͠Δҙਤ͕ҧͬͨΓ ͨΒ݁͢Ռ͕ҧ͏Μͩͳʙ ۠ผ͕͋ΔΜͩͳʙ ⏳estimate: 6 /25
Slide 36
Slide 36 text
PHPͷΤϥʔͨͪʙ͜Ε͚֮ͩ͑Α͏ʙ E_ERROR => [ ] PHP E_WARNING => [ ] PHP E_NOTICE => [ ] PHP ⏳estimate: 6 /25
Slide 37
Slide 37 text
E_ERROR / ॏେ (Throwable) ⏳estimate: 6~7 /25
Slide 38
Slide 38 text
E_WARNING / ܯࠂ ( ) ( ) URL
Slide 39
Slide 39 text
E_NOTICE / ҙ
Slide 40
Slide 40 text
§3
Slide 41
Slide 41 text
§3 .1 .2 ⏳estimate: 7 /25
Slide 42
Slide 42 text
ྑ͘ͳͦ͞͏ͳίʔυͱ͍͏ͷ͕͋Δ ⏳estimate: 7 /25
Slide 43
Slide 43 text
ᐆດ͞ʹ͍ͭͯ: shin1x1͞Μʮ੍ͷྗʯ https://speakerdeck.com/shin1x1/restricting-states ⏳estimate: 7~8 /25
Slide 44
Slide 44 text
ᐆດ͞ʹ͍ͭͯ: shin1x1͞Μʮ੍ͷྗʯ https://speakerdeck.com/shin1x1/restricting-states ⏳estimate: 7~8 /25
Slide 45
Slide 45 text
ᐆດ͞ʹ͍ͭͯ: shin1x1͞Μʮ੍ͷྗʯ https://speakerdeck.com/shin1x1/restricting-states ⏳estimate: 7~8 /25
Slide 46
Slide 46 text
ᐆດ͞ʹ͍ͭͯ: shin1x1͞Μʮ੍ͷྗʯ https://speakerdeck.com/shin1x1/restricting-states ⏳estimate: 8 /25
Slide 47
Slide 47 text
ᐆດ͞ʹ͍ͭͯ: t-wada͞Μͷʮ༧ʹউΔޚͳ͠ʯ https://speakerdeck.com/twada/growing-reliable-code-phperkaigi-2022 ⏳estimate: 8 /25
Slide 48
Slide 48 text
ᐆດ͞ʹ͍ͭͯ: t-wada͞Μͷʮ༧ʹউΔޚͳ͠ʯ https://speakerdeck.com/twada/growing-reliable-code-phperkaigi-2022 ⏳estimate: 8 /25
Slide 49
Slide 49 text
ྑ͘ͳ͍ίʔυ͕͜͏ͯ͠ੜ·ΕΔͧ ( ) ⏳estimate: 8~9 /25
Slide 50
Slide 50 text
ΤϥʔͱՄೳੑ ❌ ⭕ ⏳estimate: 8~9 /25
Slide 51
Slide 51 text
͜ͷίʔυո͍͕͠ɾɾɾ ⏳estimate: 9 /25
Slide 52
Slide 52 text
͜ͷίʔυո͍͕͠ɾɾɾ PHP ⏳estimate: 9~10 /25
Slide 53
Slide 53 text
§3 .1 .2 ⏳estimate: 9~10 /25
Slide 54
Slide 54 text
Α͘ͳͦ͞͏ͳίʔυΛආ͚ΔͨΊʹ ⏳estimate: 10 /25
Slide 55
Slide 55 text
Τϥʔɺcase-by-case ( ) ( ) ⏳estimate: 10 /25
Slide 56
Slide 56 text
࣮ྫʂϓϩάϥϛϯά ( ) ⏳estimate: 10~11 /25
Slide 57
Slide 57 text
࣮ྫʂPHP ( )
Slide 58
Slide 58 text
࣮ྫʂPHP : include E_WARNING require E_ERROR https://www.php.net/manual/ja/function.include.php ⏳estimate: 10~11 /25
Slide 59
Slide 59 text
ΤϥʔϨϕϧओ؍తʹܾ·Δ(ଆ໘͋Δ) ⏳estimate: 11 /25
Slide 60
Slide 60 text
ίϨ͋ͳͨͷ؍ʹ߹͏ʁ E_ERROR
Slide 61
Slide 61 text
ΤϥʔʹࣖΛ͚͍ͯ͜͏ʙ ⏳estimate: 11 /25
Slide 62
Slide 62 text
ΤϥʔʹࣖΛ͚͍ͯ͜͏ʙ ⏳estimate: 11~12 /25
Slide 63
Slide 63 text
§4 PRO
Slide 64
Slide 64 text
Τϥʔɺා͍Ͱ͔͢ʁ ( ) ⏳estimate: 12 /25
Slide 65
Slide 65 text
ΤϥʔͷPRO͕ɺ͍ͬͯΔ͜ͱ ( ) ⏳estimate: 12~13 /25
Slide 66
Slide 66 text
Τϥʔ͕࣍ͷʮఆ֎ʯʮᐆດʯΛݺͿ ( ) [ग़య] ᴷAndreas Zeller, தా लج, ࠓా ণ, େؠ ঘ, ా ߳බ, ٶݪ ٱඒࢠ, फܗ ࣿ৫ σόοάͷཧͱ࣮ફ ―ͳͥϓϩάϥϜ͏·͘ಈ͔ͳ͍ͷ͔ P3 - P4
Slide 67
Slide 67 text
όάʮൟ৩ʯ͢Δ 1 1 [ग़య] ᴷ Shore, James, Warden, Shane, ฏು ݈ࣇ, Լ ࢙, Ҫ ਸ࢘ ΞʔτɾΦϒɾΞδϟΠϧσϕϩοϓϝϯτ : ৫Λޭʹಋ͘ΤΫετϦʔϜϓϩάϥϛϯά P169
Slide 68
Slide 68 text
Τϥʔ͕ڭ͑ͯ͘ΕΔ͜ͱɾ͘Εͳ͍͜ͱ ⏳estimate: 13~14 /25
Slide 69
Slide 69 text
͖ͬ͞ͷίʔυ: Կ͕ਖ਼͍͠ʁ $taxRate 1.8 fl oat 0.8 fl oat 80(%) int ⏳estimate: 13~14 /25
Slide 70
Slide 70 text
ผͷྫ: ߏจΤϥʔ ( ) 7 if{} if {} 🤮 ⏳estimate: 13~14 /25
Slide 71
Slide 71 text
ผͷྫ: ߏจΤϥʔɺ͜ΕͩͬͨΒͲ͏ݟ͑Δʁ class{}
Slide 72
Slide 72 text
ผͷྫ: ߏจΤϥʔɺݟͨͰมΘΒͳ͍҆৺ײ ⏳estimate: 14 /25
Slide 73
Slide 73 text
Τϥʔͱྑ͘ͳΔʹ PRO ⏳estimate: 14~15 /25
Slide 74
Slide 74 text
Τϥʔఢ͡Όͳ͍ɺ༑ୡͳΜͩʂʂ →ͦͷ৺ʁ ⏳estimate: 15~16 /25
Slide 75
Slide 75 text
Τϥʔͱྑ͘ͳΔͨΊͷίπ௫Έ·͠ΐ͏ʂ ( ) = ( ) ⏳estimate: 16 /25
Slide 76
Slide 76 text
§5 PHP
Slide 77
Slide 77 text
§5 PHP .1 .2 ⏳estimate: 16~17 /25
Slide 78
Slide 78 text
ϓϩάϥϛϯάʹͱͬͯΤϥʔॏཁ ⏳estimate: 16~17 /25
Slide 79
Slide 79 text
PHPͲ͏͖ͯͨ͠ʁˠΑ͘ʹͳΔͭ PHP5 -> PHP7 Throwable/Error E_STRICT : E_NOTICE, E_WARNING, E_DEPRECATED PHP7 -> PHP8 warning -> Error PHP8 -> PHP9 Error (8.2 Deprecated) Error
Slide 80
Slide 80 text
ᐆດ͞ͱͷઓ͍ PHP ⏳estimate: 17~18 /25
Slide 81
Slide 81 text
ᐆດ͞ͱͷઓ͍ E_WARNING/E_NOTICE Error throw E_NOTICE (7.4 ) E_NOTICE php.ini these are warnings which often result from a bug in your code, but it's possible that it was intentional ⏳estimate: 17~18 /25
Slide 82
Slide 82 text
php-src grep 7.x NOTICE WARNING 8.x WARNING E_NOTICE/ E_WARNINGͷग़ݱ git --no-pager grep E_NOTICE -- 'ext/**/*.c' | wc -l
Slide 83
Slide 83 text
RFCͳͲ PHP: rfc:engine_warnings https://wiki.php.net/rfc/engine_warnings PHP: rfc:consistent_type_errors https://wiki.php.net/rfc/consistent_type_errors Pull requests · php/php-src https://github.com/php/php-src/pulls?q=label%3A%22Warning+promotion%22 PHP: rfc:unde fi ned_property_error_promotion https://wiki.php.net/rfc/unde fi ned_property_error_promotion PHP: rfc:unde fi ned_variable_error_promotion https://wiki.php.net/rfc/unde fi ned_variable_error_promotion
Slide 84
Slide 84 text
§5 PHP .1 .2
Slide 85
Slide 85 text
͜Ε͔ΒͲ͏ͳΓͦ͏ʁ NOTICE PHP Error WARNING (DEPRECATED ) TypeError/ValueError
Slide 86
Slide 86 text
͜Ε͔ΒͲ͏͍ͯ͘͠ʁ PHP7.0 ⏳estimate: 20 /25
Slide 87
Slide 87 text
͜Ε͔ΒͲ͏͍ͯ͘͠ʁ E_NOTICE/E_WARNING (`===` strict ) PHPStan Psalm PHP ⏳estimate: 21 /25
Slide 88
Slide 88 text
No content
Slide 89
Slide 89 text
Τϥʔͱ্ख͖͘߹͏ͱɺ͕͠͞ݮΔ PHP ⏳estimate: 21~22 /25
Slide 90
Slide 90 text
No content
Slide 91
Slide 91 text
͓͠·͍ʂ ͓͖߹͍͍͖ͨͩ ͋Γ͕ͱ͏͍͟͝·ͨ͠