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
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
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
410
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
Transcript
19 slides
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
More Decks by Y-KANOH
See All by Y-KANOH
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
260
君はジョシュアツリーを知っているか?名前をつけて事象を正しく認識しよう / Do you know Joshua Tree?
ykanoh
4
460
非エンジニアにも伝えるメールセキュリティ / Email security for non-engineers
ykanoh
18
7k
エンジニアは伝え方が9割/90% of what engineers need is communication skills
ykanoh
4
1.8k
PHPカンファレンス関西2024 クロージング/php kansai 2024 closing
ykanoh
0
190
PHPカンファレンス関西2024 オープニング/php kansai 2024 opening
ykanoh
2
410
PHP略語クイズ/PHP Abbreviation Quiz
ykanoh
1
3.2k
PHPカンファレンス関西2024スタッフ希望者向け説明会
ykanoh
0
480
PHPマジックメソッドクイズ!/PHP Magic Method Quiz
ykanoh
0
2k
Other Decks in Technology
See All in Technology
Kiro アップデート 2026 年 11 月号 (11 月 8 日時点) | 目指せ Kiro マスター アップデート編
inariku
PRO
2
130
常時稼働エージェントの作り方(Claude公式ブログを資料化)
minorun365
PRO
11
20k
Claude Codeで新規事業を伸ばせるか? Zennの試行錯誤の記録
wadayusuke
2
200
マネージャーをエスパーにしない マネジメントされる側から始める、働きやすい現場づくり
comi190327
0
530
農家は秘伝のタレを知らない - NOBODY KNOWS THE HIDDEN SOURCE - Kaggriculture 3rd Place Solution
masspeaks
0
380
The Author Pays
hiccupps
0
230
Steering と Hook (チームの決まりを守らせる) | 目指せ Kiro マスター 06
inariku
PRO
2
130
Kiro Web 入門 (サインインから、頼み方、PR の受け取り、クラウドの決まりまで) | 目指せ Kiro マスター 04
inariku
PRO
2
120
AI対話型分析を作成し、リリースするまでの話 / The Road to Release: Buiding AI Conversational Analytics
yappli_developers
0
140
SREのためのFinOps入門
muziyoshiz
3
1.6k
閉域網でのAPI公開の選択肢全部比較!
takano0131
2
280
Agent Harnessはどう作る?事例から学ぶAI Agentの設計思想
sergicalsix
0
320
Featured
See All Featured
Paper Plane (Part 1)
katiecoart
PRO
3
12k
A better future with KSS
kneath
240
18k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Making the Leap to Tech Lead
cromwellryan
135
10k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Building Adaptive Systems
keathley
44
3.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
480
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
320
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
610
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
Designing Powerful Visuals for Engaging Learning
tmiket
1
650