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
にわ
March 23, 2026
Programming
13
0
Share
「値はあるのに空判定」される怪奇現象を追ったら、犯人は __isset だった話 / PHPerKaigi 2026 ルーキーズLT
プロポーザル:
https://fortee.jp/phperkaigi-2026/proposal/5417d2ae-f878-443c-9b39-79f1a1f7de92
にわ
March 23, 2026
Other Decks in Programming
See All in Programming
安いハードウェアでVulkan
fadis
1
880
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
1.3k
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
320
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
390
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.5k
我々はなぜ「層」を分けるのか〜「関心の分離」と「抽象化」で手に入れる変更に強いシンプルな設計〜 #phperkaigi / PHPerKaigi 2026
shogogg
2
770
Cyrius ーLinux非依存にコンテナをネイティブ実行する専用OSー
n4mlz
0
270
Coding at the Speed of Thought: The New Era of Symfony Docker
dunglas
0
4.3k
ポーリング処理廃止によるイベント駆動アーキテクチャへの移行
seitarof
3
1.3k
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
140
PHPで TLSのプロトコルを実装してみる
higaki_program
0
730
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
190
Featured
See All Featured
Designing for Performance
lara
611
70k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
470
Making Projects Easy
brettharned
120
6.6k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
490
So, you think you're a good person
axbom
PRO
2
2k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
53k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
150
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
160
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.8k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
170
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
ご清聴ありがとうございました!