Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Codesniffer Laravel Package

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.

View on GitHub
Deep Wiki
Context7
4.0.1

This release includes all improvements and bugfixes from PHP_CodeSniffer 3.13.5.

Added

  • Runtime support for PHP 8.5. All known PHP 8.5 deprecation notices have been fixed.
    • Syntax support for new PHP 8.5 features will follow in a future release.
    • If you find any PHP 8.5 deprecation notices which were missed, please report them.

Changed

  • The Squiz.ControlStructures.SwitchDeclaration sniff will now flag a PHP close tag as a "wrong opener" and will auto-fix this by inserting a colon. #1316
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • 4.x regression #1277: bring back whitespace tolerance in phpcs:ignore comma-separated rule reference lists.
    • Note: this bug did not affect phpcs:disable/phpcs:enable ignore annotations.
  • Fixed bug #968: Generic.WhiteSpace.ScopeIndent was reporting false positives - and making incorrect fixes - for lines following a line containing an arrow function.
  • Fixed bug #1216: Tokenizer/PHP: added more defensive coding to prevent PHP 8.5 "Using null as an array offset" deprecation notices.
  • Fixed bug #1279: Tokenizer/PHP: on PHP < 8.0, an unclosed attribute (parse error) could end up removing some tokens from the token stream.
    • This could lead to false positives and false negative from sniffs, but could also lead to incorrect fixes being made mangling the file under scan.
  • Fixed bug #1315: Squiz.ControlStructures.SwitchDeclaration: a number of the fixers would get into fixer conflicts with each other if the code under scan contained multiple statements on a line within a switch.
    • The sniff will now forbid - and auto-fix - multiple statements on one line for case/default and "case breaking" statements.
  • Fixed bug #1316: Tokenizer/PHP: a PHP close tag after a switch case condition or after a default keyword, was not regarded as a "scope_opener" for the case/default body.
  • Fixed bug #1316: PSR2.ControlStructures.SwitchDeclaration: the WrongOpener error is now also auto-fixable if the wrong opener is a PHP close tag.
  • Fixed bug #1316: Squiz.PHP.NonExecutableCode would throw false positives when code within a switch control structure would move in and out of PHP.

New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @andrewnicols, @Soh1121

Statistics

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!

3.13.5

Added

  • Runtime support for PHP 8.5. All known PHP 8.5 deprecation notices have been fixed.
    • Syntax support for new PHP 8.5 features will follow in a future release.
    • If you find any PHP 8.5 deprecation notices which were missed, please report them.

Changed

Fixed

  • Fixed bug #1216: Tokenizer/PHP: added more defensive coding to prevent PHP 8.5 "Using null as an array offset" deprecation notices.
  • Fixed bug #1279: Tokenizer/PHP: on PHP < 8.0, an unclosed attribute (parse error) could end up removing some tokens from the token stream.
    • This could lead to false positives and false negative from sniffs, but could also lead to incorrect fixes being made mangling the file under scan.
    • Thanks to Juliette Reinders Folmer for the patch.

Other

  • Please be aware that the master branch has been renamed to 3.x and the default branch has changed to the 4.x branch.
    • If you contribute to PHP_CodeSniffer, you will need to update your local git clone.
    • If you develop against PHP_CodeSniffer and run your tests against dev branches of PHPCS, you will need to update your workflows.

New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @andrewnicols

Statistics

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!

4.0.0

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.

Changed

  • Tokenizer/PHP: fully qualified exit/die/true/false/null will be tokenized as the keyword token and the token 'content' will include the leading backslash. #1201
  • Wherever possible based on the PHP 7.2 minimum version, parameter types have been added to all methods. #1237
  • The supported PHPUnit version constraints have been updated to ^8.4.0 || ^9.3.4 || ^10.5.32 || 11.3.3 - 11.5.28 || ^11.5.31. #1247
    • External standards using the PHP_CodeSniffer native framework may need to update their own PHPUnit version constraints.
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • Fixed bug #1082: new exit codes weren't applied when running phpcbf on code provided via STDIN.
  • Fixed bug #1172: // phpcs:set for inline array properties did not handle a single item array with the value true, false or null correctly.
  • Fixed bug #1174: progress bar wasn't showing files as fixed when running phpcbf in parallel mode.
  • Fixed bug #1226: PHP 8.5 "Using null as an array offset" deprecation notice.

Other

  • Please be aware that the master branch has been renamed to 3.x and the default branch has changed to the 4.x branch.
    • If you contribute to PHP_CodeSniffer, you will need to update your local git clone.
    • If you develop against PHP_CodeSniffer and run your tests against dev branches of PHPCS, you will need to update your workflows.

Statistics

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!

3.13.4

Fixed

  • Fixed bug #1213: ability to run tests for external standards using the PHPCS native test framework was broken.
  • Fixed bug #1215: PHP 8.5 "Using null as an array offset" deprecation notices.

Statistics

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!

3.13.3

Added

  • Tokenizer support for PHP 8.4 dereferencing of new expressions without wrapping parentheses. #1160
  • Tokenizer support for PHP 8.4 abstract properties. #1183
    • The File::getMemberProperties() method now also supports abstract properties through a new is_abstract array index in the return value. #1184
    • Additionally, the following sniffs have been updated to support abstract properties:
      • Generic.PHP.LowerCaseConstant #1185
      • Generic.PHP.UpperCaseConstant #1185
      • PSR2.Classes.PropertyDeclaration #1188
      • Squiz.Commenting.VariableComment #1186
      • Squiz.WhiteSpace.MemberVarSpacing #1187
    • Thanks to Juliette Reinders Folmer for the patches
  • Tokenizer support for the PHP 8.4 "exit as a function call" change. #1201
    • When exit/die is used as a fully qualified "function call", it will now be tokenized as T_NS_SEPARATOR + T_EXIT.
    • Additionally, the following sniff has been updated to handle fully qualified exit/die correctly:
      • Squiz.PHP.NonExecutableCode
    • Thanks to Juliette Reinders Folmer for the patches

Changed

  • Tokenizer/PHP: fully qualified true/false/null will now be tokenized as T_NS_SEPARATOR + T_TRUE/T_FALSE/T_NULL. #1201
    • Previously, these were tokenized as T_NS_SEPARATOR + T_STRING.
    • Additionally, the following sniffs have been updated to handle fully qualified true/false/null correctly:
      • Generic.CodeAnalysis.UnconditionalIfStatement
      • Generic.ControlStructures.DisallowYodaConditions
      • PEAR.Functions.ValidDefaultValue
    • Thanks to Juliette Reinders Folmer for the patches.
  • Generic.PHP.Syntax: the sniff is now able to scan input provided via STDIN on non-Windows OSes. #915
  • PSR2.ControlStructures.SwitchDeclaration: the WrongOpener* error code is now auto-fixable if the identified "wrong opener" is a semi-colon. #1161
  • The PSR2.Classes.PropertyDeclaration will now check that the abstract modifier keyword is placed before a visibility keyword. #1188
    • Errors will be reported via a new AbstractAfterVisibility error code.
    • Thanks to Juliette Reinders Folmer for the patch.
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • Fixed bug #1112 : --parallel option fails if PHP_CodeSniffer is invoked via bash and the invokation creates a non-PHPCS-managed process.
  • Fixed bug #1113 : fatal error when the specified "files to scan" would result in the same file being added multiple times to the queue.
    • This error only occured when --parallel scanning was enabled.
    • Thanks to Rodrigo Primo for the patch.
  • Fixed bug #1154 : PEAR.WhiteSpace.ObjectOperatorIndent: false positive when checking multiple chained method calls in a multidimensional array.
  • Fixed bug #1193 : edge case inconsistency in how empty string array keys for sniff properties are handled.
  • Fixed bug #1197 : Squiz.Commenting.FunctionComment: return types containing a class name with underscores would be truncated leading to incorrect results.

Other


New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @benno5020, @NanoSector

Statistics

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!

4.0.0-RC1

This release includes all improvements and bugfixes from PHP_CodeSniffer 4.0.0-beta1, 3.13.1 and 3.13.2.

Changed

  • The error code Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterVisbility has been changed to Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterVisibility. #1136
  • The following sniff(s) have received efficiency improvements:
    • Generic.ControlStructures.InlineControlStructure #880
    • Thanks to Rodrigo Primo for the patch.

Fixed

  • Fixed bug #3889 : A selective phpcs:enable could sometimes override a later selective phpcs:ignore.
  • Fixed bug #1128 : missing 'parenthesis_owner' index for T_FUNCTION token on PHP < 7.4 when function is named "fn".

Other

  • The GPG signature for the PHAR files has been rotated. The new fingerprint is: D91D86963AF3A29B6520462297B02DD8E5071466.

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.


Statistics

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!

3.13.2

Changed

  • The documentation for the following sniffs has been improved:
    • Squiz.Classes.SelfMemberReference
    • Thanks to Rodrigo Primo for the patch.
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • Fixed bug #1135 : Squiz.Functions.FunctionDeclarationArgumentSpacing: typo in new error code SpacingAfterSetVis[i]bility.

Statistics

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!

3.13.1

Added

  • Added support for PHP 8.4 properties with asymmetric visibility to File::getMemberProperties() through a new set_scope array index in the return value. #1116
  • Added support for PHP 8.4 (constructor promoted) properties with asymmetric visibility to File::getMethodParameters() through new set_visibility and set_visibility_token array indexes in the return value. #1116
  • Added support for PHP 8.4 asymmetric visibility modifiers to the following sniffs:
    • Generic.PHP.LowerCaseKeyword #1117
    • PEAR.NamingConventions.ValidVariableName #1118
    • PSR2.Classes.PropertyDeclaration #1119
    • Squiz.Commenting.BlockComment #1120
    • Squiz.Commenting.DocCommentAlignment #1120
    • Squiz.Commenting.VariableComment #1120
    • Squiz.Functions.FunctionDeclarationArgumentSpacing #1121
    • Squiz.Scope.MemberVarScope #1122
    • Squiz.WhiteSpace.MemberVarSpacing #1123
    • Squiz.WhiteSpace.ScopeKeywordSpacing #1124
    • Thanks to Juliette Reinders Folmer for the patches.

Changed

  • The PSR2.Classes.PropertyDeclaration will now check that a set-visibility modifier keyword is placed after a potential general visibility keyword. #1119
  • The Squiz.Functions.FunctionDeclarationArgumentSpacing will now check spacing after a set-visibility modifier keyword. #1121
    • Errors will be reported via a new SpacingAfterSetVisibility error code.
    • Thanks to Juliette Reinders Folmer for the patch.
  • The Squiz.Scope.MemberVarScope will now flag missing "read" visibility, when "write" visibility is set, under a separate error code AsymReadMissing. #1122
  • The documentation for the following sniffs has been improved:
    • PEAR.Classes.ClassDeclaration
    • Squiz.WhiteSpace.FunctionOpeningBraceSpace
    • Thanks to Brian Dunne and Rodrigo Primo for the patches.
  • Various housekeeping, including improvements to the tests and documentation.

