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
910
assertぐらいでエバルんじゃねえ!
〜Phanがもたらす堅牢なPHP〜
Atsushi Takayama
December 15, 2016
Tweet
Share
More Decks by Atsushi Takayama
See All by Atsushi Takayama
最高の開発者体験の追求が開発生産性を改善し続ける文化を生み出した話
edvakf
3
1.4k
NeurIPS 2021 論文読み会: How Modular should Neural Module Networks Be for Systematic Generalization?
edvakf
0
190
8年物のJavaのシステムをKotlinに変えていく選択に至るまで
edvakf
2
1.1k
ピクシブ社内のImageFlux利用事例紹介
edvakf
2
3k
学びの文化を育む社内読書会のススメ
edvakf
0
300
フルCDNアーキテクチャでサービス設計した話
edvakf
5
4k
Goでバイナリを読む+α
edvakf
1
980
お前はこれまでに作ったAPIの数を覚えているのか?
edvakf
0
2.7k
「ふつうのRailsアプリケーション」についての考え方
edvakf
2
900
Other Decks in Technology
See All in Technology
迷わない!AI×MCP連携のリファレンスアーキテクチャ完全ガイド
cdataj
0
570
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
Introduction to Bill One Development Engineer
sansan33
PRO
0
350
Data Intelligence on Lakehouse Paradigm
scotthsieh825
0
160
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
1
920
AI Agent Agentic Workflow の可観測性 / Observability of AI Agent Agentic Workflow
yuzujoe
2
2k
AI との良い付き合い方を僕らは誰も知らない (WSS 2026 静岡版)
asei
1
330
AI Agent Standards and Protocols: a Walkthrough of MCP, A2A, and more...
glaforge
0
340
Proxmoxで作る自宅クラウド入門
koinunopochi
0
110
困ったCSVファイルの話
mottyzzz
0
270
RALGO : AIを組織に組み込む方法 -アルゴリズム中心組織設計- #RSGT2026 / RALGO: How to Integrate AI into an Organization – Algorithm-Centric Organizational Design
kyonmm
PRO
3
1.4k
手軽に作れる電卓を作って イベントソーシングに親しもう CQRS+ESカンファレンス2026
akinoriakatsuka
0
430
Featured
See All Featured
A better future with KSS
kneath
240
18k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
81
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
170
Technical Leadership for Architectural Decision Making
baasie
0
220
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
The untapped power of vector embeddings
frankvandijk
1
1.5k
The Cult of Friendly URLs
andyhume
79
6.8k
A designer walks into a library…
pauljervisheath
210
24k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
A Tale of Four Properties
chriscoyier
162
24k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
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Խͯ͠ ϨϏϡʔ࣌ͷ҉ΛݮΒͦ͏
ฐࣾͷ৽ଔ͕ࣥච͠·ͨ͠