您的位置:首页 > Web前端

php_codesninffer phpcs用法学习使用:

2016-01-12 19:26 357 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: