Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PHPでのリーダブルコード/Readable code in PHP
Search
Y-KANOH
March 24, 2022
Technology
2
320
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.6k
エンジニアは伝え方が9割/90% of what engineers need is communication skills
ykanoh
4
1.2k
PHPカンファレンス関西2024 クロージング/php kansai 2024 closing
ykanoh
0
110
PHPカンファレンス関西2024 オープニング/php kansai 2024 opening
ykanoh
2
310
PHP略語クイズ/PHP Abbreviation Quiz
ykanoh
1
2.8k
PHPカンファレンス関西2024スタッフ希望者向け説明会
ykanoh
0
390
PHPマジックメソッドクイズ!/PHP Magic Method Quiz
ykanoh
0
1.6k
PHPerが再利用可能な情報提供でオフショア先とコード品質向上に取り組む / PHPer try improve the code quality
ykanoh
1
1.3k
どんとこい、PhpStorm 〜Why don't you do IDE's best!〜 / Don't KOI PhpStorm!! Why don't you do IDE's best!!
ykanoh
0
8k
Other Decks in Technology
See All in Technology
Active Directory 勉強会 第 6 回目 Active Directory セキュリティについて学ぶ回
eurekaberry
16
5.7k
MAP-7thplaceSolution
yukichi0403
2
240
私も懇親会は苦手でした ~苦手だからこそ懇親会を楽しむ方法~ / 20251127 Masaki Okuda
shift_evolve
PRO
4
530
レガシーシステム刷新における TypeSpec スキーマ駆動開発のすゝめ
tsukuha
4
900
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
0
630
Claude Code Getting Started Guide(en)
oikon48
0
110
freeeにおけるファンクションを超えた一気通貫でのAI活用
jaxx2104
0
170
意外と難しいドメイン駆動設計の話
zozotech
PRO
0
980
Symfony AI in Action
el_stoffel
2
340
Kill the Vibe?Architecture in the age of AI
stoth
1
160
How native lazy objects will change Doctrine and Symfony forever
beberlei
1
350
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
9.8k
Featured
See All Featured
Bash Introduction
62gerente
615
210k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
It's Worth the Effort
3n
187
29k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.3k
A designer walks into a library…
pauljervisheath
210
24k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
700
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
119
20k
Fireside Chat
paigeccino
41
3.7k
Being A Developer After 40
akosma
91
590k
Context Engineering - Making Every Token Count
addyosmani
9
450
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