### Generic.Formatting.MultipleStatementAlignment: Aligned at start example Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Shows the resulting formatting when alignAtEnd is set to false, with assignment operators aligned at the start. ```php $foo = 'foo'; $foo .= 'bar'; ``` -------------------------------- ### Check file with installed PEAR standard using --standard Source: https://github.com/squizlabs/php_codesniffer/wiki/Usage Use the --standard command line argument to specify an installed coding standard. The example checks myfile.inc against the PEAR standard, which is installed by default. ```bash $ phpcs --standard=PEAR /path/to/code/myfile.inc ``` -------------------------------- ### Install with PEAR Source: https://github.com/squizlabs/php_codesniffer/blob/master/README.md Installs PHP_CodeSniffer using the PEAR installer. Requires PEAR to be installed first; this makes the phpcs and phpcbf commands immediately available. ```bash pear install PHP_CodeSniffer ``` -------------------------------- ### Download PHAR files with curl or wget and test Source: https://github.com/squizlabs/php_codesniffer/blob/master/README.md Downloads the phpcs.phar and phpcbf.phar files using either curl or wget, then tests them with the -h flag. Use this to get started quickly without a package manager. ```bash # Download using curl curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar # Or download using wget wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar # Then test the downloaded PHARs php phpcs.phar -h php phpcbf.phar -h ``` -------------------------------- ### Print installed coding standards with -i Source: https://github.com/squizlabs/php_codesniffer/wiki/Usage Use the -i command line argument to print a list of installed coding standards. The output shows the available standards, e.g., MySource, PEAR, PHPCS, PSR1, PSR2, Squiz and Zend. ```bash $ phpcs -i The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz and Zend ``` -------------------------------- ### Scope map output for example file Source: https://github.com/squizlabs/php_codesniffer/wiki/Advanced-Usage Verbose tokeniser output showing the step-by-step creation of the scope map for the example file. It displays token processing and scope opener/closer detection. ```text *** START SCOPE MAP *** Start scope map at 1: T_IF => if Process token 2 []: T_WHITESPACE => Process token 3 []: T_OPEN_PARENTHESIS => ( * skipping parenthesis * Process token 6 []: T_WHITESPACE => Process token 7 []: T_OPEN_CURLY_BRACKET => { => Found scope opener for 1 (T_IF) Process token 8 [opener:7;]: T_WHITESPACE => \n Process token 9 [opener:7;]: T_WHITESPACE => Process token 10 [opener:7;]: T_ECHO => echo Process token 11 [opener:7;]: T_WHITESPACE => Process token 12 [opener:7;]: T_CONSTANT_ENCAPSED_STRING => 'Condition was true' Process token 13 [opener:7;]: T_SEMICOLON => ; Process token 14 [opener:7;]: T_WHITESPACE => \n Process token 15 [opener:7;]: T_CLOSE_CURLY_BRACKET => } => Found scope closer for 1 (T_IF) *** END SCOPE MAP *** ``` -------------------------------- ### Install globally with Composer Source: https://github.com/squizlabs/php_codesniffer/blob/master/README.md Installs PHP_CodeSniffer system-wide via Composer. Ensure the composer bin dir (default ~/.composer/vendor/bin/) is in your PATH; check with 'composer global config bin-dir --absolute'. ```bash composer global require "squizlabs/php_codesniffer=*" ``` -------------------------------- ### Install with Phive Source: https://github.com/squizlabs/php_codesniffer/blob/master/README.md Installs PHP_CodeSniffer as a project tool using Phive. After installation, the tools are available in the tools directory. ```bash phive install phpcs phive install phpcbf ``` -------------------------------- ### Generic.Formatting.SpaceAfterCast: No space example Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Shows an alternative style with no space after the cast. ```php $var = (int)$foo; ``` -------------------------------- ### Level map output for example file Source: https://github.com/squizlabs/php_codesniffer/wiki/Advanced-Usage Verbose tokeniser output showing the step-by-step creation of the level map for the example file. It displays token processing with level and condition information. ```text *** START LEVEL MAP *** Process token 0 on line 1 [lvl:0;]: T_OPEN_TAG => if Process token 2 on line 2 [lvl:0;]: T_WHITESPACE => Process token 3 on line 2 [lvl:0;]: T_OPEN_PARENTHESIS => ( Process token 4 on line 2 [lvl:0;]: T_VARIABLE => $condition Process token 5 on line 2 [lvl:0;]: T_CLOSE_PARENTHESIS => ) Process token 6 on line 2 [lvl:0;]: T_WHITESPACE => Process token 7 on line 2 [lvl:0;]: T_OPEN_CURLY_BRACKET => { => Found scope opener for 1 (T_IF) * level increased * * token 1 (T_IF) added to conditions array * Process token 8 on line 2 [lvl:1;conds;T_IF;]: T_WHITESPACE => \n Process token 9 on line 3 [lvl:1;conds;T_IF;]: T_WHITESPACE => Process token 10 on line 3 [lvl:1;conds;T_IF;]: T_ECHO => echo Process token 11 on line 3 [lvl:1;conds;T_IF;]: T_WHITESPACE => Process token 12 on line 3 [lvl:1;conds;T_IF;]: T_CONSTANT_ENCAPSED_STRING => 'Condition was true' Process token 13 on line 3 [lvl:1;conds;T_IF;]: T_SEMICOLON => ; Process token 14 on line 3 [lvl:1;conds;T_IF;]: T_WHITESPACE => \n Process token 15 on line 4 [lvl:1;conds;T_IF;]: T_CLOSE_CURLY_BRACKET => } => Found scope closer for 7 (T_OPEN_CURLY_BRACKET) * token T_IF removed from conditions array * * level decreased * Process token 16 on line 4 [lvl:0;]: T_WHITESPACE => \n Process token 17 on line 5 [lvl:0;]: T_CLOSE_TAG => ?> *** END LEVEL MAP *** ``` -------------------------------- ### Sniff path to internal code conversion examples Source: https://github.com/squizlabs/php_codesniffer/wiki/Version-1.3.0-Upgrade-Guide Examples showing how to convert sniff file paths to the internal codes used in ruleset.xml. Drop the 'Sniffs' directory, convert slashes to periods, and remove 'Sniff.php' from the end. ```text BEFORE: Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php AFTER: Generic.VersionControl.SubversionProperties ``` ```text BEFORE: PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php AFTER: PEAR.ControlStructures.ControlSignature ``` ```text BEFORE: Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php AFTER: Squiz.Strings.DoubleQuoteUsage ``` -------------------------------- ### Generic.Formatting.SpaceAfterCast: Default spacing example Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Shows the default spacing of one space after a type cast. ```php $var = (int) $foo; ``` -------------------------------- ### Default concatenation spacing example Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Shows the default zero-space padding around the concatenation operator enforced by Squiz.Strings.ConcatenationSpacing. ```php $foo = $number.'-'.$letter; ``` -------------------------------- ### Run PHP_CodeSniffer from tools directory Source: https://github.com/squizlabs/php_codesniffer/blob/master/README.md Runs the phpcs and phpcbf commands from the tools directory after installing with Phive. Use the -h flag to display help. ```bash ./tools/phpcs -h ./tools/phpcbf -h ``` -------------------------------- ### Single-space concatenation example Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Shows a common alternative with a single space around the concatenation operator, which can be configured via the 'spacing' property. ```php $foo = $number . '-' . $letter; ``` -------------------------------- ### Generic.Formatting.MultipleStatementAlignment: Default alignment example Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Shows the default alignment enforced by the sniff, where assignment operators are aligned at the end, aligning the assigned values. ```php $foo = 'foo'; $foo .= 'bar'; ``` -------------------------------- ### Create MyStandard directory structure Source: https://github.com/squizlabs/php_codesniffer/wiki/Coding-Standard-Tutorial Run these commands to create the coding standard directory structure. The first two commands create the standard outside the main PHP_CodeSniffer directory, so it won't appear with the -i flag. The second set creates it inside the PHP_CodeSniffer install to make it show as installed. ```bash $ mkdir MyStandard $ mkdir MyStandard/Sniffs ``` ```bash $ cd /path/to/PHP_CodeSniffer/src/Standards $ mkdir MyStandard $ mkdir MyStandard/Sniffs ``` -------------------------------- ### Example of a function comment with only {@inheritdoc} Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Shows a docblock containing only {@inheritdoc} that the sniff will skip when skipIfInheritdoc is true. ```php /** * {@inheritDoc} */ public function foo($a, $b) {} ``` -------------------------------- ### Run PHP_CodeSniffer from vendor bin Source: https://github.com/squizlabs/php_codesniffer/blob/master/README.md Runs the phpcs and phpcbf commands from the vendor bin directory after installing via Composer. Use the -h flag to display help. ```bash ./vendor/bin/phpcs -h ./vendor/bin/phpcbf -h ``` -------------------------------- ### Example PHP file for scope map Source: https://github.com/squizlabs/php_codesniffer/wiki/Advanced-Usage A simple PHP file with an if statement, used to illustrate the scope map output. ```php ``` -------------------------------- ### Generic.Formatting.MultipleStatementAlignment: Set alignAtEnd to false Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Configures the sniff to align the start of assignment tokens instead of the end by setting alignAtEnd to false. ```xml ``` -------------------------------- ### PEAR.Commenting.FunctionComment specialMethods property Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Specifies methods that do not require a @return tag in their docblock. Default is __construct and __destruct; this example adds 'ignoreThisFunction'. ```xml ``` -------------------------------- ### Sample CodingStandard.php getIncludedSniffs() method Source: https://github.com/squizlabs/php_codesniffer/wiki/Version-1.3.0-Upgrade-Guide Example of a CodingStandard.php class method that includes sniffs from other standards. This is the old approach that is replaced by ruleset.xml in version 1.3.0. ```php public function getIncludedSniffs() { return array( 'PEAR', 'Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php', 'Generic/Sniffs/Functions', ); }//end getIncludedSniffs() ``` -------------------------------- ### PEAR.Formatting.MultiLineAssignment indent property Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Sets the indentation size for assignments split over multiple lines. Default is 4 spaces; this example sets it to 2. ```xml ``` -------------------------------- ### PHP example of single-space padding inside parentheses Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Alternative padding style with a single space inside parenthesis. ```php $foo = ( $bar !== 'bar' ); ``` -------------------------------- ### Reference sniff class by path Source: https://github.com/squizlabs/php_codesniffer/wiki/Annotated-Ruleset References sniffs not installed by using an absolute or relative path to the sniff class file instead of the sniff code. ```xml ``` -------------------------------- ### Verbose token processing output example Source: https://github.com/squizlabs/php_codesniffer/wiki/Advanced-Usage Sample output from PHP_CodeSniffer when running with -vvv. Shows each token processed, its ID, type, contents, and the sniffs executed on it with running times. ```text *** START TOKEN PROCESSING *** Process token 0: T_OPEN_TAG => if Processing PEAR_Sniffs_ControlStructures_ControlSignatureSniff... DONE in 0.0001 seconds Processing PEAR_Sniffs_ControlStructures_MultiLineConditionSniff... DONE in 0 seconds Processing PEAR_Sniffs_WhiteSpace_ScopeClosingBraceSniff... DONE in 0 seconds Processing PEAR_Sniffs_WhiteSpace_ScopeIndentSniff... DONE in 0 seconds Processing Generic_Sniffs_ControlStructures_InlineControlStructureSniff... DONE in 0 seconds Process token 2: T_WHITESPACE => Processing Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff... DONE in 0 seconds Process token 3: T_OPEN_PARENTHESIS => ( Process token 4: T_VARIABLE => $condition Processing PEAR_Sniffs_NamingConventions_ValidVariableNameSniff... DONE in 0 seconds Process token 5: T_CLOSE_PARENTHESIS => ) Process token 6: T_WHITESPACE => Processing Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff... DONE in 0 seconds Process token 7: T_OPEN_CURLY_BRACKET => { Process token 8: T_WHITESPACE => \n Processing Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff... DONE in 0 seconds Process token 9: T_WHITESPACE => Processing Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff... DONE in 0 seconds Process token 10: T_ECHO => echo Process token 11: T_WHITESPACE => Processing Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff... DONE in 0 seconds Process token 12: T_CONSTANT_ENCAPSED_STRING => 'Condition was true' Process token 13: T_SEMICOLON => ; Process token 14: T_WHITESPACE => \n Processing Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff... DONE in 0 seconds Process token 15: T_CLOSE_CURLY_BRACKET => } Process token 16: T_WHITESPACE => \n Processing Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff... DONE in 0 seconds Process token 17: T_CLOSE_TAG => ?>\n *** END TOKEN PROCESSING *** ``` -------------------------------- ### PHP example of zero spacing inside parentheses Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Default behavior of Generic.WhiteSpace.ArbitraryParenthesesSpacing: zero spaces inside parenthesis. ```php $foo = ($bar !== 'bar'); ``` -------------------------------- ### Check file with multiple standards using comma-separated --standard Source: https://github.com/squizlabs/php_codesniffer/wiki/Usage Pass a comma-separated list of standards to check multiple coding standards at once. A mix of external and installed standards is allowed. ```bash $ phpcs --standard=PEAR,Squiz,/path/to/MyStandard /path/to/code/myfile.inc ``` -------------------------------- ### Generic.Files.LineLength: Disable errors with absoluteLineLimit=0 Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Sets absoluteLineLimit to 0 to disable errors, so only warnings are generated for lines exceeding the lineLimit. This example warns for lines longer than 135 characters and never errors. ```xml ``` -------------------------------- ### Run PHP_CodeSniffer interactively with -a and example output Source: https://github.com/squizlabs/php_codesniffer/wiki/Reporting Use the -a argument to run PHP_CodeSniffer interactively, showing a report for the first file with errors or warnings and pausing for input. The example output shows the full error report and the prompt to recheck, skip, or quit. Note: interactive mode always prints the full error report and ignores any report types specified on the command line. ```bash $ phpcs -a /path/to/code ``` ```text FILE: /path/to/code/classA.php -------------------------------------------------------------------------------- FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES -------------------------------------------------------------------------------- 2 | ERROR | [ ] Missing file doc comment 4 | ERROR | [x] TRUE, FALSE and NULL must be lowercase; expected "false" | | but found "FALSE" 6 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, | | found 1 9 | ERROR | [ ] Missing function doc comment 11 | WARNING | [x] Inline control structures are discouraged -------------------------------------------------------------------------------- PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------------- to recheck, [s] to skip or [q] to quit : ``` -------------------------------- ### New process() definition with File Source: https://github.com/squizlabs/php_codesniffer/wiki/Version-3.0-Upgrade-Guide Rewrite the process() declaration to use the new File class. ```php public function process(File $phpcsFile, $stackPtr) {} ``` -------------------------------- ### Set specialMethods property for Squiz.Commenting.FunctionComment Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Specifies methods that do not require a @return tag in their docblocks. Defaults to __construct and __destruct; this example adds 'ignoreThisFunction'. ```xml ``` -------------------------------- ### Minimal ruleset.xml content Source: https://github.com/squizlabs/php_codesniffer/wiki/Coding-Standard-Tutorial The content of the ruleset.xml file. This minimal example defines the standard's name and description. The ruleset.xml can be left quite small; see the Annotated ruleset for other features. ```xml A custom coding standard. ``` -------------------------------- ### View configuration options with --config-show Source: https://github.com/squizlabs/php_codesniffer/wiki/Advanced-Usage Use the --config-show command line argument to view the currently set configuration options. The output is an array showing option names and values. ```bash $ phpcs --config-show Array ( [default_standard] => PEAR [zend_ca_path] => /path/to/ZendCodeAnalyzer ) ``` -------------------------------- ### Set lineLimit property for Squiz.Commenting.LongConditionClosingComment Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Configures the minimum number of lines a code block must span before requiring a closing comment. Default is 20; this example sets it to 40. ```xml ``` -------------------------------- ### PHP function with no spaces around equals signs Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Example of a function declaration with zero spaces around the equals signs, as enforced by default by the Squiz.Functions.FunctionDeclarationArgumentSpacing sniff. ```php function foo($a='a', $b='b') { // Body. } ``` -------------------------------- ### Create ruleset.xml file Source: https://github.com/squizlabs/php_codesniffer/wiki/Version-1.3.0-Upgrade-Guide Creates an empty ruleset.xml file in the top-level directory of your custom coding standard. The file name must be exactly 'ruleset.xml'. ```bash touch MyStandard/ruleset.xml ``` -------------------------------- ### Set indent property for Squiz.Classes.ClassDeclaration Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Configures the indentation size for class names split over multiple lines. The default is 4 spaces; this example sets it to 2. ```xml ``` -------------------------------- ### Selective rules with phpcs-only and phpcbf-only attributes Source: https://github.com/squizlabs/php_codesniffer/wiki/Annotated-Ruleset Demonstrates how to apply rules selectively for phpcs or phpcbf. The example is for documentation purposes only and not a working standard. It shows config, exclude-pattern, rule exclusion, severity, and property settings with tool-specific attributes. ```xml */3rdparty/* 0 ``` -------------------------------- ### PHP function with no spaces inside argument list brackets Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Example of a function declaration with zero spaces after the opening bracket and before the closing bracket, as enforced by default by the Squiz.Functions.FunctionDeclarationArgumentSpacing sniff. ```php function foo($a, $b) { // Body. } ``` -------------------------------- ### ruleset.xml equivalent for PEAR standard with ControlSignature exclusion Source: https://github.com/squizlabs/php_codesniffer/wiki/Version-1.3.0-Upgrade-Guide XML ruleset that replicates the PHP class example above for version 1.3.0. The rule ref="PEAR" includes the whole standard, and the nested exclude element uses the internal sniff code PEAR.ControlStructures.ControlSignature instead of a file path. Exclusions are grouped with the standard they apply to. ```xml My custom coding standard ``` -------------------------------- ### Configure Squiz.WhiteSpace.FunctionSpacing spacing properties Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Sets the required blank lines before and after function declarations. The spacing property applies generally, while spacingBeforeFirst and spacingAfterLast override it for functions at the start or end of a statement group or control structure. If the latter are not set, they inherit the spacing value. ```xml ``` -------------------------------- ### Add installed standard paths with phpcs --config-set installed_paths Source: https://github.com/squizlabs/php_codesniffer/wiki/Configuration-Options Adds one or more paths (comma-separated) where PHP_CodeSniffer looks for installed coding standards. Relative paths must begin with './' and are resolved relative to the top-level install directory. ```bash $ phpcs --config-set installed_paths /path/to/one,/path/to/two ``` -------------------------------- ### ruleset.xml equivalent for including sniffs Source: https://github.com/squizlabs/php_codesniffer/wiki/Version-1.3.0-Upgrade-Guide Ruleset.xml that replicates the includes from the sample CodingStandard.php. It uses the 'rule' tag and references sniffs by their internal code instead of file paths. ```xml My custom coding standard ``` -------------------------------- ### SpaceAfterNot: multiline ! operator Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Example of breaking a complex statement over multiple lines after `!`. ```php if (! ($foo || $bar) ) { } ``` -------------------------------- ### NestingLevel: configure nestingLevel and absoluteNestingLevel Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties XML configuration for Generic.Metrics.NestingLevel to set warning and error thresholds. ```xml ``` -------------------------------- ### Run phpcs with absolute path to standard Source: https://github.com/squizlabs/php_codesniffer/wiki/Coding-Standard-Tutorial Command to run PHP_CodeSniffer using the custom standard by passing the absolute path to the standard directory. This is required when the standard is not installed inside the main PHP_CodeSniffer directory structure. ```bash $ phpcs --standard=/path/to/MyStandard test.php ``` -------------------------------- ### Create ruleset.xml file Source: https://github.com/squizlabs/php_codesniffer/wiki/Coding-Standard-Tutorial Run this command to create the ruleset.xml file inside the MyStandard directory. This file identifies the directory as a coding standard and allows PHP_CodeSniffer to query it. ```bash $ cd MyStandard $ touch ruleset.xml ``` -------------------------------- ### Clone repository and run from Git clone Source: https://github.com/squizlabs/php_codesniffer/blob/master/README.md Clones the PHP_CodeSniffer repository and runs the phpcs and phpcbf commands directly from the bin directory. Use the -h flag to display help. ```bash git clone https://github.com/squizlabs/PHP_CodeSniffer.git cd PHP_CodeSniffer php bin/phpcs -h php bin/phpcbf -h ``` -------------------------------- ### Check a directory against PEAR standard Source: https://github.com/squizlabs/php_codesniffer/blob/master/README.md Run phpcs on an entire directory to check all files against the default PEAR coding standard. ```bash phpcs /path/to/code-directory ``` -------------------------------- ### Complete annotated ruleset.xml sample Source: https://github.com/squizlabs/php_codesniffer/wiki/Annotated-Ruleset A documentation-only sample showing the full range of ruleset.xml features: name and namespace attributes, description, config values, file and exclude-pattern tags, arg and ini settings, autoload files, and including the PEAR standard. Note that config values cannot override command line arguments like show_warnings and report_format, and file paths are relative to the ruleset's location. ```xml A custom coding standard ./path/to/directory ./path/to/file.php */tests/* */data/* ^/tests/* ^/data/* /path/to/autoload.php /path/to/other/autoload.php ./autoload.php ``` -------------------------------- ### Set skipIfInheritdoc property for Squiz.Commenting.FunctionComment Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties When true, the sniff skips checking function comments that contain only {@inheritdoc}. This example enables that behavior. ```xml ``` -------------------------------- ### Generic.Formatting.SpaceAfterCast: Set spacing to 0 Source: https://github.com/squizlabs/php_codesniffer/wiki/Customisable-Sniff-Properties Configures the sniff to allow no space after a cast by setting spacing to 0. ```xml ``` -------------------------------- ### Old process() definition with PHP_CodeSniffer_File Source: https://github.com/squizlabs/php_codesniffer/wiki/Version-3.0-Upgrade-Guide The old definition used PHP_CodeSniffer_File as the type hint. ```php public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {} ``` -------------------------------- ### Check a file against PEAR standard Source: https://github.com/squizlabs/php_codesniffer/blob/master/README.md Run phpcs on a single file to check it against the default PEAR coding standard. ```bash phpcs /path/to/code/myfile.php ``` -------------------------------- ### Set configuration option with --config-set Source: https://github.com/squizlabs/php_codesniffer/wiki/Advanced-Usage Use the --config-set command line argument to set a configuration option. The option and value are written to a global configuration file. ```bash $ phpcs --config-set