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
Atsushi Takayama
December 15, 2016
Technology
2
870
assertぐらいでエバルんじゃねえ!
〜Phanがもたらす堅牢なPHP〜
Atsushi Takayama
December 15, 2016
Tweet
Share
More Decks by Atsushi Takayama
See All by Atsushi Takayama
最高の開発者体験の追求が開発生産性を改善し続ける文化を生み出した話
edvakf
3
1.3k
NeurIPS 2021 論文読み会: How Modular should Neural Module Networks Be for Systematic Generalization?
edvakf
0
170
8年物のJavaのシステムをKotlinに変えていく選択に至るまで
edvakf
2
1.1k
ピクシブ社内のImageFlux利用事例紹介
edvakf
1
2.8k
学びの文化を育む社内読書会のススメ
edvakf
0
270
フルCDNアーキテクチャでサービス設計した話
edvakf
5
3.9k
Goでバイナリを読む+α
edvakf
1
950
お前はこれまでに作ったAPIの数を覚えているのか?
edvakf
0
2.5k
「ふつうのRailsアプリケーション」についての考え方
edvakf
2
850
Other Decks in Technology
See All in Technology
OPENLOGI Company Profile for engineer
hr01
1
34k
20250705 Headlamp: 專注可擴展性的 Kubernetes 用戶界面
pichuang
0
270
ビズリーチが挑む メトリクスを活用した技術的負債の解消 / dev-productivity-con2025
visional_engineering_and_design
3
7.7k
MobileActOsaka_250704.pdf
akaitadaaki
0
130
Delegating the chores of authenticating users to Keycloak
ahus1
0
140
ゼロからはじめる採用広報
yutadayo
3
950
Getting to Know Your Legacy (System) with AI-Driven Software Archeology (WeAreDevelopers World Congress 2025)
feststelltaste
1
130
Should Our Project Join the CNCF? (Japanese Recap)
whywaita
PRO
0
340
ビギナーであり続ける/beginning
ikuodanaka
3
760
SEQUENCE object comparison - db tech showcase 2025 LT2
nori_shinoda
0
140
ネットワーク保護はどう変わるのか?re:Inforce 2025最新アップデート解説
tokushun
0
210
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
10
130k
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
950
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
740
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
6
300
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
Building Adaptive Systems
keathley
43
2.7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
820
GraphQLとの向き合い方2022年版
quramy
49
14k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Done Done
chrislema
184
16k
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Խͯ͠ ϨϏϡʔ࣌ͷ҉ΛݮΒͦ͏
ฐࣾͷ৽ଔ͕ࣥච͠·ͨ͠