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
400
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
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
230
君はジョシュアツリーを知っているか?名前をつけて事象を正しく認識しよう / Do you know Joshua Tree?
ykanoh
4
380
非エンジニアにも伝えるメールセキュリティ / Email security for non-engineers
ykanoh
18
7k
エンジニアは伝え方が9割/90% of what engineers need is communication skills
ykanoh
4
1.7k
PHPカンファレンス関西2024 クロージング/php kansai 2024 closing
ykanoh
0
190
PHPカンファレンス関西2024 オープニング/php kansai 2024 opening
ykanoh
2
400
PHP略語クイズ/PHP Abbreviation Quiz
ykanoh
1
3.1k
PHPカンファレンス関西2024スタッフ希望者向け説明会
ykanoh
0
470
PHPマジックメソッドクイズ!/PHP Magic Method Quiz
ykanoh
0
2k
Other Decks in Technology
See All in Technology
コンテナ運用におけるネットワーク・コンテナコストの削減方法/How to Reduce Network and Container Costs in Container Operations
masakiokuda
2
390
2026-10-24 JAWS JAWS-UG 茨城 #18 IAM Policy Autopilotってなにさ。terraform planからIAM Policyつくれるの? / What's IAM Policy Autopilot
masasuzu
0
110
AWSDirectConnectの構築の進め方を整理してみた
masa_my
1
150
Turning Repos into the Product Second Brain with an LLM Wiki
linedevth
0
140
Kiro Crewで「みのるん式」仕事術やってみた
minorun365
PRO
3
1k
ポケモン対戦を自動で記録して振り返ろう
fufufukakaka
0
290
DevelopersIO 2026 Tokyo 現時点の衛星通信サービスの現状を整理してみる
maroon1st
0
230
OptunaHub: ブラックボックス最適化のためのプラットフォーム
pfn
PRO
0
150
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
140
契約で守るコンパウンドプロダクトのデザインシステム
yug1224
1
270
AWS DevOps Agentはどこまで任せられるか 〜機能の現在地と、機能拡張の実践〜
nyankotaro
0
170
導入から定着へ ~コーディングエージェントを日常業務に組み込む実践知~
yukisakai1225
0
210
Featured
See All Featured
Google's AI Overviews - The New Search
badams
0
1.6k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
530
Marketing to machines
jonoalderson
1
5.9k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
320
The Mindset for Success: Future Career Progression
greggifford
PRO
0
540
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
310
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
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