CV大法好,好就好在TMDB 接手一外包代码你就知道有多惨
phpcpd
- 用于PHP代码的复制/黏贴检测器
phpcpd
- PHP Copy/Paste Detector
1 2 3 4 5 6 7 8 9 composer require --dev sebastian/phpcpd phpcpd --fuzzy /项目目录/ phpcpd --fuzzy /项目目录/ > /导出文件/ phpcpd --fuzzy ./App > ./app.txt
phpdcd
- PHP代码的死代码检测器
phpdcd
- PHP Dead Code Detector
1 2 composer global require 'sebastian/phpdcd=*'
phpcs
- PHP代码质量检测器
phpcs
- PHP Code Sniffer
1 2 composer global require "squizlabs/php_codesniffer=*"
安装完后就会在全局的 Vendor
目录下的 bin
中生成两个软链接:
1 2 phpcbf -> ../squizlabs/php_codesniffer/bin/phpcbf phpcs -> ../squizlabs/php_codesniffer/bin/phpcs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 <?php namespace App \Http \Controllers ;use App \Traits \Tool ;class TestController extends Controller { public function test_i18n ( ) { return Tool ::sysMsg ('SYS_MSG_TEST' ); } public function test_i18n2 ( ) { return Tool ::sysMsg ('SYS_MSG_TEST' , 'en' ); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 $ phpcs TestController.php FILE: D:\app\phpStudy\PHPTutorial\WWW\Lumen\app\Http\Controllers\TestController.php ---------------------------------------------------------------------------------------------- FOUND 8 ERRORS AFFECTING 4 LINES ---------------------------------------------------------------------------------------------- 2 | ERROR | [ ] Missing file doc comment 4 | ERROR | [ ] Missing doc comment for class TestController 6 | ERROR | [ ] Missing doc comment for function test_i18n () 6 | ERROR | [ ] Public method name "TestController ::test_i18n " is not in camel caps format 6 | ERROR | [x ] Opening brace should be on a new line 10 | ERROR | [ ] Missing doc comment for function test_i18n2 () 10 | ERROR | [ ] Public method name "TestController ::test_i18n2 " is not in camel caps format 10 | ERROR | [x ] Opening brace should be on a new line ---------------------------------------------------------------------------------------------- PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------------------------------- Time : 75ms ; Memory : 4MB
1 2 3 4 5 6 7 8 9 10 11 12 $ phpcbf TestController.php PHPCBF RESULT SUMMARY -------------------------------------------------------------------------------------------------- FILE FIXED REMAINING -------------------------------------------------------------------------------------------------- D:\app\phpStudy\PHPTutorial\WWW\Lumen\app\Http\Controllers\TestController.php 2 6 -------------------------------------------------------------------------------------------------- A TOTAL OF 2 ERRORS WERE FIXED IN 1 FILE -------------------------------------------------------------------------------------------------- Time: 79 ms; Memory: 4 MB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <?php namespace App \Http \Controllers ;use App \Traits \Tool ;class TestController extends Controller { public function test_i18n ( ) { return Tool ::sysMsg ('SYS_MSG_TEST' ); } public function test_i18n2 ( ) { return Tool ::sysMsg ('SYS_MSG_TEST' , 'en' ); } }
参考