Releases: PHPCSStandards/PHP_CodeSniffer
Releases · PHPCSStandards/PHP_CodeSniffer
3.6.1 - 2021-10-11
- PHPCS annotations can now be specified using hash-style comments
- Previously, only slash-style and block-style comments could be used to do things like disable errors
- Thanks to Juliette Reinders Folmer for the patch
- Fixed an issue where some sniffs would not run on PHP files that only used the short echo tag
- The following sniffs were affected:
Generic.Files.ExecutableFile
Generic.Files.LowercasedFilename
Generic.Files.LineEndings
Generic.Files.EndFileNewline
Generic.Files.EndFileNoNewline
Generic.PHP.ClosingPHPTag
Generic.PHP.Syntax
Generic.VersionControl.GitMergeConflict
Generic.WhiteSpace.DisallowSpaceIndent
Generic.WhiteSpace.DisallowTabIndent
- Thanks to Juliette Reinders Folmer for the patch
- The following sniffs were affected:
- The new PHP 8.1 tokenisation for ampersands has been reverted to use the existing PHP_CodeSniffer method
- The PHP 8.1 tokens
T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG
andT_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG
are unsued - Ampersands continue to be tokenized as
T_BITWISE_AND
for all PHP versions - Thanks to Juliette Reinders Folmer and Anna Filina for the patch
- The PHP 8.1 tokens
File::getMethodParameters()
no longer incorrectly returns argument attributes in the type hint array index- A new
has_attributes
array index is available and set toTRUE
if the argument has attributes defined - Thanks to Juliette Reinders Folmer for the patch
- A new
Generic.NamingConventions.ConstructorName
no longer throws deprecation notices on PHP 8.1- Thanks to Juliette Reinders Folmer for the patch
Squiz.Commenting.BlockComment
now correctly applies rules for block comments after a short echo tag- Thanks to Juliette Reinders Folmer for the patch
- Fixed false positives when using attributes in the following sniffs:
PEAR.Commenting.FunctionComment
Squiz.Commenting.InlineComment
Squiz.Commenting.BlockComment
Squiz.Commenting.VariableComment
Squiz.WhiteSpace.MemberVarSpacing
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3294 : Bug in attribute tokenization when content contains PHP end token or attribute closer on new line
- Thanks to Alessandro Chitolina for the patch
- Thanks to Juliette Reinders Folmer for the tests
- Fixed bug #3296 : PSR2.ControlStructures.SwitchDeclaration takes phpcs:ignore as content of case body
- Fixed bug #3297 : PSR2.ControlStructures.SwitchDeclaration.TerminatingComment does not handle try/finally blocks
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3302 : PHP 8.0 | Tokenizer/PHP: bugfix for union types using namespace operator
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3303 : findStartOfStatement() doesn't work with T_OPEN_TAG_WITH_ECHO
- Fixed bug #3316 : Arrow function not tokenized correctly when using null in union type
- Fixed bug #3317 : Problem with how phpcs handles ignored files when running in parallel
- Thanks to Emil Andersson for the patch
- Fixed bug #3324 : PHPCS hangs processing some nested arrow functions inside a function call
- Fixed bug #3326 : Generic.Formatting.MultipleStatementAlignment error with const DEFAULT
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3333 : Squiz.Objects.ObjectInstantiation: null coalesce operators are not recognized as assignment
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3340 : Ensure interface and trait names are always tokenized as T_STRING
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3342 : PSR12/Squiz/PEAR standards all error on promoted properties with docblocks
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3345 : IF statement with no braces and double catch turned into syntax error by auto-fixer
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3352 : PSR2.ControlStructures.SwitchDeclaration can remove comments on the same line as the case statement while fixing
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3357 : Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3362 : Generic.WhiteSpace.ScopeIndent false positive for arrow functions inside arrays
- Fixed bug #3384 : Squiz.Commenting.FileComment.SpacingAfterComment false positive on empty file
- Fixed bug #3394 : Fix PHP 8.1 auto_detect_line_endings deprecation notice
- Fixed bug #3400 : PHP 8.1: prevent deprecation notices about missing return types
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3424 : PHPCS fails when using PHP 8 Constructor property promotion with attributes
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3425 : PHP 8.1 | Runner::processChildProcs(): fix passing null to non-nullable bug
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3445 : Nullable parameter after attribute incorrectly tokenized as ternary operator
- Thanks to Juliette Reinders Folmer for the patch
3.6.0 - 2021-04-09
PHP 8 Language Feature Support
PHP_CodeSniffer has run under PHP 8 for some time, but it has not supported all new language features until this release. Version 3.6.0 adds support for all new PHP 8 language features, including:
- Attributes
- Constructor property promotion
- Named arguments
- Union types
- Match expressions
- Static and Mixed return types
Note: All standards and sniffs included with PHP_CodeSniffer have been updated to support these language features, but external standards and sniffs may need updating before they are able to detect them correctly.
Changelog
- Added support for PHP 8.0 union types
- A new
T_TYPE_UNION
token is available to represent the pipe character File::getMethodParameters()
,getMethodProperties()
, andgetMemberProperties()
will now return union types- Thanks to Juliette Reinders Folmer for the patch
- A new
- Added support for PHP 8.0 named function call arguments
- A new
T_PARAM_NAME
token is available to represent the label with the name of the function argument in it - Thanks to Juliette Reinders Folmer for the patch
- A new
- Added support for PHP 8.0 attributes
- The PHP-supplied
T_ATTRIBUTE
token marks the start of an attribute - A new
T_ATTRIBUTE_END
token is available to mark the end of an attribute - New
attribute_owner
andattribute_closer
indexes are available in the tokens array for all tokens inside an attribute - Tokenizing of attributes has been backfilled for older PHP versions
- The following sniffs have been updated to support attributes:
PEAR.Commenting.ClassComment
PEAR.Commenting.FileComment
PSR1.Files.SideEffects
PSR12.Files.FileHeader
Squiz.Commenting.ClassComment
Squiz.Commenting.FileComment
Squiz.WhiteSpace.FunctionSpacing
- Thanks to Vadim Borodavko for the patch
- Thanks to Alessandro Chitolina for the patch
- The PHP-supplied
- Added support for PHP 8.0 dereferencing of text strings with interpolated variables
- Thanks to Juliette Reinders Folmer for the patch
- Added support for PHP 8.0 match expressions
- Match expressions are now tokenised with parenthesis and scope openers and closers
- Sniffs can listen for the
T_MATCH
token to process match expressions - Note that the case and default statements inside match expressions do not have scopes set
- Sniffs can listen for the
- A new
T_MATCH_ARROW
token is available to represent the arrows in match expressions - A new
T_MATCH_DEFAULT
token is available to represent the default keyword in match expressions - All tokenizing of match expressions has been backfilled for older PHP versions
- The following sniffs have been updated to support match expressions:
Generic.CodeAnalysis.AssignmentInCondition
Generic.CodeAnalysis.EmptyPHPStatement
- Thanks to Vadim Borodavko for the patch
Generic.CodeAnalysis.EmptyStatement
Generic.PHP.LowerCaseKeyword
PEAR.ControlStructures.ControlSignature
PSR12.ControlStructures.BooleanOperatorPlacement
Squiz.Commenting.LongConditionClosingComment
Squiz.Commenting.PostStatementComment
Squiz.ControlStructures.LowercaseDeclaration
Squiz.ControlStructures.ControlSignature
Squiz.Formatting.OperatorBracket
Squiz.PHP.DisallowMultipleAssignments
Squiz.Objects.ObjectInstantiation
Squiz.WhiteSpace.ControlStructureSpacing
- Thanks to Juliette Reinders Folmer for the patch
- Match expressions are now tokenised with parenthesis and scope openers and closers
- The value of the
T_FN_ARROW
token has changed from "T_FN_ARROW" to "PHPCS_T_FN_ARROW" to avoid package conflicts- This will have no impact on custom sniffs unless they are specifically looking at the value of the
T_FN_ARROW
constant - If sniffs are just using constant to find arrow functions, they will continue to work without modification
- Thanks to Juliette Reinders Folmer for the patch
- This will have no impact on custom sniffs unless they are specifically looking at the value of the
File::findStartOfStatement()
now works correctly when passed the last token in a statementFile::getMethodParameters()
now supports PHP 8.0 constructor property promotion- Returned method params now include a
property_visibility
andvisibility_token
index if property promotion is detected - Thanks to Juliette Reinders Folmer for the patch
- Returned method params now include a
File::getMethodProperties()
now includes areturn_type_end_token
index in the return value- This indicates the last token in the return type, which is helpful when checking union types
- Thanks to Juliette Reinders Folmer for the patch
- Include patterns are now ignored when processing STDIN
- Previously, checks using include patterns were excluded when processing STDIN when no file path was provided via
--stdin-path
- Now, all include and exclude rules are ignored when no file path is provided, allowing all checks to run
- If you want include and exclude rules enforced when checking STDIN, use
--stdin-path
to set the file path - Thanks to Juliette Reinders Folmer for the patch
- Previously, checks using include patterns were excluded when processing STDIN when no file path was provided via
- Spaces are now correctly escaped in the paths to external on Windows
- Thanks to Juliette Reinders Folmer for the patch
- Added
Generic.NamingConventions.AbstractClassNamePrefix
to enforce that class names are prefixed with "Abstract"- Thanks to Anna Borzenko for the contribution
- Added
Generic.NamingConventions.InterfaceNameSuffix
to enforce that interface names are suffixed with "Interface"- Thanks to Anna Borzenko for the contribution
- Added
Generic.NamingConventions.TraitNameSuffix
to enforce that trait names are suffixed with "Trait"- Thanks to Anna Borzenko for the contribution
Generic.CodeAnalysis.UnusedFunctionParameter
can now be configured to ignore variable usage for specific type hints- This allows you to suppress warnings for some variables that are not required, but leave warnings for others
- Set the
ignoreTypeHints
array property to a list of type hints to ignore - Thanks to Petr Bugyík for the patch
Generic.Formatting.MultipleStatementAlignment
can now align statements at the start of the assignment token- Previously, the sniff enforced that the values were aligned, even if this meant the assignment tokens were not
- Now, the sniff can enforce that the assignment tokens are aligned, even if this means the values are not
- Set the
alignAtEnd
sniff property tofalse
to align the assignment tokens - The default remains at
true
, so the assigned values are aligned - Thanks to John P. Bloch for the patch
Generic.PHP.LowerCaseType
now supports checking of typed properties- Thanks to Juliette Reinders Folmer for the patch
Generic.PHP.LowerCaseType
now supports checking of union types- Thanks to Juliette Reinders Folmer for the patch
PEAR.Commenting.FunctionComment
andSquiz.Commenting.FunctionComment
sniffs can now ignore private and protected methods- Set the
minimumVisibility
sniff property toprotected
to ignore private methods - Set the
minimumVisibility
sniff property topublic
to ignore both private and protected methods - The default remains at
private
, so all methods are checked - Thanks to Vincent Langlet for the patch
- Set the
PEAR.Commenting.FunctionComment
andSquiz.Commenting.FunctionComment
sniffs can now ignore return tags in any method- Previously, only
__construct
and__destruct
were ignored - Set the list of method names to ignore in the
specialMethods
sniff property - The default remains at
__construct
and__destruct
only - Thanks to Vincent Langlet for the patch
- Previously, only
PSR2.ControlStructures.SwitchDeclaration
now supports nested switch statements where every branch terminates- Previously, if a
CASE
only contained aSWITCH
and no direct terminating statement, a fall-through error was displayed - Now, the error is suppressed if every branch of the
SWITCH
has a terminating statement - Thanks to Vincent Langlet for the patch
- Previously, if a
- The
PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket
error message is now reported on the closing parenthesis token- Previously, the error was being reported on the function keyword, leading to confusing line numbers in the error report
Squiz.Commenting.FunctionComment
is now able to ignore function comments that are only inheritdoc statements- Set the
skipIfInheritdoc
sniff property totrue
to skip checking function comments if the content is only{@inhertidoc}
- The default remains at
false
, so these comments will continue to report errors - Thanks to Jess Myrbo for the patch
- Set the
Squiz.Commenting.FunctionComment
now supports the PHP 8 mixed type- Thanks to Vadim Borodavko for the patch
Squiz.PHP.NonExecutableCode
now has improved handling of syntax errors- Thanks to Thiemo Kreuz for the patch
Squiz.WhiteSpace.ScopeKeywordSpacing
now checks spacing when using PHP 8.0 constructor property promotion- Thanks to Juliette Reinders Folmer for the patch
- Fixed an issue that could occur when checking files on network drives, such as with WSL2 on Windows 10
- This works around a long-standing PHP bug with
is_readable()
- Thanks to Michael S for the patch
- This works around a long-standing PHP bug with
- Fixed a number of false positives in the
Squiz.PHP.DisallowMultipleAssignments
sniff- Sniff no longer errors for default value assignments in arrow functions
- Sniff no longer errors for assignments on first line of closure
- Sniff no longer errors for assignments after a goto label
- Thanks to Jaroslav Hanslík for the patch
- Fixed bug #2913 : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional
- Fixed bug [#299...
3.5.8 - 2020-10-23
- Reverted a change to the way include/exclude patterns are processed for STDIN content
- This change is not backwards compatible and will be re-introduced in version 3.6.0
3.5.7 - 2020-10-23
- The PHP 8.0
T_NULLSAFE_OBJECT_OPERATOR
token has been made available for older versions- Existing sniffs that check for
T_OBJECT_OPERATOR
have been modified to apply the same rules for the nullsafe object operator - Thanks to Juliette Reinders Folmer for the patch
- Existing sniffs that check for
- The new method of PHP 8.0 tokenizing for namespaced names has been revert to the pre 8.0 method
- This maintains backwards compatible for existing sniffs on PHP 8.0
- This change will be removed in PHPCS 4.0 as the PHP 8.0 tokenizing method will be backported for pre 8.0 versions
- Thanks to Juliette Reinders Folmer for the patch
- Added support for changes to the way PHP 8.0 tokenizes hash comments
- The existing PHP 5-7 behaviour has been replicated for version 8, so no sniff changes are required
- Thanks to Juliette Reinders Folmer for the patch
- The autoloader has been changed to fix sniff class name detection issues that may occur when running on PHP 7.4+
- Thanks to Eloy Lafuente for the patch
- Running the unit tests now includes warnings in the found and fixable error code counts
- Thanks to Juliette Reinders Folmer for the patch
PSR12.ControlStructures.BooleanOperatorPlacement.FoundMixed
error message is now more accurate when using the allowOnly setting- Thanks to Vincent Langlet for the patch
PSR12.Functions.NullableTypeDeclaration
now supports the PHP8 static return type- Thanks to Juliette Reinders Folmer for the patch
- Fixed
Squiz.Formatting.OperatorBracket
false positive when exiting with a negative number - Fixed
Squiz.PHP.DisallowComparisonAssignment
false positive for methods called on an object - Fixed bug #2882 : Generic.Arrays.ArrayIndent can request close brace indent to be less than the statement indent level
- Fixed bug #2883 : Generic.WhiteSpace.ScopeIndent.Incorrect issue after NOWDOC
- Fixed bug #2975 : Undefined offset in PSR12.Functions.ReturnTypeDeclaration when checking function return type inside ternary
- Fixed bug #2988 : Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding
- Thanks to Thiemo Kreuz for the patch
- Fixed bug #2989 : Incorrect auto-fixing in Generic.ControlStructures.InlineControlStructure during live coding
- Thanks to Thiemo Kreuz for the patch
- Fixed bug #3007 : Directory exclude pattern improperly excludes directories with names that start the same
- Thanks to Steve Talbot for the patch
- Fixed bug #3043 : Squiz.WhiteSpace.OperatorSpacing false positive for negation in arrow function
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3049 : Incorrect error with arrow function and parameter passed as reference
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3053 : PSR2 incorrect fix when multiple use statements on same line do not have whitespace between them
- Fixed bug #3058 : Progress gets unaligned when 100% happens at the end of the available dots
- Fixed bug #3059 : Squiz.Arrays.ArrayDeclaration false positive when using type casting
- Thanks to Sergei Morozov for the patch
- Fixed bug #3060 : Squiz.Arrays.ArrayDeclaration false positive for static functions
- Thanks to Sergei Morozov for the patch
- Fixed bug #3065 : Should not fix Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma if comment between element and comma
- Thanks to Sergei Morozov for the patch
- Fixed bug #3066 : No support for namespace operator used in type declarations
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3075 : PSR12.ControlStructures.BooleanOperatorPlacement false positive when operator is the only content on line
- Fixed bug #3099 : Squiz.WhiteSpace.OperatorSpacing false positive when exiting with negative number
- Thanks to Sergei Morozov for the patch
- Fixed bug #3102 : PSR12.Squiz.OperatorSpacing false positive for default values of arrow functions
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #3124 : PSR-12 not reporting error for empty lines with only whitespace
- Fixed bug #3135 : Ignore annotations are broken on PHP 8.0
- Thanks to Juliette Reinders Folmer for the patch
3.5.6 - 2020-08-10
- Added support for PHP 8.0 magic constant dereferencing
- Thanks to Juliette Reinders Folmer for the patch
- Added support for changes to the way PHP 8.0 tokenizes comments
- The existing PHP 5-7 behaviour has been replicated for version 8, so no sniff changes are required
- Thanks to Juliette Reinders Folmer for the patch
File::getMethodProperties()
now detects the PHP 8.0 static return type- Thanks to Juliette Reinders Folmer for the patch
- The PHP 8.0 static return type is now supported for arrow functions
- Thanks to Juliette Reinders Folmer for the patch
- The cache is no longer used if the list of loaded PHP extensions changes
- Thanks to Juliette Reinders Folmer for the patch
Generic.NamingConventions.CamelCapsFunctionName
no longer reports__serialize
and__unserialize
as invalid names- Thanks to Filip Š for the patch
PEAR.NamingConventions.ValidFunctionName
no longer reports__serialize
and__unserialize
as invalid names- Thanks to Filip Š for the patch
Squiz.Scope.StaticThisUsage
now detects usage of$this
inside closures and arrow functions- Thanks to Michał Bundyra for the patch
- Fixed bug #2877 : PEAR.Functions.FunctionCallSignature false positive for array of functions
- Thanks to Vincent Langlet for the patch
- Fixed bug #2888 : PSR12.Files.FileHeader blank line error with multiple namespaces in one file
- Fixed bug #2926 : phpcs hangs when using arrow functions that return heredoc
- Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed
- Fixed bug #2967 : Markdown generator does not output headings correctly
- Thanks to Petr Bugyík for the patch
- Fixed bug #2977 : File::isReference() does not detect return by reference for closures
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2994 : Generic.Formatting.DisallowMultipleStatements false positive for FOR loop with no body
- Fixed bug #3033 : Error generated during tokenizing of goto statements on PHP 8
- Thanks to Juliette Reinders Folmer for the patch
3.5.5 - 2020-04-17
- The
T_FN
backfill now works more reliably soT_FN
tokens only ever represent real arrow functions- Thanks to Juliette Reinders Folmer for the patch
- Fixed an issue where including sniffs using paths containing multiple dots would silently fail
Generic.CodeAnalysis.EmptyPHPStatement
now detects empty statements at the start of control structures- Error wording in
PEAR.Functions.FunctionCallSignature
now always uses "parenthesis" instead of sometimes using "bracket"- Thanks to Vincent Langlet for the patch
- Fixed bug #2787 : Squiz.PHP.DisallowMultipleAssignments not ignoring typed property declarations
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2810 : PHPCBF fails to fix file with empty statement at start on control structure
- Fixed bug #2812 : Squiz.Arrays.ArrayDeclaration not detecting some arrays with multiple arguments on the same line
- Thanks to Jakub Chábek for the patch
- Fixed bug #2826 : Generic.WhiteSpace.ArbitraryParenthesesSpacing doesn't detect issues for statements directly after a control structure
- Thanks to Vincent Langlet for the patch
- Fixed bug #2848 : PSR12.Files.FileHeader false positive for file with mixed PHP and HTML and no file header
- Fixed bug #2849 : Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array
- Fixed bug #2850 : Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase
- Fixed bug #2853 : Undefined variable error when using Info report
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2865 : Double arrow tokenized as T_STRING when placed after function named "fn"
- Fixed bug #2867 : Incorrect scope matching when arrow function used inside IF condition
- Fixed bug #2868 : phpcs:ignore annotation doesnt work inside a docblock
- Fixed bug #2878 : PSR12.Files.FileHeader conflicts with Generic.Files.LineEndings
- Fixed bug #2895 : PSR2.Methods.FunctionCallSignature.MultipleArguments false positive with arrow function argument
3.5.4 - 2020-01-30
- The PHP 7.4 numeric separator backfill now works correctly for more float formats
- Thanks to Juliette Reinders Folmer for the patch
- The PHP 7.4 numeric separator backfill is no longer run on PHP version 7.4.0 or greater
File::getCondition()
now accepts a 3rd argument that allows for the closest matching token to be returned- By default, it continues to return the first matched token found from the top of the file
- Fixed detection of array return types for arrow functions
- Added
Generic.PHP.DisallowRequestSuperglobal
to ban the use of the$_REQUEST
superglobal- Thanks to Morerice for the contribution
Generic.ControlStructures.InlineControlStructure
no longer shows errors forwhile
andfor
statements without a body- Previously it required these to have curly braces, but there were no statements to enclose in them
- Thanks to Juliette Reinders Folmer for the patch
PSR12.ControlStructures.BooleanOperatorPlacement
can now be configured to enforce a specific operator position- By default, the sniff ensures that operators are all at the beginning or end of lines, but not a mix of both
- Set the
allowOnly
property tofirst
to enforce all boolean operators to be at the start of a line - Set the
allowOnly
property tolast
to enforce all boolean operators to be at the end of a line - Thanks to Vincent Langlet for the patch
PSR12.Files.ImportStatement
now auto-fixes import statements by removing the leading slash- Thanks to Michał Bundyra for the patch
Squiz.ControlStructures.ForLoopDeclaration
now has a setting to ignore newline characters- Default remains
FALSE
, so newlines are not allowed withinfor
definitions - Override the
ignoreNewlines
setting in aruleset.xml
file to change
- Default remains
Squiz.PHP.InnerFunctions
now handles multiple nested anon classes correctly- Fixed bug #2497 : Sniff properties not set when referencing a sniff using relative paths or non-native slashes
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2657 : Squiz.WhiteSpace.FunctionSpacing can remove spaces between comment and first/last method during auto-fixing
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2688 : Case statements not tokenized correctly when switch is contained within ternary
- Fixed bug #2698 : PHPCS throws errors determining auto report width when shell_exec is disabled
- Thanks to Matthew Peveler for the patch
- Fixed bug #2730 : PSR12.ControlStructures.ControlStructureSpacing does not ignore comments between conditions
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2732 : PSR12.Files.FileHeader misidentifies file header in mixed content file
- Fixed bug #2745 : AbstractArraySniff wrong indices when mixed coalesce and ternary values
- Thanks to Michał Bundyra for the patch
- Fixed bug #2748 : Wrong end of statement for fn closures
- Thanks to Michał Bundyra for the patch
- Fixed bug #2751 : Autoload relative paths first to avoid confusion with files from the global include path
- Thanks to Klaus Purer for the patch
- Fixed bug #2763 : PSR12 standard reports errors for multi-line FOR definitions
- Fixed bug #2768 : Generic.Files.LineLength false positive for non-breakable strings at exactly the soft limit
- Thanks to Alex Miles for the patch
- Fixed bug #2773 : PSR2.Methods.FunctionCallSignature false positive when arrow function has array return type
- Fixed bug #2790 : PSR12.Traits.UseDeclaration ignores block comments
- Thanks to Vincent Langlet for the patch
- Fixed bug #2791 : PSR12.Functions.NullableTypeDeclaration false positive when ternary operator used with instanceof
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2802 : Can't specify a report file path using the tilde shortcut
- Fixed bug #2804 : PHP4-style typed properties not tokenized correctly
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2805 : Undefined Offset notice during live coding of arrow functions
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2843 : Tokenizer does not support alternative syntax for declare statements
- Thanks to Juliette Reinders Folmer for the patch
3.5.3 - 2019-12-04
- The PHP 7.4
T_FN
token has been made available for older versionsT_FN
represents thefn
string used for arrow functions- The double arrow becomes the scope opener, and uses a new
T_FN_ARROW
token type - The token after the statement (normally a semicolon) becomes the scope closer
- The token is also associated with the opening and closing parenthesis of the statement
- Any functions named
fn
will have aT_FN token
for the function name, but have no scope information - Thanks to Michał Bundyra for the help with this change
- PHP 7.4 numeric separators are now tokenized in the same way when using older PHP versions
- Previously, a number like
1_000
would tokenize asT_LNUMBER (1), T_STRING (_000)
- Now, the number tokenizes as
T_LNUMBER (1_000)
- Sniff developers should consider how numbers with underscores impact their custom sniffs
- Previously, a number like
- The PHPCS file cache now takes file permissions into account
- The cache is now invalidated for a file when its permissions are changed
File::getMethodParameters()
now supports arrow functionsFile::getMethodProperties()
now supports arrow functions- Added
Fixer::changeCodeBlockIndent()
to change the indent of a code block while auto-fixing- Can be used to either increase or decrease the indent
- Useful when moving the start position of something like a closure, where you want the content to also move
- Added
Generic.Files.ExecutableFile
sniff- Ensures that files are not executable
- Thanks to Matthew Peveler for the contribution
Generic.CodeAnalysis.EmptyPhpStatement
now reports unnecessary semicolons after control structure closing braces- Thanks to Vincent Langlet for the patch
Generic.PHP.LowerCaseKeyword
now enforces that thefn
keyword is lowercase- Thanks to Michał Bundyra for the patch
Generic.WhiteSpace.ScopeIndent
now supports static arrow functionsPEAR.Functions.FunctionCallSignature
now adjusts the indent of function argument contents during auto-fixing- Previously, only the first line of an argument was changed, leading to inconsistent indents
- This change also applies to
PSR2.Methods.FunctionCallSignature
PSR2.ControlStructures.ControlStructureSpacing
now checks whitespace before the closing parenthesis of multi-line control structures- Previously, it incorrectly applied the whitespace check for single-line definitions only
PSR12.Functions.ReturnTypeDeclaration
now checks the return type of arrow functions- Thanks to Michał Bundyra for the patch
PSR12.Traits.UseDeclaration
now ensures all trait import statements are grouped together- Previously, the trait import section of the class ended when the first non-import statement was found
- Checking now continues throughout the class to ensure all statements are grouped together
- This also ensures that empty lines are not requested after an import statement that isn't the last one
Squiz.Functions.LowercaseFunctionKeywords
now enforces that thefn
keyword is lowercase- Thanks to Michał Bundyra for the patch
- Fixed bug #2586 : Generic.WhiteSpace.ScopeIndent false positives when indenting open tags at a non tab-stop
- Fixed bug #2638 : Squiz.CSS.DuplicateClassDefinitionSniff sees comments as part of the class name
- Thanks to Raphael Horber for the patch
- Fixed bug #2640 : Squiz.WhiteSpace.OperatorSpacing false positives for some negation operators
- Thanks to Jakub Chábek and Juliette Reinders Folmer for the patch
- Fixed bug #2674 : Squiz.Functions.FunctionDeclarationArgumentSpacing prints wrong argument name in error message
- Fixed bug #2676 : PSR12.Files.FileHeader locks up when file ends with multiple inline comments
- Fixed bug #2678 : PSR12.Classes.AnonClassDeclaration incorrectly enforcing that closing brace be on a line by itself
- Fixed bug #2685 : File::getMethodParameters() setting typeHintEndToken for vars with no type hint
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2694 : AbstractArraySniff produces invalid indices when using ternary operator
- Thanks to Michał Bundyra for the patch
- Fixed bug #2702 : Generic.WhiteSpace.ScopeIndent false positive when using ternary operator with short arrays
3.5.2 - 2019-10-28
- Generic.ControlStructures.DisallowYodaConditions now returns less false positives
- False positives were being returned for array comparisions, or when performing some function calls
- Squiz.WhiteSpace.SemicolonSpacing.Incorrect error message now escapes newlines and tabs
- Provides a clearer error message as whitespace is now visible
- Also allows for better output for report types such as CSV and XML
- The error message for PSR12.Files.FileHeader.SpacingAfterBlock has been made clearer
- It now uses the wording from the published PSR-12 standard to indicate that blocks must be separated by a blank line
- Thanks to Craig Duncan for the patch
- Fixed bug #2654 : Incorrect indentation for arguments of multiline function calls
- Fixed bug #2656 : Squiz.WhiteSpace.MemberVarSpacing removes comments before first member var during auto fixing
- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #2663 : Generic.NamingConventions.ConstructorName complains about old constructor in interfaces
- Fixed bug #2664 : PSR12.Files.OpenTag incorrectly identifies PHP file with only an opening tag
- Fixed bug #2665 : PSR12.Files.ImportStatement should not apply to traits
- Fixed bug #2673 : PSR12.Traits.UseDeclaration does not allow comments or blank lines between use statements
3.5.1 - 2019-10-16
- Very very verbose diff report output has slightly changed to improve readability
- Output is printed when running PHPCS with the
--report=diff
and-vvv
command line arguments - Fully qualified class names have been replaced with sniff codes
- Tokens being changed now display the line number they are on
- Output is printed when running PHPCS with the
- PSR2, PSR12, and PEAR standards now correctly check for blank lines at the start of function calls
- This check has been missing from these standards, but has now been implemented
- When using the PEAR standard, the error code is
PEAR.Functions.FunctionCallSignature.FirstArgumentPosition
- When using PSR2 or PSR12, the error code is
PSR2.Methods.FunctionCallSignature.FirstArgumentPosition
PSR12.ControlStructures.BooleanOperatorPlacement
no longer complains when multiple expressions appear on the same line- Previously, boolean operators were enforced to appear at the start or end of lines only
- Boolean operators can now appear in the middle of the line
PSR12.Files.FileHeader
no longer ignores comments preceding ause
,namespace
, ordeclare
statementPSR12.Files.FileHeader
now allows a hashbang line at the top of the file- Fixed bug #2506 : PSR2 standard can't auto fix multi-line function call inside a string concat statement
- Fixed bug #2530 : PEAR.Commenting.FunctionComment does not support intersection types in comments
- Fixed bug #2615 : Constant visibility false positive on non-class constants
- Fixed bug #2616 : PSR12.Files.FileHeader false positive when file only contains docblock
- Fixed bug #2619 : PSR12.Files.FileHeader locks up when inline comment is the last content in a file
- Fixed bug #2621 : PSR12.Classes.AnonClassDeclaration.CloseBraceSameLine false positive for anon class passed as function argument
- Thanks to Martins Sipenko for the patch
- Fixed bug #2623 : PSR12.ControlStructures.ControlStructureSpacing not ignoring indentation inside multi-line string arguments
- Fixed bug #2624 : PSR12.Traits.UseDeclaration doesnt apply the correct indent during auto fixing
- Fixed bug #2626 : PSR12.Files.FileHeader detects
@var
annotations as file docblocks - Fixed bug #2628 : PSR12.Traits.UseDeclaration does not allow comments above a USE declaration
- Fixed bug #2632 : Incorrect indentation of lines starting with "static" inside closures
- Fixed bug #2641 : PSR12.Functions.NullableTypeDeclaration false positive when using new static()