Skip to content

1.5.0RC2

Pre-release
Pre-release
Compare
Choose a tag to compare
@gsherwood gsherwood released this 02 Jul 23:29
· 5634 commits to master since this release

Ruleset Processing

Ruleset processing now has much better support for relative paths and detection of directories of sniffs. This may mean that sniffs that were not previously being included in a standard are now included correctly. Please check your standards to see if any new sniffs are being included. The best way to do this is to use the -e command line argument. For example, phpcs --standard=mystandard.xml -e will print a list of sniffs that will be run over your code.

This version also includes the ability to exclude whole directories of sniffs inside a ruleset and the ability to pass multiple standards to PHP_CodeSniffer on the command line. For example, phpcs --standard=PEAR,Squiz,mystandard.xml /path/to/code will run 3 standards against your code.

Other Changes

  • Ruleset processing has been rewritten to be more predictable
    • Provides much better support for relative paths inside ruleset files
    • May mean that sniffs that were previously ignored are now being included when importing external rulesets
    • Ruleset processing output can be seen by using the -vv command line argument
    • Internal sniff registering functions have all changed, so please review custom scripts
  • You can now pass multiple coding standards on the command line, comma separated (request #19144)
    • Works with built-in or custom standards and rulesets, or a mix of both
  • You can now exclude directories or whole standards in a ruleset XML file (request #19731)
    • e.g., exclude "Generic.Commenting" or just "Generic"
    • You can also pass in a path to a directory instead, if you know it
  • Added Generic LowerCaseKeywordSniff to ensure all PHP keywords are defined in lowercase
    • The PSR2 and Squiz standards now use this sniff
  • Added Generic SAPIUsageSniff to ensure the PHP_SAPI constant is used instead of php_sapi_name() (request #19863)
  • Squiz FunctionSpacingSniff now has a setting to specify how many lines there should between functions (request #19843)
    • Default remains at 2
    • Override the "spacing" setting in a ruleset.xml file to change
  • Squiz LowercasePHPFunctionSniff no longer throws errors for the limited set of PHP keywords it was checking
    • Add a rule for Generic.PHP.LowerCaseKeyword to your ruleset to replicate this functionality
  • Added support for the PHP 5.4 T_CALLABLE token so it can be used in lower PHP versions
  • Generic EndFileNoNewlineSniff now supports checking of CSS and JS files
  • PSR2 SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented
    • Default remains at 4; override the indent setting in a ruleset.xml file to change
    • Thanks to Asher Snyder for the patch
  • Generic ScopeIndentSniff now has a setting to specify a list of tokens that should be ignored
    • The first token on the line is checked and the whole line is ignored if the token is in the array
    • Thanks to Eloy Lafuente for the patch
  • Squiz LowercaseClassKeywordsSniff now checks for the TRAIT keyword
    • Thanks to Anthon Pang for the patch
  • If you create your own PHP_CodeSniffer object, PHPCS will no longer exit when an unknown argument is found
    • This allows you to create wrapper scripts for PHPCS more easily
  • PSR2 MethodDeclarationSniff no longer generates a notice for methods named "_"
    • Thanks to Bart S for the patch
  • Squiz BlockCommentSniff no longer reports that a blank line between a scope closer and block comment is invalid
  • Generic DuplicateClassNameSniff no longer reports an invalid error if multiple PHP open tags exist in a file
  • Generic DuplicateClassNameSniff no longer reports duplicate errors if multiple PHP open tags exist in a file
  • Fixed bug #19819 : Freeze with syntax error in use statement
  • Fixed bug #19820 : Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff
  • Fixed bug #19859 : CodeSniffer::setIgnorePatterns API changed
  • Fixed bug #19871 : findExtendedClassName doesn't return FQCN on namespaced classes
  • Fixed bug #19879 : bitwise and operator interpreted as reference by value