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
君はジョシュアツリーを知っているか?名前をつけて事象を正しく認識しよう / Do you know Joshua Tree?
ykanoh
4
330
非エンジニアにも伝えるメールセキュリティ / Email security for non-engineers
ykanoh
18
6.8k
エンジニアは伝え方が9割/90% of what engineers need is communication skills
ykanoh
4
1.7k
PHPカンファレンス関西2024 クロージング/php kansai 2024 closing
ykanoh
0
180
PHPカンファレンス関西2024 オープニング/php kansai 2024 opening
ykanoh
2
390
PHP略語クイズ/PHP Abbreviation Quiz
ykanoh
1
3.1k
PHPカンファレンス関西2024スタッフ希望者向け説明会
ykanoh
0
470
PHPマジックメソッドクイズ!/PHP Magic Method Quiz
ykanoh
0
2k
PHPerが再利用可能な情報提供でオフショア先とコード品質向上に取り組む / PHPer try improve the code quality
ykanoh
1
1.5k
Other Decks in Technology
See All in Technology
AgentCore Runtime上にAgentic Coding基盤を構築・展開する際の設計ポイントと限界点 / Design considerations and limitations when building an agentic coding platform on AgentCore Runtime
har1101
6
740
Why Agent Cost Needs Observability
nttcom
0
150
AIに賢く動いてもらうためのコンテキスト〜Snowflake女子会 vol.8
snowwmn0824
0
170
その Lambda、8分で 管理者権限まで奪われます
k1nakayama
7
3.7k
開発投資の期待値を上げるプロダクトロードマップづくり ~プロダクトエンジニアが越境して事業を伸ばす~
kekekenta
1
250
顧客に向き合う開発組織へ。リアーキテクチャとフィーチャーチーム化で挑む組織改革
safie
0
2.4k
10Xに技術的負債をもたらした「2つの境界の歪み」その構造と解消への営み
10xinc
0
2.4k
絵ではじめるKubernetesセキュリティ
aoi1
5
710
[Kiro Meetup #7] Kiro Crew Dive Deep
konippi
0
300
ボードゲームの遊び相手をFoundation Modelsで作る / iOSDC Japan 2026
genda
0
160
Antigravity SDK for the Java Developer
glaforge
0
190
Mastering Agentic Development: Harness Engineering for Effective Coding Agents
konippi
3
490
Featured
See All Featured
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
290
Design in an AI World
tapps
1
330
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
The Pragmatic Product Professional
lauravandoore
37
7.5k
Being A Developer After 40
akosma
91
590k
Evolving SEO for Evolving Search Engines
ryanjones
0
300
Navigating Team Friction
lara
192
16k
Facilitating Awesome Meetings
lara
57
7.1k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
380
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
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