Skip to content

Releases: squizlabs/PHP_CodeSniffer

2.3.2

28 Apr 23:40
Compare
Choose a tag to compare
  • The error message for PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase is now clearer (request #579)
  • Fixed bug #545 : Long list of CASE statements can cause tokenizer to reach a depth limit
  • Fixed bug #565 : Squiz.WhiteSpace.OperatorSpacing reports negative number in short array
    • Thanks to Vašek Purchart for the patch
    • Same fix also applied to Squiz.Formatting.OperatorBracket
  • Fixed bug #569 : Generic ScopeIndentSniff throws PHP notices in JS files
  • Fixed bug #570 : Phar class fatals in PHP less than 5.3

2.3.1

23 Apr 03:49
Compare
Choose a tag to compare
  • PHPCS can now exit with 0 even if errors are found
    • Set the ignore_errors_on_exit config variable to 1 to set this behaviour
    • Use with the ignore_warnings_on_exit config variable to never return a non-zero exit code
  • Added Generic DisallowLongArraySyntaxSniff to enforce the use of the PHP short array syntax (request #483)
    • Thanks to Xaver Loppenstedt for helping with tests
  • Added Generic DisallowShortArraySyntaxSniff to ban the use of the PHP short array syntax (request #483)
    • Thanks to Xaver Loppenstedt for helping with tests
  • Generic ScopeIndentSniff no longer does exact checking for content inside parenthesis (request #528)
    • Only applies to custom coding standards that set the "exact" flag to TRUE
  • Squiz ConcatenationSpacingSniff now has a setting to ignore newline characters around operators (request #511)
    • Default remains FALSE, so newlines are not allowed
    • Override the "ignoreNewlines" setting in a ruleset.xml file to change
  • Squiz InlineCommentSniff no longer checks the last char of a comment if the first char is not a letter (request #505)
  • The Squiz standard has increased the max padding for statement alignment from 12 to 20
  • Fixed bug #479 : Yielded values are not recognised as returned values in Squiz FunctionComment sniff
  • Fixed bug #512 : Endless loop whilst parsing mixture of control structure styles
  • Fixed bug #515 : Spaces in JS block incorrectly flagged as indentation error
  • Fixed bug #523 : Generic ScopeIndent errors for IF in FINALLY
  • Fixed bug #527 : Closure inside IF statement is not tokenized correctly
  • Fixed bug #529 : Squiz.Strings.EchoedStrings gives false positive when echo'ing using an inline condition
  • Fixed bug #537 : Using --config-set is breaking phpcs.phar
  • Fixed bug #543 : SWITCH with closure in condition generates inline control structure error
  • Fixed bug #551 : Multiple catch blocks not checked in Squiz.ControlStructures.ControlSignature sniff
  • Fixed bug #554 : ScopeIndentSniff causes errors when encountering an unmatched parenthesis
  • Fixed bug #558 : PHPCBF adds brace for ELSE IF split over multiple lines
  • Fixed bug #564 : Generic MultipleStatementAlignment sniff reports incorrect errors for multiple assignments on a single line

2.3.0

04 Mar 02:13
Compare
Choose a tag to compare
  • The existence of the main config file is now cached to reduce is_file() calls when it doesn't exist (request #486)
  • Abstract classes inside the Sniffs directory are now ignored even if they are named [Name]Sniff.php (request #476)
    • Thanks to David Vernet for the patch
  • PEAR and Squiz FileComment sniffs no longer have @ in their error codes
    • e.g., PEAR.Commenting.FileComment.Duplicate@categoryTag becomes PEAR.Commenting.FileComment.DuplicateCategoryTag
    • e.g., Squiz.Commenting.FileComment.Missing@categoryTag becomes Squiz.Commenting.FileComment.MissingCategoryTag
  • PEAR MultiLineConditionSniff now allows comment lines inside multi-line IF statement conditions
    • Thanks to Klaus Purer for the patch
  • Generic ForbiddenFunctionsSniff now supports setting null replacements in ruleset files (request #263)
  • Generic opening function brace sniffs now support checking of closures
    • Set the checkClosures property to TRUE (default is FALSE) in your ruleset.xml file to enable this
    • Can also set the checkFunctions property to FALSE (default is TRUE) in your ruleset.xml file to only check closures
    • Affects OpeningFunctionBraceBsdAllmanSniff and OpeningFunctionBraceKernighanRitchieSniff
  • Generic OpeningFunctionBraceKernighanRitchieSniff can now fix all the errors it finds
  • Generic OpeningFunctionBraceKernighanRitchieSniff now allows empty functions with braces next to each other
  • Generic OpeningFunctionBraceBsdAllmanSniff now allows empty functions with braces next to each other
  • Improved auto report width for the "full" report
  • Improved conflict detection during auto fixing
  • Generic ScopeIndentSniff is no longer confused by empty closures
  • Squiz ControlSignatureSniff now always ignores comments (fixes bug #490)
    • Include the Squiz.Commenting.PostStatementComment sniff in your ruleset.xml to ban these comments again
  • Squiz OperatorSpacingSniff no longer throws errors for code in the form ($foo || -1 === $bar)
  • Fixed errors tokenizing T_ELSEIF tokens on HHVM 3.5
  • Squiz ArrayDeclarationSniff is no longer tricked by comments after array values
  • PEAR IncludingFileSniff no longer produces invalid code when removing parenthesis from require/include statements
  • Fixed bug #415 : The @codingStandardsIgnoreStart has no effect during fixing
  • Fixed bug #432 : Properties of custom sniffs cannot be configured
  • Fixed bug #453 : PSR2 standard does not allow closing tag for mixed PHP/HTML files
  • Fixed bug #457 : FunctionCallSignature sniffs do not support here/nowdoc syntax and can cause syntax error when fixing
  • Fixed bug #466 : PropertyLabelSpacing JS fixer issue when there is no space after colon
  • Fixed bug #473 : Writing a report for an empty folder to existing file includes the existing contents
  • Fixed bug #485 : PHP notice in Squiz.Commenting.FunctionComment when checking malformed @throws comment
  • Fixed bug #491 : Generic InlineControlStructureSniff can correct with missing semicolon
    • Thanks to Jesse Donat for the patch
  • Fixed bug #492 : Use statements don't increase the scope indent
  • Fixed bug #493 : PSR1_Sniffs_Methods_CamelCapsMethodNameSniff false positives for some magic method detection
    • Thanks to Andreas Möller for the patch
  • Fixed bug #496 : Closures in PSR2 are not checked for a space after the function keyword
  • Fixed bug #497 : Generic InlineControlStructureSniff does not support alternative SWITCH syntax
  • Fixed bug #500 : Functions not supported as values in Squiz ArrayDeclaration sniff
  • Fixed bug #501 : ScopeClosingBrace and ScopeIndent conflict with closures used as array values
    • Generic ScopeIndentSniff may now report fewer errors for closures, but perform the same fixes
  • Fixed bug #502 : PSR1 SideEffectsSniff sees declare() statements as side effects

2.2.0

21 Jan 22:56
Compare
Choose a tag to compare

PHPCS Config File

If PHP_CodeSniffer is not given a list of files to check and is not given a standard to use, it will now look for a phpcs.xml file in the current directory to figure out what it should do. The phpcs.xml file has the exact same format as a normal ruleset.xml file, so it can also be used as your primary standard. But it should also specify some files and/or directories to process using the new ruleset <file> tags.

Having one of these phpcs.xml files allows you to run the phpcs or phpcbf commands without specifying any command line options and still have them check or fix an entire codebase.

If you are using the phpcs.xml file as your primary standard, the files and directories you specify in there will be ignored if any files or directories are specified on the command line. So you can run phpcs like this:

$ phpcs

Or you can use phpcs.xml as a normal standard:

$ phpcs --standard=phpcs.xml /path/to/file

Auto-Sizing Reports

PHP_CodeSniffer has always allowed you to set a report width so that you can see more output in the screen-based reports. From version 2.2.0, you can tell PHP_CodeSniffer to use as much space as it can by using the --report-width=auto command line argument.

When using auto width, PHP_CodeSniffer will use the entire width of your terminal window to produce report output. If the report doesn't need all that width, PHP_CodeSniffer will only use as much as it needs to print the report without wrapping. Use the command phpcs --config-set report_width auto to use auto-sizing by default, or configure it in your ruleset.

PSR2 Tab Width

The PSR2 standard now includes a tab-width setting of 4 in the ruleset.xml file. PSR2 requires 4 spaces for indenting, so running that standard over tab indented code will now detect, and optionally fix, those tab indents correctly without you needing to specify the --tab-width=4 command line argument.

Other Changes

  • Added (hopefully) tastefully used colors to report and progress output for the phpcs command
    • Use the --colors command line argument to use colors in output
    • Use the command "phpcs --config-set colors true" to turn colors on by default
    • Use the --no-colors command line argument to turn colors off when the config value is set
  • Added support for using the full terminal width for report output
    • Use the --report-width=auto command line argument to auto-size the reports
    • Use the command "phpcs --config-set report_width auto" to use auto-sizing by default
  • Reports will now size to fit inside the report width setting instead of always using padding to fill the space
  • If no files or standards are specified, PHPCS will now look for a phpcs.xml file in the current directory
    • This file has the same format as a standard ruleset.xml file
    • The phpcs.xml file should specify (at least) files to process and a standard/sniffs to use
    • Useful for running the phpcs and phpcbf commands without any arguments at the top of a repository
  • Default file paths can now be specified in a ruleset.xml file using the "file" tag
    • File paths are only processed if no files were specified on the command line
  • Extensions specified on the CLI are now merged with those set in ruleset.xml files
    • Previously, the ruleset.xml file setting replaced the CLI setting completely
  • Squiz coding standard now requires lowercase PHP constants (true, false and null)
    • Removed Squiz.NamingConventions.ConstantCase sniff as the rule is now consistent across PHP and JS files
  • Squiz FunctionOpeningBraceSpaceSniff no longer does additional checks for JS functions
    • PHP and JS functions and closures are now treated the same way
  • Squiz MultiLineFunctionDeclarationSniff now supports JS files
  • Interactive mode no longer breaks if you also specify a report type on the command line
  • PEAR InlineCommentSniff now fixes the Perl-style comments that it finds (request #375)
  • PSR2 standard no longer fixes the placement of docblock open tags as comments are excluded from this standard
  • PSR2 standard now sets a default tab width of 4 spaces
  • Generic DocCommentSniff now only disallows lowercase letters at the start of a long/short comment (request #377)
    • All non-letter characters are now allowed, including markdown special characters and numbers
  • Generic DisallowMultipleStatementsSniff now allows multiple open/close tags on the same line (request #423)
  • Generic CharacterBeforePHPOpeningTagSniff now only checks the first PHP tag it finds (request #423)
  • Generic CharacterBeforePHPOpeningTagSniff now allows a shebang line at the start of the file (request #20481)
  • Generic InlineHTMLUnitTest now allows a shebang line at the start of the file (request #20481)
  • PEAR ObjectOperatorIndentSniff now only checks object operators at the start of a line
  • PEAR FileComment and ClassComment sniffs no longer have @ in their error codes
    • E.g., PEAR.Commenting.FileComment.Missing@categoryTag becomes PEAR.Commenting.FileComment.MissingCategoryTag
    • Thanks to Grzegorz Rygielski for the patch
  • Squiz ControlStructureSpacingSniff no longer enforces a blank line before CATCH statements
  • Squiz FunctionCommentSniff now fixes the return type in the @return tag (request #392)
  • Squiz BlockCommentSniff now only disallows lowercase letters at the start of the comment
  • Squiz InlineCommentSniff now only disallows lowercase letters at the start of the comment
  • Squiz OperatorSpacingSniff now has a setting to ignore newline characters around operators (request #348)
    • Default remains FALSE, so newlines are not allowed
    • Override the "ignoreNewlines" setting in a ruleset.xml file to change
  • PSR2 ControlStructureSpacingSniff now checks for, and fixes, newlines after the opening parenthesis
  • Added a markdown document generator (--generator=markdown to use)
    • Thanks to Stefano Kowalke for the contribution
  • Fixed bug #379 : Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast incorrectly detects comments
  • Fixed bug #382 : JS tokenizer incorrect for inline conditionally created immediately invoked anon function
  • Fixed bug #383 : Squiz.Arrays.ArrayDeclaration.ValueNoNewline incorrectly detects nested arrays
  • Fixed bug #386 : Undefined offset in Squiz.FunctionComment sniff when param has no comment
  • Fixed bug #390 : Indentation of non-control structures isn't adjusted when containing structure is fixed
  • Fixed bug #400 : InlineControlStructureSniff fails to fix when statement has no semicolon
  • Fixed bug #401 : PHPCBF no-patch option shows an error when there are no fixable violations in a file
  • Fixed bug #405 : The "Squiz.WhiteSpace.FunctionSpacing" sniff removes class "}" during fixing
  • Fixed bug #407 : PEAR.ControlStructures.MultiLineCondition doesn't account for comments at the end of lines
  • Fixed bug #410 : The "Squiz.WhiteSpace.MemberVarSpacing" not respecting "var"
  • Fixed bug #411 : Generic.WhiteSpace.ScopeIndent.Incorrect - false positive with multiple arrays in argument list
  • Fixed bug #412 : PSR2 multi-line detection doesn't work for inline IF and string concats
  • Fixed bug #414 : Squiz.WhiteSpace.MemberVarSpacing - inconsistent checking of member vars with comment
  • Fixed bug #433 : Wrong detection of Squiz.Arrays.ArrayDeclaration.KeyNotAligned when key contains space
  • Fixed bug #434 : False positive for spacing around "=>" in inline array within foreach
  • Fixed bug #452 : Ruleset exclude-pattern for specific sniff code ignored when using CLI --ignore option
  • Fixed bug #20482 : Scope indent sniff can get into infinite loop when processing a parse error

2.1.0

18 Dec 02:51
Compare
Choose a tag to compare
  • Time and memory output is now shown if progress information is also shown (request #335)
  • A tilde can now be used to reference a user's home directory in a path to a standard (request #353)
  • Added PHP_CodeSniffer_File::findStartOfStatement() to find the first non-whitespace token in a statement
    • Possible alternative for code using PHP_CodeSniffer_File::findPrevious() with the local flag set
  • Added PHP_CodeSniffer_File::findEndOfStatement() to find the last non-whitespace token in a statement
    • Possible alternative for code using PHP_CodeSniffer_File::findNext() with the local flag set
  • Generic opening function brace sniff now ensure the opening brace is the last content on the line
    • Affects OpeningFunctionBraceBsdAllmanSniff and OpeningFunctionBraceKernighanRitchieSniff
    • Also enforced in PEAR FunctionDeclarationSniff and Squiz MultiLineFunctionDeclarationSniff
  • Generic DisallowTabIndentSniff now replaces tabs everywhere it finds them, except in strings and here/now docs
  • Generic EmptyStatementSniff error codes now contain the type of empty statement detected (request #314)
    • All messages generated by this sniff are now errors (empty CATCH was previously a warning)
    • Message code Generic.CodeAnalysis.EmptyStatement.NotAllowed has been removed
    • Message code Generic.CodeAnalysis.EmptyStatement.NotAllowedWarning has been removed
    • New message codes have the format Generic.CodeAnalysis.EmptyStatement.Detected[TYPE]
    • Example code is Generic.CodeAnalysis.EmptyStatement.DetectedCATCH
    • You can now use a custom ruleset to change messages to warnings and to exclude them
  • PEAR and Squiz FunctionCommentSniffs no longer ban @return tags for constructors and destructors
    • Removed message PEAR.Commenting.FunctionComment.ReturnNotRequired
    • Removed message Squiz.Commenting.FunctionComment.ReturnNotRequired
    • Change initiated by request #324 and request #369
  • Squiz EmptyStatementSniff has been removed
    • Squiz standard now includes Generic EmptyStatementSniff and turns off the empty CATCH error
  • Squiz ControlSignatureSniff fixes now retain comments between the closing parenthesis and open brace
  • Squiz SuperfluousWhitespaceSniff now checks for extra blank lines inside closures
    • Thanks to Sertan Danis for the patch
  • Squiz ArrayDeclarationSniff now skips function calls while checking multi-line arrays
  • Fixed bug #337 : False positive with anonymous functions in Generic_Sniffs_WhiteSpace_ScopeIndentSniff
  • Fixed bug #339 : reformatting brace location can result in broken code
  • Fixed bug #342 : Nested ternary operators not tokenized correctly
  • Fixed bug #345 : Javascript regex not tokenized when inside array
  • Fixed bug #346 : PHP path can't be determined in some cases in "phpcs.bat" (on Windows XP)
  • Fixed bug #358 : False positives for Generic_Sniffs_WhiteSpace_ScopeIndentSniff
  • Fixed bug #361 : Sniff-specific exclude patterns don't work for Windows
  • Fixed bug #364 : Don't interpret "use function" as declaration
  • Fixed bug #366 : phpcbf with PSR2 errors on control structure alternative syntax
  • Fixed bug #367 : Nested Anonymous Functions Causing False Negative
  • Fixed bug #371 : Shorthand binary cast causes tokenizer errors
    • New token T_BINARY_CAST added for the b"string" cast format (the 'b' is the T_BINARY_CAST token)
  • Fixed bug #372 : phpcbf parse problem, wrong brace placement for inline IF
  • Fixed bug #373 : Double quote usage fix removing too many double quotes
  • Fixed bug #20196 : 1.5.2 breaks scope_closer position

2.0.0

05 Dec 02:50
Compare
Choose a tag to compare
  • JS tokenizer now sets functions as T_CLOSUREs if the function is anonymous
  • JS tokenizer now sets all objects to T_OBJECT
    • Object end braces are set to a new token T_CLOSE_OBJECT
    • T_OBJECT tokens no longer act like scopes; i.e., they have no condition/opener/closer
    • T_PROPERTY tokens no longer act like scopes; i.e., they have no condition/opener/closer
    • T_OBJECT tokens have a bracket_closer instead, which can be used to find the ending
    • T_CLOSE_OBJECT tokens have a bracket_opener
  • Improved regular expression detection in the JS tokenizer
  • You can now get PHP_CodeSniffer to ignore a single line by putting @codingStandardsIgnoreLine in a comment
    • When the comment is found, the comment line and the following line will be ignored
    • Thanks to Andy Bulford for the contribution
  • PHPCBF now prints output when it is changing into directories
  • Improved conflict detection during auto fixing
  • The -vvv command line argument will now output the current file content for each loop during fixing
  • Generic ScopeIndentSniff now checks that open/close PHP tags are aligned to the correct column
  • PEAR FunctionCallSignatureSniff now checks indent of closing parenthesis even if it is not on a line by itself
  • PEAR FunctionCallSignatureSniff now supports JS files
  • PEAR MultiLineConditionSniff now supports JS files
  • Squiz DocCommentAlignmentSniff now supports JS files
  • Fixed a problem correcting the closing brace line in Squiz ArrayDeclarationSniff
  • Fixed a problem auto-fixing the Squiz.WhiteSpace.FunctionClosingBraceSpace.SpacingBeforeNestedClose error
  • Squiz EmbeddedPhpSniff no longer reports incorrect alignment of tags when they are not on new lines
  • Squiz EmbeddedPhpSniff now aligns open tags correctly when moving them onto a new line
  • Improved fixing of arrays with multiple values in Squiz ArrayDeclarationSniff
  • Improved detection of function comments in Squiz FunctionCommentSpacingSniff
  • Improved fixing of lines after cases statements in Squiz SwitchDeclarationSniff
  • Fixed bug #311 : Suppression of function prototype breaks checking of lines within function
  • Fixed bug #320 : Code sniffer identation issue
  • Fixed bug #333 : Nested ternary operators causing problems

1.5.6

04 Dec 22:38
Compare
Choose a tag to compare
  • JS tokenizer now detects xor statements correctly
  • The --config-show command now pretty-prints the config values
    • Thanks to Ken Guest for the patch
  • Setting and removing config values now catches exceptions if the config file is not writable
    • Thanks to Ken Guest for the patch
  • Setting and removing config values now prints a message to confirm the action and show old values
  • You can now get PHP_CodeSniffer to ignore a single line by putting @codingStandardsIgnoreLine in a comment
    • When the comment is found, the comment line and the following line will be ignored
    • Thanks to Andy Bulford for the contribution
  • Generic ConstructorNameSniff no longer errors for PHP4 style constructors when __construct() is present
    • Thanks to Thibaud Fabre for the patch
  • Fixed bug #280 : The --config-show option generates error when there is no config file
  • Fixed bug #306 : File containing only a namespace declaration raises undefined index notice
  • Fixed bug #308 : Squiz InlineIfDeclarationSniff fails on ternary operators inside closure
  • Fixed bug #310 : Variadics not recognized by tokenizer
  • Fixed bug #311 : Suppression of function prototype breaks checking of lines within function

2.0.0RC4

06 Nov 21:21
Compare
Choose a tag to compare
2.0.0RC4 Pre-release
Pre-release
  • JS tokenizer now detects xor statements correctly
  • Improved detection of properties and objects in the JS tokenizer
  • Generic ScopeIndentSniff can now fix indents using tabs instead of spaces
    • Set the tabIndent property to TRUE in your ruleset.xml file to enable this
    • It is important to also set a tab-width setting, either in the ruleset or on the command line, for accuracy
  • Generic ScopeIndentSniff now checks and auto-fixes JS files
  • Generic DisallowSpaceIndentSniff is now able to replace space indents with tab indents during fixing
  • Support for phpcs-only and phpcbf-only attributes has been added to all ruleset.xml elements
    • Allows parts of the ruleset to only apply when using a specific tool
    • Useful for doing things like excluding indent fixes but still reporting indent errors
  • Unit tests can now set command line arguments during a test run
    • Override getCliValues() and pass an array of CLI arguments for each file being tested
  • File-wide sniff properties can now be set using T_INLINE_HTML content during unit test runs
    • Sniffs that start checking at the open tag can only, normally, have properties set using a ruleset
  • Generic ConstructorNameSniff no longer errors for PHP4 style constructors when __construct() is present
    • Thanks to Thibaud Fabre for the patch
  • Generic DocCommentSniff now checks that the end comment tag is on a new line
  • Generic MultipleStatementAlignmentSniff no longer skips assignments for closures
  • Squiz DocCommentAlignment sniff now has better checking for single line doc block
  • Running unit tests with the -v CLI argument no longer generates PHP errors
  • Fixed bug #295 : ScopeIndentSniff hangs when processing nested closures
  • Fixed bug #298 : False positive in ScopeIndentSniff when anonymous functions are used with method chaining
  • Fixed bug #302 : Fixing code in Squiz InlineComment sniff can remove some comment text
  • Fixed bug #303 : Open and close tag on same line can cause a PHP notice checking scope indent
  • Fixed bug #306 : File containing only a namespace declaration raises undefined index notice
  • Fixed bug #307 : Conditional breaks in case statements get incorrect indentions
  • Fixed bug #308 : Squiz InlineIfDeclarationSniff fails on ternary operators inside closure
  • Fixed bug #310 : Variadics not recognized by tokenizer

2.0.0RC3

16 Oct 00:07
Compare
Choose a tag to compare
2.0.0RC3 Pre-release
Pre-release
  • Improved default output for PHPCBF and removed the options to print verbose and progress output
  • Fixer now uses temporary system files for diffing rather than creating them in the current working dir
  • If a .fixed file is supplied for a unit test file, the auto fixes will be checked against it during testing
    • See Generic ScopeIndentUnitTest.inc and ScopeIndentUnitTest.inc.fixed for an example
  • Fixer token replacement methods now return TRUE if the change was accepted and FALSE if rejected
  • The --config-show command now pretty-prints the config values
    • Thanks to Ken Guest for the patch
  • Setting and removing config values now catches exceptions if the config file is not writable
    • Thanks to Ken Guest for the patch
  • Setting and removing config values now prints a message to confirm the action and show old values
  • Generic ScopeIndentSniff has been completly rewritten to improve fixing and embedded PHP detection
  • Generic DisallowTabIndent and DisallowSpaceIndent sniffs now detect indents at the start of block comments
  • Generic DisallowTabIndent and DisallowSpaceIndent sniffs now detect indents inside multi-line strings
  • Generic DisallowTabIndentSniff now replaces tabs inside doc block comments
  • Squiz ControlStructureSpacingSniff error codes have been corrected; they were reversed
  • Squiz EmbeddedPhpSniff now checks open and close tag indents and fixes some errors
  • Squiz FileCommentSniff no longer throws incorrect blank line before comment errors in JS files
  • Squiz ClassDeclarationSniff now has better checking for blank lines after a closing brace
  • Removed error Squiz.Classes.ClassDeclaration.NoNewlineAfterCloseBrace (request #285)
    • already handled by Squiz.Classes.ClassDeclaration.CloseBraceSameLine
  • Fixed bug #280 : The --config-show option generates error when there is no config file

2.0.0RC2

25 Sep 22:50
Compare
Choose a tag to compare
2.0.0RC2 Pre-release
Pre-release
  • Minified JS and CSS files are now detected and skipped (fixes bug #252 and bug #19899)
    • A warning will be added to the file so it can be found in the report and ignored in the future
  • Fixed incorrect length of JS object operator tokens
  • 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
  • PHPCS can now exit with 0 if only warnings were found (request #262)
    • Set the ignore_warnings_on_exit config variable to 1 to set this behaviour
    • Default remains at exiting with 0 only if no errors and no warnings were found
    • Also changes return value of PHP_CodeSniffer_Reporting::printReport()
  • Rulesets can now set associative array properties
    • property name="[property]" type="array" value="foo=>bar,baz=>qux"
  • Generic ForbiddenFunctionsSniff now has a public property called forbiddenFunctions (request #263)
    • Override the property in a ruleset.xml file to define forbidden functions and their replacements
    • A replacement of NULL indicates that no replacement is available
    • e.g., value="delete=>unset,print=>echo,create_function=>null"
    • Custom sniffs overriding this one will need to change the visbility of their member var
  • Improved closure support in Generic ScopeIndentSniff
  • Improved indented PHP tag support in Generic ScopeIndentSniff
  • Improved fixing of mixed line indents in Generic ScopeIndentSniff
  • Added conflict detection to the file fixer
    • If 2 sniffs look to be conflicting, one change will be ignored to allow a fix to occur
  • 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
  • Sniff ignore patterns now replace Win dir separators like file ignore patterns already did
  • Exclude patterns now use backtick delimiters, allowing all special characters to work correctly again
    • Thanks to Jeremy Edgell for the patch
  • Errors converted to warnings in a ruleset (and vice versa) now retain their fixable status
    • Thanks to Alexander Obuhovich for the patch
  • Squiz ConcatenationSpacingSniff now has a setting to specify how many spaces there should around concat operators
    • Default remains at 0
    • Override the "spacing" setting in a ruleset.xml file to change
  • Added auto-fixes for Squiz InlineCommentSniff
  • Generic DocCommentSniff now correctly fixes additional blank lines at the end of a comment
  • Squiz OperatorBracketSniff now correctly fixes operations that include arrays
  • Zend ClosingTagSniff fix now correctly leaves closing tags when followed by HTML
  • Added Generic SyntaxSniff to check for syntax errors in PHP files
    • Thanks to Blaine Schmeisser for the contribution
  • Added Generic OneTraitPerFileSniff to check that only one trait is defined in each file
    • Thanks to Alexander Obuhovich for the contribution
  • Squiz DiscouragedFunctionsSniff now warns about var_dump()
  • PEAR ValidFunctionNameSniff no longer throws an error for _()
  • Squiz and PEAR FunctionCommentSniffs now support _()
  • Generic DisallowTabIndentSniff now checks for, and fixes, mixed indents again
  • Generic UpperCaseConstantSniff and LowerCaseConstantSniff now ignore function names
  • Fixed bug #243 : Missing DocBlock not detected
  • 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 #20377 : Error when trying to execute phpcs with report=json
  • 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 #20402 : SVN pre-commit hook fails due to unknown argument error