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
型があると嬉しい〜って本当??
Search
hideki kinjyo
PRO
July 31, 2023
Programming
460
0
Share
型があると嬉しい〜って本当??
hideki kinjyo
PRO
July 31, 2023
More Decks by hideki kinjyo
See All by hideki kinjyo
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
250
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
200
夢の無限スパゲッティ製造機 #phperkaigi
o0h
PRO
0
440
PHPer Book Revue 「雑に作る」 #phperkaigi
o0h
PRO
0
330
俺にも私がAIと作った オススメの個人ツールを語らせてくれ
o0h
PRO
0
53
#phperbiglt のLT
o0h
PRO
0
83
手軽に積ん読を増やすには?/読みたい本と付き合うには?
o0h
PRO
1
260
symfony/mcp-bundleで、既存アプリケーションもお手軽にMCPサーバー化
o0h
PRO
1
140
組織もソフトウェアも難しく考えない、もっとシンプルな考え方で設計する #phpconfuk
o0h
PRO
10
5.8k
Other Decks in Programming
See All in Programming
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
0
320
Nuxt Server Components
wattanx
0
260
TiDBのアーキテクチャから学ぶ分散システム入門 〜MySQL互換のNewSQLは何を解決するのか〜 / tidb-architecture-study
dznbk
1
150
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
300
YJITとZJITにはイカなる違いがあるのか?
nakiym
0
200
PHPのバージョンアップ時にも役立ったAST(2026年版)
matsuo_atsushi
0
300
AWS re:Invent 2025の少し振り返り + DevOps AgentとBacklogを連携させてみた
satoshi256kbyte
3
150
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
330
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.3k
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
190
Vibe하게 만드는 Flutter GenUI App With ADK , 박제창, BWAI Incheon 2026
itsmedreamwalker
0
550
Featured
See All Featured
Practical Orchestrator
shlominoach
191
11k
Typedesign – Prime Four
hannesfritz
42
3k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
160
The Limits of Empathy - UXLibs8
cassininazir
1
290
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.3k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
520
Ruling the World: When Life Gets Gamed
codingconduct
0
190
4 Signs Your Business is Dying
shpigford
187
22k
HDC tutorial
michielstock
1
610
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.2k
Transcript
が ͳʹ͔ͷษڧձͱ͔͕͋Δ༁Ͱͳ͍ Hideki Kinjyo GitHub: o0h / Twitter: @o0h_
ࣗݾհ / GitHub: @o0h / Twitter: @o0h_ FW CakePHP
Πϯτϩ PHP PHP
( ) https://fortee.jp/phpcon-2021/proposal/6cd22f6c-9caa-432f-930c-9e62f512d59d
None
https://www.php.net/manual/ja/language.types.intro.php
https://www.php.net/manual/ja/language.types.intro.php PHP ( ) PHP
https://www.php.net/manual/ja/language.types.intro.php 10000 3
https://www.php.net/manual/ja/language.types.intro.php =
https://www.php.net/manual/ja/language.types.intro.php ( ) Web
shin1x1͞Μͷൃදʮ੍ͷྗʯ https://speakerdeck.com/shin1x1/restricting-states
shin1x1͞Μͷൃදʮ੍ͷྗʯ https://speakerdeck.com/shin1x1/restricting-states
shin1x1͞Μͷൃදʮ੍ͷྗʯ https://speakerdeck.com/shin1x1/restricting-states
shin1x1͞Μͷൃදʮ੍ͷྗʯ https://speakerdeck.com/shin1x1/restricting-states
t-wada͞Μͷൃදʮ༧ʹউΔޚͳ͠ʯ https://speakerdeck.com/twada/growing-reliable-code-phperkaigi-2022
t-wada͞Μͷൃදʮ༧ʹউΔޚͳ͠ʯ https://speakerdeck.com/twada/growing-reliable-code-phperkaigi-2022
ܕΛ͚ͭΔͧʂʂͷϞνϕʔγϣϯ ( )
:
PHPͷܕએݴ PHP php.net https://www.php.net/manual/ja/language.types.declarations.php
( )
int $l, $r int int NULL DB (= )
int int int int ( )
PHP7 ( ) ࢀߟ ݫີͳܕ͚ IUUQTXXXQIQOFUNBOVBMKBMBOHVBHFUZQFTEFDMBSBUJPOTQIQMBOHVBHFUZQFTEFDMBSBUJPOTTUSJDU
خ͍͠Ͱ͔͢ʁ int t-wada
خ͍͠Ͱ͔͢ʁ = (DB HTTP ) etc ( ) = int
=>
int / $response->getBody() $body- >eof() string, bool, Response, Stream
ࢀߟ IUUQTHJUIVCDPNTMJNQIQ4MJNCMPC4MJN 3FTQPOTF&NJUUFSQIQ
Interface ࢀߟ IUUQTHJUIVCDPNTMJNQIQ4MJNCMPC4MJN 3FTQPOTF&NJUUFSQIQ StreamInterface bool int: 0
(Content-Length ) int int string bool
ܕͱͷ͖߹͍ํ ( ) Interface strict_types=1 private public
:
ΨϯΨϯܕએݴΛ͢Δ͜ͱͷऑͱ͔ PHPDoc PHP PHP
੩తղੳπʔϧΛ͓͏ / PHPStan https://phpstan.org/ PHPStan scans your whole codebase and
looks for both obvious & tricky bugs. Even in those rarely executed if statements that certainly aren't covered by tests. ( )
੩తղੳπʔϧΛ͓͏ / Psalm https://psalm.dev/ Psalm is a static analysis tool
that attempts to dig into your program and fi nd as many type-related bugs as possible. PHPStan
੩తղੳπʔϧΛ͓͏ / PhpStorm PHP PHPStan Psalm lint ( )
PHPStan
= CI ࢀߟ IUUQTQIQTUBOPSHSGDGBDGCDCEGC
PHPDoc @param / @return ࢀߟ IUUQTQIQTUBOPSHSGFFECEEEDG
: `key-of- <***>` `value-of-<***>` ( ) ࢀߟ IUUQTQIQTUBOPSHSCDGDFCBCCBBEE
: int<min, max> `int` ࢀߟ IUUQTQIQTUBOPSHSEFFGDDCCBEEFE
: (key, value ) iterable array mixed ࢀߟ
IUUQTQIQTUBOPSHSEG ff EDFBBBFD
: DTO ࢀߟ IUUQTQIQTUBOPSHSDCFGGCGGGFE
৭ʑͳܕͷදݱ : https://phpstan.org/writing-php- code/phpdoc-types
PHPStan
Πϯετʔϧ͢Δ
ઃఆϑΝΠϧΛઃஔ͢Δ https://phpstan.org/con fi g-reference
࣮ߦ͢Δ
( OK)
ಋೖ࣌ʹ͓֮͑ͯ͘ͱྑͦ͞͏ͳ֓೦ Error Rule/RuleSet Rule RuleSet Rule Rule level PHPStan Ruleset
0 9(max) level
Rule Levelͷྫ https://github.com/phpstan/phpstan-src/blob/1.10.25/conf/con fi g.level6.neon
ಋೖ࣌ʹ͓֮͑ͯ͘ͱྑͦ͞͏ͳ֓೦ Baseline ( ) Error `phpstan analyze generate-baseline` Error ignoreErrors
con fi g 1 ( )Error Baseline ignoreErrors
Baselineͷྫ(CakePHP) https://github.com/cakephp/cakephp/blob/4.4.15/phpstan-baseline.neon
PHPStanͷ͍͞͠ಋೖʹ͚ͯ PJ Level OK Baseline PHPStan ignoreErrors( Baseline ) Error
(cf: https://phpstan.org/user-guide/ignoring-errors#reporting-unused- ignores)
PHPStanͷ͍͞͠ಋೖʹ͚ͯ PJ Level CI 5 6
PHPStanͷ͍͞͠ಋೖʹ͚ͯ 連 Error etc
ͬͱڧྗͳ׆༻ʹ͚ͯ PHPStan https://phpstan.org/writing-php-code/phpdoc-types https://phpstan.org/con fi g-reference https://phpstan.org/user-guide/extension-library OSS
ͱͯࢀߟʹͳΔࢿྉͨͪ PHPStan #phpcon_okinawa pixivFANBOX https://tadsan.fanbox.cc/posts/4348669 #phpcon_okinawa pixivFANBOX https://tadsan.fanbox.cc/posts/2558149
level=0 PHPStan(Larastan) - Shin x Blog https://blog.shin1x1.com/entry/getting-stated-with-phpstan CI / Great static analysis with CI - Speaker Deck https://speakerdeck.com/oogfranz/great-static-analysis-with-ci