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
PHPでのリーダブルコード/Readable code in PHP
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Y-KANOH
March 24, 2022
Technology
2
330
PHPでのリーダブルコード/Readable code in PHP
Y-KANOH
March 24, 2022
Tweet
Share
More Decks by Y-KANOH
See All by Y-KANOH
非エンジニアにも伝えるメールセキュリティ / Email security for non-engineers
ykanoh
17
5.8k
エンジニアは伝え方が9割/90% of what engineers need is communication skills
ykanoh
4
1.3k
PHPカンファレンス関西2024 クロージング/php kansai 2024 closing
ykanoh
0
120
PHPカンファレンス関西2024 オープニング/php kansai 2024 opening
ykanoh
2
330
PHP略語クイズ/PHP Abbreviation Quiz
ykanoh
1
2.8k
PHPカンファレンス関西2024スタッフ希望者向け説明会
ykanoh
0
420
PHPマジックメソッドクイズ!/PHP Magic Method Quiz
ykanoh
0
1.7k
PHPerが再利用可能な情報提供でオフショア先とコード品質向上に取り組む / PHPer try improve the code quality
ykanoh
1
1.4k
どんとこい、PhpStorm 〜Why don't you do IDE's best!〜 / Don't KOI PhpStorm!! Why don't you do IDE's best!!
ykanoh
0
8.2k
Other Decks in Technology
See All in Technology
Agile Leadership Summit Keynote 2026
m_seki
1
560
Tebiki Engineering Team Deck
tebiki
0
24k
生成AIを活用した音声文字起こしシステムの2つの構築パターンについて
miu_crescent
PRO
1
150
使いにくいの壁を突破する
sansantech
PRO
1
130
Embedded SREの終わりを設計する 「なんとなく」から計画的な自立支援へ
sansantech
PRO
3
2.3k
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
220
OWASP Top 10:2025 リリースと 少しの日本語化にまつわる裏話
okdt
PRO
3
520
Digitization部 紹介資料
sansan33
PRO
1
6.8k
ZOZOにおけるAI活用の現在 ~開発組織全体での取り組みと試行錯誤~
zozotech
PRO
5
4.9k
なぜ今、コスト最適化(倹約)が必要なのか? ~AWSでのコスト最適化の進め方「目的編」~
htan
1
110
日本の85%が使う公共SaaSは、どう育ったのか
taketakekaho
1
140
クレジットカード決済基盤を支えるSRE - 厳格な監査とSRE運用の両立 (SRE Kaigi 2026)
capytan
6
2.6k
Featured
See All Featured
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
170
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
640
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
430
Building Applications with DynamoDB
mza
96
6.9k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.6k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
64
What's in a price? How to price your products and services
michaelherold
247
13k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
120
Exploring anti-patterns in Rails
aemeredith
2
250
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
79
It's Worth the Effort
3n
188
29k
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