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_CodeSnifferを使ってPHPのコードをオートレビューしてみた.pdf
Search
Atsushi Nakatsugawa
PRO
May 31, 2017
Technology
1
190
PHP_CodeSnifferを使ってPHPのコードをオートレビューしてみた.pdf
第114回 PHP勉強会@東京でLT発表した際の資料です。
Atsushi Nakatsugawa
PRO
May 31, 2017
Tweet
Share
More Decks by Atsushi Nakatsugawa
See All by Atsushi Nakatsugawa
DevRelの基礎と戦略
moongift
PRO
0
18
DevRelの始め方
moongift
PRO
3
520
マンガで分かるDevRelオンライン
moongift
PRO
0
110
DevRel Online with Manga
moongift
PRO
0
65
DevRel 4コマ
moongift
PRO
0
100
DevRel 4 panel Manga
moongift
PRO
0
62
DevRelの基礎〜開発者マーケティング〜
moongift
PRO
0
25
DevRelの基礎〜DevX(開発者体験)〜
moongift
PRO
0
35
DevRelの基礎「DevRelの重要性」
moongift
PRO
0
37
Other Decks in Technology
See All in Technology
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
840
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
610
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
360
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
480
組織成長を加速させるオンボーディングの取り組み
sudoakiy
2
170
TypeScript、上達の瞬間
sadnessojisan
46
13k
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
200
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
9
1k
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
140
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Designing for humans not robots
tammielis
250
25k
Practical Orchestrator
shlominoach
186
10k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Facilitating Awesome Meetings
lara
50
6.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Writing Fast Ruby
sferik
627
61k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Site-Speed That Sticks
csswizardry
0
26
Transcript
[Confidential] © 2016 Actcat, Inc. PHP_CodeSnifferΛͬͯPHPͷ ίʔυΛΦʔτϨϏϡʔͯ͠Έͨ MOONGIFT/SideCIΤϰΝϯδΣϦετ தಞ࢘ ୈ114ճ
PHPษڧձˏ౦ژ
[Confidential] © 2016 Actcat, Inc. ࣗݾհ 2 !B@OBLBUTVHBXB GCNFNPPOHJGU தಞ࢘
גࣜձࣾ.00/(*'5දऔక 4JEF$*/$.#9PKPIJpWFΤϰΝϯδΣϦετ ៉ྷͳίʔυͱจԽΛ࡞ΔίʔυϨϏϡʔ༻$* !TJEFDJ@KBQBO GCNFTJEFDJ
[Confidential] © 2016 Actcat, Inc. PHP_CodeSnifferͱʁ ▪نʁ Generic PEAR
PSR1 PSR2 Squiz Zend 3 ▪ PHPͷίʔυΛنʹ߹͍ͬͯΔ͔νΣοΫͯ͘͠ΕΔπʔϧ http://www.infiniteloop.co.jp/docs/psr/psr-2-coding-style-guide.html https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md ͳ͘ͳͬͨʁʁ https://framework.zend.com/manual/1.12/ja/coding-standard.overview.html ։ൃݩ
[Confidential] © 2016 Actcat, Inc. Πϯετʔϧ 4 ▪ComposerΛ͏ͷ͕Ұ൪खܰ $ composer
global require "squizlabs/php_codesniffer=*" wgetͰՄ $ curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar $ php phpcs.phar -h $ curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar $ php phpcbf.phar -h
[Confidential] © 2016 Actcat, Inc. ͍ํ 5 ▪phpcs + σΟϨΫτϦ
$ phpcs . FILE: /path/to/your/code.php -------------------------------------------------------------------------------------------------- FOUND 61 ERRORS AFFECTING 38 LINES -------------------------------------------------------------------------------------------------- 2 | ERROR | [ ] Missing file doc comment 7 | ERROR | [ ] Missing @category tag in class comment ɿ 34 | ERROR | [x] Tag value indented incorrectly; expected 2 spaces but found 1 35 | ERROR | [ ] Tag cannot be grouped with parameter tags in a doc comment
[Confidential] © 2016 Actcat, Inc. ίʔσΟϯάنͷ֬ೝ 6 ▪-iͰ֬ೝͰ͖·͢ $ phpcs
-i The installed coding standards are MySource, PEAR, PSR1, PSR2, Squiz and Zend
[Confidential] © 2016 Actcat, Inc. ίʔσΟϯάنͷมߋ 7 ▪—standardͰࢦఆͰ͖·͢ $ phpcs
—standard Zend .
[Confidential] © 2016 Actcat, Inc. ίʔυ֬ೝ͢Δ߹ 8 ▪--report=codeΛ͚ͭΔ $ phpcs
--report=code FILE: /path/to/your/code.php --------------------------------------------------------------------------------------------------- FOUND 61 ERRORS AFFECTING 38 LINES --------------------------------------------------------------------------------------------------- LINE 2: ERROR [ ] Missing file doc comment --------------------------------------------------------------------------------------------------- 1: <?php >> 2: 3: namespace·Ncmb; 4:
[Confidential] © 2016 Actcat, Inc. ࢦఠʹ߹Θͤͯमਖ਼͍ͯ͘͠ 9 ▪phpcbfͰ·ͱΊͯमਖ਼Ͱ͖Δ $ phpcbf
. PHPCBF RESULT SUMMARY --------------------------------------------------------------------------------------------------- FILE FIXED REMAINING --------------------------------------------------------------------------------------------------- /path/to/your/code.php 23 38
[Confidential] © 2016 Actcat, Inc. ࣗಈमਖ਼ͷ ▪ίϝϯτࣗಈͰೖྗ͞Εͳ͍ͷͰΤϥʔ ͱͯ͠Γଓ͚·͢ɻ ͪΌΜͱίϝϯτΛॻ͖·͠ΐ͏ʂ 10
▪@ܥࣗಈૠೖ͞Ε·ͤΜ
[Confidential] © 2016 Actcat, Inc. ͱ͋ΔϓϩδΣΫτͰࢼͨ݁͠Ռ ▪ଞͷࢦఠೲಘͰ͖ΔͷҰ෦͋Δʢۭ നͱ͔ʣ ▪نʹΑͬͯ࠷ޙͷ ?>
ʹ͍ͭͯղऍ͕ҟͳ Δ ▪phpcbfͰमਖ਼Ͱ͖ͪΌ͏͚Ͳ…Ͷ͐ʁ 11 ▪ίϝϯτͷറΓ͕ਏ͍͕࣌͋Δ…
[Confidential] © 2016 Actcat, Inc. SideCIʹ͍ͭͯ ▪PHP_CodeSnifferʹରԠ͍ͯ͠·͢ʂPull RequestΛૹΔ ͱࣗಈͰνΣοΫ࣮ߦ 12
▪SideCIࣗಈͷιʔείʔυϨϏϡʔαʔϏεͰ͢ https://sideci.com/ja
[Confidential] © 2016 Actcat, Inc. ϓϦʔζɺπΠʔτ or τΡʔτʂ 13 4JEF$*ɺ1)1@$4
͕͑ΔΜͩͬͯʂ