Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PHPでのリーダブルコード/Readable code in PHP
Search
Y-KANOH
March 24, 2022
Technology
390
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PHPでのリーダブルコード/Readable code in PHP
Y-KANOH
March 24, 2022
More Decks by Y-KANOH
See All by Y-KANOH
君はジョシュアツリーを知っているか?名前をつけて事象を正しく認識しよう / Do you know Joshua Tree?
ykanoh
4
310
非エンジニアにも伝えるメールセキュリティ / Email security for non-engineers
ykanoh
18
6.8k
エンジニアは伝え方が9割/90% of what engineers need is communication skills
ykanoh
4
1.7k
PHPカンファレンス関西2024 クロージング/php kansai 2024 closing
ykanoh
0
180
PHPカンファレンス関西2024 オープニング/php kansai 2024 opening
ykanoh
2
390
PHP略語クイズ/PHP Abbreviation Quiz
ykanoh
1
3.1k
PHPカンファレンス関西2024スタッフ希望者向け説明会
ykanoh
0
470
PHPマジックメソッドクイズ!/PHP Magic Method Quiz
ykanoh
0
2k
PHPerが再利用可能な情報提供でオフショア先とコード品質向上に取り組む / PHPer try improve the code quality
ykanoh
1
1.5k
Other Decks in Technology
See All in Technology
synctest時代のhttptest Go 1.27で変わるHTTPサーバテストの裏側 / go conference2026 synctest and httptest
budougumi0617
1
290
ASTを使って影響範囲を特定する
nealle
0
120
目の前の楽しいが人生を変える - コミュニティの螺旋の歩き方と楽しむコツ / change your life
soudai
PRO
3
170
GuardDuty 検知対応を DevOps Agent で効率化しようとしている話 / GuardDuty Investigations with DevOps Agent
masahirokawahara
1
340
Bet AI Day 2026丨Production-Ready AI Agents — エンタープライズの実務を任せるための設計と運用
layerx
PRO
4
2.6k
DEFCON34-Write-up_HYCu-MYCu
daikiokazaki
0
110
AIとペアプロを始める。人とのペアプロをやめる。ペアプロの良さを改めて知る。もっと好きになった。 / Rediscovering Pair Programming
honyanya
1
300
推論の観測、できていますか? 〜 Google Cloud Gemini Enterprise Agent Platformで 3つの Gemini モデルを実測して踏んだ、評価の罠 〜
shukob
PRO
0
180
OpenTelemetry eBPF Instrumentationの舞台裏 / Behind the Scenes of OpenTelemetry eBPF Instrumentation
ymotongpoo
3
390
Sigmaユーザーのための有用リソース一挙公開 & Sigmaで使えるMCP #sigma_ucj /useful-resources-for-sigma-computing-users-and-mcps-with-sigma
shinyaa31
0
170
現場に行くだけでは足りない——プロダクトエンジニアが業務の流れを捉える観点と、その鍛え方
takumiengineering
0
340
プロダクト思考 × 基盤思考を AIで実現する Compound Engineering
tkc66buzz
1
300
Featured
See All Featured
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Are puppies a ranking factor?
jonoalderson
2
3.9k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
490
Raft: Consensus for Rubyists
vanstee
141
7.7k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.2k
So, you think you're a good person
axbom
PRO
2
2.1k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
310
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
270
Transcript
PHPでの リーダブルコード
加納 悠史 カノウユウジ PHPer @Ykanoh65 株式会社 ラクス
PHP使っている人
PHP使っていない人
PHPは変な言語? メリット ▰ すぐ使える ▰ 曖昧な書き方でもすぐ動く 5
PHPは変な言語? デメリット ▰ 曖昧なままなのでバグが起きやすい ▰ 変な記述でもとりあえず動く 6
デメリット回避のために
テクニックが必要
PHPで バグを減らす 記述方 9
1. PHPDoc ▰ 関数やクラスに記載するコメント ▰ PHPでは "型を指定する" ために使用 10
None
1. PHPDoc ▰ 関数やクラスに記載するコメント ▰ PHPでは "型を指定する" ために使用 ▰ 言語仕様以外で型が指定できる貴重なツール
12
2. 名前付き引数 ▰ PHP8.0 の新機能 ▰ 現在の最新は PHP8.1 ▰ 引数の初期値指定の煩雑さを回避
13
function hoge($startIndex=0, $num=0, $max=10, $min=1) { // ... } hoge(3,
12, 11); // min にはデフォルト値の 1 が入る hoge(0, 0, 10, 5); // min だけデフォルト値でないものを入れる場合に煩雑 hoge(min:5); // PHP 8.0 ではこのように書ける hoge(startIndex:3, num:12, max:11, min:1); // デフォルト値以外でも引数の意味がわかりやすくなる
2. 名前付き引数 ▰ PHP8.0 の新機能 ▰ 引数の初期値指定の煩雑さを回避 ▰ ぱっと見で引数の意味を理解できる IDE使ってたら不要かもしれないが...
15
PhpStorm の場合
3. PSR ▰ PHPの規約集 ▰ 複数のルールが存在 ▰ プロジェクトで採用ルールを選んで利用 17
https://www.php-fig.org/psr/
まとめ ▰ PHPDoc ▰ 名前付き引数 ▰ PSR 19