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
assertぐらいでエバルんじゃねえ!
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Atsushi Takayama
December 15, 2016
Technology
930
2
Share
assertぐらいでエバルんじゃねえ!
〜Phanがもたらす堅牢なPHP〜
Atsushi Takayama
December 15, 2016
More Decks by Atsushi Takayama
See All by Atsushi Takayama
最高の開発者体験の追求が開発生産性を改善し続ける文化を生み出した話
edvakf
3
1.6k
NeurIPS 2021 論文読み会: How Modular should Neural Module Networks Be for Systematic Generalization?
edvakf
0
220
8年物のJavaのシステムをKotlinに変えていく選択に至るまで
edvakf
2
1.1k
ピクシブ社内のImageFlux利用事例紹介
edvakf
2
3k
学びの文化を育む社内読書会のススメ
edvakf
0
310
フルCDNアーキテクチャでサービス設計した話
edvakf
5
4.1k
Goでバイナリを読む+α
edvakf
1
1k
お前はこれまでに作ったAPIの数を覚えているのか?
edvakf
0
2.7k
「ふつうのRailsアプリケーション」についての考え方
edvakf
2
930
Other Decks in Technology
See All in Technology
ハーネスエンジニアリングの概要と設計思想
sergicalsix
9
5.3k
AI時代における技術的負債への取り組み
codenote
1
1.7k
レビューしきれない?それは「全て人力でのレビュー」だからではないでしょうか
amixedcolor
0
350
巨大プラットフォームを進化させる「第3のROI」
recruitengineers
PRO
2
1.2k
国内外の生成AIセキュリティの最新動向 & AIガードレール製品「chakoshi」のご紹介 / Latest Trends in Generative AI Security (Domestic & International) & Introduction to AI Guardrail Product "chakoshi"
nttcom
4
1.4k
弁護士ドットコム株式会社 エンジニア職向け 会社紹介資料
bengo4com
1
180
20260428_Product Management Summit_Loglass_JoeHirose
loglassjoe
3
3.7k
Hacobu Tech Deck
hacobu
PRO
0
130
マルチプロダクトの信頼性を効率良く保っていくために
kworkdev
PRO
0
170
AWS Agent Registry の基礎・概要を理解する/aws-agent-registry-intro
ren8k
3
390
Expiration of Secure Boot Certificates for vSphere Virtual Machines
mirie_sd
0
110
AWS DevOps Agentはチームメイトになれるのか?/ Can AWS DevOps Agent become a teammate
kinunori
6
770
Featured
See All Featured
Accessibility Awareness
sabderemane
1
100
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.4k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.4k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
160
The Language of Interfaces
destraynor
162
26k
AI: The stuff that nobody shows you
jnunemaker
PRO
6
580
Believing is Seeing
oripsolob
1
110
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.4k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
180
It's Worth the Effort
3n
188
29k
Into the Great Unknown - MozCon
thekraken
41
2.4k
Transcript
assert͙Β͍Ͱ ΤόϧΜ͡ΌͶ͑ʂ ʙPhan͕ͨΒ͢ݎ࿚ͳPHPʙ
ࣗݾհ ߴࢁԹ @edvakf ϐΫγϒגࣜձࣾ ࣥߦһ CTO ISUCON6ຊબग़͠·ͨ͠ JavaScript, PHP, Ruby,
Go, Scala ͋ͨΓ͕कඋൣғ
assertศརͰ͢Ͷ
function div($a, $b) { assert($b !== 0); return $a /
$b; }
assertͷ᠘
None
ʊਓਓਓਓਓਓʊ ʼɹΤϰΝϧɹʻ ʉ:?:?:?:?:ʉ
ͭ·Γ
͜͏ॻ͚Δ function div($a, $b) { assert(“{$b} !== 0”); return $a
/ $b; }
͜͏͢Δͱassertͷத͕ධՁ͞Εͳ͍ assert_options(ASSERT_ACTIVE, false); function div($a, $b) { assert(“{$b} !== 0”);
return $a / $b; }
pixivͷϙϦγʔͰɺ։ൃڥͱϓϩμΫγϣϯͷࠩ ҟͷ࠷খԽͷͨΊɺͰ͖ΕASSERT_ACTIVEΛfalse ʹͨ͘͠ͳ͍ assertʹ͞ΕΔ͕ʢকདྷʹͬͯʣ֎෦ೖྗʹ༝ དྷ͢ΔͰͳ͍͜ͱΛอূ͢Δͷඇৗʹࠔ ·ͨɺassert͕ग़ͯ͘Δͨͼʹ͞ΕΔ͕֎෦ೖྗ ༝དྷ͔Ͳ͏͔ΛϨϏϡʔͰݟΔඞཁ͕͋Γɺίετ ͕͔͔Δ
ͱ͍͏Θ͚Ͱ pixivͰಠࣗͷassertʹ૬͢ΔؔΛఆٛͯ͠ɺ PHPͷΈࠐΈͷassertΘͳ͘ͳΓ·ͨ͠
ΊͰͨ͠ΊͰͨ͠
Ͱͳ͘
ϨϏϡʔͷίετΛ্͛ͣʹ assertΛ͑ͳ͍͔ߟ͑ͯΈͨ
ҾΛboolඞਢʹ͍ͨ͠ assert($a === 1); // OK assert(empty($a)); // OK assert(!is_null($a));
// OK assert(“$b !== 1”); // NG assert(someFunction($a)); // ?
Phan ੩తղੳπʔϧ PHP7͔Βಋೖ͞Εͨ෦ASTΛPHPଆ͔Β৮ΕΔΑ ͏ʹ͢ΔͨΊͷphp-astͱ͍͏C֦ுʹґଘ
$ phan some.php some.php:5 PhanTypeMismatchArgumentInternal Argument 1 (assertion) is int
but \assert() takes bool|string PHPͷඪ४ؔͷҾͱฦΓͷܕͷҰཡΛ࣋ͬͯ ͍ͯɺܕਪͯ͘͠ΕΔ
assertͷҾ͕boolͰ͋Δ͜ ͱΛอূ͢Δʹ
→PhanϓϥάΠϯͰ % tree -a . !"" .phan # !"" config.php
# $"" plugins # $"" NonBoolAssertPlugin.php $"" some.php
None
$ phan some.php some.php:5 PhanPluginNonBoolAssert Non bool value passed to
assert some.php:5 PhanTypeMismatchArgumentInternal Argument 1 (assertion) is int but \assert() takes bool|string
·ͱΊ PhanͰ੩తղੳͯ͠ϨϏϡʔͷίετΛԼ͛Α͏ Phan͕௨Βͳ͚ΕCI͕௨Βͳ͍Α͏ʹ͠Α͏ PhanϓϥάΠϯͰಠࣗίʔσΟϯάنlintԽͯ͠ ϨϏϡʔ࣌ͷ҉ΛݮΒͦ͏
ฐࣾͷ৽ଔ͕ࣥච͠·ͨ͠