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
Prettier
Search
chiroruxx
April 25, 2018
Technology
0
120
Prettier
chiroruxx
April 25, 2018
Tweet
Share
More Decks by chiroruxx
See All by chiroruxx
PHPはいつから死んでいるかの調査
chiroruxx
2
440
元phperから見たGoの良いところ
chiroruxx
0
21
Go Connectへの想い
chiroruxx
0
180
GraphQLに入門してみた
chiroruxx
2
210
ドキュメンテーションコメント再入門
chiroruxx
0
100
我流カンファレンス楽しみ術
chiroruxx
0
63
最初の一歩を踏み出す言葉
chiroruxx
4
1.1k
PhpStormをIDEとして使う
chiroruxx
0
64
Goを始めて感じたPHPの魅力
chiroruxx
1
68
Other Decks in Technology
See All in Technology
LLM評価の落とし穴~開発者目線で気をつけるポイント~
rishigami
12
3.3k
From here to resilience - a travel guide
ufried
1
170
iThome2024 Wailing Wall of Enterprise Security
notsurprised
0
300
汎用ポリシー言語Rego + OPAと認可・検証事例の紹介 / Introduction Rego & OPA for authorization and validation
mizutani
1
190
知識と実践を紡ぐGenAI / Connecting Knowledge and experience with GenAI
aki_moon
2
190
株式会社EventHub・エンジニア採用資料
eventhub
0
2.1k
Password cracking: past, present, future
openwall
0
300
.NET GraphQL Client のリアル
sansantech
PRO
1
460
Blazor WASM × Code-first gRPC で始める C# ⼤統⼀理論
sansantech
PRO
1
920
データベース05: SQL(2/3) 結合質問
trycycle
0
110
データベース04: SQL (1/3) 単純質問 & 集約演算
trycycle
0
180
The depthes of profiling Ruby - RubyKaigi 2024
osyoyu
0
260
Featured
See All Featured
Scaling GitHub
holman
457
140k
Atom: Resistance is Futile
akmur
260
25k
Facilitating Awesome Meetings
lara
43
5.6k
Building Better People: How to give real-time feedback that sticks.
wjessup
356
18k
The Language of Interfaces
destraynor
151
23k
Testing 201, or: Great Expectations
jmmastey
30
6.4k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
Infographics Made Easy
chrislema
238
18k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
26
2.3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
14
1.5k
Clear Off the Table
cherdarchuk
86
310k
Transcript
PRETTIER PHP勉強会@東京 前田 和人
自己紹介 ▪ 前田 和人 ▪ @chiroruxxxx ▪ 弁護士ドットコム株式会社 ▪ Android派
None
Prettierってなに
Prettierとは? ▪ JavaScript®界隈で有名なコードフォーマッター ▪ Gopherの人はgofmtを思い浮かべてくれるといいです ▪ それのPHP版が出たという話
インストール $ yarn add --dev prettier/prettier @prettier/plugin-php ▪ これだけ!
実行 ▪ $ yarn run prettier /path/to/file –write ▪ Writeオプションがない場合は結果が出力されて終わる
▪ Writeオプションがある場合はファイルが書き換わる
使用例 <?php $indent = function () { return 2; };
<?php $indent=function(){return 2;};
php-cbfやphp-cs-fixerで 良いのでは
他ツールとの違い ▪ php-cbf・php-cs-fixer – PSRなどの様々なコーディング規約に則っているかを チェックする – 多くのオプションがあり独自カスタマイズ可能 – 違反をチェックしてくれる
▪ pritter – 対応しているものはPSR-1, PSR-2, PSR-12のみ – なるべくオプションを制限 – 違反という概念がない
その他の魅力 ▪ 長い行の自動改行 <?php $result = preg_match('@.*/ab.@', 'tooLongStriiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing!'); <?php $result
= preg_match( '@.*/ab.@', 'tooLongStriiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing!' );
その他の魅力 ▪ 無駄なスペースの除去 <?php $a = 'b’; <?php $a =
'b';
まとめ ▪ 良い – 細かい部分までフォーマットしてくれる – 設定がほぼ要らない ▪ 悪い –
JavaScript®依存 – ドキュメントが少ない – 細かい設定ができない ▪ アルファ版なので、今後を見守りたいですね