Releases: squizlabs/PHP_CodeSniffer
1.5.5
- PHP tokenizer no longer converts class/function names to special tokens types
- Class/function names such as parent and true would become special tokens such as T_PARENT and T_TRUE
- Improved closure support in Generic ScopeIndentSniff
- Improved indented PHP tag support in Generic ScopeIndentSniff
- Generic CamelCapsFunctionNameSniff now ignores a single leading underscore
- Thanks to Alex Slobodiskiy for the patch
- Standards can now be located within hidden directories (further fix for bug #20323)
- Thanks to Klaus Purer for the patch
- Added Generic SyntaxSniff to check for syntax errors in PHP files
- Thanks to Blaine Schmeisser for the contribution
- Squiz DiscouragedFunctionsSniff now warns about var_dump()
- PEAR ValidFunctionNameSniff no longer throws an error for _()
- Squiz and PEAR FunctionCommentSnif now support _()
- Generic UpperCaseConstantSniff and LowerCaseConstantSniff now ignore function names
- Fixed bug #248 : FunctionCommentSniff expects ampersand on param name
- Fixed bug #265 : False positives with type hints in ForbiddenFunctionsSniff
- Fixed bug #20373 : Inline comment sniff tab handling way
- Fixed bug #20378 : Report appended to existing file if no errors found in run
- Fixed bug #20381 : Invalid "Comment closer must be on a new line"
- Thanks to Brad Kent for the patch
- Fixed bug #20386 : Squiz.Commenting.ClassComment.SpacingBefore thrown if first block comment
2.0.0RC1
- PHPCBF will now fix incorrect newline characters in a file
- PHPCBF now exists cleanly when there are no errors to fix
- Added phpcbf.bat file for Windows
- Verbose option no longer errors when using a phar file with a space in the path
- Fixed a reporting error when using HHVM
- Thanks to Martins Sipenko for the patch
- addFixableError() and addFixableWarning() now only return true if the fixer is enabled
- Saves checking ($phpcsFile->fixer->enabled === true) before every fix
- Added addErrorOnLine() and addWarningOnLine() to add a non-fixable violation to a line at column 1
- Useful if you are generating errors using an external tool or parser and only know line numbers
- Thanks to Ondřej Mirtes for the patch
- CSS tokenizer now identifies embedded PHP code using the new T_EMBEDDED_PHP token type
- The entire string of PHP is contained in a single token
- PHP tokenizer contains better detection of short array syntax
- Unit test runner now also test any standards installed under the installed_paths config var
- Exclude patterns now use {} delimiters, allowing the | special character to work correctly again
- The filtering component of the --extensions argument is now ignored again when passing filenames
- Can still be used to specify a custom tokenizer for each extension when passing filenames
- If no tokenizer is specified, default values will be used for common file extensions
- Diff report now produces relative paths on Windows, where possible (further fix for bug #20234)
- If a token's content has been modified by the tab-width setting, it will now have an orig_content in the tokens array
- Generic DisallowSpaceIndent and DisallowTabIndent sniffs now check original indent content even when tab-width is set
- Previously, setting --tab-width would force both to check the indent as spaces
- Fixed a problem where PHPCBF could replace tabs with too many spaces when changing indents
- Fixed a problem that could occur with line numbers when using HHVM to check files with Windows newline characters
- Removed use of sys_get_temp_dir() as this is not supported by the min PHP version
- Squiz ArrayDeclarationSniff now supports short array syntax
- Squiz ControlSignatureSniff no longer uses the Abstract Pattern sniff
- If you are extending this sniff, you'll need to rewrite your code
- The rewrite allows this sniff to fix all control structure formatting issues it finds
- The installed_paths config var now accepts relative paths
- The paths are relative to the PHP_CodeSniffer install directory
- Thanks to Weston Ruter for the patch
- Generic ScopeIndentSniff now accounts for different open tag indents
- PEAR FunctionDeclarationSniff now ignores short arrays when checking indent
- Thanks to Daniel Tschinder for the patch
- PSR2 FunctionCallSignatureSniff now treats multi-line strings as a single-line argument, like arrays and closures
- Thanks to Dawid Nowak for the patch
- PSR2 UseDeclarationSniff now checks for a single space after the USE keyword
- Generic ForbiddenFunctionsSniff now detects calls to functions in the global namespace
- Thanks to Ole Martin Handeland for the patch
- Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore namespaces beginning with TRUE/FALSE/NULL
- Thanks to Renan Gonçalves for the patch
- Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request #20299)
- Squiz SelfMemberReferenceSniff now works correctly with namespaces
- Squiz FunctionCommentSniff is now more relaxed when checking namespaced type hints
- Tab characters are now encoded in abstract pattern errors messages
- Thanks to Blaine Schmeisser for the patch
- Invalid sniff codes passed to --sniffs now show a friendly error message (request #20313)
- Generic LineLengthSniff now shows a warning if the iconv module is disabled (request #20314)
- Source report no longer shows errors if category or sniff names ends in an uppercase error
- Thanks to Jonathan Marcil for the patch
- Fixed bug #20261 : phpcbf has an endless fixing loop
- Fixed bug #20268 : Incorrect documentation titles in PEAR documentation
- Fixed bug #20296 : new array notion in function comma check fails
- Fixed bug #20297 : phar does not work when renamed it to phpcs
- Fixed bug #20307 : PHP_CodeSniffer_Standards_AbstractVariableSniff analyze traits
- Fixed bug #20308 : Squiz.ValidVariableNameSniff - wrong variable usage
- Fixed bug #20309 : Use "member variable" term in sniff "processMemberVar" method
- Fixed bug #20310 : PSR2 does not check for space after function name
- Fixed bug #20322 : Display rules set to type=error even when suppressing warnings
- Fixed bug #20323 : PHPCS tries to load sniffs from hidden directories
- Fixed bug #20346 : Fixer endless loop with Squiz.CSS sniffs
- Fixed bug #20355 : No sniffs are registered with PHAR on Windows
1.5.4
- Removed use of sys_get_temp_dir() as this is not supported by the min PHP version
- The installed_paths config var now accepts relative paths
- The paths are relative to the PHP_CodeSniffer install directory
- Thanks to Weston Ruter for the patch
- Generic ScopeIndentSniff now accounts for different open tag indents
- PEAR FunctionDeclarationSniff now ignores short arrays when checking indent
- Thanks to Daniel Tschinder for the patch
- PSR2 FunctionCallSignatureSniff now treats multi-line strings as a single-line argument, like arrays and closures
- Thanks to Dawid Nowak for the patch
- Generic ForbiddenFunctionsSniff now detects calls to functions in the global namespace
- Thanks to Ole Martin Handeland for the patch
- Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore namespaces beginning with TRUE/FALSE/NULL
- Thanks to Renan Gonçalves for the patch
- Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request #20299)
- Squiz SelfMemberReferenceSniff now works correctly with namespaces
- Tab characters are now encoded in abstract pattern errors messages
- Thanks to Blaine Schmeisser for the patch
- Invalid sniff codes passed to --sniffs now show a friendly error message (request #20313)
- Generic LineLengthSniff now shows a warning if the iconv module is disabled (request #20314)
- Source report no longer shows errors if category or sniff names ends in an uppercase error
- Thanks to Jonathan Marcil for the patch
- Fixed bug #20268 : Incorrect documentation titles in PEAR documentation
- Fixed bug #20296 : new array notion in function comma check fails
- Fixed bug #20307 : PHP_CodeSniffer_Standards_AbstractVariableSniff analyze traits
- Fixed bug #20308 : Squiz.ValidVariableNameSniff - wrong variable usage
- Fixed bug #20309 : Use "member variable" term in sniff "processMemberVar" method
- Fixed bug #20310 : PSR2 does not check for space after function name
- Fixed bug #20322 : Display rules set to type=error even when suppressing warnings
- Fixed bug #20323 : PHPCS tries to load sniffs from hidden directories
2.0.0a2
Information Report
PHP_CodeSniffer now comes with an information report that is able to show you information about how your code is written rather than checking that it conforms to a standard. You can read more about this report, and see example output, on the wiki.
Performance Improvements
A number of minor performance improvements have gone into this version, which will probably only be obvious when checking very large code bases. As a result, there are a few important changes to know about:
- Line length warnings will now be shown for lines that refer to licence and VCS information. The line length sniff previously ignored these lines, which meant that it had to run a regular expression on every line it checked.
- The
$tokens
array has a new length index that you can use to determine the length of the token's content rather than having to callstrlen()
yourself and deal with character encoding. - The use of
in_array()
when checking thePHP_CodeSniffer_Tokens
static vars impacted performance significantly, so they have been restructured so that you can also useisset()
on them. - Custom reports can now specify a
$recordErrors
member var that, when set toFALSE
, will tell PHP_CodeSniffer that it doesn't need to record errors during the run. This gives a significant memory saving if you are using a custom report to output summary information rather than a full list of errors found.
Phar Distribution
For the first time, PHP_CodeSniffer's phpcs
and phpcbf
commands are now available as Phar files. The Phars are still in testing and are known to not work with HHVM, but are an easy way to try out the new 2.0 alpha versions.
curl -OL https://github.com/squizlabs/PHP_CodeSniffer/releases/download/2.0.0a2/phpcs.phar
php phphcs.phar /path/to/code
curl -OL https://github.com/squizlabs/PHP_CodeSniffer/releases/download/2.0.0a2/phpcbf.phar
php phpcbf.phar /path/to/code
Other Changes
- Added report type --report=info to show information about the checked code to make building a standard easier
- Checks a number of things, such as what line length you use, and spacing are brackets, but not everything
- Still highly experimental
- Generic LineLengthSniff now shows warnings for long lines referring to licence and VCS information
- It previously ignored these lines, but at the expense of performance
- Generic DisallowTabIndent and DisallowSpaceIndent sniffs no longer error when detecting mixed indent types
- Only the first type of indent found on a line (space or indent) is considered
- Lots of little performance improvements that can add up to a substantial saving over large code bases
- Added a "length" array index to tokens so you don't need to call strlen() of them, or deal with encoding
- Can now use isset() to find tokens inside the PHP_CodeSniffer_Tokens static vars instead of in_array()
- Custom reports can now specify a $recordErrors member var; this previously only worked for built-in reports
- When set to FALSE, error messages will not be recorded and only totals will be returned
- This can save significant memory while processing a large code base
- Removed dependence on PHP_Timer
- PHP tokenizer now supports DEFAULT statements opened with a T_SEMICOLON
- The Squiz and PHPCS standards have increased the max padding for statement alignment from 8 to 12
- Squiz EchoedStringsSniff now supports statments without a semicolon, such as PHP embedded in HTML
- Squiz DoubleQuoteUsageSniff now properly replaces escaped double quotes when fixing a doubled quoted string
- Improved detection of nested IF statements that use the alternate IF/ENDIF syntax
- PSR1 CamelCapsMethodNameSniff now ignores magic methods
- Thanks to Eser Ozvataf for the patch
- PSR1 SideEffectsSniff now ignores methods named define()
- PSR1 and PEAR ClassDeclarationSniffs now support traits (request #20208)
- PSR2 ControlStructureSpacingSniff now allows newlines before/after parentheses
- Thanks to Maurus Cuelenaere for the patch
- PSR2 ControlStructureSpacingSniff now checks TRY and CATCH statements
- Squiz SuperfluousWhitespaceSniff now detects whitespace at the end of block comment lines
- Thanks to Klaus Purer for the patch
- Squiz LowercasePHPFunctionsSniff no longer reports errors for namespaced functions
- Thanks to Max Galbusera for the patch
- Squiz SwitchDeclarationSniff now allows exit() as a breaking statement for case/default
- Squiz ValidVariableNameSniff and Zend ValidVariableNameSniff now ignore additional PHP reserved vars
- Thanks to Mikuláš Dítě and Adrian Crepaz for the patch
- Sniff code Squiz.WhiteSpace.MemberVarSpacing.After changed to Squiz.WhiteSpace.MemberVarSpacing.Incorrect (request #20241)
- Fixed bug #20200 : Invalid JSON produced with specific error message
- Fixed bug #20204 : Ruleset exclude checks are case sensitive
- Fixed bug #20213 : Invalid error, Inline IF must be declared on single line
- Fixed bug #20225 : array_merge() that takes more than one line generates error
- Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting
- Fixed bug #20234 : phpcbf patch command absolute paths
- Fixed bug #20240 : Squiz block comment sniff fails when newline present
- Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while
- Thanks to Alexander Obuhovich for the patch
- Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope
- Fixed bug #20252 : Unitialized string offset when package name starts with underscore
1.5.3
- Improved detection of nested IF statements that use the alternate IF/ENDIF syntax
- PHP tokenizer now supports DEFAULT statements opened with a T_SEMICOLON
- PSR1 CamelCapsMethodNameSniff now ignores magic methods
- Thanks to Eser Ozvataf for the patch
- PSR1 SideEffectsSniff now ignores methods named define()
- PSR1 and PEAR ClassDeclarationSniffs now support traits (request #20208)
- PSR2 ControlStructureSpacingSniff now allows newlines before/after parentheses
- Thanks to Maurus Cuelenaere for the patch
- Squiz LowercasePHPFunctionsSniff no longer reports errors for namespaced functions
- Thanks to Max Galbusera for the patch
- Squiz SwitchDeclarationSniff now allows exit() as a breaking statement for case/default
- Squiz ValidVariableNameSniff and Zend ValidVariableNameSniff now ignore additional PHP reserved vars
- Thanks to Mikuláš Dítě and Adrian Crepaz for the patch
- Sniff code Squiz.WhiteSpace.MemberVarSpacing.After changed to Squiz.WhiteSpace.MemberVarSpacing.Incorrect (request #20241)
- Fixed bug #20200 : Invalid JSON produced with specific error message
- Fixed bug #20204 : Ruleset exclude checks are case sensitive
- Fixed bug #20213 : Invalid error, Inline IF must be declared on single line
- Fixed bug #20225 : array_merge() that takes more than one line generates error
- Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting
- Fixed bug #20240 : Squiz block comment sniff fails when newline present
- Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while
- Thanks to Alexander Obuhovich for the patch
- Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope
- Fixed bug #20252 : Unitialized string offset when package name starts with underscore
2.0.0a1
Fixing Errors Automatically with PHPCBF
PHP_CodeSniffer now comes with a second script; phpcbf
, the PHP Code Beautifier and Fixer. This script piggy-backs off PHP_CodeSniffer to provide fixes for a lot of common errors. It will never fix 100% of the errors PHP_CodeSniffer finds as many require a developer to make a decision (e.g., can you use ===
here?) or may cause the code to execute differently if changed (e.g., uppercasing a constant name). But there are still a lot of errors that can be corrected without causing issues. Out of the 566 unique error messages that PHP_CodeSniffer can currently produce, version 2.0.0a1 is able to correct 202 of them automatically, which is about 35%. When you run PHP_CodeSniffer and get a report of the errors found, you will now be able to see which of those errors can be automatically corrected.
Along with this new script, PHP_CodeSniffer adds a new report type; the diff
report. If you don't like the idea of PHP_CodeSniffer fixing errors automatically, you can instead ask it to output a diff of the fixes that it would make using the command line argument --report=diff
. If you like what you see, you can simply change the phpcs
command to phpcbf
, leave all the command line options the same, and let PHP_CodeSniffer patch your files.
All this new functionality is documented on the wiki, and includes sample output, so please take a read: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically
Adding Fixes to Custom Sniffs
If you have your own custom sniffs and want to correct errors automatically, you need to make a couple of changes. The first thing you need to do is call the addFixableError()
or addFixableWarning()
methods instead of addError()
and addWarning()
, to let PHP_CodeSniffer know the error can be fixed. You can then make use of the new PHP_CodeSniffer_Fixer
class to replace token values and add content to tokens, modifying the token stack as you go.
Here is a simple example, to ensure that comments don't appear at the end of a code line ($stackPtr
is the comment token):
$error = 'Comments may not appear after statements';
$phpcsFile->addError($error, $stackPtr, 'Found');
To fix this, we just need to add a newline before the comment. Other sniffs will do things like fix alignment and spacing of the comment for us. It is also important we check if the fixer is enabled and if we are supposed to be fixing this specific error message. We end up with code like this:
$error = 'Comments may not appear after statements';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found');
if ($fix === true && $phpcsFile->fixer->enabled === true) {
$phpcsFile->fixer->addNewlineBefore($stackPtr);
}
If you are changing multiple tokens in a single fix, using a changeset will ensure that they are either all applied at once, or not applied at all. This is important if a partial change would lead to a parse error, or another equally bad outcome. In the following example, a changeset is used to ensure that all content between the array braces is removed, even if the content spans multiple lines. If one of the tokens to be removed has already been modified by another sniff, the whole changeset will be ignored and PHP_CodeSniffer will attempt to apply this changeset on a second run through the file.
$error = 'Empty declaration must have no space between parentheses';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceFound');
if ($fix === true && $phpcsFile->fixer->enabled === true) {
$phpcsFile->fixer->beginChangeset();
for ($i = ($arrayStart + 1); $i < $arrayEnd; $i++) {
$phpcsFile->fixer->replaceToken($i, '');
}
$phpcsFile->fixer->endChangeset();
}
Take a look at the PHP_CodeSniffer_Fixer class for all the methods you can use: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Fixer.php
Removal of the Comment Parser
If you have written custom sniffs that either use the comment parsing classes or extend sniffs that do, you are going to need to review your sniffs and possibly rewrite them. This has already been done for all included sniffs, so there are quite a few examples to help you get started.
The best way to explain the change is to show an example of how PHP_CodeSniffer has changed the way it handles doc comments internally. If PHP_CodeSniffer is processing the following comment:
/**
* PHP_CodeSniffer tokenises PHP code.
*
* @author Greg Sherwood <[email protected]>
* @copyright 2006-2012 Squiz Pty Ltd
*/
It would have previously tokenized it like this (spaces have been replaced by periods):
T_DOC_COMMENT => /**\n
T_DOC_COMMENT => * PHP_CodeSniffer.tokenises.PHP.code.\n
T_DOC_COMMENT => *\n
T_DOC_COMMENT => * @author....Greg.Sherwood.<[email protected]>\n
T_DOC_COMMENT => * @copyright.2006-2012.Squiz.Pty.Ltd\n
T_DOC_COMMENT => */
This format makes it very hard to look for specific things like a comment tag name, and makes it very hard to make fixes to the comment automatically. So PHP_CodeSniffer will now tokenize the comment like this:
T_DOC_COMMENT_OPEN_TAG => /**
T_DOC_COMMENT_WHITESPACE => \n
T_DOC_COMMENT_WHITESPACE => .
T_DOC_COMMENT_STAR => *
T_DOC_COMMENT_WHITESPACE => .
T_DOC_COMMENT_STRING => PHP_CodeSniffer.tokenises.PHP.code.
T_DOC_COMMENT_WHITESPACE => \n
T_DOC_COMMENT_WHITESPACE => .
T_DOC_COMMENT_STAR => *
T_DOC_COMMENT_WHITESPACE => \n
T_DOC_COMMENT_WHITESPACE => .
T_DOC_COMMENT_STAR => *
T_DOC_COMMENT_WHITESPACE => .
T_DOC_COMMENT_TAG => @author
T_DOC_COMMENT_WHITESPACE => ....
T_DOC_COMMENT_STRING => Greg.Sherwood <[email protected]>
T_DOC_COMMENT_WHITESPACE => \n
T_DOC_COMMENT_WHITESPACE => .
T_DOC_COMMENT_STAR => *
T_DOC_COMMENT_WHITESPACE => .
T_DOC_COMMENT_TAG => @copyright
T_DOC_COMMENT_WHITESPACE => .
T_DOC_COMMENT_STRING => 2006-2012.Squiz.Pty.Ltd
T_DOC_COMMENT_WHITESPACE => \n
T_DOC_COMMENT_WHITESPACE => .
T_DOC_COMMENT_CLOSE_TAG => */
As you can see, this is a significant number of extra tokens, but allows for much finer control over how a comment is processed. The T_DOC_COMMENT
token has also been removed, replaced instead by T_DOC_COMMENT_OPEN_TAG
. If you have a sniff listening for T_DOC_COMMENT
, make sure you change it in your register()
method and anywhere else it is used throughout your sniffs.
Here is a fairly complex example of a sniff rewrite; the Squiz FunctionComment sniff:
old: f913dbd4540fde475282a43ca4084dc8bc65a7a3
new: 3e408ab1b3202a9cc97685cabf09adb2a0023155
And here is the commit of the changes required for the new comment tokenizer: 2b2afb4fd49071b1b6792611a908a5cda0fc7b38
Instead of using the comment parser functions to get at tag values, you can use the standard PHP_CodeSniffer functions to navigate the token stack and look for what you need. This allows you to get a precise location of each piece of the comment, and make fixes to it if you need to. You can also report more accurately on where an error has occurred.
Other Changes
- Added the phpcbf script to automatically fix many errors found by the phpcs script
- Added report type --report=diff to show suggested changes to fix coding standard violations
- The --report argument now allows for custom reports to be used
- Use the full path to your custom report class as the report name
- The --extensions argument is now respected when passing filenames; not just with directories
- The --extensions argument now allows you to specify the tokenizer for each extension
- e.g., --extensions=module/php,es/js
- Command line arguments can now be set in ruleset files
- e.g., arg name="report" value="summary" (print summary report; same as --report=summary)
- e.g., arg value="sp" (print source and progress information; same as -sp)
- The -vvv, --sniffs, --standard and -l command line arguments cannot be set in this way
- Sniff process() methods can not optionally return a token to ignore up to
- If returned, the sniff will not be executed again until the passed token is reached in the file
- Useful if you are looking for tokens like T_OPEN_TAG but only want to process the first one
- Removed the comment parser classes and replaced it with a simple comment tokenier
- T_DOC_COMMENT tokens are now tokenized into T_DOC_COMMENT_* tokens so they can be used more easily
- This change requires a significant rewrite of sniffs that use the comment parser
- This change requires minor changes to sniffs that listen for T_DOC_COMMENT tokens directly
- Added Generic DocCommentSniff to check generic doc block formatting
- Removed doc block formatting checks from PEAR ClassCommentSniff
- Removed doc block formatting checks from PEAR FileCommentSniff
- Removed doc block formatting checks from PEAR FunctionCommentSniff
- Removed doc block formatting checks from Squiz ClassCommentSniff
- Removed doc block formatting checks from Squiz FileCommentSniff
- Removed doc block formatting checks from Squiz FunctionCommentSniff
- Removed doc block formatting checks from Squiz VariableCommentSniff
- Squiz DocCommentAlignmentSniff has had its error codes changed
- NoSpaceBeforeTag becomes NoSpaceAfterStar
- SpaceBeforeTag becomes SpaceAfterStar
- SpaceBeforeAsterisk becomes SpaceBeforeStar
- Generic MultipleStatementAlignment now aligns assignments within a block so they fit within their max padding setting
- The sniff...
1.5.2
- Improved support for the PHP 5.5. classname::class syntax
- PSR2 SwitchDeclarationSniff no longer throws errors when this syntax is used in CASE conditions
- Improved support for negative checks of instanceOf in Squiz ComparisonOperatorUsageSniff
- Thanks to Martin Winkel for the patch
- Generic FunctionCallArgumentSpacingSniff now longer complains about space before comma when using here/nowdocs
- Thanks to Richard van Velzen for the patch
- Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore class constants
- Thanks to Kristopher Wilson for the patch
- PEAR FunctionCallSignatureSniff now has settings to specify how many spaces should appear before/after parentheses
- Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change
- Default remains at 0 for both
- Thanks to Astinus Eberhard for the patch
- PSR2 ControlStructureSpacingSniff now has settings to specify how many spaces should appear before/after parentheses
- Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change
- Default remains at 0 for both
- Thanks to Astinus Eberhard for the patch
- Squiz ForEachLoopDeclarationSniff now has settings to specify how many spaces should appear before/after parentheses
- Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change
- Default remains at 0 for both
- Thanks to Astinus Eberhard for the patch
- Squiz ForLoopDeclarationSniff now has settings to specify how many spaces should appear before/after parentheses
- Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change
- Default remains at 0 for both
- Thanks to Astinus Eberhard for the patch
- Squiz FunctionDeclarationArgumentSpacingSniff now has settings to specify how many spaces should appear before/after parentheses
- Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change
- Default remains at 0 for both
- Thanks to Astinus Eberhard for the patch
- Removed UnusedFunctionParameter, CyclomaticComplexity and NestingLevel from the Squiz standard
- Generic FixmeSniff and TodoSniff now work correctly with accented characters
- Fixed bug #20145 : Custom ruleset preferences directory over installed standard
- Fixed bug #20147 : phpcs-svn-pre-commit - no more default error report
- Fixed bug #20151 : Problem handling "if(): ... else: ... endif;" syntax
- Fixed bug #20190 : Invalid regex in Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff
1.5.1
- Config values can now be set at runtime using the command line argument [--runtime-set key value]
- Runtime values are the same as config values, but are not written to the main config file
- Thanks to Wim Godden for the patch
- Config values can now be set in ruleset files
- e.g., config name="zend_ca_path" value="/path/to/ZendCodeAnalyzer"
- Can not be used to set config values that override command line values, such as show_warnings
- Thanks to Jonathan Marcil for helping with the patch
- Added a new installed_paths config value to allow for the setting of directories that contain standards
- By default, standards have to be installed into the CodeSniffer/Standards directory to be considered installed
- New config value allows a list of paths to be set in addition to this internal path
- Installed standards appear when using the -i arg, and can be referenced in rulesets using only their name
- Set paths by running: phpcs --config-set installed_paths /path/one,/path/two,...
- PSR2 ClassDeclarationSniff now allows a list of extended interfaces to be split across multiple lines
- Squiz DoubleQuoteUsageSniff now allows \b in double quoted strings
- Generic ForbiddenFunctionsSniff now ignores object creation
- This is a further fix for bug #20100 : incorrect Function mysql() has been deprecated report
- Fixed bug #20136 : Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff and Traits
- Fixed bug #20138 : Protected property underscore and camel caps issue (in trait with Zend)
- Thanks to Gaetan Rousseau for the patch
- Fixed bug #20139 : No report file generated on success
1.5.0
- Doc generation is now working again for installed standards
- Includes a fix for limiting the docs to specific sniffs
- Generic ScopeIndentSniff now allows for ignored tokens to be set via ruleset.xml files
- E.g., to ignore comments, override a property using:
- name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT"
- PSR2 standard now ignores comments when checking indentation rules
- Generic UpperCaseConstantNameSniff no longer reports errors where constants are used (request #20090)
- It still reports errors where constants are defined
- Individual messages can now be excluded in ruleset.xml files using the exclude tag (request #20091)
- Setting message severity to 0 continues to be supported
- Squiz OperatorSpacingSniff no longer throws errors for the ?: short ternary operator
- Thanks to Antoine Musso for the patch
- Comment parser now supports non-English characters when splitting comment lines into words
- Thanks to Nik Sun for the patch
- Exit statements are now recognised as valid closers for CASE and DEFAULT blocks
- Thanks to Maksim Kochkin for the patch
- PHP_CodeSniffer_CLI::process() can now be passed an incomplete array of CLI values
- Missing values will be set to the CLI defaults
- Thanks to Maksim Kochkin for the patch
- Fixed bug #20093 : Bug with ternary operator token
- Fixed bug #20097 : CLI.php throws error in php 5.2
- Fixed bug #20100 : incorrect Function mysql() has been deprecated report
- Fixed bug #20119 : PHP warning: invalid argument to str_repeat() in SVN blame report with -s
- Fixed bug #20123 : PSR2 complains about an empty second statement in for-loop
- Fixed bug #20131 : PHP errors in svnblame report, if there are files not under version control
- Fixed bug #20133 : Allow "HG: hg_id" as value for @Version tag
1.4.8
- Generic ScopeIndentSniff now allows for ignored tokens to be set via ruleset.xml files
- E.g., to ignore comments, override a property using:
- name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT"
- PSR2 standard now ignores comments when checking indentation rules
- Squiz OperatorSpacingSniff no longer throws errors for the ?: short ternary operator
- Thanks to Antoine Musso for the patch
- Comment parser now supports non-English characters when splitting comment lines into words
- Thanks to Nik Sun for the patch
- Exit statements are now recognised as valid closers for CASE and DEFAULT blocks
- Thanks to Maksim Kochkin for the patch
- PHP_CodeSniffer_CLI::process() can now be passed an incomplete array of CLI values
- Missing values will be set to the CLI defaults
- Thanks to Maksim Kochkin for the patch
- Fixed bug #20097 : CLI.php throws error in php 5.2
- Fixed bug #20100 : incorrect Function mysql() has been deprecated report
- Fixed bug #20119 : PHP warning: invalid argument to str_repeat() in SVN blame report with -s
- Fixed bug #20123 : PSR2 complains about an empty second statement in for-loop
- Fixed bug #20131 : PHP errors in svnblame report, if there are files not under version control
- Fixed bug #20133 : Allow "HG: hg_id" as value for @Version tag