且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

php_codesninffer phpcs用法学习使用:

更新时间:2021-11-21 04:47:51

 

 

购买阿里云相关服务,这里可以领取优惠券, 有的产品5折优惠哟, 注意, 领取的优惠券30天内有效,尽快使用:
领取方式:进入链接后 页面下拉 一键领取全部 或者按需每次领取对应的优惠,领取链接:
点击此处链接领取
https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=s306eooi&utm_source=s306eooi
如果有需要, 可以帮助部署LNMP环境, 价格80,学生可以商量

php_codesninffer phpcs用法学习使用:  


18:34 2016/1/12
php_codesninffer phpcs用法学习使用:
可以加一个参数设置结果输出为各种格式:
如source格式:
$ phpcs -s --report=source /path/to/code
原文:
To show source codes instead of friendly names, use the -s command line argument.

Sample PHP_CodeSniffer source code output

$ phpcs -s --report=source /path/to/code


输出显示时显示屏幕一般很小,可以设置屏幕大小:
Specifying a Report Width
By default, PHP_CodeSniffer will print all screen-based reports 80 characters wide. File paths will be truncated if they don't fit within this limit and error messages will be wrapped across multiple lines. You can increase the report width to show longer file paths and limit the wrapping of error messages using the -report-width command line argument.

Setting the report width to be 120 characters

$ phpcs --report-width=120 --report=summary /path/to/code/myfile.php

很有用的是可以不输出到屏幕而保存到文件进行查看:
Writing a full report to a file and a summary report to the screen

$ phpcs --report-full=/path/to/full.txt --report-summary /path/to/code

很有用的一个用法,把结果输出到屏幕的同时保存到文件:
把phpcs + 文件名运行的结果输出到屏幕的同时输入保存到一个指定文件:
phpcs --reprt-full=保存的文件 index.php
原文:
Writing a Report to a File
PHP_CodeSniffer always prints the specified report to the screen, but it can also be told to write a copy of the report to a file. When writing to a file, all internal parsing errors and verbose output PHP_CodeSniffer produces will not be included in the file. This feature is particularly useful when using report types such as XML and CSV that are often parsed by scripts or used with continuous integration software.

To write a copy of a report to a file, use the --report-file command line argument.

Writing a report to a file

$ phpcs --report=xml --report-file=/path/to/file.xml /path/to/code

也可以把结果部分保存到文件,部分输出大屏幕:
You can print some reports to the screen and other reports to files.

Writing a full report to a file and a summary report to the screen

$ phpcs --report-full=/path/to/full.txt --report-summary /path/to/code

还可以输出不同格式到不同的多个文件:
You can write the reports to separate files by specifying the path to the output file after each report argument.

Writing a full and summary report to a file

$ phpcs --report-full=/path/to/full.txt --report-summary=/path/to/summary.txt /path/to/code