Configuration Options

Configuration Options – A list of configuration options

PHP_CodeSniffer Configuration Options

Setting the Default Coding Standard

By default, PHP_CodeSniffer will use the PEAR coding standard if no standard is supplied on the command line. You can change the default standard by setting the default_standard configuration option.

Setting the default standard to be the Zend coding standard

     

$ phpcs --config-set default_standard Zend

Setting the Default Report Format

By default, PHP_CodeSniffer will use the full report format if no format is supplied on the command line. You can change the default report format by setting the report_format configuration option.

Setting the default report format to be the summary report

     

$ phpcs --config-set report_format summary

Hiding Warnings by Default

By default, PHP_CodeSniffer will show both errors and warnings for your code. You can hide warnings for a single script run by using the -n command line argument, but you can also enable this by default if you prefer. To hide warnings by default, set the show_warnings configuration option to 0.

Hiding warnings by default

     

$ phpcs --config-set show_warnings 0
Note: When warnings are hidden by default, you can use the -w command line argument to show them for a single script run.

Setting the Default Tab Width

By default, PHP_CodeSniffer will not convert tabs to spaces in checked files. Specifying a tab width will make PHP_CodeSniffer replace tabs with spaces. You can force PHP_CodeSniffer to replace tabs with spaces by default by setting the tab_width configuration option.

Setting the default tab width to be 4 spaces

     

$ phpcs --config-set tab_width 4
Note: When the tab width is set by default, the replacement of tabs with spaces can be disabled for a single script run by setting the tab width to zero.

Disabling the replacement of tabs with spaces

      

$ phpcs --tab-width=0 /path/to/code

Squiz Coding Standard Configuration Options

Setting the Path to JSLint

The Squiz coding standard includes a sniff that will check each JavaScript file using JSLint, a JavaScript program that looks for problems in JavaScript programs. Use the jslint_path configuration option to tell the JSLint sniff where to find the tool.

Setting the path to JSLint

     

$ phpcs --config-set jslint_path /path/to/jslint.js

As JSLint is just JavaScript code, you alos need to install Rhino to be able to execute it. Use the rhino_path configuration option to tell the JSLint sniff where to find the tool.

Setting the path to Rhino

     

$ phpcs --config-set rhino_path /path/to/rhino

Setting the Path to JavaScript Lint

The Squiz coding standard includes a sniff that will check each JavaScript file using JavaScript Lint, a tool that checks all your JavaScript source code for common mistakes without actually running the script or opening the web page. Use the jsl_path configuration option to tell the JavaScript Lint sniff where to find the tool.

Setting the path to JavaScript Lint

     

$ phpcs --config-set jsl_path /path/to/jsl

Zend Coding Standard Configuration Options

Setting the Path to the Zend Code Analyzer

The Zend coding standard includes a sniff that will check each file using the Zend Code Analyzer, a tool that comes with Zend Studio. Use the zend_ca_path configuration option to tell the Zend Code Analyzer sniff where to find the tool.

Setting the path to the Zend Code Analyzer

     

$ phpcs --config-set zend_ca_path /path/to/ZendCodeAnalyzer
Advanced Usage (Previous) Coding Standard Tutorial (Next)
Last updated: Tue, 02 Jun 2009 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.