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
880
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.9k
学びの文化を育む社内読書会のススメ
edvakf
0
270
フルCDNアーキテクチャでサービス設計した話
edvakf
5
4k
Goでバイナリを読む+α
edvakf
1
950
お前はこれまでに作ったAPIの数を覚えているのか?
edvakf
0
2.6k
「ふつうのRailsアプリケーション」についての考え方
edvakf
2
860
Other Decks in Technology
See All in Technology
Amazon GuardDuty での脅威検出:脅威検出の実例から学ぶ
kintotechdev
0
110
LLMをツールからプラットフォームへ〜Ai Workforceの戦略〜 #BetAIDay
layerx
PRO
1
980
家族の思い出を形にする 〜 1秒動画の生成を支えるインフラアーキテクチャ
ojima_h
3
1.1k
MCP認可の現在地と自律型エージェント対応に向けた課題 / MCP Authorization Today and Challenges to Support Autonomous Agents
yokawasa
5
2.3k
リモートワークで心掛けていること 〜AI活用編〜
naoki85
0
150
薬屋のひとりごとにみるトラブルシューティング
tomokusaba
0
330
Foundation Model × VisionKit で実現するローカル OCR
sansantech
PRO
1
370
リリース2ヶ月で収益化した話
kent_code3
1
280
Rubyの国のPerlMonger
anatofuz
3
740
猫でもわかるQ_CLI(CDK開発編)+ちょっとだけKiro
kentapapa
0
3.5k
Instant Apps Eulogy
cyrilmottier
1
110
Bet "Bet AI" - Accelerating Our AI Journey #BetAIDay
layerx
PRO
4
1.7k
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
The World Runs on Bad Software
bkeepers
PRO
70
11k
Speed Design
sergeychernyshev
32
1.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
47
9.6k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Embracing the Ebb and Flow
colly
86
4.8k
The Invisible Side of Design
smashingmag
301
51k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
1k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Docker and Python
trallard
45
3.5k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
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Խͯ͠ ϨϏϡʔ࣌ͷ҉ΛݮΒͦ͏
ฐࣾͷ৽ଔ͕ࣥච͠·ͨ͠