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
「値はあるのに空判定」される怪奇現象を追ったら、犯人は __isset だった話 / PHPe...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
にわ
March 23, 2026
Programming
71
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
「値はあるのに空判定」される怪奇現象を追ったら、犯人は __isset だった話 / PHPerKaigi 2026 ルーキーズLT
プロポーザル:
https://fortee.jp/phperkaigi-2026/proposal/5417d2ae-f878-443c-9b39-79f1a1f7de92
にわ
March 23, 2026
More Decks by にわ
See All by にわ
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
shibuchaaaan
0
250
Other Decks in Programming
See All in Programming
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
480
Foundation Models frameworkで画像分析
ryodeveloper
1
600
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
210
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
540
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
310
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
100
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
susisu
0
150
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
590
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
18k
プロポーザルを書いてもらう
pvcresin
0
300
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
180
Featured
See All Featured
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
850
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
270
Documentation Writing (for coders)
carmenintech
77
5.4k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
660
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
New Earth Scene 8
popppiees
3
2.5k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
630
Testing 201, or: Great Expectations
jmmastey
46
8.2k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
Fireside Chat
paigeccino
42
4k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Transcript
「値はあるのに空判定」される怪奇現象を 追ったら、犯人は __isset() だった話 にわ
COPYRIGHT © EUSTYLE LABORATORY. ALL RIGHTS RESERVED. 自己紹介 • お酒、バンド、バイクが好き
• 不動産営業 ->SES ->ユースタイルラボラトリー株式会社 ◦ (ちょっと古い) 社内システム開発担当
COPYRIGHT © EUSTYLE LABORATORY. ALL RIGHTS RESERVED. 3
COPYRIGHT © EUSTYLE LABORATORY. ALL RIGHTS RESERVED. protectedプロパティに外部からアクセス 4 PHP:
オーバーロード - Manual
COPYRIGHT © EUSTYLE LABORATORY. ALL RIGHTS RESERVED. 事件発生! 5 true
値が入っているのに「空」判定!? 🤯
COPYRIGHT © EUSTYLE LABORATORY. ALL RIGHTS RESERVED. empty()のリファレンスもっかい見よう 6 isset()が無いのが怪しい!?
PHP: empty - Manual
COPYRIGHT © EUSTYLE LABORATORY. ALL RIGHTS RESERVED. 7
COPYRIGHT © EUSTYLE LABORATORY. ALL RIGHTS RESERVED. つまり、こういうこと 8 まず
__isset() で存在を確認し、 無いなら __get() を使うことなく「空」とみなす 「empty() は __get() を 直接呼ばない」
COPYRIGHT © EUSTYLE LABORATORY. ALL RIGHTS RESERVED. 今回の事象の解決策 9 __isset()
を実装 __get()と__isset()は セットで実装する public にする アクセス制御が不要なら 設計をシンプルに 明示的に比較 $obj->id !== 0 などで明⽰的に⽐較
COPYRIGHT © EUSTYLE LABORATORY. ALL RIGHTS RESERVED. まとめ 10 •
empty() はアクセス不能プロパティに対し、まず __isset() を確認する • __isset() が無いと __get() は呼ばれず、即「空」と判定される • __get() を書くなら __isset() も必ず書こう! マジックメソッドは 用法用量を守って正しくお使いください
COPYRIGHT © EUSTYLE LABORATORY. ALL RIGHTS RESERVED. ちなみに、 PHP8.1以降なら… 11
ご清聴ありがとうございました!