squizlabs/PHP_CodeSniffer
### [`v3.4.2`](https://togithub.com/squizlabs/PHP_CodeSniffer/releases/3.4.2)
[Compare Source](https://togithub.com/squizlabs/PHP_CodeSniffer/compare/3.4.1...3.4.2)
- `Squiz.Arrays.ArrayDeclaration` now has improved handling of syntax errors
- Fixed an issue where the PCRE JIT on PHP 7.3 caused PHPCS to die when using the parallel option
- PHPCS now disables the PCRE JIT before running
- Fixed bug [#2368](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2368) : MySource.PHP.AjaxNullComparison throws error when first function has no doc comment
- Fixed bug [#2414](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2414) : Indention false positive in switch/case/if combination
- Fixed bug [#2423](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2423) : Squiz.Formatting.OperatorBracket.MissingBrackets error with static
- Fixed bug [#2450](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2450) : Indentation false positive when closure containing nested IF conditions used as function argument
- Fixed bug [#2452](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2452) : LowercasePHPFunctions sniff failing on "new \\File()"
- Fixed bug [#2453](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2453) : Squiz.CSS.SemicolonSpacingSniff false positive when style name proceeded by an asterisk
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2464](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2464) : Fixer conflict between Generic.WhiteSpace.ScopeIndent and Squiz.WhiteSpace.ScopeClosingBrace when class indented 1 space
- Fixed bug [#2465](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2465) : Excluding a sniff by path is not working
- Fixed bug [#2467](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2467) : PHP open/close tags inside CSS files are replaced with internal PHPCS token strings when auto fixing
### [`v3.4.1`](https://togithub.com/squizlabs/PHP_CodeSniffer/releases/3.4.1)
[Compare Source](https://togithub.com/squizlabs/PHP_CodeSniffer/compare/3.4.0...3.4.1)
#### Note for PEAR Users
The PEAR installable version of PHPCS was missing some files, which have been re-included in this release. The result of these omissions were:
- The `code` report was not previously available for PEAR installs
- The `Generic.Formatting.SpaceBeforeCast` sniff was not previously available for PEAR installs
- The `Generic.WhiteSpace.LanguageConstructSpacing` sniff was not previously available for PEAR installs
Thanks to Juliette Reinders Folmer for the patch
#### Changelog
- PHPCS will now refuse to run if any of the required PHP extensions are not loaded
- Previously, PHPCS only relied on requirements being checked by PEAR and Composer
- Thanks to Juliette Reinders Folmer for the patch
- Ruleset XML parsing errors are now displayed in a readable format so they are easier to correct
- Thanks to Juliette Reinders Folmer for the patch
- The PSR2 standard no longer throws duplicate errors for spacing around FOR loop parentheses
- Thanks to Juliette Reinders Folmer for the patch
- `T_PHPCS_SET` tokens now contain `sniffCode`, `sniffProperty`, and `sniffPropertyValue` indexes
- Sniffs can use this information instead of having to parse the token content manually
- Added more guard code for syntax errors to various CSS sniffs
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.Commenting.DocComment` error messages now contain the name of the comment tag that caused the error
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.ControlStructures.InlineControlStructure` now handles syntax errors correctly
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.Debug.JSHint` now longer requires rhino and can be run directly from the npm install
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.Files.LineEndings` no longer adds superfluous new line at the end of JS and CSS files
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.Formatting.DisallowMultipleStatements` no longer tries fix lines containing `phpcs:ignore` statements
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.Functions.FunctionCallArgumentSpacing` now has improved performance and anonymous class support
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.WhiteSpace.ScopeIndent` now respects changes to the `exact` property using `phpcs:set` mid-way through a file
- This allows you change the `exact` rule for only some parts of a file
- `Generic.WhiteSpace.ScopeIndent` now disables exact indent checking inside all arrays
- Previously, this was only done when using long array syntax, but it now works for short array syntax as well
- `PEAR.Classes.ClassDeclaration` now has improved handling of PHPCS annotations and tab indents
- `PSR12.Classes.ClassInstantiation` has changed it's error code from `MissingParenthesis` to `MissingParentheses`
- `PSR12.Keywords.ShortFormTypeKeywords` now ignores all spacing inside type casts during both checking and fixing
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.Classes.LowercaseClassKeywords` now examines the class keyword for anonymous classes
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.ControlStructures.ControlSignature` now has improved handling of parse errors
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.Commenting.PostStatementComment` fixer no longer adds a blank line at the start of a JS file that begins with a comment
- Fixes a conflict between this sniff and the `Squiz.WhiteSpace.SuperfluousWhitespace` sniff
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.Commenting.PostStatementComment` now ignores comments inside control structure conditions, such as FOR loops
- Fixes a conflict between this sniff and the `Squiz.ControlStructures.ForLoopDeclaration` sniff
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.Commenting.FunctionCommentThrowTag` now has improved support for unknown exception types and namespaces
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.ControlStructures.ForLoopDeclaration` has improved whitespace, closure, and empty expression support
- The `SpacingAfterSecondNoThird` error code has been removed as part of these fixes
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.CSS.ClassDefinitionOpeningBraceSpace` now handles comments and indentation correctly
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.CSS.ClassDefinitionClosingBrace` now handles comments, indentation, and multiple statements on the same line correctly
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.CSS.Opacity` now handles comments correctly
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.CSS.SemicolonSpacing` now handles comments and syntax errors correctly
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.NamingConventions.ValidVariableName` now supports variables inside anonymous classes correctly
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.PHP.LowercasePHPFunctions` now handles use statements, namespaces, and comments correctly
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.WhiteSpace.FunctionSpacing` now fixes function spacing correctly when a function is the first content in a file
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.WhiteSpace.SuperfluousWhitespace` no longer throws errors for spacing between functions and properties in anon classes
- Thanks to Juliette Reinders Folmer for the patch
- `Zend.Files.ClosingTag` no longer adds a semi-colon during fixing of a file that only contains a comment
- Thanks to Juliette Reinders Folmer for the patch
- `Zend.NamingConventions.ValidVariableName` now supports variables inside anonymous classes correctly
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2298](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2298) : PSR2.Classes.ClassDeclaration allows extended class on new line
- Thanks to Michał Bundyra for the patch
- Fixed bug [#2337](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2337) : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line function call starts on same line as open tag
- Fixed bug [#2348](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2348) : Cache not invalidated when changing a ruleset included by another
- Fixed bug [#2376](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2376) : Using \_\_halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it's last in the function list
- Thanks to Sijun Zhu for the patch
- Fixed bug [#2393](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2393) : The gitmodified filter will infinitely loop when encountering deleted file paths
- Thanks to Lucas Manzke for the patch
- Fixed bug [#2396](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2396) : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line IF condition mixed with HTML
- Fixed bug [#2431](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2431) : Use function/const not tokenized as T_STRING when preceded by comment
### [`v3.4.0`](https://togithub.com/squizlabs/PHP_CodeSniffer/releases/3.4.0)
[Compare Source](https://togithub.com/squizlabs/PHP_CodeSniffer/compare/3.3.2...3.4.0)
#### Deprecations
##### Generic.Formatting.NoSpaceAfterCast Sniff
The `Generic.Formatting.NoSpaceAfterCast` sniff has been deprecated and will be removed in version 4.
The functionality of this sniff is now available in the `Generic.Formatting.SpaceAfterCast` sniff. Include the `Generic.Formatting.SpaceAfterCast` sniff and set the `spacing` property to `0` to retain the existing functionality. As soon as possible, replace all instances of the old sniff code with the new sniff code and property setting in your ruleset.xml files. The existing sniff will continue to work until version 4 has been released.
#### Other Changes
- Rule include patterns in a ruleset.xml file are now evaluated as **OR** instead of **AND**
- Previously, a file had to match every include pattern and no exclude patterns to be included
- Now, a file must match at least one include pattern and no exclude patterns to be included
- This is a bug fix as include patterns are already documented to work this way
- New token `T_BITWISE_NOT` added for the bitwise not operator
- This token was previously tokenized as `T_NONE`
- Any sniffs specifically looking for `T_NONE` tokens with a tilde as the contents must now also look for `T_BITWISE_NOT`
- Sniffs can continue looking for `T_NONE` as well as `T_BITWISE_NOT` to support older PHP_CodeSniffer versions
- All types of binary casting are now tokenized as `T_BINARY_CAST`
- Previously, the `b` in `b"some string with $var"` would be a `T_BINARY_CAST`, but only when the string contained a var
- This change ensures the `b` is always tokenized as `T_BINARY_CAST`
- This change also converts `(binary)` from `T_STRING_CAST` to `T_BINARY_CAST`
- Thanks to Juliette Reinders Folmer for the help with this patch
- Array properties set inside a ruleset.xml file can now extend a previous value instead of always overwriting it
- e.g., if you include a ruleset that defines forbidden functions, can you now add to that list instead of having to redefine it
- To use this feature, add `extend="true"` to the property tag
- e.g., ``
- Thanks to Michael Moravec for the patch
- If `$XDG_CACHE_HOME` is set and points to a valid directory, it will be used for caching instead of the system temp directory
- PHPCBF now disables parallel running if you are passing content on STDIN
- Stops an error from being shown after the fixed output is printed
- The progress report now shows files with tokenizer errors as skipped (**S**) instead of a warning (**W**)
- The tokenizer error is still displayed in reports as normal
- Thanks to Juliette Reinders Folmer for the patch
- The Squiz standard now ensures there is no space between an increment/decrement operator and its variable
- The `File:: getMethodProperties()` method now includes a `has_body` array index in the return value
- FALSE if the method has no body (as with abstract and interface methods) or TRUE otherwise
- Thanks to Chris Wilkinson for the patch
- The `File::getTokensAsString()` method now throws an exception if the `$start` param is invalid
- If the `$length` param is invalid, an empty string will be returned
- Stops an infinite loop when the function is passed invalid data
- Thanks to Juliette Reinders Folmer for the patch
- Added new `Generic.CodeAnalysis.EmptyPHPStatement` sniff
- Warns when it finds empty PHP open/close tag combinations or superfluous semicolons
- Thanks to Juliette Reinders Folmer for the contribution
- Added new `Generic.Formatting.SpaceBeforeCast` sniff
- Ensures there is exactly 1 space before a type cast, unless the cast statement is indented or multi-line
- Thanks to Juliette Reinders Folmer for the contribution
- Added new `Generic.VersionControl.GitMergeConflict` sniff
- Detects merge conflict artifacts left in files
- Thanks to Juliette Reinders Folmer for the contribution
- Added `Generic.WhiteSpace.IncrementDecrementSpacing` sniff
- Ensures there is no space between the operator and the variable it applies to
- Thanks to Juliette Reinders Folmer for the contribution
- Added `PSR12.Functions.NullableTypeDeclaration` sniff
- Ensures there is no space after the question mark in a nullable type declaration
- Thanks to Timo Schinkel for the contribution
- A number of sniffs have improved support for methods in anonymous classes
- These sniffs would often throw the same error twice for functions in nested classes
- Error messages have also been changed to be less confusing
- The full list of affected sniffs is:
- `Generic.NamingConventions.CamelCapsFunctionName`
- `PEAR.NamingConventions.ValidFunctionName`
- `PSR1.Methods.CamelCapsMethodName`
- `PSR2.Methods.MethodDeclaration`
- `Squiz.Scope.MethodScope`
- `Squiz.Scope.StaticThisUsage`
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.CodeAnalysis.UnusedFunctionParameter` now only skips functions with empty bodies when the class implements an interface
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.CodeAnalysis.UnusedFunctionParameter` now has additional error codes to indicate where unused params were found
- The new error code prefixes are:
- `FoundInExtendedClass`: when the class extends another
- `FoundInImplementedInterface`: when the class implements an interface
- `Found`: used in all other cases, including closures
- The new error code suffixes are:
- `BeforeLastUsed`: the unused param was positioned before the last used param in the function signature
- `AfterLastUsed`: the unused param was positioned after the last used param in the function signature
- This makes the new error code list for this sniff:
- `Found`
- `FoundBeforeLastUsed`
- `FoundAfterLastUsed`
- `FoundInExtendedClass`
- `FoundInExtendedClassBeforeLastUsed`
- `FoundInExtendedClassAfterLastUsed`
- `FoundInImplementedInterface`
- `FoundInImplementedInterfaceBeforeLastUsed`
- `FoundInImplementedInterfaceAfterLastUsed`
- These errors code make it easier for specific cases to be ignored or promoted using a ruleset.xml file
- Thanks to Juliette Reinders Folmer for the contribution
- `Generic.Classes.DuplicateClassName` now inspects traits for duplicate names as well as classes and interfaces
- Thanks to Chris Wilkinson for the patch
- `Generic.Files.InlineHTML` now ignores a BOM at the start of the file
- Thanks to Chris Wilkinson for the patch
- `Generic.PHP.CharacterBeforePHPOpeningTag` now ignores a BOM at the start of the file
- Thanks to Chris Wilkinson for the patch
- `Generic.Formatting.SpaceAfterCast` now has a setting to specify how many spaces are required after a type cast
- Default remains **1**
- Override the `spacing` setting in a ruleset.xml file to change
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.Formatting.SpaceAfterCast` now has a setting to ignore newline characters after a type cast
- Default remains **FALSE**, so newlines are not allowed
- Override the `ignoreNewlines` setting in a ruleset.xml file to change
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.Formatting.SpaceAfterNot` now has a setting to specify how many spaces are required after a NOT operator
- Default remains **1**
- Override the `spacing` setting in a ruleset.xml file to change
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.Formatting.SpaceAfterNot` now has a setting to ignore newline characters after the NOT operator
- Default remains **FALSE**, so newlines are not allowed
- Override the `ignoreNewlines` setting in a ruleset.xml file to change
- Thanks to Juliette Reinders Folmer for the patch
- `PEAR.Functions.FunctionDeclaration` now checks spacing before the opening parenthesis of functions with no body
- Thanks to Chris Wilkinson for the patch
- `PEAR.Functions.FunctionDeclaration` now enforces no space before the semicolon in functions with no body
- Thanks to Chris Wilkinson for the patch
- `PSR2.Classes.PropertyDeclaration` now checks the order of property modifier keywords
- This is a rule that is documented in PSR-2 but was not enforced by the included PSR2 standard until now
- This sniff is also able to fix the order of the modifier keywords if they are incorrect
- Thanks to Juliette Reinders Folmer for the patch
- `PSR2.Methods.MethodDeclaration` now checks method declarations inside traits
- Thanks to Chris Wilkinson for the patch
- `Squiz.Commenting.InlineComment` now has better detection of comment block boundaries
- `Squiz.Classes.ClassFileName` now checks that a trait name matches the filename
- Thanks to Chris Wilkinson for the patch
- `Squiz.Classes.SelfMemberReference` now supports scoped declarations and anonymous classes
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.Classes.SelfMemberReference` now fixes multiple errors at once, increasing fixer performance
- Thanks to Gabriel Ostrolucký for the patch
- `Squiz.Functions.LowercaseFunctionKeywords` now checks abstract and final prefixes, and auto-fixes errors
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.Objects.ObjectMemberComma.Missing` has been renamed to `Squiz.Objects.ObjectMemberComma.Found`
- The error is thrown when the comma is found but not required, so the error code was incorrect
- If you are referencing the old error code in a ruleset XML file, please use the new code instead
- If you wish to maintain backwards compatibility, you can provide rules for both the old and new codes
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.WhiteSpace.ObjectOperatorSpacing` is now more tolerant of parse errors
- `Squiz.WhiteSpace.ObjectOperatorSpacing` now fixes errors more efficiently
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2109](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2109) : Generic.Functions.CallTimePassByReference false positive for bitwise and used in function argument
- Fixed bug [#2165](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2165) : Conflict between Squiz.Arrays.ArrayDeclaration and ScopeIndent sniffs when heredoc used in array
- Fixed bug [#2167](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2167) : Generic.WhiteSpace.ScopeIndent shows invalid error when scope opener indented inside inline HTML
- Fixed bug [#2178](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2178) : Generic.NamingConventions.ConstructorName matches methods in anon classes with same name as containing class
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2190](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2190) : PEAR.Functions.FunctionCallSignature incorrect error when encountering trailing PHPCS annotation
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2194](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2194) : Generic.Whitespace.LanguageConstructSpacing should not be checking namespace operators
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2202](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2202) : Squiz.WhiteSpace.OperatorSpacing throws error for negative index when using curly braces for string access
- Same issue fixed in Squiz.Formatting.OperatorBracket
- Thanks to Andreas Buchenrieder for the patch
- Fixed bug [#2210](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2210) : Generic.NamingConventions.CamelCapsFunctionName not ignoring SoapClient \_\_getCookies() method
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2211](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2211) : PSR2.Methods.MethodDeclaration gets confused over comments between modifier keywords
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2212](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2212) : FUNCTION and CONST in use groups being tokenised as T_FUNCTION and T_CONST
- Thanks to Chris Wilkinson for the patch
- Fixed bug [#2214](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2214) : File::getMemberProperties() is recognizing method params as properties
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2236](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2236) : Memory info measurement unit is Mb but probably should be MB
- Fixed bug [#2246](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2246) : CSS tokenizer does not tokenize class names correctly when they contain the string NEW
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2278](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2278) : Squiz.Operators.ComparisonOperatorUsage false positive when inline IF contained in parentheses
- Thanks to Arnout Boks for the patch
- Fixed bug [#2284](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2284) : Squiz.Functions.FunctionDeclarationArgumentSpacing removing type hint during fixing
- Thanks to Michał Bundyra for the patch
- Fixed bug [#2297](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2297) : Anonymous class not tokenized correctly when used as argument to another anon class
- Thanks to Michał Bundyra for the patch
### [`v3.3.2`](https://togithub.com/squizlabs/PHP_CodeSniffer/releases/3.3.2)
[Compare Source](https://togithub.com/squizlabs/PHP_CodeSniffer/compare/3.3.1...3.3.2)
- Fixed a problem where the report cache was not being cleared when the sniffs inside a standard were updated
- The info report (`--report=info`) now has improved formatting for metrics that span multiple lines
- Thanks to Juliette Reinders Folmer for the patch
- The unit test runner now skips `.bak` files when looking for test cases
- Thanks to Juliette Reinders Folmer for the patch
- The Squiz standard now ensures underscores are not used to indicate visibility of private members vars and methods
- Previously, this standard enforced the use of underscores
- `Generic.PHP.NoSilencedErrors` error messages now contain a code snippet to show the context of the error
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.Arrays.ArrayDeclaration` no longer reports errors for a comma on a line new after a here/nowdoc
- Also stops a parse error being generated when auto-fixing
- The `SpaceBeforeComma` error message has been changed to only have one data value instead of two
- `Squiz.Commenting.FunctionComment` no longer errors when trying to fix indents of multi-line param comments
- `Squiz.Formatting.OperatorBracket` now correctly fixes statements that contain strings
- `Squiz.PHP.CommentedOutCode` now ignores more @-style annotations and includes better comment block detection
- Thanks to Juliette Reinders Folmer for the patch
- Fixed a problem where referencing a relative file path in a ruleset XML file could add unnecessary sniff exclusions
- This didn't actually exclude anything, but caused verbose output to list strange exclusion rules
- Fixed bug [#2110](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2110) : Squiz.WhiteSpace.FunctionSpacing is removing indents from the start of functions when fixing
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2115](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2115) : Squiz.Commenting.VariableComment not checking var types when the [@var](https://togithub.com/var) line contains a comment
- Fixed bug [#2120](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2120) : Tokenizer fails to match T_INLINE_ELSE when used after function call containing closure
- Fixed bug [#2121](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2121) : Squiz.PHP.DisallowMultipleAssignments false positive in while loop conditions
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2127](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2127) : File::findExtendedClassName() doesn't support nested classes
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2138](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2138) : Tokenizer detects wrong token for php ::class feature with spaces
- Fixed bug [#2143](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2143) : PSR2.Namespaces.UseDeclaration does not properly fix "use function" and "use const" statements
- Thanks to Chris Wilkinson for the patch
- Fixed bug [#2144](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2144) : Squiz.Arrays.ArrayDeclaration does incorrect align calculation in array with cyrillic keys
- Fixed bug [#2146](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2146) : Zend.Files.ClosingTag removes closing tag from end of file without inserting a semicolon
- Fixed bug [#2151](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2151) : XML schema not updated with the new array property syntax
### [`v3.3.1`](https://togithub.com/squizlabs/PHP_CodeSniffer/releases/3.3.1)
[Compare Source](https://togithub.com/squizlabs/PHP_CodeSniffer/compare/3.3.0...3.3.1)
#### HHVM Support Dropped
Support for HHVM has been dropped due to recent unfixed bugs and HHVM's refocus on Hack only. Thanks to Walt Sorensen and Juliette Reinders Folmer for helping to remove all HHVM exceptions from the core.
#### Other Changes
- The `full` report (the default report) now has improved word wrapping for multi-line messages and sniff codes
- Thanks to Juliette Reinders Folmer for the patch
- The `summary` report now sorts files based on their directory location instead of just a basic string sort
- Thanks to Juliette Reinders Folmer for the patch
- The `source` report now orders error codes by name when they have the same number of errors
- Thanks to Juliette Reinders Folmer for the patch
- The `junit` report no longer generates validation errors with the Jenkins xUnit plugin
- Thanks to Nikolay Geo for the patch
- `Generic.Commenting.DocComment` no longer generates the `SpacingBeforeTags` error if tags are the first content in the docblock
- The sniff will still generate a `MissingShort` error if there is no short comment
- This allows the `MissingShort` error to be suppressed in a ruleset to make short descriptions optional
- `Generic.Functions.FunctionCallArgumentSpacing` now properly fixes multi-line function calls with leading commas
- Previously, newlines between function arguments would be removed
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.PHP.Syntax` will now use `PHP_BINARY` instead of trying to discover the executable path
- This ensures that the sniff will always syntax check files using the PHP version that PHPCS is running under
- Setting the `php_path` config var will still override this value as normal
- Thanks to Willem Stuursma-Ruwen for the patch
- `PSR2.Namespaces.UseDeclaration` now supports commas at the end of group use declarations
- Also improves checking and fixing for use statements containing parse errors
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.Arrays.ArrayDeclaration` no longer removes the array opening brace while fixing
- This could occur when the opening brace was on a new line and the first array key directly followed
- This change also stops the `KeyNotAligned` error message being incorrectly reported in these cases
- `Squiz.Arrays.ArrayDeclaration` no longer tries to change multi-line arrays to single line when they contain comments
- Fixes a conflict between this sniff and some indentation sniffs
- `Squiz.Classes.ClassDeclaration` no longer enforces spacing rules when a class is followed by a function
- Fixes a conflict between this sniff and the `Squiz.WhiteSpace.FunctionSpacing` sniff
- The `Squiz.Classes.ValidClassName.NotCamelCaps` message now references PascalCase instead of CamelCase
- The `CamelCase class name` metric produced by the sniff has been changed to `PascalCase class name`
- This reflects the fact that the class name check is actually a Pascal Case check and not really Camel Case
- Thanks to Tom H Anderson for the patch
- `Squiz.Commenting.InlineComment` no longer enforces spacing rules when an inline comment is followed by a docblock
- Fixes a conflict between this sniff and the `Squiz.WhiteSpace.FunctionSpacing` sniff
- `Squiz.WhiteSpace.OperatorSpacing` no longer tries to fix operator spacing if the next content is a comment on a new line
- Fixes a conflict between this sniff and the `Squiz.Commenting.PostStatementComment` sniff
- Also stops PHPCS annotations from being moved to a different line, potentially changing their meaning
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.WhiteSpace.FunctionSpacing` no longer checks spacing of functions at the top of an embedded PHP block
- Fixes a conflict between this sniff and the `Squiz.PHP.EmbeddedPHP` sniff
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.WhiteSpace.MemberVarSpacing` no longer checks spacing before member vars that come directly after methods
- Fixes a conflict between this sniff and the `Squiz.WhiteSpace.FunctionSpacing` sniff
- `Squiz.WhiteSpace.SuperfluousWhitespace` now recognizes unicode whitespace at the start and end of a file
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2029](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2029) : Squiz.Scope.MemberVarScope throws fatal error when a property is found in an interface
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2047](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2047) : PSR12.Classes.ClassInstantiation false positive when instantiating class from array index
- Fixed bug [#2048](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2048) : GenericFormatting.MultipleStatementAlignment false positive when assigning values inside an array
- Fixed bug [#2053](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2053) : PSR12.Classes.ClassInstantiation incorrectly fix when using member vars and some variable formats
- Fixed bug [#2065](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2065) : Generic.ControlStructures.InlineControlStructure fixing fails when inline control structure contains closure
- Fixed bug [#2072](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2072) : Squiz.Arrays.ArrayDeclaration throws NoComma error when array value is a shorthand IF statement
- Fixed bug [#2082](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2082) : File with "defined() or define()" syntax triggers PSR1.Files.SideEffects.FoundWithSymbols
- Fixed bug [#2095](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2095) : PSR2.Namespaces.NamespaceDeclaration does not handle namespaces defined over multiple lines
### [`v3.3.0`](https://togithub.com/squizlabs/PHP_CodeSniffer/releases/3.3.0)
[Compare Source](https://togithub.com/squizlabs/PHP_CodeSniffer/compare/3.2.3...3.3.0)
#### Deprecations
##### Squiz.WhiteSpace.LanguageConstructSpacing Sniff
The `Squiz.WhiteSpace.LanguageConstructSpacing` sniff has been deprecated and will be removed in version 4.
The sniff has been moved to the Generic standard, with a new code of `Generic.WhiteSpace.LanguageConstructSpacing`. The new Generic sniff now also checks many more language constructs to enforce additional spacing rules. The existing Squiz sniff will continue to work until version 4 has been released. Thanks to Mponos George for the contribution.
As soon as possible, replace all instances of the old sniff code with the new sniff code in your ruleset.xml files.
##### Setting Array Properties
The current method for setting array properties in ruleset files has been deprecated and will be removed in version 4.
Currently, setting an array value uses the string syntax `print=>echo,create_function=>null`. Now, individual array elements are specified using a new `element` tag with `key` and `value` attributes.
For example, the following array of forbidden functions:
```xml
```
Will be rewritten using this format:
```xml
```
Thanks to Michał Bundyra for the patch.
##### T_ARRAY_HINT Token
The `T_ARRAY_HINT` token has been deprecated and will be removed in version 4.
The token was used to ensure array type hints were not tokenized as `T_ARRAY`, but no other type hints were given a special token. Array type hints now use the standard `T_STRING` token instead.
Sniffs referencing this token type will continue to run without error until version 4, but will not find any `T_ARRAY_HINT` tokens.
##### T_RETURN_TYPE Token
The T_RETURN_TYPE token has been deprecated and will be removed in version 4.
The token was used to ensure array/self/parent/callable return types were tokenized consistently. But for namespaced return types, only the last part of the string (the class name) was tokenized as `T_RETURN_TYPE`. This was not consistent and so return types are now left using their original token types so they are not skipped by sniffs. The exception are array return types, which are tokenized as `T_STRING` instead of `T_ARRAY`, as they are used for type hints.
Sniffs referencing this token type will continue to run without error until version 4, but will not find any `T_RETUTN_TYPE` tokens.
To get the return type of a function, use the `File::getMethodProperties()` method, which now contains a `return_type` array index. This index contains the return type of the function or closer, or a blank string if not specified. If the return type is nullable, the return type will contain the leading`?` and a `nullable_return_type` array index in the return value will also be set to `true`. If the return type contains namespace information, it will be cleaned of whitespace and comments. To access the original return value string, use the main tokens array.
#### PSR-12 Standard In-Progress
This release contains an incomplete version of the PSR-12 coding standard. Errors found using this standard should be valid, but it will miss a lot of violations until it is complete. If you'd like to test and help, you can use the standard by running PHPCS with `--standard=PSR12`
#### Other Changes
- Config values set using --runtime-set now override any config values set in rulesets or the CodeSniffer.conf file
- You can now apply include-pattern rules to individual message codes in a ruleset like you can with exclude-pattern rules
- Previously, include-pattern rules only applied to entire sniffs
- If a message code has both include and exclude patterns, the exclude patterns will be ignored
- Using PHPCS annotations to selectively re-enable sniffs is now more flexible
- Previously, you could only re-enable a sniff/category/standard using the exact same code that was disabled
- Now, you can disable a standard and only re-enable a specific category or sniff
- Or, you can disable a specific sniff and have it re-enable when you re-enable the category or standard
- The value of array sniff properties can now be set using phpcs:set annotations
- e.g., phpcs:set Standard.Category.SniffName property\[] key=>value,key2=>value2
- Thanks to Michał Bundyra for the patch
- PHPCS annotations now remain as T_PHPCS_\* tokens instead of reverting to comment tokens when --ignore-annotations is used
- This stops sniffs (especially commenting sniffs) from generating a large number of false errors when ignoring
- Any custom sniffs that are using the T_PHPCS_\* tokens to detect annotations may need to be changed to ignore them
- Check $phpcsFile->config->annotations to see if annotations are enabled and ignore when false
- You can now use fully or partially qualified class names for custom reports instead of absolute file paths
- To support this, you must specify an autoload file in your ruleset.xml file and use it to register an autoloader
- Your autoloader will need to load your custom report class when requested
- Thanks to Juliette Reinders Folmer for the patch
- The JSON report format now does escaping in error source codes as well as error messages
- Thanks to Martin Vasel for the patch
- Invalid installed_paths values are now ignored instead of causing a fatal error
- Improved testability of custom rulesets by allowing the installed standards to be overridden
- Thanks to Timo Schinkel for the patch
- The key used for caching PHPCS runs now includes all set config values
- This fixes a problem where changing config values (e.g., via --runtime-set) used an incorrect cache file
- The "Function opening brace placement" metric has been separated into function and closure metrics in the info report
- Closures are no longer included in the "Function opening brace placement" metric
- A new "Closure opening brace placement" metric now shows information for closures
- Multi-line T_YIELD_FROM statements are now replicated properly for older PHP versions
- The PSR2 standard no longer produces 2 error messages when the AS keyword in a foreach loop is not lowercase
- Specifying a path to a non-existent dir when using the --report-[reportType]=/path/to/report CLI option no longer throws an exception
- This now prints a readable error message, as it does when using --report-file
- The File::getMethodParamaters() method now includes a type_hint_token array index in the return value
- Provides the position in the token stack of the first token in the type hint
- The File::getMethodProperties() method now includes a return_type_token array index in the return value
- Provides the position in the token stack of the first token in the return type
- The File::getTokensAsString() method can now optionally return original (non tab-replaced) content
- Thanks to Juliette Reinders Folmer for the patch
- Removed Squiz.PHP.DisallowObEndFlush from the Squiz standard
- If you use this sniff and want to continue banning ob_end_flush(), use Generic.PHP.ForbiddenFunctions instead
- You will need to set the forbiddenFunctions property in your ruleset.xml file
- Removed Squiz.PHP.ForbiddenFunctions from the Squiz standard
- Replaced by using the forbiddenFunctions property of Generic.PHP.ForbiddenFunctions in the Squiz ruleset.xml
- Functionality of the Squiz standard remains the same, but the error codes are now different
- Previously, Squiz.PHP.ForbiddenFunctions.Found and Squiz.PHP.ForbiddenFunctions.FoundWithAlternative
- Now, Generic.PHP.ForbiddenFunctions.Found and Generic.PHP.ForbiddenFunctions.FoundWithAlternative
- Added new Generic.PHP.LowerCaseType sniff
- Ensures PHP types used for type hints, return types, and type casting are lowercase
- Thanks to Juliette Reinders Folmer for the contribution
- Added new Generic.WhiteSpace.ArbitraryParenthesesSpacing sniff
- Generates an error for whitespace inside parenthesis that don't belong to a function call/declaration or control structure
- Generates a warning for any empty parenthesis found
- Allows the required spacing to be set using the spacing sniff property (default is 0)
- Allows newlines to be used by setting the ignoreNewlines sniff property (default is false)
- Thanks to Juliette Reinders Folmer for the contribution
- Added new PSR12.Classes.ClassInstantiation sniff
- Ensures parenthesis are used when instantiating a new class
- Added new PSR12.Keywords.ShortFormTypeKeywords sniff
- Ensures the short form of PHP types is used when type casting
- Added new PSR12.Namespaces.CompundNamespaceDepth sniff
- Ensures compound namespace use statements have a max depth of 2 levels
- The max depth can be changed by setting the 'maxDepth' sniff property in a ruleset.xml file
- Added new PSR12.Operators.OperatorSpacing sniff
- Ensures operators are preceded and followed by at least 1 space
- Improved core support for grouped property declarations
- Also improves support in Squiz.WhiteSpace.ScopeKeywordSpacing and Squiz.WhiteSpace.MemberVarSpacing
- Thanks to Juliette Reinders Folmer for the patch
- Generic.Commenting.DocComment now produces a NonParamGroup error when tags are mixed in with the [@param](https://togithub.com/param) tag group
- It would previously throw either a NonParamGroup or ParamGroup error depending on the order of tags
- This change allows the NonParamGroup error to be suppressed in a ruleset to allow the [@param](https://togithub.com/param) group to contain other tags
- Thanks to Phil Davis for the patch
- Generic.Commenting.DocComment now continues checks param tags even if the doc comment short description is missing
- This change allows the MissingShort error to be suppressed in a ruleset without all other errors being suppressed as well
- Thanks to Phil Davis for the patch
- Generic.CodeAnalysis.AssignmentInCondition now reports a different error code for assignments found in WHILE conditions
- The return value of a function call is often assigned in a WHILE condition, so this change makes it easier to exclude these cases
- The new code for this error message is Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
- The error code for all other cases remains as Generic.CodeAnalysis.AssignmentInCondition.Found
- Thanks to Juliette Reinders Folmer for the patch
- Generic.Functions.OpeningFunctionBraceBsdAllman now longer leaves trailing whitespace when moving the opening brace during fixing
- Also applies to fixes made by PEAR.Functions.FunctionDeclaration and Squiz.Functions.MultiLineFunctionDeclaration
- Generic.WhiteSpace.ScopeIndent now does a better job of fixing the indent of multi-line comments
- Generic.WhiteSpace.ScopeIndent now does a better job of fixing the indent of PHP open and close tags
- PEAR.Commenting.FunctionComment now report a different error code for param comment lines with too much padding
- Previously, any lines of a param comment that don't start at the exact comment position got the same error code
- Now, only comment lines with too little padding use ParamCommentAlignment as they are clearly mistakes
- Comment lines with too much padding may be using precision alignment as now use ParamCommentAlignmentExceeded
- This allows for excessive padding to be excluded from a ruleset while continuing to enforce a minimum padding
- PEAR.WhiteSpace.ObjectOperatorIndent now checks the indent of more chained operators
- Previously, it only checked chains beginning with a variable
- Now, it checks chains beginning with function calls, static class names, etc
- Squiz.Arrays.ArrayDeclaration now continues checking array formatting even if the key indent is not correct
- Allows for using different array indent rules while still checking/fixing double arrow and value alignment
- Squiz.Commenting.BlockComment has improved support for tab-indented comments
- Thanks to Juliette Reinders Folmer for the patch
- Squiz.Commenting.BlockComment auto fixing no longer breaks when two block comments follow each other
- Also stopped single-line block comments from being auto fixed when they are embedded in other code
- Also fixed as issue found when PHPCS annotations were used inside a block comment
- Thanks to Juliette Reinders Folmer for the patch
- Squiz.Commenting.BlockComment.LastLineIndent is now able to be fixed with phpcbf
- Thanks to Juliette Reinders Folmer for the patch
- Squiz.Commenting.BlockComment now aligns star-prefixed lines under the opening tag while fixing, instead of indenting them
- Thanks to Juliette Reinders Folmer for the patch
- Squiz.Commenting.FunctionComment.IncorrectTypeHint message no longer contains cut-off suggested type hints
- Squiz.Commenting.InlineComment now uses a new error code for inline comments at the end of a function
- Previously, all inline comments followed by a blank line threw a Squiz.Commenting.InlineComment.SpacingAfter error
- Now, inline comments at the end of a function will instead throw Squiz.Commenting.InlineComment.SpacingAfterAtFunctionEnd
- If you previously excluded SpacingAfter, add an exclusion for SpacingAfterAtFunctionEnd to your ruleset as well
- If you previously only included SpacingAfter, consider including SpacingAfterAtFunctionEnd as well
- The Squiz standard now excludes SpacingAfterAtFunctionEnd as the blank line is checked elsewhere
- Thanks to Juliette Reinders Folmer for the patch
- Squiz.ControlStructures.ControlSignature now errors when a comment follows the closing brace of an earlier body
- Applies to catch, finally, else, elseif, and do/while structures
- The included PSR2 standard now enforces this rule
- Thanks to Juliette Reinders Folmer for the patch
- Squiz.Formatting.OperatorBracket.MissingBrackets message has been changed to remove the word "arithmetic"
- The sniff checks more than just arithmetic operators, so the message is now clearer
- Sniffs.Operators.ComparisonOperatorUsage now detects more cases of implicit true comparisons
- It could previously be confused by comparisons used as function arguments
- Squiz.PHP.CommentedOutCode now ignores simple @-style annotation comments so they are not flagged as commented out code
- Thanks to Juliette Reinders Folmer for the patch
- Squiz.PHP.CommentedOutCode now ignores a greater number of short comments so they are not flagged as commented out code
- Thanks to Juliette Reinders Folmer for the patch
- Squiz.PHP.DisallowComparisonAssignment no longer errors when using the null coalescing operator
- Given this operator is used almost exclusively to assign values, it didn't make sense to generate an error
- Squiz.WhiteSpacing.FunctionSpacing now has a property to specify how many blank lines should be before the first class method
- Only applies when a method is the first code block in a class (i.e., there are no member vars before it)
- Override the 'spacingBeforeFirst' property in a ruleset.xml file to change
- If not set, the sniff will use whatever value is set for the existing 'spacing' property
- Squiz.WhiteSpacing.FunctionSpacing now has a property to specify how many blank lines should be after the last class method
- Only applies when a method is the last code block in a class (i.e., there are no member vars after it)
- Override the 'spacingAfterLast' property in a ruleset.xml file to change
- If not set, the sniff will use whatever value is set for the existing 'spacing' property
- Fixed bug [#1863](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1863) : File::findEndOfStatement() not working when passed a scope opener
- Fixed bug [#1876](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1876) : PSR2.Namespaces.UseDeclaration not giving error for use statements before the namespace declaration
- Adds a new PSR2.Namespaces.UseDeclaration.UseBeforeNamespace error message
- Fixed bug [#1881](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1881) : Generic.Arrays.ArrayIndent is indenting sub-arrays incorrectly when comma not used after the last value
- Fixed bug [#1882](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1882) : Conditional with missing braces confused by indirect variables
- Fixed bug [#1915](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1915) : JS tokenizer fails to tokenize regular expression proceeded by boolean not operator
- Fixed bug [#1920](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1920) : Directory exclude pattern improperly excludes files with names that start the same
- Thanks to Jeff Puckett for the patch
- Fixed bug [#1922](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1922) : Equal sign alignment check broken when list syntax used before assignment operator
- Fixed bug [#1925](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1925) : Generic.Formatting.MultipleStatementAlignment skipping assignments within closures
- Fixed bug [#1931](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1931) : Generic opening brace placement sniffs do not correctly support function return types
- Fixed bug [#1932](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1932) : Generic.ControlStructures.InlineControlStructure fixer moves new PHPCS annotations
- Fixed bug [#1938](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1938) : Generic opening brace placement sniffs incorrectly move PHPCS annotations
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#1939](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1939) : phpcs:set annotations do not cause the line they are on to be ignored
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#1949](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1949) : Squiz.PHP.DisallowMultipleAssignments false positive when using namespaces with static assignments
- Fixed bug [#1959](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1959) : SquizMultiLineFunctionDeclaration error when param has trailing comment
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#1963](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1963) : Squiz.Scope.MemberVarScope does not work for multiline member declaration
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#1971](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1971) : Short array list syntax not correctly tokenized if short array is the first content in a file
- Fixed bug [#1979](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1979) : Tokenizer does not change heredoc to nowdoc token if the start tag contains spaces
- Fixed bug [#1982](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1982) : Squiz.Arrays.ArrayDeclaration fixer sometimes puts a comma in front of the last array value
- Fixed bug [#1993](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1993) : PSR1/PSR2 not reporting or fixing short open tags
- Fixed bug [#1996](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1996) : Custom report paths don't work on case-sensitive filesystems
- Fixed bug [#2006](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2006) : Squiz.Functions.FunctionDeclarationArgumentSpacing fixer removes comment between parens when no args
- The SpacingAfterOpenHint error message has been removed
- It is replaced by the the existing SpacingAfterOpen message
- The error message format for the SpacingAfterOpen and SpacingBeforeClose messages has been changed
- These used to contain 3 pieces of data, but now only contain 2
- If you have customised the error messages of this sniff, please review your ruleset after upgrading
- Fixed bug [#2018](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2018) : Generic.Formatting.MultipleStatementAlignment does see PHP close tag as end of statement block
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#2027](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2027) : PEAR.NamingConventions.ValidFunctionName error when function name includes double underscore
- Thanks to Juliette Reinders Folmer for the patch
### [`v3.2.3`](https://togithub.com/squizlabs/PHP_CodeSniffer/releases/3.2.3)
[Compare Source](https://togithub.com/squizlabs/PHP_CodeSniffer/compare/3.2.2...3.2.3)
- The new `phpcs:` comment syntax can now be prefixed with an at symbol ( `@phpcs:` )
- This restores the behaviour of the previous syntax where these comments are ignored by doc generators
- The current PHP version ID is now used to generate cache files
- This ensures that only cache files generated by the current PHP version are selected
- This change fixes caching issues when using sniffs that produce errors based on the current PHP version
- A new `Tokens::$phpcsCommentTokens` array is now available for sniff developers to detect `phpcs:` comment syntax
- Thanks to Juliette Reinders Folmer for the patch
- Error message codes generated by `Generic.CodeAnalysis.EmptyStatement` are no longer all-uppercase
- For example `Generic.CodeAnalysis.EmptyStatement.DetectedCATCH` becomes `Generic.CodeAnalysis.EmptyStatement.DetectedCatch`
- The `PEAR.Commenting.FunctionComment.Missing` error message now includes the name of the function
- Thanks to Yorman Arias for the patch
- The `PEAR.Commenting.ClassComment.Missing` and `Squiz.Commenting.ClassComment.Missing` error messages now include the name of the class
- Thanks to Yorman Arias for the patch
- `PEAR.Functions.FunctionCallSignature` now only forces alignment at a specific tab stop while fixing
- It was enforcing this during checking, but this meant invalid errors if the OpeningIndent message was being muted
- This fixes incorrect errors when using the PSR2 standard with some code blocks
- `Generic.Files.LineLength` now ignores lines that only contain `phpcs:` annotation comments
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.Formatting.MultipleStatementAlignment` now skips over arrays containing comments
- Thanks to Juliette Reinders Folmer for the patch
- `Generic.PHP.Syntax` now forces `display_errors` to `ON` when linting
- Thanks to Raúl Arellano for the patch
- `PSR2.Namespaces.UseDeclaration` has improved syntax error handling and closure detection
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.PHP.CommentedOutCode` now has improved comment block detection for improved accuracy
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.PHP.NonExecutableCode` could fatal error while fixing file with syntax error
- `Squiz.PHP.NonExecutableCode` now detects unreachable code after a goto statement
- Thanks to Juliette Reinders Folmer for the patch
- `Squiz.WhiteSpace.LanguageConstructSpacing` has improved syntax error handling while fixing
- Thanks to Juliette Reinders Folmer for the patch
- Improved `phpcs:` annotation syntax handling for a number of sniffs
- Thanks to Juliette Reinders Folmer for the patch
- Improved auto-fixing of files with incomplete comment blocks for various commenting sniffs
- Thanks to Juliette Reinders Folmer for the patch
- Fixed test suite compatibility with PHPUnit 7
- Fixed bug [#1793](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1793) : PSR2 forcing exact indent for function call opening statements
- Fixed bug [#1803](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1803) : Squiz.WhiteSpace.ScopeKeywordSpacing removes member var name while fixing if no space after scope keyword
- Fixed bug [#1817](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1817) : Blank line not enforced after control structure if comment on same line as closing brace
- Fixed bug [#1827](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1827) : A phpcs:enable comment is not tokenized correctly if it is outside a phpcs:disable block
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#1828](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1828) : Squiz.WhiteSpace.SuperfluousWhiteSpace ignoreBlankLines property ignores whitespace after single line comments
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug [#1840](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/1840) : When a comment h
Renovate configuration
📅 Schedule: At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻️ Rebasing: Whenever PR becomes conflicted, or if you modify the PR title to begin with "rebase!".
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Renovate Bot. View repository job log here.
This PR contains the following updates:
2.9.2
->3.4.2
Release Notes
squizlabs/PHP_CodeSniffer
### [`v3.4.2`](https://togithub.com/squizlabs/PHP_CodeSniffer/releases/3.4.2) [Compare Source](https://togithub.com/squizlabs/PHP_CodeSniffer/compare/3.4.1...3.4.2) - `Squiz.Arrays.ArrayDeclaration` now has improved handling of syntax errors - Fixed an issue where the PCRE JIT on PHP 7.3 caused PHPCS to die when using the parallel option - PHPCS now disables the PCRE JIT before running - Fixed bug [#2368](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2368) : MySource.PHP.AjaxNullComparison throws error when first function has no doc comment - Fixed bug [#2414](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2414) : Indention false positive in switch/case/if combination - Fixed bug [#2423](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2423) : Squiz.Formatting.OperatorBracket.MissingBrackets error with static - Fixed bug [#2450](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2450) : Indentation false positive when closure containing nested IF conditions used as function argument - Fixed bug [#2452](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2452) : LowercasePHPFunctions sniff failing on "new \\File()" - Fixed bug [#2453](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2453) : Squiz.CSS.SemicolonSpacingSniff false positive when style name proceeded by an asterisk - Thanks to Juliette Reinders Folmer for the patch - Fixed bug [#2464](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2464) : Fixer conflict between Generic.WhiteSpace.ScopeIndent and Squiz.WhiteSpace.ScopeClosingBrace when class indented 1 space - Fixed bug [#2465](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2465) : Excluding a sniff by path is not working - Fixed bug [#2467](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2467) : PHP open/close tags inside CSS files are replaced with internal PHPCS token strings when auto fixing ### [`v3.4.1`](https://togithub.com/squizlabs/PHP_CodeSniffer/releases/3.4.1) [Compare Source](https://togithub.com/squizlabs/PHP_CodeSniffer/compare/3.4.0...3.4.1) #### Note for PEAR Users The PEAR installable version of PHPCS was missing some files, which have been re-included in this release. The result of these omissions were: - The `code` report was not previously available for PEAR installs - The `Generic.Formatting.SpaceBeforeCast` sniff was not previously available for PEAR installs - The `Generic.WhiteSpace.LanguageConstructSpacing` sniff was not previously available for PEAR installs Thanks to Juliette Reinders Folmer for the patch #### Changelog - PHPCS will now refuse to run if any of the required PHP extensions are not loaded - Previously, PHPCS only relied on requirements being checked by PEAR and Composer - Thanks to Juliette Reinders Folmer for the patch - Ruleset XML parsing errors are now displayed in a readable format so they are easier to correct - Thanks to Juliette Reinders Folmer for the patch - The PSR2 standard no longer throws duplicate errors for spacing around FOR loop parentheses - Thanks to Juliette Reinders Folmer for the patch - `T_PHPCS_SET` tokens now contain `sniffCode`, `sniffProperty`, and `sniffPropertyValue` indexes - Sniffs can use this information instead of having to parse the token content manually - Added more guard code for syntax errors to various CSS sniffs - Thanks to Juliette Reinders Folmer for the patch - `Generic.Commenting.DocComment` error messages now contain the name of the comment tag that caused the error - Thanks to Juliette Reinders Folmer for the patch - `Generic.ControlStructures.InlineControlStructure` now handles syntax errors correctly - Thanks to Juliette Reinders Folmer for the patch - `Generic.Debug.JSHint` now longer requires rhino and can be run directly from the npm install - Thanks to Juliette Reinders Folmer for the patch - `Generic.Files.LineEndings` no longer adds superfluous new line at the end of JS and CSS files - Thanks to Juliette Reinders Folmer for the patch - `Generic.Formatting.DisallowMultipleStatements` no longer tries fix lines containing `phpcs:ignore` statements - Thanks to Juliette Reinders Folmer for the patch - `Generic.Functions.FunctionCallArgumentSpacing` now has improved performance and anonymous class support - Thanks to Juliette Reinders Folmer for the patch - `Generic.WhiteSpace.ScopeIndent` now respects changes to the `exact` property using `phpcs:set` mid-way through a file - This allows you change the `exact` rule for only some parts of a file - `Generic.WhiteSpace.ScopeIndent` now disables exact indent checking inside all arrays - Previously, this was only done when using long array syntax, but it now works for short array syntax as well - `PEAR.Classes.ClassDeclaration` now has improved handling of PHPCS annotations and tab indents - `PSR12.Classes.ClassInstantiation` has changed it's error code from `MissingParenthesis` to `MissingParentheses` - `PSR12.Keywords.ShortFormTypeKeywords` now ignores all spacing inside type casts during both checking and fixing - Thanks to Juliette Reinders Folmer for the patch - `Squiz.Classes.LowercaseClassKeywords` now examines the class keyword for anonymous classes - Thanks to Juliette Reinders Folmer for the patch - `Squiz.ControlStructures.ControlSignature` now has improved handling of parse errors - Thanks to Juliette Reinders Folmer for the patch - `Squiz.Commenting.PostStatementComment` fixer no longer adds a blank line at the start of a JS file that begins with a comment - Fixes a conflict between this sniff and the `Squiz.WhiteSpace.SuperfluousWhitespace` sniff - Thanks to Juliette Reinders Folmer for the patch - `Squiz.Commenting.PostStatementComment` now ignores comments inside control structure conditions, such as FOR loops - Fixes a conflict between this sniff and the `Squiz.ControlStructures.ForLoopDeclaration` sniff - Thanks to Juliette Reinders Folmer for the patch - `Squiz.Commenting.FunctionCommentThrowTag` now has improved support for unknown exception types and namespaces - Thanks to Juliette Reinders Folmer for the patch - `Squiz.ControlStructures.ForLoopDeclaration` has improved whitespace, closure, and empty expression support - The `SpacingAfterSecondNoThird` error code has been removed as part of these fixes - Thanks to Juliette Reinders Folmer for the patch - `Squiz.CSS.ClassDefinitionOpeningBraceSpace` now handles comments and indentation correctly - Thanks to Juliette Reinders Folmer for the patch - `Squiz.CSS.ClassDefinitionClosingBrace` now handles comments, indentation, and multiple statements on the same line correctly - Thanks to Juliette Reinders Folmer for the patch - `Squiz.CSS.Opacity` now handles comments correctly - Thanks to Juliette Reinders Folmer for the patch - `Squiz.CSS.SemicolonSpacing` now handles comments and syntax errors correctly - Thanks to Juliette Reinders Folmer for the patch - `Squiz.NamingConventions.ValidVariableName` now supports variables inside anonymous classes correctly - Thanks to Juliette Reinders Folmer for the patch - `Squiz.PHP.LowercasePHPFunctions` now handles use statements, namespaces, and comments correctly - Thanks to Juliette Reinders Folmer for the patch - `Squiz.WhiteSpace.FunctionSpacing` now fixes function spacing correctly when a function is the first content in a file - Thanks to Juliette Reinders Folmer for the patch - `Squiz.WhiteSpace.SuperfluousWhitespace` no longer throws errors for spacing between functions and properties in anon classes - Thanks to Juliette Reinders Folmer for the patch - `Zend.Files.ClosingTag` no longer adds a semi-colon during fixing of a file that only contains a comment - Thanks to Juliette Reinders Folmer for the patch - `Zend.NamingConventions.ValidVariableName` now supports variables inside anonymous classes correctly - Thanks to Juliette Reinders Folmer for the patch - Fixed bug [#2298](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2298) : PSR2.Classes.ClassDeclaration allows extended class on new line - Thanks to Michał Bundyra for the patch - Fixed bug [#2337](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2337) : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line function call starts on same line as open tag - Fixed bug [#2348](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2348) : Cache not invalidated when changing a ruleset included by another - Fixed bug [#2376](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2376) : Using \_\_halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it's last in the function list - Thanks to Sijun Zhu for the patch - Fixed bug [#2393](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2393) : The gitmodified filter will infinitely loop when encountering deleted file paths - Thanks to Lucas Manzke for the patch - Fixed bug [#2396](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2396) : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line IF condition mixed with HTML - Fixed bug [#2431](https://togithub.com/squizlabs/PHP_CodeSniffer/issues/2431) : Use function/const not tokenized as T_STRING when preceded by comment ### [`v3.4.0`](https://togithub.com/squizlabs/PHP_CodeSniffer/releases/3.4.0) [Compare Source](https://togithub.com/squizlabs/PHP_CodeSniffer/compare/3.3.2...3.4.0) #### Deprecations ##### Generic.Formatting.NoSpaceAfterCast Sniff The `Generic.Formatting.NoSpaceAfterCast` sniff has been deprecated and will be removed in version 4. The functionality of this sniff is now available in the `Generic.Formatting.SpaceAfterCast` sniff. Include the `Generic.Formatting.SpaceAfterCast` sniff and set the `spacing` property to `0` to retain the existing functionality. As soon as possible, replace all instances of the old sniff code with the new sniff code and property setting in your ruleset.xml files. The existing sniff will continue to work until version 4 has been released. #### Other Changes - Rule include patterns in a ruleset.xml file are now evaluated as **OR** instead of **AND** - Previously, a file had to match every include pattern and no exclude patterns to be included - Now, a file must match at least one include pattern and no exclude patterns to be included - This is a bug fix as include patterns are already documented to work this way - New token `T_BITWISE_NOT` added for the bitwise not operator - This token was previously tokenized as `T_NONE` - Any sniffs specifically looking for `T_NONE` tokens with a tilde as the contents must now also look for `T_BITWISE_NOT` - Sniffs can continue looking for `T_NONE` as well as `T_BITWISE_NOT` to support older PHP_CodeSniffer versions - All types of binary casting are now tokenized as `T_BINARY_CAST` - Previously, the `b` in `b"some string with $var"` would be a `T_BINARY_CAST`, but only when the string contained a var - This change ensures the `b` is always tokenized as `T_BINARY_CAST` - This change also converts `(binary)` from `T_STRING_CAST` to `T_BINARY_CAST` - Thanks to Juliette Reinders Folmer for the help with this patch - Array properties set inside a ruleset.xml file can now extend a previous value instead of always overwriting it - e.g., if you include a ruleset that defines forbidden functions, can you now add to that list instead of having to redefine it - To use this feature, add `extend="true"` to the property tag - e.g., `Renovate configuration
📅 Schedule: At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻️ Rebasing: Whenever PR becomes conflicted, or if you modify the PR title to begin with "
rebase!
".🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot. View repository job log here.