Other

  • The latest PHP_CodeSniffer XSD file is now available via the following permalink: https://schema.phpcodesniffer.com/phpcs.xsd. #1094 Older XSD files can be referenced via permalinks based on their minor: https://schema.phpcodesniffer.com/#.#/phpcs.xsd.
  • The GPG signature for the PHAR files has been rotated. The new fingerprint is: D91D86963AF3A29B6520462297B02DD8E5071466.

Statistics

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!

4.0.0beta1

Added

  • Files without extension can now be scanned if the path is passed in directly. #2916
    • Previously, files without extension would always be ignored.
    • Now, files with no extension are checked if explicitly passed on the command line or specified in a ruleset.
    • Files without extension will still be ignored when scanning directories recursively.
  • Support for extending a default value for an array property on a sniff from an XML ruleset file. #15
    • Previously, using extend="true" on an property tag for setting an array value could already extend a property value set elsewhere in an (inluded) ruleset.
    • Now, you can also add to (extend) a default value as set on the sniff itself.
    • Note: the property default value and the values set via the ruleset will be merged.
      • This also means that for associative arrays, you can redefine the value for a particular array key.
      • For numerically indexed arrays, this means the array will be renumbered. Keep this in mind if the numeric indexes hold meaning.
  • Added support for PHP 8.4 properties in interfaces to File::getMemberProperties(). #2455
    • Note: properties in interfaces is not fully supported yet, it is just this one method which handles them correctly at this moment.
  • Tokens::NAME_TOKENS containing an array with the tokens used for identifier names. #3041
  • New sniff Generic.WhiteSpace.GotoTargetSpacing to enforce no space between the label of a goto target and the colon following it. #1026
  • An error message is now displayed if no files were checked during a run. #1595
    • This occurs when all of the specified files matched exclusion rules, or none matched filtering rules.
  • An error will be shown when attempting to change an unchangable PHP ini setting using -d option[=value] or via the ruleset with <ini name=...>. #416
    • Previously, this was silently ignored.
    • Attempting to change non-existent ini settings (typo, extension not loaded) will continue to be silently ignored.

