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
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.2k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
Arm移行タイムアタック
qnighy
0
340
Macとオーディオ再生 2024/11/02
yusukeito
0
380
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
200
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.8k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Designing Experiences People Love
moore
138
23k
Statistics for Hackers
jakevdp
796
220k
Designing for humans not robots
tammielis
250
25k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
The Language of Interfaces
destraynor
154
24k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Six Lessons from altMBA
skipperchong
27
3.5k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Why Our Code Smells
bkeepers
PRO
334
57k
Site-Speed That Sticks
csswizardry
0
31
Building Flexible Design Systems
yeseniaperezcruz
327
38k
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