Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
防衛的 PHP: 多様性を生き抜くための PHP 入門 / Defensive PHP
Search
Naoki Ikeguchi
March 24, 2023
Programming
2
1k
防衛的 PHP: 多様性を生き抜くための PHP 入門 / Defensive PHP
Naoki Ikeguchi
March 24, 2023
Tweet
Share
Other Decks in Programming
See All in Programming
flutterkaigi_2024.pdf
kyoheig3
0
140
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
340
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
620
CSC509 Lecture 09
javiergs
PRO
0
140
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
330
Macとオーディオ再生 2024/11/02
yusukeito
0
370
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
190
Ethereum_.pdf
nekomatu
0
460
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Click-free releases & the making of a CLI app
oheyadam
2
120
Amazon Qを使ってIaCを触ろう!
maruto
0
410
Featured
See All Featured
KATA
mclloyd
29
14k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
A designer walks into a library…
pauljervisheath
204
24k
Visualization
eitanlees
145
15k
Making Projects Easy
brettharned
115
5.9k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Building Adaptive Systems
keathley
38
2.3k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Transcript
Ӵత 1)1 ଟ༷ੑΛੜ͖ൈͨ͘Ίͷ 1)1ೖ !TO@KQ QIQFSLBJHJ B
XIPBNJ • αʔόαΠυΤϯδχΞ !ΏΊΈ • ࡾͷ൧ΑΓ੩తܕ͚͕͖ • 1)1 3VTU (P
$ FUD • -BSBWFMΑΓ 4ZNGPOZ • +FU#SBJOT৴ऀ • 3VTU Ͱ 1)1ͷ 4"1*Λ࣮͢Δ ͷ͕झຯ 2 @s6n_jp
੩తղੳͬͯԿ 3
'PSNBUUFS Ձͳίʔυͷ··εϖʔγϯάΠϯσϯτɼෆཁͳτʔΫϯ ͳͲΛ͑Δ 4 $foo = (function ($a, $b, $c)
{})(); $bar = array(“a”, “b”,); $foo= ( function($a,$b, $c ){ }, )(); $bar = [ ‘a’, ‘b’, ];
-JOUFS -JOU • ͳॻ͖ํɼݹ͍ॻ͖ํɼҰൠʹΑ͘ͳ͍ͱ͞ΕΔॻ͖ํ ͳͲΛݕ͢Δɾผͷॻ͖ํʹม͑Δ • ഁյతͳมߋΛߦ͏ɾఏҊ͢Δ߹͋Δ • ͨͱ͑ 1)1Ͱ
declare(strict_types=1); ΛՃ͢Δ ϧʔϧ͕͜Εʹ͋ͨΔ • ࣗಈతʹमਖ਼Ͱ͖ͳ͍ͷ͋Δ 5
5ZQF$IFDLFS • ܕΛݕࠪ͢Δ ͦͷ·· 6
ଞͷݴޠʹ͓͚Δ੩తղੳ 7
1)1ͷ੩తղੳπʔϧ • 1)1@$PEF4OJGGFS • 1)1$4'JYFS • 1)1.FTT%FUFDUPS • 1)14UBO •
1TBMN • 3FDUPS FUDʜ 8
9 ଟ͗͢Δ ͷͰͱΓ͋͑ͣೖΕ͓͖ͯ͘ ͭΛհ͠·͢
8IZ੩తղੳ 10
ܕͷऑ͔ͬͨݴޠ͕ܕΛٻΊ͍ͯΔ 11
ਓྨܕΛٻΊΔ • ਓखଓ͖ܕݴޠʹ;ΕΔͱߴจ຺ͳίʔυΛੜ࢈͢Δ • ܕߟ͑Δ͜ͱΛ࠷খʹ͢ΔखஈͰ͋Δ 12
ϏϧυλΠϜͰΕΔʹӽͨ͜͠ͱͳ͍ ͋͞օ͞Μ͝Ұॹʹɺ • ίϯύΠϧΤϥʔී௨ • ίϯύΠϧΤϥʔ͕ग़ͨΒ͋Γ͕ͱ͏ • ίϯύΠϧΤϥʔ͕ग़ͨΒେتͼ 13 l
ߐఴ྄ɽzߐఴ྄ͷ$ ೖzɽɽIUUQTF[PFSZPVHJUIVCJPDQQJOUSP
Ӵతͳίʔυϕʔε 14
ͭͷӴ • ࣗͷϛε͔ΒͷӴ • ࣗͰॻ͍ͨίʔυͷจ຺Λશʹ͍֮͑ͯΒΕΔΘ͚Ͱͳ͍ • ແବͳࢥߟ͔ΒͷӴ • ίʔυͷॻ͖ํຊ࣭Ͱͳ͍ •
ॻ͖ํΛࣗಈͰ౷Ұ͢Δ͜ͱͰίʔυ্ͷຊ࣭ʹूதͰ͖Δ • ଞਓͷॻ͘ίʔυ͔ΒͷӴ • ίʔυϕʔεதͷίʔυͷ࣭ҰఆʹอͨΕΔ͖Ͱ͋Δ • ҉ͷ ίʔσΟϯάنकΒΕͳ͍ 15
ଟ༷ੑ 16
ॻ͘ਓͷ͚ͩҧ͏ίʔυ͕ੜ·ΕΔ • Πϯσϯτεϖʔε λϒ • ԋࢉࢠͷपΓʹεϖʔεΛೖΕΔ ೖΕͳ͍ • BSSBZ@NBQBSSBZ@GJMUFSΛ͏ GPSFBDIΛ͏
• ͜ͷॻ͖ํݹ͍ ৽͍͠ ˠίʔυͷຊ࣭ͦ͜Ͱͳ͍ ˠ੩తղੳʹΑͬͯຊ࣭ʹूதͰ͖ΔΑ͏ʹ͢Δ 17
143ͱ 143 18
143ͱ • 1)1'*( 'SBNFXPSL*OUFSPQFSBCJMJUZ(SPVQ ʹΑͬͯ ࡦఆ͞ΕͨϑϨʔϜϫʔΫؒͷ૬ޓӡ༻ੑΛ֬อ͢ΔͨΊͷ ඪ४ "CTUSBDUJPO • ͨͱ͑ʜʜ
• 143143ΦʔτϩʔσΟϯά • 143143143ίʔσΟϯάελΠϧ • 143)551ϝοηʔδΠϯλʔϑΣʔε • 143$MPDLˡ/&8 19
143 • 143Λݩʹͨ͠ίʔσΟϯάελΠϧඪ४ • ͨͱ͑ʜʜ • 1)1ϑΝΠϧ -'ͷΈΛ͏ .645 •
FYUFOET JNQMFNFOUTΫϥε໊ͱಉ͡ߦʹॻ͘ .645 • 5SBJUͷ VTFจ DMBTTͷ։͔࢝ͬ͜ͷ͙͢ޙ .645 • ͯ͢ͷϝιουʹ 7JTJCJMJUZΛॻ͘ .645 • BCTUSBDU GJOBM TUBUJD 7JTJCJMJUZͷલʹॻ͘ .645 • FMTFJGͰͳ͘ FMTFJGΛ͏ 4)06-% FUDʜ 20
1)1ͷ੩తղੳೖ 21
QIQM • ҙ֎ͱΒΕ͍ͯͳ͍ ࢲΒͳ͔ͬͨ ੩తղੳπʔϧ • ࣮ߦ࣌ͷ 4ZOUBY&SSPSΛ͛Δ 22
23
1)1$4'JYFS 24 • ϧʔϧηοτ • !4ZNGPOZ !4ZNGPOZSJTLZ ͜Ε !143Λܧঝ͢Δ
• !1IQ$T'JYFS !1IQ$T'JYFSSJTLZ • !1)1.JHSBUJPO !1)1.JHSBUJPOSJTLZ • !1)16OJU.JHSBUJPOSJTLZ
25
&$4 ίϯςφ͕ಈ͔ͳ͍΄͏ 26 • 0VUPG#PYͰ͑Δ • 1)1$4'JYFSͷࡉʑͱͨ͠ϧʔϧ͑ͳ͍ • &$41)1$4'JYFS 1)1$4
4ZNQMJGZ
27
1)14UBOฤ • ϨϕϧΛ d͔Β͑ΒͿ ͕͓͢͢Ί • 4ZNGPOZͰ͏߹ &YUFOTJPOΛೖΕΔ • ΄΅
0VUPG#PYͰ͑Δ • ࠷ॳෆཁͳϧʔϧΛҰ୴ແޮԽ͍͍ͯ͠ͱࢥ͏ 28
29
3FDUPSฤ • $0%&@26"-*5: %&"%@$0%& 1)1@d1)1@ 5:1&@%&$-"3"5*0/͋ͨΓͷ 4FU-JTUΛ͏ • JNQPSU/BNFTΛઃఆ͠ͳ͍ͱ '2$/͕ॻ͔ΕΔͷͰҙ
30
31
32
੩తղੳͱ 1IQ4UPSN 33
͋ͳͨͷ 1IQ4UPSN ࠷దͳઃఆ 34
͋ͳͨͷ 1IQ4UPSN ࠷దͳઃఆ 35
36
37
͏Ε͍͠χϡʔε 38
1IQ4UPSN $* Ͱಈ͖·͢ 39
1IQ4UPSN $* Ͱಈ͖·͢ brew install jetbrains/utils/qodana qodana scan –-show-report •
+BWB ,PUMJO 1)1 1ZUIPO +BWB4DSJQU 5ZQF4DSJQU (P $ ' 7#/&5 BOENPSF • 4"3*'ܗࣜͰͷग़ྗՄೳ • ࠓͳΒແྉͰ͑·͢ 40
0OF.PSF5IJOH 41
ࠓհͨ͠πʔϧΛ·ͱΊͯಋೖͰ͖·͢ composer require --dev \ quartetcom/static-analysis-kit:~8.1 • 1)1$4'JYFS 1)14UBO 3FDUPSΛҰʹಋೖͰ͖·͢
• 0VUPG#PYͰ͑ΔͷͰ໘ͳઃఆෆཁ • ݫ͠Ίͷઃఆʹͯ͋͠ΔͷͰݫ͠Ί͕͖ͳํʹ͓͢͢Ί 42
5IBOLZPV ൃදࢿྉͪ͜Β͔ΒIUUQTTQFBLFSEFDLDPNTJLFUZBO 43