Changed

  • The minimum required PHP version has changed from 5.4.0 to 7.2.0.
  • The default coding standard has changed from PEAR to PSR12.
  • Both phpcs as well as phpcbf will now exit with exit code 0 if no issues were found/remain after fixing. #184
    • Non auto-fixable issues can be ignored for the exit code determination by setting the new ignore_non_auto_fixable_on_exit config flag to 1.
    • For full details on the new exit codes, please refer to the Wiki "Advanced Usage" page.
  • Composer installs no longer include any test files. #1908
    • The test framework files will still be included to allow for use by external standards.
  • All status, debug, and progress output is now sent to STDERR instead of STDOUT. #1612
    • Only report output now goes through STDOUT. As a result of this, piping output to a file will now only include report output.
      • Pipe both STDERR and STDOUT to the same file to capture the entire output of the run.
    • The --report-file functionality remains untouched.
    • With this change in place, timing and memory consumption stats will now be displayed more often as this will no longer interfere with reports.
  • The --extensions command line argument no longer accepts the tokenizer along with the extension. #2448
    • Previously, you would check .module files as PHP files using --extensions=module/php.
    • Now, you use --extensions=module.
  • When processing rulesets, <config> directives will be applied based on the nesting level of the ruleset. #2197
    • Previously, it was not possible to overrule a <config> directive set in an included ruleset from the "root" ruleset.
    • Now, <config> directives set in the "root" ruleset will always "win" over directives in included rulesets.
    • When two included rulesets at the same nesting level both set the same directive, the value from the last included ruleset "wins" (= same as before).
  • When processing rulesets, <arg> directives will be applied based on the nesting level of the ruleset. #2395, #2597, #2602
    • Previously, it was not possible to overrule a <arg> directive set in an included ruleset from the "root" ruleset.
    • Now, <arg> directives set in the "root" ruleset will always "win" over directives in included rulesets.
    • When two included rulesets at the same nesting level both set the same directive, the value from the first included ruleset "wins" (= same as before).
  • Internal errors will no longer be suppressed when the --sniffs CLI argument is used. #98
  • The File::getDeclarationName() method will no longer accept T_ANON_CLASS or T_CLOSURE tokens. #3766
    • A RuntimeException will be thrown if these tokens are passed.
  • The File::getDeclarationName() method will now always return a string (or throw an Exception). #1007
    • Previously, the method would return null if the name could not be determined, like during live coding. Now it will return an empty string in those situations.
  • The File::getMemberProperties() method will no longer add warnings about possible parse errors. #2455
    • This means the Internal.ParseError.InterfaceHasMemberVar and the Internal.ParseError.EnumHasMemberVar error codes have been removed.
    • The method will now throw a "$stackPtr is not a class member var" RuntimeException for properties declared in enums (parse error).
    • Properties declared in interfaces will be analyzed like all other properties, as these are allowed since PHP 8.4.
  • None of the included sniffs will warn about possible parse errors any more. #2455
    • This improves the experience when the file is being checked inside an editor during live coding.
    • If you want to detect parse errors, use the Generic.PHP.Syntax sniff or a dedicated linter instead.
  • The PEAR + PSR2 FunctionCallSignature sniffs will now also examine anonymous class instantiations with parameters. #47
  • The error code Squiz.Classes.ValidClassName.NotCamelCaps has been changed to Squiz.Classes.ValidClassName.NotPascalCase. #2046
    • This reflects that the sniff is actually checking for ClassName and not className.
  • The error code Squiz.PHP.Heredoc.NotAllowed has been replaced by Squiz.PHP.Heredoc.HeredocNotAllowed and Squiz.PHP.Heredoc.NowdocNotAllowed. #2318
    • This allows for forbidding either heredocs or nowdocs without forbidding both.
  • The PSR12.Files.FileHeader sniff now has more modular error codes to allow for more selectively applying the rules. #2729 #3453
    • The PSR12.Files.FileHeader.SpacingAfterBlock error code is replaced by:
      • PSR12.Files.FileHeader.SpacingAfterTagBlock
      • PSR12.Files.FileHeader.SpacingAfterDocblockBlock
      • PSR12.Files.FileHeader.SpacingAfterDeclareBlock
      • PSR12.Files.FileHeader.SpacingAfterNamespaceBlock
      • PSR12.Files.FileHeader.SpacingAfterUseBlock
      • PSR12.Files.FileHeader.SpacingAfterUseFunctionBlock
      • PSR12.Files.FileHeader.SpacingAfterUseConstBlock
    • The PSR12.Files.FileHeader.SpacingInsideBlock error code is replaced by:
      • PSR12.Files.FileHeader.SpacingInsideUseBlock
      • PSR12.Files.FileHeader.SpacingInsideUseFunctionBlock
      • PSR12.Files.FileHeader.SpacingInsideUseConstBlock
  • The error code Squiz.Commenting.VariableComment.TagNotAllowed has been replaced by a dynamic Squiz.Commenting.VariableComment.[TagName]TagNotAllowed error code. #1039
    • This allows for selectively allowing specific tags by excluding the error code for that tag.
    • Example: to allow [@link](https://github.com/link) tags in property docblocks, exclude the Squiz.Commenting.VariableComment.LinkTagNotAllowed error code.
  • The following sniffs have received performance related improvements:
    • PEAR.NamingConventions.ValidVariableName
    • PSR2.Classes.PropertyDeclaration
    • Squiz.Commenting.VariableComment
    • Squiz.Scope.MemberVarScope
    • Squiz.WhiteSpace.MemberVarSpacing
    • These sniffs will no longer listen to non-variable tokens, nor for variables tokens outside of OO context. #374 External sniffs which extend one of these sniffs may need adjustment if they want to retain the old behaviour.
  • PHPCS now uses the PHP >= 8.0 native method for tokenizing (namespaced) identifier names. #3041
    • Before PHP 8.0, PHP would tokenize namespaced names using T_STRING and T_NS_SEPARATOR.
    • From PHP 8.0, PHP uses the tokens T_NAME_FULLY_QUALIFIED, T_NAME_RELATIVE, and T_NAME_QUALIFIED instead.
    • PHPCS now uses these new PHP 8.0 tokens no matter what version of PHP is being used to run PHPCS.
    • Custom sniffs that use T_STRING and T_NS_SEPARATOR tokens to look for namespaced names will need to be modified.
    • The Tokens::FUNCTION_NAME_TOKENS/Tokens::$functionNameTokens array now includes the identifier name tokens.
  • Closure T_USE tokens, T_ISSET, T_UNSET, T_EMPTY, T_EVAL and T_EXIT tokens now contain parenthesis information. #23, #2593
    • Previously, you had to find the opening and closing parenthesis by looking forward through the token stack.
    • Now, you can use the parenthesis_owner, parenthesis_opener and parenthesis_closer array indexes.
  • The static keyword when preceded by instanceof will now be tokenized (again) as T_STATIC. #22
    • Previously, the token was (re-)tokenized to T_STRING.
  • T_OPEN_TAG tokens will no longer contain any whitespace. #593
    • Previously, "long" open tags could include either a single space or a new line character.
    • This whitespace will now be tokenized as a T_WHITESPACE token.
  • T_GOTO_LABEL tokens will no longer include the colon following it. #185
    • The colon belonging with a goto label will now be tokenized separately as T_GOTO_COLON.
  • Context sensitive keywords used as a label in a goto statement will now be tokenized as T_STRING to prevent confusing sniffs. #185
  • All T_DOC_COMMENT_* tokens now have the comment_opener and comment_closer indexes set. #484
  • The Tokens::FUNCTION_NAME_TOKENS/Tokens::$functionNameTokens array now includes the T_ANON_CLASS token. #47
  • Type casting for sniff property values set from within a ruleset has been made more consistent. #708
    • true 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'.
    • Array element values will now also get the type casting treatment. Previously, array values would always be strings.
  • The PHP_CodeSniffer\Config::setConfigData() method is no longer static. #2675
    • The associated (private) Config::$overriddenDefaults property is also no longer static.
  • The PHP_CodeSniffer\Config::setSettings() method is now a void method. #1001
  • The signature of the DummyFile::setErrorCounts() method has changed and now expects the following parameters: $errorCount, $warningCount, $fixableErrorCount, $fixableWarningCount, $fixedErrorCount, $fixedWarningCount. #1079
  • The Generator classes will now throw a PHP_CodeSniffer\Exceptions\GeneratorException when encountering errors in the documentation XML. #1072
  • The PHP_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. #1051
  • The PHP_CodeSniffer\Util\Timing class is now final and marked as an internal class. #1074
  • The Ruleset class no longer has special behaviour when used in a test context. #996
  • The minimum required PHPUnit version for the test framework has changed from 4.0 to 8.0. #994, #997
    • The test framework is now compatible with PHPUnit 8.x - 11.x (ignoring PHPUnit deprecations related to PHPUnit 12).
  • The test framework has been refactored and no longer creates a custom test suite. #25
    • If tests for an external standard extend the PHPCS native test suite, be sure to read the upgrade guide for more detail.
  • The two abstract base test cases have been renamed. #25
    • Replace PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest with PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase.
    • Replace PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest with PHP_CodeSniffer\Tests\Core\AbstractMethodTestCase.
  • Tests which extend the AbstractSniffTestCase for which no test case files (.inc files) can be found, will now be marked as "incomplete". #998
    • Previously, those tests would silently pass.
  • All test case files (inc) which would be changed by the sniff under test if running the fixer, are now required to be accompanied by a *.fixed file. #300

Deprecated

  • The static token array properties in the Tokens class. Use the corresponding class constants on the Tokens class instead. #500
  • PHP_CodeSniffer\Util\Common::$allowedTypes. Use PHP_CodeSniffer\Util\Common::ALLOWED_TYPES instead. #1043
  • PHP_CodeSniffer\Tokenizers\PHP::$tstringContexts. Use PHP_CodeSniffer\Tokenizers\PHP::T_STRING_CONTEXTS instead. #1043
  • PHP_CodeSniffer\Sniffs\AbstractVariableSniff::$phpReservedVars. Use PHP_CodeSniffer\Sniffs\AbstractVariableSniff::PHP_RESERVED_VARS instead. #1043
  • PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff::$magicMethods. Use PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff::MAGIC_METHODS instead. #1043
    • This also affects the 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
    • This also affects the 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
    • This also affects the 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. #1043
  • PHP_CodeSniffer\Standards\Generic\Sniffs\Files\InlineHTMLSniff::$bomDefinitions. Use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\InlineHTMLSniff::BOM_DEFINITIONS instead. #1043
  • PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\CharacterBeforePHPOpeningTagSniff::$bomDefinitions. Use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\CharacterBeforePHPOpeningTagSniff::BOM_DEFINITIONS instead. #1043
  • PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\SubversionPropertiesSniff::$properties. Use PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\SubversionPropertiesSniff::REQUIRED_PROPERTIES instead. #1043
  • PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\FileCommentSniff::$tags. Use PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\FileCommentSniff::EXPECTED_TAGS instead. #1043
    • This also affects the 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
    • This also affects the 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
    • This also affects the 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. #1043
  • PHP_CodeSniffer\Util\Standards::printInstalledStandards(). Use echo PHP_CodeSniffer\Util\Standards::prepareInstalledStandardsForDisplay() instead. #1054
  • PHP_CodeSniffer\Config::printConfigData(). Use echo PHP_CodeSniffer\Config::prepareConfigDataForDisplay() instead. #1055
  • The Reporter::$totalFixable and Reporter::$totalFixed properties. #1079
    • Use respectively (Reporter::$totalFixableErrors + Reporter::$totalFixableWarnings) and (Reporter::$totalFixedErrors + Reporter::$totalFixedWarnings) instead.

Removed

  • Support for checking the coding standards of CSS and JS files has been removed. #2448
    • Sniffs which are specifically aimed at CSS/JS files will no longer run.
    • All other sniffs will now treat all files under scan as PHP files.
    • The JS/CSS tokenizers and all tokens which were specifically for CSS/JS have also been removed.
  • Support for sniffs not implementing the PHP_CodeSniffer\Sniffs\Sniff interface. See #694.
  • Support for sniffs not following the naming conventions. See #689.
  • Support for external standards called "Internal". See #799.
  • Support for the deprecated [@codingStandard](https://github.com/codingStandard) annotation syntax has been removed. #1954
    • Use the phpcs: or [@phpcs](https://github.com/phpcs): syntax instead
      • Replace [@codingStandardsIgnoreFile](https://github.com/codingStandardsIgnoreFile) with phpcs:ignoreFile
      • Replace [@codingStandardsIgnoreStart](https://github.com/codingStandardsIgnoreStart) with phpcs:disable
      • Replace [@codingStandardsIgnoreEnd](https://github.com/codingStandardsIgnoreEnd) with phpcs:enable
      • Replace [@codingStandardsIgnoreLine](https://github.com/codingStandardsIgnoreLine) with phpcs:ignore
      • Replace [@codingStandardsChangeSetting](https://github.com/codingStandardsChangeSetting) with phpcs:set
  • Support for the deprecated ruleset.xml array property string-based syntax has been removed. #1983
    • Previously, an array value could be set using a comma-delimited string print=>echo,create_function=>null
    • Now, individual array elements are specified using an element tag with key and value attributes
      • For example, <element key="print" value="echo">
  • The unused T_ARRAY_HINT token. #1997
  • The unused T_RETURN_TYPE token. #1997
  • The Generic.Debug.ClosureLinter sniff. #2448
  • The Generic.Debug.CSSLint sniff. #2448
  • The Generic.Debug.ESLint sniff. #2448
  • The Generic.Debug.JSHint sniff. #2448
  • The Generic.Formatting.NoSpaceAfterCast sniff. #2234
    • Use the Generic.Formatting.SpaceAfterCast sniff instead with the $spacing property set to 0.
  • The Generic.Functions.CallTimePassByReference sniff. #921
  • The entire MySource standard, and all sniffs within. #2471
  • The Squiz.Classes.DuplicateProperty sniff. #2448
  • The entire Squiz.CSS category, and all sniffs within. #2448
  • The Squiz.Debug.JavaScriptLint sniff. #2448
  • The Squiz.Debug.JSLint sniff. #2448
  • The Squiz.Objects.DisallowObjectStringIndex sniff. #2448
  • The Squiz.Objects.ObjectMemberComment sniff. #2448
  • The Squiz.WhiteSpace.LanguageConstructSpacing sniff. #1953
    • Use the Generic.WhiteSpace.LanguageConstructSpacing sniff instead.
  • The Squiz.WhiteSpace.PropertyLabelSpacing sniff. #2448
  • The Zend.Debug.CodeAnalyzer sniff. #58
  • The error property of sniff Generic.Strings.UnnecessaryStringConcat. See #2823
    • This sniff now always produces errors
    • To make this sniff produce warnings, include the following in a ruleset.xml or [.]phpcs.xml[.dist] file:
      <rule ref="Generic.Strings.UnnecessaryStringConcat">
          <type>warning</type>
      </rule>
      
  • The error property of sniff Generic.Formatting.MultipleStatementAlignment. See #2823
    • This sniff now always produces warnings
    • The Generic.Formatting.MultipleStatementAlignment.IncorrectWarning error code has been removed.
      • Refer to the Generic.Formatting.MultipleStatementAlignment.Incorrect error code instead.
    • The Generic.Formatting.MultipleStatementAlignment.NotSameWarning error code has been removed.
      • Refer to the Generic.Formatting.MultipleStatementAlignment.NotSame error code instead.
    • To make this sniff produce errors, include the following in a ruleset.xml or [.]phpcs.xml[.dist] file:
      <rule ref="Generic.Formatting.MultipleStatementAlignment">
          <type>error</type>
      </rule>
      
  • The $ignoreComments parameter for the AbstractPatternSniff::__construct() method.
  • Ruleset::setSniffProperty(): support for the old $settings parameter format. #3629
  • Use of the deprecated auto_detect_line_endings ini setting. #3394
    • This removes support for files with \r line endings.
  • The abstract PHP_CodeSniffer\Filters\ExactMatch::getBlacklist() and PHP_CodeSniffer\Filters\ExactMatch::getWhitelist() methods. See #199.
    • These have been replaced by the ExactMatch::getDisallowedFiles() and ExactMatch::getAllowedFiles() methods.
  • The deprecated PHP_CodeSniffer\Generators\[HTML|Markdown|Text]::print*() methods. See #755.
  • Unused static PHP_CodeSniffer\Reporter::$startTime property. #1064

Fixed

  • Fixed bug #185 : goto labels were incorrectly tokenized as T_STRING if there was whitespace and/or comments between the label and colon.
  • Fixed bug #1012 : in edge cases, the tokenizer could create some stray parenthesis_* keys.
  • Fixed bug #1020 : File::findExtendedClassName() will no longer break on namespace relative class names.
  • Fixed bug #1020 : File::findImplementedInterfaceNames() will no longer break on namespace relative interface names.
  • Fixed bug #1020 : Various sniffs now have better support for ignoring/examining qualified function calls.

Other

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.

Statistics

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!

3.13.0

Added

  • Added support for PHP 8.4 asymmetric visibility modifiers to the tokenizer. #871
  • Added support for PHP 8.4 final properties to the following sniffs:

Changed

  • Generic.WhiteSpace.LanguageConstructSpacing: will now also check the spacing after the goto language construct keyword. #917
  • The PSR2.Classes.PropertyDeclaration will now check that the final modifier keyword is placed before a visibility keyword. #950
  • Improved Help information about the --reports CLI flag. #1078
  • The documentation for the following sniffs has been improved:
    • PSR1.Files.SideEffects
    • PSR2.ControlStructures.SwitchDeclaration
    • PSR2.Namespaces.NamespaceDeclaration
    • Thanks to Rodrigo Primo for the patches.
  • Various housekeeping, including improvements to the tests and documentation.

Deprecated

  • Nearly everything which was soft deprecated before is now hard deprecated and will show deprecation notices:
    • This applies to:
      • All sniffs which will be removed in 4.0. #888
      • The deprecated Generator methods. #889
      • The old array property setting format (via comma separated strings). #890
      • Sniffs not implementing the PHP_CodeSniffer\Sniffs\Sniff interface. #891
      • Sniffs not following the naming conventions. #892
      • Standards called Internal. #893
      • Sniffs which don't listen for PHP, like JS/CSS specific sniffs. #894
    • The deprecation notices can be silenced by using the -q (=quiet) CLI flag.
    • Thanks to Juliette Reinders Folmer for the patches.

Fixed

  • Fixed bug #1040 : Generic.Strings.UnnecessaryHeredoc - false positive for heredocs containing escape sequences.
  • Fixed bug #1040 : Generic.Strings.UnnecessaryHeredoc - fixer would not clean up escape sequences which aren't necessary in nowdocs.
  • Fixed bug #1048 : A file under scan would sometimes be updated with partial fixes, even though the file "failed to fix".

Other

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.


Statistics

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!

3.12.2

Added

  • Added support for PHP 8.4 final properties to the following sniffs:
    • Generic.PHP.LowerCaseConstant #948
    • Generic.PHP.UpperCaseConstant #948
    • Squiz.Commenting.DocCommentAlignment #951
    • Squiz.Commenting.VariableComment #949
    • Thanks to Juliette Reinders Folmer for the patches.

Changed

  • Tokenizer/PHP: a PHP open tag at the very end of a file will now always be tokenized as T_OPEN_TAG, independently of the PHP version. #937
    • Previously, a PHP open tag at the end of a file was not tokenized as an open tag on PHP < 7.4 and the tokenization would depend on the short_open_tag setting.
    • Thanks to Juliette Reinders Folmer for the patch.
  • PEAR.Commenting.FunctionComment: improved message for "blank lines between docblock and declaration" check. #830
  • The documentation for the following sniffs has been improved:
    • Generic.Functions.OpeningFunctionBraceBsdAllman
    • Generic.Functions.OpeningFunctionBraceKernighanRitchie
    • Generic.WhiteSpace.LanguageConstructSpacing
    • Thanks to Rodrigo Primo for the patches.
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • Fixed bug #830 : PEAR.Commenting.FunctionComment will no longer remove blank lines within attributes.
  • Fixed bug #929 : Generic.PHP.ForbiddenFunctions: prevent false positives/negatives for code interlaced with comments.
  • Fixed bug #934 : Generic.PHP.LowerCaseConstant and Generic.PHP.UpperCaseConstant will now correctly ignore DNF types for properties.
  • Fixed bug #936 : Squiz.Commenting.FunctionCommentThrowTag: sniff would bow out when function has attributes attached, leading to false negatives.
  • Fixed bug #940 : Squiz.Commenting.VariableComment: false positive for missing docblock for properties using DNF types.
  • Fixed bug #944 : Squiz.Commenting.FunctionComment did not support DNF/intersection types in [@param](https://github.com/param) tags.
  • Fixed bug #945 : Squiz.WhiteSpace.FunctionSpacing would get confused when there are two docblocks above a function declaration.
  • Fixed bug #947 : Squiz.Commenting.FunctionCommentThrowTag: prevent false positives/negatives for code interlaced with comments.
  • Fixed bug #951 : Squiz.Commenting.DocCommentAlignment did not examine docblocks for final classes.
  • Fixed bug #955 : Potential race condition, leading to a fatal error, when both the Diff + the Code reports are requested and caching is on.
  • Fixed bug #956 : Generic.WhiteSpace.ScopeIndent: undefined array index notice when running in debug mode.

Other

  • PHP_CodeSniffer 4.0 is coming soon! Interested in a sneak peek ? Join the live stream at any time on April 14, 15, 17 or 18. Read the open invitation (#924) for all the details.

New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @devfrey

Statistics

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!

3.12.1

Added

  • Documentation for the following sniffs:
    • Squiz.Commenting.BlockComment
    • Thanks to Colin Stewart for the patch.

Changed

Deprecated

  • The Generic.Functions.CallTimePassByReference sniff. See #921.
    • This sniff will be removed in version 4.0.0.

Fixed

  • Fixed bug #906 : Fixer: prevent InvalidArgumentExceptions when displaying verbose information.
  • Fixed bug #907 : Tokenizer/PHP: tokenization of tokens related to union, intersection and DNF types in combination with PHP 8.4 final properties.
  • Fixed bug #908 : Tokenizer/PHP: tokenization of ? in nullable types for readonly properties.
  • Fixed bug #916 : Tokenizer/PHP: goto was not recognized as a terminating statement for a case/default in a switch control structure.

Other

  • PHP_CodeSniffer 4.0 is coming soon! Interested in a sneak peek ? Join the live stream at any time on April 14, 15, 17 or 18. Read the open invitation (#924) for all the details.

New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @costdev

Statistics

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!

3.12.0

Added

  • Added support for PHP 8.4 final properties to File::getMemberProperties() through a new is_final array index in the return value. #834
  • Generators/HTML: each section title now has a unique anchor link, which can be copied when hovering over a title. #859
    • This should make sharing a link to a specific section of the documentation more straight-forward.
    • Thanks to Juliette Reinders Folmer for the patch.
  • Documentation for the following sniffs:
    • Squiz.Classes.ClassFileName
    • Squiz.Classes.ValidClassName
    • Thanks to Brian Dunne for the patches.

Changed

  • PHPCBF: the messaging when no fixable errors are found will now distinguish between "No violations" (at all) versus "No fixable errors". #806
  • The -h (Help) option now contains a more extensive list of "config" options which can be set. #809
  • Improved error message when invalid sniff codes are supplied to --sniffs or --exclude command line arguments. #344
  • Improved error message when an invalid generator name is supplied to the --generator command line argument. #709, #771
    • The generator name will now also always be handled case-insensitively, independently of the OS used.
    • Thanks to Rodrigo Primo for the patch.
  • The user will be shown an informative error message for sniffs missing one of the required methods. #873
  • Ruleset processing will now be allowed to run to its conclusion - barring critical errors - before displaying all ruleset errors in one go. #857
    • Previously an error in a ruleset would cause PHPCS to exit immediately and show only one error at a time.
    • Thanks to Juliette Reinders Folmer for the patch.
  • Generators: XML documentation files which don't contain any actual documentation will now silently be ignored. #755
  • Generators: when the title attribute is missing, the documentation generation will now fall back to the sniff name as the title. #820
  • Generators: cleaner output based on the elements of the documentation which are available. #819, #821
  • Generators/HTML: improved display of code tables by using semantic HTML. #854
  • Squiz.Classes.ClassFileName: recommend changing the file name instead of changing the class name. #845
    • This prevents unactionable recommendations due to the file name not translating to a valid PHP symbol name.
    • Thanks to Juliette Reinders Folmer for the patch.
  • Squiz.Functions.FunctionDeclarationArgumentSpacing: incorrect spacing after a comma followed by a promoted property has an improved error message and will now be flagged with the SpacingBeforePropertyModifier or NoSpaceBeforePropertyModifier error codes. #792
    • This was previously already flagged, but using either the SpacingBeforeHint or NoSpaceBeforeHint error code, which was misleading.
    • Thanks to Juliette Reinders Folmer for the patch.
  • Squiz.Functions.FunctionDeclarationArgumentSpacing: the sniff will now also check the spacing after property modifiers for promoted properties in constructor methods. #792
  • Squiz.WhiteSpace.ScopeKeywordSpacing: the sniff will now also check the spacing after the final and abstract modifier keywords. #604
  • The following sniff(s) have received efficiency improvements:
  • Incorrectly set inline properties (in test case files) will be silently ignored again. #884
  • The AbstractMethodUnitTest class will now flag duplicate test case markers in a test case file. #773
  • Various housekeeping, including improvements to the tests and documentation.

Deprecated

All deprecation are slated for removal in PHP_CodeSniffer 4.0.

  • Support for sniffs not implementing the PHPCS Sniff interface. See #694.
  • Support for including sniffs which don't comply with the PHPCS naming conventions (by referencing the sniff file directly). See #689.
  • Support for external standards named "Internal". See #799.
  • The following Generator methods are now (soft) deprecated. See #755:
    • 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()
    • Thanks to Juliette Reinders Folmer for the patch.

Fixed

  • Fixed bug #794 : Generators: prevent fatal error when the XML documentation does not comply with the expected format.
  • Fixed bug #814 : Generic.NamingConventions.ConstructorName: prevent potential fatal errors during live coding.
  • Fixed bug #816 : File::getDeclarationName(): prevent incorrect result for unfinished closures during live coding.
  • Fixed bug #817 : Squiz.Classes.ValidClassName: ignore comments when determining the name to be validated.
  • Fixed bug #825 : Squiz.Classes.ClassDeclaration: false positives when the next thing after a class was a function with an attribute attached.
  • Fixed bug #826 : Squiz.WhiteSpace.FunctionSpacing: prevent incorrect some results when attributes are attached to a function.
  • Fixed bug #827 : PEAR.Functions.FunctionDeclaration: fixer conflict over an unfinished closure during live coding.
  • Fixed bug #828 : Squiz.WhiteSpace.MemberVarSpacing: allow for readonly properties.
  • Fixed bug #832 : Squiz.WhiteSpace.MemberVarSpacing: prevent potential fixer conflict during live coding.
  • Fixed bug #833 : Squiz.PHP.EmbeddedPhp: fixer conflict when a PHP open tag for a multi-line snippet is found on the same line as a single-line embedded PHP snippet.
  • Fixed bug #833 : Squiz.PHP.EmbeddedPhp: incorrect indent calculation in certain specific situations.
  • Fixed bug #835 : Generic.PHP.DisallowShortOpenTag: don't act on parse errors.
  • Fixed bug #838 : Squiz.PHP.EmbeddedPhp: no new line before close tag was incorrectly enforced when a preceding OO construct or function had a trailing comment after the close curly.
  • Fixed bug #840 : Squiz.WhiteSpace.MemberVarSpacing: more accurate reporting on blank lines in the property "pre-amble" (i.e. docblock, attributes).
  • Fixed bug #845 : Squiz.Classes.ClassFileName: don't throw an incorrect error for an unfinished OO declaration during live coding.
  • Fixed bug #865 : Setting an array property to an empty array from an XML ruleset now works correctly.
  • Fixed bug #866 : Squiz.WhiteSpace.FunctionOpeningBraceSpace: XML docs were not accessible due to an issue with the file name.

Other

  • A new wiki page is available to clarify the difference between a project ruleset and an external standard.
    • This wiki page also contains detailed information about the naming conventions external standards must comply with.
  • A new XMLLint validate action runner is available which can be used in CI to validate rulesets for PHP_CodeSniffer against the XSD.

New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @asispts, @braindawg, @DanielEScherzer, @peterwilsoncc

Statistics

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!

3.11.3

Changed

  • Generic.ControlStructures.InlineControlStructure no longer unnecessarily listens for T_SWITCH tokens. #595
  • Squiz.Functions.FunctionDeclarationArgumentSpacing: improvements to error message for SpaceBeforeComma error. #783
  • The following sniff(s) have received efficiency improvements:
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • Fixed bug #620 : Squiz.Functions.FunctionDeclarationArgumentSpacing: newlines after type will now be handled by the fixer. This also prevents a potential fixer conflict.
  • Fixed bug #782 : Tokenizer/PHP: prevent an "Undefined array key" notice during live coding for unfinished arrow functions.
  • Fixed bug #783 : Squiz.Functions.FunctionDeclarationArgumentSpacing: new line after reference token was not flagged nor fixed.
  • Fixed bug #783 : Squiz.Functions.FunctionDeclarationArgumentSpacing: new line after variadic token was not flagged nor fixed.
  • Fixed bug #783 : Squiz.Functions.FunctionDeclarationArgumentSpacing: new line before/after the equal sign for default values was not flagged nor fixed when equalsSpacing was set to 0.
  • Fixed bug #783 : Squiz.Functions.FunctionDeclarationArgumentSpacing: fixer conflict when a new line is found before/after the equal sign for default values and equalsSpacing was set to 1.
  • Fixed bug #783 : Squiz.Functions.FunctionDeclarationArgumentSpacing: fixer for spacing before/after equal sign could inadvertently remove comment.
  • Fixed bug #783 : Squiz.Functions.FunctionDeclarationArgumentSpacing: fixer will now handle comments between the end of a parameter and a comma more cleanly.
  • Fixed bug #784 : Squiz.WhiteSpace.FunctionSpacing: prevent fixer conflict when a multi-line docblock would start on the same line as the function close curly being examined.

Statistics

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!

3.11.2

Changed

  • Generators/HTML + Markdown: the output will now be empty (no page header/footer) when there are no docs to display. #687
    • This is in line with the Text Generator which already didn't produce output if there are no docs.
    • Thanks to Juliette Reinders Folmer for the patch.
  • Generators/HTML: only display a Table of Contents when there is more than one sniff with documentation. #697
  • Generators/HTML: improved handling of line breaks in <standard> blocks. #723
  • Generators/Markdown: improved compatibility with the variety of available markdown parsers. #722
  • Generators/Markdown: improved handling of line breaks in <standard> blocks. #737
    • This prevents additional paragraphs from being displayed as code blocks.
    • Thanks to Juliette Reinders Folmer for the patch.
  • Generic.NamingConventions.UpperCaseConstantName: the exact token containing the non-uppercase constant name will now be identified with more accuracy. #665
  • Generic.Functions.OpeningFunctionBraceKernighanRitchie: minor improvement to the error message wording. #736
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • Fixed bug #527 : Squiz.Arrays.ArrayDeclaration: short lists within a foreach condition should be ignored.
  • Fixed bug #665 : Generic.NamingConventions.UpperCaseConstantName: false positives and false negatives when code uses unconventional spacing and comments when calling define().
  • Fixed bug #665 : Generic.NamingConventions.UpperCaseConstantName: false positive when a constant named DEFINE is encountered.
  • Fixed bug #665 : Generic.NamingConventions.UpperCaseConstantName: false positive for attribute class called define.
  • Fixed bug #665 : Generic.NamingConventions.UpperCaseConstantName: false positive when handling the instantiation of a class named define.
  • Fixed bug #688 : Generators/Markdown could leave error_reporting in an incorrect state.
  • Fixed bug #698 : Generators/Markdown : link in the documentation footer would not parse as a link.
  • Fixed bug #738 : Generators/Text: stray blank lines after code sample titles.
  • Fixed bug #739 : Generators/HTML + Markdown: multi-space whitespace within a code sample title was folded into a single space.

Other

  • On December 1st, one year after the repo was abandoned and revived, a retrospective of the past year was published for funders.
    • This retrospective is publicly available and also provides some insights into what's to come in the new year.

Statistics

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!

3.11.1

Changed

Fixed

  • Fixed bug #674 : Generic.WhiteSpace.HereNowdocIdentifierSpacing broken XML documentation
  • Fixed bug #675 : InvalidArgumentException when a ruleset includes a sniff by file name and the included sniff does not comply with the PHPCS naming conventions.
    • Notwithstanding this fix, it is strongly recommended to ensure custom sniff classes comply with the PHPCS naming conventions.
    • Thanks to Juliette Reinders Folmer for the patch.

New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @MatmaRex

Statistics

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!

3.11.0

Added

  • Runtime support for PHP 8.4. All known PHP 8.4 deprecation notices have been fixed.
    • Syntax support for new PHP 8.4 features will follow in a future release.
    • If you find any PHP 8.4 deprecation notices which were missed, please report them.
    • Thanks to Juliette Reinders Folmer for the patches.
  • Tokenizer support for PHP 8.3 "yield from" expressions with a comment between the keywords. #529, #647
    • Sniffs explicitly handling T_YIELD_FROM tokens may need updating. The PR description contains example code for use by sniff developers.
    • Additionally, the following sniff has been updated to support "yield from" expressions with comments:
      • Generic.WhiteSpace.LanguageConstructSpacing
    • Thanks to Juliette Reinders Folmer for the patch.
  • New Generic.WhiteSpace.HereNowdocIdentifierSpacing sniff. #586, #637
    • Forbid whitespace between the <<< and the identifier string in heredoc/nowdoc start tokens.
    • Thanks to Juliette Reinders Folmer for the patch.
  • New Generic.Strings.UnnecessaryHeredoc sniff. #633
    • Warns about heredocs without interpolation or expressions in the body text and can auto-fix these to nowdocs.
    • Thanks to Juliette Reinders Folmer for the patch.
  • Documentation for the following sniffs:

Changed

  • The Common::getSniffCode() method will now throw an InvalidArgumentException exception if an invalid $sniffClass is passed. #524, #625
  • Documentation generated using the --generator=... feature will now always be presented in natural order based on the sniff name(s). #668
  • Minor improvements to the display of runtime information. #658
  • Squiz.Commenting.PostStatementComment: trailing annotations in PHP files will now be reported under a separate, non-auto-fixable error code AnnotationFound. #560, #627
    • This prevents (tooling related) annotations from taking on a different meaning when moved by the fixer.
    • The separate error code also allows for selectively excluding it to prevent the sniff from triggering on trailing annotations, while still forbidding other trailing comments.
    • Thanks to Rodrigo Primo for the patch.
  • Squiz.ControlStructures.ForEachLoopDeclaration: the 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
  • The following sniff(s) have received efficiency improvements:
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • Fixed bug #3808 : Generic.WhiteSpace.ScopeIndent would throw false positive for tab indented multi-token yield from expression.
  • Fixed bug #630 : The tokenizer could inadvertently transform "normal" parentheses to DNF parentheses, when a function call was preceded by a switch-case / alternative syntax control structure colon.
  • Fixed bug #645 : On PHP 5.4, if yield was used as the declaration name for a function declared to return by reference, the function name would incorrectly be tokenized as T_YIELD instead of T_STRING.
  • Fixed bug #647 : Tokenizer not applying tab replacement in single token "yield from" keywords.
  • Fixed bug #647 : Generic.WhiteSpace.DisallowSpaceIndent did not flag space indentation in multi-line yield from.
  • Fixed bug #647 : Generic.WhiteSpace.DisallowTabIndent did not flag tabs inside yield from.
  • Fixed bug #652 : Generic.NamingConventions.ConstructorName: false positives for PHP-4 style calls to PHP-4 style parent constructor when a method with the same name as the parent class was called on another class.
  • Fixed bug #652 : Generic.NamingConventions.ConstructorName: false negatives for PHP-4 style calls to parent constructor for function calls with whitespace and comments in unconventional places.
  • Fixed bug #653 : Generic.Classes.DuplicateClassName : the sniff did not skip namespace keywords used as operators, which could lead to false positives.
  • Fixed bug #653 : Generic.Classes.DuplicateClassName : sniff going into an infinite loop during live coding.
  • Fixed bug #653 : Generic.Classes.DuplicateClassName : false positives/negatives when a namespace declaration contained whitespace or comments in unconventional places.
  • Fixed bug #653 : Generic.Classes.DuplicateClassName : namespace for a file going in/out of PHP was not remembered/applied correctly.

Statistics

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!

3.10.3

Changed

Fixed

  • Fixed bug #553 : Squiz.Classes.SelfMemberReference: false negative(s) when namespace operator was encountered between the namespace declaration and the OO declaration.
  • Fixed bug #579 : AbstractPatternSniff: potential PHP notice during live coding.
  • Fixed bug #580 : Squiz.Formatting.OperatorBracket: potential PHP notice during live coding.
  • Fixed bug #581 : PSR12.ControlStructures.ControlStructureSpacing: prevent fixer conflict by correctly handling multiple empty newlines before the first condition in a multi-line control structure.
  • Fixed bug #585 : Tokenizer not applying tab replacement in heredoc/nowdoc openers.
  • Fixed bug #588 : Squiz.PHP.EmbeddedPhp false positive when checking spaces after a PHP short open tag.
  • Fixed bug #597 : Generic.PHP.LowerCaseKeyword did not flag nor fix non-lowercase anonymous class keywords.
  • Fixed bug #598 : Squiz.PHP.DisallowMultipleAssignments: false positive on assignments to variable property on object stored in array.
  • Fixed bug #608 : Squiz.Functions.MultiLineFunctionDeclaration did not take (parameter) attributes into account when checking for one parameter per line.

Other


New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @maryo

Statistics

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!

3.10.2

Changed

Fixed

  • Fixed bug #513 : Generic.Functions.FunctionCallArgumentSpacing did not ignore the body of a match expressions passed as a function argument, which could lead to false positives.
  • Fixed bug #533 : Generic.WhiteSpace.DisallowTabIndent: tab indentation for heredoc/nowdoc closers will no longer be auto-fixed to prevent parse errors. The issue will still be reported.
    • The error code for heredoc/nowdoc indentation using tabs has been made more specific - TabsUsedHeredocCloser - to allow for selectively excluding the indentation check for heredoc/nowdoc closers.
    • Thanks to Juliette Reinders Folmer for the patch
  • Fixed bug #534 : Generic.WhiteSpace.DisallowSpaceIndent did not report on space indentation for PHP 7.3 flexible heredoc/nowdoc closers.
    • Closers using space indentation will be reported with a dedicated error code: SpacesUsedHeredocCloser.
    • Thanks to Juliette Reinders Folmer for the patch
  • Fixed bug #537 : Squiz.PHP.DisallowMultipleAssignments false positive for list assignments at the start of a new PHP block after an embedded PHP statement.
  • Fixed bug #551 : Squiz.PHP.DisallowMultipleAssignments prevent false positive for function parameters during live coding.
  • Fixed bug #554 : Generic.CodeAnalysis.UselessOverridingMethod edge case false negative when the call to the parent method would end on a PHP close tag.
  • Fixed bug #555 : Squiz.Classes.SelfMemberReference edge case false negative when the namespace declaration would end on a PHP close tag.

New Contributors

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.

Statistics

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

3.10.1

Added

  • Documentation for the following sniffs:
    • Generic.Commenting.DocComment
    • Thanks to Rodrigo Primo for the patch.

Changed

  • The following have received efficiency improvements:
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • Fixed bug #110, #437, #475: 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.
  • Fixed bug #504: The tokenizer could inadvertently mistake the last parameter in a function call using named arguments for a DNF type.
  • Fixed bug #508: Tokenizer/PHP: extra hardening against handling parse errors in the type handling layer.

Statistics

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

3.10.0

Added

  • Tokenizer support for PHP 8.2 Disjunctive Normal Form (DNF) types. #3731, #387, #461
    • Includes new T_TYPE_OPEN_PARENTHESIS and T_TYPE_CLOSE_PARENTHESIS tokens to represent the parentheses in DNF types.
    • These new tokens, like other parentheses, will have the parenthesis_opener and parenthesis_closer token array indexes set and the tokens between them will have the nested_parenthesis index.
    • The File::getMethodProperties(), File::getMethodParameters() and File::getMemberProperties() methods now all support DNF types. #471, #472, #473
    • Additionally, the following sniff has been updated to support DNF types:
      • Generic.PHP.LowerCaseType #478
    • Thanks to Juliette Reinders Folmer for the patches.
  • Documentation for the following sniffs:
    • Squiz.WhiteSpace.FunctionClosingBraceSpace
    • Thanks to Przemek Hernik for the patch.

Changed

Fixed

  • Fixed bug #466 : Generic.Functions.CallTimePassByReference was not flagging call-time pass-by-reference in class instantiations using the self/parent/static keywords.
  • Fixed bug #494 : edge case bug in tokenization of an empty block comment.
  • Fixed bug #494 : edge case bug in tokenization of an empty single-line DocBlock.
  • Fixed bug #499 : Generic.ControlStructures.InlineControlStructure now handles statements with a comment between else and if correctly.

New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @przemekhernik

Statistics

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

3.9.2

Changed

  • The Generic.ControlStructures.DisallowYodaConditions sniff no longer listens for the null coalesce operator. #458
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • Fixed bug #381 : Squiz.Commenting.ClosingDeclarationComment could throw the wrong error when the close brace being examined is at the very end of a file.
  • Fixed bug #385 : Generic.CodeAnalysis.JumbledIncrementer improved handling of parse errors/live coding.
  • Fixed bug #394 : Generic.Functions.CallTimePassByReference was not flagging call-time pass-by-reference in anonymous class instantiations
  • Fixed bug #420 : PEAR.Functions.FunctionDeclaration could run into a blocking PHP notice while fixing code containing a parse error.
  • Fixed bug #421 : File::getMethodProperties() small performance improvement & more defensive coding.
  • Fixed bug #423 : PEAR.WhiteSpace.ScopeClosingBrace would have a fixer conflict with itself when a close tag was preceded by non-empty inline HTML.
  • Fixed bug #424 : PSR2.Classes.ClassDeclaration using namespace relative interface names in the extends/implements part of a class declaration would lead to a fixer conflict.
  • Fixed bug #427 : Squiz.Operators.OperatorSpacing would have a fixer conflict with itself when an operator was preceeded by a new line and the previous line ended in a comment.
  • Fixed bug #430 : Squiz.ControlStructures.ForLoopDeclaration: fixed potential undefined array index notice
  • Fixed bug #431 : PSR2.Classes.ClassDeclaration will no longer try to auto-fix multi-line interface implements statements if these are interlaced with comments on their own line. This prevents a potential fixer conflict.
  • Fixed bug #453 : Arrow function tokenization was broken when the return type was a stand-alone true or false; or contained true or false as part of a union type.

Other

  • ESLint 9.0 has been released and changes the supported configuration file format. The (deprecated) 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.

Statistics

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!

3.9.1

Added

  • Documentation for the following sniffs:
    • Generic.PHP.RequireStrictTypes
    • Squiz.WhiteSpace.MemberVarSpacing
    • Squiz.WhiteSpace.ScopeClosingBrace
    • Squiz.WhiteSpace.SuperfluousWhitespace
    • Thanks to Jay McPartland and Rodrigo Primo for the patches.

Changed

  • The following sniffs have received performance related improvements:
    • Generic.CodeAnalysis.UselessOverridingMethod
    • Generic.Files.ByteOrderMark
    • Thanks to Rodrigo Primo for the patches.
  • Performance improvement for the "Diff" report. Should be most notable for Windows users. #355
  • The test suite has received some performance improvements. Should be most notable for contributors using Windows. #351
    • External standards with sniff tests using the PHP_CodeSniffer native test framework will also benefit from these changes.
    • Thanks to Juliette Reinders Folmer for the patch.
  • Various housekeeping, including improvements to the tests and documentation.

Fixed

  • Fixed bug #289 : Squiz.WhiteSpace.OperatorSpacing and PSR12.Operators.OperatorSpacing : improved fixer conflict protection by more strenuously avoiding handling operators in declare statements.
  • Fixed bug #366 : Generic.CodeAnalysis.UselessOverridingMethod : prevent false negative when the declared method name and the called method name do not use the same case.
  • Fixed bug #368 : Squiz.Arrays.ArrayDeclaration fixer did not handle static closures correctly when moving array items to their own line.
  • Fixed bug #404 : Test framework : fixed PHP 8.4 deprecation notice.

New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @jaymcp @jpoliveira08

Statistics

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).

3.9.0

Added

  • Tokenizer support for PHP 8.3 typed class constants. #321
    • Additionally, the following sniffs have been updated to support typed class constants:
      • Generic.NamingConventions.UpperCaseConstantName #332
      • Generic.PHP.LowerCaseConstant #330
      • Generic.PHP.LowerCaseType #331
    • Thanks to Juliette Reinders Folmer for the patches
  • Tokenizer support for PHP 8.3 readonly anonymous classes. #309
    • Additionally, the following sniffs have been updated to support readonly anonymous classes:
      • PSR12.Classes.ClassInstantiation #324
    • Thanks to Juliette Reinders Folmer for the patches
  • New PHP_CodeSniffer\Sniffs\DeprecatedSniff interface to allow for marking a sniff as deprecated. #281
    • If a ruleset uses deprecated sniffs, deprecation notices will be shown to the end-user before the scan starts. When running in -q (quiet) mode, the deprecation notices will be hidden.
    • Deprecated sniffs will still run and using them will have no impact on the exit code for a scan.
    • In ruleset "explain"-mode (-e) an asterix * will show next to deprecated sniffs.
    • Sniff maintainers are advised to read through the PR description for full details on how to use this feature for their own (deprecated) sniffs.
    • Thanks to Juliette Reinders Folmer for the patch
  • New Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence sniff. #197
    • Forbid mixing different binary boolean operators within a single expression without making precedence clear using parentheses
    • Thanks to Tim Düsterhus for the contribution
  • Squiz.PHP.EmbeddedPhp : the sniff will now also examine the formatting of embedded PHP statements using short open echo tags. #27
    • Includes a new ShortOpenEchoNoSemicolon errorcode to allow for selectively ignoring missing semicolons in single line embedded PHP snippets within short open echo tags.
    • The other error codes are the same and do not distinguish between what type of open tag was used.
    • Thanks to Juliette Reinders Folmer for the patch
  • Documentation for the following sniffs:
    • Generic.WhiteSpace.IncrementDecrementSpacing
    • PSR12.ControlStructures.ControlStructureSpacing
    • PSR12.Files.ImportStatement
    • PSR12.Functions.ReturnTypeDeclaration
    • PSR12.Properties.ConstantVisibility
    • Thanks to Denis Žoljom and Rodrigo Primo for the patches

Changed

  • The Performance report can now also be used for a phpcbf run. #308
  • Sniff tests which extend the PHPCS native 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
    • The warning is only displayed on PHPUnit 7.3.0 and higher.
    • The warning will be elevated to a test failure in PHPCS 4.0.
    • Thanks to Dan Wallis for the patch
  • The following sniffs have received performance related improvements:
  • Various housekeeping, including improvements to the tests and documentation

Deprecated

  • Support for scanning JavaScript and CSS files. See #2448.
    • This also means that all sniffs which are only aimed at JavaScript or CSS files are now deprecated.
    • The Javascript and CSS Tokenizers, all Javascript and CSS specific sniffs, and support for JS and CSS in select sniffs which support multiple file types, will be removed in version 4.0.0.
  • The abstract 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.
    • In version 4.0, these methods will be replaced with abstract ExactMatch::getDisallowedFiles() and ExactMatch::getAllowedFiles() methods
    • To make Filters extending ExactMatch cross-version compatible with both PHP_CodeSniffer 3.9.0+ as well as 4.0+, implement the new getDisallowedFiles() and getAllowedFiles() methods.
      • When both the getDisallowedFiles() and getAllowedFiles() methods as well as the getBlacklist() and getWhitelist() are available, the new methods will take precedence over the old methods.
    • Thanks to Juliette Reinders Folmer for the patch
  • The MySource standard and all sniffs in it. See #2471.
    • The MySource standard and all sniffs in it will be removed in version 4.0.0.
  • The Zend.Debug.CodeAnalyzer sniff. See #277.

Fixed

  • Fixed bug #127 : Squiz.Commenting.FunctionComment : The 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.
  • Fixed bug #196 : Squiz.PHP.EmbeddedPhp : fixer will no longer leave behind trailing whitespace when moving code to another line.
  • Fixed bug #196 : Squiz.PHP.EmbeddedPhp : will now determine the needed indent with higher precision in multiple situations.
  • Fixed bug #196 : Squiz.PHP.EmbeddedPhp : fixer will no longer insert a stray new line when the closer of a multi-line embedded PHP block and the opener of the next multi-line embedded PHP block would be on the same line.
  • Fixed bug #235 : Generic.CodeAnalysis.ForLoopWithTestFunctionCall : prevent a potential PHP 8.3 deprecation notice during live coding
  • Fixed bug #288 : Generic.WhiteSpace.IncrementDecrementSpacing : error message for post-in/decrement will now correctly inform about new lines found before the operator.
  • Fixed bug #296 : Generic.WhiteSpace.ArbitraryParenthesesSpacing : false positive for non-arbitrary parentheses when these follow the scope closer of a switch case.
  • Fixed bug #307 : PSR2.Classes.ClassDeclaration : space between a modifier keyword and the class keyword was not checked when the space included a new line or comment.
  • Fixed bug #325 : Squiz.Operators.IncrementDecrementUsage : the sniff was underreporting when there was (no) whitespace and/or comments in unexpected places.
  • Fixed bug #335 : PSR12.Files.DeclareStatement : bow out in a certain parse error situation to prevent incorrect auto-fixes from being made.
  • Fixed bug #340 : Squiz.Commenting.ClosingDeclarationComment : no longer adds a stray newline when adding a missing comment.

Other

  • A "Community cc list" has been introduced to ping maintainers of external standards and integrators for input regarding change proposals for PHP_CodeSniffer which may impact them. #227
    • For anyone who missed the discussion about this and is interested to be on this list, please feel invited to submit a PR to add yourself. The list is located in the .github folder.

New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @joachim-n, @remicollet, @TimWolla

Statistics

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!

3.8.1

Added

  • Documentation has been added for the following sniffs:
    • Generic.CodeAnalysis.EmptyPHPStatement
    • Generic.Formatting.SpaceBeforeCast
    • Generic.PHP.Syntax
    • Generic.WhiteSpace.LanguageConstructSpacing
    • PSR12.Classes.ClosingBrace
    • PSR12.Classes.OpeningBraceSpace
    • PSR12.ControlStructures.BooleanOperatorPlacement
    • PSR12.Files.OpenTag
    • Thanks to [Rodrigo Primo][@rodrigoprimo] and [Denis Žoljom][@dingo-d] for the patches

Changed

  • GitHub releases will now always only contain unversioned versions of the release assets (PHARS + asc files). See #205 for context.
    • Thanks to [Shivam Mathur][@shivammathur] for opening a discussion about this
  • Various housekeeping, includes improvements to the tests and documentation

Fixed

  • Fixed bug #124 : Report Full : avoid unnecessarily wrapping lines when -s is used
    • Thanks to [Brad Jorsch][@anomiex] for the patch
  • Fixed bug #124 : Report Full : fix incorrect bolding of pipes when -s is used and messages wraps
    • Thanks to [Brad Jorsch][@anomiex] for the patch
  • Fixed bug #150 : Squiz.WhiteSpace.KeywordSpacing : prevent a PHP notice when run during live coding
    • Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch
  • Fixed bug #154 : Report Full : delimiter line calculation could go wonky on wide screens when a report contains multi-line messages
    • Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch
  • Fixed bug #178 : Squiz.Commenting.VariableComment : docblocks were incorrectly being flagged as missing when a property declaration used PHP native union/intersection type declarations
    • Thanks to [Ferdinand Kuhl][@fcool] for the patch
  • Fixed bug #211 : Squiz.Commenting.VariableComment : docblocks were incorrectly being flagged as missing when a property declaration used PHP 8.2+ stand-alone true/false/null type declarations
    • Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch
  • Fixed bug #211 : Squiz.Commenting.VariableComment : docblocks were incorrectly being flagged as missing when a property declaration used PHP native parent, self or a namespace relative class name type declaration
    • Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch
  • Fixed bug #226 : Generic.CodeAnalysis.ForLoopShouldBeWhileLoop : prevent a potential PHP 8.3 deprecation notice during live coding

New Contributors

The PHP_CodeSniffer project is happy to welcome the following new contributors: @anomiex, @dingo-d, @fcool, @lucc, @rodrigoprimo

Statistics

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

3.8.0

Squizlabs/PHP_CodeSniffer is dead. Long live PHPCSStandards/PHP_CodeSniffer!

Breaking Changes

  • The 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.
    • Installation of PHP_CodeSniffer via PEAR is no longer supported.
      • Users will need to switch to another installation method.
      • Note: this does not affect the PEAR sniffs.
    • For Composer users, nothing changes.
      • In contrast to earlier information, the squizlabs/php_codesniffer package now points to the new repository and everything will continue to work as before.
    • PHIVE users may need to clear the PHIVE URL cache.
      • PHIVE users who don't use the package alias, but refer to the package URL, will need to update the URL from https://squizlabs.github.io/PHP_CodeSniffer/phars/ to https://phars.phpcodesniffer.com/phars/.
    • Users who download the PHAR files using curl or wget, will need to update the download URL from 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.
    • For users who install PHP_CodeSniffer via the setup-php action runner for GitHub Actions, nothing changes.
    • Users using a git clone will need to update the clone address from git@github.com:squizlabs/PHP_CodeSniffer.git to git@github.com:PHPCSStandards/PHP_CodeSniffer.git.
      • Contributors will need to fork the new repo and add both the new fork as well as the new repo as remotes to their local git copy of PHP_CodeSniffer.
      • Users who have (valid) open issues or pull requests in the squizlabs/PHP_CodeSniffer repository are invited to resubmit these to the PHPCSStandards/PHP_CodeSniffer repository.

Added

  • Runtime support for PHP 8.3. All known PHP 8.3 deprecation notices have been fixed
    • Syntax support for new PHP 8.3 features will follow in a future release
    • If you find any PHP 8.3 deprecation notices which were missed, please report them
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patches
  • Added support for PHP 8.2 readonly classes to File::getClassProperties() through a new is_readonly array index in the return value
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Added support for PHP 8.2 readonly classes to a number of sniffs
    • Generic.CodeAnalysis.UnnecessaryFinalModifier
    • PEAR.Commenting.ClassComment
    • PEAR.Commenting.FileComment
    • PSR1.Files.SideEffects
    • PSR2.Classes.ClassDeclaration
    • PSR12.Files.FileHeader
    • Squiz.Classes.ClassDeclaration
    • Squiz.Classes.LowercaseClassKeywords
    • Squiz.Commenting.ClassComment
    • Squiz.Commenting.DocCommentAlignment
    • Squiz.Commenting.FileComment
    • Squiz.Commenting.InlineComment
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Added support for PHP 8.2 true as a stand-alone type declaration
    • The File::getMethodProperties(), File::getMethodParameters() and File::getMemberProperties() methods now all support the true type
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Added support for PHP 8.2 true as a stand-alone type to a number of sniffs
    • Generic.PHP.LowerCaseType
    • PSr12.Functions.NullableTypeDeclaration
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Added a Performance report to allow for finding "slow" sniffs
    • To run this report, run PHPCS with --report=Performance.
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Generic.PHP.RequireStrictTypes : new warning for when there is a declare statement, but the strict_types directive is set to 0
    • The warning can be turned off by excluding the Generic.PHP.RequireStrictTypes.Disabled error code
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Squiz.Commenting.FunctionComment : new ParamNameUnexpectedAmpersandPrefix error for parameters annotated as passed by reference while the parameter is not passed by reference
    • Thanks to Dan Wallis (@fredden) for the patch
  • Documentation has been added for the following sniffs:
    • PSR2.Files.ClosingTag
    • PSR2.Methods.FunctionCallSignature
    • PSR2.Methods.FunctionClosingBrace
    • Thanks to Atsushi Okui (@blue32a) for the patch
  • Support for PHPUnit 8 and 9 to the test suite
    • Test suites for external standards which run via the PHPCS native test suite can now run on PHPUnit 4-9 (was 4-7)
    • If any of these tests use the PHPUnit setUp()/tearDown() methods or overload the setUp() in the AbstractSniffUnitTest test case, they will need to be adjusted. See the PR details for further information
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch

Changed

  • Changes have been made to the way PHPCS handles invalid sniff properties being set in a custom ruleset
    • Fixes PHP 8.2 deprecation notices for properties set in a (custom) ruleset for complete standards/complete sniff categories
    • Invalid sniff properties set for individual sniffs will now result in an error and halt the execution of PHPCS
      • A descriptive error message is provided to allow users to fix their ruleset
    • Sniff properties set for complete standards/complete sniff categories will now only be set on sniffs which explicitly support the property
      • The property will be silently ignored for those sniffs which do not support the property
    • Invalid sniff properties set for sniffs via inline annotations will result in an informative Internal.PropertyDoesNotExist errror on line 1 of the scanned file, but will not halt the execution of PHPCS
    • For sniff developers, it is strongly recommended for sniffs to explicitly declare any user-adjustable public properties
      • If dynamic properties need to be supported for a sniff, either declare the magic __set()/__get()/__isset()/__unset() methods on the sniff or let the sniff extend stdClass
      • Note: The #[\AllowDynamicProperties] attribute will have no effect for properties which are being set in rulesets
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • The third parameter for the Ruleset::setSniffProperty() method has been changed to expect an array
    • Sniff developers/integrators of PHPCS may need to make some small adjustments to allow for this change
    • Existing code will continue to work but will throw a deprecation error
    • The backwards compatiblity layer will be removed in PHPCS 4.0
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • When using auto report width (the default) a value of 80 columns will be used if the width cannot be determined
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Sniff error messages are now more informative to help bugs get reported to the correct project
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Generic.CodeAnalysis.UnusedFunctionParameter will now ignore magic methods for which the signature is defined by PHP
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Generic.Functions.OpeningFunctionBraceBsdAllman will now check the brace indent before the opening brace for empty functions
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Generic.Functions.OpeningFunctionBraceKernighanRitchie will now check the spacing before the opening brace for empty functions
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Generic.WhiteSpace.IncrementDecrementSpacing now detects more spacing issues
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • PSR2.Classes.PropertyDeclaration now enforces that the readonly modifier comes after the visibility modifier
    • PSR2 and PSR12 do not have documented rules for this as they pre-date the readonly modifier
    • PSR-PER has been used to confirm the order of this keyword so it can be applied to PSR2 and PSR12 correctly
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • PEAR.Commenting.FunctionComment + Squiz.Commenting.FunctionComment: the SpacingAfter error can now be auto-fixed
    • Thanks to Dan Wallis (@fredden) for the patch
  • Squiz.PHP.InnerFunctions sniff no longer reports on OO methods for OO structures declared within a function or closure
  • Squiz.PHP.NonExecutableCode will now also flag redundant return statements just before a closure close brace
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Runtime performance improvement for PHPCS CLI users. The improvement should be most noticeable for users on Windows.
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • The following sniffs have received performance related improvements:
    • Generic.PHP.LowerCaseConstant
    • Generic.PHP.LowerCaseType
    • PSR12.Files.OpenTag
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patches
  • The -e (explain) command will now list sniffs in natural order
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Tests using the PHPCS native test framework with multiple test case files will now run the test case files in numeric order.
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • The following sniffs have received minor message readability improvements:
    • Generic.Arrays.ArrayIndent
    • Generic.Formatting.SpaceAfterCast
    • Generic.Formatting.SpaceAfterNot
    • Generic.WhiteSpace.SpreadOperatorSpacingAfter
    • Squiz.Arrays.ArrayDeclaration
    • Squiz.Commenting.DocCommentAlignment
    • Squiz.ControlStructures.ControlSignature
    • Thanks to Danny van der Sluijs (@DannyvdSluijs) and Juliette Reinders Folmer (@jrfnl) for the patches
  • Improved README syntax highlighting
  • Various documentation improvements

Removed

  • Removed support for installation via PEAR
    • Use composer or the PHAR files instead

Fixed

  • Fixed bug #2857 : Squiz/NonExecutableCode: prevent false positives when exit is used in a ternary expression or as default with null coalesce
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3386 : PSR1/SideEffects : improved recognition of disable/enable annotations
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3557 : Squiz.Arrays.ArrayDeclaration will now ignore PHP 7.4 array unpacking when determining whether an array is associative
    • Thanks to Volker Dusch (@edorian) for the patch
  • Fixed bug #3592 : Squiz/NonExecutableCode: prevent false positives when a PHP 8.0+ inline throw expression is encountered
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3715 : Generic/UnusedFunctionParameter: fixed incorrect errorcode for closures/arrow functions nested within extended classes/classes which implement
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3717 : Squiz.Commenting.FunctionComment: fixed false positive for InvalidNoReturn when type is never
    • Thanks to Choraimy Kroonstuiver (@axlon) for the patch
  • Fixed bug #3720 : Generic/RequireStrictTypes : will now bow out silently in case of parse errors/live coding instead of throwing false positives/false negatives
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3720 : Generic/RequireStrictTypes : did not handle multi-directive declare statements
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3722 : Potential "Uninitialized string offset 1" in octal notation backfill
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3736 : PEAR/FunctionDeclaration: prevent fixer removing the close brace (and creating a parse error) when there is no space between the open brace and close brace of a function
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3739 : PEAR/FunctionDeclaration: prevent fixer conflict, and potentially creating a parse error, for unconventionally formatted return types
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3770 : Squiz/NonExecutableCode: prevent false positives for switching between PHP and HTML
    • Thanks to Dan Wallis (@fredden) for the patch
  • Fixed bug #3773 : Tokenizer/PHP: tokenization of the readonly keyword when used in combination with PHP 8.2 disjunctive normal types
    • Thanks to Dan Wallis (@fredden) and Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3776 : Generic/JSHint: error when JSHint is not available
    • Thanks to Dan Wallis (@fredden) for the patch
  • Fixed bug #3777 : Squiz/NonExecutableCode: slew of bug fixes, mostly related to modern PHP
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3778 : Squiz/LowercasePHPFunctions: bug fix for class names in attributes
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3779 : Generic/ForbiddenFunctions: bug fix for class names in attributes
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3785 : Squiz.Commenting.FunctionComment: potential "Uninitialized string offset 0" when a type contains a duplicate pipe symbol
    • Thanks to Dan Wallis (@fredden) for the patch
  • Fixed bug #3787 : PEAR/Squiz/[MultiLine]FunctionDeclaration: allow for PHP 8.1 new in initializers
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3789 : Incorrect tokenization for ternary operator with match inside of it
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3790 : PSR12/AnonClassDeclaration: prevent fixer creating parse error when there was no space before the open brace
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3797 : Tokenizer/PHP: more context sensitive keyword fixes
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3801 : File::getMethodParameters(): allow for readonly promoted properties without visibility
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3805 : Generic/FunctionCallArgumentSpacing: prevent fixer conflict over PHP 7.3+ trailing comma's in function calls
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3806 : Squiz.PHP.InnerFunctions sniff now correctly reports inner functions declared within a closure
  • Fixed bug #3809 : GitBlame report was broken when passing a basepath
  • Fixed bug #3813 : Squiz.Commenting.FunctionComment: false positive for parameter name mismatch on parameters annotated as passed by reference
    • Thanks to Dan Wallis (@fredden) for the patch
  • Fixed bug #3833 : Generic.PHP.LowerCaseType: fixed potential undefined array index notice
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3846 : PSR2.Classes.ClassDeclaration.CloseBraceAfterBody : fixer will no longer remove indentation on the close brace line
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3854 : Fatal error when using Gitblame report in combination with --basepath and running from project subdirectory
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3856 : PSR12.Traits.UseDeclaration was using the wrong error code - SpacingAfterAs - for spacing issues after the use keyword
    • These will now be reported using the SpacingAfterUse error code
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3856 : PSR12.Traits.UseDeclaration did not check spacing after use keyword for multi-line trait use statements
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3867 : Tokenizer/PHP: union type and intersection type operators were not correctly tokenized for static properties without explicit visibility
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3877 : Filter names can be case-sensitive. The -h help text will now display the correct case for the available filters
  • Fixed bug #3893 : Generic/DocComment : the SpacingAfterTagGroup fixer could accidentally remove ignore annotations
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3898 : Squiz/NonExecutableCode : the sniff could get confused over comments in unexpected places
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3904 : Squiz/FunctionSpacing : prevent potential fixer conflict
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3906 : Tokenizer/CSS: bug fix related to the unsupported slash comment syntax
    • Thanks to Dan Wallis (@fredden) for the patch
  • Fixed bug #3913 : Config did not always correctly store unknown "long" arguments in the $unknown property
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch

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.

3.7.2
  • Newer versions of Composer will now suggest installing PHPCS using require-dev instead of require
  • A custom Out Of Memory error will now be shown if PHPCS or PHPCBF run out of memory during a run
    • Error message provides actionable information about how to fix the problem and ensures the error is not silent
    • Thanks to Juliette Reinders Folmer (@jrfnl) and Alain Schlesser (@schlessera) for the patch
  • Generic.PHP.LowerCaseType sniff now correctly examines types inside arrow functions
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Squiz.Formatting.OperatorBracket no longer reports false positives in match() structures
  • Fixed bug #3616 : Squiz.PHP.DisallowComparisonAssignment false positive for PHP 8 match expression
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3618 : Generic.WhiteSpace.ArbitraryParenthesesSpacing false positive for return new parent()
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3632 : Short list not tokenized correctly in control structures without braces
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3639 : Tokenizer not applying tab replacement to heredoc/nowdoc closers
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3640 : Generic.WhiteSpace.DisallowTabIndent not reporting errors for PHP 7.3 flexible heredoc/nowdoc syntax
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3645 : PHPCS can show 0 exit code when running in parallel even if child process has fatal error
    • Thanks to Alex Panshin (@enl) for the patch
  • Fixed bug #3653 : False positives for match() in OperatorSpacingSniff
    • Thanks to Jaroslav Hanslík (@kukulich) for the patch
  • Fixed bug #3666 : PEAR.Functions.FunctionCallSignature incorrect indent fix when checking mixed HTML/PHP files
  • Fixed bug #3668 : PSR12.Classes.ClassInstantiation.MissingParentheses false positive when instantiating parent classes
    • Similar issues also fixed in Generic.Functions.FunctionCallArgumentSpacing and Squiz.Formatting.OperatorBracket
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3672 : Incorrect ScopeIndent.IncorrectExact report for match inside array literal
  • Fixed bug #3694 : Generic.WhiteSpace.SpreadOperatorSpacingAfter does not ignore spread operator in PHP 8.1 first class callables
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
3.7.1
  • Fixed bug #3609: Methods/constants with name empty/isset/unset are always reported as error
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
3.7.0

PHP 8.1 Language Feature Support

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:

  • Enums
  • Explicit octal notation
  • Readonly properties
  • Intersection types
  • The never type

Note: 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.1 explicit octal notation
    • This new syntax has been backfilled for PHP versions less than 8.1
    • Thanks to Mark Baker (@MarkBaker) for the patch
    • Thanks to Juliette Reinders Folmer (@jrfnl) for additional fixes
  • Added support for PHP 8.1 enums
    • This new syntax has been backfilled for PHP versions less than 8.1
    • Includes a new T_ENUM_CASE token to represent the case statements inside an enum
    • Thanks to Jaroslav Hanslík (@kukulich) for the patch
    • Thanks to Juliette Reinders Folmer (@jrfnl) for additional core and sniff support
  • Added support for the PHP 8.1 readonly token
    • Tokenzing of the readonly keyword has been backfilled for PHP versions less than 8.1
    • Thanks to Jaroslav Hanslík (@kukulich) for the patch
  • Added support for PHP 8.1 intersection types
    • Includes a new T_TYPE_INTERSECTION token to represent the ampersand character inside intersection types
    • Thanks to Jaroslav Hanslík (@kukulich) for the patch
  • File::getMethodParameters now supports the new PHP 8.1 readonly token
    • When constructor property promotion is used, a new property_readonly array index is included in the return value
      • This is a boolean value indicating if the property is readonly
    • If the readonly token is detected, a new readonly_token array index is included in the return value
      • This contains the token index of the readonly keyword
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Support for new PHP 8.1 readonly keyword has been added to the following sniffs:
    • Generic.PHP.LowerCaseKeyword
    • PSR2.Classes.PropertyDeclaration
    • Squiz.Commenting.BlockComment
    • Squiz.Commenting.DocCommentAlignment
    • Squiz.Commenting.VariableComment
    • Squiz.WhiteSpace.ScopeKeywordSpacing
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patches
  • The parallel feature is now more efficient and runs faster in some situations due to improved process management
    • Thanks to Sergei Morozov (@morozov) for the patch
  • The list of installed coding standards now has consistent ordering across all platforms
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Generic.PHP.UpperCaseConstant and Generic.PHP.LowerCaseConstant now ignore type declarations
    • These sniffs now only report errors for true/false/null when used as values
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Generic.PHP.LowerCaseType now supports the PHP 8.1 never type
    • Thanks to Jaroslav Hanslík (@kukulich) for the patch
  • Fixed bug #3502 : A match statement within an array produces Squiz.Arrays.ArrayDeclaration.NoKeySpecified
  • Fixed bug #3503 : Squiz.Commenting.FunctionComment.ThrowsNoFullStop false positive when one line [@throw](https://github.com/throw)
  • Fixed bug #3505 : The nullsafe operator is not counted in Generic.Metrics.CyclomaticComplexity
  • Fixed bug #3526 : PSR12.Properties.ConstantVisibility false positive when using public final const syntax
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3530 : Line indented incorrectly false positive when using match-expression inside switch case
  • Fixed bug #3534 : Name of typed enum tokenized as T_GOTO_LABEL
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3546 : Tokenizer/PHP: bug fix - parent/static keywords in class instantiations
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3550 : False positive from PSR2.ControlStructures.SwitchDeclaration.TerminatingComment when using trailing comment
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3575: Squiz.Scope.MethodScope misses visibility keyword on previous line
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3604: Tokenizer/PHP: bug fix for double quoted strings using ${
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
3.6.2
  • Processing large code bases that use tab indenting inside comments and strings will now be faster
  • Fixed bug #3388 : phpcs does not work when run from WSL drives
    • Thanks to Juliette Reinders Folmer (@jrfnl) and Graham Wharton (@gwharton) for the patch
  • Fixed bug #3422 : Squiz.WhiteSpace.ScopeClosingBrace fixer removes HTML content when fixing closing brace alignment
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3437 : PSR12 does not forbid blank lines at the start of the class body
    • Added new PSR12.Classes.OpeningBraceSpace sniff to enforce this
  • Fixed bug #3440 : Squiz.WhiteSpace.MemberVarSpacing false positives when attributes used without docblock
    • Thanks to Vadim Borodavko (@javer) for the patch
  • Fixed bug #3448 : PHP 8.1 deprecation notice while generating running time value
    • Thanks to Juliette Reinders Folmer (@jrfnl) and Andy Postnikov (@andypost) for the patch
  • Fixed bug #3456 : PSR12.Classes.ClassInstantiation.MissingParentheses false positive using attributes on anonymous class
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3460 : Generic.Formatting.MultipleStatementAlignment false positive on closure with parameters
    • Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
  • Fixed bug #3468 : do/while loops are double-counted in Generic.Metrics.CyclomaticComplexity
  • Fixed bug #3469 : Ternary Operator and Null Coalescing Operator are not counted in Generic.Metrics.CyclomaticComplexity
  • Fixed bug #3472 : PHP 8 match() expression is not counted in Generic.Metrics.CyclomaticComplexity
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport