squizlabs/php_codesniffer
PHP_CodeSniffer (PHPCS) provides phpcs to detect coding standard violations and phpcbf to automatically fix them. Tokenizes PHP files against defined standards to keep code clean and consistent, suitable for teams and CI.
This release includes all improvements and bugfixes from PHP_CodeSniffer 3.13.5.
phpcs:ignore comma-separated rule reference lists.
phpcs:disable/phpcs:enable ignore annotations.switch.
case/default and "case breaking" statements.switch case condition or after a default keyword, was not regarded as a "scope_opener" for the case/default body.WrongOpener error is now also auto-fixable if the wrong opener is a PHP close tag.The PHP_CodeSniffer project is happy to welcome the following new contributors: @andrewnicols, @Soh1121
Closed: 2 issues Merged: 8 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
master branch has been renamed to 3.x and the default branch has changed to the 4.x branch.
The PHP_CodeSniffer project is happy to welcome the following new contributors: @andrewnicols
Closed: 2 issues Merged: 36 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
This release contains breaking changes.
Upgrade guides for both ruleset maintainers/end-users, as well as for sniff developers and integrators, have been published to the Wiki.
You are strongly encouraged to read the upgrade guide applicable to your situation before upgrading.
This release includes all improvements and bugfixes from PHP_CodeSniffer 4.0.0-beta1, 4.0.0-RC1, 3.13.3 and 3.13.4.
exit/die/true/false/null will be tokenized as the keyword token and the token 'content' will include the leading backslash. #1201^8.4.0 || ^9.3.4 || ^10.5.32 || 11.3.3 - 11.5.28 || ^11.5.31. #1247
phpcbf on code provided via STDIN.
// phpcs:set for inline array properties did not handle a single item array with the value true, false or null correctly.phpcbf in parallel mode.master branch has been renamed to 3.x and the default branch has changed to the 4.x branch.
Closed: 5 issues Merged: 35 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
Closed: 0 issues Merged: 3 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://x.com/PHP_CodeSniffer).
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
abstract properties. #1183
File::getMemberProperties() method now also supports abstract properties through a new is_abstract array index in the return value. #1184abstract properties:
exit/die is used as a fully qualified "function call", it will now be tokenized as T_NS_SEPARATOR + T_EXIT.true/false/null will now be tokenized as T_NS_SEPARATOR + T_TRUE/T_FALSE/T_NULL. #1201
T_NS_SEPARATOR + T_STRING.WrongOpener* error code is now auto-fixable if the identified "wrong opener" is a semi-colon. #1161
AbstractAfterVisibility error code.--parallel option fails if PHP_CodeSniffer is invoked via bash and the invokation creates a non-PHPCS-managed process.
--parallel scanning was enabled.The PHP_CodeSniffer project is happy to welcome the following new contributors: @benno5020, @NanoSector
Closed: 11 issues Merged: 40 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
This release includes all improvements and bugfixes from PHP_CodeSniffer 4.0.0-beta1, 3.13.1 and 3.13.2.
Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterVisbility has been changed to Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterVisibility. #1136phpcs:enable could sometimes override a later selective phpcs:ignore.
Calling all testers!
Please help by testing the RC release and reporting any issues you run into. Upgrade guides for both ruleset maintainers/end-users, as well as for sniff developers and integrators, have been published to the Wiki to help smooth the transition.
Closed: 2 issues Merged: 4 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
SpacingAfterSetVis[i]bility.
Closed: 0 issues Merged: 6 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
set_scope array index in the return value. #1116
set_visibility and set_visibility_token array indexes in the return value. #1116
AvizKeywordOrder error code.SpacingAfterSetVisibility error code.AsymReadMissing. #1122
https://schema.phpcodesniffer.com/#.#/phpcs.xsd.Closed: 3 issues Merged: 24 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
extend="true" on an property tag for setting an array value could already extend a property value set elsewhere in an (inluded) ruleset.Tokens::NAME_TOKENS containing an array with the tokens used for identifier names. #3041Generic.WhiteSpace.GotoTargetSpacing to enforce no space between the label of a goto target and the colon following it. #1026-d option[=value] or via the ruleset with <ini name=...>. #416
PEAR to PSR12.phpcs as well as phpcbf will now exit with exit code 0 if no issues were found/remain after fixing. #184
ignore_non_auto_fixable_on_exit config flag to 1.--report-file functionality remains untouched.--extensions command line argument no longer accepts the tokenizer along with the extension. #2448
.module files as PHP files using --extensions=module/php.--extensions=module.<config> directives will be applied based on the nesting level of the ruleset. #2197
<config> directive set in an included ruleset from the "root" ruleset.<config> directives set in the "root" ruleset will always "win" over directives in included rulesets.<arg> directives will be applied based on the nesting level of the ruleset. #2395, #2597, #2602
<arg> directive set in an included ruleset from the "root" ruleset.<arg> directives set in the "root" ruleset will always "win" over directives in included rulesets.--sniffs CLI argument is used. #98File::getDeclarationName() method will no longer accept T_ANON_CLASS or T_CLOSURE tokens. #3766
RuntimeException will be thrown if these tokens are passed.File::getDeclarationName() method will now always return a string (or throw an Exception). #1007
null if the name could not be determined, like during live coding.
Now it will return an empty string in those situations.File::getMemberProperties() method will no longer add warnings about possible parse errors. #2455
Internal.ParseError.InterfaceHasMemberVar and the Internal.ParseError.EnumHasMemberVar error codes have been removed.RuntimeException for properties declared in enums (parse error).Generic.PHP.Syntax sniff or a dedicated linter instead.Squiz.Classes.ValidClassName.NotCamelCaps has been changed to Squiz.Classes.ValidClassName.NotPascalCase. #2046
ClassName and not className.Squiz.PHP.Heredoc.NotAllowed has been replaced by Squiz.PHP.Heredoc.HeredocNotAllowed and Squiz.PHP.Heredoc.NowdocNotAllowed. #2318
PSR12.Files.FileHeader sniff now has more modular error codes to allow for more selectively applying the rules. #2729 #3453
PSR12.Files.FileHeader.SpacingAfterBlock error code is replaced by:
PSR12.Files.FileHeader.SpacingAfterTagBlockPSR12.Files.FileHeader.SpacingAfterDocblockBlockPSR12.Files.FileHeader.SpacingAfterDeclareBlockPSR12.Files.FileHeader.SpacingAfterNamespaceBlockPSR12.Files.FileHeader.SpacingAfterUseBlockPSR12.Files.FileHeader.SpacingAfterUseFunctionBlockPSR12.Files.FileHeader.SpacingAfterUseConstBlockPSR12.Files.FileHeader.SpacingInsideBlock error code is replaced by:
PSR12.Files.FileHeader.SpacingInsideUseBlockPSR12.Files.FileHeader.SpacingInsideUseFunctionBlockPSR12.Files.FileHeader.SpacingInsideUseConstBlockSquiz.Commenting.VariableComment.TagNotAllowed has been replaced by a dynamic Squiz.Commenting.VariableComment.[TagName]TagNotAllowed error code. #1039
[@link](https://github.com/link) tags in property docblocks, exclude the Squiz.Commenting.VariableComment.LinkTagNotAllowed error code.T_STRING and T_NS_SEPARATOR.T_NAME_FULLY_QUALIFIED, T_NAME_RELATIVE, and T_NAME_QUALIFIED instead.T_STRING and T_NS_SEPARATOR tokens to look for namespaced names will need to be modified.Tokens::FUNCTION_NAME_TOKENS/Tokens::$functionNameTokens array now includes the identifier name tokens.parenthesis_owner, parenthesis_opener and parenthesis_closer array indexes.static keyword when preceded by instanceof will now be tokenized (again) as T_STATIC. #22
T_STRING.T_OPEN_TAG tokens will no longer contain any whitespace. #593
T_WHITESPACE token.T_GOTO_LABEL tokens will no longer include the colon following it. #185
T_GOTO_COLON.goto statement will now be tokenized as T_STRING to prevent confusing sniffs. #185T_DOC_COMMENT_* tokens now have the comment_opener and comment_closer indexes set. #484Tokens::FUNCTION_NAME_TOKENS/Tokens::$functionNameTokens array now includes the T_ANON_CLASS token. #47true and false will now always be set to a boolean value, independently of the case in which the value was provided.null will now be set to an actual null value. Previously, the sniff property would have been set to string 'null'.PHP_CodeSniffer\Config::setConfigData() method is no longer static. #2675
private) Config::$overriddenDefaults property is also no longer static.PHP_CodeSniffer\Config::setSettings() method is now a void method. #1001DummyFile::setErrorCounts() method has changed and now expects the following parameters: $errorCount, $warningCount, $fixableErrorCount, $fixableWarningCount, $fixedErrorCount, $fixedWarningCount. #1079Generator classes will now throw a PHP_CodeSniffer\Exceptions\GeneratorException when encountering errors in the documentation XML. #1072PHP_CodeSniffer\Generators\HTML::STYLESHEET, PHP_CodeSniffer\Util\Timing::MINUTE_IN_MS and PHP_CodeSniffer\Util\Timing::SECOND_IN_MS class constants are no longer public. #1051PHP_CodeSniffer\Util\Timing class is now final and marked as an internal class. #1074PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest with PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase.PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest with PHP_CodeSniffer\Tests\Core\AbstractMethodTestCase.AbstractSniffTestCase for which no test case files (.inc files) can be found, will now be marked as "incomplete". #998
inc) which would be changed by the sniff under test if running the fixer, are now required to be accompanied by a *.fixed file. #300Tokens class. Use the corresponding class constants on the Tokens class instead. #500PHP_CodeSniffer\Util\Common::$allowedTypes. Use PHP_CodeSniffer\Util\Common::ALLOWED_TYPES instead. #1043PHP_CodeSniffer\Tokenizers\PHP::$tstringContexts. Use PHP_CodeSniffer\Tokenizers\PHP::T_STRING_CONTEXTS instead. #1043PHP_CodeSniffer\Sniffs\AbstractVariableSniff::$phpReservedVars. Use PHP_CodeSniffer\Sniffs\AbstractVariableSniff::PHP_RESERVED_VARS instead. #1043PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff::$magicMethods. Use PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff::MAGIC_METHODS instead. #1043
PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff class which extends the CamelCapsFunctionNameSniff.PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff::$methodsDoubleUnderscore. Use PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff::DOUBLE_UNDERSCORE_METHODS instead. #1043
PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff class which extends the CamelCapsFunctionNameSniff.PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff::$magicFunctions. Use PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff::MAGIC_FUNCTIONS instead. #1043
PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff class which extends the CamelCapsFunctionNameSniff.PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ByteOrderMarkSniff::$bomDefinitions. Use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ByteOrderMarkSniff::BOM_DEFINITIONS instead. #1043PHP_CodeSniffer\Standards\Generic\Sniffs\Files\InlineHTMLSniff::$bomDefinitions. Use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\InlineHTMLSniff::BOM_DEFINITIONS instead. #1043PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\CharacterBeforePHPOpeningTagSniff::$bomDefinitions. Use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\CharacterBeforePHPOpeningTagSniff::BOM_DEFINITIONS instead. #1043PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\SubversionPropertiesSniff::$properties. Use PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\SubversionPropertiesSniff::REQUIRED_PROPERTIES instead. #1043PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\FileCommentSniff::$tags. Use PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\FileCommentSniff::EXPECTED_TAGS instead. #1043
PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\ClassCommentSniff class which extends the FileCommentSniff.PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff::$magicMethods. Use PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff::MAGIC_METHODS instead. #1043
PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidFunctionNameSniff class which extends the PEAR ValidFunctionNameSniff.PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff::$magicFunctions. Use PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff::MAGIC_FUNCTIONS instead. #1043
PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidFunctionNameSniff class which extends the PEAR ValidFunctionNameSniff.PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowSizeFunctionsInLoopsSniff::$forbiddenFunctions. Use PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowSizeFunctionsInLoopsSniff::FORBIDDEN_FUNCTIONS instead. #1043PHP_CodeSniffer\Util\Standards::printInstalledStandards(). Use echo PHP_CodeSniffer\Util\Standards::prepareInstalledStandardsForDisplay() instead. #1054PHP_CodeSniffer\Config::printConfigData(). Use echo PHP_CodeSniffer\Config::prepareConfigDataForDisplay() instead. #1055Reporter::$totalFixable and Reporter::$totalFixed properties. #1079
(Reporter::$totalFixableErrors + Reporter::$totalFixableWarnings) and (Reporter::$totalFixedErrors + Reporter::$totalFixedWarnings) instead.PHP_CodeSniffer\Sniffs\Sniff interface. See #694.[@codingStandard](https://github.com/codingStandard) annotation syntax has been removed. #1954
phpcs: or [@phpcs](https://github.com/phpcs): syntax instead
[@codingStandardsIgnoreFile](https://github.com/codingStandardsIgnoreFile) with phpcs:ignoreFile[@codingStandardsIgnoreStart](https://github.com/codingStandardsIgnoreStart) with phpcs:disable[@codingStandardsIgnoreEnd](https://github.com/codingStandardsIgnoreEnd) with phpcs:enable[@codingStandardsIgnoreLine](https://github.com/codingStandardsIgnoreLine) with phpcs:ignore[@codingStandardsChangeSetting](https://github.com/codingStandardsChangeSetting) with phpcs:setruleset.xml array property string-based syntax has been removed. #1983
print=>echo,create_function=>nullelement tag with key and value attributes
<element key="print" value="echo">T_ARRAY_HINT token. #1997T_RETURN_TYPE token. #1997Generic.Debug.ClosureLinter sniff. #2448Generic.Debug.CSSLint sniff. #2448Generic.Debug.ESLint sniff. #2448Generic.Debug.JSHint sniff. #2448Generic.Formatting.NoSpaceAfterCast sniff. #2234
Generic.Formatting.SpaceAfterCast sniff instead with the $spacing property set to 0.Generic.Functions.CallTimePassByReference sniff. #921MySource standard, and all sniffs within. #2471Squiz.Classes.DuplicateProperty sniff. #2448Squiz.CSS category, and all sniffs within. #2448Squiz.Debug.JavaScriptLint sniff. #2448Squiz.Debug.JSLint sniff. #2448Squiz.Objects.DisallowObjectStringIndex sniff. #2448Squiz.Objects.ObjectMemberComment sniff. #2448Squiz.WhiteSpace.LanguageConstructSpacing sniff. #1953
Generic.WhiteSpace.LanguageConstructSpacing sniff instead.Squiz.WhiteSpace.PropertyLabelSpacing sniff. #2448Zend.Debug.CodeAnalyzer sniff. #58error property of sniff Generic.Strings.UnnecessaryStringConcat. See #2823
ruleset.xml or [.]phpcs.xml[.dist] file:
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<type>warning</type>
</rule>
error property of sniff Generic.Formatting.MultipleStatementAlignment. See #2823
Generic.Formatting.MultipleStatementAlignment.IncorrectWarning error code has been removed.
Generic.Formatting.MultipleStatementAlignment.Incorrect error code instead.Generic.Formatting.MultipleStatementAlignment.NotSameWarning error code has been removed.
Generic.Formatting.MultipleStatementAlignment.NotSame error code instead.ruleset.xml or [.]phpcs.xml[.dist] file:
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<type>error</type>
</rule>
$ignoreComments parameter for the AbstractPatternSniff::__construct() method.$settings parameter format. #3629auto_detect_line_endings ini setting. #3394
\r line endings.PHP_CodeSniffer\Filters\ExactMatch::getBlacklist() and PHP_CodeSniffer\Filters\ExactMatch::getWhitelist() methods. See #199.
ExactMatch::getDisallowedFiles() and ExactMatch::getAllowedFiles() methods.PHP_CodeSniffer\Generators\[HTML|Markdown|Text]::print*() methods. See #755.PHP_CodeSniffer\Reporter::$startTime property. #1064T_STRING if there was whitespace and/or comments between the label and colon.parenthesis_* keys.Calling all testers!
Please help by testing the beta release and reporting any issues you run into. Upgrade guides for both ruleset maintainers/end-users, as well as for sniff developers and integrators, have been published to the Wiki to help smooth the transition.
All patches courtesy of Greg Sherwood (@gsherwood) and Juliette Reinders Folmer (@jrfnl).
Special thanks go out to Dan Wallis (@fredden) and Rodrigo Primo (@rodrigoprimo) for their reviews and feedback.
Closed: 51 issues Merged: 95 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
final properties to the following sniffs:
goto language construct keyword. #917
final modifier keyword is placed before a visibility keyword. #950
FinalAfterVisibility error code.--reports CLI flag. #1078
PHP_CodeSniffer\Sniffs\Sniff interface. #891-q (=quiet) CLI flag.Calling all testers!
The first beta release for PHP_CodeSniffer 4.0 has been tagged. Please help by testing the beta release and reporting any issues you run into. Upgrade guides for both ruleset maintainers/end-users, as well as for sniff developers and integrators, have been published to the Wiki to help smooth the transition.
Closed: 3 issues Merged: 29 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
final properties to the following sniffs:
short_open_tag setting.[@param](https://github.com/param) tags.
final classes.
Diff + the Code reports are requested and caching is on.
The PHP_CodeSniffer project is happy to welcome the following new contributors: @devfrey
Closed: 1 issues Merged: 36 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
Generic.Functions.CallTimePassByReference sniff. See #921.
InvalidArgumentExceptions when displaying verbose information.
? in nullable types for readonly properties.
goto was not recognized as a terminating statement for a case/default in a switch control structure.
The PHP_CodeSniffer project is happy to welcome the following new contributors: @costdev
Closed: 0 issues Merged: 24 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
is_final array index in the return value. #834
-h (Help) option now contains a more extensive list of "config" options which can be set. #809
--sniffs or --exclude command line arguments. #344
--generator command line argument. #709, #771
title attribute is missing, the documentation generation will now fall back to the sniff name as the title. #820
SpacingBeforePropertyModifier or NoSpaceBeforePropertyModifier error codes. #792
SpacingBeforeHint or NoSpaceBeforeHint error code, which was misleading.final and abstract modifier keywords. #604
Internal.PropertyDoesNotExist error code.All deprecation are slated for removal in PHP_CodeSniffer 4.0.
Sniff interface. See #694.
PHP_CodeSniffer\Generators\Text::printTitle() in favour of PHP_CodeSniffer\Generators\Text::getFormattedTitle()PHP_CodeSniffer\Generators\Text::printTextBlock() in favour of PHP_CodeSniffer\Generators\Text::getFormattedTextBlock()PHP_CodeSniffer\Generators\Text::printCodeComparisonBlock() in favour of PHP_CodeSniffer\Generators\Text::getFormattedCodeComparisonBlock()PHP_CodeSniffer\Generators\Markdown::printHeader() in favour of PHP_CodeSniffer\Generators\Markdown::getFormattedHeader()PHP_CodeSniffer\Generators\Markdown::printFooter() in favour of PHP_CodeSniffer\Generators\Markdown::getFormattedFooter()PHP_CodeSniffer\Generators\Markdown::printTextBlock() in favour of PHP_CodeSniffer\Generators\Markdown::getFormattedTextBlock()PHP_CodeSniffer\Generators\Markdown::printCodeComparisonBlock() in favour of PHP_CodeSniffer\Generators\Markdown::getFormattedCodeComparisonBlock()PHP_CodeSniffer\Generators\HTML::printHeader() in favour of PHP_CodeSniffer\Generators\HTML::getFormattedHeader()PHP_CodeSniffer\Generators\HTML::printToc() in favour of PHP_CodeSniffer\Generators\HTML::getFormattedToc()PHP_CodeSniffer\Generators\HTML::printFooter() in favour of PHP_CodeSniffer\Generators\HTML::getFormattedFooter()PHP_CodeSniffer\Generators\HTML::printTextBlock() in favour of PHP_CodeSniffer\Generators\HTML::getFormattedTextBlock()PHP_CodeSniffer\Generators\HTML::printCodeComparisonBlock() in favour of PHP_CodeSniffer\Generators\HTML::getFormattedCodeComparisonBlock()readonly properties.
[0 => ''].The PHP_CodeSniffer project is happy to welcome the following new contributors: @asispts, @braindawg, @DanielEScherzer, @peterwilsoncc
Closed: 5 issues Merged: 74 pull requests
Follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer) to stay informed.
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
SpaceBeforeComma error. #783
equalsSpacing was set to 0.
equalsSpacing was set to 1.
Closed: 0 issues Merged: 14 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer).
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
<standard> blocks. #723
<standard> blocks. #737
define().
DEFINE is encountered.
define.
define.
Closed: 2 issues Merged: 52 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer).
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
--generator=... feature will respect the OS-expected EOL char in more places. #671
The PHP_CodeSniffer project is happy to welcome the following new contributors: @MatmaRex
Closed: 1 issue Merged: 11 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer).
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
Generic.WhiteSpace.HereNowdocIdentifierSpacing sniff. #586, #637
<<< and the identifier string in heredoc/nowdoc start tokens.Generic.Strings.UnnecessaryHeredoc sniff. #633
$sniffClass is passed. #524, #625
--generator=... feature will now always be presented in natural order based on the sniff name(s). #668
AnnotationFound. #560, #627
SpacingAfterOpen error code has been replaced by the SpaceAfterOpen error code. The latter is a pre-existing code. The former appears to have been a typo. #582
Closed: 4 issues Merged: 42 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer).
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
gh attestation verify [phpcs|phpcbf].phar -o PHPCSStandards. #574
The PHP_CodeSniffer project is happy to welcome the following new contributors: @maryo
Closed: 4 issues Merged: 19 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer).
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
Reports::generateFileReport() method is now documented in the Reports interface. #523
TabsUsedHeredocCloser - to allow for selectively excluding the indentation check for heredoc/nowdoc closers.SpacesUsedHeredocCloser.The PHP_CodeSniffer project is happy to welcome the following new contributor: @biinari (with a whopping 9 merged PRs!)
We also welcome @klausi back to the project.
Furthermore, the project is happy to welcome @jetbrains as a corporate funder for the project, joining @automattic, @humanmade and @godaddy.
Closed: 2 issues Merged: 30 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer).
[@biinari]: https://github.com/biinari [@fredden]: https://github.com/fredden [@jrfnl]: https://github.com/jrfnl [@klausi]: https://github.com/klausi [@rodrigoprimo]: https://github.com/rodrigoprimo
File::findStartOfStatement(): the start of statement/expression determination for tokens in parentheses/short array brackets/others scopes, nested within match expressions, was incorrect in most cases.
The trickle down effect of the bug fixes made to the File::findStartOfStatement() method, is that the Generic.WhiteSpace.ScopeIndent and the PEAR.WhiteSpace.ScopeIndent sniffs should now be able to correctly determine and fix the indent for match expressions containing nested expressions.
These fixes also fix an issue with the Squiz.Arrays.ArrayDeclaration sniff and possibly other, unreported bugs.
Closed: 5 issues Merged: 7 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer).
Full Changelog: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.10.0...3.10.1
T_TYPE_OPEN_PARENTHESIS and T_TYPE_CLOSE_PARENTHESIS tokens to represent the parentheses in DNF types.parenthesis_opener and parenthesis_closer token array indexes set and the tokens between them will have the nested_parenthesis index.File::getMethodProperties(), File::getMethodParameters() and File::getMemberProperties() methods now all support DNF types. #471, #472, #473else and if correctly.
The PHP_CodeSniffer project is happy to welcome the following new contributors: @przemekhernik
Closed: 2 issues Merged: 26 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer).
Please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
Full Changelog: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.9.2...3.10.0
true or false; or contained true or false as part of a union type.
Generic.Debug.ESLint sniff only supports the "old" configuration file formats and when using the sniff to run ESLint, the ESLINT_USE_FLAT_CONFIG=false environment variable will need to be set when using ESLint >= 9.0.
For more information, see #436.Closed: 0 issues Merged: 22 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer).
If you like what you see, please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
The PHP_CodeSniffer project is happy to welcome the following new contributors: @jaymcp @jpoliveira08
Closed: 2 issues Merged: 52 pull requests
If you like to stay informed about releases and more, follow [@phpcs on Mastodon](https://phpc.social/@phpcs) or [@PHP_CodeSniffer on X](https://twitter.com/PHP_CodeSniffer).
PHP_CodeSniffer\Sniffs\DeprecatedSniff interface to allow for marking a sniff as deprecated. #281
-q (quiet) mode, the deprecation notices will be hidden.-e) an asterix * will show next to deprecated sniffs.Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence sniff. #197
ShortOpenEchoNoSemicolon errorcode to allow for selectively ignoring missing semicolons in single line embedded PHP snippets within short open echo tags.phpcbf run. #308
AbstractSniffUnitTest class will now show a (non-build-breaking) warning when test case files contain fixable errors/warnings, but there is no corresponding .fixed file available in the test suite to verify the fixes against. #336
PHP_CodeSniffer\Filters\ExactMatch::getBlacklist() and PHP_CodeSniffer\Filters\ExactMatch::getWhitelist() methods are deprecated and will be removed in the 4.0 release. See #198.
ExactMatch::getDisallowedFiles() and ExactMatch::getAllowedFiles() methodsExactMatch cross-version compatible with both PHP_CodeSniffer 3.9.0+ as well as 4.0+, implement the new getDisallowedFiles() and getAllowedFiles() methods.
getDisallowedFiles() and getAllowedFiles() methods as well as the getBlacklist() and getWhitelist() are available, the new methods will take precedence over the old methods.Zend.Debug.CodeAnalyzer sniff. See #277.
MissingParamType error code will now be used instead of MissingParamName when a parameter name is provided, but not its type. Additionally, invalid type hint suggestions will no longer be provided in these cases.
switch case.
class keyword was not checked when the space included a new line or comment.
.github folder.The PHP_CodeSniffer project is happy to welcome the following new contributors: @joachim-n, @remicollet, @TimWolla
Closed: 8 issues Merged: 77 pull requests
💸 If you like what you see, please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
-s is used
-s is used and messages wraps
true/false/null type declarations
parent, self or a namespace relative class name type declaration
The PHP_CodeSniffer project is happy to welcome the following new contributors: @anomiex, @dingo-d, @fcool, @lucc, @rodrigoprimo
Closed: 4 issues Merged: 63 pull requests
If you like what you see, please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
[@anomiex]: https://github.com/anomiex [@dingo-d]: https://github.com/dingo-d [@fcool]: https://github.com/fcool [@fredden]: https://github.com/fredden [@jrfnl]: https://github.com/jrfnl [@lucc]: https://github.com/lucc [@rodrigoprimo]: https://github.com/rodrigoprimo [@shivammathur]: https://github.com/shivammathur
Squizlabs/PHP_CodeSniffer is dead. Long live PHPCSStandards/PHP_CodeSniffer!
squizlabs/PHP_CodeSniffer repository has been abandoned. The PHPCSStandards/PHP_CodeSniffer repository will serve as the continuation of the project. For more information about this change, please read the announcement.
squizlabs/php_codesniffer package now points to the new repository and everything will continue to work as before.https://squizlabs.github.io/PHP_CodeSniffer/phars/ to https://phars.phpcodesniffer.com/phars/.https://squizlabs.github.io/PHP_CodeSniffer/[phpcs|phpcbf].phar or https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/[phpcs|phpcbf].phar to https://phars.phpcodesniffer.com/[phpcs|phpcbf].phar.git@github.com:squizlabs/PHP_CodeSniffer.git to git@github.com:PHPCSStandards/PHP_CodeSniffer.git.
squizlabs/PHP_CodeSniffer repository are invited to resubmit these to the PHPCSStandards/PHP_CodeSniffer repository.true as a stand-alone type declaration
File::getMethodProperties(), File::getMethodParameters() and File::getMemberProperties() methods now all support the true typetrue as a stand-alone type to a number of sniffs
Generic.PHP.RequireStrictTypes.Disabled error codeParamNameUnexpectedAmpersandPrefix error for parameters annotated as passed by reference while the parameter is not passed by reference
setUp()/tearDown() methods or overload the setUp() in the AbstractSniffUnitTest test case, they will need to be adjusted. See the PR details for further informationInternal.PropertyDoesNotExist errror on line 1 of the scanned file, but will not halt the execution of PHPCSauto report width (the default) a value of 80 columns will be used if the width cannot be determined
InvalidNoReturn when type is never
match inside of it
--basepath and running from project subdirectory
use keyword
use keyword for multi-line trait use statements
$unknown property
Thanks go to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) for reviewing quite a few of the PRs for this release. Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo change over.
PHP_CodeSniffer has run correctly under PHP 8.1 since PHP 8 support was added, but it has not supported new 8.1 language features until this release. Version 3.7.0 adds support for the following PHP 8.1 language features:
never typeNote: 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.
T_TYPE_INTERSECTION token to represent the ampersand character inside intersection typesFile::getMethodParameters now supports the new PHP 8.1 readonly token
property_readonly array index is included in the return value
readonly_token array index is included in the return value
Generic.PHP.LowerCaseKeywordPSR2.Classes.PropertyDeclarationSquiz.Commenting.BlockCommentSquiz.Commenting.DocCommentAlignmentSquiz.Commenting.VariableCommentSquiz.WhiteSpace.ScopeKeywordSpacingGeneric.PHP.UpperCaseConstant and Generic.PHP.LowerCaseConstant now ignore type declarations
true/false/null when used as valuesGeneric.PHP.LowerCaseType now supports the PHP 8.1 never type
[@throw](https://github.com/throw)T_GOTO_LABEL
${
How can I help you explore Laravel packages today?