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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Y-KANOH
March 24, 2022
Technology
2
330
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.8k
エンジニアは伝え方が9割/90% of what engineers need is communication skills
ykanoh
4
1.3k
PHPカンファレンス関西2024 クロージング/php kansai 2024 closing
ykanoh
0
120
PHPカンファレンス関西2024 オープニング/php kansai 2024 opening
ykanoh
2
330
PHP略語クイズ/PHP Abbreviation Quiz
ykanoh
1
2.8k
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
MCPでつなぐElasticsearchとLLM - 深夜の障害対応を楽にしたい / Bridging Elasticsearch and LLMs with MCP
sashimimochi
0
140
コスト削減から「セキュリティと利便性」を担うプラットフォームへ
sansantech
PRO
3
1.3k
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
67k
2人で作ったAIダッシュボードが、開発組織の次の一手を照らした話― Cursor × SpecKit × 可視化の実践 ― Qiita AI Summit
noalisaai
1
370
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
120
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
410
Deno・Bunの標準機能やElysiaJSを使ったWebSocketサーバー実装 / ラーメン屋を貸し切ってLT会! IoTLT 2026新年会
you
PRO
0
290
変化するコーディングエージェントとの現実的な付き合い方 〜Cursor安定択説と、ツールに依存しない「資産」〜
empitsu
4
1.3k
データの整合性を保ちたいだけなんだ
shoheimitani
8
2.9k
Meshy Proプラン課金した
henjin0
0
250
プロポーザルに込める段取り八分
shoheimitani
1
170
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
Featured
See All Featured
Tell your own story through comics
letsgokoyo
1
800
Visualization
eitanlees
150
17k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
270
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
96
A Soul's Torment
seathinner
5
2.2k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
240
KATA
mclloyd
PRO
34
15k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
89
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