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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Y-KANOH
March 24, 2022
Technology
2
340
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.9k
エンジニアは伝え方が9割/90% of what engineers need is communication skills
ykanoh
4
1.3k
PHPカンファレンス関西2024 クロージング/php kansai 2024 closing
ykanoh
0
130
PHPカンファレンス関西2024 オープニング/php kansai 2024 opening
ykanoh
2
340
PHP略語クイズ/PHP Abbreviation Quiz
ykanoh
1
2.9k
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
作るべきものと向き合う - ecspresso 8年間の開発史から学ぶ技術選定 / 技術選定con findy 2026
fujiwara3
6
1.6k
Digitization部 紹介資料
sansan33
PRO
1
6.9k
なぜAIは組織を速くしないのか 令和の腑分け
sugino
80
50k
Snowflake Night #2 LT
taromatsui_cccmkhd
0
270
Microsoft Fabric のワークスペースと容量の設計原則
ryomaru0825
2
210
Databricksアシスタントが自分で考えて動く時代に! エージェントモード体験もくもく会
taka_aki
0
210
論文検索を日本語でできるアプリを作ってみた
sailen2
0
140
[続・営業向け 誰でも話せるOCI セールストーク] AWSよりOCIの優位性が分からない編(2026年2月20日開催)
oracle4engineer
PRO
0
140
三菱UFJ銀行におけるエンタープライズAI駆動開発のリアル / Enterprise AI_Driven Development at MUFG Bank: The Real Story
muit
10
20k
2026年のAIエージェント構築はどうなる?
minorun365
12
2.9k
OCI技術資料 : 外部接続 VPN接続 詳細
ocise
1
10k
AI が Approve する開発フロー / How AI Reviewers Accelerate Our Development
zaimy
1
230
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
310
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
260
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
72k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
190
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.2k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
130
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
92
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
140
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.3k
Code Review Best Practice
trishagee
74
20k
BBQ
matthewcrist
89
10k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
170
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