From 97d94c29773b2407e6bcdd14bcd2cb60f56fc773 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 7 Nov 2023 00:09:34 +0100 Subject: [PATCH 001/874] GH Actions: update workflows --- .github/workflows/manage-labels.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/manage-labels.yml b/.github/workflows/manage-labels.yml index f2b074e8c2..e3229cd7c4 100644 --- a/.github/workflows/manage-labels.yml +++ b/.github/workflows/manage-labels.yml @@ -12,7 +12,7 @@ on: jobs: on-issue-close: runs-on: ubuntu-latest - if: github.repository_owner == 'squizlabs' && github.event.issue.state == 'closed' + if: github.repository_owner == 'PHPCSStandards' && github.event.issue.state == 'closed' name: Clean up labels on issue close @@ -28,7 +28,7 @@ jobs: on-pr-merge: runs-on: ubuntu-latest - if: github.repository_owner == 'squizlabs' && github.event.pull_request.merged == true + if: github.repository_owner == 'PHPCSStandards' && github.event.pull_request.merged == true name: Clean up labels on PR merge @@ -44,7 +44,7 @@ jobs: on-pr-close: runs-on: ubuntu-latest - if: github.repository_owner == 'squizlabs' && github.event_name == 'pull_request_target' && github.event.pull_request.merged == false + if: github.repository_owner == 'PHPCSStandards' && github.event_name == 'pull_request_target' && github.event.pull_request.merged == false name: Clean up labels on PR close From f6dc841498ab8b056ba0bb8f6785ed634700b34e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 7 Nov 2023 00:08:33 +0100 Subject: [PATCH 002/874] Composer: update package name ... and indicate that this package replaces `squizlabs/php_codesniffer`. --- README.md | 6 +++--- composer.json | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 859de432c6..b74227b929 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,16 @@ php phpcbf.phar -h ### Composer If you use Composer, you can install PHP_CodeSniffer system-wide with the following command: ```bash -composer global require "squizlabs/php_codesniffer=*" +composer global require "phpcsstandards/php_codesniffer=*" ``` Make sure you have the composer bin dir in your PATH. The default value is `~/.composer/vendor/bin/`, but you can check the value that you need to use by running `composer global config bin-dir --absolute`. -Or alternatively, include a dependency for `squizlabs/php_codesniffer` in your `composer.json` file. For example: +Or alternatively, include a dependency for `phpcsstandards/php_codesniffer` in your `composer.json` file. For example: ```json { "require-dev": { - "squizlabs/php_codesniffer": "3.*" + "phpcsstandards/php_codesniffer": "^3.0" } } ``` diff --git a/composer.json b/composer.json index 37f41a0b80..0e6c53315f 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "squizlabs/php_codesniffer", + "name": "phpcsstandards/php_codesniffer", "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", "type": "library", "keywords": [ @@ -34,6 +34,9 @@ "require-dev": { "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, + "replace": { + "squizlabs/php_codesniffer": "> 2.0" + }, "bin": [ "bin/phpcs", "bin/phpcbf" From 41b0e05ec10268a9d9107c65aaf81193557cf699 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 7 Nov 2023 00:09:48 +0100 Subject: [PATCH 003/874] Composer: update repo address --- composer.json | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 0e6c53315f..3a0b91aecf 100644 --- a/composer.json +++ b/composer.json @@ -7,18 +7,26 @@ "standards", "static analysis" ], - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "license": "BSD-3-Clause", "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name" : "Contributors", + "homepage" : "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki", - "source": "https://github.com/squizlabs/PHP_CodeSniffer" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer" }, "extra": { "branch-alias": { From c071f8138be2969a36ad20274068eab0cf17fe5e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 7 Nov 2023 00:18:54 +0100 Subject: [PATCH 004/874] README: remove link to analysis reports The analysis reports are currently very out-of-date, with the last update having been run in February 2018. I'm not (yet) sure whether those will be republished. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b74227b929..eca5c472c0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ PHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokeni [![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Validate/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions) [![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Test/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions) -[![Code consistency](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer/grade.svg)](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer) [![Join the chat at https://gitter.im/squizlabs/PHP_CodeSniffer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/squizlabs/PHP_CodeSniffer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Requirements From 7f9983fe659c019a1a74966c1e00b020bcbe5d59 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 7 Nov 2023 00:20:10 +0100 Subject: [PATCH 005/874] README: remove Gitter badge For the time being, I have no intention of registering the PHPCSStandards organisation/this repo with Gitter. For now, discussions will have to do. This may be revisited in the future. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index eca5c472c0..509218b92c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ PHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokeni [![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Validate/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions) [![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Test/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions) -[![Join the chat at https://gitter.im/squizlabs/PHP_CodeSniffer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/squizlabs/PHP_CodeSniffer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Requirements From c855348766a424d23425eba5cc4420e26e4a3e38 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 7 Nov 2023 00:11:33 +0100 Subject: [PATCH 006/874] Update repo references everywhere ... with the exception of issue/PR links as those should still point to the old location. --- README.md | 16 ++++++++-------- autoload.php | 2 +- bin/phpcbf | 2 +- bin/phpcbf.bat | 2 +- bin/phpcs | 2 +- bin/phpcs.bat | 2 +- scripts/build-phar.php | 2 +- src/Config.php | 2 +- src/Exceptions/DeepExitException.php | 2 +- src/Exceptions/RuntimeException.php | 2 +- src/Exceptions/TokenizerException.php | 2 +- src/Files/DummyFile.php | 2 +- src/Files/File.php | 2 +- src/Files/FileList.php | 2 +- src/Files/LocalFile.php | 2 +- src/Filters/ExactMatch.php | 2 +- src/Filters/Filter.php | 2 +- src/Filters/GitModified.php | 2 +- src/Filters/GitStaged.php | 2 +- src/Fixer.php | 2 +- src/Generators/Generator.php | 2 +- src/Generators/HTML.php | 4 ++-- src/Generators/Markdown.php | 4 ++-- src/Generators/Text.php | 2 +- src/Reporter.php | 2 +- src/Reports/Cbf.php | 2 +- src/Reports/Checkstyle.php | 2 +- src/Reports/Code.php | 2 +- src/Reports/Csv.php | 2 +- src/Reports/Diff.php | 2 +- src/Reports/Emacs.php | 2 +- src/Reports/Full.php | 2 +- src/Reports/Gitblame.php | 2 +- src/Reports/Hgblame.php | 2 +- src/Reports/Info.php | 2 +- src/Reports/Json.php | 2 +- src/Reports/Junit.php | 2 +- src/Reports/Notifysend.php | 2 +- src/Reports/Report.php | 2 +- src/Reports/Source.php | 2 +- src/Reports/Summary.php | 2 +- src/Reports/Svnblame.php | 2 +- src/Reports/VersionControl.php | 2 +- src/Reports/Xml.php | 2 +- src/Ruleset.php | 2 +- src/Runner.php | 2 +- src/Sniffs/AbstractArraySniff.php | 2 +- src/Sniffs/AbstractPatternSniff.php | 2 +- src/Sniffs/AbstractScopeSniff.php | 2 +- src/Sniffs/AbstractVariableSniff.php | 2 +- src/Sniffs/Sniff.php | 2 +- .../Generic/Sniffs/Arrays/ArrayIndentSniff.php | 2 +- .../Arrays/DisallowLongArraySyntaxSniff.php | 2 +- .../Arrays/DisallowShortArraySyntaxSniff.php | 2 +- .../Sniffs/Classes/DuplicateClassNameSniff.php | 2 +- .../Sniffs/Classes/OpeningBraceSameLineSniff.php | 2 +- .../CodeAnalysis/AssignmentInConditionSniff.php | 2 +- .../CodeAnalysis/EmptyPHPStatementSniff.php | 2 +- .../Sniffs/CodeAnalysis/EmptyStatementSniff.php | 2 +- .../ForLoopShouldBeWhileLoopSniff.php | 2 +- .../ForLoopWithTestFunctionCallSniff.php | 2 +- .../CodeAnalysis/JumbledIncrementerSniff.php | 2 +- .../UnconditionalIfStatementSniff.php | 2 +- .../UnnecessaryFinalModifierSniff.php | 2 +- .../UnusedFunctionParameterSniff.php | 2 +- .../UselessOverridingMethodSniff.php | 2 +- .../Sniffs/Commenting/DocCommentSniff.php | 2 +- .../Generic/Sniffs/Commenting/FixmeSniff.php | 2 +- .../Generic/Sniffs/Commenting/TodoSniff.php | 2 +- .../DisallowYodaConditionsSniff.php | 2 +- .../InlineControlStructureSniff.php | 2 +- .../Generic/Sniffs/Debug/CSSLintSniff.php | 2 +- .../Generic/Sniffs/Debug/ClosureLinterSniff.php | 2 +- .../Generic/Sniffs/Debug/ESLintSniff.php | 2 +- .../Generic/Sniffs/Debug/JSHintSniff.php | 2 +- .../Generic/Sniffs/Files/ByteOrderMarkSniff.php | 2 +- .../Generic/Sniffs/Files/EndFileNewlineSniff.php | 2 +- .../Sniffs/Files/EndFileNoNewlineSniff.php | 2 +- .../Generic/Sniffs/Files/ExecutableFileSniff.php | 2 +- .../Generic/Sniffs/Files/InlineHTMLSniff.php | 2 +- .../Generic/Sniffs/Files/LineEndingsSniff.php | 2 +- .../Generic/Sniffs/Files/LineLengthSniff.php | 2 +- .../Sniffs/Files/LowercasedFilenameSniff.php | 2 +- .../Sniffs/Files/OneClassPerFileSniff.php | 2 +- .../Sniffs/Files/OneInterfacePerFileSniff.php | 2 +- .../Files/OneObjectStructurePerFileSniff.php | 2 +- .../Sniffs/Files/OneTraitPerFileSniff.php | 2 +- .../DisallowMultipleStatementsSniff.php | 2 +- .../MultipleStatementAlignmentSniff.php | 2 +- .../Sniffs/Formatting/NoSpaceAfterCastSniff.php | 2 +- .../Sniffs/Formatting/SpaceAfterCastSniff.php | 2 +- .../Sniffs/Formatting/SpaceAfterNotSniff.php | 2 +- .../Sniffs/Formatting/SpaceBeforeCastSniff.php | 2 +- .../Functions/CallTimePassByReferenceSniff.php | 2 +- .../FunctionCallArgumentSpacingSniff.php | 2 +- .../OpeningFunctionBraceBsdAllmanSniff.php | 2 +- ...OpeningFunctionBraceKernighanRitchieSniff.php | 2 +- .../Sniffs/Metrics/CyclomaticComplexitySniff.php | 2 +- .../Generic/Sniffs/Metrics/NestingLevelSniff.php | 2 +- .../AbstractClassNamePrefixSniff.php | 2 +- .../CamelCapsFunctionNameSniff.php | 2 +- .../NamingConventions/ConstructorNameSniff.php | 2 +- .../InterfaceNameSuffixSniff.php | 2 +- .../NamingConventions/TraitNameSuffixSniff.php | 2 +- .../UpperCaseConstantNameSniff.php | 2 +- .../Generic/Sniffs/PHP/BacktickOperatorSniff.php | 2 +- .../PHP/CharacterBeforePHPOpeningTagSniff.php | 2 +- .../Generic/Sniffs/PHP/ClosingPHPTagSniff.php | 2 +- .../Sniffs/PHP/DeprecatedFunctionsSniff.php | 2 +- .../PHP/DisallowAlternativePHPTagsSniff.php | 2 +- .../PHP/DisallowRequestSuperglobalSniff.php | 2 +- .../Sniffs/PHP/DisallowShortOpenTagSniff.php | 2 +- .../Generic/Sniffs/PHP/DiscourageGotoSniff.php | 2 +- .../Sniffs/PHP/ForbiddenFunctionsSniff.php | 2 +- .../Sniffs/PHP/LowerCaseConstantSniff.php | 2 +- .../Generic/Sniffs/PHP/LowerCaseKeywordSniff.php | 2 +- .../Generic/Sniffs/PHP/LowerCaseTypeSniff.php | 2 +- .../Generic/Sniffs/PHP/NoSilencedErrorsSniff.php | 2 +- .../Sniffs/PHP/RequireStrictTypesSniff.php | 2 +- .../Generic/Sniffs/PHP/SAPIUsageSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php | 2 +- .../Sniffs/PHP/UpperCaseConstantSniff.php | 2 +- .../Strings/UnnecessaryStringConcatSniff.php | 2 +- .../VersionControl/GitMergeConflictSniff.php | 2 +- .../VersionControl/SubversionPropertiesSniff.php | 2 +- .../ArbitraryParenthesesSpacingSniff.php | 2 +- .../WhiteSpace/DisallowSpaceIndentSniff.php | 2 +- .../Sniffs/WhiteSpace/DisallowTabIndentSniff.php | 2 +- .../IncrementDecrementSpacingSniff.php | 2 +- .../WhiteSpace/LanguageConstructSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/ScopeIndentSniff.php | 2 +- .../SpreadOperatorSpacingAfterSniff.php | 2 +- .../Generic/Tests/Arrays/ArrayIndentUnitTest.php | 2 +- .../Arrays/DisallowLongArraySyntaxUnitTest.php | 2 +- .../Arrays/DisallowShortArraySyntaxUnitTest.php | 2 +- .../Tests/Classes/DuplicateClassNameUnitTest.php | 2 +- .../Classes/OpeningBraceSameLineUnitTest.php | 2 +- .../AssignmentInConditionUnitTest.php | 2 +- .../CodeAnalysis/EmptyPHPStatementUnitTest.php | 2 +- .../CodeAnalysis/EmptyStatementUnitTest.php | 2 +- .../ForLoopShouldBeWhileLoopUnitTest.php | 2 +- .../ForLoopWithTestFunctionCallUnitTest.php | 2 +- .../CodeAnalysis/JumbledIncrementerUnitTest.php | 2 +- .../UnconditionalIfStatementUnitTest.php | 2 +- .../UnnecessaryFinalModifierUnitTest.php | 2 +- .../UnusedFunctionParameterUnitTest.php | 2 +- .../UselessOverridingMethodUnitTest.php | 2 +- .../Tests/Commenting/DocCommentUnitTest.inc | 6 +++--- .../Commenting/DocCommentUnitTest.inc.fixed | 6 +++--- .../Tests/Commenting/DocCommentUnitTest.js | 6 +++--- .../Tests/Commenting/DocCommentUnitTest.js.fixed | 6 +++--- .../Tests/Commenting/DocCommentUnitTest.php | 2 +- .../Generic/Tests/Commenting/FixmeUnitTest.php | 2 +- .../Generic/Tests/Commenting/TodoUnitTest.php | 2 +- .../DisallowYodaConditionsUnitTest.php | 2 +- .../InlineControlStructureUnitTest.php | 2 +- .../Generic/Tests/Debug/CSSLintUnitTest.php | 2 +- .../Tests/Debug/ClosureLinterUnitTest.php | 2 +- .../Generic/Tests/Debug/ESLintUnitTest.php | 2 +- .../Generic/Tests/Debug/JSHintUnitTest.php | 2 +- .../Tests/Files/ByteOrderMarkUnitTest.php | 2 +- .../Tests/Files/EndFileNewlineUnitTest.php | 2 +- .../Tests/Files/EndFileNoNewlineUnitTest.php | 2 +- .../Tests/Files/ExecutableFileUnitTest.php | 2 +- .../Generic/Tests/Files/InlineHTMLUnitTest.php | 2 +- .../Generic/Tests/Files/LineEndingsUnitTest.php | 2 +- .../Generic/Tests/Files/LineLengthUnitTest.php | 2 +- .../Tests/Files/LowercasedFilenameUnitTest.php | 2 +- .../Tests/Files/OneClassPerFileUnitTest.php | 2 +- .../Tests/Files/OneInterfacePerFileUnitTest.php | 2 +- .../Files/OneObjectStructurePerFileUnitTest.php | 2 +- .../Tests/Files/OneTraitPerFileUnitTest.php | 2 +- .../DisallowMultipleStatementsUnitTest.php | 2 +- .../MultipleStatementAlignmentUnitTest.php | 2 +- .../Formatting/NoSpaceAfterCastUnitTest.php | 2 +- .../Tests/Formatting/SpaceAfterCastUnitTest.php | 2 +- .../Tests/Formatting/SpaceAfterNotUnitTest.php | 2 +- .../Tests/Formatting/SpaceBeforeCastUnitTest.php | 2 +- .../CallTimePassByReferenceUnitTest.php | 2 +- .../FunctionCallArgumentSpacingUnitTest.php | 2 +- .../OpeningFunctionBraceBsdAllmanUnitTest.php | 2 +- ...ningFunctionBraceKernighanRitchieUnitTest.php | 2 +- .../Metrics/CyclomaticComplexityUnitTest.php | 2 +- .../Tests/Metrics/NestingLevelUnitTest.php | 2 +- .../AbstractClassNamePrefixUnitTest.php | 2 +- .../CamelCapsFunctionNameUnitTest.php | 2 +- .../ConstructorNameUnitTest.php | 2 +- .../InterfaceNameSuffixUnitTest.php | 2 +- .../TraitNameSuffixUnitTest.php | 2 +- .../UpperCaseConstantNameUnitTest.php | 2 +- .../Tests/PHP/BacktickOperatorUnitTest.php | 2 +- .../PHP/CharacterBeforePHPOpeningTagUnitTest.php | 2 +- .../Generic/Tests/PHP/ClosingPHPTagUnitTest.php | 2 +- .../Tests/PHP/DeprecatedFunctionsUnitTest.php | 2 +- .../PHP/DisallowAlternativePHPTagsUnitTest.php | 2 +- .../PHP/DisallowRequestSuperglobalUnitTest.php | 2 +- .../Tests/PHP/DisallowShortOpenTagUnitTest.php | 2 +- .../Generic/Tests/PHP/DiscourageGotoUnitTest.php | 2 +- .../Tests/PHP/ForbiddenFunctionsUnitTest.php | 2 +- .../Tests/PHP/LowerCaseConstantUnitTest.php | 2 +- .../Tests/PHP/LowerCaseKeywordUnitTest.php | 2 +- .../Generic/Tests/PHP/LowerCaseTypeUnitTest.php | 2 +- .../Tests/PHP/NoSilencedErrorsUnitTest.php | 2 +- .../Tests/PHP/RequireStrictTypesUnitTest.php | 2 +- .../Generic/Tests/PHP/SAPIUsageUnitTest.php | 2 +- .../Generic/Tests/PHP/SyntaxUnitTest.php | 2 +- .../Tests/PHP/UpperCaseConstantUnitTest.php | 2 +- .../Strings/UnnecessaryStringConcatUnitTest.php | 2 +- .../VersionControl/GitMergeConflictUnitTest.php | 2 +- .../SubversionPropertiesUnitTest.php | 2 +- .../ArbitraryParenthesesSpacingUnitTest.php | 2 +- .../WhiteSpace/DisallowSpaceIndentUnitTest.php | 2 +- .../WhiteSpace/DisallowTabIndentUnitTest.php | 2 +- .../IncrementDecrementSpacingUnitTest.php | 2 +- .../LanguageConstructSpacingUnitTest.php | 2 +- .../Tests/WhiteSpace/ScopeIndentUnitTest.php | 2 +- .../SpreadOperatorSpacingAfterUnitTest.php | 2 +- .../Sniffs/CSS/BrowserSpecificStylesSniff.php | 2 +- .../Sniffs/Channels/DisallowSelfActionsSniff.php | 2 +- .../Sniffs/Channels/IncludeOwnSystemSniff.php | 2 +- .../Sniffs/Channels/IncludeSystemSniff.php | 2 +- .../Sniffs/Channels/UnusedSystemSniff.php | 2 +- .../Sniffs/Commenting/FunctionCommentSniff.php | 2 +- .../MySource/Sniffs/Debug/DebugCodeSniff.php | 2 +- .../Sniffs/Debug/FirebugConsoleSniff.php | 2 +- .../MySource/Sniffs/Objects/AssignThisSniff.php | 2 +- .../Objects/CreateWidgetTypeCallbackSniff.php | 2 +- .../Sniffs/Objects/DisallowNewWidgetSniff.php | 2 +- .../Sniffs/PHP/AjaxNullComparisonSniff.php | 2 +- .../Sniffs/PHP/EvalObjectFactorySniff.php | 2 +- .../MySource/Sniffs/PHP/GetRequestDataSniff.php | 2 +- .../Sniffs/PHP/ReturnFunctionValueSniff.php | 2 +- .../MySource/Sniffs/Strings/JoinStringsSniff.php | 2 +- .../Tests/CSS/BrowserSpecificStylesUnitTest.php | 2 +- .../Channels/DisallowSelfActionsUnitTest.php | 2 +- .../Tests/Channels/IncludeSystemUnitTest.php | 2 +- .../Tests/Channels/UnusedSystemUnitTest.php | 2 +- .../Tests/Commenting/FunctionCommentUnitTest.php | 2 +- .../MySource/Tests/Debug/DebugCodeUnitTest.php | 2 +- .../Tests/Debug/FirebugConsoleUnitTest.php | 2 +- .../Tests/Objects/AssignThisUnitTest.php | 2 +- .../Objects/CreateWidgetTypeCallbackUnitTest.php | 2 +- .../Tests/Objects/DisallowNewWidgetUnitTest.php | 2 +- .../Tests/PHP/AjaxNullComparisonUnitTest.php | 2 +- .../Tests/PHP/EvalObjectFactoryUnitTest.php | 2 +- .../Tests/PHP/GetRequestDataUnitTest.php | 2 +- .../Tests/PHP/ReturnFunctionValueUnitTest.php | 2 +- .../Tests/Strings/JoinStringsUnitTest.php | 2 +- .../Sniffs/Classes/ClassDeclarationSniff.php | 2 +- .../PEAR/Sniffs/Commenting/ClassCommentSniff.php | 2 +- .../PEAR/Sniffs/Commenting/FileCommentSniff.php | 2 +- .../Sniffs/Commenting/FunctionCommentSniff.php | 2 +- .../Sniffs/Commenting/InlineCommentSniff.php | 2 +- .../ControlStructures/ControlSignatureSniff.php | 2 +- .../MultiLineConditionSniff.php | 2 +- .../PEAR/Sniffs/Files/IncludingFileSniff.php | 2 +- .../Formatting/MultiLineAssignmentSniff.php | 2 +- .../Functions/FunctionCallSignatureSniff.php | 2 +- .../Functions/FunctionDeclarationSniff.php | 2 +- .../Sniffs/Functions/ValidDefaultValueSniff.php | 2 +- .../NamingConventions/ValidClassNameSniff.php | 2 +- .../NamingConventions/ValidFunctionNameSniff.php | 2 +- .../NamingConventions/ValidVariableNameSniff.php | 2 +- .../WhiteSpace/ObjectOperatorIndentSniff.php | 2 +- .../Sniffs/WhiteSpace/ScopeClosingBraceSniff.php | 2 +- .../PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php | 2 +- .../Tests/Classes/ClassDeclarationUnitTest.php | 2 +- .../Tests/Commenting/ClassCommentUnitTest.inc | 8 ++++---- .../Tests/Commenting/ClassCommentUnitTest.php | 2 +- .../Tests/Commenting/FileCommentUnitTest.php | 2 +- .../Tests/Commenting/FunctionCommentUnitTest.php | 2 +- .../Tests/Commenting/InlineCommentUnitTest.php | 2 +- .../ControlSignatureUnitTest.php | 2 +- .../MultiLineConditionUnitTest.php | 2 +- .../PEAR/Tests/Files/IncludingFileUnitTest.php | 2 +- .../Formatting/MultiLineAssignmentUnitTest.php | 2 +- .../Functions/FunctionCallSignatureUnitTest.php | 2 +- .../Functions/FunctionDeclarationUnitTest.php | 2 +- .../Functions/ValidDefaultValueUnitTest.php | 2 +- .../NamingConventions/ValidClassNameUnitTest.php | 2 +- .../ValidFunctionNameUnitTest.php | 2 +- .../ValidVariableNameUnitTest.php | 2 +- .../WhiteSpace/ObjectOperatorIndentUnitTest.php | 2 +- .../WhiteSpace/ScopeClosingBraceUnitTest.php | 2 +- .../Tests/WhiteSpace/ScopeIndentUnitTest.php | 2 +- .../Sniffs/Classes/ClassDeclarationSniff.php | 2 +- .../PSR1/Sniffs/Files/SideEffectsSniff.php | 2 +- .../Sniffs/Methods/CamelCapsMethodNameSniff.php | 2 +- .../Tests/Classes/ClassDeclarationUnitTest.php | 2 +- .../PSR1/Tests/Files/SideEffectsUnitTest.php | 2 +- .../Methods/CamelCapsMethodNameUnitTest.php | 2 +- .../Sniffs/Classes/AnonClassDeclarationSniff.php | 2 +- .../Sniffs/Classes/ClassInstantiationSniff.php | 2 +- .../PSR12/Sniffs/Classes/ClosingBraceSniff.php | 2 +- .../Sniffs/Classes/OpeningBraceSpaceSniff.php | 2 +- .../BooleanOperatorPlacementSniff.php | 2 +- .../ControlStructureSpacingSniff.php | 2 +- .../PSR12/Sniffs/Files/DeclareStatementSniff.php | 2 +- .../PSR12/Sniffs/Files/FileHeaderSniff.php | 2 +- .../PSR12/Sniffs/Files/ImportStatementSniff.php | 2 +- .../PSR12/Sniffs/Files/OpenTagSniff.php | 2 +- .../Functions/NullableTypeDeclarationSniff.php | 2 +- .../Functions/ReturnTypeDeclarationSniff.php | 2 +- .../Keywords/ShortFormTypeKeywordsSniff.php | 2 +- .../Namespaces/CompoundNamespaceDepthSniff.php | 2 +- .../Sniffs/Operators/OperatorSpacingSniff.php | 2 +- .../Properties/ConstantVisibilitySniff.php | 2 +- .../PSR12/Sniffs/Traits/UseDeclarationSniff.php | 2 +- .../Classes/AnonClassDeclarationUnitTest.php | 2 +- .../Tests/Classes/ClassInstantiationUnitTest.php | 2 +- .../PSR12/Tests/Classes/ClosingBraceUnitTest.php | 2 +- .../Tests/Classes/OpeningBraceSpaceUnitTest.php | 2 +- .../BooleanOperatorPlacementUnitTest.php | 2 +- .../ControlStructureSpacingUnitTest.php | 2 +- .../Tests/Files/DeclareStatementUnitTest.php | 2 +- .../PSR12/Tests/Files/FileHeaderUnitTest.php | 2 +- .../Tests/Files/ImportStatementUnitTest.php | 2 +- .../PSR12/Tests/Files/OpenTagUnitTest.php | 2 +- .../NullableTypeDeclarationUnitTest.php | 2 +- .../Functions/ReturnTypeDeclarationUnitTest.php | 2 +- .../Keywords/ShortFormTypeKeywordsUnitTest.php | 2 +- .../CompoundNamespaceDepthUnitTest.php | 2 +- .../Tests/Operators/OperatorSpacingUnitTest.php | 2 +- .../Properties/ConstantVisibilityUnitTest.php | 2 +- .../Tests/Traits/UseDeclarationUnitTest.php | 2 +- .../Sniffs/Classes/ClassDeclarationSniff.php | 2 +- .../Sniffs/Classes/PropertyDeclarationSniff.php | 2 +- .../ControlStructureSpacingSniff.php | 2 +- .../ControlStructures/ElseIfDeclarationSniff.php | 2 +- .../ControlStructures/SwitchDeclarationSniff.php | 2 +- .../PSR2/Sniffs/Files/ClosingTagSniff.php | 2 +- .../PSR2/Sniffs/Files/EndFileNewlineSniff.php | 2 +- .../Methods/FunctionCallSignatureSniff.php | 2 +- .../Sniffs/Methods/FunctionClosingBraceSniff.php | 2 +- .../Sniffs/Methods/MethodDeclarationSniff.php | 2 +- .../Namespaces/NamespaceDeclarationSniff.php | 2 +- .../Sniffs/Namespaces/UseDeclarationSniff.php | 2 +- .../Tests/Classes/ClassDeclarationUnitTest.php | 2 +- .../Classes/PropertyDeclarationUnitTest.php | 2 +- .../ControlStructureSpacingUnitTest.php | 2 +- .../ElseIfDeclarationUnitTest.php | 2 +- .../SwitchDeclarationUnitTest.php | 2 +- .../PSR2/Tests/Files/ClosingTagUnitTest.php | 2 +- .../PSR2/Tests/Files/EndFileNewlineUnitTest.php | 2 +- .../Methods/FunctionCallSignatureUnitTest.php | 2 +- .../Methods/FunctionClosingBraceUnitTest.php | 2 +- .../Tests/Methods/MethodDeclarationUnitTest.php | 2 +- .../Namespaces/NamespaceDeclarationUnitTest.php | 2 +- .../Tests/Namespaces/UseDeclarationUnitTest.php | 2 +- .../Sniffs/Arrays/ArrayBracketSpacingSniff.php | 2 +- .../Sniffs/Arrays/ArrayDeclarationSniff.php | 2 +- .../ClassDefinitionClosingBraceSpaceSniff.php | 2 +- .../CSS/ClassDefinitionNameSpacingSniff.php | 2 +- .../ClassDefinitionOpeningBraceSpaceSniff.php | 2 +- .../Squiz/Sniffs/CSS/ColonSpacingSniff.php | 2 +- .../Squiz/Sniffs/CSS/ColourDefinitionSniff.php | 2 +- .../DisallowMultipleStyleDefinitionsSniff.php | 2 +- .../Sniffs/CSS/DuplicateClassDefinitionSniff.php | 2 +- .../Sniffs/CSS/DuplicateStyleDefinitionSniff.php | 2 +- .../Sniffs/CSS/EmptyClassDefinitionSniff.php | 2 +- .../Sniffs/CSS/EmptyStyleDefinitionSniff.php | 2 +- .../Squiz/Sniffs/CSS/ForbiddenStylesSniff.php | 2 +- .../Squiz/Sniffs/CSS/IndentationSniff.php | 2 +- .../Sniffs/CSS/LowercaseStyleDefinitionSniff.php | 2 +- .../Squiz/Sniffs/CSS/MissingColonSniff.php | 2 +- .../Squiz/Sniffs/CSS/NamedColoursSniff.php | 2 +- src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php | 2 +- .../Squiz/Sniffs/CSS/SemicolonSpacingSniff.php | 2 +- .../Squiz/Sniffs/CSS/ShorthandSizeSniff.php | 2 +- .../Sniffs/Classes/ClassDeclarationSniff.php | 2 +- .../Squiz/Sniffs/Classes/ClassFileNameSniff.php | 2 +- .../Sniffs/Classes/DuplicatePropertySniff.php | 2 +- .../Classes/LowercaseClassKeywordsSniff.php | 2 +- .../Sniffs/Classes/SelfMemberReferenceSniff.php | 2 +- .../Squiz/Sniffs/Classes/ValidClassNameSniff.php | 2 +- .../Sniffs/Commenting/BlockCommentSniff.php | 2 +- .../Sniffs/Commenting/ClassCommentSniff.php | 2 +- .../ClosingDeclarationCommentSniff.php | 2 +- .../Commenting/DocCommentAlignmentSniff.php | 2 +- .../Sniffs/Commenting/EmptyCatchCommentSniff.php | 2 +- .../Squiz/Sniffs/Commenting/FileCommentSniff.php | 2 +- .../Sniffs/Commenting/FunctionCommentSniff.php | 2 +- .../Commenting/FunctionCommentThrowTagSniff.php | 2 +- .../Sniffs/Commenting/InlineCommentSniff.php | 2 +- .../LongConditionClosingCommentSniff.php | 2 +- .../Commenting/PostStatementCommentSniff.php | 2 +- .../Sniffs/Commenting/VariableCommentSniff.php | 2 +- .../ControlStructures/ControlSignatureSniff.php | 2 +- .../ControlStructures/ElseIfDeclarationSniff.php | 2 +- .../ForEachLoopDeclarationSniff.php | 2 +- .../ForLoopDeclarationSniff.php | 2 +- .../InlineIfDeclarationSniff.php | 2 +- .../LowercaseDeclarationSniff.php | 2 +- .../ControlStructures/SwitchDeclarationSniff.php | 2 +- src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php | 2 +- .../Squiz/Sniffs/Debug/JavaScriptLintSniff.php | 2 +- .../Squiz/Sniffs/Files/FileExtensionSniff.php | 2 +- .../Sniffs/Formatting/OperatorBracketSniff.php | 2 +- .../FunctionDeclarationArgumentSpacingSniff.php | 2 +- .../Functions/FunctionDeclarationSniff.php | 2 +- .../Functions/FunctionDuplicateArgumentSniff.php | 2 +- .../Sniffs/Functions/GlobalFunctionSniff.php | 2 +- .../Functions/LowercaseFunctionKeywordsSniff.php | 2 +- .../MultiLineFunctionDeclarationSniff.php | 2 +- .../NamingConventions/ValidFunctionNameSniff.php | 2 +- .../NamingConventions/ValidVariableNameSniff.php | 2 +- .../Objects/DisallowObjectStringIndexSniff.php | 2 +- .../Sniffs/Objects/ObjectInstantiationSniff.php | 2 +- .../Sniffs/Objects/ObjectMemberCommaSniff.php | 2 +- .../Operators/ComparisonOperatorUsageSniff.php | 2 +- .../Operators/IncrementDecrementUsageSniff.php | 2 +- .../Operators/ValidLogicalOperatorsSniff.php | 2 +- .../Squiz/Sniffs/PHP/CommentedOutCodeSniff.php | 2 +- .../Sniffs/PHP/DisallowBooleanStatementSniff.php | 2 +- .../PHP/DisallowComparisonAssignmentSniff.php | 2 +- .../Squiz/Sniffs/PHP/DisallowInlineIfSniff.php | 2 +- .../PHP/DisallowMultipleAssignmentsSniff.php | 2 +- .../PHP/DisallowSizeFunctionsInLoopsSniff.php | 2 +- .../Sniffs/PHP/DiscouragedFunctionsSniff.php | 2 +- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/EvalSniff.php | 2 +- .../Squiz/Sniffs/PHP/GlobalKeywordSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php | 2 +- .../Squiz/Sniffs/PHP/InnerFunctionsSniff.php | 2 +- .../Sniffs/PHP/LowercasePHPFunctionsSniff.php | 2 +- .../Squiz/Sniffs/PHP/NonExecutableCodeSniff.php | 2 +- .../Squiz/Sniffs/Scope/MemberVarScopeSniff.php | 2 +- .../Squiz/Sniffs/Scope/MethodScopeSniff.php | 2 +- .../Squiz/Sniffs/Scope/StaticThisUsageSniff.php | 2 +- .../Sniffs/Strings/ConcatenationSpacingSniff.php | 2 +- .../Sniffs/Strings/DoubleQuoteUsageSniff.php | 2 +- .../Squiz/Sniffs/Strings/EchoedStringsSniff.php | 2 +- .../Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php | 2 +- .../WhiteSpace/ControlStructureSpacingSniff.php | 2 +- .../FunctionClosingBraceSpaceSniff.php | 2 +- .../FunctionOpeningBraceSpaceSniff.php | 2 +- .../Sniffs/WhiteSpace/FunctionSpacingSniff.php | 2 +- .../WhiteSpace/LanguageConstructSpacingSniff.php | 2 +- .../WhiteSpace/LogicalOperatorSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/MemberVarSpacingSniff.php | 2 +- .../WhiteSpace/ObjectOperatorSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/OperatorSpacingSniff.php | 2 +- .../WhiteSpace/PropertyLabelSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/ScopeClosingBraceSniff.php | 2 +- .../WhiteSpace/ScopeKeywordSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/SemicolonSpacingSniff.php | 2 +- .../WhiteSpace/SuperfluousWhitespaceSniff.php | 2 +- .../Tests/Arrays/ArrayBracketSpacingUnitTest.php | 2 +- .../Tests/Arrays/ArrayDeclarationUnitTest.php | 2 +- .../ClassDefinitionClosingBraceSpaceUnitTest.php | 2 +- .../CSS/ClassDefinitionNameSpacingUnitTest.php | 2 +- .../ClassDefinitionOpeningBraceSpaceUnitTest.php | 2 +- .../Squiz/Tests/CSS/ColonSpacingUnitTest.php | 2 +- .../Squiz/Tests/CSS/ColourDefinitionUnitTest.php | 2 +- .../DisallowMultipleStyleDefinitionsUnitTest.php | 2 +- .../CSS/DuplicateClassDefinitionUnitTest.php | 2 +- .../CSS/DuplicateStyleDefinitionUnitTest.php | 2 +- .../Tests/CSS/EmptyClassDefinitionUnitTest.php | 2 +- .../Tests/CSS/EmptyStyleDefinitionUnitTest.php | 2 +- .../Squiz/Tests/CSS/ForbiddenStylesUnitTest.php | 2 +- .../Squiz/Tests/CSS/IndentationUnitTest.php | 2 +- .../CSS/LowercaseStyleDefinitionUnitTest.php | 2 +- .../Squiz/Tests/CSS/MissingColonUnitTest.php | 2 +- .../Squiz/Tests/CSS/NamedColoursUnitTest.php | 2 +- .../Squiz/Tests/CSS/OpacityUnitTest.php | 2 +- .../Squiz/Tests/CSS/SemicolonSpacingUnitTest.php | 2 +- .../Squiz/Tests/CSS/ShorthandSizeUnitTest.php | 2 +- .../Tests/Classes/ClassDeclarationUnitTest.php | 2 +- .../Tests/Classes/ClassFileNameUnitTest.php | 2 +- .../Tests/Classes/DuplicatePropertyUnitTest.php | 2 +- .../Classes/LowercaseClassKeywordsUnitTest.php | 2 +- .../Classes/SelfMemberReferenceUnitTest.php | 2 +- .../Tests/Classes/ValidClassNameUnitTest.php | 2 +- .../Tests/Commenting/BlockCommentUnitTest.php | 2 +- .../Tests/Commenting/ClassCommentUnitTest.php | 2 +- .../ClosingDeclarationCommentUnitTest.php | 2 +- .../Commenting/DocCommentAlignmentUnitTest.php | 2 +- .../Commenting/EmptyCatchCommentUnitTest.php | 2 +- .../Tests/Commenting/FileCommentUnitTest.php | 2 +- .../FunctionCommentThrowTagUnitTest.php | 2 +- .../Tests/Commenting/FunctionCommentUnitTest.php | 2 +- .../Tests/Commenting/InlineCommentUnitTest.php | 2 +- .../LongConditionClosingCommentUnitTest.php | 2 +- .../Commenting/PostStatementCommentUnitTest.php | 2 +- .../Tests/Commenting/VariableCommentUnitTest.php | 2 +- .../ControlSignatureUnitTest.php | 2 +- .../ElseIfDeclarationUnitTest.php | 2 +- .../ForEachLoopDeclarationUnitTest.php | 2 +- .../ForLoopDeclarationUnitTest.php | 2 +- .../InlineIfDeclarationUnitTest.php | 2 +- .../LowercaseDeclarationUnitTest.php | 2 +- .../SwitchDeclarationUnitTest.php | 2 +- .../Squiz/Tests/Debug/JSLintUnitTest.php | 2 +- .../Squiz/Tests/Debug/JavaScriptLintUnitTest.php | 2 +- .../Squiz/Tests/Files/FileExtensionUnitTest.php | 2 +- .../Tests/Formatting/OperatorBracketUnitTest.php | 2 +- ...unctionDeclarationArgumentSpacingUnitTest.php | 2 +- .../Functions/FunctionDeclarationUnitTest.php | 2 +- .../FunctionDuplicateArgumentUnitTest.php | 2 +- .../Tests/Functions/GlobalFunctionUnitTest.php | 2 +- .../LowercaseFunctionKeywordsUnitTest.php | 2 +- .../MultiLineFunctionDeclarationUnitTest.php | 2 +- .../ValidFunctionNameUnitTest.php | 2 +- .../ValidVariableNameUnitTest.php | 2 +- .../DisallowObjectStringIndexUnitTest.php | 2 +- .../Objects/ObjectInstantiationUnitTest.php | 2 +- .../Tests/Objects/ObjectMemberCommaUnitTest.php | 2 +- .../ComparisonOperatorUsageUnitTest.php | 2 +- .../IncrementDecrementUsageUnitTest.php | 2 +- .../Operators/ValidLogicalOperatorsUnitTest.php | 2 +- .../Squiz/Tests/PHP/CommentedOutCodeUnitTest.php | 2 +- .../PHP/DisallowBooleanStatementUnitTest.php | 2 +- .../PHP/DisallowComparisonAssignmentUnitTest.php | 2 +- .../Squiz/Tests/PHP/DisallowInlineIfUnitTest.php | 2 +- .../PHP/DisallowMultipleAssignmentsUnitTest.php | 2 +- .../PHP/DisallowSizeFunctionsInLoopsUnitTest.php | 2 +- .../Tests/PHP/DiscouragedFunctionsUnitTest.php | 2 +- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/EvalUnitTest.php | 2 +- .../Squiz/Tests/PHP/GlobalKeywordUnitTest.php | 2 +- .../Squiz/Tests/PHP/HeredocUnitTest.php | 2 +- .../Squiz/Tests/PHP/InnerFunctionsUnitTest.php | 2 +- .../Tests/PHP/LowercasePHPFunctionsUnitTest.php | 2 +- .../Tests/PHP/NonExecutableCodeUnitTest.php | 2 +- .../Squiz/Tests/Scope/MemberVarScopeUnitTest.php | 2 +- .../Squiz/Tests/Scope/MethodScopeUnitTest.php | 2 +- .../Tests/Scope/StaticThisUsageUnitTest.php | 2 +- .../Strings/ConcatenationSpacingUnitTest.php | 2 +- .../Tests/Strings/DoubleQuoteUsageUnitTest.php | 2 +- .../Tests/Strings/EchoedStringsUnitTest.php | 2 +- .../Tests/WhiteSpace/CastSpacingUnitTest.php | 2 +- .../ControlStructureSpacingUnitTest.php | 2 +- .../FunctionClosingBraceSpaceUnitTest.php | 2 +- .../FunctionOpeningBraceSpaceUnitTest.php | 2 +- .../Tests/WhiteSpace/FunctionSpacingUnitTest.php | 2 +- .../LanguageConstructSpacingUnitTest.php | 2 +- .../LogicalOperatorSpacingUnitTest.php | 2 +- .../WhiteSpace/MemberVarSpacingUnitTest.php | 2 +- .../WhiteSpace/ObjectOperatorSpacingUnitTest.php | 2 +- .../Tests/WhiteSpace/OperatorSpacingUnitTest.php | 2 +- .../WhiteSpace/PropertyLabelSpacingUnitTest.php | 2 +- .../WhiteSpace/ScopeClosingBraceUnitTest.php | 2 +- .../WhiteSpace/ScopeKeywordSpacingUnitTest.php | 2 +- .../WhiteSpace/SemicolonSpacingUnitTest.php | 2 +- .../WhiteSpace/SuperfluousWhitespaceUnitTest.php | 2 +- .../Zend/Sniffs/Debug/CodeAnalyzerSniff.php | 2 +- .../Zend/Sniffs/Files/ClosingTagSniff.php | 2 +- .../NamingConventions/ValidVariableNameSniff.php | 2 +- .../Zend/Tests/Debug/CodeAnalyzerUnitTest.php | 2 +- .../Zend/Tests/Files/ClosingTagUnitTest.php | 2 +- .../ValidVariableNameUnitTest.php | 2 +- src/Tokenizers/CSS.php | 2 +- src/Tokenizers/Comment.php | 2 +- src/Tokenizers/JS.php | 2 +- src/Tokenizers/PHP.php | 2 +- src/Tokenizers/Tokenizer.php | 2 +- src/Util/Cache.php | 2 +- src/Util/Common.php | 2 +- src/Util/Standards.php | 2 +- src/Util/Timing.php | 2 +- src/Util/Tokens.php | 2 +- tests/AllTests.php | 2 +- tests/Core/AbstractMethodUnitTest.php | 2 +- tests/Core/AllTests.php | 2 +- .../Core/Autoloader/DetermineLoadedClassTest.php | 2 +- tests/Core/Config/ReportWidthTest.php | 2 +- tests/Core/ErrorSuppressionTest.php | 2 +- tests/Core/File/FindEndOfStatementTest.php | 2 +- tests/Core/File/FindExtendedClassNameTest.php | 2 +- .../File/FindImplementedInterfaceNamesTest.php | 2 +- tests/Core/File/FindStartOfStatementTest.php | 2 +- tests/Core/File/GetClassPropertiesTest.php | 2 +- tests/Core/File/GetMemberPropertiesTest.php | 2 +- tests/Core/File/GetMethodParametersTest.php | 2 +- tests/Core/File/GetMethodPropertiesTest.php | 2 +- tests/Core/File/IsReferenceTest.php | 2 +- tests/Core/Filters/Filter/AcceptTest.php | 2 +- tests/Core/IsCamelCapsTest.php | 2 +- .../Ruleset/RuleInclusionAbsoluteLinuxTest.php | 2 +- .../Ruleset/RuleInclusionAbsoluteLinuxTest.xml | 2 +- .../Ruleset/RuleInclusionAbsoluteWindowsTest.php | 2 +- .../Ruleset/RuleInclusionAbsoluteWindowsTest.xml | 2 +- tests/Core/Ruleset/RuleInclusionTest-include.xml | 2 +- tests/Core/Ruleset/RuleInclusionTest.php | 2 +- .../Ruleset/SetPropertyAllowedAsDeclaredTest.xml | 2 +- .../SetPropertyAllowedViaMagicMethodTest.xml | 2 +- .../SetPropertyAllowedViaStdClassTest.xml | 2 +- ...iesPropertyToMultipleSniffsInCategoryTest.xml | 2 +- ...orOnInvalidPropertyWhenSetForCategoryTest.xml | 2 +- ...orOnInvalidPropertyWhenSetForStandardTest.xml | 2 +- .../SetPropertyNotAllowedViaAttributeTest.xml | 2 +- ...tPropertyThrowsErrorOnInvalidPropertyTest.xml | 2 +- tests/Core/Ruleset/SetSniffPropertyTest.php | 2 +- tests/Core/Sniffs/AbstractArraySniffTest.php | 2 +- tests/Core/Sniffs/AbstractArraySniffTestable.php | 2 +- .../Tokenizer/AnonClassParenthesisOwnerTest.php | 2 +- tests/Core/Tokenizer/ArrayKeywordTest.php | 2 +- tests/Core/Tokenizer/AttributesTest.php | 2 +- tests/Core/Tokenizer/BackfillEnumTest.php | 2 +- .../BackfillExplicitOctalNotationTest.php | 2 +- tests/Core/Tokenizer/BackfillFnTokenTest.php | 2 +- tests/Core/Tokenizer/BackfillMatchTokenTest.php | 2 +- .../Tokenizer/BackfillNumericSeparatorTest.php | 2 +- tests/Core/Tokenizer/BackfillReadonlyTest.php | 2 +- tests/Core/Tokenizer/BitwiseOrTest.php | 2 +- .../Tokenizer/ContextSensitiveKeywordsTest.php | 2 +- tests/Core/Tokenizer/DefaultKeywordTest.php | 2 +- tests/Core/Tokenizer/DoubleArrowTest.php | 2 +- tests/Core/Tokenizer/DoubleQuotedStringTest.php | 2 +- tests/Core/Tokenizer/EnumCaseTest.php | 2 +- tests/Core/Tokenizer/FinallyTest.php | 2 +- tests/Core/Tokenizer/GotoLabelTest.php | 2 +- tests/Core/Tokenizer/HeredocNowdocCloserTest.php | 2 +- tests/Core/Tokenizer/HeredocStringTest.php | 2 +- .../Tokenizer/NamedFunctionCallArgumentsTest.php | 2 +- .../Tokenizer/NullsafeObjectOperatorTest.php | 2 +- .../ScopeSettingWithNamespaceOperatorTest.php | 2 +- tests/Core/Tokenizer/ShortArrayTest.php | 2 +- .../Tokenizer/StableCommentWhitespaceTest.php | 2 +- .../Tokenizer/StableCommentWhitespaceWinTest.php | 2 +- tests/Core/Tokenizer/TypeIntersectionTest.php | 2 +- .../UndoNamespacedNameSingleTokenTest.php | 2 +- tests/FileList.php | 2 +- tests/Standards/AbstractSniffUnitTest.php | 2 +- tests/Standards/AllSniffs.php | 2 +- tests/TestSuite.php | 2 +- tests/TestSuite7.php | 2 +- tests/bootstrap.php | 2 +- 628 files changed, 648 insertions(+), 648 deletions(-) diff --git a/README.md b/README.md index 509218b92c..6f6ac8c452 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@ PHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second `phpcbf` script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. -[![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Validate/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions) -[![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Test/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions) +[![Build Status](https://github.com/PHPCSStandards/PHP_CodeSniffer/workflows/Validate/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions) +[![Build Status](https://github.com/PHPCSStandards/PHP_CodeSniffer/workflows/Test/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions) ## Requirements -PHP_CodeSniffer requires PHP version 5.4.0 or greater, although individual sniffs may have additional requirements such as external applications and scripts. See the [Configuration Options manual page](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options) for a list of these requirements. +PHP_CodeSniffer requires PHP version 5.4.0 or greater, although individual sniffs may have additional requirements such as external applications and scripts. See the [Configuration Options manual page](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options) for a list of these requirements. -If you're using PHP_CodeSniffer as part of a team, or you're running it on a [CI](https://en.wikipedia.org/wiki/Continuous_integration) server, you may want to configure your project's settings [using a configuration file](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). +If you're using PHP_CodeSniffer as part of a team, or you're running it on a [CI](https://en.wikipedia.org/wiki/Continuous_integration) server, you may want to configure your project's settings [using a configuration file](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). ## Installation @@ -70,7 +70,7 @@ pear install PHP_CodeSniffer ### Git Clone You can also download the PHP_CodeSniffer source and run the `phpcs` and `phpcbf` commands directly from the Git clone: ```bash -git clone https://github.com/squizlabs/PHP_CodeSniffer.git +git clone https://github.com/PHPCSStandards/PHP_CodeSniffer.git cd PHP_CodeSniffer php bin/phpcs -h php bin/phpcbf -h @@ -92,15 +92,15 @@ phpcs --standard=PSR12 /path/to/code-directory If PHP_CodeSniffer finds any coding standard errors, a report will be shown after running the command. -Full usage information and example reports are available on the [usage page](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage). +Full usage information and example reports are available on the [usage page](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage). ## Documentation -The documentation for PHP_CodeSniffer is available on the [Github wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki). +The documentation for PHP_CodeSniffer is available on the [Github wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki). ## Issues -Bug reports and feature requests can be submitted on the [Github Issue Tracker](https://github.com/squizlabs/PHP_CodeSniffer/issues). +Bug reports and feature requests can be submitted on the [Github Issue Tracker](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues). ## Contributing diff --git a/autoload.php b/autoload.php index 0dcf1b4c81..7e546bb5b6 100644 --- a/autoload.php +++ b/autoload.php @@ -11,7 +11,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer; diff --git a/bin/phpcbf b/bin/phpcbf index 45b43f4326..2e86a40e62 100755 --- a/bin/phpcbf +++ b/bin/phpcbf @@ -5,7 +5,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ if (is_file(__DIR__.'/../autoload.php') === true) { diff --git a/bin/phpcbf.bat b/bin/phpcbf.bat index 5b07a7d924..82e9d561b1 100644 --- a/bin/phpcbf.bat +++ b/bin/phpcbf.bat @@ -3,7 +3,7 @@ REM PHP Code Beautifier and Fixer fixes violations of a defined coding standard. REM REM @author Greg Sherwood REM @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) -REM @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence +REM @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence if "%PHP_PEAR_PHP_BIN%" neq "" ( set PHPBIN=%PHP_PEAR_PHP_BIN% diff --git a/bin/phpcs b/bin/phpcs index 52d28cdf18..e8e8b02894 100755 --- a/bin/phpcs +++ b/bin/phpcs @@ -5,7 +5,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ if (is_file(__DIR__.'/../autoload.php') === true) { diff --git a/bin/phpcs.bat b/bin/phpcs.bat index 9f9be72033..7fe506cf98 100755 --- a/bin/phpcs.bat +++ b/bin/phpcs.bat @@ -3,7 +3,7 @@ REM PHP_CodeSniffer detects violations of a defined coding standard. REM REM @author Greg Sherwood REM @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) -REM @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence +REM @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence if "%PHP_PEAR_PHP_BIN%" neq "" ( set PHPBIN=%PHP_PEAR_PHP_BIN% diff --git a/scripts/build-phar.php b/scripts/build-phar.php index 45e44bab2e..81ee997f19 100644 --- a/scripts/build-phar.php +++ b/scripts/build-phar.php @@ -10,7 +10,7 @@ * @author Benjamin Pearson * @author Greg Sherwood * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ diff --git a/src/Config.php b/src/Config.php index 0320bdee87..ffad6cb8f1 100644 --- a/src/Config.php +++ b/src/Config.php @@ -7,7 +7,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer; diff --git a/src/Exceptions/DeepExitException.php b/src/Exceptions/DeepExitException.php index b1440944a6..7732c6da48 100644 --- a/src/Exceptions/DeepExitException.php +++ b/src/Exceptions/DeepExitException.php @@ -7,7 +7,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Exceptions; diff --git a/src/Exceptions/RuntimeException.php b/src/Exceptions/RuntimeException.php index 093bf13d4c..a3d590984c 100644 --- a/src/Exceptions/RuntimeException.php +++ b/src/Exceptions/RuntimeException.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Exceptions; diff --git a/src/Exceptions/TokenizerException.php b/src/Exceptions/TokenizerException.php index ceba00ccda..ad25ace198 100644 --- a/src/Exceptions/TokenizerException.php +++ b/src/Exceptions/TokenizerException.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Exceptions; diff --git a/src/Files/DummyFile.php b/src/Files/DummyFile.php index 601430301d..eb947fd2a9 100644 --- a/src/Files/DummyFile.php +++ b/src/Files/DummyFile.php @@ -9,7 +9,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Files; diff --git a/src/Files/File.php b/src/Files/File.php index 21cbeb2158..0945b7c3d2 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Files; diff --git a/src/Files/FileList.php b/src/Files/FileList.php index 66833a3ee4..bf98385a35 100644 --- a/src/Files/FileList.php +++ b/src/Files/FileList.php @@ -6,7 +6,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Files; diff --git a/src/Files/LocalFile.php b/src/Files/LocalFile.php index ca2e74ad39..c2af77c42a 100644 --- a/src/Files/LocalFile.php +++ b/src/Files/LocalFile.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Files; diff --git a/src/Filters/ExactMatch.php b/src/Filters/ExactMatch.php index 13af8ff22b..38a2f05bb8 100644 --- a/src/Filters/ExactMatch.php +++ b/src/Filters/ExactMatch.php @@ -6,7 +6,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Filters; diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index a1246a2c52..c72518c660 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Filters; diff --git a/src/Filters/GitModified.php b/src/Filters/GitModified.php index 4b6ef3fc58..9bba997c24 100644 --- a/src/Filters/GitModified.php +++ b/src/Filters/GitModified.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Filters; diff --git a/src/Filters/GitStaged.php b/src/Filters/GitStaged.php index fcb92c3d97..1fdbb952ca 100644 --- a/src/Filters/GitStaged.php +++ b/src/Filters/GitStaged.php @@ -6,7 +6,7 @@ * * @author Juliette Reinders Folmer * @copyright 2018 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Filters; diff --git a/src/Fixer.php b/src/Fixer.php index b8dc05b16e..2ff09576a7 100644 --- a/src/Fixer.php +++ b/src/Fixer.php @@ -7,7 +7,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer; diff --git a/src/Generators/Generator.php b/src/Generators/Generator.php index 56049768b0..483cae800f 100644 --- a/src/Generators/Generator.php +++ b/src/Generators/Generator.php @@ -7,7 +7,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Generators; diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php index db26468439..55acd9e172 100644 --- a/src/Generators/HTML.php +++ b/src/Generators/HTML.php @@ -8,7 +8,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Generators; @@ -169,7 +169,7 @@ protected function printFooter() $errorLevel = error_reporting(0); echo '
'; echo 'Documentation generated on '.date('r'); - echo ' by PHP_CodeSniffer '.Config::VERSION.''; + echo ' by PHP_CodeSniffer '.Config::VERSION.''; echo '
'.PHP_EOL; error_reporting($errorLevel); diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index 9756bcf140..23bed27e20 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -4,7 +4,7 @@ * * @author Stefano Kowalke * @copyright 2014 Arroba IT - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Generators; @@ -67,7 +67,7 @@ protected function printFooter() // don't have their timezone set. error_reporting(0); echo 'Documentation generated on '.date('r'); - echo ' by [PHP_CodeSniffer '.Config::VERSION.'](https://github.com/squizlabs/PHP_CodeSniffer)'.PHP_EOL; + echo ' by [PHP_CodeSniffer '.Config::VERSION.'](https://github.com/PHPCSStandards/PHP_CodeSniffer)'.PHP_EOL; }//end printFooter() diff --git a/src/Generators/Text.php b/src/Generators/Text.php index ffff206aa8..7ec95ec9c7 100644 --- a/src/Generators/Text.php +++ b/src/Generators/Text.php @@ -6,7 +6,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Generators; diff --git a/src/Reporter.php b/src/Reporter.php index e89a20edff..3e3da32110 100644 --- a/src/Reporter.php +++ b/src/Reporter.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer; diff --git a/src/Reports/Cbf.php b/src/Reports/Cbf.php index c85353d988..b84f69f6cc 100644 --- a/src/Reports/Cbf.php +++ b/src/Reports/Cbf.php @@ -8,7 +8,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Checkstyle.php b/src/Reports/Checkstyle.php index 313e086710..dc1f6cc7bf 100644 --- a/src/Reports/Checkstyle.php +++ b/src/Reports/Checkstyle.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Code.php b/src/Reports/Code.php index 4a7a27af82..2382705817 100644 --- a/src/Reports/Code.php +++ b/src/Reports/Code.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Csv.php b/src/Reports/Csv.php index 1f02edbd85..aef7d7e375 100644 --- a/src/Reports/Csv.php +++ b/src/Reports/Csv.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Diff.php b/src/Reports/Diff.php index 68af0a0261..03f7bf20d5 100644 --- a/src/Reports/Diff.php +++ b/src/Reports/Diff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Emacs.php b/src/Reports/Emacs.php index cae9d22d85..3f0036576a 100644 --- a/src/Reports/Emacs.php +++ b/src/Reports/Emacs.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Full.php b/src/Reports/Full.php index 5f6bcde80a..f6db5833be 100644 --- a/src/Reports/Full.php +++ b/src/Reports/Full.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Gitblame.php b/src/Reports/Gitblame.php index 0919e0e0ba..3beb34524a 100644 --- a/src/Reports/Gitblame.php +++ b/src/Reports/Gitblame.php @@ -5,7 +5,7 @@ * @author Ben Selby * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Hgblame.php b/src/Reports/Hgblame.php index f88a06836b..3b4bbcfa1b 100644 --- a/src/Reports/Hgblame.php +++ b/src/Reports/Hgblame.php @@ -5,7 +5,7 @@ * @author Ben Selby * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Info.php b/src/Reports/Info.php index fa0698efdf..e263199be9 100644 --- a/src/Reports/Info.php +++ b/src/Reports/Info.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Json.php b/src/Reports/Json.php index f7aedb30a5..0b9ad34fa1 100644 --- a/src/Reports/Json.php +++ b/src/Reports/Json.php @@ -5,7 +5,7 @@ * @author Jeffrey Fisher * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Junit.php b/src/Reports/Junit.php index 0b59604ae0..40145a7178 100644 --- a/src/Reports/Junit.php +++ b/src/Reports/Junit.php @@ -5,7 +5,7 @@ * @author Oleg Lobach * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Notifysend.php b/src/Reports/Notifysend.php index 71aed108ed..7f5a7e4181 100644 --- a/src/Reports/Notifysend.php +++ b/src/Reports/Notifysend.php @@ -11,7 +11,7 @@ * @author Greg Sherwood * @copyright 2012-2014 Christian Weiske * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Report.php b/src/Reports/Report.php index fd60185e94..eec5eb1d0b 100644 --- a/src/Reports/Report.php +++ b/src/Reports/Report.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Source.php b/src/Reports/Source.php index 44f0d8748e..6aa891a4bd 100644 --- a/src/Reports/Source.php +++ b/src/Reports/Source.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Summary.php b/src/Reports/Summary.php index cd5ca69476..d2927a1c3f 100644 --- a/src/Reports/Summary.php +++ b/src/Reports/Summary.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Svnblame.php b/src/Reports/Svnblame.php index a7f65e154b..b44e83d627 100644 --- a/src/Reports/Svnblame.php +++ b/src/Reports/Svnblame.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/VersionControl.php b/src/Reports/VersionControl.php index e8e399a7dd..df1cd642db 100644 --- a/src/Reports/VersionControl.php +++ b/src/Reports/VersionControl.php @@ -5,7 +5,7 @@ * @author Ben Selby * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Reports/Xml.php b/src/Reports/Xml.php index c748dca726..dc25bba3f0 100644 --- a/src/Reports/Xml.php +++ b/src/Reports/Xml.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/src/Ruleset.php b/src/Ruleset.php index 5ba0d180fc..dbfa6ab9eb 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -6,7 +6,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer; diff --git a/src/Runner.php b/src/Runner.php index 2f21edf482..0f57243c23 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -7,7 +7,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer; diff --git a/src/Sniffs/AbstractArraySniff.php b/src/Sniffs/AbstractArraySniff.php index efe9969d8d..45e1091883 100644 --- a/src/Sniffs/AbstractArraySniff.php +++ b/src/Sniffs/AbstractArraySniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Sniffs; diff --git a/src/Sniffs/AbstractPatternSniff.php b/src/Sniffs/AbstractPatternSniff.php index 66bc2f5247..8dde80414a 100644 --- a/src/Sniffs/AbstractPatternSniff.php +++ b/src/Sniffs/AbstractPatternSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Sniffs; diff --git a/src/Sniffs/AbstractScopeSniff.php b/src/Sniffs/AbstractScopeSniff.php index 70d8720a1e..f2e101dcc3 100644 --- a/src/Sniffs/AbstractScopeSniff.php +++ b/src/Sniffs/AbstractScopeSniff.php @@ -21,7 +21,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Sniffs; diff --git a/src/Sniffs/AbstractVariableSniff.php b/src/Sniffs/AbstractVariableSniff.php index 5dc8ba5568..6493d5701a 100644 --- a/src/Sniffs/AbstractVariableSniff.php +++ b/src/Sniffs/AbstractVariableSniff.php @@ -10,7 +10,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Sniffs; diff --git a/src/Sniffs/Sniff.php b/src/Sniffs/Sniff.php index 3f0fb6a1cf..92acbc4a05 100644 --- a/src/Sniffs/Sniff.php +++ b/src/Sniffs/Sniff.php @@ -9,7 +9,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Sniffs; diff --git a/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php b/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php index adb74ec8cb..9bff5c6354 100644 --- a/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays; diff --git a/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php b/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php index bf7f3ed1c0..5c83895294 100644 --- a/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays; diff --git a/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php b/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php index 2ba42d673a..ea435321fc 100644 --- a/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays; diff --git a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php index 3243f8b7dc..c14e7ecad3 100644 --- a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php +++ b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Classes; diff --git a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php index dfd925f918..a00443b3fa 100644 --- a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php +++ b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Classes; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php index 8788a912ea..cfde25f59d 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php @@ -8,7 +8,7 @@ * * @author Juliette Reinders Folmer * @copyright 2017 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php index 1c9e400019..450df7a270 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php @@ -7,7 +7,7 @@ * * @author Juliette Reinders Folmer * @copyright 2017 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php index 574bb0ba5a..2e5b7da33b 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php @@ -18,7 +18,7 @@ * @author Manuel Pichler * @author Greg Sherwood * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php index f583e93891..5835f6ce5d 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php @@ -17,7 +17,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php index 62a07b26af..bbe02a3404 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php @@ -21,7 +21,7 @@ * @author Greg Sherwood * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php index 364658db65..d4af5776dc 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php @@ -24,7 +24,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php index cc9958c586..978fba73a6 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php @@ -21,7 +21,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php index 02ae2e7a32..d66abc2729 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php @@ -17,7 +17,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php index 58aa29fe85..ac6e599a03 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php @@ -11,7 +11,7 @@ * @author Manuel Pichler * @author Greg Sherwood * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php index fded929534..ba3553e1f6 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php @@ -16,7 +16,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; diff --git a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php index 545319be5e..1e96e64b75 100644 --- a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting; diff --git a/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php b/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php index 84385221ec..240c60edb6 100644 --- a/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php @@ -5,7 +5,7 @@ * @author Greg Sherwood * @author Sam Graham * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting; diff --git a/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php b/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php index 6396804610..9b5b34ab6f 100644 --- a/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting; diff --git a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php index f760fa1c60..7a705747dc 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php @@ -5,7 +5,7 @@ * @author Mponos George * @author Mark Scherer * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures; diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php index a67a6a798c..5ae358ff6a 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures; diff --git a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php index 81284787a2..9baad8c97c 100644 --- a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php @@ -4,7 +4,7 @@ * * @author Roman Levishchenko * @copyright 2013-2014 Roman Levishchenko - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; diff --git a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php index 19204718b0..926fec1555 100644 --- a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; diff --git a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php index d11d347050..cf576383f6 100644 --- a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php @@ -4,7 +4,7 @@ * * @author Ryan McCue * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; diff --git a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php index 738ab67ebe..aa3e6bd7f6 100644 --- a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php @@ -5,7 +5,7 @@ * @author Greg Sherwood * @author Alexander Wei§ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; diff --git a/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php b/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php index cee8ecc5f2..23249156bb 100644 --- a/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php +++ b/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php @@ -5,7 +5,7 @@ * @author Piotr Karas * @author Greg Sherwood * @copyright 2010-2014 mediaSELF Sp. z o.o. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php b/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php index d5375dc5c0..ffca4227a3 100644 --- a/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php +++ b/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php b/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php index 41c9c74991..2e82176b0f 100644 --- a/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php +++ b/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php b/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php index e1213d5f64..7db30618eb 100644 --- a/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php @@ -4,7 +4,7 @@ * * @author Matthew Peveler * @copyright 2019 Matthew Peveler - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php b/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php index eb01da87b3..99e2e91f4b 100644 --- a/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php +++ b/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php index 845e1bcfc4..2a8647e44f 100644 --- a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php index 5aa45ea0e1..56fbe858b2 100644 --- a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php @@ -8,7 +8,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php b/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php index a9fd4c5d44..c6ab14ce21 100644 --- a/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php @@ -4,7 +4,7 @@ * * @author Andy Grunwald * @copyright 2010-2014 Andy Grunwald - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php index 52d5d84c74..9eea7278df 100644 --- a/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php @@ -4,7 +4,7 @@ * * @author Andy Grunwald * @copyright 2010-2014 Andy Grunwald - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php index 9a6f5bccd5..71b6894a38 100644 --- a/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php @@ -4,7 +4,7 @@ * * @author Andy Grunwald * @copyright 2010-2014 Andy Grunwald - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php index 4d417e069e..d94a32db17 100644 --- a/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php @@ -4,7 +4,7 @@ * * @author Mponos George * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php index 7ae523f70e..0be3734148 100644 --- a/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php @@ -4,7 +4,7 @@ * * @author Alexander Obuhovich * @copyright 2010-2014 Alexander Obuhovich - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Files; diff --git a/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php b/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php index 6f9ff9f917..5466938d1c 100644 --- a/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting; diff --git a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php index 802e594485..68ddf53ff7 100644 --- a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php @@ -7,7 +7,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting; diff --git a/src/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php b/src/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php index f6a37dafd9..e7d294de6f 100644 --- a/src/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * * @deprecated 3.4.0 Use the Generic.Formatting.SpaceAfterCast sniff with * the $spacing property set to 0 instead. diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php index f19489e8e5..36eff864ac 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting; diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php index b74ca80edc..1ff25bdade 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting; diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php index a4f85aeb63..e4d9338401 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting; diff --git a/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php b/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php index 425748cee9..33f0c34e65 100644 --- a/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php @@ -4,7 +4,7 @@ * * @author Florian Grandel * @copyright 2009-2014 Florian Grandel - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Functions; diff --git a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php index 39fdae9526..2b33eeac58 100644 --- a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Functions; diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php index ff19526a9b..de2c083175 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Functions; diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php index 62eafc1203..7034550e5c 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Functions; diff --git a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php index 9bd0dff3de..f68666f946 100644 --- a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php @@ -9,7 +9,7 @@ * @author Johann-Peter Hartmann * @author Greg Sherwood * @copyright 2007-2014 Mayflower GmbH - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics; diff --git a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php index d001dedad1..35b5b29a5f 100644 --- a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php @@ -5,7 +5,7 @@ * @author Johann-Peter Hartmann * @author Greg Sherwood * @copyright 2007-2014 Mayflower GmbH - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics; diff --git a/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php index 3e3af830d3..8f3e5570e6 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php @@ -3,7 +3,7 @@ * Checks that abstract classes are prefixed by Abstract. * * @author Anna Borzenko - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions; diff --git a/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php index b45112034a..ec1cfd0029 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions; diff --git a/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php index a41960637c..75fbd2264e 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php @@ -8,7 +8,7 @@ * @author Greg Sherwood * @author Leif Wickland * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions; diff --git a/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php index c5dc34d489..2e69aea532 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php @@ -3,7 +3,7 @@ * Checks that interfaces are suffixed by Interface. * * @author Anna Borzenko - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions; diff --git a/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php index 4e3b211dff..81a96b7932 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php @@ -3,7 +3,7 @@ * Checks that traits are suffixed by Trait. * * @author Anna Borzenko - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions; diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index db50eb56bb..4f4ae40e17 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions; diff --git a/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php b/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php index d455845b57..ce9bee3101 100644 --- a/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php b/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php index f52180dd35..af9cb9b29f 100644 --- a/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php @@ -4,7 +4,7 @@ * * @author Andy Grunwald * @copyright 2010-2014 Andy Grunwald - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php b/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php index d03bf8abe1..b8ed0a0aaf 100644 --- a/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php @@ -4,7 +4,7 @@ * * @author Stefano Kowalke * @copyright 2010-2014 Stefano Kowalke - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php b/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php index 42eaa40f4e..83f38898ce 100644 --- a/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php @@ -5,7 +5,7 @@ * @author Sebastian Bergmann * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php index 433750adfd..8451f80a6e 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php @@ -6,7 +6,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php index 1c2b1aee93..913e16f9b8 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php @@ -4,7 +4,7 @@ * * @author Jeantwan Teuma * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php index 3f3fdbe62b..433ef5cf7f 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php b/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php index 6389846d8a..1a552ee722 100644 --- a/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php b/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php index 8717189f0e..9b21db15db 100644 --- a/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php @@ -7,7 +7,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php index 4376daa9dd..34c825fbff 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php index e6b4917834..542fea5d8b 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php index 4d463f28fb..29cfbc7e2b 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php b/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php index 14dfaa7216..a3db4a167b 100644 --- a/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php @@ -11,7 +11,7 @@ * * @author Andy Brockhurst * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php index bffe7439c7..0e3fb6dfe3 100644 --- a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php @@ -4,7 +4,7 @@ * * @author Sertan Danis * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php b/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php index 19d58572c6..05bac4528a 100644 --- a/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php b/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php index 85e717bc99..144a0001b2 100644 --- a/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php @@ -5,7 +5,7 @@ * @author Greg Sherwood * @author Blaine Schmeisser * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php index 2740884bb4..1a65f3c34e 100644 --- a/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; diff --git a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php index 82dae8fb00..2d2286c9df 100644 --- a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php +++ b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Strings; diff --git a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php index 83265b2e47..79035abe5d 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2017 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl; diff --git a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php index 3c3829a692..8fc4943003 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php @@ -4,7 +4,7 @@ * * @author Jack Bates * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php index 09aea5436e..6beec4219b 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php @@ -7,7 +7,7 @@ * * @author Juliette Reinders Folmer * @copyright 2017 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php index bbdbfe0a9a..e085e4ae80 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php index 2140e55ef5..15d4580c94 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php index 0ff30f4449..bde065e1c2 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2018 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php index 068a4e7f29..c577c9dc6f 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index 7fd604849d..17e9c7d7b4 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php index 070bbcd1fb..9479dd9bdb 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace; diff --git a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php index 4861041f62..482742a356 100644 --- a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Arrays; diff --git a/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php b/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php index af1d9c9a86..edd7e6d5a6 100644 --- a/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Arrays; diff --git a/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php b/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php index 25c9666ebd..d9d305db14 100644 --- a/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Arrays; diff --git a/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php b/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php index 68982f8686..8032ced0b9 100644 --- a/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php +++ b/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Classes; diff --git a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php index c357afc927..1fa1e4d263 100644 --- a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php +++ b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Classes; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php index 3ed57d2207..889b7010e7 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2017 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php index 23b3ec8fba..e83dff0a79 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2017 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php index 4e00ada1ca..464ea50435 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php @@ -4,7 +4,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php index 1d9eddaa6a..b474c086a0 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php @@ -4,7 +4,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php index 60f00b5d97..c2d45eea7d 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php @@ -4,7 +4,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php index d6f0e3d4a4..376df0c66c 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php @@ -4,7 +4,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php index a99fdd8dda..8f373d929b 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php @@ -4,7 +4,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php index 33bb160a04..5f65d6e3f6 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php @@ -4,7 +4,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php index 063c72073e..b6384888e5 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php @@ -4,7 +4,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php index d6ea1d03ba..b04b2743aa 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php @@ -4,7 +4,7 @@ * * @author Manuel Pichler * @copyright 2007-2014 Manuel Pichler. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc index 81366272c9..8824166722 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc @@ -144,7 +144,7 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -232,7 +232,7 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -245,7 +245,7 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed index 43ce064a5d..46b4cd05bb 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed @@ -139,7 +139,7 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -237,7 +237,7 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -250,7 +250,7 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js index b3283f7853..3506fe0cf8 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js @@ -144,7 +144,7 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -232,7 +232,7 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -245,6 +245,6 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed index 0df0687a2f..f4ca127d66 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed @@ -139,7 +139,7 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -237,7 +237,7 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -250,6 +250,6 @@ * @author Greg Sherwood * @author Marc McIntyre * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php index 57937581ba..4f2c18f9e4 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Commenting; diff --git a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php index e14ab316c3..49104febae 100644 --- a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php @@ -5,7 +5,7 @@ * @author Greg Sherwood * @author Sam Graham * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Commenting; diff --git a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php index 4864b9373a..0651595326 100644 --- a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Commenting; diff --git a/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php index c558ae8f6f..1fd642c8f3 100644 --- a/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\ControlStructures; diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index a9c4f4f8ed..d7e07bb777 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\ControlStructures; diff --git a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php b/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php index 2b86facc16..38ab9a3581 100644 --- a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Debug; diff --git a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php b/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php index 2d960f32d9..25a05a34f8 100644 --- a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Debug; diff --git a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php index 0a079d1489..aae2af2195 100644 --- a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Debug; diff --git a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php b/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php index 6a10e2ad8b..27a56033f8 100644 --- a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Debug; diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php index a95331d72c..2e9fc9ef7a 100644 --- a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php index f5ab9ffa6f..ebda19cbb1 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php index 88dc2f88a1..1333eb7746 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php index 269102dd3e..3aae0bab07 100644 --- a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php @@ -4,7 +4,7 @@ * * @author Matthew Peveler * @copyright 2019 Matthew Peveler - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php index 4403e5d525..870d16788a 100644 --- a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php +++ b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php index 772d4c4a56..10dcc702b2 100644 --- a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php index 4414753a1f..b37f1eb678 100644 --- a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php index f67a40a3be..a0033a7a19 100644 --- a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php @@ -4,7 +4,7 @@ * * @author Andy Grunwald * @copyright 2010-2014 Andy Grunwald - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php index 42a962284e..984daf7170 100644 --- a/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php @@ -4,7 +4,7 @@ * * @author Andy Grunwald * @copyright 2010-2014 Andy Grunwald - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php index f083178793..deced9a4af 100644 --- a/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php @@ -4,7 +4,7 @@ * * @author Andy Grunwald * @copyright 2010-2014 Andy Grunwald - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php index 36a4bb9385..d9e0fc2123 100644 --- a/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php @@ -4,7 +4,7 @@ * * @author Mponos George * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php index 5519309eed..9fe3e4d284 100644 --- a/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php @@ -4,7 +4,7 @@ * * @author Alexander Obuhovich * @copyright 2010-2014 Alexander Obuhovich - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; diff --git a/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php b/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php index 84044d58d9..fb91599052 100644 --- a/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Formatting; diff --git a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php index 23f2f9a780..c6972a9d99 100644 --- a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Formatting; diff --git a/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php index 58627615fd..b2f3f6da34 100644 --- a/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Formatting; diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php index 505ded6c51..8507665649 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Formatting; diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php index 9019bb49d7..3b49e07971 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Formatting; diff --git a/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php index aed6b32ae4..cd2294919e 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Formatting; diff --git a/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php b/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php index 1c10c99fac..eee6288a0f 100644 --- a/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Functions; diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php index 5f87962e62..be92b743db 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Functions; diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php index 10af4fd55a..6d4abebaad 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Functions; diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php index aee774f79a..7cd60a3023 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Functions; diff --git a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php index d3860dff9e..77a3092984 100644 --- a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Metrics; diff --git a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php index ccd7550763..e9e44a3d4e 100644 --- a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Metrics; diff --git a/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php index 7be4e8f887..64450b42a0 100644 --- a/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for the AbstractClassNamePrefix sniff. * * @author Anna Borzenko - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\NamingConventions; diff --git a/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php index 3d0320c3ae..795a6a7428 100644 --- a/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\NamingConventions; diff --git a/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php index e6c6df3f23..2122f16b24 100644 --- a/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\NamingConventions; diff --git a/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php index be23f7a656..66360bcff0 100644 --- a/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for the InterfaceNameSuffix sniff. * * @author Anna Borzenko - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\NamingConventions; diff --git a/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php index 742fdd1ab4..b8d5ba7982 100644 --- a/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php @@ -3,7 +3,7 @@ * Unit test class for the TraitNameSuffix sniff. * * @author Anna Borzenko - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\NamingConventions; diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php index 8db68c8aa9..de68dd6006 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\NamingConventions; diff --git a/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php b/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php index a2541851d7..27c405a883 100644 --- a/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php b/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php index 11f4f14dad..a3fdb72ab9 100644 --- a/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php @@ -4,7 +4,7 @@ * * @author Andy Grunwald * @copyright 2010-2014 Andy Grunwald - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php b/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php index 9c567b7bad..1b88883a99 100644 --- a/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php @@ -4,7 +4,7 @@ * * @author Andy Grunwald * @copyright 2010-2014 Andy Grunwald - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php b/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php index d2f7cb803d..32af71d2d3 100644 --- a/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php index 953e8ad9b5..90c9c137c2 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php index 7ece551201..05f6198ee4 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php @@ -4,7 +4,7 @@ * * @author Jeantwan Teuma * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php index b79572ce6b..3edda9a567 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php b/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php index c1f82d61b7..f96b41bf2c 100644 --- a/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php b/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php index 760e807868..a0e86f2393 100644 --- a/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php index 2fb2d6f6dc..23af1226d8 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php index 6d08e12751..2d415eff1e 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php index fa05aba6a3..197b734a1f 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php index 0e7a4eaa40..a2d3ff8a6e 100644 --- a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php index 4ab417cd02..1340829a0b 100644 --- a/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php @@ -4,7 +4,7 @@ * * @author Sertan Danis * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php b/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php index 08c0ccdcfb..24229b7536 100644 --- a/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php b/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php index 98d205ce43..0477733c34 100644 --- a/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php @@ -5,7 +5,7 @@ * @author Greg Sherwood * @author Blaine Schmeisser * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php index 30e5776337..486ab915bf 100644 --- a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP; diff --git a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php index 6a9284822c..dcf6d68875 100644 --- a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php +++ b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\Strings; diff --git a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php index 50986f48bb..050b08ee9a 100644 --- a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php +++ b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2017 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\VersionControl; diff --git a/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php b/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php index d108974abf..e47d63bcd8 100644 --- a/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php +++ b/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\VersionControl; diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php index 0f70e287af..36c220ae04 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace; diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php index f915cf4aa9..575258fdfe 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace; diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php index 816d24c8d1..2be60b7442 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace; diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php index 0959d673eb..1136bda4e9 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2018 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace; diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php index 14c44da45a..db42ad5b65 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace; diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index 6b0a71028e..23905fdadc 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace; diff --git a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php index 07bf328ce5..c2f342ff57 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace; diff --git a/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php b/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php index 9575398aa6..ae0f280d31 100644 --- a/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php +++ b/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\CSS; diff --git a/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php b/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php index 81b7f1b699..d8458cadd3 100644 --- a/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Channels; diff --git a/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php index 2d56261cf3..1852756819 100644 --- a/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Channels; diff --git a/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php index 8bbd91e828..1c9e5727a8 100644 --- a/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Channels; diff --git a/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php index 6b10cd3ede..9d6ca03800 100644 --- a/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Channels; diff --git a/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php index fd75bcb22e..d5f09b6f74 100644 --- a/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php @@ -6,7 +6,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Commenting; diff --git a/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php b/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php index eccf6fe4b4..e43a10db7f 100644 --- a/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php +++ b/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Debug; diff --git a/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php b/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php index 3115bac4ec..5e342d3387 100644 --- a/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php +++ b/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Debug; diff --git a/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php b/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php index 0a3c9cf21f..7cfe208cb9 100644 --- a/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Objects; diff --git a/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php b/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php index 8fb893760e..7111e2294d 100644 --- a/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Objects; diff --git a/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php b/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php index cae7c08d93..c53165ffca 100644 --- a/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Objects; diff --git a/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php b/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php index 3914b7b8ec..2037ec14b5 100644 --- a/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php @@ -7,7 +7,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\PHP; diff --git a/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php b/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php index 67b35723fa..64492c84e0 100644 --- a/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php +++ b/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\PHP; diff --git a/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php b/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php index 82419fcb89..ff840bf242 100644 --- a/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\PHP; diff --git a/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php b/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php index 9b2029af41..5d11550d50 100644 --- a/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\PHP; diff --git a/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php b/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php index 311cf684fd..e94eba5e06 100644 --- a/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php +++ b/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Strings; diff --git a/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php b/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php index 2135349988..0018af2418 100644 --- a/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php +++ b/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\CSS; diff --git a/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php b/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php index d29bf5c6cd..746637e9ed 100644 --- a/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\Channels; diff --git a/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php b/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php index 0320038ec6..c48d0fe580 100644 --- a/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\Channels; diff --git a/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php b/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php index fbc0ac70b9..6795d3fb81 100644 --- a/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\Channels; diff --git a/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php index 5cc43b6447..53c995c2dd 100644 --- a/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\Commenting; diff --git a/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php b/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php index 78da9c94fe..73e697dcb8 100644 --- a/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php +++ b/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\Debug; diff --git a/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php b/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php index 3a9c235845..039e8e848a 100644 --- a/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php +++ b/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\Debug; diff --git a/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php b/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php index f28dff191d..e758bd9ef3 100644 --- a/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\Objects; diff --git a/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php b/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php index a3c55bf367..4c94b00e84 100644 --- a/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\Objects; diff --git a/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php b/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php index 333952f6c8..b562c37974 100644 --- a/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\Objects; diff --git a/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php b/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php index 315808bd9d..dda88b5319 100644 --- a/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\PHP; diff --git a/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php b/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php index 423f242d9f..25f481c734 100644 --- a/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\PHP; diff --git a/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php b/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php index 16e4cfb277..928de6eb1b 100644 --- a/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\PHP; diff --git a/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php b/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php index 3236378686..fcc6bbce68 100644 --- a/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\PHP; diff --git a/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php b/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php index ecd490a433..85dd342d70 100644 --- a/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php +++ b/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\MySource\Tests\Strings; diff --git a/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php index dbd61f3d23..ae9baad41e 100644 --- a/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Classes; diff --git a/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php index 2e9b59b7bf..0934f11ba0 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting; diff --git a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php index 0009f804a6..2b42648404 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting; diff --git a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php index 1bf9444784..ffa5cb8e8b 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting; diff --git a/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php index aa9f37537e..313f74d25c 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting; diff --git a/src/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php b/src/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php index edd2d6beb9..4ca5451b36 100644 --- a/src/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\ControlStructures; diff --git a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php index fff62bb1ee..f407373566 100644 --- a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php +++ b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\ControlStructures; diff --git a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php index 04f208dee7..763b50c432 100644 --- a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php +++ b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php @@ -6,7 +6,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Files; diff --git a/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php b/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php index 0a7ff7db1e..f7b75cb0b8 100644 --- a/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php +++ b/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Formatting; diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php index b5e8695c15..594325ec30 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions; diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index 14479e2c0a..af18a2b82d 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions; diff --git a/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php b/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php index f13470789b..1e38cc092c 100644 --- a/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions; diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php index 00e68bfec5..e50fd1f57e 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions; diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php index e7f87d44dd..b1521aa682 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions; diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php index 89af5df8e9..48674b1e80 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions; diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php index fb1b79a329..d333a5530d 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace; diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index 097754e578..2b51a8a65b 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace; diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php index 2620d20f2e..e95dc8bda1 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace; diff --git a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php index 4c1d28e733..2ee177cfa3 100644 --- a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Classes; diff --git a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc index e340ff0041..bd7d061806 100644 --- a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc +++ b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.inc @@ -31,7 +31,7 @@ class Invalid_Comment_Style1 * @package PHP_CodeSniffer * @author Greg Sherwood * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @version Release: 1.0 * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -47,7 +47,7 @@ class Extra_Description_Newlines * @package PHP_CodeSniffer * @author Greg Sherwood * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @version * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -136,7 +136,7 @@ enum Empty_Enum_Doc * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ #[Authenticate('admin_logged_in')] @@ -150,7 +150,7 @@ class TodoController extends AbstractController implements MustBeLoggedInInterfa * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ abstract readonly class AbstractReadonlyWithDocblock {} diff --git a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php index 73465fadc9..e0e98bd392 100644 --- a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Commenting; diff --git a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php index 63663ed1b2..8d7354e050 100644 --- a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Commenting; diff --git a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php index e7ec800d02..6283c4a623 100644 --- a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Commenting; diff --git a/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php index 6cc5cd3b5a..3c06d151c6 100644 --- a/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Commenting; diff --git a/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php index 98c3463b7b..f9f72378c6 100644 --- a/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\ControlStructures; diff --git a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php index f78b4e3f3b..9a9b1ca40d 100644 --- a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php +++ b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\ControlStructures; diff --git a/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php b/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php index ab3ea8acec..9661f4409a 100644 --- a/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php +++ b/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Files; diff --git a/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php b/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php index 734d4fce8d..e419b52b69 100644 --- a/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php +++ b/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Formatting; diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php index 4984de2bf6..cebb7a10ea 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Functions; diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php index 01ab3e8482..93a19d1b0d 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Functions; diff --git a/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php b/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php index 60d261cbbb..668611d876 100644 --- a/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Functions; diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php index 54ee74aac1..3fbbb384ef 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\NamingConventions; diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php index 4639a1e2ab..a3a33d975f 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\NamingConventions; diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php index 834852c335..d1a333e751 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\NamingConventions; diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php index 0cad3efc15..63a8fc82f9 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\WhiteSpace; diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php index 265932549a..197a50fa63 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\WhiteSpace; diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php index 0857021b2e..ed1825b359 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PEAR\Tests\WhiteSpace; diff --git a/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php index 3db26f6fd1..19161d77f3 100644 --- a/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR1\Sniffs\Classes; diff --git a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php index 7ad52fa708..dc59e41fe4 100644 --- a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php +++ b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR1\Sniffs\Files; diff --git a/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php b/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php index 2d13814626..0cf1022f05 100644 --- a/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php +++ b/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods; diff --git a/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php index 7c03a9f4ce..600fec9966 100644 --- a/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR1\Tests\Classes; diff --git a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php index 013bf7ce5a..e53b99a8cc 100644 --- a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php +++ b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR1\Tests\Files; diff --git a/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php b/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php index 0b1ef7132c..a3133de49f 100644 --- a/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php +++ b/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR1\Tests\Methods; diff --git a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php index db67fb9428..6dcd464fb9 100644 --- a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes; diff --git a/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php b/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php index 2298da39f4..40e928bdc6 100644 --- a/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes; diff --git a/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php b/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php index fa1f8d60ed..6571af5b19 100644 --- a/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes; diff --git a/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php b/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php index 83ffda4df0..d2a2c5bd8c 100644 --- a/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes; diff --git a/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php b/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php index b87c33918d..e86ff4f289 100644 --- a/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php +++ b/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures; diff --git a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index 3d29c4ace1..5f54aa7cc5 100644 --- a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures; diff --git a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php index 67776c33da..95357a7842 100644 --- a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php @@ -4,7 +4,7 @@ * * @author Sertan Danis * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Files; diff --git a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php index c3d0d0cadc..d2b10aef0e 100644 --- a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Files; diff --git a/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php b/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php index 176aef0061..627b32936a 100644 --- a/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Files; diff --git a/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php b/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php index 4371bee19b..c5cd9d5b6e 100644 --- a/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Files; diff --git a/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php index 8d90734311..3f18a82179 100644 --- a/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2018 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Functions; diff --git a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php index 14d91e2ead..61c45f5e2e 100644 --- a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Functions; diff --git a/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php b/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php index adf04d9088..e79fe38b21 100644 --- a/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php +++ b/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Keywords; diff --git a/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php b/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php index 725fbde311..f87ced057b 100644 --- a/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php +++ b/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Namespaces; diff --git a/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php b/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php index 8757e05a35..c3b48f473d 100644 --- a/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php +++ b/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators; diff --git a/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php b/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php index 7f63d1e87a..5d6882585b 100644 --- a/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php +++ b/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Properties; diff --git a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php index 113e8b9f84..8770467ee2 100644 --- a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Traits; diff --git a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php index cc162b290b..67a3a663e5 100644 --- a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Classes; diff --git a/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php b/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php index 0a16af8fc0..3df377b7ee 100644 --- a/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Classes; diff --git a/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php b/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php index d402f1bb94..a397a8d722 100644 --- a/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Classes; diff --git a/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php b/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php index 71d9d6f48f..3005276fe7 100644 --- a/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Classes; diff --git a/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php b/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php index 3eeaeebc42..d883c5d3d7 100644 --- a/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php +++ b/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\ControlStructures; diff --git a/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php b/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php index 6ee076f2ea..6639e1e828 100644 --- a/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php +++ b/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\ControlStructures; diff --git a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php index 5e75d98a0e..acd407be4e 100644 --- a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php @@ -4,7 +4,7 @@ * * @author Sertan Danis * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Files; diff --git a/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php b/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php index ca9c2b1500..4333f9ba12 100644 --- a/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Files; diff --git a/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php b/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php index 04590b97a6..7ddd42beb8 100644 --- a/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Files; diff --git a/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php b/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php index b94043a31a..8ce5633efd 100644 --- a/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Files; diff --git a/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php index 2344b6d97d..b4905d3650 100644 --- a/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2018 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Functions; diff --git a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php index fc6b5e19c5..edc0d8e0f7 100644 --- a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2018 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Functions; diff --git a/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php b/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php index 460cd55f5e..3e9d9eca41 100644 --- a/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php +++ b/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Keywords; diff --git a/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php b/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php index 41e9db7745..cbc56809dd 100644 --- a/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php +++ b/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Namespaces; diff --git a/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php b/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php index e23fd968b7..1a14da8a79 100644 --- a/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php +++ b/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Operators; diff --git a/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php b/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php index b738706da2..e27bc4875b 100644 --- a/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php +++ b/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Properties; diff --git a/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php index 797a2912e7..5c7e237df6 100644 --- a/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Traits; diff --git a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php index c620582d41..3d5b3d8195 100644 --- a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes; diff --git a/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php index aca0be2d0d..550e0458e0 100644 --- a/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes; diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index 09d2c14a07..9382524fee 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures; diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php index 9f97684a9f..fa89cfee22 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures; diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php index de81c530ee..2554226ac6 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures; diff --git a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php index 39834b3869..ef1dc052f4 100644 --- a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\Files; diff --git a/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php b/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php index aed461f83f..3df15a229b 100644 --- a/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\Files; diff --git a/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php b/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php index 406f27948a..c43a747f1a 100644 --- a/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php +++ b/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods; diff --git a/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php b/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php index 1e11f02f27..4f1716b187 100644 --- a/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php +++ b/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods; diff --git a/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php index d23b8bee2f..6500d04681 100644 --- a/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods; diff --git a/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php index bf37af09bb..2f6bb64fdd 100644 --- a/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\Namespaces; diff --git a/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php index aba9caa717..ba71c30900 100644 --- a/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Sniffs\Namespaces; diff --git a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php index 95c225edb4..64e451544a 100644 --- a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\Classes; diff --git a/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php index 6a1778b904..6c6c662eab 100644 --- a/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\Classes; diff --git a/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php index 35d5e51508..7c67b923d8 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\ControlStructures; diff --git a/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php index 935205b404..6036ab0ff6 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\ControlStructures; diff --git a/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php index 0cd946d888..84a1c7e5c4 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\ControlStructures; diff --git a/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php b/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php index 619f024918..5be71d12ed 100644 --- a/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php +++ b/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\Files; diff --git a/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php index 456106fe5a..ccb9fea2c1 100644 --- a/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\Files; diff --git a/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php b/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php index 1d87825891..7f6ce1f959 100644 --- a/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\Methods; diff --git a/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php b/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php index 2497f35bb5..6e99abecd1 100644 --- a/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\Methods; diff --git a/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php index a8dcdfea58..f7a78f2124 100644 --- a/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\Methods; diff --git a/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php index 71f7bec1ab..8579b3b700 100644 --- a/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\Namespaces; diff --git a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php index b424a2c113..a62eaad9fa 100644 --- a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\PSR2\Tests\Namespaces; diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php index ee63dead11..22dda0edb1 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays; diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php index 64d5d64da2..73454fd99f 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays; diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php index a9a55fa864..156c0f114b 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php index 4b7efd99a0..b3ea8976d1 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php index e56dad7304..0d12ef09d2 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php index 8548a7218e..d4b18d2df1 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php index 6b071ea7cd..f1ede4d628 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php b/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php index def95c1ef0..a32de327e6 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php index d489cb1ba4..9f51b524b1 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php index c74797597e..8c9cf82a43 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php index d3bb9696c6..eccd91e925 100644 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php index 05f2e51596..c77c2488ac 100644 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php b/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php index d8585dc861..183afdbf21 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php b/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php index 5e35f4e9f9..a0f0a9bdba 100644 --- a/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php index c80a639c80..654ca5f5b9 100644 --- a/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php b/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php index dbf7d6c95e..f3887cd7ff 100644 --- a/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php b/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php index 0a51f501bb..4d599e1be5 100644 --- a/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php b/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php index 1dfbcf676d..90763c80f0 100644 --- a/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php index fdc168e242..f668d17f1d 100644 --- a/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php b/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php index 8f2d9aa8c5..57570a761a 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php index 69188326d9..3f5e1fbc79 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes; diff --git a/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php b/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php index 88a7e0daae..681b5e19e9 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes; diff --git a/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php b/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php index a632f81e92..1638d1f163 100644 --- a/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes; diff --git a/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php b/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php index 2ea5ad8bc2..1842eea1b2 100644 --- a/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes; diff --git a/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php b/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php index d17ca44ce1..407d3dae2a 100644 --- a/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php @@ -9,7 +9,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes; diff --git a/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php b/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php index ffddd2cde7..0f019d35b6 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes; diff --git a/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php index eb647f5fe7..81d8580538 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php index 3f30036a8d..4c4d3badea 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php @@ -12,7 +12,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php index cd509d0c89..dc4921bcde 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php index 1f49d2c0c9..55cd62526e 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php index 4fc252197d..2ec8add0d4 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php index a1c79c6a25..ec31e4f6d7 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index 3c79a7a8c4..21c8229998 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php index a168bfe6ca..33c558cfe0 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php index e3ef5c0dc1..1306d185aa 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php index 103d90ffba..33bd8e6cc0 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php index ce19d5c1d9..28cb7430d1 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php index 32e89789a7..d2d53e2c3b 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php index 8a56b23fcb..e2794aaf02 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php index 8abb8fb3cd..580f053cbc 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php index c5f22e23bb..e0d22c3c4a 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php index 370eab1890..1c6ffe3dc7 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php index 28443794a3..c8501116aa 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php index cba076840a..10d76cd46a 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php index a5f3769db1..a5bd11fc86 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures; diff --git a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php index 49dfc2c42f..11ed4f26c8 100644 --- a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php +++ b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug; diff --git a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php index 30dca6722d..8eae332f16 100644 --- a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php +++ b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug; diff --git a/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php b/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php index 6277b809e6..4069a22e13 100644 --- a/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php +++ b/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Files; diff --git a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php index 8becb74a4e..6e60aadd10 100644 --- a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php +++ b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Formatting; diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php index e696d8001d..2c9e7c56a1 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions; diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php index 4b6a6acfdf..fdb391c285 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions; diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php index f6fc383ae3..ecf06ac258 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions; diff --git a/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php b/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php index 24588a912f..3ecb31e305 100644 --- a/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions; diff --git a/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php b/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php index 2357960c27..471c602e68 100644 --- a/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions; diff --git a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php index c12bd0c47c..635116d2d9 100644 --- a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions; diff --git a/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php index 878035e67a..2450ba7fdb 100644 --- a/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions; diff --git a/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php index 5c3a74930e..79f9c4b231 100644 --- a/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions; diff --git a/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php b/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php index c324e20586..b8757c5399 100644 --- a/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php @@ -4,7 +4,7 @@ * * @author Sertan Danis * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects; diff --git a/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php b/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php index 84facf0540..5f43d1b770 100644 --- a/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects; diff --git a/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php b/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php index 787d3fc82d..7c943a8bee 100644 --- a/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects; diff --git a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php index 85e9825f89..58d529ed42 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators; diff --git a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php index cb3778453a..af2a377e23 100644 --- a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators; diff --git a/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php b/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php index f9ea62020d..bc964b7e48 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators; diff --git a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php index 04d0633871..87e5d3c80e 100644 --- a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php index 9d8077f592..99171bdb7a 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php index 9eb2124233..595afc5370 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php index 60b0c370a5..9bd02637c0 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php index 4448d2445b..2598b44859 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php index a0f1161c6a..1842ef87d7 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php index 9f86a1798c..56fce551d2 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index ef11aa6c48..22911d80c6 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php b/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php index 3162c14b14..74539d9338 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php b/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php index 024eff8ac3..a76fc73a2f 100644 --- a/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php b/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php index 67369cb221..6003dc1891 100644 --- a/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php index e42ef5a16a..0d0b93f4f0 100644 --- a/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php index 37f1e40e7b..134db8881d 100644 --- a/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index 31d9c5a351..7bcb89dcfe 100644 --- a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP; diff --git a/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php b/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php index 5239b644e2..3d1c83f019 100644 --- a/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php +++ b/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope; diff --git a/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php b/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php index 8a34a4f29f..39ed5b0dd4 100644 --- a/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php +++ b/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope; diff --git a/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php b/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php index f3b5495d90..aab5bdb7ad 100644 --- a/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope; diff --git a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php index 9d32e54a0a..99b935eded 100644 --- a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Strings; diff --git a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php index 1ff99b9ca5..f2e76f00dc 100644 --- a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Strings; diff --git a/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php b/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php index 512d878a4b..2bf1b0530c 100644 --- a/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Strings; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php index 95f95ed6b9..8162f48817 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index 808888f404..1500b576bd 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php index 68871990b9..83b4a4de62 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php index 09c5a48a58..dc9f32e995 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php index 1f4704b91f..32af8b4ca0 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php index c1492bf7bd..c6fe537fda 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php index a89a02a941..2d84b38881 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php index 0ece1acad2..c2d82c0695 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php index cc5db16446..1c1f80c556 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php index f1e2fce692..aeeb3665f6 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php index 198460dfcd..b21660c439 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index fd03875347..5251bce874 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php index 2d800f0520..1424819f51 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php index bdcf9a5ddd..a1aa6c5e5e 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php index e99d829bca..bc24f99766 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php @@ -8,7 +8,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php b/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php index 304a0d4245..ad74ac3fd5 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Arrays; diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php index 9d917b46b0..d723e577e0 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Arrays; diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php index 528fcfd6fb..da5ca616e8 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php index 41202bc8d1..db3cfa8941 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php index d1e44219c4..69698b1486 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php index 9b8aa10300..a7b0307d55 100644 --- a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php index d535fdc2ed..50b6a82b1b 100644 --- a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php index 8e3b487382..56070b620e 100644 --- a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php index 2a95971b05..4361c18e7a 100644 --- a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php index c555461b18..7c430b2792 100644 --- a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php index b3fd318c92..7efde6b5bd 100644 --- a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php index f5bc858d03..5118d1b54e 100644 --- a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php index 28aa8ec304..1857f6c61b 100644 --- a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php index 9413b4ffb7..2fa963f354 100644 --- a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php index 1a25aaac88..1c6e86f0fb 100644 --- a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php b/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php index dc0809e26a..e1b07f2406 100644 --- a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php b/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php index a8032fad3b..bd880a516c 100644 --- a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php index 9fe839da5d..bde499d62d 100644 --- a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php index 897df65ec9..980fd96956 100644 --- a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php index 3d0baaaded..4b92b21904 100644 --- a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; diff --git a/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php index 23d89ec77a..f4698e74ab 100644 --- a/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Classes; diff --git a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php index 5964d2b1ec..2a2c2a63bd 100644 --- a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Classes; diff --git a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php b/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php index 1b71eb2c6a..f887aaec9e 100644 --- a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Classes; diff --git a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php index b4d5aae5a1..de07e252de 100644 --- a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Classes; diff --git a/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php b/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php index ea493d3cbb..63829e3627 100644 --- a/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Classes; diff --git a/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php b/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php index b7de260b65..2257638af5 100644 --- a/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Classes; diff --git a/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php index c8a360e244..aaa1b882c0 100644 --- a/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php index b370d547c0..ed64d93bfc 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php index 6f5166ec6b..7e44a01c6d 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php index acbf13e869..8ff7ec5eb6 100644 --- a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php index 3c1668e440..d53429e019 100644 --- a/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php index 1402432aec..6e6ad1a031 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php index 1e2d07fafb..8b54e400d9 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php index ff1d10c487..866b1e9664 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php index e4a5298bf4..04c3ed9973 100644 --- a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php index 5b61612c50..b369830fe1 100644 --- a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php index a04426f15a..5e4c97b80f 100644 --- a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php index 1af5e14845..a83791c624 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php index 92427f0da1..78afbf0e99 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\ControlStructures; diff --git a/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php index f0d9210f38..f119fe8db8 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\ControlStructures; diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php index 6957ff6781..ccb77521fc 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\ControlStructures; diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php index 51638866ed..4aef1d7a98 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\ControlStructures; diff --git a/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php index 97212dbafe..87d52fc432 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\ControlStructures; diff --git a/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php index dc8a3ac6c0..b0085487b3 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\ControlStructures; diff --git a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php index c94c8333a5..4211345db3 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\ControlStructures; diff --git a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php index 7ccfe1a316..2eff82d656 100644 --- a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php +++ b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Debug; diff --git a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php index 1e83f1f40d..dac3b3addf 100644 --- a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php +++ b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Debug; diff --git a/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php b/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php index 7e613b330b..992f26221b 100644 --- a/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php +++ b/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Files; diff --git a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php index 4f04a6ebd0..feaf1dcd4f 100644 --- a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php +++ b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Formatting; diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php index 65e987dda4..9d97a2bf26 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Functions; diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php index a939a9051f..e53e9e7acd 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Functions; diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php index da09cef348..88568b79fd 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Functions; diff --git a/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php b/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php index 7be76488e6..efea5445f1 100644 --- a/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Functions; diff --git a/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php b/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php index 1e1537b7d2..d2ad14b75e 100644 --- a/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Functions; diff --git a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php index 5208ad0cdb..ac8c1f9992 100644 --- a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Functions; diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php index 77f13bb258..1a58cae166 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\NamingConventions; diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php index 9acbe241a8..e69f2b7bcd 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\NamingConventions; diff --git a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php index cb2d58e543..f98b13983a 100644 --- a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php @@ -4,7 +4,7 @@ * * @author Sertan Danis * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Objects; diff --git a/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php b/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php index f9979fa29f..8c82d0c3b8 100644 --- a/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Objects; diff --git a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php index ab1cf8108a..3b37ed55f5 100644 --- a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Objects; diff --git a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php index 5618a7fc0c..5062f1dfea 100644 --- a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Operators; diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php index 3846905da0..c77425d11e 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Operators; diff --git a/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php b/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php index fc35131982..ca38f9ed77 100644 --- a/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Operators; diff --git a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php index 36c556d8c2..4dc9c6855c 100644 --- a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php index 6439b63237..348bcd65f7 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php index c8d8b0b87d..d4485b8707 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php index 27083ce2c1..086255154b 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php index 618d76efa4..ee4f958fab 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php index 21260ad718..d9d7f261e5 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php index 2b2ff5b4aa..077c896e27 100644 --- a/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php index f8cf4cc799..ef825be46a 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php b/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php index adee788268..bfeb595cd5 100644 --- a/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php b/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php index 52f6a00a55..1a9f1d0e64 100644 --- a/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php index 2f06f0b083..326d3cada2 100644 --- a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php index b0b13b6147..cd3a49d36d 100644 --- a/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php index 708d01ef08..83460f2b51 100644 --- a/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php index 40e4068e42..dca8e7d545 100644 --- a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\PHP; diff --git a/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php b/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php index 59e49910df..7d94ba5322 100644 --- a/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Scope; diff --git a/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php b/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php index 4dc7177953..cf99afb07b 100644 --- a/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Scope; diff --git a/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php b/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php index b1a5dd6afd..076af551cd 100644 --- a/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Scope; diff --git a/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php b/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php index 862af7d203..9818c2c675 100644 --- a/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Strings; diff --git a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php index a95d1888b2..a0330eaeac 100644 --- a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Strings; diff --git a/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php b/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php index 0d9af1e936..61d5db666c 100644 --- a/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Strings; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php index 48bc841fd8..f87eb7c84a 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php index ac3f5d6ff5..20050c27ad 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php index 2e18f875b3..ee3a63048d 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php index 438263ebe1..caef988ef6 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php index fabb6adb92..2a3107c75e 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php index 46b0d858fd..d8993959c1 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php index 62b74e369f..9b71ceb133 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php index 9b4066811a..3819a84e0a 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php index 82a4056f7e..a9e8ebf6b9 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php index 8e8ad98d08..65e5ca4767 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php index e80f93670e..a63070b0d8 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php index d659d64731..087ac8a446 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php index 30b66215c9..6862807c1f 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php index 72196f8e78..b53be50aad 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php index 2f1ead2307..ba9f474db6 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; diff --git a/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php b/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php index 5df4b0fc2c..a77635eadd 100644 --- a/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php +++ b/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php @@ -5,7 +5,7 @@ * @author Holger Kral * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Zend\Sniffs\Debug; diff --git a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php index 0ed34d13c1..e5e0c22d7a 100644 --- a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Zend\Sniffs\Files; diff --git a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php index 267cd0ad62..2dfeb39aa6 100644 --- a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Zend\Sniffs\NamingConventions; diff --git a/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php b/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php index efd3b900e5..f1e04521c5 100644 --- a/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php +++ b/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Zend\Tests\Debug; diff --git a/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php b/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php index 4a42cde094..f13b78b67a 100644 --- a/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php +++ b/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Zend\Tests\Files; diff --git a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php index e57c735646..7ed046c890 100644 --- a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Standards\Zend\Tests\NamingConventions; diff --git a/src/Tokenizers/CSS.php b/src/Tokenizers/CSS.php index 2f486d6cfa..d3f71b3794 100644 --- a/src/Tokenizers/CSS.php +++ b/src/Tokenizers/CSS.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tokenizers; diff --git a/src/Tokenizers/Comment.php b/src/Tokenizers/Comment.php index beba53c2bb..9ca2ddf267 100644 --- a/src/Tokenizers/Comment.php +++ b/src/Tokenizers/Comment.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tokenizers; diff --git a/src/Tokenizers/JS.php b/src/Tokenizers/JS.php index ee2f842948..8ef0ad92f1 100644 --- a/src/Tokenizers/JS.php +++ b/src/Tokenizers/JS.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tokenizers; diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 0fa6d42c17..42ba192e91 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tokenizers; diff --git a/src/Tokenizers/Tokenizer.php b/src/Tokenizers/Tokenizer.php index 0e00bf7f22..53407a2da0 100644 --- a/src/Tokenizers/Tokenizer.php +++ b/src/Tokenizers/Tokenizer.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tokenizers; diff --git a/src/Util/Cache.php b/src/Util/Cache.php index 68abef59c4..3910fabe3b 100644 --- a/src/Util/Cache.php +++ b/src/Util/Cache.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Util; diff --git a/src/Util/Common.php b/src/Util/Common.php index ce7967cc33..b8e3d4f80e 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Util; diff --git a/src/Util/Standards.php b/src/Util/Standards.php index 65e5d6cb3c..ca1060bc9f 100644 --- a/src/Util/Standards.php +++ b/src/Util/Standards.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Util; diff --git a/src/Util/Timing.php b/src/Util/Timing.php index 95ee85216d..8cd3524186 100644 --- a/src/Util/Timing.php +++ b/src/Util/Timing.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Util; diff --git a/src/Util/Tokens.php b/src/Util/Tokens.php index bb1fb2ca99..ab70e78322 100644 --- a/src/Util/Tokens.php +++ b/src/Util/Tokens.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Util; diff --git a/tests/AllTests.php b/tests/AllTests.php index 9d099c1e3d..cb22aabf1b 100644 --- a/tests/AllTests.php +++ b/tests/AllTests.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests; diff --git a/tests/Core/AbstractMethodUnitTest.php b/tests/Core/AbstractMethodUnitTest.php index 4d4f546995..f9ecd81831 100644 --- a/tests/Core/AbstractMethodUnitTest.php +++ b/tests/Core/AbstractMethodUnitTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2018-2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core; diff --git a/tests/Core/AllTests.php b/tests/Core/AllTests.php index 304690eff0..60547bb363 100644 --- a/tests/Core/AllTests.php +++ b/tests/Core/AllTests.php @@ -5,7 +5,7 @@ * @author Greg Sherwood * @author Juliette Reinders Folmer * @copyright 2006-2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core; diff --git a/tests/Core/Autoloader/DetermineLoadedClassTest.php b/tests/Core/Autoloader/DetermineLoadedClassTest.php index c0f38fa6f1..af14d83266 100644 --- a/tests/Core/Autoloader/DetermineLoadedClassTest.php +++ b/tests/Core/Autoloader/DetermineLoadedClassTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Autoloader; diff --git a/tests/Core/Config/ReportWidthTest.php b/tests/Core/Config/ReportWidthTest.php index aa5375a42c..8d92a4d1bc 100644 --- a/tests/Core/Config/ReportWidthTest.php +++ b/tests/Core/Config/ReportWidthTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2006-2023 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Config; diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index 7181613c62..3c99f5f999 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core; diff --git a/tests/Core/File/FindEndOfStatementTest.php b/tests/Core/File/FindEndOfStatementTest.php index 7bff26b566..4f9b3b0604 100644 --- a/tests/Core/File/FindEndOfStatementTest.php +++ b/tests/Core/File/FindEndOfStatementTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\File; diff --git a/tests/Core/File/FindExtendedClassNameTest.php b/tests/Core/File/FindExtendedClassNameTest.php index f39377e6c8..a82e1e590e 100644 --- a/tests/Core/File/FindExtendedClassNameTest.php +++ b/tests/Core/File/FindExtendedClassNameTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\File; diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.php b/tests/Core/File/FindImplementedInterfaceNamesTest.php index 2395032897..4e2885f1ca 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.php +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\File; diff --git a/tests/Core/File/FindStartOfStatementTest.php b/tests/Core/File/FindStartOfStatementTest.php index ff859eca1c..dabb706c78 100644 --- a/tests/Core/File/FindStartOfStatementTest.php +++ b/tests/Core/File/FindStartOfStatementTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\File; diff --git a/tests/Core/File/GetClassPropertiesTest.php b/tests/Core/File/GetClassPropertiesTest.php index fb816ad586..7eed507307 100644 --- a/tests/Core/File/GetClassPropertiesTest.php +++ b/tests/Core/File/GetClassPropertiesTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2022 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\File; diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index 934d8e2890..a207e2c2ba 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\File; diff --git a/tests/Core/File/GetMethodParametersTest.php b/tests/Core/File/GetMethodParametersTest.php index b5bd61813c..6cd2d6e87b 100644 --- a/tests/Core/File/GetMethodParametersTest.php +++ b/tests/Core/File/GetMethodParametersTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\File; diff --git a/tests/Core/File/GetMethodPropertiesTest.php b/tests/Core/File/GetMethodPropertiesTest.php index 66f4eea3ea..3a32aa5f61 100644 --- a/tests/Core/File/GetMethodPropertiesTest.php +++ b/tests/Core/File/GetMethodPropertiesTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\File; diff --git a/tests/Core/File/IsReferenceTest.php b/tests/Core/File/IsReferenceTest.php index ea2dddbad3..d40bee98ef 100644 --- a/tests/Core/File/IsReferenceTest.php +++ b/tests/Core/File/IsReferenceTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\File; diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index 2c9f57cd39..84c4487abc 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -5,7 +5,7 @@ * @author Willington Vega * @author Juliette Reinders Folmer * @copyright 2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Filters\Filter; diff --git a/tests/Core/IsCamelCapsTest.php b/tests/Core/IsCamelCapsTest.php index b60d524b03..94766260ff 100644 --- a/tests/Core/IsCamelCapsTest.php +++ b/tests/Core/IsCamelCapsTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core; diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php index 8b138e0b01..079934a6b5 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Ruleset; diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.xml b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.xml index 64d1aae681..2978cef9f3 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.xml +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php index f8e3255b88..633b729306 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Ruleset; diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.xml b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.xml index 15710d2098..e92c688427 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.xml +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/RuleInclusionTest-include.xml b/tests/Core/Ruleset/RuleInclusionTest-include.xml index ca116d45e7..d95af20d97 100644 --- a/tests/Core/Ruleset/RuleInclusionTest-include.xml +++ b/tests/Core/Ruleset/RuleInclusionTest-include.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index 8a1bfd9ce5..6772d54c76 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Ruleset; diff --git a/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml b/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml index 21dba9da8f..70859bac8c 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml b/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml index 03424db26e..65e22555f3 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml b/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml index 4e4fd59e65..ba094db24a 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml b/tests/Core/Ruleset/SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml index cb4f489d37..7c4ca4fd35 100644 --- a/tests/Core/Ruleset/SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml +++ b/tests/Core/Ruleset/SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml b/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml index 044414c0f5..979b48f522 100644 --- a/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml +++ b/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml b/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml index 759c6c655a..48a36a8313 100644 --- a/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml +++ b/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml b/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml index d9f808e383..e411520c19 100644 --- a/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml +++ b/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyThrowsErrorOnInvalidPropertyTest.xml b/tests/Core/Ruleset/SetPropertyThrowsErrorOnInvalidPropertyTest.xml index 435601affb..5dca1a010d 100644 --- a/tests/Core/Ruleset/SetPropertyThrowsErrorOnInvalidPropertyTest.xml +++ b/tests/Core/Ruleset/SetPropertyThrowsErrorOnInvalidPropertyTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetSniffPropertyTest.php b/tests/Core/Ruleset/SetSniffPropertyTest.php index 9dbfc7bc88..5add67b1e4 100644 --- a/tests/Core/Ruleset/SetSniffPropertyTest.php +++ b/tests/Core/Ruleset/SetSniffPropertyTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2022 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Ruleset; diff --git a/tests/Core/Sniffs/AbstractArraySniffTest.php b/tests/Core/Sniffs/AbstractArraySniffTest.php index 20c28d60b2..3a9a6c4df2 100644 --- a/tests/Core/Sniffs/AbstractArraySniffTest.php +++ b/tests/Core/Sniffs/AbstractArraySniffTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Sniffs; diff --git a/tests/Core/Sniffs/AbstractArraySniffTestable.php b/tests/Core/Sniffs/AbstractArraySniffTestable.php index a224012f22..751b01a8b9 100644 --- a/tests/Core/Sniffs/AbstractArraySniffTestable.php +++ b/tests/Core/Sniffs/AbstractArraySniffTestable.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Sniffs; diff --git a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php index a4bc49f9a4..9a5470971a 100644 --- a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php +++ b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/ArrayKeywordTest.php b/tests/Core/Tokenizer/ArrayKeywordTest.php index 237258a62a..b831ed74af 100644 --- a/tests/Core/Tokenizer/ArrayKeywordTest.php +++ b/tests/Core/Tokenizer/ArrayKeywordTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2021 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/AttributesTest.php b/tests/Core/Tokenizer/AttributesTest.php index 8ac826f2f6..1593f0f44f 100644 --- a/tests/Core/Tokenizer/AttributesTest.php +++ b/tests/Core/Tokenizer/AttributesTest.php @@ -4,7 +4,7 @@ * * @author Alessandro Chitolina * @copyright 2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/BackfillEnumTest.php b/tests/Core/Tokenizer/BackfillEnumTest.php index 33cff3a2c7..7c72672137 100644 --- a/tests/Core/Tokenizer/BackfillEnumTest.php +++ b/tests/Core/Tokenizer/BackfillEnumTest.php @@ -4,7 +4,7 @@ * * @author Jaroslav Hanslík * @copyright 2021 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php b/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php index ddc3ff10b6..a01754a5ae 100644 --- a/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php +++ b/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php @@ -4,7 +4,7 @@ * * @author Mark Baker * @copyright 2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/BackfillFnTokenTest.php b/tests/Core/Tokenizer/BackfillFnTokenTest.php index 4d0f4c0649..e6935331b3 100644 --- a/tests/Core/Tokenizer/BackfillFnTokenTest.php +++ b/tests/Core/Tokenizer/BackfillFnTokenTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/BackfillMatchTokenTest.php b/tests/Core/Tokenizer/BackfillMatchTokenTest.php index 80f909acdf..72ca61e6da 100644 --- a/tests/Core/Tokenizer/BackfillMatchTokenTest.php +++ b/tests/Core/Tokenizer/BackfillMatchTokenTest.php @@ -5,7 +5,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020-2021 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php index 645088fd6c..4b96801b5f 100644 --- a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php +++ b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2019 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index dddc18ebc2..eb7ec5d8d7 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -4,7 +4,7 @@ * * @author Jaroslav Hanslík * @copyright 2021 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/BitwiseOrTest.php b/tests/Core/Tokenizer/BitwiseOrTest.php index d56e7340aa..e96b7840ad 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.php +++ b/tests/Core/Tokenizer/BitwiseOrTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php index 3f077ca639..21233511d1 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php @@ -4,7 +4,7 @@ * * @author Jaroslav Hanslík * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/DefaultKeywordTest.php b/tests/Core/Tokenizer/DefaultKeywordTest.php index 9a5b061a05..9f89ce5948 100644 --- a/tests/Core/Tokenizer/DefaultKeywordTest.php +++ b/tests/Core/Tokenizer/DefaultKeywordTest.php @@ -5,7 +5,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020-2021 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/DoubleArrowTest.php b/tests/Core/Tokenizer/DoubleArrowTest.php index ad1a411ff3..e1a0174d7b 100644 --- a/tests/Core/Tokenizer/DoubleArrowTest.php +++ b/tests/Core/Tokenizer/DoubleArrowTest.php @@ -6,7 +6,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020-2021 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/DoubleQuotedStringTest.php b/tests/Core/Tokenizer/DoubleQuotedStringTest.php index cc9fe49ec4..4e837babac 100644 --- a/tests/Core/Tokenizer/DoubleQuotedStringTest.php +++ b/tests/Core/Tokenizer/DoubleQuotedStringTest.php @@ -5,7 +5,7 @@ * * @author Juliette Reinders Folmer * @copyright 2022 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/EnumCaseTest.php b/tests/Core/Tokenizer/EnumCaseTest.php index 61141da4fe..d4b6fe7c07 100644 --- a/tests/Core/Tokenizer/EnumCaseTest.php +++ b/tests/Core/Tokenizer/EnumCaseTest.php @@ -4,7 +4,7 @@ * * @author Jaroslav Hanslík * @copyright 2021 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/FinallyTest.php b/tests/Core/Tokenizer/FinallyTest.php index 2b28bc5d30..d5e089a05b 100644 --- a/tests/Core/Tokenizer/FinallyTest.php +++ b/tests/Core/Tokenizer/FinallyTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2021 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/GotoLabelTest.php b/tests/Core/Tokenizer/GotoLabelTest.php index 0f937cc8b0..f3799e755e 100644 --- a/tests/Core/Tokenizer/GotoLabelTest.php +++ b/tests/Core/Tokenizer/GotoLabelTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php index 6e32240700..dbefd23f9d 100644 --- a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php +++ b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/HeredocStringTest.php b/tests/Core/Tokenizer/HeredocStringTest.php index 2c808be906..993fd98c97 100644 --- a/tests/Core/Tokenizer/HeredocStringTest.php +++ b/tests/Core/Tokenizer/HeredocStringTest.php @@ -5,7 +5,7 @@ * * @author Juliette Reinders Folmer * @copyright 2022 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php index cc57637c6f..8819a202b1 100644 --- a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php +++ b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php b/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php index 8e465a3be1..83b48e67f1 100644 --- a/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php +++ b/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php b/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php index 23cbd9877c..143179547f 100644 --- a/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php +++ b/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/ShortArrayTest.php b/tests/Core/Tokenizer/ShortArrayTest.php index 1d97894f59..3cf9cd14e6 100644 --- a/tests/Core/Tokenizer/ShortArrayTest.php +++ b/tests/Core/Tokenizer/ShortArrayTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php index 389bb74e69..781fc1b7e3 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php @@ -10,7 +10,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php index 9ab66e9c7a..3fef5e421e 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php @@ -7,7 +7,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.php b/tests/Core/Tokenizer/TypeIntersectionTest.php index 2170021933..4d18485c39 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.php +++ b/tests/Core/Tokenizer/TypeIntersectionTest.php @@ -5,7 +5,7 @@ * @author Juliette Reinders Folmer * @author Jaroslav Hanslík * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php index 24667e486f..72ee773f0f 100644 --- a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php +++ b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php @@ -14,7 +14,7 @@ * * @author Juliette Reinders Folmer * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; diff --git a/tests/FileList.php b/tests/FileList.php index 8ef57b7aff..1672411deb 100644 --- a/tests/FileList.php +++ b/tests/FileList.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests; diff --git a/tests/Standards/AbstractSniffUnitTest.php b/tests/Standards/AbstractSniffUnitTest.php index c050a0c2af..78699a7639 100644 --- a/tests/Standards/AbstractSniffUnitTest.php +++ b/tests/Standards/AbstractSniffUnitTest.php @@ -8,7 +8,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Standards; diff --git a/tests/Standards/AllSniffs.php b/tests/Standards/AllSniffs.php index 24527dd51c..ced988e920 100644 --- a/tests/Standards/AllSniffs.php +++ b/tests/Standards/AllSniffs.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Standards; diff --git a/tests/TestSuite.php b/tests/TestSuite.php index 9eb269f8b8..ff7bde7e43 100644 --- a/tests/TestSuite.php +++ b/tests/TestSuite.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests; diff --git a/tests/TestSuite7.php b/tests/TestSuite7.php index 43db293d5e..a4dabf5fc2 100644 --- a/tests/TestSuite7.php +++ b/tests/TestSuite7.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 47084d1135..e8020a06fc 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,7 +4,7 @@ * * @author Greg Sherwood * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ if (defined('PHP_CODESNIFFER_IN_TESTS') === false) { From 6d22f38f6c846512d321f3d5ac15c8805c694084 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 8 Nov 2023 05:19:17 +0100 Subject: [PATCH 007/874] README: update badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f6ac8c452..5c71918147 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ PHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second `phpcbf` script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. -[![Build Status](https://github.com/PHPCSStandards/PHP_CodeSniffer/workflows/Validate/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions) -[![Build Status](https://github.com/PHPCSStandards/PHP_CodeSniffer/workflows/Test/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions) +[![Validate](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/validate.yml/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/validate.yml) +[![Test](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml) ## Requirements From 73806933a816eeb82a5574e879bc0600aff3f885 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 6 Nov 2023 23:08:35 +0100 Subject: [PATCH 008/874] Drop support for releasing via PEAR PEAR is barely used anymore and registering this fork as a new package on PEAR does not seem worth the effort considering that PEAR install support was going to be dropped in 4.0 anyway. This means that new releases will no longer be available via PEAR. Installing via Composer, PHIVE, PHAR download and git clones will still be supported. --- .github/workflows/validate.yml | 20 - CHANGELOG.md | 5182 ++++++++++ README.md | 5 - package.xml | 8631 ----------------- .../ValidatePEAR/ValidatePEARPackageXML.php | 363 - scripts/validate-pear-package.php | 19 - src/Config.php | 7 - .../Tests/Files/ExecutableFileUnitTest.php | 6 +- tests/AllTests.php | 10 +- tests/Core/Filters/Filter/AcceptTest.php | 22 - .../RuleInclusionAbsoluteLinuxTest.php | 7 - .../RuleInclusionAbsoluteWindowsTest.php | 7 - tests/Core/Ruleset/RuleInclusionTest.php | 22 - tests/Core/Ruleset/SetSniffPropertyTest.php | 17 - tests/Standards/AllSniffs.php | 11 +- tests/bootstrap.php | 7 - 16 files changed, 5187 insertions(+), 9149 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 package.xml delete mode 100644 scripts/ValidatePEAR/ValidatePEARPackageXML.php delete mode 100644 scripts/validate-pear-package.php diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 887b9c2b7b..366dc7ace4 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -58,23 +58,3 @@ jobs: diff -B ./src/Standards/PSR12/ruleset.xml <(xmllint --format "./src/Standards/PSR12/ruleset.xml") diff -B ./src/Standards/Squiz/ruleset.xml <(xmllint --format "./src/Standards/Squiz/ruleset.xml") diff -B ./src/Standards/Zend/ruleset.xml <(xmllint --format "./src/Standards/Zend/ruleset.xml") - - pear: - name: "PHP: 7.4 | PEAR package validation" - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - coverage: none - - - name: Validate the PEAR package file contents - run: php scripts/validate-pear-package.php - - - name: Validate the PEAR package - run: pear package-validate package.xml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..0d4f85e60e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5182 @@ +# Changelog +The file documents changes to the PHP_CodeSniffer project. + +## [Unreleased] + +### Added +- Added support for 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 readonly class to a number of sniffs + - Generic.CodeAnalysis.UnnecessaryFinalModifier + - PEAR.Commenting.ClassComment + - PEAR.Commenting.FileComment + - PSR2.Classes.ClassDeclaration + - 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 +- 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 + +### 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 + - 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 an auto 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 +- 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 + - Thanks to @Daimona for the patch + +### Removed +- Removed support for installing via PEAR + - Use composer or the phar files + +### Fixed +- 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 #3717 : Squiz.Commenting.FunctionComment: fixed false positive for InvalidNoReturn when type is never + - Thanks to Choraimy Kroonstuiver (@axlon) 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 #3728 : PHP 8.2 | PSR1/SideEffects: allow for readonly classes + - 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 #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 #3779 : Squiz/LowercasePHPFunctions + 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 #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 + - Thanks to @Daimona for the patch +- Fixed bug #3809 : GitBlame report was broken when passing a basepath + - Thanks to Chris (@datengraben) for the patch +- 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 #3816 : PSR12/FileHeader: bug fix - false positives on PHP 8.2+ readonly classes + - 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 + - Thanks to @simonsan for the patch +- Fixed bug #3906 : Tokenizer/CSS: fixed a bug related to the unsupported slash comment syntax + - Thanks to Dan Wallis (@fredden) for the patch + +## [3.7.2] - 2023-02-23 +### Changed +- Newer versions of Composer will now suggest installing PHPCS using require-dev instead of require + - Thanks to Gary Jones (@GaryJones) for the patch +- 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 +- 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] - 2022-06-18 +### Fixed +- 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] - 2022-06-13 +### Added +- 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 for the patch + - Thanks to Juliette Reinders Folmer 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 for the patch + - Thanks to Juliette Reinders Folmer 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 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 for the patch + +### Changed +- 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 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 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 for the patch +- The list of installed coding standards now has consistent ordering across all platforms + - Thanks to Juliette Reinders Folmer 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 for the patch +- Generic.PHP.LowerCaseType now supports the PHP 8.1 never type + - Thanks to Jaroslav Hanslík for the patch + +### Fixed +- 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 +- Fixed bug #3505 : The nullsafe operator is not counted in Generic.Metrics.CyclomaticComplexity + - Thanks to Mark Baker for the patch +- Fixed bug #3526 : PSR12.Properties.ConstantVisibility false positive when using public final const syntax + - Thanks to Juliette Reinders Folmer 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 for the patch +- Fixed bug #3546 : Tokenizer/PHP: bug fix - parent/static keywords in class instantiations + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3550 : False positive from PSR2.ControlStructures.SwitchDeclaration.TerminatingComment when using trailing comment + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3575: Squiz.Scope.MethodScope misses visibility keyword on previous line + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3604: Tokenizer/PHP: bug fix for double quoted strings using ${ + - Thanks to Juliette Reinders Folmer for the patch + +## [3.6.2] - 2021-12-13 +### Changed +- Processing large code bases that use tab indenting inside comments and strings will now be faster + - Thanks to Thiemo Kreuz for the patch + +### Fixed +- Fixed bug #3388 : phpcs does not work when run from WSL drives + - Thanks to Juliette Reinders Folmer and Graham Wharton for the patch +- Fixed bug #3422 : Squiz.WhiteSpace.ScopeClosingBrace fixer removes HTML content when fixing closing brace alignment + - Thanks to Juliette Reinders Folmer 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 for the patch +- Fixed bug #3448 : PHP 8.1 deprecation notice while generating running time value + - Thanks to Juliette Reinders Folmer and Andy Postnikov for the patch +- Fixed bug #3456 : PSR12.Classes.ClassInstantiation.MissingParentheses false positive using attributes on anonymous class + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3460 : Generic.Formatting.MultipleStatementAlignment false positive on closure with parameters + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3468 : do/while loops are double-counted in Generic.Metrics.CyclomaticComplexity + - Thanks to Mark Baker for the patch +- Fixed bug #3469 : Ternary Operator and Null Coalescing Operator are not counted in Generic.Metrics.CyclomaticComplexity + - Thanks to Mark Baker for the patch +- Fixed bug #3472 : PHP 8 match() expression is not counted in Generic.Metrics.CyclomaticComplexity + - Thanks to Mark Baker for the patch + +## [3.6.1] - 2021-10-11 +### Changed +- PHPCS annotations can now be specified using hash-style comments + - Previously, only slash-style and block-style comments could be used to do things like disable errors + - Thanks to Juliette Reinders Folmer for the patch +- The new PHP 8.1 tokenisation for ampersands has been reverted to use the existing PHP_CodeSniffer method + - The PHP 8.1 tokens T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG and T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG are unsued + - Ampersands continue to be tokenized as T_BITWISE_AND for all PHP versions + - Thanks to Juliette Reinders Folmer and Anna Filina for the patch +- File::getMethodParameters() no longer incorrectly returns argument attributes in the type hint array index + - A new has_attributes array index is available and set to TRUE if the argument has attributes defined + - Thanks to Juliette Reinders Folmer for the patch +- Fixed an issue where some sniffs would not run on PHP files that only used the short echo tag + - The following sniffs were affected: + - Generic.Files.ExecutableFile + - Generic.Files.LowercasedFilename + - Generic.Files.LineEndings + - Generic.Files.EndFileNewline + - Generic.Files.EndFileNoNewline + - Generic.PHP.ClosingPHPTag + - Generic.PHP.Syntax + - Generic.VersionControl.GitMergeConflict + - Generic.WhiteSpace.DisallowSpaceIndent + - Generic.WhiteSpace.DisallowTabIndent + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.BlockComment now correctly applies rules for block comments after a short echo tag + - Thanks to Juliette Reinders Folmer for the patch + +### Fixed +- Generic.NamingConventions.ConstructorName no longer throws deprecation notices on PHP 8.1 + - Thanks to Juliette Reinders Folmer for the patch +- Fixed false positives when using attributes in the following sniffs: + - PEAR.Commenting.FunctionComment + - Squiz.Commenting.InlineComment + - Squiz.Commenting.BlockComment + - Squiz.Commenting.VariableComment + - Squiz.WhiteSpace.MemberVarSpacing + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3294 : Bug in attribute tokenization when content contains PHP end token or attribute closer on new line + - Thanks to Alessandro Chitolina for the patch + - Thanks to Juliette Reinders Folmer for the tests +- Fixed bug #3296 : PSR2.ControlStructures.SwitchDeclaration takes phpcs:ignore as content of case body +- Fixed bug #3297 : PSR2.ControlStructures.SwitchDeclaration.TerminatingComment does not handle try/finally blocks + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3302 : PHP 8.0 | Tokenizer/PHP: bugfix for union types using namespace operator + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3303 : findStartOfStatement() doesn't work with T_OPEN_TAG_WITH_ECHO +- Fixed bug #3316 : Arrow function not tokenized correctly when using null in union type +- Fixed bug #3317 : Problem with how phpcs handles ignored files when running in parallel + - Thanks to Emil Andersson for the patch +- Fixed bug #3324 : PHPCS hangs processing some nested arrow functions inside a function call +- Fixed bug #3326 : Generic.Formatting.MultipleStatementAlignment error with const DEFAULT + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3333 : Squiz.Objects.ObjectInstantiation: null coalesce operators are not recognized as assignment + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3340 : Ensure interface and trait names are always tokenized as T_STRING + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3342 : PSR12/Squiz/PEAR standards all error on promoted properties with docblocks + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3345 : IF statement with no braces and double catch turned into syntax error by auto-fixer + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3352 : PSR2.ControlStructures.SwitchDeclaration can remove comments on the same line as the case statement while fixing + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3357 : Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3362 : Generic.WhiteSpace.ScopeIndent false positive for arrow functions inside arrays +- Fixed bug #3384 : Squiz.Commenting.FileComment.SpacingAfterComment false positive on empty file +- Fixed bug #3394 : Fix PHP 8.1 auto_detect_line_endings deprecation notice +- Fixed bug #3400 : PHP 8.1: prevent deprecation notices about missing return types + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3424 : PHPCS fails when using PHP 8 Constructor property promotion with attributes + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3425 : PHP 8.1 | Runner::processChildProcs(): fix passing null to non-nullable bug + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3445 : Nullable parameter after attribute incorrectly tokenized as ternary operator + - Thanks to Juliette Reinders Folmer for the patch + +## [3.6.0] - 2021-04-09 +### Added +- Added support for PHP 8.0 union types + - A new T_TYPE_UNION token is available to represent the pipe character + - File::getMethodParameters(), getMethodProperties(), and getMemberProperties() will now return union types + - Thanks to Juliette Reinders Folmer for the patch +- Added support for PHP 8.0 named function call arguments + - A new T_PARAM_NAME token is available to represent the label with the name of the function argument in it + - Thanks to Juliette Reinders Folmer for the patch +- Added support for PHP 8.0 attributes + - The PHP-supplied T_ATTRIBUTE token marks the start of an attribute + - A new T_ATTRIBUTE_END token is available to mark the end of an attribute + - New attribute_owner and attribute_closer indexes are available in the tokens array for all tokens inside an attribute + - Tokenizing of attributes has been backfilled for older PHP versions + - The following sniffs have been updated to support attributes: + - PEAR.Commenting.ClassComment + - PEAR.Commenting.FileComment + - PSR1.Files.SideEffects + - PSR12.Files.FileHeader + - Squiz.Commenting.ClassComment + - Squiz.Commenting.FileComment + - Squiz.WhiteSpace.FunctionSpacing + - Thanks to Vadim Borodavko for the patch + - Thanks to Alessandro Chitolina for the patch +- Added support for PHP 8.0 dereferencing of text strings with interpolated variables + - Thanks to Juliette Reinders Folmer for the patch +- Added support for PHP 8.0 match expressions + - Match expressions are now tokenised with parenthesis and scope openers and closers + - Sniffs can listen for the T_MATCH token to process match expressions + - Note that the case and default statements inside match expressions do not have scopes set + - A new T_MATCH_ARROW token is available to represent the arrows in match expressions + - A new T_MATCH_DEFAULT token is available to represent the default keyword in match expressions + - All tokenizing of match expressions has been backfilled for older PHP versions + - The following sniffs have been updated to support match expressions: + - Generic.CodeAnalysis.AssignmentInCondition + - Generic.CodeAnalysis.EmptyPHPStatement + - Thanks to Vadim Borodavko for the patch + - Generic.CodeAnalysis.EmptyStatement + - Generic.PHP.LowerCaseKeyword + - PEAR.ControlStructures.ControlSignature + - PSR12.ControlStructures.BooleanOperatorPlacement + - Squiz.Commenting.LongConditionClosingComment + - Squiz.Commenting.PostStatementComment + - Squiz.ControlStructures.LowercaseDeclaration + - Squiz.ControlStructures.ControlSignature + - Squiz.Formatting.OperatorBracket + - Squiz.PHP.DisallowMultipleAssignments + - Squiz.Objects.ObjectInstantiation + - Squiz.WhiteSpace.ControlStructureSpacing + - Thanks to Juliette Reinders Folmer for the patch +- Added Generic.NamingConventions.AbstractClassNamePrefix to enforce that class names are prefixed with "Abstract" + - Thanks to Anna Borzenko for the contribution +- Added Generic.NamingConventions.InterfaceNameSuffix to enforce that interface names are suffixed with "Interface" + - Thanks to Anna Borzenko for the contribution +- Added Generic.NamingConventions.TraitNameSuffix to enforce that trait names are suffixed with "Trait" + - Thanks to Anna Borzenko for the contribution + +### Changed +- The value of the T_FN_ARROW token has changed from "T_FN_ARROW" to "PHPCS_T_FN_ARROW" to avoid package conflicts + - This will have no impact on custom sniffs unless they are specifically looking at the value of the T_FN_ARROW constant + - If sniffs are just using constant to find arrow functions, they will continue to work without modification + - Thanks to Juliette Reinders Folmer for the patch +- File::findStartOfStatement() now works correctly when passed the last token in a statement +- File::getMethodParameters() now supports PHP 8.0 constructor property promotion + - Returned method params now include a "property_visibility" and "visibility_token" index if property promotion is detected + - Thanks to Juliette Reinders Folmer for the patch +- File::getMethodProperties() now includes a "return_type_end_token" index in the return value + - This indicates the last token in the return type, which is helpful when checking union types + - Thanks to Juliette Reinders Folmer for the patch +- Include patterns are now ignored when processing STDIN + - Previously, checks using include patterns were excluded when processing STDIN when no file path was provided via --stdin-path + - Now, all include and exclude rules are ignored when no file path is provided, allowing all checks to run + - If you want include and exclude rules enforced when checking STDIN, use --stdin-path to set the file path + - Thanks to Juliette Reinders Folmer for the patch +- Spaces are now correctly escaped in the paths to external on Windows + - Thanks to Juliette Reinders Folmer for the patch +- Generic.CodeAnalysis.UnusedFunctionParameter can now be configured to ignore variable usage for specific type hints + -- This allows you to suppress warnings for some variables that are not required, but leave warnings for others + -- Set the ignoreTypeHints array property to a list of type hints to ignore + -- Thanks to Petr Bugyík for the patch +- Generic.Formatting.MultipleStatementAlignment can now align statements at the start of the assignment token + - Previously, the sniff enforced that the values were aligned, even if this meant the assignment tokens were not + - Now, the sniff can enforce that the assignment tokens are aligned, even if this means the values are not + - Set the "alignAtEnd" sniff property to "false" to align the assignment tokens + - The default remains at "true", so the assigned values are aligned + - Thanks to John P. Bloch for the patch +- Generic.PHP.LowerCaseType now supports checking of typed properties + - Thanks to Juliette Reinders Folmer for the patch +- Generic.PHP.LowerCaseType now supports checking of union types + - Thanks to Juliette Reinders Folmer for the patch +- PEAR.Commenting.FunctionComment and Squiz.Commenting.FunctionComment sniffs can now ignore private and protected methods + - Set the "minimumVisibility" sniff property to "protected" to ignore private methods + - Set the "minimumVisibility" sniff property to "public" to ignore both private and protected methods + - The default remains at "private", so all methods are checked + - Thanks to Vincent Langlet for the patch +- PEAR.Commenting.FunctionComment and Squiz.Commenting.FunctionComment sniffs can now ignore return tags in any method + - Previously, only __construct and __destruct were ignored + - Set the list of method names to ignore in the "specialMethods" sniff property + - The default remains at "__construct" and "__destruct" only + - Thanks to Vincent Langlet for the patch +- PSR2.ControlStructures.SwitchDeclaration now supports nested switch statements where every branch terminates + - Previously, if a CASE only contained a SWITCH and no direct terminating statement, a fall-through error was displayed + - Now, the error is surpressed if every branch of the SWITCH has a terminating statement + - Thanks to Vincent Langlet for the patch +- The PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket error message is now reported on the closing parenthesis token + - Previously, the error was being reported on the function keyword, leading to confusing line numbers in the error report +- Squiz.Commenting.FunctionComment is now able to ignore function comments that are only inheritdoc statements + - Set the skipIfInheritdoc sniff property to "true" to skip checking function comments if the content is only {@inhertidoc} + - The default remains at "false", so these comments will continue to report errors + - Thanks to Jess Myrbo for the patch +- Squiz.Commenting.FunctionComment now supports the PHP 8 mixed type + - Thanks to Vadim Borodavko for the patch +- Squiz.PHP.NonExecutableCode now has improved handling of syntax errors + - Thanks to Thiemo Kreuz for the patch +- Squiz.WhiteSpace.ScopeKeywordSpacing now checks spacing when using PHP 8.0 constructor property promotion + - Thanks to Juliette Reinders Folmer for the patch + +### Fixed +- Fixed an issue that could occurr when checking files on network drives, such as with WSL2 on Windows 10 + - This works around a long-standing PHP bug with is_readable() + - Thanks to Michael S for the patch +- Fixed a number of false positives in the Squiz.PHP.DisallowMultipleAssignments sniff + - Sniff no longer errors for default value assignments in arrow functions + - Sniff no longer errors for assignments on first line of closure + - Sniff no longer errors for assignments after a goto label + - Thanks to Jaroslav Hanslík for the patch +- Fixed bug #2913 : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional +- Fixed bug #2992 : Enabling caching using a ruleset produces invalid cache files when using --sniffs and --exclude CLI args +- Fixed bug #3003 : Squiz.Formatting.OperatorBracket autofix incorrect when assignment used with null coalescing operator +- Fixed bug #3145 : Autoloading of sniff fails when multiple classes declared in same file +- Fixed bug #3157 : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented +- Fixed bug #3163 : Undefined index error with pre-commit hook using husky on PHP 7.4 + - Thanks to Ismo Vuorinen for the patch +- Fixed bug #3165 : Squiz.PHP.DisallowComparisonAssignment false positive when comparison inside closure +- Fixed bug #3167 : Generic.WhiteSpace.ScopeIndent false positive when using PHP 8.0 constructor property promotion +- Fixed bug #3170 : Squiz.WhiteSpace.OperatorSpacing false positive when using negation with string concat + - This also fixes the same issue in the PSR12.Operators.OperatorSpacing sniff +- Fixed bug #3177 : Incorrect tokenization of GOTO statements in mixed PHP/HTML files + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3184 : PSR2.Namespace.NamespaceDeclaration false positive on namespace operator + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3188 : Squiz.WhiteSpace.ScopeKeywordSpacing false positive for static return type + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3192 : findStartOfStatement doesn't work correctly inside switch + - Thanks to Vincent Langlet for the patch +- Fixed bug #3195 : Generic.WhiteSpace.ScopeIndent confusing message when combination of tabs and spaces found +- Fixed bug #3197 : Squiz.NamingConventions.ValidVariableName does not use correct error code for all member vars +- Fixed bug #3219 : Generic.Formatting.MultipleStatementAlignment false positive for empty anonymous classes and closures +- Fixed bug #3258 : Squiz.Formatting.OperatorBracket duplicate error messages for unary minus + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3273 : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis +- Fixed bug #3277 : Nullable static return typehint causes whitespace error +- Fixed bug #3284 : Unused parameter false positive when using array index in arrow function + +## [3.5.8] - 2020-10-23 +### Removed +- Reverted a change to the way include/exclude patterns are processed for STDIN content + - This change is not backwards compatible and will be re-introduced in version 3.6.0 + +## [3.5.7] - 2020-10-23 +### Added +- The PHP 8.0 T_NULLSAFE_OBJECT_OPERATOR token has been made available for older versions + - Existing sniffs that check for T_OBJECT_OPERATOR have been modified to apply the same rules for the nullsafe object operator + - Thanks to Juliette Reinders Folmer for the patch +- The new method of PHP 8.0 tokenizing for namespaced names has been revert to thr pre 8.0 method + - This maintains backwards compatible for existing sniffs on PHP 8.0 + - This change will be removed in PHPCS 4.0 as the PHP 8.0 tokenizing method will be backported for pre 8.0 versions + - Thanks to Juliette Reinders Folmer for the patch +- Added support for changes to the way PHP 8.0 tokenizes hash comments + - The existing PHP 5-7 behaviour has been replicated for version 8, so no sniff changes are required + - Thanks to Juliette Reinders Folmer for the patch +- Running the unit tests now includes warnings in the found and fixable error code counts + - Thanks to Juliette Reinders Folmer for the patch +- PSR12.Functions.NullableTypeDeclaration now supports the PHP8 static return type + - Thanks to Juliette Reinders Folmer for the patch + +### Changed +- The autoloader has been changed to fix sniff class name detection issues that may occur when running on PHP 7.4+ + - Thanks to Eloy Lafuente for the patch +- PSR12.ControlStructures.BooleanOperatorPlacement.FoundMixed error message is now more accurate when using the allowOnly setting + - Thanks to Vincent Langlet for the patch + +### Fixed +- Fixed Squiz.Formatting.OperatorBracket false positive when exiting with a negative number +- Fixed Squiz.PHP.DisallowComparisonAssignment false positive for methods called on an object +- Fixed bug #2882 : Generic.Arrays.ArrayIndent can request close brace indent to be less than the statement indent level +- Fixed bug #2883 : Generic.WhiteSpace.ScopeIndent.Incorrect issue after NOWDOC +- Fixed bug #2975 : Undefined offset in PSR12.Functions.ReturnTypeDeclaration when checking function return type inside ternary +- Fixed bug #2988 : Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding + - Thanks to Thiemo Kreuz for the patch +- Fixed bug #2989 : Incorrect auto-fixing in Generic.ControlStructures.InlineControlStructure during live coding + - Thanks to Thiemo Kreuz for the patch +- Fixed bug #3007 : Directory exclude pattern improperly excludes directories with names that start the same + - Thanks to Steve Talbot for the patch +- Fixed bug #3043 : Squiz.WhiteSpace.OperatorSpacing false positive for negation in arrow function + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3049 : Incorrect error with arrow function and parameter passed as reference + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3053 : PSR2 incorrect fix when multiple use statements on same line do not have whitespace between them +- Fixed bug #3058 : Progress gets unaligned when 100% happens at the end of the available dots +- Fixed bug #3059 : Squiz.Arrays.ArrayDeclaration false positive when using type casting + - Thanks to Sergei Morozov for the patch +- Fixed bug #3060 : Squiz.Arrays.ArrayDeclaration false positive for static functions + - Thanks to Sergei Morozov for the patch +- Fixed bug #3065 : Should not fix Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma if comment between element and comma + - Thanks to Sergei Morozov for the patch +- Fixed bug #3066 : No support for namespace operator used in type declarations + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3075 : PSR12.ControlStructures.BooleanOperatorPlacement false positive when operator is the only content on line +- Fixed bug #3099 : Squiz.WhiteSpace.OperatorSpacing false positive when exiting with negative number + - Thanks to Sergei Morozov for the patch +- Fixed bug #3102 : PSR12.Squiz.OperatorSpacing false positive for default values of arrow functions + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #3124 : PSR-12 not reporting error for empty lines with only whitespace +- Fixed bug #3135 : Ignore annotations are broken on PHP 8.0 + - Thanks to Juliette Reinders Folmer for the patch + +## [3.5.6] - 2020-08-10 +### Added +- Added support for PHP 8.0 magic constant dereferencing + - Thanks to Juliette Reinders Folmer for the patch +- Added support for changes to the way PHP 8.0 tokenizes comments + - The existing PHP 5-7 behaviour has been replicated for version 8, so no sniff changes are required + - Thanks to Juliette Reinders Folmer for the patch +- `File::getMethodProperties()` now detects the PHP 8.0 static return type + - Thanks to Juliette Reinders Folmer for the patch +- The PHP 8.0 static return type is now supported for arrow functions + - Thanks to Juliette Reinders Folmer for the patch + +### Changed +- The cache is no longer used if the list of loaded PHP extensions changes + - Thanks to Juliette Reinders Folmer for the patch +- `Generic.NamingConventions.CamelCapsFunctionName` no longer reports `__serialize` and `__unserialize` as invalid names + - Thanks to Filip Å  for the patch +- `PEAR.NamingConventions.ValidFunctionName` no longer reports `__serialize` and `__unserialize` as invalid names + - Thanks to Filip Å  for the patch +- `Squiz.Scope.StaticThisUsage` now detects usage of `$this` inside closures and arrow functions + - Thanks to MichaÅ‚ Bundyra for the patch + +### Fixed +- Fixed bug #2877 : PEAR.Functions.FunctionCallSignature false positive for array of functions + - Thanks to Vincent Langlet for the patch +- Fixed bug #2888 : PSR12.Files.FileHeader blank line error with multiple namespaces in one file +- Fixed bug #2926 : phpcs hangs when using arrow functions that return heredoc +- Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed +- Fixed bug #2967 : Markdown generator does not output headings correctly + - Thanks to Petr Bugyík for the patch +- Fixed bug #2977 : File::isReference() does not detect return by reference for closures + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2994 : Generic.Formatting.DisallowMultipleStatements false positive for FOR loop with no body +- Fixed bug #3033 : Error generated during tokenizing of goto statements on PHP 8 + - Thanks to Juliette Reinders Folmer for the patch + +## [3.5.5] - 2020-04-17 +### Changed +- The T_FN backfill now works more reliably so T_FN tokens only ever represent real arrow functions + - Thanks to Juliette Reinders Folmer for the patch +- Fixed an issue where including sniffs using paths containing multiple dots would silently fail +- Generic.CodeAnalysis.EmptyPHPStatement now detects empty statements at the start of control structures + +### Fixed +- Error wording in PEAR.Functions.FunctionCallSignature now always uses "parenthesis" instead of sometimes using "bracket" + - Thanks to Vincent Langlet for the patch +- Fixed bug #2787 : Squiz.PHP.DisallowMultipleAssignments not ignoring typed property declarations + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2810 : PHPCBF fails to fix file with empty statement at start on control structure +- Fixed bug #2812 : Squiz.Arrays.ArrayDeclaration not detecting some arrays with multiple arguments on the same line + - Thanks to Jakub Chábek for the patch +- Fixed bug #2826 : Generic.WhiteSpace.ArbitraryParenthesesSpacing doesn't detect issues for statements directly after a control structure + - Thanks to Vincent Langlet for the patch +- Fixed bug #2848 : PSR12.Files.FileHeader false positive for file with mixed PHP and HTML and no file header +- Fixed bug #2849 : Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array +- Fixed bug #2850 : Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase +- Fixed bug #2853 : Undefined variable error when using Info report + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2865 : Double arrow tokenized as T_STRING when placed after function named "fn" +- Fixed bug #2867 : Incorrect scope matching when arrow function used inside IF condition +- Fixed bug #2868 : phpcs:ignore annotation doesnt work inside a docblock +- Fixed bug #2878 : PSR12.Files.FileHeader conflicts with Generic.Files.LineEndings +- Fixed bug #2895 : PSR2.Methods.FunctionCallSignature.MultipleArguments false positive with arrow function argument + +## [3.5.4] - 2020-01-31 +### Changed +- The PHP 7.4 numeric separator backfill now works correctly for more float formats + - Thanks to Juliette Reinders Folmer for the patch +- The PHP 7.4 numeric separator backfill is no longer run on PHP version 7.4.0 or greater +- File::getCondition() now accepts a 3rd argument that allows for the closest matching token to be returned + - By default, it continues to return the first matched token found from the top of the file +- Fixed detection of array return types for arrow functions +- Added Generic.PHP.DisallowRequestSuperglobal to ban the use of the $_REQUEST superglobal + - Thanks to Morerice for the contribution +- Generic.ControlStructures.InlineControlStructure no longer shows errors for WHILE and FOR statements without a body + - Previously it required these to have curly braces, but there were no statements to enclose in them + - Thanks to Juliette Reinders Folmer for the patch +- PSR12.ControlStructures.BooleanOperatorPlacement can now be configured to enforce a specific operator position + - By default, the sniff ensures that operators are all at the begining or end of lines, but not a mix of both + - Set the allowOnly property to "first" to enforce all boolean operators to be at the start of a line + - Set the allowOnly property to "last" to enforce all boolean operators to be at the end of a line + - Thanks to Vincent Langlet for the patch +- PSR12.Files.ImportStatement now auto-fixes import statements by removing the leading slash + - Thanks to MichaÅ‚ Bundyra for the patch +- Squiz.ControlStructures.ForLoopDeclaration now has a setting to ignore newline characters + - Default remains FALSE, so newlines are not allowed within FOR definitions + - Override the "ignoreNewlines" setting in a ruleset.xml file to change +- Squiz.PHP.InnerFunctions now handles multiple nested anon classes correctly + +### Fixed +- Fixed bug #2497 : Sniff properties not set when referencing a sniff using relative paths or non-native slashes + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2657 : Squiz.WhiteSpace.FunctionSpacing can remove spaces between comment and first/last method during auto-fixing + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2688 : Case statements not tokenized correctly when switch is contained within ternary +- Fixed bug #2698 : PHPCS throws errors determining auto report width when shell_exec is disabled + - Thanks to Matthew Peveler for the patch +- Fixed bug #2730 : PSR12.ControlStructures.ControlStructureSpacing does not ignore comments between conditions + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2732 : PSR12.Files.FileHeader misidentifies file header in mixed content file +- Fixed bug #2745 : AbstractArraySniff wrong indices when mixed coalesce and ternary values + - Thanks to MichaÅ‚ Bundyra for the patch +- Fixed bug #2748 : Wrong end of statement for fn closures + - Thanks to MichaÅ‚ Bundyra for the patch +- Fixed bug #2751 : Autoload relative paths first to avoid confusion with files from the global include path + - Thanks to Klaus Purer for the patch +- Fixed bug #2763 : PSR12 standard reports errors for multi-line FOR definitions +- Fixed bug #2768 : Generic.Files.LineLength false positive for non-breakable strings at exactly the soft limit + - Thanks to Alex Miles for the patch +- Fixed bug #2773 : PSR2.Methods.FunctionCallSignature false positive when arrow function has array return type +- Fixed bug #2790 : PSR12.Traits.UseDeclaration ignores block comments + - Thanks to Vincent Langlet for the patch +- Fixed bug #2791 : PSR12.Functions.NullableTypeDeclaration false positive when ternary operator used with instanceof + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2802 : Can't specify a report file path using the tilde shortcut +- Fixed bug #2804 : PHP4-style typed properties not tokenized correctly + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2805 : Undefined Offset notice during live coding of arrow functions + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2843 : Tokenizer does not support alternative syntax for declare statements + - Thanks to Juliette Reinders Folmer for the patch + +## [3.5.3] - 2019-12-04 +### Changed +- The PHP 7.4 T_FN token has been made available for older versions + - T_FN represents the fn string used for arrow functions + - The double arrow becomes the scope opener, and uses a new T_FN_ARROW token type + - The token after the statement (normally a semicolon) becomes the scope closer + - The token is also associated with the opening and closing parenthesis of the statement + - Any functions named "fn" will cause have a T_FN token for the function name, but have no scope information + - Thanks to MichaÅ‚ Bundyra for the help with this change +- PHP 7.4 numeric separators are now tokenized in the same way when using older PHP versions + - Previously, a number like 1_000 would tokenize as T_LNUMBER (1), T_STRING (_000) + - Now, the number tokenizes as T_LNUMBER (1_000) + - Sniff developers should consider how numbers with underscores impact their custom sniffs +- The PHPCS file cache now takes file permissions into account + - The cache is now invalidated for a file when its permissions are changed +- File::getMethodParameters() now supports arrow functions +- File::getMethodProperties() now supports arrow functions +- Added Fixer::changeCodeBlockIndent() to change the indent of a code block while auto-fixing + - Can be used to either increase or decrease the indent + - Useful when moving the start position of something like a closure, where you want the content to also move +- Added Generic.Files.ExecutableFile sniff + - Ensures that files are not executable + - Thanks to Matthew Peveler for the contribution +- Generic.CodeAnalysis.EmptyPhpStatement now reports unnecessary semicolons after control structure closing braces + - Thanks to Vincent Langlet for the patch +- Generic.PHP.LowerCaseKeyword now enforces that the "fn" keyword is lowercase + - Thanks to MichaÅ‚ Bundyra for the patch +- Generic.WhiteSpace.ScopeIndent now supports static arrow functions +- PEAR.Functions.FunctionCallSignature now adjusts the indent of function argument contents during auto-fixing + - Previously, only the first line of an argument was changed, leading to inconsistent indents + - This change also applies to PSR2.Methods.FunctionCallSignature +- PSR2.ControlStructures.ControlStructureSpacing now checks whitespace before the closing parenthesis of multi-line control structures + - Previously, it incorrectly applied the whitespace check for single-line definitions only +- PSR12.Functions.ReturnTypeDeclaration now checks the return type of arrow functions + - Thanks to MichaÅ‚ Bundyra for the patch +- PSR12.Traits.UseDeclaration now ensures all trait import statements are grouped together + - Previously, the trait import section of the class ended when the first non-import statement was found + - Checking now continues throughout the class to ensure all statements are grouped together + - This also ensures that empty lines are not requested after an import statement that isn't the last one +- Squiz.Functions.LowercaseFunctionKeywords now enforces that the "fn" keyword is lowercase + - Thanks to MichaÅ‚ Bundyra for the patch + +### Fixed +- Fixed bug #2586 : Generic.WhiteSpace.ScopeIndent false positives when indenting open tags at a non tab-stop +- Fixed bug #2638 : Squiz.CSS.DuplicateClassDefinitionSniff sees comments as part of the class name + - Thanks to Raphael Horber for the patch +- Fixed bug #2640 : Squiz.WhiteSpace.OperatorSpacing false positives for some negation operators + - Thanks to Jakub Chábek and Juliette Reinders Folmer for the patch +- Fixed bug #2674 : Squiz.Functions.FunctionDeclarationArgumentSpacing prints wrong argument name in error message +- Fixed bug #2676 : PSR12.Files.FileHeader locks up when file ends with multiple inline comments +- Fixed bug #2678 : PSR12.Classes.AnonClassDeclaration incorrectly enforcing that closing brace be on a line by itself +- Fixed bug #2685 : File::getMethodParameters() setting typeHintEndToken for vars with no type hint + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2694 : AbstractArraySniff produces invalid indices when using ternary operator + - Thanks to MichaÅ‚ Bundyra for the patch +- Fixed bug #2702 : Generic.WhiteSpace.ScopeIndent false positive when using ternary operator with short arrays + +## [3.5.2] - 2019-10-28 +### Changed +- Generic.ControlStructures.DisallowYodaConditions now returns less false positives + - False positives were being returned for array comparisions, or when performing some function calls +- Squiz.WhiteSpace.SemicolonSpacing.Incorrect error message now escapes newlines and tabs + - Provides a clearer error message as whitespace is now visible + - Also allows for better output for report types such as CSV and XML +- The error message for PSR12.Files.FileHeader.SpacingAfterBlock has been made clearer + - It now uses the wording from the published PSR-12 standard to indicate that blocks must be separated by a blank line + - Thanks to Craig Duncan for the patch + +### Fixed +- Fixed bug #2654 : Incorrect indentation for arguments of multiline function calls +- Fixed bug #2656 : Squiz.WhiteSpace.MemberVarSpacing removes comments before first member var during auto fixing + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2663 : Generic.NamingConventions.ConstructorName complains about old constructor in interfaces +- Fixed bug #2664 : PSR12.Files.OpenTag incorrectly identifies PHP file with only an opening tag +- Fixed bug #2665 : PSR12.Files.ImportStatement should not apply to traits +- Fixed bug #2673 : PSR12.Traits.UseDeclaration does not allow comments or blank lines between use statements + +## [3.5.1] - 2019-10-17 +### Changed +- Very very verbose diff report output has slightly changed to improve readability + - Output is printed when running PHPCS with the --report=diff and -vvv command line arguments + - Fully qualified class names have been replaced with sniff codes + - Tokens being changed now display the line number they are on +- PSR2, PSR12, and PEAR standards now correctly check for blank lines at the start of function calls + - This check has been missing from these standards, but has now been implemented + - When using the PEAR standard, the error code is PEAR.Functions.FunctionCallSignature.FirstArgumentPosition + - When using PSR2 or PSR12, the error code is PSR2.Methods.FunctionCallSignature.FirstArgumentPosition +- PSR12.ControlStructures.BooleanOperatorPlacement no longer complains when multiple expression appears on the same line + - Previously, boolean operators were enforce to appear at the start or end of lines only + - Boolean operators can now appear in the middle of the line +- PSR12.Files.FileHeader no longer ignores comments preceding a use, namespace, or declare statement +- PSR12.Files.FileHeader now allows a hashbang line at the top of the file + +### Fixed +- Fixed bug #2506 : PSR2 standard can't auto fix multi-line function call inside a string concat statement +- Fixed bug #2530 : PEAR.Commenting.FunctionComment does not support intersection types in comments +- Fixed bug #2615 : Constant visibility false positive on non-class constants +- Fixed bug #2616 : PSR12.Files.FileHeader false positive when file only contains docblock +- Fixed bug #2619 : PSR12.Files.FileHeader locks up when inline comment is the last content in a file +- Fixed bug #2621 : PSR12.Classes.AnonClassDeclaration.CloseBraceSameLine false positive for anon class passed as function argument + - Thanks to Martins Sipenko for the patch +- Fixed bug #2623 : PSR12.ControlStructures.ControlStructureSpacing not ignoring indentation inside multi-line string arguments +- Fixed bug #2624 : PSR12.Traits.UseDeclaration doesnt apply the correct indent during auto fixing +- Fixed bug #2626 : PSR12.Files.FileHeader detects @var annotations as file docblocks +- Fixed bug #2628 : PSR12.Traits.UseDeclaration does not allow comments above a USE declaration +- Fixed bug #2632 : Incorrect indentation of lines starting with "static" inside closures +- Fixed bug #2641 : PSR12.Functions.NullableTypeDeclaration false positive when using new static() + +## [3.5.0] - 2019-09-27 +### Changed +- The included PSR12 standard is now complete and ready to use + - Check your code using PSR-12 by running PHPCS with --standard=PSR12 +- Added support for PHP 7.4 typed properties + - The nullable operator is now tokenized as T_NULLABLE inside property types, as it is elsewhere + - To get the type of a member var, use the File::getMemberProperties() method, which now contains a "type" array index + - This contains the type of the member var, or a blank string if not specified + - If the type is nullable, the return type will contain the leading ? + - If a type is specified, the position of the first token in the type will be set in a "type_token" array index + - If a type is specified, the position of the last token in the type will be set in a "type_end_token" array index + - If the type is nullable, a "nullable_type" array index will also be set to TRUE + - If the type contains namespace information, it will be cleaned of whitespace and comments in the return value +- The PSR1 standard now correctly bans alternate PHP tags + - Previously, it only banned short open tags and not the pre-7.0 alternate tags +- Added support for only checking files that have been locally staged in a git repo + - Use --filter=gitstaged to check these files + - You still need to give PHPCS a list of files or directories in which to apply the filter + - Thanks to Juliette Reinders Folmer for the contribution +- JSON reports now end with a newline character +- The phpcs.xsd schema now validates phpcs-only and phpcbf-only attributes correctly + - Thanks to Juliette Reinders Folmer for the patch +- The tokenizer now correctly identifies inline control structures in more cases +- All helper methods inside the File class now throw RuntimeException instead of TokenizerException + - Some tokenizer methods were also throwing RuntimeExpection but now correctly throw TokenizerException + - Thanks to Juliette Reinders Folmer for the patch +- The File::getMethodParameters() method now returns more information, and supports closure USE groups + - If a type hint is specified, the position of the last token in the hint will be set in a "type_hint_end_token" array index + - If a default is specified, the position of the first token in the default value will be set in a "default_token" array index + - If a default is specified, the position of the equals sign will be set in a "default_equal_token" array index + - If the param is not the last, the position of the comma will be set in a "comma_token" array index + - If the param is passed by reference, the position of the reference operator will be set in a "reference_token" array index + - If the param is variable length, the position of the variadic operator will be set in a "variadic_token" array index +- The T_LIST token and it's opening and closing parentheses now contain references to each other in the tokens array + - Uses the same parenthesis_opener/closer/owner indexes as other tokens + - Thanks to Juliette Reinders Folmer for the patch +- The T_ANON_CLASS token and it's opening and closing parentheses now contain references to each other in the tokens array + - Uses the same parenthesis_opener/closer/owner indexes as other tokens + - Only applicable if the anon class is passing arguments to the constructor + - Thanks to Juliette Reinders Folmer for the patch +- The PHP 7.4 T_BAD_CHARACTER token has been made available for older versions + - Allows you to safely look for this token, but it will not appear unless checking with PHP 7.4+ +- Metrics are now available for Squiz.WhiteSpace.FunctionSpacing + - Use the "info" report to see blank lines before/after functions + - Thanks to Juliette Reinders Folmer for the patch +- Metrics are now available for Squiz.WhiteSpace.MemberVarSpacing + - Use the "info" report to see blank lines before member vars + - Thanks to Juliette Reinders Folmer for the patch +- Added Generic.ControlStructures.DisallowYodaConditions sniff + - Ban the use of Yoda conditions + - Thanks to Mponos George for the contribution +- Added Generic.PHP.RequireStrictTypes sniff + - Enforce the use of a strict types declaration in PHP files +- Added Generic.WhiteSpace.SpreadOperatorSpacingAfter sniff + - Checks whitespace between the spread operator and the variable/function call it applies to + - Thanks to Juliette Reinders Folmer for the contribution +- Added PSR12.Classes.AnonClassDeclaration sniff + - Enforces the formatting of anonymous classes +- Added PSR12.Classes.ClosingBrace sniff + - Enforces that closing braces of classes/interfaces/traits/functions are not followed by a comment or statement +- Added PSR12.ControlStructures.BooleanOperatorPlacement sniff + - Enforces that boolean operators between conditions are consistently at the start or end of the line +- Added PSR12.ControlStructures.ControlStructureSpacing sniff + - Enforces that spacing and indents are correct inside control structure parenthesis +- Added PSR12.Files.DeclareStatement sniff + - Enforces the formatting of declare statements within a file +- Added PSR12.Files.FileHeader sniff + - Enforces the order and formatting of file header blocks +- Added PSR12.Files.ImportStatement sniff + - Enforces the formatting of import statements within a file +- Added PSR12.Files.OpenTag sniff + - Enforces that the open tag is on a line by itself when used at the start of a php-only file +- Added PSR12.Functions.ReturnTypeDeclaration sniff + - Enforces the formatting of return type declarations in functions and closures +- Added PSR12.Properties.ConstantVisibility sniff + - Enforces that constants must have their visibility defined + - Uses a warning instead of an error due to this conditionally requiring the project to support PHP 7.1+ +- Added PSR12.Traits.UseDeclaration sniff + - Enforces the formatting of trait import statements within a class +- Generic.Files.LineLength ignoreComments property now ignores comments at the end of a line + - Previously, this property was incorrectly causing the sniff to ignore any line that ended with a comment + - Now, the trailing comment is not included in the line length, but the rest of the line is still checked +- Generic.Files.LineLength now only ignores unwrappable comments when the comment is on a line by itself + - Previously, a short unwrappable comment at the end of the line would have the sniff ignore the entire line +- Generic.Functions.FunctionCallArgumentSpacing no longer checks spacing around assignment operators inside function calls + - Use the Squiz.WhiteSpace.OperatorSpacing sniff to enforce spacing around assignment operators + - Note that this sniff checks spacing around all assignment operators, not just inside function calls + - The Generic.Functions.FunctionCallArgumentSpacing.NoSpaceBeforeEquals error has been removed + - use Squiz.WhiteSpace.OperatorSpacing.NoSpaceBefore instead + - The Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterEquals error has been removed + - use Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter instead + - This also changes the PEAR/PSR2/PSR12 standards so they no longer check assignment operators inside function calls + - They were previously checking these operators when they should not have + - Thanks to Juliette Reinders Folmer for the patch +- Generic.WhiteSpace.ScopeIndent no longer performs exact indents checking for chained method calls + - Other sniffs can be used to enforce chained method call indent rules + - Thanks to Pieter Frenssen for the patch +- PEAR.WhiteSpace.ObjectOperatorIndent now supports multi-level chained statements + - When enabled, chained calls must be indented 1 level more or less than the previous line + - Set the new "multilevel" setting to TRUE in a ruleset.xml file to enable this behaviour + - Thanks to Marcos Passos for the patch +- PSR2.ControlStructures.ControlStructureSpacing now allows whitespace after the opening parenthesis if followed by a comment + - Thanks to MichaÅ‚ Bundyra for the patch +- PSR2.Classes.PropertyDeclaration now enforces a single space after a property type keyword + - The PSR2 standard itself excludes this new check as it is not defined in the written standard + - Using the PSR12 standard will enforce this check +- Squiz.Commenting.BlockComment no longer requires blank line before comment if it's the first content after the PHP open tag + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Functions.FunctionDeclarationArgumentSpacing now has more accurate error messages + - This includes renaming the SpaceAfterDefault error code to SpaceAfterEquals, which reflects the real error +- Squiz.Functions.FunctionDeclarationArgumentSpacing now checks for no space after a reference operator + - If you don't want this new behaviour, exclude the SpacingAfterReference error message in a ruleset.xml file +- Squiz.Functions.FunctionDeclarationArgumentSpacing now checks for no space after a variadic operator + - If you don't want this new behaviour, exclude the SpacingAfterVariadic error message in a ruleset.xml file +- Squiz.Functions.MultiLineFunctionDeclaration now has improved fixing for the FirstParamSpacing and UseFirstParamSpacing errors +- Squiz.Operators.IncrementDecrementUsage now suggests pre-increment of variables instead of post-increment + - This change does not enforce pre-increment over post-increment; only the suggestion has changed + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.PHP.DisallowMultipleAssignments now has a second error code for when assignments are found inside control structure conditions + - The new error code is Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure + - All other multiple assignment cases use the existing error code Squiz.PHP.DisallowMultipleAssignments.Found + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.FunctionSpacing now applies beforeFirst and afterLast spacing rules to nested functions + - Previously, these rules only applied to the first and last function in a class, interface, or trait + - These rules now apply to functions nested in any statement block, including other functions and conditions +- Squiz.WhiteSpace.OperatorSpacing now has improved handling of parse errors + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.OperatorSpacing now checks spacing around the instanceof operator + - Thanks to Jakub Chábek for the patch +- Squiz.WhiteSpace.OperatorSpacing can now enforce a single space before assignment operators + - Previously, the sniff this spacing as multiple assignment operators are sometimes aligned + - Now, you can set the ignoreSpacingBeforeAssignments sniff property to FALSE to enable checking + - Default remains TRUE, so spacing before assignments is not checked by default + - Thanks to Jakub Chábek for the patch + +### Fixed +- Fixed bug #2391 : Sniff-specific ignore rules inside rulesets are filtering out too many files + - Thanks to Juliette Reinders Folmer and Willington Vega for the patch +- Fixed bug #2478 : FunctionCommentThrowTag.WrongNumber when exception is thrown once but built conditionally +- Fixed bug #2479 : Generic.WhiteSpace.ScopeIndent error when using array destructing with exact indent checking +- Fixed bug #2498 : Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed autofix breaks heredoc +- Fixed bug #2502 : Generic.WhiteSpace.ScopeIndent false positives with nested switch indentation and case fall-through +- Fixed bug #2504 : Generic.WhiteSpace.ScopeIndent false positives with nested arrays and nowdoc string +- Fixed bug #2511 : PSR2 standard not checking if closing paren of single-line function declaration is on new line +- Fixed bug #2512 : Squiz.PHP.NonExecutableCode does not support alternate SWITCH control structure + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2522 : Text generator throws error when code sample line is too long + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2526 : XML report format has bad syntax on Windows + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2529 : Generic.Formatting.MultipleStatementAlignment wrong error for assign in string concat +- Fixed bug #2534 : Unresolvable installed_paths can lead to open_basedir errors + - Thanks to Oliver Nowak for the patch +- Fixed bug #2541 : Text doc generator does not allow for multi-line rule explanations + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2549 : Searching for a phpcs.xml file can throw warnings due to open_basedir restrictions + - Thanks to Matthew Peveler for the patch +- Fixed bug #2558 : PHP 7.4 throwing offset syntax with curly braces is deprecated message + - Thanks to Matthew Peveler for the patch +- Fixed bug #2561 : PHP 7.4 compatibility fix / implode argument order + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2562 : Inline WHILE triggers SpaceBeforeSemicolon incorrectly + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2565 : Generic.ControlStructures.InlineControlStructure confused by mixed short/long tags + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2566 : Author tag email validation doesn't support all TLDs + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2575 : Custom error messages don't have data replaced when cache is enabled +- Fixed bug #2601 : Squiz.WhiteSpace.FunctionSpacing incorrect fix when spacing is 0 +- Fixed bug #2608 : PSR2 throws errors for use statements when multiple namespaces are defined in a file + +## [3.4.2] - 2019-04-11 +### Changed +- Squiz.Arrays.ArrayDeclaration now has improved handling of syntax errors + +### Fixed +- Fixed an issue where the PCRE JIT on PHP 7.3 caused PHPCS to die when using the parallel option + - PHPCS now disables the PCRE JIT before running +- Fixed bug #2368 : MySource.PHP.AjaxNullComparison throws error when first function has no doc comment +- Fixed bug #2414 : Indention false positive in switch/case/if combination +- Fixed bug #2423 : Squiz.Formatting.OperatorBracket.MissingBrackets error with static +- Fixed bug #2450 : Indentation false positive when closure containing nested IF conditions used as function argument +- Fixed bug #2452 : LowercasePHPFunctions sniff failing on "new \File()" +- Fixed bug #2453 : Squiz.CSS.SemicolonSpacingSniff false positive when style name proceeded by an asterisk + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2464 : Fixer conflict between Generic.WhiteSpace.ScopeIndent and Squiz.WhiteSpace.ScopeClosingBrace when class indented 1 space +- Fixed bug #2465 : Excluding a sniff by path is not working +- Fixed bug #2467 : PHP open/close tags inside CSS files are replaced with internal PHPCS token strings when auto fixing + +## [3.4.1] - 2019-03-19 +### Changed +- The PEAR installable version of PHPCS was missing some files, which have been re-included in this release + - The code report was not previously available for PEAR installs + - The Generic.Formatting.SpaceBeforeCast sniff was not previously available for PEAR installs + - The Generic.WhiteSpace.LanguageConstructSpacing sniff was not previously available for PEAR installs + - Thanks to Juliette Reinders Folmer for the patch +- PHPCS will now refuse to run if any of the required PHP extensions are not loaded + - Previously, PHPCS only relied on requirements being checked by PEAR and Composer + - Thanks to Juliette Reinders Folmer for the patch +- Ruleset XML parsing errors are now displayed in a readable format so they are easier to correct + - Thanks to Juliette Reinders Folmer for the patch +- The PSR2 standard no longer throws duplicate errors for spacing around FOR loop parentheses + - Thanks to Juliette Reinders Folmer for the patch +- T_PHPCS_SET tokens now contain sniffCode, sniffProperty, and sniffPropertyValue indexes + - Sniffs can use this information instead of having to parse the token content manually +- Added more guard code for syntax errors to various CSS sniffs + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Commenting.DocComment error messages now contain the name of the comment tag that caused the error + - Thanks to Juliette Reinders Folmer for the patch +- Generic.ControlStructures.InlineControlStructure now handles syntax errors correctly + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Debug.JSHint now longer requires rhino and can be run directly from the npm install + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Files.LineEndings no longer adds superfluous new line at the end of JS and CSS files + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Formatting.DisallowMultipleStatements no longer tries fix lines containing phpcs:ignore statements + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Functions.FunctionCallArgumentSpacing now has improved performance and anonymous class support + - Thanks to Juliette Reinders Folmer for the patch +- Generic.WhiteSpace.ScopeIndent now respects changes to the "exact" property using phpcs:set mid-way through a file + - This allows you change the "exact" rule for only some parts of a file +- Generic.WhiteSpace.ScopeIndent now disables exact indent checking inside all arrays + - Previously, this was only done when using long array syntax, but it now works for short array syntax as well +- PEAR.Classes.ClassDeclaration now has improved handling of PHPCS annotations and tab indents +- PSR12.Classes.ClassInstantiation has changed it's error code from MissingParenthesis to MissingParentheses +- PSR12.Keywords.ShortFormTypeKeywords now ignores all spacing inside type casts during both checking and fixing + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Classes.LowercaseClassKeywords now examines the class keyword for anonymous classes + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.ControlStructures.ControlSignature now has improved handling of parse errors + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.PostStatementComment fixer no longer adds a blank line at the start of a JS file that begins with a comment + - Fixes a conflict between this sniff and the Squiz.WhiteSpace.SuperfluousWhitespace sniff + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.PostStatementComment now ignores comments inside control structure conditions, such as FOR loops + - Fixes a conflict between this sniff and the Squiz.ControlStructures.ForLoopDeclaration sniff + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.FunctionCommentThrowTag now has improved support for unknown exception types and namespaces + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.ControlStructures.ForLoopDeclaration has improved whitespace, closure, and empty expression support + - The SpacingAfterSecondNoThird error code has been removed as part of these fixes + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.CSS.ClassDefinitionOpeningBraceSpace now handles comments and indentation correctly + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.CSS.ClassDefinitionClosingBrace now handles comments, indentation, and multiple statements on the same line correctly + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.CSS.Opacity now handles comments correctly + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.CSS.SemicolonSpacing now handles comments and syntax errors correctly + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.NamingConventions.ValidVariableName now supports variables inside anonymous classes correctly + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.PHP.LowercasePHPFunctions now handles use statements, namespaces, and comments correctly + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.FunctionSpacing now fixes function spacing correctly when a function is the first content in a file + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.SuperfluousWhitespace no longer throws errors for spacing between functions and properties in anon classes + - Thanks to Juliette Reinders Folmer for the patch +- Zend.Files.ClosingTag no longer adds a semi-colon during fixing of a file that only contains a comment + - Thanks to Juliette Reinders Folmer for the patch +- Zend.NamingConventions.ValidVariableName now supports variables inside anonymous classes correctly + - Thanks to Juliette Reinders Folmer for the patch + +### Fixed +- Fixed bug #2298 : PSR2.Classes.ClassDeclaration allows extended class on new line + - Thanks to MichaÅ‚ Bundyra for the patch +- Fixed bug #2337 : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line function call starts on same line as open tag +- Fixed bug #2348 : Cache not invalidated when changing a ruleset included by another +- Fixed bug #2376 : Using __halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it's last in the function list + - Thanks to Sijun Zhu for the patch +- Fixed bug #2393 : The gitmodified filter will infinitely loop when encountering deleted file paths + - Thanks to Lucas Manzke for the patch +- Fixed bug #2396 : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line IF condition mixed with HTML +- Fixed bug #2431 : Use function/const not tokenized as T_STRING when preceded by comment + +## [3.4.0] - 2018-12-20 +### Deprecated +- The Generic.Formatting.NoSpaceAfterCast sniff has been deprecated and will be removed in version 4 + - The functionality of this sniff is now available in the Generic.Formatting.SpaceAfterCast sniff + - Include the Generic.Formatting.SpaceAfterCast sniff and set the "spacing" property to "0" + - As soon as possible, replace all instances of the old sniff code with the new sniff code and property setting + - The existing sniff will continue to work until version 4 has been released + +### Changed +- Rule include patterns in a ruleset.xml file are now evaluated as OR instead of AND + - Previously, a file had to match every include pattern and no exclude patterns to be included + - Now, a file must match at least one include pattern and no exclude patterns to be included + - This is a bug fix as include patterns are already documented to work this way +- New token T_BITWISE_NOT added for the bitwise not operator + - This token was previously tokenized as T_NONE + - Any sniffs specifically looking for T_NONE tokens with a tilde as the contents must now also look for T_BITWISE_NOT + - Sniffs can continue looking for T_NONE as well as T_BITWISE_NOT to support older PHP_CodeSniffer versions +- All types of binary casting are now tokenized as T_BINARY_CAST + - Previously, the 'b' in 'b"some string with $var"' would be a T_BINARY_CAST, but only when the string contained a var + - This change ensures the 'b' is always tokenized as T_BINARY_CAST + - This change also converts '(binary)' from T_STRING_CAST to T_BINARY_CAST + - Thanks to Juliette Reinders Folmer for the help with this patch +- Array properties set inside a ruleset.xml file can now extend a previous value instead of always overwriting it + - e.g., if you include a ruleset that defines forbidden functions, can you now add to that list instead of having to redefine it + - To use this feature, add extends="true" to the property tag + - e.g., property name="forbiddenFunctionNames" type="array" extend="true" + - Thanks to Michael Moravec for the patch +- If $XDG_CACHE_HOME is set and points to a valid directory, it will be used for caching instead of the system temp directory +- PHPCBF now disables parallel running if you are passing content on STDIN + - Stops an error from being shown after the fixed output is printed +- The progress report now shows files with tokenizer errors as skipped (S) instead of a warning (W) + - The tokenizer error is still displayed in reports as normal + - Thanks to Juliette Reinders Folmer for the patch +- The Squiz standard now ensures there is no space between an increment/decrement operator and its variable +- The File::getMethodProperties() method now includes a has_body array index in the return value + - FALSE if the method has no body (as with abstract and interface methods) or TRUE otherwise + - Thanks to Chris Wilkinson for the patch +- The File::getTokensAsString() method now throws an exception if the $start param is invalid + - If the $length param is invalid, an empty string will be returned + - Stops an infinite loop when the function is passed invalid data + - Thanks to Juliette Reinders Folmer for the patch +- Added new Generic.CodeAnalysis.EmptyPHPStatement sniff + - Warns when it finds empty PHP open/close tag combinations or superfluous semicolons + - Thanks to Juliette Reinders Folmer for the contribution +- Added new Generic.Formatting.SpaceBeforeCast sniff + - Ensures there is exactly 1 space before a type cast, unless the cast statement is indented or multi-line + - Thanks to Juliette Reinders Folmer for the contribution +- Added new Generic.VersionControl.GitMergeConflict sniff + - Detects merge conflict artifacts left in files + - Thanks to Juliette Reinders Folmer for the contribution +- Added Generic.WhiteSpace.IncrementDecrementSpacing sniff + - Ensures there is no space between the operator and the variable it applies to + - Thanks to Juliette Reinders Folmer for the contribution +- Added PSR12.Functions.NullableTypeDeclaration sniff + - Ensures there is no space after the question mark in a nullable type declaration + - Thanks to Timo Schinkel for the contribution +- A number of sniffs have improved support for methods in anonymous classes + - These sniffs would often throw the same error twice for functions in nested classes + - Error messages have also been changed to be less confusing + - The full list of affected sniffs is: + - Generic.NamingConventions.CamelCapsFunctionName + - PEAR.NamingConventions.ValidFunctionName + - PSR1.Methods.CamelCapsMethodName + - PSR2.Methods.MethodDeclaration + - Squiz.Scope.MethodScope + - Squiz.Scope.StaticThisUsage + - Thanks to Juliette Reinders Folmer for the patch +- Generic.CodeAnalysis.UnusedFunctionParameter now only skips functions with empty bodies when the class implements an interface + - Thanks to Juliette Reinders Folmer for the patch +- Generic.CodeAnalysis.UnusedFunctionParameter now has additional error codes to indicate where unused params were found + - The new error code prefixes are: + - FoundInExtendedClass: when the class extends another + - FoundInImplementedInterface: when the class implements an interface + - Found: used in all other cases, including closures + - The new error code suffixes are: + - BeforeLastUsed: the unused param was positioned before the last used param in the function signature + - AfterLastUsed: the unused param was positioned after the last used param in the function signature + - This makes the new error code list for this sniff: + - Found + - FoundBeforeLastUsed + - FoundAfterLastUsed + - FoundInExtendedClass + - FoundInExtendedClassBeforeLastUsed + - FoundInExtendedClassAfterLastUsed + - FoundInImplementedInterface + - FoundInImplementedInterfaceBeforeLastUsed + - FoundInImplementedInterfaceAfterLastUsed + - These errors code make it easier for specific cases to be ignored or promoted using a ruleset.xml file + - Thanks to Juliette Reinders Folmer for the contribution +- Generic.Classes.DuplicateClassName now inspects traits for duplicate names as well as classes and interfaces + - Thanks to Chris Wilkinson for the patch +- Generic.Files.InlineHTML now ignores a BOM at the start of the file + - Thanks to Chris Wilkinson for the patch +- Generic.PHP.CharacterBeforePHPOpeningTag now ignores a BOM at the start of the file + - Thanks to Chris Wilkinson for the patch +- Generic.Formatting.SpaceAfterCast now has a setting to specify how many spaces are required after a type cast + - Default remains 1 + - Override the "spacing" setting in a ruleset.xml file to change + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Formatting.SpaceAfterCast now has a setting to ignore newline characters after a type cast + - Default remains FALSE, so newlines are not allowed + - Override the "ignoreNewlines" setting in a ruleset.xml file to change + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Formatting.SpaceAfterNot now has a setting to specify how many spaces are required after a NOT operator + - Default remains 1 + - Override the "spacing" setting in a ruleset.xml file to change + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Formatting.SpaceAfterNot now has a setting to ignore newline characters after the NOT operator + - Default remains FALSE, so newlines are not allowed + - Override the "ignoreNewlines" setting in a ruleset.xml file to change + - Thanks to Juliette Reinders Folmer for the patch +- PEAR.Functions.FunctionDeclaration now checks spacing before the opening parenthesis of functions with no body + - Thanks to Chris Wilkinson for the patch +- PEAR.Functions.FunctionDeclaration now enforces no space before the semicolon in functions with no body + - Thanks to Chris Wilkinson for the patch +- PSR2.Classes.PropertyDeclaration now checks the order of property modifier keywords + - This is a rule that is documented in PSR-2 but was not enforced by the included PSR2 standard until now + - This sniff is also able to fix the order of the modifier keywords if they are incorrect + - Thanks to Juliette Reinders Folmer for the patch +- PSR2.Methods.MethodDeclaration now checks method declarations inside traits + - Thanks to Chris Wilkinson for the patch +- Squiz.Commenting.InlineComment now has better detection of comment block boundaries +- Squiz.Classes.ClassFileName now checks that a trait name matches the filename + - Thanks to Chris Wilkinson for the patch +- Squiz.Classes.SelfMemberReference now supports scoped declarations and anonymous classes + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Classes.SelfMemberReference now fixes multiple errors at once, increasing fixer performance + - Thanks to Gabriel Ostrolucký for the patch +- Squiz.Functions.LowercaseFunctionKeywords now checks abstract and final prefixes, and auto-fixes errors + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Objects.ObjectMemberComma.Missing has been renamed to Squiz.Objects.ObjectMemberComma.Found + - The error is thrown when the comma is found but not required, so the error code was incorrect + - If you are referencing the old error code in a ruleset XML file, please use the new code instead + - If you wish to maintain backwards compatibility, you can provide rules for both the old and new codes + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.ObjectOperatorSpacing is now more tolerant of parse errors +- Squiz.WhiteSpace.ObjectOperatorSpacing now fixes errors more efficiently + - Thanks to Juliette Reinders Folmer for the patch + +### Fixed +- Fixed bug #2109 : Generic.Functions.CallTimePassByReference false positive for bitwise and used in function argument +- Fixed bug #2165 : Conflict between Squiz.Arrays.ArrayDeclaration and ScopeIndent sniffs when heredoc used in array +- Fixed bug #2167 : Generic.WhiteSpace.ScopeIndent shows invalid error when scope opener indented inside inline HTML +- Fixed bug #2178 : Generic.NamingConventions.ConstructorName matches methods in anon classes with same name as containing class + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2190 : PEAR.Functions.FunctionCallSignature incorrect error when encountering trailing PHPCS annotation + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2194 : Generic.Whitespace.LanguageConstructSpacing should not be checking namespace operators + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2202 : Squiz.WhiteSpace.OperatorSpacing throws error for negative index when using curly braces for string access + - Same issue fixed in Squiz.Formatting.OperatorBracket + - Thanks to Andreas Buchenrieder for the patch +- Fixed bug #2210 : Generic.NamingConventions.CamelCapsFunctionName not ignoring SoapClient __getCookies() method + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2211 : PSR2.Methods.MethodDeclaration gets confused over comments between modifier keywords + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2212 : FUNCTION and CONST in use groups being tokenised as T_FUNCTION and T_CONST + - Thanks to Chris Wilkinson for the patch +- Fixed bug #2214 : File::getMemberProperties() is recognizing method params as properties + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2236 : Memory info measurement unit is Mb but probably should be MB +- Fixed bug #2246 : CSS tokenizer does not tokenize class names correctly when they contain the string NEW + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2278 : Squiz.Operators.ComparisonOperatorUsage false positive when inline IF contained in parentheses + - Thanks to Arnout Boks for the patch +- Fixed bug #2284 : Squiz.Functions.FunctionDeclarationArgumentSpacing removing type hint during fixing + - Thanks to MichaÅ‚ Bundyra for the patch +- Fixed bug #2297 : Anonymous class not tokenized correctly when used as argument to another anon class + - Thanks to MichaÅ‚ Bundyra for the patch + +## [2.9.2] - 2018-11-08 +### Changed +- PHPCS should now run under PHP 7.3 without deprecation warnings + - Thanks to Nick Wilde for the patch + +### Fixed +- Fixed bug #1496 : Squiz.Strings.DoubleQuoteUsage not unescaping dollar sign when fixing + - Thanks to MichaÅ‚ Bundyra for the patch +- Fixed bug #1549 : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1890 : Incorrect Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose error between catch and finally statements + +## [3.3.2] - 2018-09-24 +### Changed +- Fixed a problem where the report cache was not being cleared when the sniffs inside a standard were updated +- The info report (--report=info) now has improved formatting for metrics that span multiple lines + - Thanks to Juliette Reinders Folmer for the patch +- The unit test runner now skips .bak files when looking for test cases + - Thanks to Juliette Reinders Folmer for the patch +- The Squiz standard now ensures underscores are not used to indicate visibility of private members vars and methods + - Previously, this standard enforced the use of underscores +- Generic.PHP.NoSilencedErrors error messages now contain a code snippet to show the context of the error + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Arrays.ArrayDeclaration no longer reports errors for a comma on a line new after a here/nowdoc + - Also stops a parse error being generated when auto-fixing + - The SpaceBeforeComma error message has been changed to only have one data value instead of two +- Squiz.Commenting.FunctionComment no longer errors when trying to fix indents of multi-line param comments +- Squiz.Formatting.OperatorBracket now correctly fixes statements that contain strings +- Squiz.PHP.CommentedOutCode now ignores more @-style annotations and includes better comment block detection + - Thanks to Juliette Reinders Folmer for the patch + +### Fixed +- Fixed a problem where referencing a relative file path in a ruleset XML file could add unnecessary sniff exclusions + - This didn't actually exclude anything, but caused verbose output to list strange exclusion rules +- Fixed bug #2110 : Squiz.WhiteSpace.FunctionSpacing is removing indents from the start of functions when fixing + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2115 : Squiz.Commenting.VariableComment not checking var types when the @var line contains a comment +- Fixed bug #2120 : Tokenizer fails to match T_INLINE_ELSE when used after function call containing closure +- Fixed bug #2121 : Squiz.PHP.DisallowMultipleAssignments false positive in while loop conditions + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2127 : File::findExtendedClassName() doesn't support nested classes + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2138 : Tokenizer detects wrong token for php ::class feature with spaces +- Fixed bug #2143 : PSR2.Namespaces.UseDeclaration does not properly fix "use function" and "use const" statements + - Thanks to Chris Wilkinson for the patch +- Fixed bug #2144 : Squiz.Arrays.ArrayDeclaration does incorrect align calculation in array with cyrillic keys +- Fixed bug #2146 : Zend.Files.ClosingTag removes closing tag from end of file without inserting a semicolon +- Fixed bug #2151 : XML schema not updated with the new array property syntax + +## [3.3.1] - 2018-07-27 +### Removed +- Support for HHVM has been dropped due to recent unfixed bugs and HHVM refocus on Hack only + - Thanks to Walt Sorensen and Juliette Reinders Folmer for helping to remove all HHVM exceptions from the core + +### Changed +- The full report (the default report) now has improved word wrapping for multi-line messages and sniff codes + - Thanks to Juliette Reinders Folmer for the patch +- The summary report now sorts files based on their directory location instead of just a basic string sort + - Thanks to Juliette Reinders Folmer for the patch +- The source report now orders error codes by name when they have the same number of errors + - Thanks to Juliette Reinders Folmer for the patch +- The junit report no longer generates validation errors with the Jenkins xUnit plugin + - Thanks to Nikolay Geo for the patch +- Generic.Commenting.DocComment no longer generates the SpacingBeforeTags error if tags are the first content in the docblock + - The sniff will still generate a MissingShort error if there is no short comment + - This allows the MissingShort error to be suppressed in a ruleset to make short descriptions optional +- Generic.Functions.FunctionCallArgumentSpacing now properly fixes multi-line function calls with leading commas + - Previously, newlines between function arguments would be removed + - Thanks to Juliette Reinders Folmer for the patch +- Generic.PHP.Syntax will now use PHP_BINARY instead of trying to discover the executable path + - This ensures that the sniff will always syntax check files using the PHP version that PHPCS is running under + - Setting the php_path config var will still override this value as normal + - Thanks to Willem Stuursma-Ruwen for the patch +- PSR2.Namespaces.UseDeclaration now supports commas at the end of group use declarations + - Also improves checking and fixing for use statements containing parse errors + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Arrays.ArrayDeclaration no longer removes the array opening brace while fixing + - This could occur when the opening brace was on a new line and the first array key directly followed + - This change also stops the KeyNotAligned error message being incorrectly reported in these cases +- Squiz.Arrays.ArrayDeclaration no longer tries to change multi-line arrays to single line when they contain comments + - Fixes a conflict between this sniff and some indentation sniffs +- Squiz.Classes.ClassDeclaration no longer enforces spacing rules when a class is followed by a function + - Fixes a conflict between this sniff and the Squiz.WhiteSpace.FunctionSpacing sniff +- The Squiz.Classes.ValidClassName.NotCamelCaps message now references PascalCase instead of CamelCase + - The "CamelCase class name" metric produced by the sniff has been changed to "PascalCase class name" + - This reflects the fact that the class name check is actually a Pascal Case check and not really Camel Case + - Thanks to Tom H Anderson for the patch +- Squiz.Commenting.InlineComment no longer enforces spacing rules when an inline comment is followed by a docblock + - Fixes a conflict between this sniff and the Squiz.WhiteSpace.FunctionSpacing sniff +- Squiz.WhiteSpace.OperatorSpacing no longer tries to fix operator spacing if the next content is a comment on a new line + - Fixes a conflict between this sniff and the Squiz.Commenting.PostStatementComment sniff + - Also stops PHPCS annotations from being moved to a different line, potentially changing their meaning + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.FunctionSpacing no longer checks spacing of functions at the top of an embedded PHP block + - Fixes a conflict between this sniff and the Squiz.PHP.EmbeddedPHP sniff + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.MemberVarSpacing no longer checks spacing before member vars that come directly after methods + - Fixes a conflict between this sniff and the Squiz.WhiteSpace.FunctionSpacing sniff +- Squiz.WhiteSpace.SuperfluousWhitespace now recognizes unicode whitespace at the start and end of a file + - Thanks to Juliette Reinders Folmer for the patch + +### Fixed +- Fixed bug #2029 : Squiz.Scope.MemberVarScope throws fatal error when a property is found in an interface + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2047 : PSR12.Classes.ClassInstantiation false positive when instantiating class from array index +- Fixed bug #2048 : GenericFormatting.MultipleStatementAlignment false positive when assigning values inside an array +- Fixed bug #2053 : PSR12.Classes.ClassInstantiation incorrectly fix when using member vars and some variable formats +- Fixed bug #2065 : Generic.ControlStructures.InlineControlStructure fixing fails when inline control structure contains closure +- Fixed bug #2072 : Squiz.Arrays.ArrayDeclaration throws NoComma error when array value is a shorthand IF statement +- Fixed bug #2082 : File with "defined() or define()" syntax triggers PSR1.Files.SideEffects.FoundWithSymbols +- Fixed bug #2095 : PSR2.Namespaces.NamespaceDeclaration does not handle namespaces defined over multiple lines + +## [3.3.0] - 2018-06-07 +### Deprecated +- The Squiz.WhiteSpace.LanguageConstructSpacing sniff has been deprecated and will be removed in version 4 + - The sniff has been moved to the Generic standard, with a new code of Generic.WhiteSpace.LanguageConstructSpacing + - As soon as possible, replace all instances of the old sniff code with the new sniff code in your ruleset.xml files + - The existing Squiz sniff will continue to work until version 4 has been released + - The new Generic sniff now also checks many more language constructs to enforce additional spacing rules + - Thanks to Mponos George for the contribution +- The current method for setting array properties in ruleset files has been deprecated and will be removed in version 4 + - Currently, setting an array value uses the string syntax "print=>echo,create_function=>null" + - Now, individual array elements are specified using a new "element" tag with "key" and "value" attributes + - For example, element key="print" value="echo" + - Thanks to MichaÅ‚ Bundyra for the patch +- The T_ARRAY_HINT token has been deprecated and will be removed in version 4 + - The token was used to ensure array type hints were not tokenized as T_ARRAY, but no other type hints were given a special token + - Array type hints now use the standard T_STRING token instead + - Sniffs referencing this token type will continue to run without error until version 4, but will not find any T_ARRAY_HINT tokens +- The T_RETURN_TYPE token has been deprecated and will be removed in version 4 + - The token was used to ensure array/self/parent/callable return types were tokenized consistently + - For namespaced return types, only the last part of the string (the class name) was tokenized as T_RETURN_TYPE + - This was not consistent and so return types are now left using their original token types so they are not skipped by sniffs + - The exception are array return types, which are tokenized as T_STRING instead of T_ARRAY, as they are for type hints + - Sniffs referencing this token type will continue to run without error until version 4, but will not find any T_RETUTN_TYPE tokens + - To get the return type of a function, use the File::getMethodProperties() method, which now contains a "return_type" array index + - This contains the return type of the function or closer, or a blank string if not specified + - If the return type is nullable, the return type will contain the leading ? + - A nullable_return_type array index in the return value will also be set to true + - If the return type contains namespace information, it will be cleaned of whitespace and comments + - To access the original return value string, use the main tokens array + +### Added +- This release contains an incomplete version of the PSR-12 coding standard + - Errors found using this standard should be valid, but it will miss a lot of violations until it is complete + - If you'd like to test and help, you can use the standard by running PHPCS with --standard=PSR12 + +### Changed +- Config values set using --runtime-set now override any config values set in rulesets or the CodeSniffer.conf file +- You can now apply include-pattern rules to individual message codes in a ruleset like you can with exclude-pattern rules + - Previously, include-pattern rules only applied to entire sniffs + - If a message code has both include and exclude patterns, the exclude patterns will be ignored +- Using PHPCS annotations to selectively re-enable sniffs is now more flexible + - Previously, you could only re-enable a sniff/category/standard using the exact same code that was disabled + - Now, you can disable a standard and only re-enable a specific category or sniff + - Or, you can disable a specific sniff and have it re-enable when you re-enable the category or standard +- The value of array sniff properties can now be set using phpcs:set annotations + - e.g., phpcs:set Standard.Category.SniffName property[] key=>value,key2=>value2 + - Thanks to MichaÅ‚ Bundyra for the patch +- PHPCS annotations now remain as T_PHPCS_* tokens instead of reverting to comment tokens when --ignore-annotations is used + - This stops sniffs (especially commenting sniffs) from generating a large number of false errors when ignoring + - Any custom sniffs that are using the T_PHPCS_* tokens to detect annotations may need to be changed to ignore them + - Check $phpcsFile->config->annotations to see if annotations are enabled and ignore when false +- You can now use fully or partially qualified class names for custom reports instead of absolute file paths + - To support this, you must specify an autoload file in your ruleset.xml file and use it to register an autoloader + - Your autoloader will need to load your custom report class when requested + - Thanks to Juliette Reinders Folmer for the patch +- The JSON report format now does escaping in error source codes as well as error messages + - Thanks to Martin Vasel for the patch +- Invalid installed_paths values are now ignored instead of causing a fatal error +- Improved testability of custom rulesets by allowing the installed standards to be overridden + - Thanks to Timo Schinkel for the patch +- The key used for caching PHPCS runs now includes all set config values + - This fixes a problem where changing config values (e.g., via --runtime-set) used an incorrect cache file +- The "Function opening brace placement" metric has been separated into function and closure metrics in the info report + - Closures are no longer included in the "Function opening brace placement" metric + - A new "Closure opening brace placement" metric now shows information for closures +- Multi-line T_YIELD_FROM statements are now replicated properly for older PHP versions +- The PSR2 standard no longer produces 2 error messages when the AS keyword in a foreach loop is not lowercase +- Specifying a path to a non-existent dir when using the --report-[reportType]=/path/to/report CLI option no longer throws an exception + - This now prints a readable error message, as it does when using --report-file +- The File::getMethodParamaters() method now includes a type_hint_token array index in the return value + - Provides the position in the token stack of the first token in the type hint +- The File::getMethodProperties() method now includes a return_type_token array index in the return value + - Provides the position in the token stack of the first token in the return type +- The File::getTokensAsString() method can now optionally return original (non tab-replaced) content + - Thanks to Juliette Reinders Folmer for the patch +- Removed Squiz.PHP.DisallowObEndFlush from the Squiz standard + - If you use this sniff and want to continue banning ob_end_flush(), use Generic.PHP.ForbiddenFunctions instead + - You will need to set the forbiddenFunctions property in your ruleset.xml file +- Removed Squiz.PHP.ForbiddenFunctions from the Squiz standard + - Replaced by using the forbiddenFunctions property of Generic.PHP.ForbiddenFunctions in the Squiz ruleset.xml + - Functionality of the Squiz standard remains the same, but the error codes are now different + - Previously, Squiz.PHP.ForbiddenFunctions.Found and Squiz.PHP.ForbiddenFunctions.FoundWithAlternative + - Now, Generic.PHP.ForbiddenFunctions.Found and Generic.PHP.ForbiddenFunctions.FoundWithAlternative +- Added new Generic.PHP.LowerCaseType sniff + - Ensures PHP types used for type hints, return types, and type casting are lowercase + - Thanks to Juliette Reinders Folmer for the contribution +- Added new Generic.WhiteSpace.ArbitraryParenthesesSpacing sniff + - Generates an error for whitespace inside parenthesis that don't belong to a function call/declaration or control structure + - Generates a warning for any empty parenthesis found + - Allows the required spacing to be set using the spacing sniff property (default is 0) + - Allows newlines to be used by setting the ignoreNewlines sniff property (default is false) + - Thanks to Juliette Reinders Folmer for the contribution +- Added new PSR12.Classes.ClassInstantiation sniff + - Ensures parenthesis are used when instantiating a new class +- Added new PSR12.Keywords.ShortFormTypeKeywords sniff + - Ensures the short form of PHP types is used when type casting +- Added new PSR12.Namespaces.CompundNamespaceDepth sniff + - Ensures compound namespace use statements have a max depth of 2 levels + - The max depth can be changed by setting the 'maxDepth' sniff property in a ruleset.xml file +- Added new PSR12.Operators.OperatorSpacing sniff + - Ensures operators are preceded and followed by at least 1 space +- Improved core support for grouped property declarations + - Also improves support in Squiz.WhiteSpace.ScopeKeywordSpacing and Squiz.WhiteSpace.MemberVarSpacing + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Commenting.DocComment now produces a NonParamGroup error when tags are mixed in with the @param tag group + - It would previously throw either a NonParamGroup or ParamGroup error depending on the order of tags + - This change allows the NonParamGroup error to be suppressed in a ruleset to allow the @param group to contain other tags + - Thanks to Phil Davis for the patch +- Generic.Commenting.DocComment now continues checks param tags even if the doc comment short description is missing + - This change allows the MissingShort error to be suppressed in a ruleset without all other errors being suppressed as well + - Thanks to Phil Davis for the patch +- Generic.CodeAnalysis.AssignmentInCondition now reports a different error code for assignments found in WHILE conditions + - The return value of a function call is often assigned in a WHILE condition, so this change makes it easier to exclude these cases + - The new code for this error message is Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition + - The error code for all other cases remains as Generic.CodeAnalysis.AssignmentInCondition.Found + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Functions.OpeningFunctionBraceBsdAllman now longer leaves trailing whitespace when moving the opening brace during fixing + - Also applies to fixes made by PEAR.Functions.FunctionDeclaration and Squiz.Functions.MultiLineFunctionDeclaration +- Generic.WhiteSpace.ScopeIndent now does a better job of fixing the indent of multi-line comments +- Generic.WhiteSpace.ScopeIndent now does a better job of fixing the indent of PHP open and close tags +- PEAR.Commenting.FunctionComment now report a different error code for param comment lines with too much padding + - Previously, any lines of a param comment that don't start at the exact comment position got the same error code + - Now, only comment lines with too little padding use ParamCommentAlignment as they are clearly mistakes + - Comment lines with too much padding may be using precision alignment as now use ParamCommentAlignmentExceeded + - This allows for excessive padding to be excluded from a ruleset while continuing to enforce a minimum padding +- PEAR.WhiteSpace.ObjectOperatorIndent now checks the indent of more chained operators + - Previously, it only checked chains beginning with a variable + - Now, it checks chains beginning with function calls, static class names, etc +- Squiz.Arrays.ArrayDeclaration now continues checking array formatting even if the key indent is not correct + - Allows for using different array indent rules while still checking/fixing double arrow and value alignment +- Squiz.Commenting.BlockComment has improved support for tab-indented comments + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.BlockComment auto fixing no longer breaks when two block comments follow each other + - Also stopped single-line block comments from being auto fixed when they are embedded in other code + - Also fixed as issue found when PHPCS annotations were used inside a block comment + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.BlockComment.LastLineIndent is now able to be fixed with phpcbf + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.BlockComment now aligns star-prefixed lines under the opening tag while fixing, instead of indenting them + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.FunctionComment.IncorrectTypeHint message no longer contains cut-off suggested type hints +- Squiz.Commenting.InlineComment now uses a new error code for inline comments at the end of a function + - Previously, all inline comments followed by a blank line threw a Squiz.Commenting.InlineComment.SpacingAfter error + - Now, inline comments at the end of a function will instead throw Squiz.Commenting.InlineComment.SpacingAfterAtFunctionEnd + - If you previously excluded SpacingAfter, add an exclusion for SpacingAfterAtFunctionEnd to your ruleset as well + - If you previously only included SpacingAfter, consider including SpacingAfterAtFunctionEnd as well + - The Squiz standard now excludes SpacingAfterAtFunctionEnd as the blank line is checked elsewhere + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.ControlStructures.ControlSignature now errors when a comment follows the closing brace of an earlier body + - Applies to catch, finally, else, elseif, and do/while structures + - The included PSR2 standard now enforces this rule + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Formatting.OperatorBracket.MissingBrackets message has been changed to remove the word "arithmetic" + - The sniff checks more than just arithmetic operators, so the message is now clearer +- Sniffs.Operators.ComparisonOperatorUsage now detects more cases of implicit true comparisons + - It could previously be confused by comparisons used as function arguments +- Squiz.PHP.CommentedOutCode now ignores simple @-style annotation comments so they are not flagged as commented out code + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.PHP.CommentedOutCode now ignores a greater number of short comments so they are not flagged as commented out code + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.PHP.DisallowComparisonAssignment no longer errors when using the null coalescing operator + - Given this operator is used almost exclusively to assign values, it didn't make sense to generate an error +- Squiz.WhiteSpacing.FunctionSpacing now has a property to specify how many blank lines should be before the first class method + - Only applies when a method is the first code block in a class (i.e., there are no member vars before it) + - Override the 'spacingBeforeFirst' property in a ruleset.xml file to change + - If not set, the sniff will use whatever value is set for the existing 'spacing' property +- Squiz.WhiteSpacing.FunctionSpacing now has a property to specify how many blank lines should be after the last class method + - Only applies when a method is the last code block in a class (i.e., there are no member vars after it) + - Override the 'spacingAfterLast' property in a ruleset.xml file to change + - If not set, the sniff will use whatever value is set for the existing 'spacing' property + +### Fixed +- Fixed bug #1863 : File::findEndOfStatement() not working when passed a scope opener +- Fixed bug #1876 : PSR2.Namespaces.UseDeclaration not giving error for use statements before the namespace declaration + - Adds a new PSR2.Namespaces.UseDeclaration.UseBeforeNamespace error message +- Fixed bug #1881 : Generic.Arrays.ArrayIndent is indenting sub-arrays incorrectly when comma not used after the last value +- Fixed bug #1882 : Conditional with missing braces confused by indirect variables +- Fixed bug #1915 : JS tokenizer fails to tokenize regular expression proceeded by boolean not operator +- Fixed bug #1920 : Directory exclude pattern improperly excludes files with names that start the same + - Thanks to Jeff Puckett for the patch +- Fixed bug #1922 : Equal sign alignment check broken when list syntax used before assignment operator +- Fixed bug #1925 : Generic.Formatting.MultipleStatementAlignment skipping assignments within closures +- Fixed bug #1931 : Generic opening brace placement sniffs do not correctly support function return types +- Fixed bug #1932 : Generic.ControlStructures.InlineControlStructure fixer moves new PHPCS annotations +- Fixed bug #1938 : Generic opening brace placement sniffs incorrectly move PHPCS annotations + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1939 : phpcs:set annotations do not cause the line they are on to be ignored + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1949 : Squiz.PHP.DisallowMultipleAssignments false positive when using namespaces with static assignments +- Fixed bug #1959 : SquizMultiLineFunctionDeclaration error when param has trailing comment + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1963 : Squiz.Scope.MemberVarScope does not work for multiline member declaration + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1971 : Short array list syntax not correctly tokenized if short array is the first content in a file +- Fixed bug #1979 : Tokenizer does not change heredoc to nowdoc token if the start tag contains spaces +- Fixed bug #1982 : Squiz.Arrays.ArrayDeclaration fixer sometimes puts a comma in front of the last array value +- Fixed bug #1993 : PSR1/PSR2 not reporting or fixing short open tags +- Fixed bug #1996 : Custom report paths don't work on case-sensitive filesystems +- Fixed bug #2006 : Squiz.Functions.FunctionDeclarationArgumentSpacing fixer removes comment between parens when no args + - The SpacingAfterOpenHint error message has been removed + - It is replaced by the the existing SpacingAfterOpen message + - The error message format for the SpacingAfterOpen and SpacingBeforeClose messages has been changed + - These used to contain 3 pieces of data, but now only contain 2 + - If you have customised the error messages of this sniff, please review your ruleset after upgrading +- Fixed bug #2018 : Generic.Formatting.MultipleStatementAlignment does see PHP close tag as end of statement block + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #2027 : PEAR.NamingConventions.ValidFunctionName error when function name includes double underscore + - Thanks to Juliette Reinders Folmer for the patch + +## [3.2.3] - 2018-02-21 +### Changed +- The new phpcs: comment syntax can now be prefixed with an at symbol ( @phpcs: ) + - This restores the behaviour of the previous syntax where these comments are ignored by doc generators +- The current PHP version ID is now used to generate cache files + - This ensures that only cache files generated by the current PHP version are selected + - This change fixes caching issues when using sniffs that produce errors based on the current PHP version +- A new Tokens::$phpcsCommentTokens array is now available for sniff developers to detect phpcs: comment syntax + - Thanks to Juliette Reinders Folmer for the patch +- The PEAR.Commenting.FunctionComment.Missing error message now includes the name of the function + - Thanks to Yorman Arias for the patch +- The PEAR.Commenting.ClassComment.Missing and Squiz.Commenting.ClassComment.Missing error messages now include the name of the class + - Thanks to Yorman Arias for the patch +- PEAR.Functions.FunctionCallSignature now only forces alignment at a specific tab stop while fixing + - It was enforcing this during checking, but this meant invalid errors if the OpeningIndent message was being muted + - This fixes incorrect errors when using the PSR2 standard with some code blocks +- Generic.Files.LineLength now ignores lines that only contain phpcs: annotation comments + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Formatting.MultipleStatementAlignment now skips over arrays containing comments + - Thanks to Juliette Reinders Folmer for the patch +- Generic.PHP.Syntax now forces display_errors to ON when linting + - Thanks to Raúl Arellano for the patch +- PSR2.Namespaces.UseDeclaration has improved syntax error handling and closure detection + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.PHP.CommentedOutCode now has improved comment block detection for improved accuracy + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.PHP.NonExecutableCode could fatal error while fixing file with syntax error +- Squiz.PHP.NonExecutableCode now detects unreachable code after a goto statement + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.LanguageConstructSpacing has improved syntax error handling while fixing + - Thanks to Juliette Reinders Folmer for the patch +- Improved phpcs: annotation syntax handling for a number of sniffs + - Thanks to Juliette Reinders Folmer for the patch +- Improved auto-fixing of files with incomplete comment blocks for various commenting sniffs + - Thanks to Juliette Reinders Folmer for the patch + +### Fixed +- Fixed test suite compatibility with PHPUnit 7 +- Fixed bug #1793 : PSR2 forcing exact indent for function call opening statements +- Fixed bug #1803 : Squiz.WhiteSpace.ScopeKeywordSpacing removes member var name while fixing if no space after scope keyword +- Fixed bug #1817 : Blank line not enforced after control structure if comment on same line as closing brace +- Fixed bug #1827 : A phpcs:enable comment is not tokenized correctly if it is outside a phpcs:disable block + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1828 : Squiz.WhiteSpace.SuperfluousWhiteSpace ignoreBlankLines property ignores whitespace after single line comments + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1840 : When a comment has too many asterisks, phpcbf gives FAILED TO FIX error +- Fixed bug #1867 : Cant use phpcs:ignore where the next line is HTML +- Fixed bug #1870 : Invalid warning in multiple assignments alignment with closure or anon class +- Fixed bug #1890 : Incorrect Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose error between catch and finally statements +- Fixed bug #1891 : Comment on last USE statement causes false positive for PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse + - Thanks to Matt Coleman, Daniel Hensby, and Juliette Reinders Folmer for the patch +- Fixed bug #1901 : Fixed PHPCS annotations in multi-line tab-indented comments + not ignoring whole line for phpcs:set + - Thanks to Juliette Reinders Folmer for the patch + +## [3.2.2] - 2017-12-20 +### Changed +- Disabled STDIN detection on Windows + - This fixes a problem with IDE plugins (e.g., PHPStorm) hanging on Windows + +## [3.2.1] - 2017-12-18 +### Changed +- Empty diffs are no longer followed by a newline character (request #1781) +- Generic.Functions.OpeningFunctionBraceKernighanRitchie no longer complains when the open brace is followed by a close tag + - This makes the sniff more useful when used in templates + - Thanks to Joseph Zidell for the patch + +### Fixed +- Fixed problems with some scripts and plugins waiting for STDIN + - This was a notable problem with IDE plugins (e.g., PHPStorm) and build systems +- Fixed bug #1782 : Incorrect detection of operator in ternary + anonymous function + +## [3.2.0] - 2017-12-13 +### Deprecated +- This release deprecates the @codingStandards comment syntax used for sending commands to PHP_CodeSniffer + - The existing syntax will continue to work in all version 3 releases, but will be removed in version 4 + - The comment formats have been replaced by a shorter syntax: + - @codingStandardsIgnoreFile becomes phpcs:ignoreFile + - @codingStandardsIgnoreStart becomes phpcs:disable + - @codingStandardsIgnoreEnd becomes phpcs:enable + - @codingStandardsIgnoreLine becomes phpcs:ignore + - @codingStandardsChangeSetting becomes phpcs:set + - The new syntax allows for additional developer comments to be added after a -- separator + - This is useful for describing why a code block is being ignored, or why a setting is being changed + - E.g., phpcs:disable -- This code block must be left as-is. + - Comments using the new syntax are assigned new comment token types to allow them to be detected: + - phpcs:ignoreFile has the token T_PHPCS_IGNORE_FILE + - phpcs:disable has the token T_PHPCS_DISABLE + - phpcs:enable has the token T_PHPCS_ENABLE + - phpcs:ignore has the token T_PHPCS_IGNORE + - phpcs:set has the token T_PHPCS_SET + +### Changed +- The phpcs:disable and phpcs:ignore comments can now selectively ignore specific sniffs (request #604) + - E.g., phpcs:disable Generic.Commenting.Todo.Found for a specific message + - E.g., phpcs:disable Generic.Commenting.Todo for a whole sniff + - E.g., phpcs:disable Generic.Commenting for a whole category of sniffs + - E.g., phpcs:disable Generic for a whole standard + - Multiple sniff codes can be specified by comma separating them + - E.g., phpcs:disable Generic.Commenting.Todo,PSR1.Files +- @codingStandardsIgnoreLine comments now only ignore the following line if they are on a line by themselves + - If they are at the end of an existing line, they will only ignore the line they are on + - Stops some lines from accidentally being ignored + - Same rule applies for the new phpcs:ignore comment syntax +- PSR1.Files.SideEffects now respects the new phpcs:disable comment syntax + - The sniff will no longer check any code that is between phpcs:disable and phpcs:enable comments + - The sniff does not support phpcs:ignore; you must wrap code structures with disable/enable comments + - Previously, there was no way to have this sniff ignore parts of a file +- Fixed a problem where PHPCS would sometimes hang waiting for STDIN, or read incomplete versions of large files + - Thanks to Arne Jørgensen for the patch +- Array properties specified in ruleset files now have their keys and values trimmed + - This saves having to do this in individual sniffs and stops errors introduced by whitespace in rulesets + - Thanks to Juliette Reinders Folmer for the patch +- Added phpcs.xsd to allow validation of ruleset XML files + - Thanks to Renaat De Muynck for the contribution +- File paths specified using --stdin-path can now point to fake file locations (request #1488) + - Previously, STDIN files using fake file paths were excluded from checking +- Setting an empty basepath (--basepath=) on the CLI will now clear a basepath set directly in a ruleset + - Thanks to Xaver Loppenstedt for the patch +- Ignore patterns are now checked on symlink target paths instead of symlink source paths + - Restores previous behaviour of this feature +- Metrics were being double counted when multiple sniffs were recording the same metric +- Added support for bash process substitution + - Thanks to Scott Dutton for the contribution +- Files included in the cache file code hash are now sorted to aid in cache file reuse across servers +- Windows BAT files can now be used outside a PEAR install + - You must have the path to PHP set in your PATH environment variable + - Thanks to Joris Debonnet for the patch +- The JS unsigned right shift assignment operator is now properly classified as an assignment operator + - Thanks to Juliette Reinders Folmer for the patch +- The AbstractVariableSniff abstract sniff now supports anonymous classes and nested functions + - Also fixes an issue with Squiz.Scope.MemberVarScope where member vars of anonymous classes were not being checked +- Added AbstractArraySniff to make it easier to create sniffs that check array formatting + - Allows for checking of single and multi line arrays easily + - Provides a parsed structure of the array including positions of keys, values, and double arrows +- Added Generic.Arrays.ArrayIndent to enforce a single tab stop indent for array keys in multi-line arrays + - Also ensures the close brace is on a new line and indented to the same level as the original statement + - Allows for the indent size to be set using an "indent" property of the sniff +- Added Generic.PHP.DiscourageGoto to warn about the use of the GOTO language construct + - Thanks to Juliette Reinders Folmer for the contribution +- Generic.Debug.ClosureLinter was not running the gjslint command + - Thanks to MichaÅ‚ Bundyra for the patch +- Generic.WhiteSpace.DisallowSpaceIndent now fixes space indents in multi-line block comments + - Thanks to Juliette Reinders Folmer for the patch +- Generic.WhiteSpace.DisallowSpaceIndent now fixes mixed space/tab indents more accurately + - Thanks to Juliette Reinders Folmer for the patch +- Generic.WhiteSpace.DisallowTabIndent now fixes tab indents in multi-line block comments + - Thanks to Juliette Reinders Folmer for the patch +- PEAR.Functions.FunctionDeclaration no longer errors when a function declaration is the first content in a JS file + - Thanks to Juliette Reinders Folmer for the patch +- PEAR.Functions.FunctionCallSignature now requires the function name to be indented to an exact tab stop + - If the function name is not the start of the statement, the opening statement must be indented correctly instead + - Added a new fixable error code PEAR.Functions.FunctionCallSignature.OpeningIndent for this error +- Squiz.Functions.FunctionDeclarationArgumentSpacing is no longer confused about comments in function declarations + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.PHP.NonExecutableCode error messages now indicate which line the code block ending is on + - Makes it easier to identify where the code block exited or returned + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.FunctionComment now supports nullable type hints +- Squiz.Commenting.FunctionCommentThrowTag no longer assigns throw tags inside anon classes to the enclosing function +- Squiz.WhiteSpace.SemicolonSpacing now ignores semicolons used for empty statements inside FOR conditions + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.ControlStructures.ControlSignature now allows configuring the number of spaces before the colon in alternative syntax + - Override the 'requiredSpacesBeforeColon' setting in a ruleset.xml file to change + - Default remains at 1 + - Thanks to Nikola Kovacs for the patch +- The Squiz standard now ensures array keys are indented 4 spaces from the main statement + - Previously, this standard aligned keys 1 space from the start of the array keyword +- The Squiz standard now ensures array end braces are aligned with the main statement + - Previously, this standard aligned the close brace with the start of the array keyword +- The standard for PHP_CodeSniffer itself now enforces short array syntax +- The standard for PHP_CodeSniffer itself now uses the Generic.Arrays/ArrayIndent sniff rules +- Improved fixer conflicts and syntax error handling for a number of sniffs + - Thanks to Juliette Reinders Folmer for the patch + +### Fixed +- Fixed bug #1462 : Error processing cyrillic strings in Tokenizer +- Fixed bug #1573 : Squiz.WhiteSpace.LanguageConstructSpacing does not properly check for tabs and newlines + - Thanks to MichaÅ‚ Bundyra for the patch +- Fixed bug #1590 : InlineControlStructure CBF issue while adding braces to an if thats returning a nested function +- Fixed bug #1718 : Unclosed strings at EOF sometimes tokenized as T_WHITESPACE by the JS tokenizer +- Fixed bug #1731 : Directory exclusions do not work as expected when a single file name is passed to phpcs +- Fixed bug #1737 : Squiz.CSS.EmptyStyleDefinition sees comment as style definition and fails to report error +- Fixed bug #1746 : Very large reports can sometimes become garbled when using the parallel option +- Fixed bug #1747 : Squiz.Scope.StaticThisUsage incorrectly looking inside closures +- Fixed bug #1757 : Unknown type hint "object" in Squiz.Commenting.FunctionComment +- Fixed bug #1758 : PHPCS gets stuck creating file list when processing circular symlinks +- Fixed bug #1761 : Generic.WhiteSpace.ScopeIndent error on multi-line function call with static closure argument +- Fixed bug #1762 : Generic.WhiteSpace.Disallow[Space/Tab]Indent not inspecting content before open tag + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1769 : Custom "define" function triggers a warning about declaring new symbols +- Fixed bug #1776 : Squiz.Scope.StaticThisUsage incorrectly looking inside anon classes +- Fixed bug #1777 : Generic.WhiteSpace.ScopeIndent incorrect indent errors when self called function proceeded by comment + +## [3.1.1] - 2017-10-17 +### Changed +- Restored preference of non-dist files over dist files for phpcs.xml and phpcs.xml.dist + - The order that the files are searched is now: .phpcs.xml, phpcs.xml, .phpcs.xml.dist, phpcs.xml.dist + - Thanks to Juliette Reinders Folmer for the patch +- Progress output now correctly shows skipped files +- Progress output now shows 100% when the file list has finished processing (request #1697) +- Stopped some IDEs complaining about testing class aliases + - Thanks to Vytautas Stankus for the patch +- Squiz.Commenting.InlineComment incorrectly identified comment blocks in some cases, muting some errors + - Thanks to Juliette Reinders Folmer for the patch + +### Fixed +- Fixed bug #1512 : PEAR.Functions.FunctionCallSignature enforces spaces when no arguments if required spaces is not 0 +- Fixed bug #1522 : Squiz Arrays.ArrayDeclaration and Strings.ConcatenationSpacing fixers causing parse errors with here/ nowdocs +- Fixed bug #1570 : Squiz.Arrays.ArrayDeclaration fixer removes comments between array keyword and open parentheses +- Fixed bug #1604 : File::isReference has problems with some bitwise operators and class property references + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1645 : Squiz.Commenting.InlineComment will fail to fix comments at the end of the file + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1656 : Using the --sniffs argument has a problem with case sensitivity +- Fixed bug #1657 : Uninitialized string offset: 0 when sniffing CSS +- Fixed bug #1669 : Temporary expression proceeded by curly brace is detected as function call +- Fixed bug #1681 : Huge arrays are super slow to scan with Squiz.Arrays.ArrayDeclaration sniff +- Fixed bug #1694 : Squiz.Arrays.ArrayBracketSpacing is removing some comments during fixing + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1702 : Generic.WhiteSpaceDisallowSpaceIndent fixer bug when line only contains superfluous whitespace + +## [3.1.0] - 2017-09-20 +### Changed +- This release includes a change to support newer versions of PHPUnit (versions 4, 5, and 6 are now supported) + - The custom PHP_CodeSniffer test runner now requires a bootstrap file + - Developers with custom standards using the PHP_CodeSniffer test runner will need to do one of the following: + - run your unit tests from the PHP_CodeSniffer root dir so the bootstrap file is included + - specify the PHP_CodeSniffer bootstrap file on the command line: phpunit --bootstrap=/path/to/phpcs/tests/bootstrap.php + - require the PHP_CodeSniffer bootstrap file from your own bootstrap file + - If you don't run PHP_CodeSniffer unit tests, this change will not affect you + - Thanks to Juliette Reinders Folmer for the patch +- A phpcs.xml or phpcs.xml.dist file now takes precedence over the default_standard config setting + - Thanks to Björn Fischer for the patch +- Both phpcs.xml and phpcs.xml.dist files can now be prefixed with a dot (request #1566) + - The order that the files are searched is: .phpcs.xml, .phpcs.xml.dist, phpcs.xml, phpcs.xml.dist +- The autoloader will now search for files during unit tests runs from the same locations as during normal phpcs runs + - Allows for easier unit testing of custom standards that use helper classes or custom namespaces +- Include patterns for sniffs now use OR logic instead of AND logic + - Previously, a file had to be in each of the include patterns to be processed by a sniff + - Now, a file has to only be in at least one of the patterns + - This change reflects the original intention of the feature +- PHPCS will now follow symlinks under the list of checked directories + - This previously only worked if you specified the path to a symlink on the command line +- Output from --config-show, --config-set, and --config-delete now includes the path to the loaded config file +- PHPCS now cleanly exits if its config file is not readable + - Previously, a combination of PHP notices and PHPCS errors would be generated +- Comment tokens that start with /** are now always tokenized as docblocks + - Thanks to MichaÅ‚ Bundyra for the patch +- The PHP-supplied T_YIELD and T_YIELD_FROM token have been replicated for older PHP versions + - Thanks to MichaÅ‚ Bundyra for the patch +- Added new Generic.CodeAnalysis.AssignmentInCondition sniff to warn about variable assignments inside conditions + - Thanks to Juliette Reinders Folmer for the contribution +- Added Generic.Files.OneObjectStructurePerFile sniff to ensure there is a single class/interface/trait per file + - Thanks to Mponos George for the contribution +- Function call sniffs now check variable function names and self/static object creation + - Specific sniffs are Generic.Functions.FunctionCallArgumentSpacing, PEAR.Functions.FunctionCallSignature, and PSR2.Methods.FunctionCallSignature + - Thanks to MichaÅ‚ Bundyra for the patch +- Generic.Files.LineLength can now be configured to ignore all comment lines, no matter their length + - Set the ignoreComments property to TRUE (default is FALSE) in your ruleset.xml file to enable this + - Thanks to Juliette Reinders Folmer for the patch +- Generic.PHP.LowerCaseKeyword now checks self, parent, yield, yield from, and closure (function) keywords + - Thanks to MichaÅ‚ Bundyra for the patch +- PEAR.Functions.FunctionDeclaration now removes a blank line if it creates one by moving the curly brace during fixing +- Squiz.Commenting.FunctionCommentThrowTag now supports PHP 7.1 multi catch exceptions +- Squiz.Formatting.OperatorBracket no longer throws errors for PHP 7.1 multi catch exceptions +- Squiz.Commenting.LongConditionClosingComment now supports finally statements +- Squiz.Formatting.OperatorBracket now correctly fixes pipe separated flags +- Squiz.Formatting.OperatorBracket now correctly fixes statements containing short array syntax +- Squiz.PHP.EmbeddedPhp now properly fixes cases where the only content in an embedded PHP block is a comment + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.ControlStructureSpacing now ignores comments when checking blank lines at the top of control structures +- Squiz.WhiteSpace.ObjectOperatorSpacing now detects and fixes spaces around double colons + - Thanks to Julius Å mataviÄius for the patch +- Squiz.WhiteSpace.MemberVarSpacing can now be configured to check any number of blank lines between member vars + - Set the spacing property (default is 1) in your ruleset.xml file to set the spacing +- Squiz.WhiteSpace.MemberVarSpacing can now be configured to check a different number of blank lines before the first member var + - Set the spacingBeforeFirst property (default is 1) in your ruleset.xml file to set the spacing +- Added a new PHP_CodeSniffer\Util\Tokens::$ooScopeTokens static member var for quickly checking object scope + - Includes T_CLASS, T_ANON_CLASS, T_INTERFACE, and T_TRAIT + - Thanks to Juliette Reinders Folmer for the patch +- PHP_CodeSniffer\Files\File::findExtendedClassName() now supports extended interfaces + - Thanks to Martin Hujer for the patch + +### Fixed +- Fixed bug #1550 : Squiz.Commenting.FunctionComment false positive when function contains closure +- Fixed bug #1577 : Generic.InlineControlStructureSniff breaks with a comment between body and condition in do while loops +- Fixed bug #1581 : Sniffs not loaded when one-standard directories are being registered in installed_paths +- Fixed bug #1591 : Autoloader failing to load arbitrary files when installed_paths only set via a custom ruleset +- Fixed bug #1605 : Squiz.WhiteSpace.OperatorSpacing false positive on unary minus after comment + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1615 : Uncaught RuntimeException when phpcbf fails to fix files +- Fixed bug #1637 : Generic.WhiteSpaceScopeIndent closure argument indenting incorrect with multi-line strings +- Fixed bug #1638 : Squiz.WhiteSpace.ScopeClosingBrace closure argument indenting incorrect with multi-line strings +- Fixed bug #1640 : Squiz.Strings.DoubleQuoteUsage replaces tabs with spaces when fixing + - Thanks to Juliette Reinders Folmer for the patch + +## [3.0.2] - 2017-07-18 +### Changed +- The code report now gracefully handles tokenizer exceptions +- The phpcs and phpcbf scripts and now the only places that exit() in the code + - This allows for easier usage of core PHPCS functions from external scripts + - If you are calling Runner::runPHPCS() or Runner::runPHPCBF() directly, you will get back the full range of exit codes + - If not, catch the new DeepExitException to get the error message ($e->getMessage()) and exit code ($e->getCode()); +- NOWDOC tokens are now considered conditions, just as HEREDOC tokens are + - This makes it easier to find the start and end of a NOWDOC from any token within it + - Thanks to MichaÅ‚ Bundyra for the patch +- Custom autoloaders are now only included once in case multiple standards are using the same one + - Thanks to Juliette Reinders Folmer for the patch +- Improved tokenizing of fallthrough CASE and DEFAULT statements that share a closing statement and use curly braces +- Improved the error message when Squiz.ControlStructures.ControlSignature detects a newline after the closing parenthesis + +### Fixed +- Fixed a problem where the source report was not printing the correct number of errors found +- Fixed a problem where the --cache=/path/to/cachefile CLI argument was not working +- Fixed bug #1465 : Generic.WhiteSpace.ScopeIndent reports incorrect errors when indenting double arrows in short arrays +- Fixed bug #1478 : Indentation in fallthrough CASE that contains a closure +- Fixed bug #1497 : Fatal error if composer prepend-autoloader is set to false + - Thanks to Kunal Mehta for the patch +- Fixed bug #1503 : Alternative control structure syntax not always recognized as scoped +- Fixed bug #1523 : Fatal error when using the --suffix argument + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1526 : Use of basepath setting can stop PHPCBF being able to write fixed files +- Fixed bug #1530 : Generic.WhiteSpace.ScopeIndent can increase indent too much for lines within code blocks +- Fixed bug #1547 : Wrong token type for backslash in use function + - Thanks to MichaÅ‚ Bundyra for the patch +- Fixed bug #1549 : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1560 : Squiz.Commenting.FunctionComment fatal error when fixing additional param comment lines that have no indent + +## [3.0.1] - 2017-06-14 +### Security +- This release contains a fix for a security advisory related to the improper handling of a shell command + - A properly crafted filename would allow for arbitrary code execution when using the --filter=gitmodified command line option + - All version 3 users are encouraged to upgrade to this version, especially if you are checking 3rd-party code + - e.g., you run PHPCS over libraries that you did not write + - e.g., you provide a web service that runs PHPCS over user-uploaded files or 3rd-party repositories + - e.g., you allow external tool paths to be set by user-defined values + - If you are unable to upgrade but you check 3rd-party code, ensure you are not using the Git modified filter + - This advisory does not affect PHP_CodeSniffer version 2. + - Thanks to Sergei Morozov for the report and patch + +### Changed +- Arguments on the command line now override or merge with those specified in a ruleset.xml file in all cases +- PHPCS now stops looking for a phpcs.xml file as soon as one is found, favoring the closest one to the current dir +- Added missing help text for the --stdin-path CLI option to --help +- Re-added missing help text for the --file-list and --bootstrap CLI options to --help +- Runner::runPHPCS() and Runner::runPHPCBF() now return an exit code instead of exiting directly (request #1484) +- The Squiz standard now enforces short array syntax by default +- The autoloader is now working correctly with classes created with class_alias() +- The autoloader will now search for files inside all directories in the installed_paths config var + - This allows autoloading of files inside included custom coding standards without manually requiring them +- You can now specify a namespace for a custom coding standard, used by the autoloader to load non-sniff helper files + - Also used by the autoloader to help other standards directly include sniffs for your standard + - Set the value to the namespace prefix you are using for sniff files (everything up to \Sniffs\) + - e.g., if your namespace format is MyProject\CS\Standard\Sniffs\Category set the namespace to MyProject\CS\Standard + - If omitted, the namespace is assumed to be the same as the directory name containing the ruleset.xml file + - The namespace is set in the ruleset tag of the ruleset.xml file + - e.g., ruleset name="My Coding Standard" namespace="MyProject\CS\Standard" +- Rulesets can now specify custom autoloaders using the new autoload tag + - Autoloaders are included while the ruleset is being processed and before any custom sniffs are included + - Allows for very custom autoloading of helper classes well before the boostrap files are included +- The PEAR standard now includes Squiz.Commenting.DocCommentAlignment + - It previously broke comments onto multiple lines, but didn't align them + +### Fixed +- Fixed a problem where excluding a message from a custom standard's own sniff would exclude the whole sniff + - This caused some PSR2 errors to be under-reported +- Fixed bug #1442 : T_NULLABLE detection not working for nullable parameters and return type hints in some cases +- Fixed bug #1447 : Running the unit tests with a phpunit config file breaks the test suite + - Unknown arguments were not being handled correctly, but are now stored in $config->unknown +- Fixed bug #1449 : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1450 : Coding standard located under an installed_path with the same directory name throws an error + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1451 : Sniff exclusions/restrictions dont work with custom sniffs unless they use the PHP_CodeSniffer NS +- Fixed bug #1454 : Squiz.WhiteSpace.OperatorSpacing is not checking spacing on either side of a short ternary operator + - Thanks to Mponos George for the patch +- Fixed bug #1495 : Setting an invalid installed path breaks all commands +- Fixed bug #1496 : Squiz.Strings.DoubleQuoteUsage not unescaping dollar sign when fixing + - Thanks to MichaÅ‚ Bundyra for the patch +- Fixed bug #1501 : Interactive mode is broken +- Fixed bug #1504 : PSR2.Namespaces.UseDeclaration hangs fixing use statement with no trailing code + +## [2.9.1] - 2017-05-22 +### Fixed +- Fixed bug #1442 : T_NULLABLE detection not working for nullable parameters and return type hints in some cases +- Fixed bug #1448 : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace + - Thanks to Juliette Reinders Folmer for the patch + +## [3.0.0] - 2017-05-04 +### Changed +- Added an --ignore-annotations command line argument to ignore all @codingStandards annotations in code comments (request #811) +- This allows you to force errors to be shown that would otherwise be ignored by code comments + - Also stop files being able to change sniff properties mid way through processing +- An error is now reported if no sniffs were registered to be run (request #1129) +- The autoloader will now search for files inside the directory of any loaded coding standard + - This allows autoloading of any file inside a custom coding standard without manually requiring them + - Ensure your namespace begins with your coding standard's directory name and follows PSR-4 + - e.g., StandardName\Sniffs\CategoryName\AbstractHelper or StandardName\Helpers\StringSniffHelper +- Fixed an error where STDIN was sometimes not checked when using the --parallel CLI option +- The is_closure index has been removed from the return value of File::getMethodProperties() + - This value was always false because T_FUNCTION tokens are never closures + - Closures have a token type of T_CLOSURE +- The File::isAnonymousFunction() method has been removed + - This function always returned false because it only accepted T_FUNCTION tokens, which are never closures + - Closures have a token type of T_CLOSURE +- Includes all changes from the 2.9.0 release + +### Fixed +- Fixed bug #834 : PSR2.ControlStructures.SwitchDeclaration does not handle if branches with returns + - Thanks to Fabian Wiget for the patch + +## [3.0.0RC4] - 2017-03-02 +### Security +- This release contains a fix for a security advisory related to the improper handling of shell commands + - Uses of shell_exec() and exec() were not escaping filenames and configuration settings in most cases + - A properly crafted filename or configuration option would allow for arbitrary code execution when using some features + - All users are encouraged to upgrade to this version, especially if you are checking 3rd-party code + - e.g., you run PHPCS over libraries that you did not write + - e.g., you provide a web service that runs PHPCS over user-uploaded files or 3rd-party repositories + - e.g., you allow external tool paths to be set by user-defined values + - If you are unable to upgrade but you check 3rd-party code, ensure you are not using the following features: + - The diff report + - The notify-send report + - The Generic.PHP.Syntax sniff + - The Generic.Debug.CSSLint sniff + - The Generic.Debug.ClosureLinter sniff + - The Generic.Debug.JSHint sniff + - The Squiz.Debug.JSLint sniff + - The Squiz.Debug.JavaScriptLint sniff + - The Zend.Debug.CodeAnalyzer sniff + - Thanks to Klaus Purer for the report + +### Changed +- The indent property of PEAR.Classes.ClassDeclaration has been removed + - Instead of calculating the indent of the brace, it just ensures the brace is aligned with the class keyword + - Other sniffs can be used to ensure the class itself is indented correctly +- Invalid exclude rules inside a ruleset.xml file are now ignored instead of potentially causing out of memory errors + - Using the -vv command line argument now also shows the invalid exclude rule as XML +- Includes all changes from the 2.8.1 release + +### Fixed +- Fixed bug #1333 : The new autoloader breaks some frameworks with custom autoloaders +- Fixed bug #1334 : Undefined offset when explaining standard with custom sniffs + +## [3.0.0RC3] - 2017-02-02 +### Changed +- Added support for ES6 class declarations + - Previously, these class were tokenized as JS objects but are now tokenized as normal T_CLASS structures +- Added support for ES6 method declarations, where the "function" keyword is not used + - Previously, these methods were tokenized as JS objects (fixes bug #1251) + - The name of the ES6 method is now assigned the T_FUNCTION keyword and treated like a normal function + - Custom sniffs that support JS and listen for T_FUNCTION tokens can't assume the token represents the word "function" + - Check the contents of the token first, or use $phpcsFile->getDeclarationName($stackPtr) if you just want its name + - There is no change for custom sniffs that only check PHP code +- PHPCBF exit codes have been changed so they are now more useful (request #1270) + - Exit code 0 is now used to indicate that no fixable errors were found, and so nothing was fixed + - Exit code 1 is now used to indicate that all fixable errors were fixed correctly + - Exit code 2 is now used to indicate that PHPCBF failed to fix some of the fixable errors it found + - Exit code 3 is now used for general script execution errors +- Added PEAR.Commenting.FileComment.ParamCommentAlignment to check alignment of multi-line param comments +- Includes all changes from the 2.8.0 release + +### Fixed +- Fixed an issue where excluding a file using a @codingStandardsIgnoreFile comment would produce errors + - For PHPCS, it would show empty files being processed + - For PHPCBF, it would produce a PHP error +- Fixed bug #1233 : Can't set config data inside ruleset.xml file +- Fixed bug #1241 : CodeSniffer.conf not working with 3.x PHAR file + +## [3.0.0RC2] - 2016-11-30 +### Changed +- Made the Runner class easier to use with wrapper scripts +- Full usage information is no longer printed when a usage error is encountered (request #1186) + - Makes it a lot easier to find and read the error message that was printed +- Includes all changes from the 2.7.1 release + +### Fixed +- Fixed an undefined var name error that could be produced while running PHPCBF +- Fixed bug #1167 : 3.0.0RC1 PHAR does not work with PEAR standard +- Fixed bug #1208 : Excluding files doesn't work when using STDIN with a filename specified + +## [3.0.0RC1] - 2016-09-02 +### Changed +- Progress output now shows E and W in green when a file has fixable errors or warnings + - Only supported if colors are enabled +- PHPCBF no longer produces verbose output by default (request #699) + - Use the -v command line argument to show verbose fixing output + - Use the -q command line argument to disable verbose information if enabled by default +- PHPBF now prints a summary report after fixing files + - Report shows files that were fixed, how many errors were fixed, and how many remain +- PHPCBF now supports the -p command line argument to print progress information + - Prints a green F for files where fixes occurred + - Prints a red E for files that could not be fixed due to an error + - Use the -q command line argument to disable progress information if enabled by default +- Running unit tests using --verbose no longer throws errors +- Includes all changes from the 2.7.0 release + +### Fixed +- Fixed shell error appearing on some systems when trying to find executable paths + +## [3.0.0a1] - 2016-07-20 +### Changed +- Min PHP version increased from 5.1.2 to 5.4.0 +- Added optional caching of results between runs (request #530) + - Enable the cache by using the --cache command line argument + - If you want the cache file written somewhere specific, use --cache=/path/to/cacheFile + - Use the command "phpcs --config-set cache true" to turn caching on by default + - Use the --no-cache command line argument to disable caching if it is being turned on automatically +- Add support for checking file in parallel (request #421) + - Tell PHPCS how many files to check at once using the --parallel command line argument + - To check 100 files at once, using --parallel=100 + - To disable parallel checking if it is being turned on automatically, use --parallel=1 + - Requires PHP to be compiled with the PCNTL package +- The default encoding has been changed from iso-8859-1 to utf-8 (request #760) + - The --encoding command line argument still works, but you no longer have to set it to process files as utf-8 + - If encoding is being set to utf-8 in a ruleset or on the CLI, it can be safely removed + - If the iconv PHP extension is not installed, standard non-multibyte aware functions will be used +- Added a new "code" report type to show a code snippet for each error (request #419) + - The line containing the error is printed, along with 2 lines above and below it to show context + - The location of the errors is underlined in the code snippet if you also use --colors + - Use --report=code to generate this report +- Added support for custom filtering of the file list + - Developers can write their own filter classes to perform custom filtering of the list before the run starts + - Use the command line arg --filter=/path/to/filter.php to specify a filter to use + - Extend \PHP_CodeSniffer\Filters\Filter to also support the core PHPCS extension and path filtering + - Extend \PHP_CodeSniffer\Filters\ExactMatch to get the core filtering and the ability to use blacklists and whitelists + - The included \PHP_CodeSniffer\Filters\GitModified filter is a good example of an ExactMatch filter +- Added support for only checking files that have been locally modified or added in a git repo + - Use --filter=gitmodified to check these files + - You still need to give PHPCS a list of files or directories in which to check +- Added automatic discovery of executable paths (request #571) + - Thanks to Sergey Morozov for the patch +- You must now pass "-" on the command line to have PHPCS wait for STDIN + - E.g., phpcs --standard=PSR2 - + - You can still pipe content via STDIN as normal as PHPCS will see this and process it + - But without the "-", PHPCS will throw an error if no content or files are passed to it +- All PHP errors generated by sniffs are caught, re-thrown as exceptions, and reported in the standard error reports + - This should stop bugs inside sniffs causing infinite loops + - Also stops invalid reports being produced as errors don't print to the screen directly +- Sniff codes are no longer optional + - If a sniff throws and error or a warning, it must specify an internal code for that message +- The installed_paths config setting can now point directly to a standard + - Previously, it had to always point to the directory in which the standard lives +- Multiple reports can now be specified using the --report command line argument + - Report types are separated by commas + - E.g., --report=full,summary,info + - Previously, you had to use one argument for each report such as --report=full --report=summary --report=info +- You can now set the severity, message type, and exclude patterns for and entire sniff, category, or standard + - Previously, this was only available for a single message +- You can now include a single sniff code in a ruleset instead of having to include an entire sniff + - Including a sniff code will automatically exclude all other messages from that sniff + - If the sniff is already included by an imported standard, set the sniff severity to 0 and include the specific message you want +- PHPCBF no longer uses patch + - Files are now always overwritten + - The --no-patch option has been removed +- Added a --basepath option to strip a directory from the front of file paths in output (request #470) + - The basepath is absolute or relative to the current directory + - E.g., to output paths relative to current dir in reports, use --basepath=. +- Ignore rules are now checked when using STDIN (request #733) +- Added an include-pattern tag to rulesets to include a sniff for specific files and folders only (request #656) + - This is the exact opposite of the exclude-pattern tag + - This option is only usable within sniffs, not globally like exclude-patterns are +- Added a new -m option to stop error messages from being recorded, which saves a lot of memory + - PHPCBF always uses this setting to reduce memory as it never outputs error messages + - Setting the $recordErrors member var inside custom report classes is no longer supported (use -m instead) +- Exit code 2 is now used to indicate fixable errors were found (request #930) + - Exit code 3 is now used for general script execution errors + - Exit code 1 is used to indicate that coding standard errors were found, but none are fixable + - Exit code 0 is unchanged and continues to mean no coding standard errors found + +### Removed +- The included PHPCS standard has been removed + - All rules are now found inside the phpcs.xml.dist file + - Running "phpcs" without any arguments from a git clone will use this ruleset +- The included SVN pre-commit hook has been removed + - Hooks for version control systems will no longer be maintained within the PHPCS project + +## [2.9.0] - 2017-05-04 +### Changed +- Added Generic.Debug.ESLint sniff to run ESLint over JS files and report errors + - Set eslint path using: phpcs --config-set eslint_path /path/to/eslint + - Thanks to Ryan McCue for the contribution +- T_POW is now properly considered an arithmetic operator, and will be checked as such + - Thanks to Juliette Reinders Folmer for the patch +- T_SPACESHIP and T_COALESCE are now properly considered comparison operators, and will be checked as such + - Thanks to Juliette Reinders Folmer for the patch +- Generic.PHP.DisallowShortOpenTag now warns about possible short open tags even when short_open_tag is set to OFF + - Thanks to Juliette Reinders Folmer for the patch +- Generic.WhiteSpace.DisallowTabIndent now finds and fixes improper use of spaces anywhere inside the line indent + - Previously, only the first part of the indent was used to determine the indent type + - Thanks to Juliette Reinders Folmer for the patch +- PEAR.Commenting.ClassComment now supports checking of traits as well as classes and interfaces + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.FunctionCommentThrowTag now supports re-throwing exceptions (request #946) + - Thanks to Samuel Levy for the patch +- Squiz.PHP.DisallowMultipleAssignments now ignores PHP4-style member var assignments + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.FunctionSpacing now ignores spacing above functions when they are preceded by inline comments + - Stops conflicts between this sniff and comment spacing sniffs +- Squiz.WhiteSpace.OperatorSpacing no longer checks the equal sign in declare statements + - Thanks to Juliette Reinders Folmer for the patch +- Added missing error codes for a couple of sniffs so they can now be customised as normal + +### Fixed +- Fixed bug #1266 : PEAR.WhiteSpace.ScopeClosingBrace can throw an error while fixing mixed PHP/HTML +- Fixed bug #1364 : Yield From values are not recognised as returned values in Squiz FunctionComment sniff +- Fixed bug #1373 : Error in tab expansion results in white-space of incorrect size + - Thanks to Mark Clements for the patch +- Fixed bug #1381 : Tokenizer: dereferencing incorrectly identified as short array +- Fixed bug #1387 : Squiz.ControlStructures.ControlSignature does not handle alt syntax when checking space after closing brace +- Fixed bug #1392 : Scope indent calculated incorrectly when using array destructuring +- Fixed bug #1394 : integer type hints appearing as TypeHintMissing instead of ScalarTypeHintMissing + - PHP 7 type hints were also being shown when run under PHP 5 in some cases +- Fixed bug #1405 : Squiz.WhiteSpace.ScopeClosingBrace fails to fix closing brace within indented PHP tags +- Fixed bug #1421 : Ternaries used in constant scalar expression for param default misidentified by tokenizer +- Fixed bug #1431 : PHPCBF can't fix short open tags when they are not followed by a space + - Thanks to Gonçalo Queirós for the patch +- Fixed bug #1432 : PHPCBF can make invalid fixes to inline JS control structures that make use of JS objects + +## [2.8.1] - 2017-03-02 +### Security +- This release contains a fix for a security advisory related to the improper handling of shell commands + - Uses of shell_exec() and exec() were not escaping filenames and configuration settings in most cases + - A properly crafted filename or configuration option would allow for arbitrary code execution when using some features + - All users are encouraged to upgrade to this version, especially if you are checking 3rd-party code + - e.g., you run PHPCS over libraries that you did not write + - e.g., you provide a web service that runs PHPCS over user-uploaded files or 3rd-party repositories + - e.g., you allow external tool paths to be set by user-defined values + - If you are unable to upgrade but you check 3rd-party code, ensure you are not using the following features: + - The diff report + - The notify-send report + - The Generic.PHP.Syntax sniff + - The Generic.Debug.CSSLint sniff + - The Generic.Debug.ClosureLinter sniff + - The Generic.Debug.JSHint sniff + - The Squiz.Debug.JSLint sniff + - The Squiz.Debug.JavaScriptLint sniff + - The Zend.Debug.CodeAnalyzer sniff + - Thanks to Klaus Purer for the report + +### Changed +- The PHP-supplied T_COALESCE_EQUAL token has been replicated for PHP versions before 7.2 +- PEAR.Functions.FunctionDeclaration now reports an error for blank lines found inside a function declaration +- PEAR.Functions.FunctionDeclaration no longer reports indent errors for blank lines in a function declaration +- Squiz.Functions.MultiLineFunctionDeclaration no longer reports errors for blank lines in a function declaration + - It would previously report that only one argument is allowed per line +- Squiz.Commenting.FunctionComment now corrects multi-line param comment padding more accurately +- Squiz.Commenting.FunctionComment now properly fixes pipe-separated param types +- Squiz.Commenting.FunctionComment now works correctly when function return types also contain a comment + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.ControlStructures.InlineIfDeclaration now supports the elvis operator + - As this is not a real PHP operator, it enforces no spaces between ? and : when the THEN statement is empty +- Squiz.ControlStructures.InlineIfDeclaration is now able to fix the spacing errors it reports + +### Fixed +- Fixed bug #1340 : STDIN file contents not being populated in some cases + - Thanks to David Biňovec for the patch +- Fixed bug #1344 : PEAR.Functions.FunctionCallSignatureSniff throws error for blank comment lines +- Fixed bug #1347 : PSR2.Methods.FunctionCallSignature strips some comments during fixing + - Thanks to Algirdas Gurevicius for the patch +- Fixed bug #1349 : Squiz.Strings.DoubleQuoteUsage.NotRequired message is badly formatted when string contains a CR newline char + - Thanks to Algirdas Gurevicius for the patch +- Fixed bug #1350 : Invalid Squiz.Formatting.OperatorBracket error when using namespaces +- Fixed bug #1369 : Empty line in multi-line function declaration cause infinite loop + +## [2.8.0] - 2017-02-02 +### Changed +- The Internal.NoCodeFound error is no longer generated for content sourced from STDIN + - This should stop some Git hooks generating errors because PHPCS is trying to process the refs passed on STDIN +- Squiz.Commenting.DocCommentAlignment now checks comments on class properties defined using the VAR keyword + - Thanks to Klaus Purer for the patch +- The getMethodParameters() method now recognises "self" as a valid type hint + - The return array now contains a new "content" index containing the raw content of the param definition + - Thanks to Juliette Reinders Folmer for the patch +- The getMethodParameters() method now supports nullable types + - The return array now contains a new "nullable_type" index set to true or false for each method param + - Thanks to Juliette Reinders Folmer for the patch +- The getMethodParameters() method now supports closures + - Thanks to Juliette Reinders Folmer for the patch +- Added more guard code for JS files with syntax errors (request #1271 and request #1272) +- Added more guard code for CSS files with syntax errors (request #1304) +- PEAR.Commenting.FunctionComment fixers now correctly handle multi-line param comments +- AbstractVariableSniff now supports anonymous classes + - Thanks to Juliette Reinders Folmer for the patch +- Generic.NamingConventions.ConstructorName and PEAR.NamingConventions.ValidVariable now support anonymous classes +- Generic.NamingConventions.CamelCapsFunctionName and PEAR.NamingConventions.ValidFunctionName now support anonymous classes + - Thanks to Juliette Reinders Folmer for the patch +- Generic.CodeAnalysis.UnusedFunctionParameter and PEAR.Functions.ValidDefaultValue now support closures + - Thanks to Juliette Reinders Folmer for the patch +- PEAR.NamingConventions.ValidClassName and Squiz.Classes.ValidClassName now support traits + - Thanks to Juliette Reinders Folmer for the patch +- Generic.Functions.FunctionCallArgumentSpacing now supports closures other PHP-provided functions + - Thanks to Algirdas Gurevicius for the patch +- Fixed an error where a nullable type character was detected as an inline then token + - A new T_NULLABLE token has been added to represent the ? nullable type character + - Thanks to Jaroslav Hanslík for the patch +- Squiz.WhiteSpace.SemicolonSpacing no longer removes comments while fixing the placement of semicolons + - Thanks to Algirdas Gurevicius for the patch + +### Fixed +- Fixed bug #1230 : JS tokeniser incorrectly tokenises bitwise shifts as comparison + - Thanks to Ryan McCue for the patch +- Fixed bug #1237 : Uninitialized string offset in PHP Tokenizer on PHP 5.2 +- Fixed bug #1239 : Warning when static method name is 'default' +- Fixed bug #1240 : False positive for function names starting with triple underscore + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1245 : SELF is not recognised as T_SELF token in: return new self +- Fixed bug #1246 : A mix of USE statements with and without braces can cause the tokenizer to mismatch brace tokens + - Thanks to MichaÅ‚ Bundyra for the patch +- Fixed bug #1249 : GitBlame report requires a .git directory +- Fixed bug #1252 : Squiz.Strings.ConcatenationSpacing fix creates syntax error when joining a number to a string +- Fixed bug #1253 : Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch +- Fixed bug #1255 : Inconsistent indentation check results when ELSE on new line +- Fixed bug #1257 : Double dash in CSS class name can lead to "Named colours are forbidden" false positives +- Fixed bug #1260 : Syntax errors not being shown when error_prepend_string is set + - Thanks to Juliette Reinders Folmer for the patch +- Fixed bug #1264 : Array return type hint is sometimes detected as T_ARRAY_HINT instead of T_RETURN_TYPE + - Thanks to Jaroslav Hanslík for the patch +- Fixed bug #1265 : ES6 arrow function raises unexpected operator spacing errors +- Fixed bug #1267 : Fixer incorrectly handles filepaths with repeated dir names + - Thanks to Sergey Ovchinnikov for the patch +- Fixed bug #1276 : Commenting.FunctionComment.InvalidReturnVoid conditional issue with anonymous classes +- Fixed bug #1277 : Squiz.PHP.DisallowMultipleAssignments.Found error when var assignment is on the same line as an open tag +- Fixed bug #1284 : Squiz.Arrays.ArrayBracketSpacing.SpaceBeforeBracket false positive match for short list syntax + +## [2.7.1] - 2016-11-30 +### Changed +- Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis fix now removes unnecessary whitespace +- Squiz.Formatting.OperatorBracket no longer errors for negative array indexes used within a function call +- Squiz.PHP.EmbeddedPhp no longer expects a semicolon after statements that are only opening a scope +- Fixed a problem where the content of T_DOC_COMMENT_CLOSE_TAG tokens could sometimes be (boolean) false +- Developers of custom standards with custom test runners can now have their standards ignored by the built-in test runner + - Set the value of an environment variable called PHPCS_IGNORE_TESTS with a comma separated list of your standard names + - Thanks to Juliette Reinders Folmer for the patch +- The unit test runner now loads the test sniff outside of the standard's ruleset so that exclude rules do not get applied + - This may have caused problems when testing custom sniffs inside custom standards + - Also makes the unit tests runs a little faster +- The SVN pre-commit hook now works correctly when installed via composer + - Thanks to Sergey for the patch + +### Fixed +- Fixed bug #1135 : PEAR.ControlStructures.MultiLineCondition.CloseBracketNewLine not detected if preceded by multiline function call +- Fixed bug #1138 : PEAR.ControlStructures.MultiLineCondition.Alignment not detected if closing brace is first token on line +- Fixed bug #1141 : Sniffs that check EOF newlines don't detect newlines properly when the last token is a doc block +- Fixed bug #1150 : Squiz.Strings.EchoedStrings does not properly fix bracketed statements +- Fixed bug #1156 : Generic.Formatting.DisallowMultipleStatements errors when multiple short echo tags are used on the same line + - Thanks to Nikola Kovacs for the patch +- Fixed bug #1161 : Absolute report path is treated like a relative path if it also exists within the current directory +- Fixed bug #1170 : Javascript regular expression literal not recognized after comparison operator +- Fixed bug #1180 : Class constant named FUNCTION is incorrectly tokenized +- Fixed bug #1181 : Squiz.Operators.IncrementDecrementUsage.NoBrackets false positive when incrementing properties + - Thanks to Jürgen Henge-Ernst for the patch +- Fixed bug #1188 : Generic.WhiteSpace.ScopeIndent issues with inline HTML and multi-line function signatures +- Fixed bug #1190 : phpcbf on if/else with trailing comment generates erroneous code +- Fixed bug #1191 : Javascript sniffer fails with function called "Function" +- Fixed bug #1203 : Inconsistent behavior of PHP_CodeSniffer_File::findEndOfStatement +- Fixed bug #1218 : CASE conditions using class constants named NAMESPACE/INTERFACE/TRAIT etc are incorrectly tokenized +- Fixed bug #1221 : Indented function call with multiple closure arguments can cause scope indent error +- Fixed bug #1224 : PHPCBF fails to fix code with heredoc/nowdoc as first argument to a function + +## [2.7.0] - 2016-09-02 +### Changed +- Added --file-list command line argument to allow a list of files and directories to be specified in an external file + - Useful is you have a generated list of files to check that would be too long for the command line + - File and directory paths are listed one per line + - Usage is: phpcs --file-list=/path/to/file-list ... + - Thanks to Blotzu for the patch +- Values set using @codingStandardsChangeSetting comments can now contain spaces +- Sniff unit tests can now specify a list of test files instead of letting the runner pick them (request #1078) + - Useful if a sniff needs to exclude files based on the environment, or is checking filenames + - Override the new getTestFiles() method to specify your own list of test files +- Generic.Functions.OpeningFunctionBraceKernighanRitchie now ignores spacing for function return types + - The sniff code Generic.Functions.OpeningFunctionBraceKernighanRitchie.SpaceAfterBracket has been removed + - Replaced by Generic.Functions.OpeningFunctionBraceKernighanRitchie.SpaceBeforeBrace + - The new error message is slightly clearer as it indicates that a single space is needed before the brace +- Squiz.Commenting.LongConditionClosingComment now allows for the length of a code block to be configured + - Set the lineLimit property (default is 20) in your ruleset.xml file to set the code block length + - When the code block length is reached, the sniff will enforce a closing comment after the closing brace + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.Commenting.LongConditionClosingComment now allows for the end comment format to be configured + - Set the commentFormat property (default is "//end %s") in your ruleset.xml file to set the format + - The placeholder %s will be replaced with the type of condition opener, e.g., "//end foreach" + - Thanks to Juliette Reinders Folmer for the patch +- Generic.PHPForbiddenFunctions now allows forbidden functions to have mixed case + - Previously, it would only do a strtolower comparison + - Error message now shows what case was found in the code and what the correct case should be + - Thanks to Juliette Reinders Folmer for the patch +- Added Generic.Classes.OpeningBraceSameLine to ensure opening brace of class/interface/trait is on the same line as the declaration + - Thanks to Juliette Reinders Folmer for the patch +- Added Generic.PHP.BacktickOperator to ban the use of the backtick operator for running shell commands + - Thanks to Juliette Reinders Folmer for the patch +- Added Generic.PHP.DisallowAlternativePHPTags to ban the use of alternate PHP tags + - Thanks to Juliette Reinders Folmer for the patch +- Squiz.WhiteSpace.LanguageConstructSpacing no longer checks for spaces if parenthesis are being used (request #1062) + - Makes this sniff more compatible with those that check parenthesis spacing of function calls +- Squiz.WhiteSpace.ObjectOperatorSpacing now has a setting to ignore newline characters around object operators + - Default remains FALSE, so newlines are not allowed + - Override the "ignoreNewlines" setting in a ruleset.xml file to change + - Thanks to Alex Howansky for the patch +- Squiz.Scope.MethodScope now sniffs traits as well as classes and interfaces + - Thanks to Jesse Donat for the patch +- PHPCBF is now able to fix Squiz.SelfMemberReference.IncorrectCase errors + - Thanks to Nikola Kovacs for the patch +- PHPCBF is now able to fix Squiz.Commenting.VariableComment.IncorrectVarType + - Thanks to Walt Sorensen for the patch +- PHPCBF is now able to fix Generic.PHP.DisallowShortOpenTag + - Thanks to Juliette Reinders Folmer for the patch +- Improved the formatting of the end brace when auto fixing InlineControlStructure errors (request #1121) +- Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine fix no longer leaves blank line after brace (request #1085) +- Generic UpperCaseConstantNameSniff now allows lowercase namespaces in constant definitions + - Thanks to Daniel Schniepp for the patch +- Squiz DoubleQuoteUsageSniff is now more tolerant of syntax errors caused by mismatched string tokens +- A few sniffs that produce errors based on the current PHP version can now be told to run using a specific PHP version + - Set the php_version config var using --config-set, --runtime-set, or in a ruleset to specify a specific PHP version + - The format of the PHP version is the same as the PHP_VERSION_ID constant (e.g., 50403 for version 5.4.3) + - Supported sniffs are Generic.PHP.DisallowAlternativePHPTags, PSR1.Classes.ClassDeclaration, Squiz.Commenting.FunctionComment + - Thanks to Finlay Beaton for the patch + +### Fixed +- Fixed bug #985 : Duplicate class definition detection generates false-positives in media queries + - Thanks to Raphael Horber for the patch +- Fixed bug #1014 : Squiz VariableCommentSniff doesn't always detect a missing comment +- Fixed bug #1066 : Undefined index: quiet in CLI.php during unit test run with -v command line arg +- Fixed bug #1072 : Squiz.SelfMemberReference.NotUsed not detected if leading namespace separator is used +- Fixed bug #1089 : Rulesets cannot be loaded if the path contains urlencoded characters +- Fixed bug #1091 : PEAR and Squiz FunctionComment sniffs throw errors for some invalid @param line formats +- Fixed bug #1092 : PEAR.Functions.ValidDefaultValue should not flag type hinted methods with a NULL default argument +- Fixed bug #1095 : Generic LineEndings sniff replaces tabs with spaces with --tab-width is set +- Fixed bug #1096 : Squiz FunctionDeclarationArgumentSpacing gives incorrect error/fix when variadic operator is followed by a space +- Fixed bug #1099 : Group use declarations are incorrectly fixed by the PSR2 standard + - Thanks to Jason McCreary for the patch +- Fixed bug #1101 : Incorrect indent errors when breaking out of PHP inside an IF statement +- Fixed bug #1102 : Squiz.Formatting.OperatorBracket.MissingBrackets faulty bracketing fix +- Fixed bug #1109 : Wrong scope indent reported in anonymous class +- Fixed bug #1112 : File docblock not recognized when require_once follows it +- Fixed bug #1120 : InlineControlStructureSniff does not handle auto-fixing for control structures that make function calls +- Fixed bug #1124 : Squiz.Operators.ComparisonOperatorUsage does not detect bracketed conditions for inline IF statements + - Thanks to Raphael Horber for the patch + +## [2.6.2] - 2016-07-14 +### Changed +- Added a new --exclude CLI argument to exclude a list of sniffs from checking and fixing (request #904) + - Accepts the same sniff codes as the --sniffs command line argument, but provides the opposite functionality +- Added a new -q command line argument to disable progress and verbose information from being printed (request #969) + - Useful if a coding standard hard-codes progress or verbose output but you want PHPCS to be quiet + - Use the command "phpcs --config-set quiet true" to turn quiet mode on by default +- Generic LineLength sniff no longer errors for comments that cannot be broken out onto a new line (request #766) + - A typical case is a comment that contains a very long URL + - The comment is ignored if putting the URL on a indented new comment line would be longer than the allowed length +- Settings extensions in a ruleset no longer causes PHP notices during unit testing + - Thanks to Klaus Purer for the patch +- Version control reports now show which errors are fixable if you are showing sources +- Added a new sniff to enforce a single space after a NOT operator (request #1051) + - Include in a ruleset using the code Generic.Formatting.SpaceAfterNot +- The Squiz.Commenting.BlockComment sniff now supports tabs for indenting comment lines (request #1056) + +### Fixed +- Fixed bug #790 : Incorrect missing @throws error in methods that use closures +- Fixed bug #908 : PSR2 standard is not checking that closing brace is on line following the body +- Fixed bug #945 : Incorrect indent behavior using deep-nested function and arrays +- Fixed bug #961 : Two anonymous functions passed as function/method arguments cause indentation false positive +- Fixed bug #1005 : Using global composer vendor autoload breaks PHP lowercase built-in function sniff + - Thanks to Michael Butler for the patch +- Fixed bug #1007 : Squiz Unreachable code detection is not working properly with a closure inside a case +- Fixed bug #1023 : PSR2.Classes.ClassDeclaration fails if class extends base class and "implements" is on trailing line +- Fixed bug #1026 : Arrays in comma delimited class properties cause ScopeIndent to increase indent +- Fixed bug #1028 : Squiz ArrayDeclaration incorrectly fixes multi-line array where end bracket is not on a new line +- Fixed bug #1034 : Squiz FunctionDeclarationArgumentSpacing gives incorrect error when first arg is a variadic +- Fixed bug #1036 : Adjacent assignments aligned analysis statement wrong +- Fixed bug #1049 : Version control reports can show notices when the report width is very small +- Fixed bug #21050 : PEAR MultiLineCondition sniff suppresses errors on last condition line + +## [2.6.1] - 2016-05-31 +### Changed +- The PHP-supplied T_COALESCE token has been replicated for PHP versions before 7.0 +- Function return types of self, parent and callable are now tokenized as T_RETURN_TYPE + - Thanks to Jaroslav Hanslík for the patch +- The default_standard config setting now allows multiple standards to be listed, like on the command line + - Thanks to Michael Mayer for the patch +- Installations done via composer now only include the composer autoloader for PHP 5.3.2+ (request #942) +- Added a rollbackChangeset() method to the Fixer class to purposely rollback the active changeset + +### Fixed +- Fixed bug #940 : Auto-fixing issue encountered with inconsistent use of braces +- Fixed bug #943 : Squiz.PHP.InnerFunctions.NotAllowed reported in anonymous classes +- Fixed bug #944 : PHP warning when running the latest phar +- Fixed bug #951 : InlineIfDeclaration: invalid error produced with UTF-8 string +- Fixed bug #957 : Operator spacing sniff errors when plus is used as part of a number + - Thanks to Klaus Purer for the patch +- Fixed bug #959 : Call-time pass-by-reference false positive if there is a square bracket before the ampersand + - Thanks to Konstantin Leboev for the patch +- Fixed bug #962 : Null coalescing operator (??) not detected as a token + - Thanks to Joel Posti for the patch +- Fixed bug #973 : Anonymous class declaration and PSR1.Files.SideEffects.FoundWithSymbols +- Fixed bug #974 : Error when file ends with "function" +- Fixed bug #979 : Anonymous function with return type hint is not refactored as expected +- Fixed bug #983 : Squiz.WhiteSpace.MemberVarSpacing.AfterComment fails to fix error when comment is not a docblock +- Fixed bug #1010 : Squiz NonExecutableCode sniff does not detect boolean OR + - Thanks to Derek Henderson for the patch +- Fixed bug #1015 : The Squiz.Commenting.FunctionComment sniff doesn't allow description in @return tag + - Thanks to Alexander Obuhovich for the patch +- Fixed bug #1022 : Duplicate spaces after opening bracket error with PSR2 standard +- Fixed bug #1025 : Syntax error in JS file can cause undefined index for parenthesis_closer + +## [2.6.0] - 2016-04-04 +### Changed +- Paths used when setting CLI arguments inside ruleset.xml files are now relative to the ruleset location (request #847) + - This change only applies to paths within ARG tags, used to set CLI arguments + - Previously, the paths were relative to the directory PHPCS was being run from + - Absolute paths are still allowed and work the same way they always have + - This change allows ruleset.xml files to be more portable +- Content passed via STDIN will now be processed even if files are specified on the command line or in a ruleset +- When passing content via STDIN, you can now specify the file path to use on the command line (request #934) + - This allows sniffs that check file paths to work correctly + - This is the same functionality provided by the phpcs_input_file line, except it is available on the command line +- Files processed with custom tokenizers will no longer be skipped if they appear minified (request #877) + - If the custom tokenizer wants minified files skipped, it can set a $skipMinified member var to TRUE + - See the included JS and CSS tokenizers for an example +- Config vars set in ruleset.xml files are now processed earlier, allowing them to be used during sniff registration + - Among other things, this allows the installed_paths config var to be set in ruleset.xml files + - Thanks to Pieter Frenssen for the patch +- Improved detection of regular expressions in the JS tokenizer +- Generic PHP Syntax sniff now uses PHP_BINARY (if available) to determine the path to PHP if no other path is available + - You can still manually set php_path to use a specific binary for testing + - Thanks to Andrew Berry for the patch +- The PHP-supplied T_POW_EQUAL token has been replicated for PHP versions before 5.6 +- Added support for PHP7 use group declarations (request #878) + - New tokens T_OPEN_USE_GROUP and T_CLOSE_USE_GROUP are assigned to the open and close curly braces +- Generic ScopeIndent sniff now reports errors for every line that needs the indent changed (request #903) + - Previously, it ignored lines that were indented correctly in the context of their block + - This change produces more technically accurate error messages, but is much more verbose +- The PSR2 and Squiz standards now allow multi-line default values in function declarations (request #542) + - Previously, these would automatically make the function a multi-line declaration +- Squiz InlineCommentSniff now allows docblocks on require(_once) and include(_once) statements + - Thanks to Gary Jones for the patch +- Squiz and PEAR Class and File sniffs no longer assume the first comment in a file is always a file comment + - phpDocumentor assigns the comment to the file only if it is not followed by a structural element + - These sniffs now follow this same rule +- Squiz ClassCommentSniff no longer checks for blank lines before class comments + - Removes the error Squiz.Commenting.ClassComment.SpaceBefore +- Renamed Squiz.CSS.Opacity.SpacingAfterPoint to Squiz.CSS.Opacity.DecimalPrecision + - Please update your ruleset if you are referencing this error code directly +- Fixed PHP tokenizer problem that caused an infinite loop when checking a comment with specific content +- Generic Disallow Space and Tab indent sniffs now detect and fix indents inside embedded HTML chunks (request #882) +- Squiz CSS IndentationSniff no longer assumes the class opening brace is at the end of a line +- Squiz FunctionCommentThrowTagSniff now ignores non-docblock comments +- Squiz ComparisonOperatorUsageSniff now allows conditions like while(true) +- PEAR FunctionCallSignatureSniff (and the Squiz and PSR2 sniffs that use it) now correctly check the first argument + - Further fix for bug #698 + +### Fixed +- Fixed bug #791 : codingStandardsChangeSetting settings not working with namespaces +- Fixed bug #872 : Incorrect detection of blank lines between CSS class names +- Fixed bug #879 : Generic InlineControlStructureSniff can create parse error when case/if/elseif/else have mixed brace and braceless definitions +- Fixed bug #883 : PSR2 is not checking for blank lines at the start and end of control structures +- Fixed bug #884 : Incorrect indentation notice for anonymous classes +- Fixed bug #887 : Using curly braces for a shared CASE/DEFAULT statement can generate an error in PSR2 SwitchDeclaration +- Fixed bug #889 : Closure inside catch/else/elseif causes indentation error +- Fixed bug #890 : Function call inside returned short array value can cause indentation error inside CASE statements +- Fixed bug #897 : Generic.Functions.CallTimePassByReference.NotAllowed false positive when short array syntax +- Fixed bug #900 : Squiz.Functions.FunctionDeclarationArgumentSpacing bug when no space between type hint and argument +- Fixed bug #902 : T_OR_EQUAL and T_POW_EQUAL are not seen as assignment tokens +- Fixed bug #910 : Unrecognized "extends" and indentation on anonymous classes +- Fixed bug #915 : JS Tokenizer generates errors when processing some decimals +- Fixed bug #928 : Endless loop when sniffing a PHP file with a git merge conflict inside a function +- Fixed bug #937 : Shebang can cause PSR1 SideEffects warning + - Thanks to Clay Loveless for the patch +- Fixed bug #938 : CallTimePassByReferenceSniff ignores functions with return value + +## [2.5.1] - 2016-01-20 +### Changed +- The PHP-supplied T_SPACESHIP token has been replicated for PHP versions before 7.0 +- T_SPACESHIP is now correctly identified as an operator + - Thanks to Alexander Obuhovich for the patch +- Generic LowerCaseKeyword now ensures array type hints are lowercase as well + - Thanks to Mathieu Rochette for the patch +- Squiz ComparisonOperatorUsageSniff no longer hangs on JS FOR loops that don't use semicolons +- PHP_CodesSniffer now includes the composer autoload.php file, if there is one + - Thanks to Klaus Purer for the patch +- Added error Squiz.Commenting.FunctionComment.ScalarTypeHintMissing for PHP7 only (request #858) + - These errors were previously reported as Squiz.Commenting.FunctionComment.TypeHintMissing on PHP7 + - Disable this error message in a ruleset.xml file if your code needs to run on both PHP5 and PHP7 +- The PHP 5.6 __debugInfo magic method no longer produces naming convention errors + - Thanks to Michael Nowack for the patch +- PEAR and Squiz FunctionComment sniffs now support variadic functions (request #841) + +### Fixed +- Fixed bug #622 : Wrong detection of Squiz.CSS.DuplicateStyleDefinition with media queries +- Fixed bug #752 : The missing exception error is reported in first found DocBlock +- Fixed bug #794 : PSR2 MultiLineFunctionDeclaration forbids comments after opening parenthesis of a multiline call +- Fixed bug #820 : PEAR/PSR2 FunctionCallSignature sniffs suggest wrong indent when there are multiple arguments on a line +- Fixed bug #822 : Ruleset hard-coded file paths are not used if not running from the same directory as the ruleset +- Fixed bug #825 : FunctionCallArgumentSpacing sniff complains about more than one space before comment in multi-line function call +- Fixed bug #828 : Null classname is tokenized as T_NULL instead of T_STRING +- Fixed bug #829 : Short array argument not fixed correctly when multiple function arguments are on the same line +- Fixed bug #831 : PHPCS freezes in an infinite loop under Windows if no standard is passed +- Fixed bug #832 : Tokenizer does not support context sensitive parsing + - Thanks to Jaroslav Hanslík for the patch +- Fixed bug #835 : PEAR.Functions.FunctionCallSignature broken when closure uses return types +- Fixed bug #838 : CSS indentation fixer changes color codes + - Thanks to Klaus Purer for the patch +- Fixed bug #839 : "__()" method is marked as not camel caps + - Thanks to Tim Bezhashvyly for the patch +- Fixed bug #852 : Generic.Commenting.DocComment not finding errors when long description is omitted +- Fixed bug #854 : Return typehints in interfaces are not reported as T_RETURN_TYPE + - Thanks to Jaroslav Hanslík for the patch +- Fixed bug #855 : Capital letter detection for multibyte strings doesn't work correctly +- Fixed bug #857 : PSR2.ControlStructure.SwitchDeclaration shouldn't check indent of curly brace closers +- Fixed bug #859 : Switch statement indention issue when returning function call with closure +- Fixed bug #861 : Single-line arrays and function calls can generate incorrect indentation errors +- Fixed bug #867 : Squiz.Strings.DoubleQuoteUsage broken for some escape codes + - Thanks to Jack Blower for the help with the fix +- Fixed bug #21005 : Incorrect indent detection when multiple properties are initialized to arrays +- Fixed bug #21010 : Incorrect missing colon detection in CSS when first style is not on new line +- Fixed bug #21011 : Incorrect error message text when newline found after opening brace + +## [2.5.0] - 2015-12-11 +### Changed +- PHPCS will now look for a phpcs.xml file in parent directories as well as the current directory (request #626) +- PHPCS will now use a phpcs.xml file even if files are specified on the command line + - This file is still only used if no standard is specified on the command line +- Added support for a phpcs.xml.dist file (request #583) + - If both a phpcs.xml and phpcs.xml.dist file are present, the phpcs.xml file will be used +- Added support for setting PHP ini values in ruleset.xml files (request #560) + - Setting the value of the new ini tags to name="memory_limit" value="32M" is the same as -d memory_limit=32M +- Added support for one or more bootstrap files to be run before processing begins + - Use the --bootstrap=file,file,file command line argument to include bootstrap files + - Useful if you want to override some of the high-level settings of PHPCS or PHPCBF + - Thanks to John Maguire for the patch +- Added additional verbose output for CSS tokenizing +- Squiz ComparisonOperatorUsageSniff now checks FOR, WHILE and DO-WHILE statements + - Thanks to Arnout Boks for the patch + +### Fixed +- Fixed bug #660 : Syntax checks can fail on Windows with PHP5.6 +- Fixed bug #784 : $this->trait is seen as a T_TRAIT token +- Fixed bug #786 : Switch indent issue with short array notation +- Fixed bug #787 : SpacingAfterDefaultBreak confused by multi-line statements +- Fixed bug #797 : Parsing CSS url() value breaks further parsing +- Fixed bug #805 : Squiz.Commenting.FunctionComment.InvalidTypeHint on Scalar types on PHP7 +- Fixed bug #807 : Cannot fix line endings when open PHP tag is not on the first line +- Fixed bug #808 : JS tokeniser incorrectly setting some function and class names to control structure tokens +- Fixed bug #809 : PHPCBF can break a require_once statement with a space before the open parenthesis +- Fixed bug #813 : PEAR FunctionCallSignature checks wrong indent when first token on line is part of a multi-line string + +## [2.4.0] - 2015-11-24 +### Changed +- Added support for PHP 7 anonymous classes + - Anonymous classes are now tokenized as T_ANON_CLASS and ignored by normal class sniffs +- Added support for PHP 7 function return type declarations + - Return types are now tokenized as T_RETURN_TYPE +- Fixed tokenizing of the XOR operator, which was incorrectly identified as a power operator (bug #765) + - The T_POWER token has been removed and replaced by the T_BITWISE_XOR token + - The PHP-supplied T_POW token has been replicated for PHP versions before 5.6 +- Traits are now tokenized in PHP versions before 5.4 to make testing easier +- Improved regular expression detection in JS files +- PEAR FunctionCallSignatureSniff now properly detects indents in more mixed HTML/PHP code blocks +- Full report now properly indents lines when newlines are found inside error messages +- Generating documentation without specifying a standard now uses the default standard instead + - Thanks to Ken Guest for the patch +- Generic InlineControlStructureSniff now supports braceless do/while loops in JS + - Thanks to Pieter Frenssen for the patch +- Added more guard code for function declarations with syntax errors + - Thanks to Yun Young-jin for the patch +- Added more guard code for foreach declarations with syntax errors + - Thanks to Johan de Ruijter for the patch +- Added more guard code for class declarations with syntax errors +- Squiz ArrayDeclarationSniff now has guard code for arrays with syntax errors +- Generic InlineControlStructureSniff now correctly fixes ELSEIF statements + +### Fixed +- Fixed bug #601 : Expected type hint int[]; found array in Squiz FunctionCommentSniff + - Thanks to Scato Eggen for the patch +- Fixed bug #625 : Consider working around T_HASHBANG in HHVM 3.5.x and 3.6.x + - Thanks to Kunal Mehta for the patch +- Fixed bug #692 : Comment tokenizer can break when using mbstring function overloading +- Fixed bug #694 : Long sniff codes can cause PHP warnings in source report when showing error codes +- Fixed bug #698 : PSR2.Methods.FunctionCallSignature.Indent forces exact indent of ternary operator parameters +- Fixed bug #704 : ScopeIndent can fail when an opening parenthesis is on a line by itself +- Fixed bug #707 : Squiz MethodScopeSniff doesn't handle nested functions +- Fixed bug #709 : Squiz.Sniffs.Whitespace.ScopeClosingBraceSniff marking indented endif in mixed inline HTML blocks +- Fixed bug #711 : Sniffing from STDIN shows Generic.Files.LowercasedFilename.NotFound error +- Fixed bug #714 : Fixes suppression of errors using docblocks + - Thanks to Andrzej Karmazyn for the patch +- Fixed bug #716 : JSON report is invalid when messages contain newlines or tabs + - Thanks to Pieter Frenssen for the patch +- Fixed bug #723 : ScopeIndent can fail when multiple array closers are on the same line +- Fixed bug #730 : ScopeIndent can fail when a short array opening square bracket is on a line by itself +- Fixed bug #732 : PHP Notice if @package name is made up of all invalid characters + - Adds new error code PEAR.Commenting.FileComment.InvalidPackageValue +- Fixed bug #748 : Auto fix for Squiz.Commenting.BlockComment.WrongEnd is incorrect + - Thanks to J.D. Grimes for the patch +- Fixed bug #753 : PSR2 standard shouldn't require space after USE block when next code is a closing tag +- Fixed bug #768 : PEAR FunctionCallSignature sniff forbids comments after opening parenthesis of a multiline call +- Fixed bug #769 : Incorrect detection of variable reference operator when used with short array syntax + - Thanks to Klaus Purer for the patch +- Fixed bug #772 : Syntax error when using PHPCBF on alternative style foreach loops +- Fixed bug #773 : Syntax error when stripping trailing PHP close tag and previous statement has no semicolon +- Fixed bug #778 : PHPCBF creates invalid PHP for inline FOREACH containing multiple control structures +- Fixed bug #781 : Incorrect checking for PHP7 return types on multi-line function declarations +- Fixed bug #782 : Conditional function declarations cause fixing conflicts in Squiz standard + - Squiz.ControlStructures.ControlSignature no longer enforces a single newline after open brace + - Squiz.WhiteSpace.ControlStructureSpacing can be used to check spacing at the start/end of control structures + +## [2.3.4] - 2015-09-09 +### Changed +- JSON report format now includes the fixable status for each error message and the total number of fixable errors +- Added more guard code for function declarations with syntax errors +- Added tokenizer support for the PHP declare construct + - Thanks to Andy Blyler for the patch +- Generic UnnecessaryStringConcatSniff can now allow strings concatenated over multiple lines + - Set the allowMultiline property to TRUE (default is FALSE) in your ruleset.xml file to enable this + - By default, concat used only for getting around line length limits still generates an error + - Thanks to Stefan Lenselink for the contribution +- Invalid byte sequences no longer throw iconv_strlen() errors (request #639) + - Thanks to Willem Stuursma for the patch +- Generic TodoSniff and FixmeSniff are now better at processing strings with invalid characters +- PEAR FunctionCallSignatureSniff now ignores indentation of inline HTML content +- Squiz ControlSignatureSniff now supports control structures with only inline HTML content + +### Fixed +- Fixed bug #636 : Some class names cause CSS tokenizer to hang +- Fixed bug #638 : VCS blame reports output error content from the blame commands for files not under VC +- Fixed bug #642 : Method params incorrectly detected when default value uses short array syntax + - Thanks to Josh Davis for the patch +- Fixed bug #644 : PEAR ScopeClosingBrace sniff does not work with mixed HTML/PHP +- Fixed bug #645 : FunctionSignature and ScopeIndent sniffs don't detect indents correctly when PHP open tag is not on a line by itself +- Fixed bug #648 : Namespace not tokenized correctly when followed by multiple use statements +- Fixed bug #654 : Comments affect indent check for BSDAllman brace style +- Fixed bug #658 : Squiz.Functions.FunctionDeclarationSpacing error for multi-line declarations with required spaces greater than zero + - Thanks to J.D. Grimes for the patch +- Fixed bug #663 : No space after class name generates: Class name "" is not in camel caps format +- Fixed bug #667 : Scope indent check can go into infinite loop due to some parse errors +- Fixed bug #670 : Endless loop in PSR1 SideEffects sniffer if no semicolon after last statement + - Thanks to Thomas Jarosch for the patch +- Fixed bug #672 : Call-time pass-by-reference false positive +- Fixed bug #683 : Comments are incorrectly reported by PSR2.ControlStructures.SwitchDeclaration sniff +- Fixed bug #687 : ScopeIndent does not check indent correctly for method prefixes like public and abstract +- Fixed bug #689 : False error on some comments after class closing brace + +## [2.3.3] - 2015-06-24 +### Changed +- Improved the performance of the CSS tokenizer, especially on very large CSS files (thousands of lines) + - Thanks to Klaus Purer for the patch +- Defined tokens for lower PHP versions are now phpcs-specific strings instead of ints + - Stops conflict with other projects, like PHP_CodeCoverage +- Added more guard code for syntax errors to various sniffs +- Improved support for older HHVM versions + - Thanks to Kunal Mehta for the patch +- Squiz ValidLogicalOperatorsSniff now ignores XOR as type casting is different when using the ^ operator (request #567) +- Squiz CommentedOutCodeSniff is now better at ignoring URLs inside comments +- Squiz ControlSignatureSniff is now better at checking embedded PHP code +- Squiz ScopeClosingBraceSniff is now better at checking embedded PHP code + +### Fixed +- Fixed bug #584 : Squiz.Arrays.ArrayDeclaration sniff gives incorrect NoComma error for multiline string values +- Fixed bug #589 : PEAR.Functions.FunctionCallSignature sniff not checking all function calls +- Fixed bug #592 : USE statement tokenising can sometimes result in mismatched scopes +- Fixed bug #594 : Tokenizer issue on closure that returns by reference +- Fixed bug #595 : Colons in CSS selectors within media queries throw false positives + - Thanks to Klaus Purer for the patch +- Fixed bug #598 : PHPCBF can break function/use closure brace placement +- Fixed bug #603 : Squiz ControlSignatureSniff hard-codes opener type while fixing +- Fixed bug #605 : Auto report-width specified in ruleset.xml ignored +- Fixed bug #611 : Invalid numeric literal on CSS files under PHP7 +- Fixed bug #612 : Multi-file diff generating incorrectly if files do not end with EOL char +- Fixed bug #615 : Squiz OperatorBracketSniff incorrectly reports and fixes operations using self:: +- Fixed bug #616 : Squiz DisallowComparisonAssignmentSniff inconsistent errors with inline IF statements +- Fixed bug #617 : Space after switch keyword in PSR-2 is not being enforced +- Fixed bug #621 : PSR2 SwitchDeclaration sniff doesn't detect, or correctly fix, case body on same line as statement + +## [2.3.2] - 2015-04-29 +### Changed +- The error message for PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase is now clearer (request #579) + +### Fixed +- Fixed bug #545 : Long list of CASE statements can cause tokenizer to reach a depth limit +- Fixed bug #565 : Squiz.WhiteSpace.OperatorSpacing reports negative number in short array + - Thanks to VaÅ¡ek Purchart for the patch + - Same fix also applied to Squiz.Formatting.OperatorBracket +- Fixed bug #569 : Generic ScopeIndentSniff throws PHP notices in JS files +- Fixed bug #570 : Phar class fatals in PHP less than 5.3 + +## [2.3.1] - 2015-04-23 +### Changed +- PHPCS can now exit with 0 even if errors are found + - Set the ignore_errors_on_exit config variable to 1 to set this behaviour + - Use with the ignore_warnings_on_exit config variable to never return a non-zero exit code +- Added Generic DisallowLongArraySyntaxSniff to enforce the use of the PHP short array syntax (request #483) + - Thanks to Xaver Loppenstedt for helping with tests +- Added Generic DisallowShortArraySyntaxSniff to ban the use of the PHP short array syntax (request #483) + - Thanks to Xaver Loppenstedt for helping with tests +- Generic ScopeIndentSniff no longer does exact checking for content inside parenthesis (request #528) + - Only applies to custom coding standards that set the "exact" flag to TRUE +- Squiz ConcatenationSpacingSniff now has a setting to ignore newline characters around operators (request #511) + - Default remains FALSE, so newlines are not allowed + - Override the "ignoreNewlines" setting in a ruleset.xml file to change +- Squiz InlineCommentSniff no longer checks the last char of a comment if the first char is not a letter (request #505) +- The Squiz standard has increased the max padding for statement alignment from 12 to 20 + +### Fixed +- Fixed bug #479 : Yielded values are not recognised as returned values in Squiz FunctionComment sniff +- Fixed bug #512 : Endless loop whilst parsing mixture of control structure styles +- Fixed bug #515 : Spaces in JS block incorrectly flagged as indentation error +- Fixed bug #523 : Generic ScopeIndent errors for IF in FINALLY +- Fixed bug #527 : Closure inside IF statement is not tokenized correctly +- Fixed bug #529 : Squiz.Strings.EchoedStrings gives false positive when echo'ing using an inline condition +- Fixed bug #537 : Using --config-set is breaking phpcs.phar +- Fixed bug #543 : SWITCH with closure in condition generates inline control structure error +- Fixed bug #551 : Multiple catch blocks not checked in Squiz.ControlStructures.ControlSignature sniff +- Fixed bug #554 : ScopeIndentSniff causes errors when encountering an unmatched parenthesis +- Fixed bug #558 : PHPCBF adds brace for ELSE IF split over multiple lines +- Fixed bug #564 : Generic MultipleStatementAlignment sniff reports incorrect errors for multiple assignments on a single line + +## [2.3.0] - 2015-03-04 +### Changed +- The existence of the main config file is now cached to reduce is_file() calls when it doesn't exist (request #486) +- Abstract classes inside the Sniffs directory are now ignored even if they are named [Name]Sniff.php (request #476) + - Thanks to David Vernet for the patch +- PEAR and Squiz FileComment sniffs no longer have @ in their error codes + - e.g., PEAR.Commenting.FileComment.Duplicate@categoryTag becomes PEAR.Commenting.FileComment.DuplicateCategoryTag + - e.g., Squiz.Commenting.FileComment.Missing@categoryTag becomes Squiz.Commenting.FileComment.MissingCategoryTag +- PEAR MultiLineConditionSniff now allows comment lines inside multi-line IF statement conditions + - Thanks to Klaus Purer for the patch +- Generic ForbiddenFunctionsSniff now supports setting null replacements in ruleset files (request #263) +- Generic opening function brace sniffs now support checking of closures + - Set the checkClosures property to TRUE (default is FALSE) in your ruleset.xml file to enable this + - Can also set the checkFunctions property to FALSE (default is TRUE) in your ruleset.xml file to only check closures + - Affects OpeningFunctionBraceBsdAllmanSniff and OpeningFunctionBraceKernighanRitchieSniff +- Generic OpeningFunctionBraceKernighanRitchieSniff can now fix all the errors it finds +- Generic OpeningFunctionBraceKernighanRitchieSniff now allows empty functions with braces next to each other +- Generic OpeningFunctionBraceBsdAllmanSniff now allows empty functions with braces next to each other +- Improved auto report width for the "full" report +- Improved conflict detection during auto fixing +- Generic ScopeIndentSniff is no longer confused by empty closures +- Squiz ControlSignatureSniff now always ignores comments (fixes bug #490) + - Include the Squiz.Commenting.PostStatementComment sniff in your ruleset.xml to ban these comments again +- Squiz OperatorSpacingSniff no longer throws errors for code in the form ($foo || -1 === $bar) +- Fixed errors tokenizing T_ELSEIF tokens on HHVM 3.5 +- Squiz ArrayDeclarationSniff is no longer tricked by comments after array values +- PEAR IncludingFileSniff no longer produces invalid code when removing parenthesis from require/include statements + +### Fixed +- Fixed bug #415 : The @codingStandardsIgnoreStart has no effect during fixing +- Fixed bug #432 : Properties of custom sniffs cannot be configured +- Fixed bug #453 : PSR2 standard does not allow closing tag for mixed PHP/HTML files +- Fixed bug #457 : FunctionCallSignature sniffs do not support here/nowdoc syntax and can cause syntax error when fixing +- Fixed bug #466 : PropertyLabelSpacing JS fixer issue when there is no space after colon +- Fixed bug #473 : Writing a report for an empty folder to existing file includes the existing contents +- Fixed bug #485 : PHP notice in Squiz.Commenting.FunctionComment when checking malformed @throws comment +- Fixed bug #491 : Generic InlineControlStructureSniff can correct with missing semicolon + - Thanks to Jesse Donat for the patch +- Fixed bug #492 : Use statements don't increase the scope indent +- Fixed bug #493 : PSR1_Sniffs_Methods_CamelCapsMethodNameSniff false positives for some magic method detection + - Thanks to Andreas Möller for the patch +- Fixed bug #496 : Closures in PSR2 are not checked for a space after the function keyword +- Fixed bug #497 : Generic InlineControlStructureSniff does not support alternative SWITCH syntax +- Fixed bug #500 : Functions not supported as values in Squiz ArrayDeclaration sniff +- Fixed bug #501 : ScopeClosingBrace and ScopeIndent conflict with closures used as array values + - Generic ScopeIndentSniff may now report fewer errors for closures, but perform the same fixes +- Fixed bug #502 : PSR1 SideEffectsSniff sees declare() statements as side effects + +## [2.2.0] - 2015-01-22 +### Changed +- Added (hopefully) tastefully used colors to report and progress output for the phpcs command + - Use the --colors command line argument to use colors in output + - Use the command "phpcs --config-set colors true" to turn colors on by default + - Use the --no-colors command line argument to turn colors off when the config value is set +- Added support for using the full terminal width for report output + - Use the --report-width=auto command line argument to auto-size the reports + - Use the command "phpcs --config-set report_width auto" to use auto-sizing by default +- Reports will now size to fit inside the report width setting instead of always using padding to fill the space +- If no files or standards are specified, PHPCS will now look for a phpcs.xml file in the current directory + - This file has the same format as a standard ruleset.xml file + - The phpcs.xml file should specify (at least) files to process and a standard/sniffs to use + - Useful for running the phpcs and phpcbf commands without any arguments at the top of a repository +- Default file paths can now be specified in a ruleset.xml file using the "file" tag + - File paths are only processed if no files were specified on the command line +- Extensions specified on the CLI are now merged with those set in ruleset.xml files + - Previously, the ruleset.xml file setting replaced the CLI setting completely +- Squiz coding standard now requires lowercase PHP constants (true, false and null) + - Removed Squiz.NamingConventions.ConstantCase sniff as the rule is now consistent across PHP and JS files +- Squiz FunctionOpeningBraceSpaceSniff no longer does additional checks for JS functions + - PHP and JS functions and closures are now treated the same way +- Squiz MultiLineFunctionDeclarationSniff now supports JS files +- Interactive mode no longer breaks if you also specify a report type on the command line +- PEAR InlineCommentSniff now fixes the Perl-style comments that it finds (request #375) +- PSR2 standard no longer fixes the placement of docblock open tags as comments are excluded from this standard +- PSR2 standard now sets a default tab width of 4 spaces +- Generic DocCommentSniff now only disallows lowercase letters at the start of a long/short comment (request #377) + - All non-letter characters are now allowed, including markdown special characters and numbers +- Generic DisallowMultipleStatementsSniff now allows multiple open/close tags on the same line (request #423) +- Generic CharacterBeforePHPOpeningTagSniff now only checks the first PHP tag it finds (request #423) +- Generic CharacterBeforePHPOpeningTagSniff now allows a shebang line at the start of the file (request #20481) +- Generic InlineHTMLUnitTest now allows a shebang line at the start of the file (request #20481) +- PEAR ObjectOperatorIndentSniff now only checks object operators at the start of a line +- PEAR FileComment and ClassComment sniffs no longer have @ in their error codes + - E.g., PEAR.Commenting.FileComment.Missing@categoryTag becomes PEAR.Commenting.FileComment.MissingCategoryTag + - Thanks to Grzegorz Rygielski for the patch +- Squiz ControlStructureSpacingSniff no longer enforces a blank line before CATCH statements +- Squiz FunctionCommentSniff now fixes the return type in the @return tag (request #392) +- Squiz BlockCommentSniff now only disallows lowercase letters at the start of the comment +- Squiz InlineCommentSniff now only disallows lowercase letters at the start of the comment +- Squiz OperatorSpacingSniff now has a setting to ignore newline characters around operators (request #348) + - Default remains FALSE, so newlines are not allowed + - Override the "ignoreNewlines" setting in a ruleset.xml file to change +- PSR2 ControlStructureSpacingSniff now checks for, and fixes, newlines after the opening parenthesis +- Added a markdown document generator (--generator=markdown to use) + - Thanks to Stefano Kowalke for the contribution + +### Fixed +- Fixed bug #379 : Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast incorrectly detects comments +- Fixed bug #382 : JS tokenizer incorrect for inline conditionally created immediately invoked anon function +- Fixed bug #383 : Squiz.Arrays.ArrayDeclaration.ValueNoNewline incorrectly detects nested arrays +- Fixed bug #386 : Undefined offset in Squiz.FunctionComment sniff when param has no comment +- Fixed bug #390 : Indentation of non-control structures isn't adjusted when containing structure is fixed +- Fixed bug #400 : InlineControlStructureSniff fails to fix when statement has no semicolon +- Fixed bug #401 : PHPCBF no-patch option shows an error when there are no fixable violations in a file +- Fixed bug #405 : The "Squiz.WhiteSpace.FunctionSpacing" sniff removes class "}" during fixing +- Fixed bug #407 : PEAR.ControlStructures.MultiLineCondition doesn't account for comments at the end of lines +- Fixed bug #410 : The "Squiz.WhiteSpace.MemberVarSpacing" not respecting "var" +- Fixed bug #411 : Generic.WhiteSpace.ScopeIndent.Incorrect - false positive with multiple arrays in argument list +- Fixed bug #412 : PSR2 multi-line detection doesn't work for inline IF and string concats +- Fixed bug #414 : Squiz.WhiteSpace.MemberVarSpacing - inconsistent checking of member vars with comment +- Fixed bug #433 : Wrong detection of Squiz.Arrays.ArrayDeclaration.KeyNotAligned when key contains space +- Fixed bug #434 : False positive for spacing around "=>" in inline array within foreach +- Fixed bug #452 : Ruleset exclude-pattern for specific sniff code ignored when using CLI --ignore option +- Fixed bug #20482 : Scope indent sniff can get into infinite loop when processing a parse error + +## [2.1.0] - 2014-12-18 +### Changed +- Time and memory output is now shown if progress information is also shown (request #335) +- A tilde can now be used to reference a user's home directory in a path to a standard (request #353) +- Added PHP_CodeSniffer_File::findStartOfStatement() to find the first non-whitespace token in a statement + - Possible alternative for code using PHP_CodeSniffer_File::findPrevious() with the local flag set +- Added PHP_CodeSniffer_File::findEndOfStatement() to find the last non-whitespace token in a statement + - Possible alternative for code using PHP_CodeSniffer_File::findNext() with the local flag set +- Generic opening function brace sniffs now ensure the opening brace is the last content on the line + - Affects OpeningFunctionBraceBsdAllmanSniff and OpeningFunctionBraceKernighanRitchieSniff + - Also enforced in PEAR FunctionDeclarationSniff and Squiz MultiLineFunctionDeclarationSniff +- Generic DisallowTabIndentSniff now replaces tabs everywhere it finds them, except in strings and here/now docs +- Generic EmptyStatementSniff error codes now contain the type of empty statement detected (request #314) + - All messages generated by this sniff are now errors (empty CATCH was previously a warning) + - Message code Generic.CodeAnalysis.EmptyStatement.NotAllowed has been removed + - Message code Generic.CodeAnalysis.EmptyStatement.NotAllowedWarning has been removed + - New message codes have the format Generic.CodeAnalysis.EmptyStatement.Detected[TYPE] + - Example code is Generic.CodeAnalysis.EmptyStatement.DetectedCATCH + - You can now use a custom ruleset to change messages to warnings and to exclude them +- PEAR and Squiz FunctionCommentSniffs no longer ban @return tags for constructors and destructors + - Removed message PEAR.Commenting.FunctionComment.ReturnNotRequired + - Removed message Squiz.Commenting.FunctionComment.ReturnNotRequired + - Change initiated by request #324 and request #369 +- Squiz EmptyStatementSniff has been removed + - Squiz standard now includes Generic EmptyStatementSniff and turns off the empty CATCH error +- Squiz ControlSignatureSniff fixes now retain comments between the closing parenthesis and open brace +- Squiz SuperfluousWhitespaceSniff now checks for extra blank lines inside closures + - Thanks to Sertan Danis for the patch +- Squiz ArrayDeclarationSniff now skips function calls while checking multi-line arrays + +### Fixed +- Fixed bug #337 : False positive with anonymous functions in Generic_Sniffs_WhiteSpace_ScopeIndentSniff +- Fixed bug #339 : reformatting brace location can result in broken code +- Fixed bug #342 : Nested ternary operators not tokenized correctly +- Fixed bug #345 : Javascript regex not tokenized when inside array +- Fixed bug #346 : PHP path can't be determined in some cases in "phpcs.bat" (on Windows XP) +- Fixed bug #358 : False positives for Generic_Sniffs_WhiteSpace_ScopeIndentSniff +- Fixed bug #361 : Sniff-specific exclude patterns don't work for Windows +- Fixed bug #364 : Don't interpret "use function" as declaration +- Fixed bug #366 : phpcbf with PSR2 errors on control structure alternative syntax +- Fixed bug #367 : Nested Anonymous Functions Causing False Negative +- Fixed bug #371 : Shorthand binary cast causes tokenizer errors + - New token T_BINARY_CAST added for the b"string" cast format (the 'b' is the T_BINARY_CAST token) +- Fixed bug #372 : phpcbf parse problem, wrong brace placement for inline IF +- Fixed bug #373 : Double quote usage fix removing too many double quotes +- Fixed bug #20196 : 1.5.2 breaks scope_closer position + +## [2.0.0] - 2014-12-05 +### Changed +- JS tokenizer now sets functions as T_CLOSUREs if the function is anonymous +- JS tokenizer now sets all objects to T_OBJECT + - Object end braces are set to a new token T_CLOSE_OBJECT + - T_OBJECT tokens no longer act like scopes; i.e., they have no condition/opener/closer + - T_PROPERTY tokens no longer act like scopes; i.e., they have no condition/opener/closer + - T_OBJECT tokens have a bracket_closer instead, which can be used to find the ending + - T_CLOSE_OBJECT tokens have a bracket_opener +- Improved regular expression detection in the JS tokenizer +- You can now get PHP_CodeSniffer to ignore a single line by putting @codingStandardsIgnoreLine in a comment + - When the comment is found, the comment line and the following line will be ignored + - Thanks to Andy Bulford for the contribution +- PHPCBF now prints output when it is changing into directories +- Improved conflict detection during auto fixing +- The -vvv command line argument will now output the current file content for each loop during fixing +- Generic ScopeIndentSniff now checks that open/close PHP tags are aligned to the correct column +- PEAR FunctionCallSignatureSniff now checks indent of closing parenthesis even if it is not on a line by itself +- PEAR FunctionCallSignatureSniff now supports JS files +- PEAR MultiLineConditionSniff now supports JS files +- Squiz DocCommentAlignmentSniff now supports JS files +- Fixed a problem correcting the closing brace line in Squiz ArrayDeclarationSniff +- Fixed a problem auto-fixing the Squiz.WhiteSpace.FunctionClosingBraceSpace.SpacingBeforeNestedClose error +- Squiz EmbeddedPhpSniff no longer reports incorrect alignment of tags when they are not on new lines +- Squiz EmbeddedPhpSniff now aligns open tags correctly when moving them onto a new line +- Improved fixing of arrays with multiple values in Squiz ArrayDeclarationSniff +- Improved detection of function comments in Squiz FunctionCommentSpacingSniff +- Improved fixing of lines after cases statements in Squiz SwitchDeclarationSniff + +### Fixed +- Fixed bug #311 : Suppression of function prototype breaks checking of lines within function +- Fixed bug #320 : Code sniffer indentation issue +- Fixed bug #333 : Nested ternary operators causing problems + +## [1.5.6] - 2014-12-05 +### Changed +- JS tokenizer now detects xor statements correctly +- The --config-show command now pretty-prints the config values + - Thanks to Ken Guest for the patch +- Setting and removing config values now catches exceptions if the config file is not writable + - Thanks to Ken Guest for the patch +- Setting and removing config values now prints a message to confirm the action and show old values +- You can now get PHP_CodeSniffer to ignore a single line by putting @codingStandardsIgnoreLine in a comment + - When the comment is found, the comment line and the following line will be ignored + - Thanks to Andy Bulford for the contribution +- Generic ConstructorNameSniff no longer errors for PHP4 style constructors when __construct() is present + - Thanks to Thibaud Fabre for the patch + +### Fixed +- Fixed bug #280 : The --config-show option generates error when there is no config file +- Fixed bug #306 : File containing only a namespace declaration raises undefined index notice +- Fixed bug #308 : Squiz InlineIfDeclarationSniff fails on ternary operators inside closure +- Fixed bug #310 : Variadics not recognized by tokenizer +- Fixed bug #311 : Suppression of function prototype breaks checking of lines within function + +## [2.0.0RC4] - 2014-11-07 +### Changed +- JS tokenizer now detects xor statements correctly +- Improved detection of properties and objects in the JS tokenizer +- Generic ScopeIndentSniff can now fix indents using tabs instead of spaces + - Set the tabIndent property to TRUE in your ruleset.xml file to enable this + - It is important to also set a tab-width setting, either in the ruleset or on the command line, for accuracy +- Generic ScopeIndentSniff now checks and auto-fixes JS files +- Generic DisallowSpaceIndentSniff is now able to replace space indents with tab indents during fixing +- Support for phpcs-only and phpcbf-only attributes has been added to all ruleset.xml elements + - Allows parts of the ruleset to only apply when using a specific tool + - Useful for doing things like excluding indent fixes but still reporting indent errors +- Unit tests can now set command line arguments during a test run + - Override getCliValues() and pass an array of CLI arguments for each file being tested +- File-wide sniff properties can now be set using T_INLINE_HTML content during unit test runs + - Sniffs that start checking at the open tag can only, normally, have properties set using a ruleset +- Generic ConstructorNameSniff no longer errors for PHP4 style constructors when __construct() is present + - Thanks to Thibaud Fabre for the patch +- Generic DocCommentSniff now checks that the end comment tag is on a new line +- Generic MultipleStatementAlignmentSniff no longer skips assignments for closures +- Squiz DocCommentAlignment sniff now has better checking for single line doc block +- Running unit tests with the -v CLI argument no longer generates PHP errors + +### Fixed +- Fixed bug #295 : ScopeIndentSniff hangs when processing nested closures +- Fixed bug #298 : False positive in ScopeIndentSniff when anonymous functions are used with method chaining +- Fixed bug #302 : Fixing code in Squiz InlineComment sniff can remove some comment text +- Fixed bug #303 : Open and close tag on same line can cause a PHP notice checking scope indent +- Fixed bug #306 : File containing only a namespace declaration raises undefined index notice +- Fixed bug #307 : Conditional breaks in case statements get incorrect indentations +- Fixed bug #308 : Squiz InlineIfDeclarationSniff fails on ternary operators inside closure +- Fixed bug #310 : Variadics not recognized by tokenizer + +## [2.0.0RC3] - 2014-10-16 +### Changed +- Improved default output for PHPCBF and removed the options to print verbose and progress output +- If a .fixed file is supplied for a unit test file, the auto fixes will be checked against it during testing + - See Generic ScopeIndentUnitTest.inc and ScopeIndentUnitTest.inc.fixed for an example +- Fixer token replacement methods now return TRUE if the change was accepted and FALSE if rejected +- The --config-show command now pretty-prints the config values + - Thanks to Ken Guest for the patch +- Setting and removing config values now catches exceptions if the config file is not writable + - Thanks to Ken Guest for the patch +- Setting and removing config values now prints a message to confirm the action and show old values +- Generic ScopeIndentSniff has been completely rewritten to improve fixing and embedded PHP detection +- Generic DisallowTabIndent and DisallowSpaceIndent sniffs now detect indents at the start of block comments +- Generic DisallowTabIndent and DisallowSpaceIndent sniffs now detect indents inside multi-line strings +- Generic DisallowTabIndentSniff now replaces tabs inside doc block comments +- Squiz ControlStructureSpacingSniff error codes have been corrected; they were reversed +- Squiz EmbeddedPhpSniff now checks open and close tag indents and fixes some errors +- Squiz FileCommentSniff no longer throws incorrect blank line before comment errors in JS files +- Squiz ClassDeclarationSniff now has better checking for blank lines after a closing brace +- Removed error Squiz.Classes.ClassDeclaration.NoNewlineAfterCloseBrace (request #285) + - Already handled by Squiz.Classes.ClassDeclaration.CloseBraceSameLine + +### Fixed +- Fixed bug #280 : The --config-show option generates error when there is no config file + +## [2.0.0RC2] - 2014-09-26 +### Changed +- Minified JS and CSS files are now detected and skipped (fixes bug #252 and bug #19899) + - A warning will be added to the file so it can be found in the report and ignored in the future +- Fixed incorrect length of JS object operator tokens +- PHP tokenizer no longer converts class/function names to special tokens types + - Class/function names such as parent and true would become special tokens such as T_PARENT and T_TRUE +- PHPCS can now exit with 0 if only warnings were found (request #262) + - Set the ignore_warnings_on_exit config variable to 1 to set this behaviour + - Default remains at exiting with 0 only if no errors and no warnings were found + - Also changes return value of PHP_CodeSniffer_Reporting::printReport() +- Rulesets can now set associative array properties + - property name="[property]" type="array" value="foo=>bar,baz=>qux" +- Generic ForbiddenFunctionsSniff now has a public property called forbiddenFunctions (request #263) + - Override the property in a ruleset.xml file to define forbidden functions and their replacements + - A replacement of NULL indicates that no replacement is available + - e.g., value="delete=>unset,print=>echo,create_function=>null" + - Custom sniffs overriding this one will need to change the visibility of their member var +- Improved closure support in Generic ScopeIndentSniff +- Improved indented PHP tag support in Generic ScopeIndentSniff +- Improved fixing of mixed line indents in Generic ScopeIndentSniff +- Added conflict detection to the file fixer + - If 2 sniffs look to be conflicting, one change will be ignored to allow a fix to occur +- Generic CamelCapsFunctionNameSniff now ignores a single leading underscore + - Thanks to Alex Slobodiskiy for the patch +- Standards can now be located within hidden directories (further fix for bug #20323) + - Thanks to Klaus Purer for the patch +- Sniff ignore patterns now replace Win dir separators like file ignore patterns already did +- Exclude patterns now use backtick delimiters, allowing all special characters to work correctly again + - Thanks to Jeremy Edgell for the patch +- Errors converted to warnings in a ruleset (and vice versa) now retain their fixable status + - Thanks to Alexander Obuhovich for the patch +- Squiz ConcatenationSpacingSniff now has a setting to specify how many spaces there should around concat operators + - Default remains at 0 + - Override the "spacing" setting in a ruleset.xml file to change +- Added auto-fixes for Squiz InlineCommentSniff +- Generic DocCommentSniff now correctly fixes additional blank lines at the end of a comment +- Squiz OperatorBracketSniff now correctly fixes operations that include arrays +- Zend ClosingTagSniff fix now correctly leaves closing tags when followed by HTML +- Added Generic SyntaxSniff to check for syntax errors in PHP files + - Thanks to Blaine Schmeisser for the contribution +- Added Generic OneTraitPerFileSniff to check that only one trait is defined in each file + - Thanks to Alexander Obuhovich for the contribution +- Squiz DiscouragedFunctionsSniff now warns about var_dump() +- PEAR ValidFunctionNameSniff no longer throws an error for _() +- Squiz and PEAR FunctionCommentSniffs now support _() +- Generic DisallowTabIndentSniff now checks for, and fixes, mixed indents again +- Generic UpperCaseConstantSniff and LowerCaseConstantSniff now ignore function names + +### Fixed +- Fixed bug #243 : Missing DocBlock not detected +- Fixed bug #248 : FunctionCommentSniff expects ampersand on param name +- Fixed bug #265 : False positives with type hints in ForbiddenFunctionsSniff +- Fixed bug #20373 : Inline comment sniff tab handling way +- Fixed bug #20377 : Error when trying to execute phpcs with report=json +- Fixed bug #20378 : Report appended to existing file if no errors found in run +- Fixed bug #20381 : Invalid "Comment closer must be on a new line" + - Thanks to Brad Kent for the patch +- Fixed bug #20402 : SVN pre-commit hook fails due to unknown argument error + +## [1.5.5] - 2014-09-25 +### Changed +- PHP tokenizer no longer converts class/function names to special tokens types + - Class/function names such as parent and true would become special tokens such as T_PARENT and T_TRUE +- Improved closure support in Generic ScopeIndentSniff +- Improved indented PHP tag support in Generic ScopeIndentSniff +- Generic CamelCapsFunctionNameSniff now ignores a single leading underscore + - Thanks to Alex Slobodiskiy for the patch +- Standards can now be located within hidden directories (further fix for bug #20323) + - Thanks to Klaus Purer for the patch +- Added Generic SyntaxSniff to check for syntax errors in PHP files + - Thanks to Blaine Schmeisser for the contribution +- Squiz DiscouragedFunctionsSniff now warns about var_dump() +- PEAR ValidFunctionNameSniff no longer throws an error for _() +- Squiz and PEAR FunctionCommentSnif now support _() +- Generic UpperCaseConstantSniff and LowerCaseConstantSniff now ignore function names + +### Fixed +- Fixed bug #248 : FunctionCommentSniff expects ampersand on param name +- Fixed bug #265 : False positives with type hints in ForbiddenFunctionsSniff +- Fixed bug #20373 : Inline comment sniff tab handling way +- Fixed bug #20378 : Report appended to existing file if no errors found in run +- Fixed bug #20381 : Invalid "Comment closer must be on a new line" + - Thanks to Brad Kent for the patch +- Fixed bug #20386 : Squiz.Commenting.ClassComment.SpacingBefore thrown if first block comment + +## [2.0.0RC1] - 2014-08-06 +### Changed +- PHPCBF will now fix incorrect newline characters in a file +- PHPCBF now exists cleanly when there are no errors to fix +- Added phpcbf.bat file for Windows +- Verbose option no longer errors when using a phar file with a space in the path +- Fixed a reporting error when using HHVM + - Thanks to Martins Sipenko for the patch +- addFixableError() and addFixableWarning() now only return true if the fixer is enabled + - Saves checking ($phpcsFile->fixer->enabled === true) before every fix +- Added addErrorOnLine() and addWarningOnLine() to add a non-fixable violation to a line at column 1 + - Useful if you are generating errors using an external tool or parser and only know line numbers + - Thanks to OndÅ™ej Mirtes for the patch +- CSS tokenizer now identifies embedded PHP code using the new T_EMBEDDED_PHP token type + - The entire string of PHP is contained in a single token +- PHP tokenizer contains better detection of short array syntax +- Unit test runner now also test any standards installed under the installed_paths config var +- Exclude patterns now use {} delimiters, allowing the | special character to work correctly again +- The filtering component of the --extensions argument is now ignored again when passing filenames + - Can still be used to specify a custom tokenizer for each extension when passing filenames + - If no tokenizer is specified, default values will be used for common file extensions +- Diff report now produces relative paths on Windows, where possible (further fix for bug #20234) +- If a token's content has been modified by the tab-width setting, it will now have an orig_content in the tokens array +- Generic DisallowSpaceIndent and DisallowTabIndent sniffs now check original indent content even when tab-width is set + - Previously, setting --tab-width would force both to check the indent as spaces +- Fixed a problem where PHPCBF could replace tabs with too many spaces when changing indents +- Fixed a problem that could occur with line numbers when using HHVM to check files with Windows newline characters +- Removed use of sys_get_temp_dir() as this is not supported by the min PHP version +- Squiz ArrayDeclarationSniff now supports short array syntax +- Squiz ControlSignatureSniff no longer uses the Abstract Pattern sniff + - If you are extending this sniff, you'll need to rewrite your code + - The rewrite allows this sniff to fix all control structure formatting issues it finds +- The installed_paths config var now accepts relative paths + - The paths are relative to the PHP_CodeSniffer install directory + - Thanks to Weston Ruter for the patch +- Generic ScopeIndentSniff now accounts for different open tag indents +- PEAR FunctionDeclarationSniff now ignores short arrays when checking indent + - Thanks to Daniel Tschinder for the patch +- PSR2 FunctionCallSignatureSniff now treats multi-line strings as a single-line argument, like arrays and closures + - Thanks to Dawid Nowak for the patch +- PSR2 UseDeclarationSniff now checks for a single space after the USE keyword +- Generic ForbiddenFunctionsSniff now detects calls to functions in the global namespace + - Thanks to Ole Martin Handeland for the patch +- Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore namespaces beginning with TRUE/FALSE/NULL + - Thanks to Renan Gonçalves for the patch +- Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request #20299) +- Squiz SelfMemberReferenceSniff now works correctly with namespaces +- Squiz FunctionCommentSniff is now more relaxed when checking namespaced type hints +- Tab characters are now encoded in abstract pattern errors messages + - Thanks to Blaine Schmeisser for the patch +- Invalid sniff codes passed to --sniffs now show a friendly error message (request #20313) +- Generic LineLengthSniff now shows a warning if the iconv module is disabled (request #20314) +- Source report no longer shows errors if category or sniff names ends in an uppercase error + - Thanks to Jonathan Marcil for the patch + +### Fixed +- Fixed bug #20261 : phpcbf has an endless fixing loop +- Fixed bug #20268 : Incorrect documentation titles in PEAR documentation +- Fixed bug #20296 : new array notion in function comma check fails +- Fixed bug #20297 : phar does not work when renamed it to phpcs +- Fixed bug #20307 : PHP_CodeSniffer_Standards_AbstractVariableSniff analyze traits +- Fixed bug #20308 : Squiz.ValidVariableNameSniff - wrong variable usage +- Fixed bug #20309 : Use "member variable" term in sniff "processMemberVar" method +- Fixed bug #20310 : PSR2 does not check for space after function name +- Fixed bug #20322 : Display rules set to type=error even when suppressing warnings +- Fixed bug #20323 : PHPCS tries to load sniffs from hidden directories +- Fixed bug #20346 : Fixer endless loop with Squiz.CSS sniffs +- Fixed bug #20355 : No sniffs are registered with PHAR on Windows + +## [1.5.4] - 2014-08-06 +### Changed +- Removed use of sys_get_temp_dir() as this is not supported by the min PHP version +- The installed_paths config var now accepts relative paths + - The paths are relative to the PHP_CodeSniffer install directory + - Thanks to Weston Ruter for the patch +- Generic ScopeIndentSniff now accounts for different open tag indents +- PEAR FunctionDeclarationSniff now ignores short arrays when checking indent + - Thanks to Daniel Tschinder for the patch +- PSR2 FunctionCallSignatureSniff now treats multi-line strings as a single-line argument, like arrays and closures + - Thanks to Dawid Nowak for the patch +- Generic ForbiddenFunctionsSniff now detects calls to functions in the global namespace + - Thanks to Ole Martin Handeland for the patch +- Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore namespaces beginning with TRUE/FALSE/NULL + - Thanks to Renan Gonçalves for the patch +- Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request #20299) +- Squiz SelfMemberReferenceSniff now works correctly with namespaces +- Tab characters are now encoded in abstract pattern errors messages + - Thanks to Blaine Schmeisser for the patch +- Invalid sniff codes passed to --sniffs now show a friendly error message (request #20313) +- Generic LineLengthSniff now shows a warning if the iconv module is disabled (request #20314) +- Source report no longer shows errors if category or sniff names ends in an uppercase error + - Thanks to Jonathan Marcil for the patch + +### Fixed +- Fixed bug #20268 : Incorrect documentation titles in PEAR documentation +- Fixed bug #20296 : new array notion in function comma check fails +- Fixed bug #20307 : PHP_CodeSniffer_Standards_AbstractVariableSniff analyze traits +- Fixed bug #20308 : Squiz.ValidVariableNameSniff - wrong variable usage +- Fixed bug #20309 : Use "member variable" term in sniff "processMemberVar" method +- Fixed bug #20310 : PSR2 does not check for space after function name +- Fixed bug #20322 : Display rules set to type=error even when suppressing warnings +- Fixed bug #20323 : PHPCS tries to load sniffs from hidden directories + +## [2.0.0a2] - 2014-05-01 +### Changed +- Added report type --report=info to show information about the checked code to make building a standard easier + - Checks a number of things, such as what line length you use, and spacing are brackets, but not everything + - Still highly experimental +- Generic LineLengthSniff now shows warnings for long lines referring to licence and VCS information + - It previously ignored these lines, but at the expense of performance +- Generic DisallowTabIndent and DisallowSpaceIndent sniffs no longer error when detecting mixed indent types + - Only the first type of indent found on a line (space or indent) is considered +- Lots of little performance improvements that can add up to a substantial saving over large code bases + - Added a "length" array index to tokens so you don't need to call strlen() of them, or deal with encoding + - Can now use isset() to find tokens inside the PHP_CodeSniffer_Tokens static vars instead of in_array() +- Custom reports can now specify a $recordErrors member var; this previously only worked for built-in reports + - When set to FALSE, error messages will not be recorded and only totals will be returned + - This can save significant memory while processing a large code base +- Removed dependence on PHP_Timer +- PHP tokenizer now supports DEFAULT statements opened with a T_SEMICOLON +- The Squiz and PHPCS standards have increased the max padding for statement alignment from 8 to 12 +- Squiz EchoedStringsSniff now supports statements without a semicolon, such as PHP embedded in HTML +- Squiz DoubleQuoteUsageSniff now properly replaces escaped double quotes when fixing a doubled quoted string +- Improved detection of nested IF statements that use the alternate IF/ENDIF syntax +- PSR1 CamelCapsMethodNameSniff now ignores magic methods + - Thanks to Eser Ozvataf for the patch +- PSR1 SideEffectsSniff now ignores methods named define() +- PSR1 and PEAR ClassDeclarationSniffs now support traits (request #20208) +- PSR2 ControlStructureSpacingSniff now allows newlines before/after parentheses + - Thanks to Maurus Cuelenaere for the patch +- PSR2 ControlStructureSpacingSniff now checks TRY and CATCH statements +- Squiz SuperfluousWhitespaceSniff now detects whitespace at the end of block comment lines + - Thanks to Klaus Purer for the patch +- Squiz LowercasePHPFunctionsSniff no longer reports errors for namespaced functions + - Thanks to Max Galbusera for the patch +- Squiz SwitchDeclarationSniff now allows exit() as a breaking statement for case/default +- Squiz ValidVariableNameSniff and Zend ValidVariableNameSniff now ignore additional PHP reserved vars + - Thanks to Mikuláš DítÄ› and Adrian Crepaz for the patch +- Sniff code Squiz.WhiteSpace.MemberVarSpacing.After changed to Squiz.WhiteSpace.MemberVarSpacing.Incorrect (request #20241) + +### Fixed +- Fixed bug #20200 : Invalid JSON produced with specific error message +- Fixed bug #20204 : Ruleset exclude checks are case sensitive +- Fixed bug #20213 : Invalid error, Inline IF must be declared on single line +- Fixed bug #20225 : array_merge() that takes more than one line generates error +- Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting +- Fixed bug #20234 : phpcbf patch command absolute paths +- Fixed bug #20240 : Squiz block comment sniff fails when newline present +- Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while + - Thanks to Alexander Obuhovich for the patch +- Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope +- Fixed bug #20252 : Unitialized string offset when package name starts with underscore + +## [1.5.3] - 2014-05-01 +### Changed +- Improved detection of nested IF statements that use the alternate IF/ENDIF syntax +- PHP tokenizer now supports DEFAULT statements opened with a T_SEMICOLON +- PSR1 CamelCapsMethodNameSniff now ignores magic methods + - Thanks to Eser Ozvataf for the patch +- PSR1 SideEffectsSniff now ignores methods named define() +- PSR1 and PEAR ClassDeclarationSniffs now support traits (request #20208) +- PSR2 ControlStructureSpacingSniff now allows newlines before/after parentheses + - Thanks to Maurus Cuelenaere for the patch +- Squiz LowercasePHPFunctionsSniff no longer reports errors for namespaced functions + - Thanks to Max Galbusera for the patch +- Squiz SwitchDeclarationSniff now allows exit() as a breaking statement for case/default +- Squiz ValidVariableNameSniff and Zend ValidVariableNameSniff now ignore additional PHP reserved vars + - Thanks to Mikuláš DítÄ› and Adrian Crepaz for the patch +- Sniff code Squiz.WhiteSpace.MemberVarSpacing.After changed to Squiz.WhiteSpace.MemberVarSpacing.Incorrect (request #20241) + +### Fixed +- Fixed bug #20200 : Invalid JSON produced with specific error message +- Fixed bug #20204 : Ruleset exclude checks are case sensitive +- Fixed bug #20213 : Invalid error, Inline IF must be declared on single line +- Fixed bug #20225 : array_merge() that takes more than one line generates error +- Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting +- Fixed bug #20240 : Squiz block comment sniff fails when newline present +- Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while + - Thanks to Alexander Obuhovich for the patch +- Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope +- Fixed bug #20252 : Uninitialized string offset when package name starts with underscore + +## [2.0.0a1] - 2014-02-05 +### Changed +- Added the phpcbf script to automatically fix many errors found by the phpcs script +- Added report type --report=diff to show suggested changes to fix coding standard violations +- The --report argument now allows for custom reports to be used + - Use the full path to your custom report class as the report name +- The --extensions argument is now respected when passing filenames; not just with directories +- The --extensions argument now allows you to specify the tokenizer for each extension + - e.g., --extensions=module/php,es/js +- Command line arguments can now be set in ruleset files + - e.g., arg name="report" value="summary" (print summary report; same as --report=summary) + - e.g., arg value="sp" (print source and progress information; same as -sp) + - The -vvv, --sniffs, --standard and -l command line arguments cannot be set in this way +- Sniff process() methods can not optionally return a token to ignore up to + - If returned, the sniff will not be executed again until the passed token is reached in the file + - Useful if you are looking for tokens like T_OPEN_TAG but only want to process the first one +- Removed the comment parser classes and replaced it with a simple comment tokenizer + - T_DOC_COMMENT tokens are now tokenized into T_DOC_COMMENT_* tokens so they can be used more easily + - This change requires a significant rewrite of sniffs that use the comment parser + - This change requires minor changes to sniffs that listen for T_DOC_COMMENT tokens directly +- Added Generic DocCommentSniff to check generic doc block formatting + - Removed doc block formatting checks from PEAR ClassCommentSniff + - Removed doc block formatting checks from PEAR FileCommentSniff + - Removed doc block formatting checks from PEAR FunctionCommentSniff + - Removed doc block formatting checks from Squiz ClassCommentSniff + - Removed doc block formatting checks from Squiz FileCommentSniff + - Removed doc block formatting checks from Squiz FunctionCommentSniff + - Removed doc block formatting checks from Squiz VariableCommentSniff +- Squiz DocCommentAlignmentSniff has had its error codes changed + - NoSpaceBeforeTag becomes NoSpaceAfterStar + - SpaceBeforeTag becomes SpaceAfterStar + - SpaceBeforeAsterisk becomes SpaceBeforeStar +- Generic MultipleStatementAlignment now aligns assignments within a block so they fit within their max padding setting + - The sniff previously requested the padding as 1 space if max padding was exceeded + - It now aligns the assignment with surrounding assignments if it can + - Removed property ignoreMultiline as multi-line assignments are now handled correctly and should not be ignored +- Squiz FunctionClosingBraceSpaceSniff now requires a blank line before the brace in all cases except function args +- Added error Squiz.Commenting.ClassComment.SpacingAfter to ensure there are no blank lines after a class comment +- Added error Squiz.WhiteSpace.MemberVarSpacing.AfterComment to ensure there are no blank lines after a member var comment + - Fixes have also been corrected to not strip the member var comment or indent under some circumstances + - Thanks to Mark Scherer for help with this fix +- Added error Squiz.Commenting.FunctionCommentThrowTag.Missing to ensure a throw is documented +- Removed error Squiz.Commenting.FunctionCommentThrowTag.WrongType +- Content passed via STDIN can now specify the filename to use so that sniffs can run the correct filename checks + - Ensure the first line of the content is: phpcs_input_file: /path/to/file +- Squiz coding standard now enforces no closing PHP tag at the end of a pure PHP file +- Squiz coding standard now enforces a single newline character at the end of the file +- Squiz ClassDeclarationSniff no longer checks for a PHP ending tag after a class definition +- Squiz ControlStructureSpacingSniff now checks TRY and CATCH statements as well +- Removed MySource ChannelExceptionSniff + +## [1.5.2] - 2014-02-05 +### Changed +- Improved support for the PHP 5.5. classname::class syntax + - PSR2 SwitchDeclarationSniff no longer throws errors when this syntax is used in CASE conditions +- Improved support for negative checks of instanceOf in Squiz ComparisonOperatorUsageSniff + - Thanks to Martin Winkel for the patch +- Generic FunctionCallArgumentSpacingSniff now longer complains about space before comma when using here/nowdocs + - Thanks to Richard van Velzen for the patch +- Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore class constants + - Thanks to Kristopher Wilson for the patch +- PEAR FunctionCallSignatureSniff now has settings to specify how many spaces should appear before/after parentheses + - Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change + - Default remains at 0 for both + - Thanks to Astinus Eberhard for the patch +- PSR2 ControlStructureSpacingSniff now has settings to specify how many spaces should appear before/after parentheses + - Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change + - Default remains at 0 for both + - Thanks to Astinus Eberhard for the patch +- Squiz ForEachLoopDeclarationSniff now has settings to specify how many spaces should appear before/after parentheses + - Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change + - Default remains at 0 for both + - Thanks to Astinus Eberhard for the patch +- Squiz ForLoopDeclarationSniff now has settings to specify how many spaces should appear before/after parentheses + - Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change + - Default remains at 0 for both + - Thanks to Astinus Eberhard for the patch +- Squiz FunctionDeclarationArgumentSpacingSniff now has settings to specify how many spaces should appear before/after parentheses + - Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change + - Default remains at 0 for both + - Thanks to Astinus Eberhard for the patch +- Removed UnusedFunctionParameter, CyclomaticComplexity and NestingLevel from the Squiz standard +- Generic FixmeSniff and TodoSniff now work correctly with accented characters + +### Fixed +- Fixed bug #20145 : Custom ruleset preferences directory over installed standard +- Fixed bug #20147 : phpcs-svn-pre-commit - no more default error report +- Fixed bug #20151 : Problem handling "if(): ... else: ... endif;" syntax +- Fixed bug #20190 : Invalid regex in Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff + +## [1.5.1] - 2013-12-12 +### Changed +- Config values can now be set at runtime using the command line argument [--runtime-set key value] + - Runtime values are the same as config values, but are not written to the main config file + - Thanks to Wim Godden for the patch +- Config values can now be set in ruleset files + - e.g., config name="zend_ca_path" value="/path/to/ZendCodeAnalyzer" + - Can not be used to set config values that override command line values, such as show_warnings + - Thanks to Jonathan Marcil for helping with the patch +- Added a new installed_paths config value to allow for the setting of directories that contain standards + - By default, standards have to be installed into the CodeSniffer/Standards directory to be considered installed + - New config value allows a list of paths to be set in addition to this internal path + - Installed standards appear when using the -i arg, and can be referenced in rulesets using only their name + - Set paths by running: phpcs --config-set installed_paths /path/one,/path/two,... +- PSR2 ClassDeclarationSniff now allows a list of extended interfaces to be split across multiple lines +- Squiz DoubleQuoteUsageSniff now allows \b in double quoted strings +- Generic ForbiddenFunctionsSniff now ignores object creation + - This is a further fix for bug #20100 : incorrect Function mysql() has been deprecated report + +### Fixed +- Fixed bug #20136 : Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff and Traits +- Fixed bug #20138 : Protected property underscore and camel caps issue (in trait with Zend) + - Thanks to Gaetan Rousseau for the patch +- Fixed bug #20139 : No report file generated on success + +## [1.5.0] - 2013-11-28 +### Changed +- Doc generation is now working again for installed standards + - Includes a fix for limiting the docs to specific sniffs +- Generic ScopeIndentSniff now allows for ignored tokens to be set via ruleset.xml files + - E.g., to ignore comments, override a property using: + - name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT" +- PSR2 standard now ignores comments when checking indentation rules +- Generic UpperCaseConstantNameSniff no longer reports errors where constants are used (request #20090) + - It still reports errors where constants are defined +- Individual messages can now be excluded in ruleset.xml files using the exclude tag (request #20091) + - Setting message severity to 0 continues to be supported +- Squiz OperatorSpacingSniff no longer throws errors for the ?: short ternary operator + - Thanks to Antoine Musso for the patch +- Comment parser now supports non-English characters when splitting comment lines into words + - Thanks to Nik Sun for the patch +- Exit statements are now recognised as valid closers for CASE and DEFAULT blocks + - Thanks to Maksim Kochkin for the patch +- PHP_CodeSniffer_CLI::process() can now be passed an incomplete array of CLI values + - Missing values will be set to the CLI defaults + - Thanks to Maksim Kochkin for the patch + +### Fixed +- Fixed bug #20093 : Bug with ternary operator token +- Fixed bug #20097 : CLI.php throws error in php 5.2 +- Fixed bug #20100 : incorrect Function mysql() has been deprecated report +- Fixed bug #20119 : PHP warning: invalid argument to str_repeat() in SVN blame report with -s +- Fixed bug #20123 : PSR2 complains about an empty second statement in for-loop +- Fixed bug #20131 : PHP errors in svnblame report, if there are files not under version control +- Fixed bug #20133 : Allow "HG: hg_id" as value for @version tag + +## [1.4.8] - 2013-11-26 +### Changed +- Generic ScopeIndentSniff now allows for ignored tokens to be set via ruleset.xml files + - E.g., to ignore comments, override a property using: + - name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT" +- PSR2 standard now ignores comments when checking indentation rules +- Squiz OperatorSpacingSniff no longer throws errors for the ?: short ternary operator + - Thanks to Antoine Musso for the patch +- Comment parser now supports non-English characters when splitting comment lines into words + - Thanks to Nik Sun for the patch +- Exit statements are now recognised as valid closers for CASE and DEFAULT blocks + - Thanks to Maksim Kochkin for the patch +- PHP_CodeSniffer_CLI::process() can now be passed an incomplete array of CLI values + - Missing values will be set to the CLI defaults + - Thanks to Maksim Kochkin for the patch + +### Fixed +- Fixed bug #20097 : CLI.php throws error in php 5.2 +- Fixed bug #20100 : incorrect Function mysql() has been deprecated report +- Fixed bug #20119 : PHP warning: invalid argument to str_repeat() in SVN blame report with -s +- Fixed bug #20123 : PSR2 complains about an empty second statement in for-loop +- Fixed bug #20131 : PHP errors in svnblame report, if there are files not under version control +- Fixed bug #20133 : Allow "HG: hg_id" as value for @version tag + +## [1.5.0RC4] - 2013-09-26 +### Changed +- You can now restrict violations to individual sniff codes using the --sniffs command line argument + - Previously, this only restricted violations to an entire sniff and not individual messages + - If you have scripts calling PHP_CodeSniffer::process() or creating PHP_CodeSniffer_File objects, you must update your code + - The array of restrictions passed to PHP_CodeSniffer::process() must now be an array of sniff codes instead of class names + - The PHP_CodeSniffer_File::__construct() method now requires an array of restrictions to be passed +- Doc generation is now working again +- Progress information now shows the percentage complete at the end of each line +- Added report type --report=junit to show the error list in a JUnit compatible format + - Thanks to Oleg Lobach for the contribution +- Added support for the PHP 5.4 callable type hint +- Fixed problem where some file content could be ignored when checking STDIN +- Version information is now printed when installed via composer or run from a Git clone (request #20050) +- Added Squiz DisallowBooleanStatementSniff to ban boolean operators outside of control structure conditions +- The CSS tokenizer is now more reliable when encountering 'list' and 'break' strings +- Coding standard ignore comments can now appear instead doc blocks as well as inline comments + - Thanks to Stuart Langley for the patch +- Generic LineLengthSniff now ignores SVN URL and Head URL comments + - Thanks to Karl DeBisschop for the patch +- PEAR MultiLineConditionSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change + - Thanks to Szabolcs Sulik for the patch +- PEAR MultiLineAssignmentSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change + - Thanks to Szabolcs Sulik for the patch +- PEAR FunctionDeclarationSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change + - Thanks to Szabolcs Sulik for the patch +- Squiz SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change + - Thanks to Szabolcs Sulik for the patch +- Squiz CSS IndentationSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change + - Thanks to Hugo Fonseca for the patch +- Squiz and MySource File and Function comment sniffs now allow all tags and don't require a particular licence +- Squiz standard now allows lines to be 120 characters long before warning; up from 85 +- Squiz LowercaseStyleDefinitionSniff no longer throws errors for class names in nested style definitions +- Squiz ClassFileNameSniff no longer throws errors when checking STDIN +- Squiz CSS sniffs no longer generate errors for IE filters +- Squiz CSS IndentationSniff no longer sees comments as blank lines +- Squiz LogicalOperatorSpacingSniff now ignores whitespace at the end of a line +- Squiz.Scope.MethodScope.Missing error message now mentions 'visibility' instead of 'scope modifier' + - Thanks to Renat Akhmedyanov for the patch +- Added support for the PSR2 multi-line arguments errata +- The PSR2 standard no longer throws errors for additional spacing after a type hint +- PSR UseDeclarationSniff no longer throws errors for USE statements inside TRAITs + +### Fixed +- Fixed cases where code was incorrectly assigned the T_GOTO_LABEL token when used in a complex CASE condition +- Fixed bug #20026 : Check for multi-line arrays that should be single-line is slightly wrong + - Adds new error message for single-line arrays that end with a comma +- Fixed bug #20029 : ForbiddenFunction sniff incorrectly recognizes methods in USE clauses +- Fixed bug #20043 : Mis-interpretation of Foo::class +- Fixed bug #20044 : PSR1 camelCase check does not ignore leading underscores +- Fixed bug #20045 : Errors about indentation for closures with multi-line 'use' in functions +- Fixed bug #20051 : Undefined index: scope_opener / scope_closer + - Thanks to Anthon Pang for the patch + +## [1.4.7] - 2013-09-26 +### Changed +- Added report type --report=junit to show the error list in a JUnit compatible format + - Thanks to Oleg Lobach for the contribution +- Added support for the PHP 5.4 callable type hint +- Fixed problem where some file content could be ignored when checking STDIN +- Version information is now printed when installed via composer or run from a Git clone (request #20050) +- The CSS tokenizer is now more reliable when encountering 'list' and 'break' strings +- Coding standard ignore comments can now appear instead doc blocks as well as inline comments + - Thanks to Stuart Langley for the patch +- Generic LineLengthSniff now ignores SVN URL and Head URL comments + - Thanks to Karl DeBisschop for the patch +- PEAR MultiLineConditionSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change + - Thanks to Szabolcs Sulik for the patch +- PEAR MultiLineAssignmentSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change + - Thanks to Szabolcs Sulik for the patch +- PEAR FunctionDeclarationSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change + - Thanks to Szabolcs Sulik for the patch +- Squiz SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change + - Thanks to Szabolcs Sulik for the patch +- Squiz CSS IndentationSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change + - Thanks to Hugo Fonseca for the patch +- Squiz and MySource File and Function comment sniffs now allow all tags and don't require a particular licence +- Squiz LowercaseStyleDefinitionSniff no longer throws errors for class names in nested style definitions +- Squiz ClassFileNameSniff no longer throws errors when checking STDIN +- Squiz CSS sniffs no longer generate errors for IE filters +- Squiz CSS IndentationSniff no longer sees comments as blank lines +- Squiz LogicalOperatorSpacingSniff now ignores whitespace at the end of a line +- Squiz.Scope.MethodScope.Missing error message now mentions 'visibility' instead of 'scope modifier' + - Thanks to Renat Akhmedyanov for the patch +- Added support for the PSR2 multi-line arguments errata +- The PSR2 standard no longer throws errors for additional spacing after a type hint +- PSR UseDeclarationSniff no longer throws errors for USE statements inside TRAITs + +### Fixed +- Fixed bug #20026 : Check for multi-line arrays that should be single-line is slightly wrong + - Adds new error message for single-line arrays that end with a comma +- Fixed bug #20029 : ForbiddenFunction sniff incorrectly recognizes methods in USE clauses +- Fixed bug #20043 : Mis-interpretation of Foo::class +- Fixed bug #20044 : PSR1 camelCase check does not ignore leading underscores +- Fixed bug #20045 : Errors about indentation for closures with multi-line 'use' in functions + +## [1.5.0RC3] - 2013-07-25 +### Changed +- Added report type --report=json to show the error list and total counts for all checked files + - Thanks to Jeffrey Fisher for the contribution +- PHP_CodeSniffer::isCamelCaps now allows for acronyms at the start of a string if the strict flag is FALSE + - acronyms are defined as at least 2 uppercase characters in a row + - e.g., the following is now valid camel caps with strict set to FALSE: XMLParser +- The PHP tokenizer now tokenizes goto labels as T_GOTO_LABEL instead of T_STRING followed by T_COLON +- The JS tokenizer now has support for the T_THROW token +- Symlinked directories inside CodeSniffer/Standards and in ruleset.xml files are now supported + - Only available since PHP 5.2.11 and 5.3.1 + - Thanks to Maik Penz for the patch +- The JS tokenizer now correctly identifies T_INLINE_ELSE tokens instead of leaving them as T_COLON + - Thanks to Arnout Boks for the patch +- Explaining a standard (phpcs -e) that uses namespaces now works correctly +- Restricting a check to specific sniffs (phpcs --sniffs=...) now works correctly with namespaced sniffs + - Thanks to Maik Penz for the patch +- Docs added for the entire Generic standard, and many sniffs from other standards are now documented as well + - Thanks to Spencer Rinehart for the contribution +- Clearer error message for when the sniff class name does not match the directory structure +- Generated HTML docs now correctly show the open PHP tag in code comparison blocks +- Added Generic InlineHTMLSniff to ensure a file only contains PHP code +- Added Squiz ShorthandSizeSniff to check that CSS sizes are using shorthand notation only when 1 or 2 values are used +- Added Squiz ForbiddenStylesSniff to ban the use of some deprecated browser-specific styles +- Added Squiz NamedColoursSniff to ban the use of colour names +- PSR2 standard no longer enforces no whitespace between the closing parenthesis of a function call and the semicolon +- PSR2 ClassDeclarationSniff now ignores empty classes when checking the end brace position +- PSR2 SwitchDeclarationSniff no longer reports errors for empty lines between CASE statements +- PEAR ObjectOperatorIndentSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the indent setting in a ruleset.xml file to change + - Thanks to Andrey Mindubaev for the patch +- Squiz FileExtensionSniff now supports traits + - Thanks to Lucas Green for the patch +- Squiz ArrayDeclarationSniff no longer reports errors for no comma at the end of a line that contains a function call +- Squiz SwitchDeclarationSniff now supports T_CONTINUE and T_THROW as valid case/default breaking statements +- Squiz CommentedOutCodeSniff is now better at ignoring commented out HTML, XML and regular expressions +- Squiz DisallowComparisonAssignmentSniff no longer throws errors for the third expression in a FOR statement +- Squiz ColourDefinitionSniff no longer throws errors for some CSS class names +- Squiz ControlStructureSpacingSniff now supports all types of CASE/DEFAULT breaking statements +- Generic CallTimePassByReferenceSniff now reports errors for functions called using a variable + - Thanks to Maik Penz for the patch +- Generic ConstructorNameSniff no longer throws a notice for abstract constructors inside abstract classes + - Thanks to Spencer Rinehart for the patch +- Squiz ComparisonOperatorUsageSniff now checks inside elseif statements + - Thanks to Arnout Boks for the patch +- Squiz OperatorSpacingSniff now reports errors for no spacing around inline then and else tokens + - Thanks to Arnout Boks for the patch + +### Fixed +- Fixed bug #19811 : Comments not ignored in all cases in AbstractPatternSniff + - Thanks to Erik Wiffin for the patch +- Fixed bug #19892 : ELSE with no braces causes incorrect SWITCH break statement indentation error +- Fixed bug #19897 : Indenting warnings in templates not consistent +- Fixed bug #19908 : PEAR MultiLineCondition Does Not Apply elseif +- Fixed bug #19930 : option --report-file generate an empty file +- Fixed bug #19935 : notify-send reports do not vanish in gnome-shell + - Thanks to Christian Weiske for the patch +- Fixed bug #19944 : docblock squiz sniff "return void" trips over return in lambda function +- Fixed bug #19953 : PSR2 - Spaces before interface name for abstract class +- Fixed bug #19956 : phpcs warns for Type Hint missing Resource +- Fixed bug #19957 : Does not understand trait method aliasing +- Fixed bug #19968 : Permission denied on excluded directory +- Fixed bug #19969 : Sniffs with namespace not recognized in reports +- Fixed bug #19997 : Class names incorrectly detected as constants + +## [1.4.6] - 2013-07-25 +### Changed +- Added report type --report=json to show the error list and total counts for all checked files + - Thanks to Jeffrey Fisher for the contribution +- The JS tokenizer now has support for the T_THROW token +- Symlinked directories inside CodeSniffer/Standards and in ruleset.xml files are now supported + - Only available since PHP 5.2.11 and 5.3.1 + - Thanks to Maik Penz for the patch +- The JS tokenizer now correctly identifies T_INLINE_ELSE tokens instead of leaving them as T_COLON + - Thanks to Arnout Boks for the patch +- Explaining a standard (phpcs -e) that uses namespaces now works correctly +- Restricting a check to specific sniffs (phpcs --sniffs=...) now works correctly with namespaced sniffs + - Thanks to Maik Penz for the patch +- Docs added for the entire Generic standard, and many sniffs from other standards are now documented as well + - Thanks to Spencer Rinehart for the contribution +- Clearer error message for when the sniff class name does not match the directory structure +- Generated HTML docs now correctly show the open PHP tag in code comparison blocks +- Added Generic InlineHTMLSniff to ensure a file only contains PHP code +- Added Squiz ShorthandSizeSniff to check that CSS sizes are using shorthand notation only when 1 or 2 values are used +- Added Squiz ForbiddenStylesSniff to ban the use of some deprecated browser-specific styles +- Added Squiz NamedColoursSniff to ban the use of colour names +- PSR2 standard no longer enforces no whitespace between the closing parenthesis of a function call and the semicolon +- PSR2 ClassDeclarationSniff now ignores empty classes when checking the end brace position +- PSR2 SwitchDeclarationSniff no longer reports errors for empty lines between CASE statements +- PEAR ObjectOperatorIndentSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the indent setting in a ruleset.xml file to change + - Thanks to Andrey Mindubaev for the patch +- Squiz FileExtensionSniff now supports traits + - Thanks to Lucas Green for the patch +- Squiz ArrayDeclarationSniff no longer reports errors for no comma at the end of a line that contains a function call +- Squiz SwitchDeclarationSniff now supports T_CONTINUE and T_THROW as valid case/default breaking statements +- Squiz CommentedOutCodeSniff is now better at ignoring commented out HTML, XML and regular expressions +- Squiz DisallowComparisonAssignmentSniff no longer throws errors for the third expression in a FOR statement +- Squiz ColourDefinitionSniff no longer throws errors for some CSS class names +- Squiz ControlStructureSpacingSniff now supports all types of CASE/DEFAULT breaking statements +- Generic CallTimePassByReferenceSniff now reports errors for functions called using a variable + - Thanks to Maik Penz for the patch +- Generic ConstructorNameSniff no longer throws a notice for abstract constructors inside abstract classes + - Thanks to Spencer Rinehart for the patch +- Squiz ComparisonOperatorUsageSniff now checks inside elseif statements + - Thanks to Arnout Boks for the patch +- Squiz OperatorSpacingSniff now reports errors for no spacing around inline then and else tokens + - Thanks to Arnout Boks for the patch + +### Fixed +- Fixed bug #19811 : Comments not ignored in all cases in AbstractPatternSniff + - Thanks to Erik Wiffin for the patch +- Fixed bug #19892 : ELSE with no braces causes incorrect SWITCH break statement indentation error +- Fixed bug #19897 : Indenting warnings in templates not consistent +- Fixed bug #19908 : PEAR MultiLineCondition Does Not Apply elseif +- Fixed bug #19913 : Running phpcs in interactive mode causes warnings + - Thanks to Harald Franndorfer for the patch +- Fixed bug #19935 : notify-send reports do not vanish in gnome-shell + - Thanks to Christian Weiske for the patch +- Fixed bug #19944 : docblock squiz sniff "return void" trips over return in lambda function +- Fixed bug #19953 : PSR2 - Spaces before interface name for abstract class +- Fixed bug #19956 : phpcs warns for Type Hint missing Resource +- Fixed bug #19957 : Does not understand trait method aliasing +- Fixed bug #19968 : Permission denied on excluded directory +- Fixed bug #19969 : Sniffs with namespace not recognized in reports +- Fixed bug #19997 : Class names incorrectly detected as constants + +## [1.5.0RC2] - 2013-04-04 +### Changed +- Ruleset processing has been rewritten to be more predictable + - Provides much better support for relative paths inside ruleset files + - May mean that sniffs that were previously ignored are now being included when importing external rulesets + - Ruleset processing output can be seen by using the -vv command line argument + - Internal sniff registering functions have all changed, so please review custom scripts +- You can now pass multiple coding standards on the command line, comma separated (request #19144) + - Works with built-in or custom standards and rulesets, or a mix of both +- You can now exclude directories or whole standards in a ruleset XML file (request #19731) + - e.g., exclude "Generic.Commenting" or just "Generic" + - You can also pass in a path to a directory instead, if you know it +- Added Generic LowerCaseKeywordSniff to ensure all PHP keywords are defined in lowercase + - The PSR2 and Squiz standards now use this sniff +- Added Generic SAPIUsageSniff to ensure the PHP_SAPI constant is used instead of php_sapi_name() (request #19863) +- Squiz FunctionSpacingSniff now has a setting to specify how many lines there should between functions (request #19843) + - Default remains at 2 + - Override the "spacing" setting in a ruleset.xml file to change +- Squiz LowercasePHPFunctionSniff no longer throws errors for the limited set of PHP keywords it was checking + - Add a rule for Generic.PHP.LowerCaseKeyword to your ruleset to replicate this functionality +- Added support for the PHP 5.4 T_CALLABLE token so it can be used in lower PHP versions +- Generic EndFileNoNewlineSniff now supports checking of CSS and JS files +- PSR2 SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the indent setting in a ruleset.xml file to change + - Thanks to Asher Snyder for the patch +- Generic ScopeIndentSniff now has a setting to specify a list of tokens that should be ignored + - The first token on the line is checked and the whole line is ignored if the token is in the array + - Thanks to Eloy Lafuente for the patch +- Squiz LowercaseClassKeywordsSniff now checks for the TRAIT keyword + - Thanks to Anthon Pang for the patch +- If you create your own PHP_CodeSniffer object, PHPCS will no longer exit when an unknown argument is found + - This allows you to create wrapper scripts for PHPCS more easily +- PSR2 MethodDeclarationSniff no longer generates a notice for methods named "_" + - Thanks to Bart S for the patch +- Squiz BlockCommentSniff no longer reports that a blank line between a scope closer and block comment is invalid +- Generic DuplicateClassNameSniff no longer reports an invalid error if multiple PHP open tags exist in a file +- Generic DuplicateClassNameSniff no longer reports duplicate errors if multiple PHP open tags exist in a file + +### Fixed +- Fixed bug #19819 : Freeze with syntax error in use statement +- Fixed bug #19820 : Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff +- Fixed bug #19859 : CodeSniffer::setIgnorePatterns API changed +- Fixed bug #19871 : findExtendedClassName doesn't return FQCN on namespaced classes +- Fixed bug #19879 : bitwise and operator interpreted as reference by value + +## [1.4.5] - 2013-04-04 +### Changed +- Added Generic LowerCaseKeywordSniff to ensure all PHP keywords are defined in lowercase + - The PSR2 and Squiz standards now use this sniff +- Added Generic SAPIUsageSniff to ensure the PHP_SAPI constant is used instead of php_sapi_name() (request #19863) +- Squiz FunctionSpacingSniff now has a setting to specify how many lines there should between functions (request #19843) + - Default remains at 2 + - Override the "spacing" setting in a ruleset.xml file to change +- Squiz LowercasePHPFunctionSniff no longer throws errors for the limited set of PHP keywords it was checking + - Add a rule for Generic.PHP.LowerCaseKeyword to your ruleset to replicate this functionality +- Added support for the PHP 5.4 T_CALLABLE token so it can be used in lower PHP versions +- Generic EndFileNoNewlineSniff now supports checking of CSS and JS files +- PSR2 SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented + - Default remains at 4; override the indent setting in a ruleset.xml file to change + - Thanks to Asher Snyder for the patch +- Generic ScopeIndentSniff now has a setting to specify a list of tokens that should be ignored + - The first token on the line is checked and the whole line is ignored if the token is in the array + - Thanks to Eloy Lafuente for the patch +- Squiz LowercaseClassKeywordsSniff now checks for the TRAIT keyword + - Thanks to Anthon Pang for the patch +- If you create your own PHP_CodeSniffer object, PHPCS will no longer exit when an unknown argument is found + - This allows you to create wrapper scripts for PHPCS more easily +- PSR2 MethodDeclarationSniff no longer generates a notice for methods named "_" + - Thanks to Bart S for the patch +- Squiz BlockCommentSniff no longer reports that a blank line between a scope closer and block comment is invalid +- Generic DuplicateClassNameSniff no longer reports an invalid error if multiple PHP open tags exist in a file +- Generic DuplicateClassNameSniff no longer reports duplicate errors if multiple PHP open tags exist in a file + +### Fixed +- Fixed bug #19819 : Freeze with syntax error in use statement +- Fixed bug #19820 : Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff +- Fixed bug #19859 : CodeSniffer::setIgnorePatterns API changed +- Fixed bug #19871 : findExtendedClassName doesn't return FQCN on namespaced classes +- Fixed bug #19879 : bitwise and operator interpreted as reference by value + +## [1.5.0RC1] - 2013-02-08 +### Changed +- Reports have been completely rewritten to consume far less memory + - Each report is incrementally written to the file system during a run and then printed out when the run ends + - There is no longer a need to keep the list of errors and warnings in memory during a run +- Multi-file sniff support has been removed because they are too memory intensive + - If you have a custom multi-file sniff, you can convert it into a standard sniff quite easily + - See CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php for an example + +## [1.4.4] - 2013-02-07 +### Changed +- Ignored lines no longer cause the summary report to show incorrect error and warning counts + - Thanks to Bert Van Hauwaert for the patch +- Added Generic CSSLintSniff to run CSSLint over a CSS file and report warnings + - Set full command to run CSSLint using phpcs --config-set csslint_path /path/to/csslint + - Thanks to Roman Levishchenko for the contribution +- Added PSR2 ControlStructureSpacingSniff to ensure there are no spaces before and after parenthesis in control structures + - Fixes bug #19732 : PSR2: some control structures errors not reported +- Squiz commenting sniffs now support non-English characters when checking for capital letters + - Thanks to Roman Levishchenko for the patch +- Generic EndFileNewlineSniff now supports JS and CSS files + - Thanks to Denis Ryabkov for the patch +- PSR1 SideEffectsSniff no longer reports constant declarations as side effects +- Notifysend report now supports notify-send versions before 0.7.3 + - Thanks to Ken Guest for the patch +- PEAR and Squiz FunctionCommentSniffs no longer report errors for misaligned argument comments when they are blank + - Thanks to Thomas Peterson for the patch +- Squiz FunctionDeclarationArgumentSpacingSniff now works correctly for equalsSpacing values greater than 0 + - Thanks to Klaus Purer for the patch +- Squiz SuperfluousWhitespaceSniff no longer throws errors for CSS files with no newline at the end +- Squiz SuperfluousWhitespaceSniff now allows a single newline at the end of JS and CSS files + +### Fixed +- Fixed bug #19755 : Token of T_CLASS type has no scope_opener and scope_closer keys +- Fixed bug #19759 : Squiz.PHP.NonExecutableCode fails for return function()... +- Fixed bug #19763 : Use statements for traits not recognised correctly for PSR2 code style +- Fixed bug #19764 : Instead of for traits throws uppercase constant name errors +- Fixed bug #19772 : PSR2_Sniffs_Namespaces_UseDeclarationSniff does not properly recognize last use +- Fixed bug #19775 : False positive in NonExecutableCode sniff when not using curly braces +- Fixed bug #19782 : Invalid found size functions in loop when using object operator +- Fixed bug #19799 : config folder is not created automatically +- Fixed bug #19804 : JS Tokenizer wrong /**/ parsing + +## [1.4.3] - 2012-12-04 +### Changed +- Added support for the PHP 5.5 T_FINALLY token to detect try/catch/finally statements +- Added empty CodeSniffer.conf to enable config settings for Composer installs +- Added Generic EndFileNoNewlineSniff to ensure there is no newline at the end of a file +- Autoloader can now load PSR-0 compliant classes + - Thanks to Maik Penz for the patch +- Squiz NonExecutableCodeSniff no longer throws error for multi-line RETURNs inside CASE statements + - Thanks to Marc Ypes for the patch +- Squiz OperatorSpacingSniff no longer reports errors for negative numbers inside inline THEN statements + - Thanks to Klaus Purer for the patch +- Squiz OperatorSpacingSniff no longer reports errors for the assignment of operations involving negative numbers +- Squiz SelfMemberReferenceSniff can no longer get into an infinite loop when checking a static call with a namespace + - Thanks to Andy Grunwald for the patch + +### Fixed +- Fixed bug #19699 : Generic.Files.LineLength giving false positives when tab-width is used +- Fixed bug #19726 : Wrong number of spaces expected after instanceof static +- Fixed bug #19727 : PSR2: no error reported when using } elseif { + +## [1.4.2] - 2012-11-09 +### Changed +- PHP_CodeSniffer can now be installed using Composer + - Require squizlabs/php_codesniffer in your composer.json file + - Thanks to Rob Bast, Stephen Rees-Carter, Stefano Kowalke and Ivan Habunek for help with this +- Squiz BlockCommentSniff and InlineCommentSniff no longer report errors for trait block comments +- Squiz SelfMemberReferenceSniff now supports namespaces + - Thanks to Andy Grunwald for the patch +- Squiz FileCommentSniff now uses tag names inside the error codes for many messages + - This allows you to exclude specific missing, out of order etc., tags +- Squiz SuperfluousWhitespaceSniff now has an option to ignore blank lines + - This will stop errors being reported for lines that contain only whitespace + - Set the ignoreBlankLines property to TRUE in your ruleset.xml file to enable this +- PSR2 no longer reports errors for whitespace at the end of blank lines + +### Fixed +- Fixed gitblame report not working on Windows + - Thanks to Rogerio Prado de Jesus +- Fixed an incorrect error in Squiz OperatorSpacingSniff for default values inside a closure definition +- Fixed bug #19691 : SubversionPropertiesSniff fails to find missing properties + - Thanks to Kevin Winahradsky for the patch +- Fixed bug #19692 : DisallowMultipleAssignments is triggered by a closure +- Fixed bug #19693 : exclude-patterns no longer work on specific messages +- Fixed bug #19694 : Squiz.PHP.LowercasePHPFunctions incorrectly matches return by ref functions + +## [1.4.1] - 2012-11-02 +### Changed +- All ignore patterns have been reverted to being checked against the absolute path of a file + - Patterns can be specified to be relative in a ruleset.xml file, but nowhere else + - e.g., [exclude-pattern type="relative"]^tests/*[/exclude-pattern] (with angle brackets, not square brackets) +- Added support for PHP tokenizing of T_INLINE_ELSE colons, so this token type is now available + - Custom sniffs that rely on looking for T_COLON tokens inside inline if statements must be changed to use the new token + - Fixes bug #19666 : PSR1.Files.SideEffects throws a notice Undefined index: scope_closer +- Messages can now be changed from errors to warnings (and vice versa) inside ruleset.xml files + - As you would with "message" and "severity", specify a "type" tag under a "rule" tag and set the value to "error" or "warning" +- PHP_CodeSniffer will now generate a warning on files that it detects have mixed line endings + - This warning has the code Internal.LineEndings.Mixed and can be overridden in a ruleset.xml file + - Thanks to Vit Brunner for help with this +- Sniffs inside PHP 5.3 namespaces are now supported, along with the existing underscore-style emulated namespaces + - For example: namespace MyStandard\Sniffs\Arrays; class ArrayDeclarationSniff implements \PHP_CodeSniffer_Sniff { ... + - Thanks to Till Klampaeckel for the patch +- Generic DuplicateClassNameSniff is no longer a multi-file sniff, so it won't max out your memory + - Multi-file sniff support should be considered deprecated as standard sniffs can now do the same thing +- Added Generic DisallowSpaceIndent to check that files are indented using tabs +- Added Generic OneClassPerFileSniff to check that only one class is defined in each file + - Thanks to Andy Grunwald for the contribution +- Added Generic OneInterfacePerFileSniff to check that only one interface is defined in each file + - Thanks to Andy Grunwald for the contribution +- Added Generic LowercasedFilenameSniff to check that filenames are lowercase + - Thanks to Andy Grunwald for the contribution +- Added Generic ClosingPHPTagSniff to check that each open PHP tag has a corresponding close tag + - Thanks to Andy Grunwald for the contribution +- Added Generic CharacterBeforePHPOpeningTagSniff to check that the open PHP tag is the first content in a file + - Thanks to Andy Grunwald for the contribution +- Fixed incorrect errors in Squiz OperatorBracketSniff and OperatorSpacingSniff for negative numbers in CASE statements + - Thanks to Arnout Boks for the patch +- Generic CamelCapsFunctionNameSniff no longer enforces exact case matching for PHP magic methods +- Generic CamelCapsFunctionNameSniff no longer throws errors for overridden SOAPClient methods prefixed with double underscores + - Thanks to Dorian Villet for the patch +- PEAR ValidFunctionNameSniff now supports traits +- PSR1 ClassDeclarationSniff no longer throws an error for non-namespaced code if PHP version is less than 5.3.0 + +### Fixed +- Fixed bug #19616 : Nested switches cause false error in PSR2 +- Fixed bug #19629 : PSR2 error for inline comments on multi-line argument lists +- Fixed bug #19644 : Alternative syntax, e.g. if/endif triggers Inline Control Structure error +- Fixed bug #19655 : Closures reporting as multi-line when they are not +- Fixed bug #19675 : Improper indent of nested anonymous function bodies in a call +- Fixed bug #19685 : PSR2 catch-22 with empty third statement in for loop +- Fixed bug #19687 : Anonymous functions inside arrays marked as indented incorrectly in PSR2 + +## [1.4.0] - 2012-09-26 +### Changed +- Added PSR1 and PSR2 coding standards that can be used to check your code against these guidelines +- PHP 5.4 short array syntax is now detected and tokens are assigned to the open and close characters + - New tokens are T_OPEN_SHORT_ARRAY and T_CLOSE_SHORT_ARRAY as PHP does not define its own +- Added the ability to explain a coding standard by listing the sniffs that it includes + - The sniff list includes all imported and native sniffs + - Explain a standard by using the -e and --standard=[standard] command line arguments + - E.g., phpcs -e --standard=Squiz + - Thanks to Ben Selby for the idea +- Added report to show results using notify-send + - Use --report=notifysend to generate the report + - Thanks to Christian Weiske for the contribution +- The JS tokenizer now recognises RETURN as a valid closer for CASE and DEFAULT inside switch statements +- AbstractPatternSniff now sets the ignoreComments option using a public var rather than through the constructor + - This allows the setting to be overwritten in ruleset.xml files + - Old method remains for backwards compatibility +- Generic LowerCaseConstantSniff and UpperCaseConstantSniff no longer report errors on classes named True, False or Null +- PEAR ValidFunctionNameSniff no longer enforces exact case matching for PHP magic methods +- Squiz SwitchDeclarationSniff now allows RETURN statements to close a CASE or DEFAULT statement +- Squiz BlockCommentSniff now correctly reports an error for blank lines before blocks at the start of a control structure + +### Fixed +- Fixed a PHP notice generated when loading custom array settings from a ruleset.xml file +- Fixed bug #17908 : CodeSniffer does not recognise optional @params + - Thanks to Pete Walker for the patch +- Fixed bug #19538 : Function indentation code sniffer checks inside short arrays +- Fixed bug #19565 : Non-Executable Code Sniff Broken for Case Statements with both return and break +- Fixed bug #19612 : Invalid @package suggestion + +## [1.3.6] - 2012-08-08 +### Changed +- Memory usage has been dramatically reduced when using the summary report + - Reduced memory is only available when displaying a single summary report to the screen + - PHP_CodeSniffer will not generate any messages in this case, storing only error counts instead + - Impact is most notable with very high error and warning counts +- Significantly improved the performance of Squiz NonExecutableCodeSniff +- Ignore patterns now check the relative path of a file based on the dir being checked + - Allows ignore patterns to become more generic as the path to the code is no longer included when checking + - Thanks to Kristof Coomans for the patch +- Sniff settings can now be changed by specifying a special comment format inside a file + - e.g., // @codingStandardsChangeSetting PEAR.Functions.FunctionCallSignature allowMultipleArguments false + - If you change a setting, don't forget to change it back +- Added Generic EndFileNewlineSniff to ensure PHP files end with a newline character +- PEAR FunctionCallSignatureSniff now includes a setting to force one argument per line in multi-line calls + - Set allowMultipleArguments to false +- Squiz standard now enforces one argument per line in multi-line function calls +- Squiz FunctionDeclarationArgumentSpacingSniff now supports closures +- Squiz OperatorSpacingSniff no longer throws an error for negative values inside an inline THEN statement + - Thanks to Klaus Purer for the patch +- Squiz FunctionCommentSniff now throws an error for not closing a comment with */ + - Thanks to Klaus Purer for the patch +- Summary report no longer shows two lines of PHP_Timer output when showing sources + +### Fixed +- Fixed undefined variable error in PEAR FunctionCallSignatureSniff for lines with no indent +- Fixed bug #19502 : Generic.Files.LineEndingsSniff fails if no new-lines in file +- Fixed bug #19508 : switch+return: Closing brace indented incorrectly +- Fixed bug #19532 : The PSR-2 standard don't recognize Null in class names +- Fixed bug #19546 : Error thrown for __call() method in traits + +## [1.3.5] - 2012-07-12 +### Changed +- Added Generic CamelCapsFunctionNameSniff to just check if function and method names use camel caps + - Does not allow underscore prefixes for private/protected methods + - Defaults to strict checking, where two uppercase characters can not be next to each other + - Strict checking can be disabled in a ruleset.xml file +- Squiz FunctionDeclarationArgumentSpacing now has a setting to specify how many spaces should surround equals signs + - Default remains at 0 + - Override the equalsSpacing setting in a ruleset.xml file to change +- Squiz ClassDeclarationSniff now throws errors for > 1 space before extends/implements class name with ns separator +- Squiz standard now warns about deprecated functions using Generic DeprecatedFunctionsSniff +- PEAR FunctionDeclarationSniff now reports an error for multiple spaces after the FUNCTION keyword and around USE +- PEAR FunctionDeclarationSniff now supports closures +- Squiz MultiLineFunctionDeclarationSniff now supports closures +- Exclude rules written for Unix systems will now work correctly on Windows + - Thanks to Walter Tamboer for the patch +- The PHP tokenizer now recognises T_RETURN as a valid closer for T_CASE and T_DEFAULT inside switch statements + +### Fixed +- Fixed duplicate message codes in Generic OpeningFunctionBraceKernighanRitchieSniff +- Fixed bug #18651 : PHPunit Test cases for custom standards are not working on Windows +- Fixed bug #19416 : Shorthand arrays cause bracket spacing errors +- Fixed bug #19421 : phpcs doesn't recognize ${x} as equivalent to $x +- Fixed bug #19428 : PHPCS Report "hgblame" doesn't support windows paths + - Thanks to Justin Rovang for the patch +- Fixed bug #19448 : Problem with detecting remote standards +- Fixed bug #19463 : Anonymous functions incorrectly being flagged by NonExecutableCodeSniff +- Fixed bug #19469 : PHP_CodeSniffer_File::getMemberProperties() sets wrong scope +- Fixed bug #19471 : phpcs on Windows, when using Zend standard, doesn't catch problems + - Thanks to Ivan Habunek for the patch +- Fixed bug #19478 : Incorrect indent detection in PEAR standard + - Thanks to Shane Auckland for the patch +- Fixed bug #19483 : Blame Reports fail with space in directory name + +## [1.3.4] - 2012-05-17 +### Changed +- Added missing package.xml entries for new Generic FixmeSniff + - Thanks to Jaroslav Hanslík for the patch +- Expected indents for PEAR ScopeClosingBraceSniff and FunctionCallSignatureSniff can now be set in ruleset files + - Both sniffs use a variable called "indent" + - Thanks to Thomas Despoix for the patch +- Standards designed to be installed in the PHPCS Standards dir will now work outside this dir as well + - In particular, allows the Drupal CS to work without needing to symlink it into the PHPCS install + - Thanks to Peter Philipp for the patch +- Rule references for standards, directories and specific sniffs can now be relative in ruleset.xml files + - For example: ref="../MyStandard/Sniffs/Commenting/DisallowHashCommentsSniff.php" +- Symlinked standards now work correctly, allowing aliasing of installed standards (request #19417) + - Thanks to Tom Klingenberg for the patch +- Squiz ObjectInstantiationSniff now allows objects to be returned without assigning them to a variable +- Added Squiz.Commenting.FileComment.MissingShort error message for file comments that only contains tags + - Also stops undefined index errors being generated for these comments +- Debug option -vv now shows tokenizer status for CSS files +- Added support for new gjslint error formats + - Thanks to Meck for the patch +- Generic ScopeIndentSniff now allows comment indents to not be exact even if the exact flag is set + - The start of the comment is still checked for exact indentation as normal +- Fixed an issue in AbstractPatternSniff where comments were not being ignored in some cases +- Fixed an issue in Zend ClosingTagSniff where the closing tag was not always being detected correctly + - Thanks to Jonathan Robson for the patch +- Fixed an issue in Generic FunctionCallArgumentSpacingSniff where closures could cause incorrect errors +- Fixed an issue in Generic UpperCaseConstantNameSniff where errors were incorrectly reported on goto statements + - Thanks to Tom Klingenberg for the patch +- PEAR FileCommentSniff and ClassCommentSniff now support author emails with a single character in the local part + - E.g., a@me.com + - Thanks to Denis Shapkin for the patch + +### Fixed +- Fixed bug #19290 : Generic indent sniffer fails for anonymous functions +- Fixed bug #19324 : Setting show_warnings configuration option does not work +- Fixed bug #19354 : Not recognizing references passed to method +- Fixed bug #19361 : CSS tokenizer generates errors when PHP embedded in CSS file +- Fixed bug #19374 : HEREDOC/NOWDOC Indentation problems +- Fixed bug #19381 : traits and indentations in traits are not handled properly +- Fixed bug #19394 : Notice in NonExecutableCodeSniff +- Fixed bug #19402 : Syntax error when executing phpcs on Windows with parens in PHP path + - Thanks to Tom Klingenberg for the patch +- Fixed bug #19411 : magic method error on __construct() + - The fix required a rewrite of AbstractScopeSniff, so please test any sniffs that extend this class +- Fixed bug #19412 : Incorrect error about assigning objects to variables when inside inline IF +- Fixed bug #19413 : php_cs thinks I haven't used a parameter when I have +- Fixed bug #19414 : php_cs seems to not track variables correctly in heredocs + +## [1.3.3] - 2012-02-07 +### Changed +- Added new Generic FixmeSniff that shows error messages for all FIXME comments left in your code + - Thanks to Sam Graham for the contribution +- The maxPercentage setting in the Squiz CommentedOutCodeSniff can now be overridden in a ruleset.xml file + - Thanks to Volker Dusch for the patch +- The Checkstyle and XML reports now use XMLWriter + - Only change in output is that empty file tags are no longer produced for files with no violations + - Thanks to Sebastian Bergmann for the patch +- Added PHP_CodeSniffer_Tokens::$bracketTokens to give sniff writers fast access to open and close bracket tokens +- Fixed an issue in AbstractPatternSniff where EOL tokens were not being correctly checked in some cases +- PHP_CodeSniffer_File::getTokensAsString() now detects incorrect length value (request #19313) + +### Fixed +- Fixed bug #19114 : CodeSniffer checks extension even for single file +- Fixed bug #19171 : Show sniff codes option is ignored by some report types + - Thanks to Dominic Scheirlinck for the patch +- Fixed bug #19188 : Lots of PHP Notices when analyzing the Symfony framework + - First issue was list-style.. lines in CSS files not properly adjusting open/close bracket positions + - Second issue was notices caused by bug #19137 +- Fixed bug #19208 : UpperCaseConstantName reports class members + - Was also a problem with LowerCaseConstantName as well +- Fixed bug #19256 : T_DOC_COMMENT in CSS files breaks ClassDefinitionNameSpacingSniff + - Thanks to Klaus Purer for the patch +- Fixed bug #19264 : Squiz.PHP.NonExecutableCode does not handle RETURN in CASE without BREAK +- Fixed bug #19270 : DuplicateClassName does not handle namespaces correctly +- Fixed bug #19283 : CSS @media rules cause false positives + - Thanks to Klaus Purer for the patch + +## [1.3.2] - 2011-12-01 +### Changed +- Added Generic JSHintSniff to run jshint.js over a JS file and report warnings + - Set jshint path using phpcs --config-set jshint_path /path/to/jshint-rhino.js + - Set rhino path using phpcs --config-set rhino_path /path/to/rhino + - Thanks to Alexander Weiß for the contribution +- Nowdocs are now tokenized using PHP_CodeSniffer specific T_NOWDOC tokens for easier identification +- Generic UpperCaseConstantNameSniff no longer throws errors for namespaces + - Thanks to Jaroslav Hanslík for the patch +- Squiz NonExecutableCodeSniff now detects code after thrown exceptions + - Thanks to Jaroslav Hanslík for the patch +- Squiz OperatorSpacingSniff now ignores references + - Thanks to Jaroslav Hanslík for the patch +- Squiz FunctionCommentSniff now reports a missing function comment if it finds a standard code comment instead +- Squiz FunctionCommentThrownTagSniff no longer reports errors if it can't find a function comment + +### Fixed +- Fixed unit tests not running under Windows + - Thanks to Jaroslav Hanslík for the patch +- Fixed bug #18964 : "$stackPtr must be of type T_VARIABLE" on heredocs and nowdocs +- Fixed bug #18973 : phpcs is looking for variables in a nowdoc +- Fixed bug #18974 : Blank line causes "Multi-line function call not indented correctly" + - Adds new error message to ban empty lines in multi-line function calls +- Fixed bug #18975 : "Closing parenthesis must be on a line by itself" also causes indentation error + +## [1.3.1] - 2011-11-03 +### Changed +- All report file command line arguments now work with relative paths (request #17240) +- The extensions command line argument now supports multi-part file extensions (request #17227) +- Added report type --report=hgblame to show number of errors/warnings committed by authors in a Mercurial repository + - Has the same functionality as the svnblame report + - Thanks to Ben Selby for the patch +- Added T_BACKTICK token type to make detection of backticks easier (request #18799) +- Added pattern matching support to Generic ForbiddenFunctionsSniff + - If you are extending it and overriding register() or addError() you will need to review your sniff +- Namespaces are now recognised as scope openers, although they do not require braces (request #18043) +- Added new ByteOrderMarkSniff to Generic standard (request #18194) + - Throws an error if a byte order mark is found in any PHP file + - Thanks to Piotr Karas for the contribution +- PHP_Timer output is no longer included in reports when being written to a file (request #18252) + - Also now shown for all report types if nothing is being printed to the screen +- Generic DeprecatedFunctionSniff now reports functions as deprecated and not simply forbidden (request #18288) +- PHPCS now accepts file contents from STDIN (request #18447) + - Example usage: cat temp.php | phpcs [options] -OR- phpcs [options] < temp.php + - Not every sniff will work correctly due to the lack of a valid file path +- PHP_CodeSniffer_Exception no longer extends PEAR_Exception (request #18483) + - PEAR_Exception added a requirement that PEAR had to be installed + - PHP_CodeSniffer is not used as a library, so unlikely to have any impact +- PEAR FileCommentSniff now allows GIT IDs in the version tag (request #14874) +- AbstractVariableSniff now supports heredocs + - Also includes some variable detection fixes + - Thanks to Sam Graham for the patch +- Squiz FileCommentSniff now enforces rule that package names cannot start with the word Squiz +- MySource AssignThisSniff now allows "this" to be assigned to the private var _self +- PEAR ClassDeclaration sniff now supports indentation checks when using the alternate namespace syntax + - PEAR.Classes.ClassDeclaration.SpaceBeforeBrace message now contains 2 variables instead of 1 + - Sniff allows overriding of the default indent level, which is set to 4 + - Fixes bug #18933 : Alternative namespace declaration syntax confuses scope sniffs + +### Fixed +- Fixed issue in Squiz FileCommentSniff where suggested package name was the same as the incorrect package name +- Fixed some issues with Squiz ArrayDeclarationSniff when using function calls in array values +- Fixed doc generation so it actually works again + - Also now works when being run from an SVN checkout as well as when installed as a PEAR package + - Should fix bug #18949 : Call to private method from static +- Fixed bug #18465 : "self::" does not work in lambda functions + - Also corrects conversion of T_FUNCTION tokens to T_CLOSURE, which was not fixing token condition arrays +- Fixed bug #18543 : CSS Tokenizer deletes too many # +- Fixed bug #18624 : @throws namespace problem + - Thanks to Gavin Davies for the patch +- Fixed bug #18628 : Generic.Files.LineLength gives incorrect results with Windows line-endings +- Fixed bug #18633 : CSS Tokenizer doesn't replace T_LIST tokens inside some styles +- Fixed bug #18657 : anonymous functions wrongly indented +- Fixed bug #18670 : UpperCaseConstantNameSniff fails on dynamic retrieval of class constant +- Fixed bug #18709 : Code sniffer sniffs file if even if it's in --ignore + - Thanks to Artem Lopata for the patch +- Fixed bug #18762 : Incorrect handling of define and constant in UpperCaseConstantNameSniff + - Thanks to Thomas Baker for the patch +- Fixed bug #18769 : CSS Tokenizer doesn't replace T_BREAK tokens inside some styles +- Fixed bug #18835 : Unreachable errors of inline returns of closure functions + - Thanks to Patrick Schmidt for the patch +- Fixed bug #18839 : Fix miscount of warnings in AbstractSniffUnitTest.php + - Thanks to Sam Graham for the patch +- Fixed bug #18844 : Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff with empty body + - Thanks to Dmitri Medvedev for the patch +- Fixed bug #18847 : Running Squiz_Sniffs_Classes_ClassDeclarationSniff results in PHP notice +- Fixed bug #18868 : jslint+rhino: errors/warnings not detected + - Thanks to Christian Weiske for the patch +- Fixed bug #18879 : phpcs-svn-pre-commit requires escapeshellarg + - Thanks to Bjorn Katuin for the patch +- Fixed bug #18951 : weird behaviour with closures and multi-line use () params + +## [1.3.0] - 2011-03-17 +### Changed +- Add a new token T_CLOSURE that replaces T_FUNCTION if the function keyword is anonymous +- Many Squiz sniffs no longer report errors when checking closures; they are now ignored +- Fixed some error messages in PEAR MultiLineConditionSniff that were not using placeholders for message data +- AbstractVariableSniff now correctly finds variable names wrapped with curly braces inside double quoted strings +- PEAR FunctionDeclarationSniff now ignores arrays in argument default values when checking multi-line declarations + +### Fixed +- Fixed bug #18200 : Using custom named ruleset file as standard no longer works +- Fixed bug #18196 : PEAR MultiLineCondition.SpaceBeforeOpenBrace not consistent with newline chars +- Fixed bug #18204 : FunctionCommentThrowTag picks wrong exception type when throwing function call +- Fixed bug #18222 : Add __invoke method to PEAR standard +- Fixed bug #18235 : Invalid error generation in Squiz.Commenting.FunctionCommentThrowTag +- Fixed bug #18250 : --standard with relative path skips Standards' "implicit" sniffs +- Fixed bug #18274 : Multi-line IF and function call indent rules conflict +- Fixed bug #18282 : Squiz doesn't handle final keyword before function comments + - Thanks to Dave Perrett for the patch +- Fixed bug #18336 : Function isUnderscoreName gives php notices + +## [1.3.0RC2] - 2011-01-14 +### Changed +- You can now print multiple reports for each run and print each to the screen or a file (request #12434) + - Format is --report-[report][=file] (e.g., --report-xml=out.xml) + - Printing to screen is done by leaving [file] empty (e.g., --report-xml) + - Multiple reports can be specified in this way (e.g., --report-summary --report-xml=out.xml) + - The standard --report and --report-file command line arguments are unchanged +- Added -d command line argument to set php.ini settings while running (request #17244) + - Usage is: phpcs -d memory_limit=32M -d ... + - Thanks to Ben Selby for the patch +- Added -p command line argument to show progress during a run + - Dot means pass, E means errors found, W means only warnings found and S means skipped file + - Particularly good for runs where you are checking more than 100 files + - Enable by default with --config-set show_progress 1 + - Will not print anything if you are already printing verbose output + - This has caused a big change in the way PHP_CodeSniffer processes files (API changes around processing) +- You can now add exclude rules for individual sniffs or error messages (request #17903) + - Only available when using a ruleset.xml file to specify rules + - Uses the same exclude-pattern tags as normal but allows them inside rule tags +- Using the -vvv option will now print a list of sniffs executed for each file and how long they took to process +- Added Generic ClosureLinterSniff to run Google's gjslint over your JS files +- The XML and CSV reports now include the severity of the error (request #18165) + - The Severity column in the CSV report has been renamed to Type, and a new Severity column added for this +- Fixed issue with Squiz FunctionCommentSniff reporting incorrect type hint when default value uses namespace + - Thanks to Anti Veeranna for the patch +- Generic FileLengthSniff now uses iconv_strlen to check line length if an encoding is specified (request #14237) +- Generic UnnecessaryStringConcatSniff now allows strings to be combined to form a PHP open or close tag +- Squiz SwitchDeclarationSniff no longer reports indentation errors for BREAK statements inside IF conditions +- Interactive mode now always prints the full error report (ignores command line) +- Improved regular expression detection in JavaScript files + - Added new T_TYPEOF token that can be used to target the typeof JS operator + - Fixes bug #17611 : Regular expression tokens not recognised +- Squiz ScopeIndentSniff removed + - Squiz standard no longer requires additional indents between ob_* methods + - Also removed Squiz OutputBufferingIndentSniff that was checking the same thing +- PHP_CodeSniffer_File::getMemberProperties() performance improved significantly + - Improves performance of Squiz ValidVariableNameSniff significantly +- Squiz OperatorSpacingSniff performance improved significantly +- Squiz NonExecutableCodeSniff performance improved significantly + - Will throw duplicate errors in some cases now, but these should be rare +- MySource IncludeSystemSniff performance improved significantly +- MySource JoinStringsSniff no longer reports an error when using join() on a named JS array +- Warnings are now reported for each file when they cannot be opened instead of stopping the script + - Hide warnings with the -n command line argument + - Can override the warnings using the code Internal.DetectLineEndings + +### Fixed +- Fixed bug #17693 : issue with pre-commit hook script with filenames that start with v +- Fixed bug #17860 : isReference function fails with references in array + - Thanks to Lincoln Maskey for the patch +- Fixed bug #17902 : Cannot run tests when tests are symlinked into tests dir + - Thanks to Matt Button for the patch +- Fixed bug #17928 : Improve error message for Generic_Sniffs_PHP_UpperCaseConstantSniff + - Thanks to Stefano Kowalke for the patch +- Fixed bug #18039 : JS Tokenizer crash when ] is last character in file +- Fixed bug #18047 : Incorrect handling of namespace aliases as constants + - Thanks to Dmitri Medvedev for the patch +- Fixed bug #18072 : Impossible to exclude path from processing when symlinked +- Fixed bug #18073 : Squiz.PHP.NonExecutableCode fault +- Fixed bug #18117 : PEAR coding standard: Method constructor not sniffed as a function +- Fixed bug #18135 : Generic FunctionCallArgumentSpacingSniff reports function declaration errors +- Fixed bug #18140 : Generic scope indent in exact mode: strange expected/found values for switch +- Fixed bug #18145 : Sniffs are not loaded for custom ruleset file + - Thanks to Scott McCammon for the patch +- Fixed bug #18152 : While and do-while with AbstractPatternSniff +- Fixed bug #18191 : Squiz.PHP.LowercasePHPFunctions does not work with new Date() +- Fixed bug #18193 : CodeSniffer doesn't reconize CR (\r) line endings + +## [1.3.0RC1] - 2010-09-03 +### Changed +- Added exclude pattern support to ruleset.xml file so you can specify ignore patterns in a standard (request #17683) + - Use new exclude-pattern tags to include the ignore rules into your ruleset.xml file + - See CodeSniffer/Standards/PHPCS/ruleset.xml for an example +- Added new --encoding command line argument to specify the encoding of the files being checked + - When set to utf-8, stops the XML-based reports from double-encoding + - When set to something else, helps the XML-based reports encode to utf-8 + - Default value is iso-8859-1 but can be changed with --config-set encoding [value] +- The report is no longer printed to screen when using the --report-file command line option (request #17467) + - If you want to print it to screen as well, use the -v command line argument +- The SVN and GIT blame reports now also show percentage of reported errors per author (request #17606) + - Thanks to Ben Selby for the patch +- Updated the SVN pre-commit hook to work with the new severity levels feature +- Generic SubversionPropertiesSniff now allows properties to have NULL values (request #17682) + - A null value indicates that the property should exist but the value should not be checked +- Generic UpperCaseConstantName Sniff now longer complains about the PHPUnit_MAIN_METHOD constant (request #17798) +- Squiz FileComment sniff now checks JS files as well as PHP files +- Squiz FunctionCommentSniff now supports namespaces in type hints + +### Fixed +- Fixed a problem in Squiz OutputBufferingIndentSniff where block comments were reported as not indented +- Fixed bug #17092 : Problems with utf8_encode and htmlspecialchars with non-ascii chars + - Use the new --encoding=utf-8 command line argument if your files are utf-8 encoded +- Fixed bug #17629 : PHP_CodeSniffer_Tokens::$booleanOperators missing T_LOGICAL_XOR + - Thanks to Matthew Turland for the patch +- Fixed bug #17699 : Fatal error generating code coverage with PHPUnit 5.3.0RC1 +- Fixed bug #17718 : Namespace 'use' statement: used global class name is recognized as constant +- Fixed bug #17734 : Generic SubversionPropertiesSniff complains on non SVN files +- Fixed bug #17742 : EmbeddedPhpSniff reacts negatively to file without closing php tag +- Fixed bug #17823 : Notice: Please no longer include PHPUnit/Framework.php + +## [1.3.0a1] - 2010-07-15 +### Changed +- All CodingStandard.php files have been replaced by ruleset.xml files + - Custom standards will need to be converted over to this new format to continue working +- You can specify a path to your own custom ruleset.xml file by using the --standard command line arg + - e.g., phpcs --standard=/path/to/my/ruleset.xml +- Added a new report type --report=gitblame to show how many errors and warnings were committed by each author + - Has the same functionality as the svnblame report + - Thanks to Ben Selby for the patch +- A new token type T_DOLLAR has been added to allow you to sniff for variable variables (feature request #17095) + - Thanks to Ian Young for the patch +- JS tokenizer now supports T_POWER (^) and T_MOD_EQUAL (%=) tokens (feature request #17441) +- If you have PHP_Timer installed, you'll now get a time/memory summary at the end of a script run + - Only happens when printing reports that are designed to be read on the command line +- Added Generic DeprecatedFunctionsSniff to warn about the use of deprecated functions (feature request #16694) + - Thanks to Sebastian Bergmann for the patch +- Added Squiz LogicalOperatorSniff to ensure that logical operators are surrounded by single spaces +- Added MySource ChannelExceptionSniff to ensure action files only throw ChannelException +- Added new method getClassProperties() for sniffs to use to determine if a class is abstract and/or final + - Thanks to Christian Kaps for the patch +- Generic UpperCaseConstantSniff no longer throws errors about namespaces + - Thanks to Christian Kaps for the patch +- Squiz OperatorBracketSniff now correctly checks value assignments in arrays +- Squiz LongConditionClosingCommentSniff now requires a comment for long CASE statements that use curly braces +- Squiz LongConditionClosingCommentSniff now requires an exact comment match on the brace +- MySource IncludeSystemSniff now ignores DOMDocument usage +- MySource IncludeSystemSniff no longer requires inclusion of systems that are being implemented +- Removed found and expected messages from Squiz ConcatenationSpacingSniff because they were messy and not helpful + +### Fixed +- Fixed a problem where Generic CodeAnalysisSniff could show warnings if checking multi-line strings +- Fixed error messages in Squiz ArrayDeclarationSniff reporting incorrect number of found and expected spaces +- Fixed bug #17048 : False positive in Squiz_WhiteSpace_ScopeKeywordSpacingSniff +- Fixed bug #17054 : phpcs more strict than PEAR CS regarding function parameter spacing +- Fixed bug #17096 : Notice: Undefined index: scope_condition in ScopeClosingBraceSniff.php + - Moved PEAR.Functions.FunctionCallArgumentSpacing to Generic.Functions.FunctionCallArgumentSpacing +- Fixed bug #17144 : Deprecated: Function eregi() is deprecated +- Fixed bug #17236 : PHP Warning due to token_get_all() in DoubleQuoteUsageSniff +- Fixed bug #17243 : Alternate Switch Syntax causes endless loop of Notices in SwitchDeclaration +- Fixed bug #17313 : Bug with switch case structure +- Fixed bug #17331 : Possible parse error: interfaces may not include member vars +- Fixed bug #17337 : CSS tokenizer fails on quotes urls +- Fixed bug #17420 : Uncaught exception when comment before function brace +- Fixed bug #17503 : closures formatting is not supported + +## [1.2.2] - 2010-01-27 +### Changed +- The core PHP_CodeSniffer_File methods now understand the concept of closures (feature request #16866) + - Thanks to Christian Kaps for the sample code +- Sniffs can now specify violation codes for each error and warning they add + - Future versions will allow you to override messages and severities using these codes + - Specifying a code is optional, but will be required if you wish to support overriding +- All reports have been broken into separate classes + - Command line usage and report output remains the same + - Thanks to Gabriele Santini for the patch +- Added an interactive mode that can be enabled using the -a command line argument + - Scans files and stops when it finds a file with errors + - Waits for user input to recheck the file (hopefully you fixed the errors) or skip the file + - Useful for very large code bases where full rechecks take a while +- The reports now show the correct number of errors and warnings found +- The isCamelCaps method now allows numbers in class names +- The JS tokenizer now correctly identifies boolean and bitwise AND and OR tokens +- The JS tokenizer now correctly identifies regular expressions used in conditions +- PEAR ValidFunctionNameSniff now ignores closures +- Squiz standard now uses the PEAR setting of 85 chars for LineLengthSniff +- Squiz ControlStructureSpacingSniff now ensure there are no spaces around parentheses +- Squiz LongConditionClosingCommentSniff now checks for comments at the end of try/catch statements +- Squiz LongConditionClosingCommentSniff now checks validity of comments for short structures if they exist +- Squiz IncrementDecrementUsageSniff now has better checking to ensure it only looks at simple variable assignments +- Squiz PostStatementCommentSniff no longer throws errors for end function comments +- Squiz InlineCommentSniff no longer throws errors for end function comments +- Squiz OperatorBracketSniff now allows simple arithmetic operations in SWITCH conditions +- Squiz ValidFunctionNameSniff now ignores closures +- Squiz MethodScopeSniff now ignores closures +- Squiz ClosingDeclarationCommentSniff now ignores closures +- Squiz GlobalFunctionSniff now ignores closures +- Squiz DisallowComparisonAssignmentSniff now ignores the assigning of arrays +- Squiz DisallowObjectStringIndexSniff now allows indexes that contain dots and reserved words +- Squiz standard now throws nesting level and cyclomatic complexity errors at much higher levels +- Squiz CommentedOutCodeSniff now ignores common comment framing characters +- Squiz ClassCommentSniff now ensures the open comment tag is the only content on the first line +- Squiz FileCommentSniff now ensures the open comment tag is the only content on the first line +- Squiz FunctionCommentSniff now ensures the open comment tag is the only content on the first line +- Squiz VariableCommentSniff now ensures the open comment tag is the only content on the first line +- Squiz NonExecutableCodeSniff now warns about empty return statements that are not required +- Removed ForbiddenStylesSniff from Squiz standard + - It is now in in the MySource standard as BrowserSpecificStylesSniff + - New BrowserSpecificStylesSniff ignores files with browser-specific suffixes +- MySource IncludeSystemSniff no longer throws errors when extending the Exception class +- MySource IncludeSystemSniff no longer throws errors for the abstract widget class +- MySource IncludeSystemSniff and UnusedSystemSniff now allow includes inside IF statements +- MySource IncludeSystemSniff no longer throws errors for included widgets inside methods +- MySource GetRequestDataSniff now throws errors for using $_FILES +- MySource CreateWidgetTypeCallbackSniff now allows return statements in nested functions +- MySource DisallowSelfActionsSniff now ignores abstract classes + +### Fixed +- Fixed a problem with the SVN pre-commit hook for PHP versions without vertical whitespace regex support +- Fixed bug #16740 : False positives for heredoc strings and unused parameter sniff +- Fixed bug #16794 : ValidLogicalOperatorsSniff doesn't report operators not in lowercase +- Fixed bug #16804 : Report filename is shortened too much +- Fixed bug #16821 : Bug in Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff + - Thanks to Jaroslav Hanslík for the patch +- Fixed bug #16836 : Notice raised when using semicolon to open case +- Fixed bug #16855 : Generic standard sniffs incorrectly for define() method +- Fixed bug #16865 : Two bugs in Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff + - Thanks to Jaroslav Hanslík for the patch +- Fixed bug #16902 : Inline If Declaration bug +- Fixed bug #16960 : False positive for late static binding in Squiz/ScopeKeywordSpacingSniff + - Thanks to Jakub Tománek for the patch +- Fixed bug #16976 : The phpcs attempts to process symbolic links that don't resolve to files +- Fixed bug #17017 : Including one file in the files sniffed alters errors reported for another file + +## [1.2.1] - 2009-11-17 +### Changed +- Added a new report type --report=svnblame to show how many errors and warnings were committed by each author + - Also shows the percentage of their code that are errors and warnings + - Requires you to have the SVN command in your path + - Make sure SVN is storing usernames and passwords (if required) or you will need to enter them for each file + - You can also use the -s command line argument to see the different types of errors authors are committing + - You can use the -v command line argument to see all authors, even if they have no errors or warnings +- Added a new command line argument --report-width to allow you to set the column width of screen reports + - Reports wont accept values less than 70 or else they get too small + - Can also be set via a config var: phpcs --config-set report_width 100 +- You can now get PHP_CodeSniffer to ignore a whole file by adding @codingStandardsIgnoreFile in the content + - If you put it in the first two lines the file wont even be tokenized, so it will be much quicker +- Reports now print their file lists in alphabetical order +- PEAR FunctionDeclarationSniff now reports error for incorrect closing bracket placement in multi-line definitions +- Added Generic CallTimePassByReferenceSniff to prohibit the passing of variables into functions by reference + - Thanks to Florian Grandel for the contribution +- Added Squiz DisallowComparisonAssignmentSniff to ban the assignment of comparison values to a variable +- Added Squiz DuplicateStyleDefinitionSniff to check for duplicate CSS styles in a single class block +- Squiz ArrayDeclarationSniff no longer checks the case of array indexes because that is not its job +- Squiz PostStatementCommentSniff now allows end comments for class member functions +- Squiz InlineCommentSniff now supports the checking of JS files +- MySource CreateWidgetTypeCallbackSniff now allows the callback to be passed to another function +- MySource CreateWidgetTypeCallbackSniff now correctly ignores callbacks used inside conditions +- Generic MultipleStatementAlignmentSniff now enforces a single space before equals sign if max padding is reached +- Fixed a problem in the JS tokenizer where regular expressions containing \// were not converted correctly +- Fixed a problem tokenizing CSS files where multiple ID targets on a line would look like comments +- Fixed a problem tokenizing CSS files where class names containing a colon looked like style definitions +- Fixed a problem tokenizing CSS files when style statements had empty url() calls +- Fixed a problem tokenizing CSS colours with the letter E in first half of the code +- Squiz ColonSpacingSniff now ensures it is only checking style definitions in CSS files and not class names +- Squiz DisallowComparisonAssignmentSniff no longer reports errors when assigning the return value of a function +- CSS tokenizer now correctly supports multi-line comments +- When only the case of var names differ for function comments, the error now indicates the case is different + +### Fixed +- Fixed an issue with Generic UnnecessaryStringConcatSniff where it incorrectly suggested removing a concat +- Fixed bug #16530 : ScopeIndentSniff reports false positive +- Fixed bug #16533 : Duplicate errors and warnings +- Fixed bug #16563 : Check file extensions problem in phpcs-svn-pre-commit + - Thanks to Kaijung Chen for the patch +- Fixed bug #16592 : Object operator indentation incorrect when first operator is on a new line +- Fixed bug #16641 : Notice output +- Fixed bug #16682 : Squiz_Sniffs_Strings_DoubleQuoteUsageSniff reports string "\0" as invalid +- Fixed bug #16683 : Typing error in PHP_CodeSniffer_CommentParser_AbstractParser +- Fixed bug #16684 : Bug in Squiz_Sniffs_PHP_NonExecutableCodeSniff +- Fixed bug #16692 : Spaces in paths in Squiz_Sniffs_Debug_JavaScriptLintSniff + - Thanks to Jaroslav Hanslík for the patch +- Fixed bug #16696 : Spelling error in MultiLineConditionSniff +- Fixed bug #16697 : MultiLineConditionSniff incorrect result with inline IF +- Fixed bug #16698 : Notice in JavaScript Tokenizer +- Fixed bug #16736 : Multi-files sniffs aren't processed when FILE is a single directory + - Thanks to Alexey Shein for the patch +- Fixed bug #16792 : Bug in Generic_Sniffs_PHP_ForbiddenFunctionsSniff + +## [1.2.0] - 2009-08-17 +### Changed +- Installed standards are now favoured over custom standards when using the cmd line arg with relative paths +- Unit tests now use a lot less memory while running +- Squiz standard now uses Generic EmptyStatementSniff but throws errors instead of warnings +- Squiz standard now uses Generic UnusedFunctionParameterSniff +- Removed unused ValidArrayIndexNameSniff from the Squiz standard + +### Fixed +- Fixed bug #16424 : SubversionPropertiesSniff print PHP Warning +- Fixed bug #16450 : Constant PHP_CODESNIFFER_VERBOSITY already defined (unit tests) +- Fixed bug #16453 : function declaration long line splitted error +- Fixed bug #16482 : phpcs-svn-pre-commit ignores extensions parameter + +## [1.2.0RC3] - 2009-07-07 +### Changed +- You can now use @codingStandardsIgnoreStart and @...End comments to suppress messages (feature request #14002) +- A warning is now included for files without any code when short_open_tag is set to Off (feature request #12952) +- You can now use relative paths to your custom standards with the --standard cmd line arg (feature request #14967) +- You can now override magic methods and functions in PEAR ValidFunctionNameSniff (feature request #15830) +- MySource IncludeSystemSniff now recognises widget action classes +- MySource IncludeSystemSniff now knows about unit test classes and changes rules accordingly + +## [1.2.0RC2] - 2009-05-25 +### Changed +- Test suite can now be run using the full path to AllTests.php (feature request #16179) + +### Fixed +- Fixed bug #15980 : PHP_CodeSniffer change php current directory + - Thanks to Dolly Aswin Harahap for the patch +- Fixed bug #16001 : Notice triggered +- Fixed bug #16054 : phpcs-svn-pre-commit not showing any errors +- Fixed bug #16071 : Fatal error: Uncaught PHP_CodeSniffer_Exception +- Fixed bug #16170 : Undefined Offset -1 in MultiLineConditionSniff.php on line 68 +- Fixed bug #16175 : Bug in Squiz-IncrementDecrementUsageSniff + +## [1.2.0RC1] - 2009-03-09 +### Changed +- Reports that are output to a file now include a trailing newline at the end of the file +- Fixed sniff names not shown in -vvv token processing output +- Added Generic SubversionPropertiesSniff to check that specific svn props are set for files + - Thanks to Jack Bates for the contribution +- The PHP version check can now be overridden in classes that extend PEAR FileCommentSniff + - Thanks to Helgi Þormar Þorbjörnsson for the suggestion +- Added Generic ConstructorNameSniff to check for PHP4 constructor name usage + - Thanks to Leif Wickland for the contribution +- Squiz standard now supports multi-line function and condition sniffs from PEAR standard +- Squiz standard now uses Generic ConstructorNameSniff +- Added MySource GetRequestDataSniff to ensure REQUEST, GET and POST are not accessed directly +- Squiz OperatorBracketSniff now allows square brackets in simple unbracketed operations + +### Fixed +- Fixed the incorrect tokenizing of multi-line block comments in CSS files +- Fixed bug #15383 : Uncaught PHP_CodeSniffer_Exception +- Fixed bug #15408 : An unexpected exception has been caught: Undefined offset: 2 +- Fixed bug #15519 : Uncaught PHP_CodeSniffer_Exception +- Fixed bug #15624 : Pre-commit hook fails with PHP errors +- Fixed bug #15661 : Uncaught PHP_CodeSniffer_Exception +- Fixed bug #15722 : "declare(encoding = 'utf-8');" leads to "Missing file doc comment" +- Fixed bug #15910 : Object operator indention not calculated correctly + +## [1.2.0a1] - 2008-12-18 +### Changed +- PHP_CodeSniffer now has a CSS tokenizer for checking CSS files +- Added support for a new multi-file sniff that sniffs all processed files at once +- Added new output format --report=emacs to output errors using the emacs standard compile output format + - Thanks to Len Trigg for the contribution +- Reports can now be written to a file using the --report-file command line argument (feature request #14953) + - The report is also written to screen when using this argument +- The CheckStyle, CSV and XML reports now include a source for each error and warning (feature request #13242) + - A new report type --report=source can be used to show you the most common errors in your files +- Added new command line argument -s to show error sources in all reports +- Added new command line argument --sniffs to specify a list of sniffs to restrict checking to + - Uses the sniff source codes that are optionally displayed in reports +- Changed the max width of error lines from 80 to 79 chars to stop blank lines in the default windows cmd window +- PHP_CodeSniffer now has a token for an asperand (@ symbol) so sniffs can listen for them + - Thanks to Andy Brockhurst for the patch +- Added Generic DuplicateClassNameSniff that will warn if the same class name is used in multiple files + - Not currently used by any standard; more of a multi-file sniff sample than anything useful +- Added Generic NoSilencedErrorsSniff that warns if PHP errors are being silenced using the @ symbol + - Thanks to Andy Brockhurst for the contribution +- Added Generic UnnecessaryStringConcatSniff that checks for two strings being concatenated +- Added PEAR FunctionDeclarationSniff to enforce the new multi-line function declaration PEAR standard +- Added PEAR MultiLineAssignmentSniff to enforce the correct indentation of multi-line assignments +- Added PEAR MultiLineConditionSniff to enforce the new multi-line condition PEAR standard +- Added PEAR ObjectOperatorIndentSniff to enforce the new chained function call PEAR standard +- Added MySource DisallowSelfActionSniff to ban the use of self::method() calls in Action classes +- Added MySource DebugCodeSniff to ban the use of Debug::method() calls +- Added MySource CreateWidgetTypeCallback sniff to check callback usage in widget type create methods +- Added Squiz DisallowObjectStringIndexSniff that forces object dot notation in JavaScript files + - Thanks to Sertan Danis for the contribution +- Added Squiz DiscouragedFunctionsSniff to warn when using debug functions +- Added Squiz PropertyLabelSniff to check whitespace around colons in JS property and label declarations +- Added Squiz DuplicatePropertySniff to check for duplicate property names in JS classes +- Added Squiz ColonSpacingSniff to check for spacing around colons in CSS style definitions +- Added Squiz SemicolonSpacingSniff to check for spacing around semicolons in CSS style definitions +- Added Squiz IndentationSniff to check for correct indentation of CSS files +- Added Squiz ColourDefinitionSniff to check that CSS colours are defined in uppercase and using shorthand +- Added Squiz EmptyStyleDefinitionSniff to check for CSS style definitions without content +- Added Squiz EmptyClassDefinitionSniff to check for CSS class definitions without content +- Added Squiz ClassDefinitionOpeningBraceSpaceSniff to check for spaces around opening brace of CSS class definitions +- Added Squiz ClassDefinitionClosingBraceSpaceSniff to check for a single blank line after CSS class definitions +- Added Squiz ClassDefinitionNameSpacingSniff to check for a blank lines inside CSS class definition names +- Added Squiz DisallowMultipleStyleDefinitionsSniff to check for multiple style definitions on a single line +- Added Squiz DuplicateClassDefinitionSniff to check for duplicate CSS class blocks that can be merged +- Added Squiz ForbiddenStylesSniff to check for usage of browser specific styles +- Added Squiz OpacitySniff to check for incorrect opacity values in CSS +- Added Squiz LowercaseStyleDefinitionSniff to check for styles that are not defined in lowercase +- Added Squiz MissingColonSniff to check for style definitions where the colon has been forgotten +- Added Squiz MultiLineFunctionDeclarationSniff to check that multi-line declarations contain one param per line +- Added Squiz JSLintSniff to check for JS errors using the jslint.js script through Rhino + - Set jslint path using phpcs --config-set jslint_path /path/to/jslint.js + - Set rhino path using phpcs --config-set rhino_path /path/to/rhino +- Added Generic TodoSniff that warns about comments that contain the word TODO +- Removed MultipleStatementAlignmentSniff from the PEAR standard as alignment is now optional +- Generic ForbiddenFunctionsSniff now has protected member var to specify if it should use errors or warnings +- Generic MultipleStatementAlignmentSniff now has correct error message if assignment is on a new line +- Generic MultipleStatementAlignmentSniff now has protected member var to allow it to ignore multi-line assignments +- Generic LineEndingsSniff now supports checking of JS files +- Generic LineEndingsSniff now supports checking of CSS files +- Generic DisallowTabIndentSniff now supports checking of CSS files +- Squiz DoubleQuoteUsageSniff now bans the use of variables in double quoted strings in favour of concatenation +- Squiz SuperfluousWhitespaceSniff now supports checking of JS files +- Squiz SuperfluousWhitespaceSniff now supports checking of CSS files +- Squiz DisallowInlineIfSniff now supports checking of JS files +- Squiz SemicolonSpacingSniff now supports checking of JS files +- Squiz PostStatementCommentSniff now supports checking of JS files +- Squiz FunctionOpeningBraceSpacingSniff now supports checking of JS files +- Squiz FunctionClosingBraceSpacingSniff now supports checking of JS files + - Empty JS functions must have their opening and closing braces next to each other +- Squiz ControlStructureSpacingSniff now supports checking of JS files +- Squiz LongConditionClosingCommentSniff now supports checking of JS files +- Squiz OperatorSpacingSniff now supports checking of JS files +- Squiz SwitchDeclarationSniff now supports checking of JS files +- Squiz CommentedOutCodeSniff now supports checking of CSS files +- Squiz DisallowSizeFunctionsInLoopsSniff now supports checking of JS files for the use of object.length +- Squiz DisallowSizeFunctionsInLoopsSniff no longer complains about size functions outside of the FOR condition +- Squiz ControlStructureSpacingSniff now bans blank lines at the end of a control structure +- Squiz ForLoopDeclarationSniff no longer throws errors for JS FOR loops without semicolons +- Squiz MultipleStatementAlignmentSniff no longer throws errors if a statement would take more than 8 spaces to align +- Squiz standard now uses Generic TodoSniff +- Squiz standard now uses Generic UnnecessaryStringConcatSniff +- Squiz standard now uses PEAR MultiLineAssignmentSniff +- Squiz standard now uses PEAR MultiLineConditionSniff +- Zend standard now uses OpeningFunctionBraceBsdAllmanSniff (feature request #14647) +- MySource JoinStringsSniff now bans the use of inline array joins and suggests the + operator +- Fixed incorrect errors that can be generated from abstract scope sniffs when moving to a new file +- Core tokenizer now matches orphaned curly braces in the same way as square brackets +- Whitespace tokens at the end of JS files are now added to the token stack +- JavaScript tokenizer now identifies properties and labels as new token types +- JavaScript tokenizer now identifies object definitions as a new token type and matches curly braces for them +- JavaScript tokenizer now identifies DIV_EQUAL and MUL_EQUAL tokens +- Improved regular expression detection in the JavaScript tokenizer +- Improve AbstractPatternSniff support so it can listen for any token type, not just weighted tokens + +### Fixed +- Fixed Squiz DoubleQuoteUsageSniff so it works correctly with short_open_tag=Off +- Fixed bug #14409 : Output of warnings to log file +- Fixed bug #14520 : Notice: Undefined offset: 1 in /usr/share/php/PHP/CodeSniffer/File.php on line +- Fixed bug #14637 : Call to processUnknownArguments() misses second parameter $pos + - Thanks to Peter Buri for the patch +- Fixed bug #14889 : Lack of clarity: licence or license +- Fixed bug #15008 : Nested Parentheses in Control Structure Sniffs +- Fixed bug #15091 : pre-commit hook attempts to sniff folders + - Thanks to Bruce Weirdan for the patch +- Fixed bug #15124 : AbstractParser.php uses deprecated split() function + - Thanks to Sebastian Bergmann for the patch +- Fixed bug #15188 : PHPCS vs HEREDOC strings +- Fixed bug #15231 : Notice: Uninitialized string offset: 0 in FileCommentSniff.php on line 555 +- Fixed bug #15336 : Notice: Undefined offset: 2 in /usr/share/php/PHP/CodeSniffer/File.php on line + +## [1.1.0] - 2008-07-14 +### Changed +- PEAR FileCommentSniff now allows tag orders to be overridden in child classes + - Thanks to Jeff Hodsdon for the patch +- Added Generic DisallowMultipleStatementsSniff to ensure there is only one statement per line +- Squiz standard now uses DisallowMultipleStatementsSniff + +### Fixed +- Fixed error in Zend ValidVariableNameSniff when checking vars in form: $class->{$var} +- Fixed bug #14077 : Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a class member +- Fixed bug #14168 : Global Function -> Static Method and __autoload() +- Fixed bug #14238 : Line length not checked at last line of a file +- Fixed bug #14249 : wrong detection of scope_opener +- Fixed bug #14250 : ArrayDeclarationSniff emit warnings at malformed array +- Fixed bug #14251 : --extensions option doesn't work + +## [1.1.0RC3] - 2008-07-03 +### Changed +- PEAR FileCommentSniff now allows tag orders to be overridden in child classes + - Thanks to Jeff Hodsdon for the patch +- Added Generic DisallowMultipleStatementsSniff to ensure there is only one statement per line +- Squiz standard now uses DisallowMultipleStatementsSniff + +### Fixed +- Fixed error in Zend ValidVariableNameSniff when checking vars in form: $class->{$var} +- Fixed bug #14077 : Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a class member +- Fixed bug #14168 : Global Function -> Static Method and __autoload() +- Fixed bug #14238 : Line length not checked at last line of a file +- Fixed bug #14249 : wrong detection of scope_opener +- Fixed bug #14250 : ArrayDeclarationSniff emit warnings at malformed array +- Fixed bug #14251 : --extensions option doesn't work + +## [1.1.0RC2] - 2008-06-13 +### Changed +- Permission denied errors now stop script execution but still display current errors (feature request #14076) +- Added Squiz ValidArrayIndexNameSniff to ensure array indexes do not use camel case +- Squiz ArrayDeclarationSniff now ensures arrays are not declared with camel case index values +- PEAR ValidVariableNameSniff now alerts about a possible parse error for member vars inside an interface + +### Fixed +- Fixed bug #13921 : js parsing fails for comments on last line of file +- Fixed bug #13922 : crash in case of malformed (but tokenized) php file + - PEAR and Squiz ClassDeclarationSniff now throw warnings for possible parse errors + - Squiz ValidClassNameSniff now throws warning for possible parse errors + - Squiz ClosingDeclarationCommentSniff now throws additional warnings for parse errors + +## [1.1.0RC1] - 2008-05-13 +### Changed +- Added support for multiple tokenizers so PHP_CodeSniffer can check more than just PHP files + - PHP_CodeSniffer now has a JS tokenizer for checking JavaScript files + - Sniffs need to be updated to work with additional tokenizers, or new sniffs written for them +- phpcs now exits with status 2 if the tokenizer extension has been disabled (feature request #13269) +- Added scripts/phpcs-svn-pre-commit that can be used as an SVN pre-commit hook + - Also reworked the way the phpcs script works to make it easier to wrap it with other functionality + - Thanks to Jack Bates for the contribution +- Fixed error in phpcs error message when a supplied file does not exist +- Fixed a cosmetic error in AbstractPatternSniff where the "found" string was missing some content +- Added sniffs that implement part of the PMD rule catalog to the Generic standard + - Thanks to Manuel Pichler for the contribution of all these sniffs. +- Squiz FunctionCommentThrowTagSniff no longer throws errors for function that only throw variables +- Generic ScopeIndentSniff now has private member to enforce exact indent matching +- Replaced Squiz DisallowCountInLoopsSniff with Squiz DisallowSizeFunctionsInLoopsSniff + - Thanks to Jan Miczaika for the sniff +- Squiz BlockCommentSniff now checks inline doc block comments +- Squiz InlineCommentSniff now checks inline doc block comments +- Squiz BlockCommentSniff now checks for no blank line before first comment in a function +- Squiz DocCommentAlignmentSniff now ignores inline doc block comments +- Squiz ControlStructureSpacingSniff now ensures no blank lines at the start of control structures +- Squiz ControlStructureSpacingSniff now ensures no blank lines between control structure closing braces +- Squiz IncrementDecrementUsageSniff now ensures inc/dec ops are bracketed in string concats +- Squiz IncrementDecrementUsageSniff now ensures inc/dec ops are not used in arithmetic operations +- Squiz FunctionCommentSniff no longer throws errors if return value is mixed but function returns void somewhere +- Squiz OperatorBracketSniff no allows function call brackets to count as operator brackets +- Squiz DoubleQuoteUsageSniff now supports \x \f and \v (feature request #13365) +- Squiz ComparisonOperatorUsageSniff now supports JS files +- Squiz ControlSignatureSniff now supports JS files +- Squiz ForLoopDeclarationSniff now supports JS files +- Squiz OperatorBracketSniff now supports JS files +- Squiz InlineControlStructureSniff now supports JS files +- Generic LowerCaseConstantSniff now supports JS files +- Generic DisallowTabIndentSniff now supports JS files +- Generic MultipleStatementAlignmentSniff now supports JS files +- Added Squiz ObjectMemberCommaSniff to ensure the last member of a JS object is not followed by a comma +- Added Squiz ConstantCaseSniff to ensure the PHP constants are uppercase and JS lowercase +- Added Squiz JavaScriptLintSniff to check JS files with JSL + - Set path using phpcs --config-set jsl_path /path/to/jsl +- Added MySource FirebugConsoleSniff to ban the use of "console" for JS variable and function names +- Added MySource JoinStringsSniff to enforce the use of join() to concatenate JS strings +- Added MySource AssignThisSniff to ensure this is only assigned to a var called self +- Added MySource DisallowNewWidgetSniff to ban manual creation of widget objects +- Removed warning shown in Zend CodeAnalyzerSniff when the ZCA path is not set + +### Fixed +- Fixed error in Squiz ValidVariableNameSniff when checking vars in the form $obj->$var +- Fixed error in Squiz DisallowMultipleAssignmentsSniff when checking vars in the form $obj->$var +- Fixed error in Squiz InlineCommentSniff where comments for class constants were seen as inline +- Fixed error in Squiz BlockCommentSniff where comments for class constants were not ignored +- Fixed error in Squiz OperatorBracketSniff where negative numbers were ignored during comparisons +- Fixed error in Squiz FunctionSpacingSniff where functions after member vars reported incorrect spacing +- Fixed bug #13062 : Interface comments aren't handled in PEAR standard + - Thanks to Manuel Pichler for the path +- Fixed bug #13119 : php minimum requirement need to be fix +- Fixed bug #13156 : Bug in Squiz_Sniffs_PHP_NonExecutableCodeSniff +- Fixed bug #13158 : Strange behaviour in AbstractPatternSniff +- Fixed bug #13169 : Undefined variables +- Fixed bug #13178 : Catch exception in File.php +- Fixed bug #13254 : Notices output in checkstyle report causes XML issues +- Fixed bug #13446 : crash with src of phpMyAdmin + - Thanks to Manuel Pichler for the path + +## [1.0.1a1] - 2008-04-21 +### Changed +- Fixed error in PEAR ValidClassNameSniff when checking class names with double underscores +- Moved Squiz InlineControlStructureSniff into Generic standard +- PEAR standard now throws warnings for inline control structures +- Squiz OutputBufferingIndentSniff now ignores the indentation of inline HTML +- MySource IncludeSystemSniff now ignores usage of ZipArchive +- Removed "function" from error messages for Generic function brace sniffs (feature request #13820) +- Generic UpperCaseConstantSniff no longer throws errors for declare(ticks = ...) + - Thanks to Josh Snyder for the patch +- Squiz ClosingDeclarationCommentSniff and AbstractVariableSniff now throw warnings for possible parse errors + +### Fixed +- Fixed bug #13827 : AbstractVariableSniff throws "undefined index" +- Fixed bug #13846 : Bug in Squiz.NonExecutableCodeSniff +- Fixed bug #13849 : infinite loop in PHP_CodeSniffer_File::findNext() + +## [1.0.1] - 2008-02-04 +### Changed +- Squiz ArrayDeclarationSniff now throws error if the array keyword is followed by a space +- Squiz ArrayDeclarationSniff now throws error for empty multi-line arrays +- Squiz ArrayDeclarationSniff now throws error for multi-line arrays with a single value +- Squiz DocCommentAlignmentSniff now checks for a single space before tags inside docblocks +- Squiz ForbiddenFunctionsSniff now disallows is_null() to force use of (=== NULL) instead +- Squiz VariableCommentSniff now continues throwing errors after the first one is found +- Squiz SuperfluousWhitespaceSniff now throws errors for multiple blank lines inside functions +- MySource IncludedSystemSniff now checks extended class names +- MySource UnusedSystemSniff now checks extended and implemented class names +- MySource IncludedSystemSniff now supports includeWidget() +- MySource UnusedSystemSniff now supports includeWidget() +- Added PEAR ValidVariableNameSniff to check that only private member vars are prefixed with an underscore +- Added Squiz DisallowCountInLoopsSniff to check for the use of count() in FOR and WHILE loop conditions +- Added MySource UnusedSystemSniff to check for included classes that are never used + +### Fixed +- Fixed a problem that caused the parentheses map to sometimes contain incorrect values +- Fixed bug #12767 : Cant run phpcs from dir with PEAR subdir +- Fixed bug #12773 : Reserved variables are not detected in strings + - Thanks to Wilfried Loche for the patch +- Fixed bug #12832 : Tab to space conversion does not work +- Fixed bug #12888 : extra space indentation = Notice: Uninitialized string offset... +- Fixed bug #12909 : Default generateDocs function does not work under linux + - Thanks to Paul Smith for the patch +- Fixed bug #12957 : PHP 5.3 magic method __callStatic + - Thanks to Manuel Pichler for the patch + +## [1.0.0] - 2007-12-21 +### Changed +- You can now specify the full path to a coding standard on the command line (feature request #11886) + - This allows you to use standards that are stored outside of PHP_CodeSniffer's own Standard dir + - You can also specify full paths in the CodingStandard.php include and exclude methods + - Classes, dirs and files need to be names as if the standard was part of PHP_CodeSniffer + - Thanks to Dirk Thomas for the doc generator patch and testing +- Modified the scope map to keep checking after 3 lines for some tokens (feature request #12561) + - Those tokens that must have an opener (like T_CLASS) now keep looking until EOF + - Other tokens (like T_FUNCTION) still stop after 3 lines for performance +- You can now escape commas in ignore patterns so they can be matched in file names + - Thanks to Carsten Wiedmann for the patch +- Config data is now cached in a global var so the file system is not hit so often + - You can also set config data temporarily for the script if you are using your own external script + - Pass TRUE as the third argument to PHP_CodeSniffer::setConfigData() +- PEAR ClassDeclarationSniff no longer throws errors for multi-line class declarations +- Squiz ClassDeclarationSniff now ensures there is one blank line after a class closing brace +- Squiz ClassDeclarationSniff now throws errors for a missing end PHP tag after the end class tag +- Squiz IncrementDecrementUsageSniff no longer throws errors when -= and += are being used with vars +- Squiz SwitchDeclarationSniff now throws errors for switch statements that do not contain a case statement + - Thanks to Sertan Danis for the patch +- MySource IncludeSystemSniff no longer throws errors for the Util package + +### Fixed +- Fixed bug #12621 : "space after AS" check is wrong + - Thanks to Satoshi Oikawa for the patch +- Fixed bug #12645 : error message is wrong + - Thanks to Renoiv for the patch +- Fixed bug #12651 : Increment/Decrement Operators Usage at -1 + +## [1.0.0RC3] - 2007-11-30 +### Changed +- Added new command line argument --tab-width that will convert tabs to spaces before testing + - This allows you to use the existing sniffs that check for spaces even when you use tabs + - Can also be set via a config var: phpcs --config-set tab_width 4 + - A value of zero (the default) tells PHP_CodeSniffer not to replace tabs with spaces +- You can now change the default report format from "full" to something else + - Run: phpcs --config-set report_format [format] +- Improved performance by optimising the way the scope map is created during tokenising +- Added new Squiz DisallowInlineIfSniff to disallow the usage of inline IF statements +- Fixed incorrect errors being thrown for nested switches in Squiz SwitchDeclarationSniff +- PEAR FunctionCommentSniff no longer complains about missing comments for @throws tags +- PEAR FunctionCommentSniff now throws error for missing exception class name for @throws tags +- PHP_CodeSniffer_File::isReference() now correctly returns for functions that return references +- Generic LineLengthSniff no longer warns about @version lines with CVS or SVN id tags +- Generic LineLengthSniff no longer warns about @license lines with long URLs +- Squiz FunctionCommentThrowTagSniff no longer complains about throwing variables +- Squiz ComparisonOperatorUsageSniff no longer throws incorrect errors for inline IF statements +- Squiz DisallowMultipleAssignmentsSniff no longer throws errors for assignments in inline IF statements + +### Fixed +- Fixed bug #12455 : CodeSniffer treats content inside heredoc as PHP code +- Fixed bug #12471 : Checkstyle report is broken +- Fixed bug #12476 : PHP4 destructors are reported as error +- Fixed bug #12513 : Checkstyle XML messages need to be utf8_encode()d + - Thanks to Sebastian Bergmann for the patch. +- Fixed bug #12517 : getNewlineAfter() and dos files + +## [1.0.0RC2] - 2007-11-14 +### Changed +- Added a new Checkstyle report format + - Like the current XML format but modified to look like Checkstyle output + - Thanks to Manuel Pichler for helping get the format correct +- You can now hide warnings by default + - Run: phpcs --config-set show_warnings 0 + - If warnings are hidden by default, use the new -w command line argument to override +- Added new command line argument --config-delete to delete a config value and revert to the default +- Improved overall performance by optimising tokenising and next/prev methods (feature request #12421) + - Thanks to Christian Weiske for the patch +- Added FunctionCallSignatureSniff to Squiz standard +- Added @subpackage support to file and class comment sniffs in PEAR standard (feature request #12382) + - Thanks to Carsten Wiedmann for the patch +- An error is now displayed if you use a PHP version less than 5.1.0 (feature request #12380) + - Thanks to Carsten Wiedmann for the patch +- phpcs now exits with status 2 if it receives invalid input (feature request #12380) + - This is distinct from status 1, which indicates errors or warnings were found +- Added new Squiz LanguageConstructSpacingSniff to throw errors for additional whitespace after echo etc. +- Removed Squiz ValidInterfaceNameSniff +- PEAR FunctionCommentSniff no longer complains about unknown tags + +### Fixed +- Fixed incorrect errors about missing function comments in PEAR FunctionCommentSniff +- Fixed incorrect function docblock detection in Squiz FunctionCommentSniff +- Fixed incorrect errors for list() in Squiz DisallowMultipleAssignmentsSniff +- Errors no longer thrown if control structure is followed by a CASE's BREAK in Squiz ControlStructureSpacingSniff +- Fixed bug #12368 : Autoloader cannot be found due to include_path override + - Thanks to Richard Quadling for the patch +- Fixed bug #12378 : equal sign alignments problem with while() + +## [1.0.0RC1] - 2007-11-01 +### Changed +- Main phpcs script can now be run from a CVS checkout without installing the package +- Added a new CSV report format + - Header row indicates what position each element is in + - Always use the header row to determine positions rather than assuming the format, as it may change +- XML and CSV report formats now contain information about which column the error occurred at + - Useful if you want to highlight the token that caused the error in a custom application +- Square bracket tokens now have bracket_opener and bracket_closer set +- Added new Squiz SemicolonSpacingSniff to throw errors if whitespace is found before a semicolon +- Added new Squiz ArrayBracketSpacingSniff to throw errors if whitespace is found around square brackets +- Added new Squiz ObjectOperatorSpacingSniff to throw errors if whitespace is found around object operators +- Added new Squiz DisallowMultipleAssignmentsSniff to throw errors if multiple assignments are on the same line +- Added new Squiz ScopeKeywordSpacingSniff to throw errors if there is not a single space after a scope modifier +- Added new Squiz ObjectInstantiationSniff to throw errors if new objects are not assigned to a variable +- Added new Squiz FunctionDuplicateArgumentSniff to throw errors if argument is declared multiple times in a function +- Added new Squiz FunctionOpeningBraceSpaceSniff to ensure there are no blank lines after a function open brace +- Added new Squiz CommentedOutCodeSniff to warn about comments that looks like they are commented out code blocks +- Added CyclomaticComplexitySniff to Squiz standard +- Added NestingLevelSniff to Squiz standard +- Squiz ForbiddenFunctionsSniff now recommends echo() instead of print() +- Squiz ValidLogicalOperatorsSniff now recommends ^ instead of xor +- Squiz SwitchDeclarationSniff now contains more checks + - A single space is required after the case keyword + - No space is allowed before the colon in a case or default statement + - All switch statements now require a default case + - Default case must contain a break statement + - Empty default case must contain a comment describing why the default is ignored + - Empty case statements are not allowed + - Case and default statements must not be followed by a blank line + - Break statements must be followed by a blank line or the closing brace + - There must be no blank line before a break statement +- Squiz standard is now using the PEAR IncludingFileSniff +- PEAR ClassCommentSniff no longer complains about unknown tags +- PEAR FileCommentSniff no longer complains about unknown tags +- PEAR FileCommentSniff now accepts multiple @copyright tags +- Squiz BlockCommentSniff now checks that comment starts with a capital letter +- Squiz InlineCommentSniff now has better checking to ensure comment starts with a capital letter +- Squiz ClassCommentSniff now checks that short and long comments start with a capital letter +- Squiz FunctionCommentSniff now checks that short, long and param comments start with a capital letter +- Squiz VariableCommentSniff now checks that short and long comments start with a capital letter + +### Fixed +- Fixed error with multi-token array indexes in Squiz ArrayDeclarationSniff +- Fixed error with checking shorthand IF statements without a semicolon in Squiz InlineIfDeclarationSniff +- Fixed error where constants used as default values in function declarations were seen as type hints +- Fixed bug #12316 : PEAR is no longer the default standard +- Fixed bug #12321 : wrong detection of missing function docblock + +## [0.9.0] - 2007-09-24 +### Changed +- Added a config system for setting config data across phpcs runs +- You can now change the default coding standard from PEAR to something else + - Run: phpcs --config-set default_standard [standard] +- Added new Zend coding standard to check code against the Zend Framework standards + - The complete standard is not yet implemented + - Specify --standard=Zend to use + - Thanks to Johann-Peter Hartmann for the contribution of some sniffs + - Thanks to Holger Kral for the Code Analyzer sniff + +## [0.8.0] - 2007-08-08 +### Changed +- Added new XML report format; --report=xml (feature request #11535) + - Thanks to Brett Bieber for the patch +- Added new command line argument --ignore to specify a list of files to skip (feature request #11556) +- Added PHPCS and MySource coding standards into the core install +- Scope map no longer gets confused by curly braces that act as string offsets +- Removed CodeSniffer/SniffException.php as it is no longer used +- Unit tests can now be run directly from a CVS checkout +- Made private vars and functions protected in PHP_CodeSniffer class so this package can be overridden +- Added new Metrics category to Generic coding standard + - Contains Cyclomatic Complexity and Nesting Level sniffs + - Thanks to Johann-Peter Hartmann for the contribution +- Added new Generic DisallowTabIndentSniff to throw errors if tabs are used for indentation (feature request #11738) + - PEAR and Squiz standards use this new sniff to throw more specific indentation errors +- Generic MultipleStatementAlignmentSniff has new private var to set a padding size limit (feature request #11555) +- Generic MultipleStatementAlignmentSniff can now handle assignments that span multiple lines (feature request #11561) +- Generic LineLengthSniff now has a max line length after which errors are thrown instead of warnings + - BC BREAK: Override the protected member var absoluteLineLimit and set it to zero in custom LineLength sniffs + - Thanks to Johann-Peter Hartmann for the contribution +- Comment sniff errors about incorrect tag orders are now more descriptive (feature request #11693) + +### Fixed +- Fixed bug #11473 : Invalid CamelCaps name when numbers used in names + +## [0.7.0] - 2007-07-02 +### Changed +- BC BREAK: EOL character is now auto-detected and used instead of hard-coded \n + - Pattern sniffs must now specify "EOL" instead of "\n" or "\r\n" to use auto-detection + - Please use $phpcsFile->eolChar to check for newlines instead of hard-coding "\n" or "\r\n" + - Comment parser classes now require you to pass $phpcsFile as an additional argument +- BC BREAK: Included and excluded sniffs now require .php extension + - Please update your coding standard classes and add ".php" to all sniff entries + - See CodeSniffer/Standards/PEAR/PEARCodingStandard.php for an example + +- Fixed error where including a directory of sniffs in a coding standard class did not work +- Coding standard classes can now specify a list of sniffs to exclude as well as include (feature request #11056) +- Two uppercase characters can now be placed side-by-side in class names in Squiz ValidClassNameSniff +- SVN tags now allowed in PEAR file doc blocks (feature request #11038) + - Thanks to Torsten Roehr for the patch +- Private methods in commenting sniffs and comment parser are now protected (feature request #11087) +- Added Generic LineEndingsSniff to check the EOL character of a file +- PEAR standard now only throws one error per file for incorrect line endings (eg. /r/n) +- Command line arg -v now shows number of registered sniffs +- Command line arg -vvv now shows list of registered sniffs +- Squiz ControlStructureSpacingSniff no longer throws errors if the control structure is at the end of the script +- Squiz FunctionCommentSniff now throws error for "return void" if function has return statement +- Squiz FunctionCommentSniff now throws error for functions that return void but specify something else +- Squiz ValidVariableNameSniff now allows multiple uppercase letters in a row +- Squiz ForEachLoopDeclarationSniff now throws error for AS keyword not being lowercase +- Squiz SwitchDeclarationSniff now throws errors for CASE/DEFAULT/BREAK keywords not being lowercase +- Squiz ArrayDeclarationSniff now handles multi-token array values when checking alignment +- Squiz standard now enforces a space after cast tokens +- Generic MultipleStatementAlignmentSniff no longer gets confused by assignments inside FOR conditions +- Generic MultipleStatementAlignmentSniff no longer gets confused by the use of list() +- Added Generic SpaceAfterCastSniff to ensure there is a single space after a cast token +- Added Generic NoSpaceAfterCastSniff to ensure there is no whitespace after a cast token +- Added PEAR ClassDeclarationSniff to ensure the opening brace of a class is on the line after the keyword +- Added Squiz ScopeClosingBraceSniff to ensure closing braces are aligned correctly +- Added Squiz EvalSniff to discourage the use of eval() +- Added Squiz LowercaseDeclarationSniff to ensure all declaration keywords are lowercase +- Added Squiz LowercaseClassKeywordsSniff to ensure all class declaration keywords are lowercase +- Added Squiz LowercaseFunctionKeywordsSniff to ensure all function declaration keywords are lowercase +- Added Squiz LowercasePHPFunctionsSniff to ensure all calls to inbuilt PHP functions are lowercase +- Added Squiz CastSpacingSniff to ensure cast statements dont contain whitespace +- Errors no longer thrown when checking 0 length files with verbosity on + +### Fixed +- Fixed bug #11105 : getIncludedSniffs() not working anymore + - Thanks to Blair Robertson for the patch +- Fixed bug #11120 : Uninitialized string offset in AbstractParser.php on line 200 + +## [0.6.0] - 2007-05-15 +### Changed +- The number of errors and warnings found is now shown for each file while checking the file if verbosity is enabled +- Now using PHP_EOL instead of hard-coded \n so output looks good on Windows (feature request #10761) + - Thanks to Carsten Wiedmann for the patch. +- phpcs now exits with status 0 (no errors) or 1 (errors found) (feature request #10348) +- Added new -l command line argument to stop recursion into directories (feature request #10979) + +### Fixed +- Fixed variable name error causing incorrect error message in Squiz ValidVariableNameSniff +- Fixed bug #10757 : Error in ControlSignatureSniff +- Fixed bugs #10751, #10777 : Sniffer class paths handled incorrectly in Windows + - Thanks to Carsten Wiedmann for the patch. +- Fixed bug #10961 : Error "Last parameter comment requires a blank newline after it" thrown +- Fixed bug #10983 : phpcs outputs notices when checking invalid PHP +- Fixed bug #10980 : Incorrect warnings for equals sign + +## [0.5.0] - 2007-04-17 +### Changed +- BC BREAK: Coding standards now require a class to be added so PHP_CodeSniffer can get information from them + - Please read the end user docs for info about the new class required for all coding standards + +- Coding standards can now include sniffs from other standards, or whole standards, without writing new sniff files +- PHP_CodeSniffer_File::isReference() now correctly returns for references in function declarations +- PHP_CodeSniffer_File::isReference() now returns false if you don't pass it a T_BITWISE_AND token +- PHP_CodeSniffer_File now stores the absolute path to the file so sniffs can check file locations correctly +- Fixed undefined index error in AbstractVariableSniff for variables inside an interface function definition +- Added MemberVarSpacingSniff to Squiz standard to enforce one-line spacing between member vars +- Add FunctionCommentThrowTagSniff to Squiz standard to check that @throws tags are correct + +### Fixed +- Fixed problems caused by references and type hints in Squiz FunctionDeclarationArgumentSpacingSniff +- Fixed problems with errors not being thrown for some misaligned @param comments in Squiz FunctionCommentSniff +- Fixed badly spaced comma error being thrown for "extends" class in Squiz ClassDeclarationSniff +- Errors no longer thrown for class method names in Generic ForbiddenFunctionsSniff +- Errors no longer thrown for type hints in front of references in Generic UpperCaseConstantNameSniff +- Errors no longer thrown for correctly indented buffered lines in Squiz ScopeIndexSniff +- Errors no longer thrown for user-defined functions named as forbidden functions in Generic ForbiddenFunctionsSniff +- Errors no longer thrown on __autoload functions in PEAR ValidFunctionNameSniff +- Errors now thrown for __autoload methods in PEAR ValidFunctionNameSniff +- Errors now thrown if constructors or destructors have @return tags in Squiz FunctionCommentSniff +- Errors now thrown if @throws tags dont start with a capital and end with a full stop in Squiz FunctionCommentSniff +- Errors now thrown for invalid @var tag values in Squiz VariableCommentSniff +- Errors now thrown for missing doc comment in Squiz VariableCommentSniff +- Errors now thrown for unspaced operators in FOR loop declarations in Squiz OperatorSpacingSniff +- Errors now thrown for using ob_get_clean/flush functions to end buffers in Squiz OutputBufferingIndentSniff +- Errors now thrown for all missing member variable comments in Squiz VariableCommentSniff + +## [0.4.0] - 2007-02-19 +### Changed +- Standard name specified with --standard command line argument is no longer case sensitive +- Long error and warning messages are now wrapped to 80 characters in the full error report (thanks Endre Czirbesz) +- Shortened a lot of error and warning messages so they don't take up so much room +- Squiz FunctionCommentSniff now checks that param comments start with a capital letter and end with a full stop +- Squiz FunctionSpacingSniff now reports incorrect lines below function on closing brace, not function keyword +- Squiz FileCommentSniff now checks that there are no blank lines between the open PHP tag and the comment +- PHP_CodeSniffer_File::isReference() now returns correctly when checking refs on right side of => + +### Fixed +- Fixed incorrect error with switch closing brace in Squiz SwitchDeclarationSniff +- Fixed missing error when multiple statements are not aligned correctly with object operators +- Fixed incorrect errors for some PHP special variables in Squiz ValidVariableNameSniff +- Fixed incorrect errors for arrays that only contain other arrays in Squiz ArrayDeclarationSniff +- Fixed bug #9844 : throw new Exception(\n accidentally reported as error but it ain't + +## [0.3.0] - 2007-01-11 +### Changed +- Updated package.xml to version 2 +- Specifying coding standard on command line is now optional, even if you have multiple standards installed + - PHP_CodeSniffer uses the PEAR coding standard by default if no standard is specified +- New command line option, --extensions, to specify a comma separated list of file extensions to check +- Converted all unit tests to PHPUnit 3 format +- Added new coding standard, Squiz, that can be used as an alternative to PEAR + - also contains more examples of sniffs + - some may be moved into the Generic coding standard if required +- Added MultipleStatementAlignmentSniff to Generic standard +- Added ScopeIndentSniff to Generic standard +- Added ForbiddenFunctionsSniff to Generic standard +- Added FileCommentSniff to PEAR standard +- Added ClassCommentSniff to PEAR standard +- Added FunctionCommentSniff to PEAR standard +- Change MultipleStatementSniff to MultipleStatementAlignmentSniff in PEAR standard +- Replaced Methods directory with Functions directory in Generic and PEAR standards + - also renamed some of the sniffs in those directories +- Updated file, class and method comments for all files + +### Fixed +- Fixed bug #9274 : nested_parenthesis element not set for open and close parenthesis tokens +- Fixed bug #9411 : too few pattern characters cause incorrect error report + +## [0.2.1] - 2006-11-09 +### Fixed +- Fixed bug #9274 : nested_parenthesis element not set for open and close parenthesis tokens + +## [0.2.0] - 2006-10-13 +### Changed +- Added a generic standards package that will contain generic sniffs to be used in specific coding standards + - thanks to Frederic Poeydomenge for the idea +- Changed PEAR standard to use generic sniffs where available +- Added LowerCaseConstantSniff to Generic standard +- Added UpperCaseConstantSniff to Generic standard +- Added DisallowShortOpenTagSniff to Generic standard +- Added LineLengthSniff to Generic standard +- Added UpperCaseConstantNameSniff to Generic standard +- Added OpeningMethodBraceBsdAllmanSniff to Generic standard (contrib by Frederic Poeydomenge) +- Added OpeningMethodBraceKernighanRitchieSniff to Generic standard (contrib by Frederic Poeydomenge) +- Added framework for core PHP_CodeSniffer unit tests +- Added unit test for PHP_CodeSniffer:isCamelCaps method +- ScopeClosingBraceSniff now checks indentation of BREAK statements +- Added new command line arg (-vv) to show developer debug output + +### Fixed +- Fixed some coding standard errors +- Fixed bug #8834 : Massive memory consumption +- Fixed bug #8836 : path case issues in package.xml +- Fixed bug #8843 : confusion on nested switch() +- Fixed bug #8841 : comments taken as whitespace +- Fixed bug #8884 : another problem with nested switch() statements + +## [0.1.1] - 2006-09-25 +### Changed +- Added unit tests for all PEAR sniffs +- Exception class now extends from PEAR_Exception + +### Fixed +- Fixed summary report so files without errors but with warnings are not shown when warnings are hidden + +## [0.1.0] - 2006-09-19 +### Changed +- Reorganised package contents to conform to PEAR standards +- Changed version numbering to conform to PEAR standards +- Removed duplicate require_once() of Exception.php from CodeSniffer.php + +## [0.0.5] - 2006-09-18 +### Fixed +- Fixed .bat file for situation where php.ini cannot be found so include_path is not set + +## [0.0.4] - 2006-08-28 +### Changed +- Added .bat file for easier running of PHP_CodeSniffer on Windows +- Sniff that checks method names now works for PHP4 style code where there is no scope keyword +- Sniff that checks method names now works for PHP4 style constructors +- Sniff that checks method names no longer incorrectly reports error with magic methods +- Sniff that checks method names now reports errors with non-magic methods prefixed with __ +- Sniff that checks for constant names no longer incorrectly reports errors with heredoc strings +- Sniff that checks for constant names no longer incorrectly reports errors with created objects +- Sniff that checks indentation no longer incorrectly reports errors with heredoc strings +- Sniff that checks indentation now correctly reports errors with improperly indented multi-line strings +- Sniff that checks function declarations now checks for spaces before and after an equals sign for default values +- Sniff that checks function declarations no longer incorrectly reports errors with multi-line declarations +- Sniff that checks included code no longer incorrectly reports errors when return value is used conditionally +- Sniff that checks opening brace of function no longer incorrectly reports errors with multi-line declarations +- Sniff that checks spacing after commas in function calls no longer reports too many errors for some code +- Sniff that checks control structure declarations now gives more descriptive error message + +## [0.0.3] - 2006-08-22 +### Changed +- Added sniff to check for invalid class and interface names +- Added sniff to check for invalid function and method names +- Added sniff to warn if line is greater than 85 characters +- Added sniff to check that function calls are in the correct format +- Added command line arg to print current version (--version) + +### Fixed +- Fixed error where comments were not allowed on the same line as a control structure declaration + +## [0.0.2] - 2006-07-25 +### Changed +- Removed the including of checked files to stop errors caused by parsing them +- Removed the use of reflection so checked files do not have to be included +- Memory usage has been greatly reduced +- Much faster tokenising and checking times +- Reworked the PEAR coding standard sniffs (much faster now) +- Fix some bugs with the PEAR scope indentation standard +- Better checking for installed coding standards +- Can now accept multiple files and dirs on the command line +- Added an option to list installed coding standards +- Added an option to print a summary report (number of errors and warnings shown for each file) +- Added an option to hide warnings from reports +- Added an option to print verbose output (so you know what is going on) +- Reordered command line args to put switches first (although order is not enforced) +- Switches can now be specified together (eg. php -nv) as well as separately (phpcs -n -v) + +## [0.0.1] - 2006-07-19 +### Added +- Initial preview release diff --git a/README.md b/README.md index 5c71918147..377c2d4429 100644 --- a/README.md +++ b/README.md @@ -62,11 +62,6 @@ You will then be able to run PHP_CodeSniffer from the tools directory: ./tools/phpcs -h ./tools/phpcbf -h ``` -### PEAR -If you use PEAR, you can install PHP_CodeSniffer using the PEAR installer. This will make the `phpcs` and `phpcbf` commands immediately available for use. To install PHP_CodeSniffer using the PEAR installer, first ensure you have [installed PEAR](http://pear.php.net/manual/en/installation.getting.php) and then run the following command: -```bash -pear install PHP_CodeSniffer -``` ### Git Clone You can also download the PHP_CodeSniffer source and run the `phpcs` and `phpcbf` commands directly from the Git clone: ```bash diff --git a/package.xml b/package.xml deleted file mode 100644 index 4120579390..0000000000 --- a/package.xml +++ /dev/null @@ -1,8631 +0,0 @@ - - - PHP_CodeSniffer - pear.php.net - PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files to detect and fix violations of a defined set of coding standards. - PHP_CodeSniffer is a set of two PHP scripts; the main phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second phpcbf script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. - - - Greg Sherwood - squiz - gsherwood@squiz.net - yes - - 2022-06-18 - - - 3.8.0 - 3.8.0 - - - stable - stable - - BSD 3-Clause License - - - 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 - -- 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 an auto 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 - - Added support for 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 readonly class to a number of sniffs - -- Generic.CodeAnalysis.UnnecessaryFinalModifier - -- PEAR.Commenting.ClassComment - -- PEAR.Commenting.FileComment - -- PSR2.Classes.ClassDeclaration - -- 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 - - 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 - - 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 - - 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 - -- Thanks to @Daimona 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 - - 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 #3717 : Squiz.Commenting.FunctionComment: fixed false positive for InvalidNoReturn when type is never - -- Thanks to Choraimy Kroonstuiver (@axlon) 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 #3728 : PHP 8.2 | PSR1/SideEffects: allow for readonly classes - -- 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 #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 #3779 : Squiz/LowercasePHPFunctions + 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 #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 - -- Thanks to @Daimona for the patch - - Fixed bug #3809 : GitBlame report was broken when passing a basepath - -- Thanks to Chris (@datengraben) for the patch - - 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 #3816 : PSR12/FileHeader: bug fix - false positives on PHP 8.2+ readonly classes - -- 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 - -- Thanks to @simonsan for the patch - - Fixed bug #3906 : Tokenizer/CSS: fixed a bug related to the unsupported slash comment syntax - -- Thanks to Dan Wallis (@fredden) for the patch - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5.4.0 - - - 1.4.0b1 - - - tokenizer - - - xmlwriter - - - simplexml - - - - - - - windows - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3.7.2 - 3.7.2 - - - stable - stable - - 2023-02-23 - BSD License - - - Newer versions of Composer will now suggest installing PHPCS using require-dev instead of require - -- Thanks to Gary Jones (@GaryJones) for the patch - - 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 - 3.7.1 - - - stable - stable - - 2022-06-18 - BSD License - - - 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 - 3.7.0 - - - stable - stable - - 2022-06-13 - BSD License - - - 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 for the patch - -- Thanks to Juliette Reinders Folmer 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 for the patch - -- Thanks to Juliette Reinders Folmer 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 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 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 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 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 for the patch - - The list of installed coding standards now has consistent ordering across all platforms - -- Thanks to Juliette Reinders Folmer 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 for the patch - - Generic.PHP.LowerCaseType now supports the PHP 8.1 never type - -- Thanks to Jaroslav Hanslík 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 - - Fixed bug #3505 : The nullsafe operator is not counted in Generic.Metrics.CyclomaticComplexity - -- Thanks to Mark Baker for the patch - - Fixed bug #3526 : PSR12.Properties.ConstantVisibility false positive when using public final const syntax - -- Thanks to Juliette Reinders Folmer 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 for the patch - - Fixed bug #3546 : Tokenizer/PHP: bug fix - parent/static keywords in class instantiations - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3550 : False positive from PSR2.ControlStructures.SwitchDeclaration.TerminatingComment when using trailing comment - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3575: Squiz.Scope.MethodScope misses visibility keyword on previous line - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3604: Tokenizer/PHP: bug fix for double quoted strings using ${ - -- Thanks to Juliette Reinders Folmer for the patch - - - - - 3.6.2 - 3.6.2 - - - stable - stable - - 2021-12-13 - BSD License - - - Processing large code bases that use tab indenting inside comments and strings will now be faster - -- Thanks to Thiemo Kreuz for the patch - - Fixed bug #3388 : phpcs does not work when run from WSL drives - -- Thanks to Juliette Reinders Folmer and Graham Wharton for the patch - - Fixed bug #3422 : Squiz.WhiteSpace.ScopeClosingBrace fixer removes HTML content when fixing closing brace alignment - -- Thanks to Juliette Reinders Folmer 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 for the patch - - Fixed bug #3448 : PHP 8.1 deprecation notice while generating running time value - -- Thanks to Juliette Reinders Folmer and Andy Postnikov for the patch - - Fixed bug #3456 : PSR12.Classes.ClassInstantiation.MissingParentheses false positive using attributes on anonymous class - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3460 : Generic.Formatting.MultipleStatementAlignment false positive on closure with parameters - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3468 : do/while loops are double-counted in Generic.Metrics.CyclomaticComplexity - -- Thanks to Mark Baker for the patch - - Fixed bug #3469 : Ternary Operator and Null Coalescing Operator are not counted in Generic.Metrics.CyclomaticComplexity - -- Thanks to Mark Baker for the patch - - Fixed bug #3472 : PHP 8 match() expression is not counted in Generic.Metrics.CyclomaticComplexity - -- Thanks to Mark Baker for the patch - - - - - 3.6.1 - 3.6.1 - - - stable - stable - - 2021-10-11 - BSD License - - - PHPCS annotations can now be specified using hash-style comments - -- Previously, only slash-style and block-style comments could be used to do things like disable errors - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed an issue where some sniffs would not run on PHP files that only used the short echo tag - -- The following sniffs were affected: - --- Generic.Files.ExecutableFile - --- Generic.Files.LowercasedFilename - --- Generic.Files.LineEndings - --- Generic.Files.EndFileNewline - --- Generic.Files.EndFileNoNewline - --- Generic.PHP.ClosingPHPTag - --- Generic.PHP.Syntax - --- Generic.VersionControl.GitMergeConflict - --- Generic.WhiteSpace.DisallowSpaceIndent - --- Generic.WhiteSpace.DisallowTabIndent - -- Thanks to Juliette Reinders Folmer for the patch - - The new PHP 8.1 tokenisation for ampersands has been reverted to use the existing PHP_CodeSniffer method - -- The PHP 8.1 tokens T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG and T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG are unsued - -- Ampersands continue to be tokenized as T_BITWISE_AND for all PHP versions - -- Thanks to Juliette Reinders Folmer and Anna Filina for the patch - - File::getMethodParameters() no longer incorrectly returns argument attributes in the type hint array index - -- A new has_attributes array index is available and set to TRUE if the argument has attributes defined - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.NamingConventions.ConstructorName no longer throws deprecation notices on PHP 8.1 - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.BlockComment now correctly applies rules for block comments after a short echo tag - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed false positives when using attributes in the following sniffs: - -- PEAR.Commenting.FunctionComment - -- Squiz.Commenting.InlineComment - -- Squiz.Commenting.BlockComment - -- Squiz.Commenting.VariableComment - -- Squiz.WhiteSpace.MemberVarSpacing - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3294 : Bug in attribute tokenization when content contains PHP end token or attribute closer on new line - -- Thanks to Alessandro Chitolina for the patch - -- Thanks to Juliette Reinders Folmer for the tests - - Fixed bug #3296 : PSR2.ControlStructures.SwitchDeclaration takes phpcs:ignore as content of case body - - Fixed bug #3297 : PSR2.ControlStructures.SwitchDeclaration.TerminatingComment does not handle try/finally blocks - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3302 : PHP 8.0 | Tokenizer/PHP: bugfix for union types using namespace operator - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3303 : findStartOfStatement() doesn't work with T_OPEN_TAG_WITH_ECHO - - Fixed bug #3316 : Arrow function not tokenized correctly when using null in union type - - Fixed bug #3317 : Problem with how phpcs handles ignored files when running in parallel - -- Thanks to Emil Andersson for the patch - - Fixed bug #3324 : PHPCS hangs processing some nested arrow functions inside a function call - - Fixed bug #3326 : Generic.Formatting.MultipleStatementAlignment error with const DEFAULT - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3333 : Squiz.Objects.ObjectInstantiation: null coalesce operators are not recognized as assignment - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3340 : Ensure interface and trait names are always tokenized as T_STRING - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3342 : PSR12/Squiz/PEAR standards all error on promoted properties with docblocks - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3345 : IF statement with no braces and double catch turned into syntax error by auto-fixer - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3352 : PSR2.ControlStructures.SwitchDeclaration can remove comments on the same line as the case statement while fixing - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3357 : Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3362 : Generic.WhiteSpace.ScopeIndent false positive for arrow functions inside arrays - - Fixed bug #3384 : Squiz.Commenting.FileComment.SpacingAfterComment false positive on empty file - - Fixed bug #3394 : Fix PHP 8.1 auto_detect_line_endings deprecation notice - - Fixed bug #3400 : PHP 8.1: prevent deprecation notices about missing return types - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3424 : PHPCS fails when using PHP 8 Constructor property promotion with attributes - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3425 : PHP 8.1 | Runner::processChildProcs(): fix passing null to non-nullable bug - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3445 : Nullable parameter after attribute incorrectly tokenized as ternary operator - -- Thanks to Juliette Reinders Folmer for the patch - - - - - 3.6.0 - 3.6.0 - - - stable - stable - - 2021-04-09 - BSD License - - - Added support for PHP 8.0 union types - -- A new T_TYPE_UNION token is available to represent the pipe character - -- File::getMethodParameters(), getMethodProperties(), and getMemberProperties() will now return union types - -- Thanks to Juliette Reinders Folmer for the patch - - Added support for PHP 8.0 named function call arguments - -- A new T_PARAM_NAME token is available to represent the label with the name of the function argument in it - -- Thanks to Juliette Reinders Folmer for the patch - - Added support for PHP 8.0 attributes - -- The PHP-supplied T_ATTRIBUTE token marks the start of an attribute - -- A new T_ATTRIBUTE_END token is available to mark the end of an attribute - -- New attribute_owner and attribute_closer indexes are available in the tokens array for all tokens inside an attribute - -- Tokenizing of attributes has been backfilled for older PHP versions - -- The following sniffs have been updated to support attributes: - --- PEAR.Commenting.ClassComment - --- PEAR.Commenting.FileComment - --- PSR1.Files.SideEffects - --- PSR12.Files.FileHeader - --- Squiz.Commenting.ClassComment - --- Squiz.Commenting.FileComment - --- Squiz.WhiteSpace.FunctionSpacing - ---- Thanks to Vadim Borodavko for the patch - -- Thanks to Alessandro Chitolina for the patch - - Added support for PHP 8.0 dereferencing of text strings with interpolated variables - -- Thanks to Juliette Reinders Folmer for the patch - - Added support for PHP 8.0 match expressions - -- Match expressions are now tokenised with parenthesis and scope openers and closers - --- Sniffs can listen for the T_MATCH token to process match expressions - --- Note that the case and default statements inside match expressions do not have scopes set - -- A new T_MATCH_ARROW token is available to represent the arrows in match expressions - -- A new T_MATCH_DEFAULT token is available to represent the default keyword in match expressions - -- All tokenizing of match expressions has been backfilled for older PHP versions - -- The following sniffs have been updated to support match expressions: - --- Generic.CodeAnalysis.AssignmentInCondition - --- Generic.CodeAnalysis.EmptyPHPStatement - ---- Thanks to Vadim Borodavko for the patch - --- Generic.CodeAnalysis.EmptyStatement - --- Generic.PHP.LowerCaseKeyword - --- PEAR.ControlStructures.ControlSignature - --- PSR12.ControlStructures.BooleanOperatorPlacement - --- Squiz.Commenting.LongConditionClosingComment - --- Squiz.Commenting.PostStatementComment - --- Squiz.ControlStructures.LowercaseDeclaration - --- Squiz.ControlStructures.ControlSignature - --- Squiz.Formatting.OperatorBracket - --- Squiz.PHP.DisallowMultipleAssignments - --- Squiz.Objects.ObjectInstantiation - --- Squiz.WhiteSpace.ControlStructureSpacing - -- Thanks to Juliette Reinders Folmer for the patch - - The value of the T_FN_ARROW token has changed from "T_FN_ARROW" to "PHPCS_T_FN_ARROW" to avoid package conflicts - -- This will have no impact on custom sniffs unless they are specifically looking at the value of the T_FN_ARROW constant - -- If sniffs are just using constant to find arrow functions, they will continue to work without modification - -- Thanks to Juliette Reinders Folmer for the patch - - File::findStartOfStatement() now works correctly when passed the last token in a statement - - File::getMethodParameters() now supports PHP 8.0 constructor property promotion - -- Returned method params now include a "property_visibility" and "visibility_token" index if property promotion is detected - -- Thanks to Juliette Reinders Folmer for the patch - - File::getMethodProperties() now includes a "return_type_end_token" index in the return value - -- This indicates the last token in the return type, which is helpful when checking union types - -- Thanks to Juliette Reinders Folmer for the patch - - Include patterns are now ignored when processing STDIN - -- Previously, checks using include patterns were excluded when processing STDIN when no file path was provided via --stdin-path - -- Now, all include and exclude rules are ignored when no file path is provided, allowing all checks to run - -- If you want include and exclude rules enforced when checking STDIN, use --stdin-path to set the file path - -- Thanks to Juliette Reinders Folmer for the patch - - Spaces are now correctly escaped in the paths to external on Windows - -- Thanks to Juliette Reinders Folmer for the patch - - Added Generic.NamingConventions.AbstractClassNamePrefix to enforce that class names are prefixed with "Abstract" - -- Thanks to Anna Borzenko for the contribution - - Added Generic.NamingConventions.InterfaceNameSuffix to enforce that interface names are suffixed with "Interface" - -- Thanks to Anna Borzenko for the contribution - - Added Generic.NamingConventions.TraitNameSuffix to enforce that trait names are suffixed with "Trait" - -- Thanks to Anna Borzenko for the contribution - - Generic.CodeAnalysis.UnusedFunctionParameter can now be configured to ignore variable usage for specific type hints - -- This allows you to suppress warnings for some variables that are not required, but leave warnings for others - -- Set the ignoreTypeHints array property to a list of type hints to ignore - -- Thanks to Petr Bugyík for the patch - - Generic.Formatting.MultipleStatementAlignment can now align statements at the start of the assignment token - -- Previously, the sniff enforced that the values were aligned, even if this meant the assignment tokens were not - -- Now, the sniff can enforce that the assignment tokens are aligned, even if this means the values are not - -- Set the "alignAtEnd" sniff property to "false" to align the assignment tokens - -- The default remains at "true", so the assigned values are aligned - -- Thanks to John P. Bloch for the patch - - Generic.PHP.LowerCaseType now supports checking of typed properties - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.PHP.LowerCaseType now supports checking of union types - -- Thanks to Juliette Reinders Folmer for the patch - - PEAR.Commenting.FunctionComment and Squiz.Commenting.FunctionComment sniffs can now ignore private and protected methods - -- Set the "minimumVisibility" sniff property to "protected" to ignore private methods - -- Set the "minimumVisibility" sniff property to "public" to ignore both private and protected methods - -- The default remains at "private", so all methods are checked - -- Thanks to Vincent Langlet for the patch - - PEAR.Commenting.FunctionComment and Squiz.Commenting.FunctionComment sniffs can now ignore return tags in any method - -- Previously, only __construct and __destruct were ignored - -- Set the list of method names to ignore in the "specialMethods" sniff property - -- The default remains at "__construct" and "__destruct" only - -- Thanks to Vincent Langlet for the patch - - PSR2.ControlStructures.SwitchDeclaration now supports nested switch statements where every branch terminates - -- Previously, if a CASE only contained a SWITCH and no direct terminating statement, a fall-through error was displayed - -- Now, the error is surpressed if every branch of the SWITCH has a terminating statement - -- Thanks to Vincent Langlet for the patch - - The PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket error message is now reported on the closing parenthesis token - -- Previously, the error was being reported on the function keyword, leading to confusing line numbers in the error report - - Squiz.Commenting.FunctionComment is now able to ignore function comments that are only inheritdoc statements - -- Set the skipIfInheritdoc sniff property to "true" to skip checking function comments if the content is only {@inhertidoc} - -- The default remains at "false", so these comments will continue to report errors - -- Thanks to Jess Myrbo for the patch - - Squiz.Commenting.FunctionComment now supports the PHP 8 mixed type - -- Thanks to Vadim Borodavko for the patch - - Squiz.PHP.NonExecutableCode now has improved handling of syntax errors - -- Thanks to Thiemo Kreuz for the patch - - Squiz.WhiteSpace.ScopeKeywordSpacing now checks spacing when using PHP 8.0 constructor property promotion - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed an issue that could occurr when checking files on network drives, such as with WSL2 on Windows 10 - -- This works around a long-standing PHP bug with is_readable() - -- Thanks to Michael S for the patch - - Fixed a number of false positives in the Squiz.PHP.DisallowMultipleAssignments sniff - -- Sniff no longer errors for default value assignments in arrow functions - -- Sniff no longer errors for assignments on first line of closure - -- Sniff no longer errors for assignments after a goto label - -- Thanks to Jaroslav Hanslík for the patch - - Fixed bug #2913 : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional - - Fixed bug #2992 : Enabling caching using a ruleset produces invalid cache files when using --sniffs and --exclude CLI args - - Fixed bug #3003 : Squiz.Formatting.OperatorBracket autofix incorrect when assignment used with null coalescing operator - - Fixed bug #3145 : Autoloading of sniff fails when multiple classes declared in same file - - Fixed bug #3157 : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented - - Fixed bug #3163 : Undefined index error with pre-commit hook using husky on PHP 7.4 - -- Thanks to Ismo Vuorinen for the patch - - Fixed bug #3165 : Squiz.PHP.DisallowComparisonAssignment false positive when comparison inside closure - - Fixed bug #3167 : Generic.WhiteSpace.ScopeIndent false positive when using PHP 8.0 constructor property promotion - - Fixed bug #3170 : Squiz.WhiteSpace.OperatorSpacing false positive when using negation with string concat - -- This also fixes the same issue in the PSR12.Operators.OperatorSpacing sniff - - Fixed bug #3177 : Incorrect tokenization of GOTO statements in mixed PHP/HTML files - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3184 : PSR2.Namespace.NamespaceDeclaration false positive on namespace operator - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3188 : Squiz.WhiteSpace.ScopeKeywordSpacing false positive for static return type - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3192 : findStartOfStatement doesn't work correctly inside switch - -- Thanks to Vincent Langlet for the patch - - Fixed bug #3195 : Generic.WhiteSpace.ScopeIndent confusing message when combination of tabs and spaces found - - Fixed bug #3197 : Squiz.NamingConventions.ValidVariableName does not use correct error code for all member vars - - Fixed bug #3219 : Generic.Formatting.MultipleStatementAlignment false positive for empty anonymous classes and closures - - Fixed bug #3258 : Squiz.Formatting.OperatorBracket duplicate error messages for unary minus - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3273 : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis - - Fixed bug #3277 : Nullable static return typehint causes whitespace error - - Fixed bug #3284 : Unused parameter false positive when using array index in arrow function - - - - - 3.5.8 - 3.5.8 - - - stable - stable - - 2020-10-23 - BSD License - - - Reverted a change to the way include/exclude patterns are processed for STDIN content - -- This change is not backwards compatible and will be re-introduced in version 3.6.0 - - - - - 3.5.7 - 3.5.7 - - - stable - stable - - 2020-10-23 - BSD License - - - The PHP 8.0 T_NULLSAFE_OBJECT_OPERATOR token has been made available for older versions - -- Existing sniffs that check for T_OBJECT_OPERATOR have been modified to apply the same rules for the nullsafe object operator - -- Thanks to Juliette Reinders Folmer for the patch - - The new method of PHP 8.0 tokenizing for namespaced names has been reverted to the pre 8.0 method - -- This maintains backwards compatibility for existing sniffs on PHP 8.0 - -- This change will be removed in PHPCS 4.0 as the PHP 8.0 tokenizing method will be backported for pre 8.0 versions - -- Thanks to Juliette Reinders Folmer for the patch - - Added support for changes to the way PHP 8.0 tokenizes hash comments - -- The existing PHP 5-7 behaviour has been replicated for version 8, so no sniff changes are required - -- Thanks to Juliette Reinders Folmer for the patch - - The autoloader has been changed to fix sniff class name detection issues that may occur when running on PHP 7.4+ - -- Thanks to Eloy Lafuente for the patch - - Running the unit tests now includes warnings in the found and fixable error code counts - -- Thanks to Juliette Reinders Folmer for the patch - - PSR12.ControlStructures.BooleanOperatorPlacement.FoundMixed error message is now more accurate when using the allowOnly setting - -- Thanks to Vincent Langlet for the patch - - PSR12.Functions.NullableTypeDeclaration now supports the PHP8 static return type - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed Squiz.Formatting.OperatorBracket false positive when exiting with a negative number - - Fixed Squiz.PHP.DisallowComparisonAssignment false positive for methods called on an object - - Fixed bug #2882 : Generic.Arrays.ArrayIndent can request close brace indent to be less than the statement indent level - - Fixed bug #2883 : Generic.WhiteSpace.ScopeIndent.Incorrect issue after NOWDOC - - Fixed bug #2975 : Undefined offset in PSR12.Functions.ReturnTypeDeclaration when checking function return type inside ternary - - Fixed bug #2988 : Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding - -- Thanks to Thiemo Kreuz for the patch - - Fixed bug #2989 : Incorrect auto-fixing in Generic.ControlStructures.InlineControlStructure during live coding - -- Thanks to Thiemo Kreuz for the patch - - Fixed bug #3007 : Directory exclude pattern improperly excludes directories with names that start the same - -- Thanks to Steve Talbot for the patch - - Fixed bug #3043 : Squiz.WhiteSpace.OperatorSpacing false positive for negation in arrow function - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3049 : Incorrect error with arrow function and parameter passed as reference - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3053 : PSR2 incorrect fix when multiple use statements on same line do not have whitespace between them - - Fixed bug #3058 : Progress gets unaligned when 100% happens at the end of the available dots - - Fixed bug #3059 : Squiz.Arrays.ArrayDeclaration false positive when using type casting - -- Thanks to Sergei Morozov for the patch - - Fixed bug #3060 : Squiz.Arrays.ArrayDeclaration false positive for static functions - -- Thanks to Sergei Morozov for the patch - - Fixed bug #3065 : Should not fix Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma if comment between element and comma - -- Thanks to Sergei Morozov for the patch - - Fixed bug #3066 : No support for namespace operator used in type declarations - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3075 : PSR12.ControlStructures.BooleanOperatorPlacement false positive when operator is the only content on line - - Fixed bug #3099 : Squiz.WhiteSpace.OperatorSpacing false positive when exiting with negative number - -- Thanks to Sergei Morozov for the patch - - Fixed bug #3102 : PSR12.Squiz.OperatorSpacing false positive for default values of arrow functions - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #3124 : PSR-12 not reporting error for empty lines with only whitespace - - Fixed bug #3135 : Ignore annotations are broken on PHP 8.0 - -- Thanks to Juliette Reinders Folmer for the patch - - - - - 3.5.6 - 3.5.6 - - - stable - stable - - 2020-08-10 - BSD License - - - Added support for PHP 8.0 magic constant dereferencing - -- Thanks to Juliette Reinders Folmer for the patch - - Added support for changes to the way PHP 8.0 tokenizes comments - -- The existing PHP 5-7 behaviour has been replicated for version 8, so no sniff changes are required - -- Thanks to Juliette Reinders Folmer for the patch - - File::getMethodProperties() now detects the PHP 8.0 static return type - -- Thanks to Juliette Reinders Folmer for the patch - - The PHP 8.0 static return type is now supported for arrow functions - -- Thanks to Juliette Reinders Folmer for the patch - - The cache is no longer used if the list of loaded PHP extensions changes - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.NamingConventions.CamelCapsFunctionName no longer reports __serialize and __unserialize as invalid names - -- Thanks to Filip Å  for the patch - - PEAR.NamingConventions.ValidFunctionName no longer reports __serialize and __unserialize as invalid names - -- Thanks to Filip Å  for the patch - - Squiz.Scope.StaticThisUsage now detects usage of $this inside closures and arrow Functions - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #2877 : PEAR.Functions.FunctionCallSignature false positive for array of functions - -- Thanks to Vincent Langlet for the patch - - Fixed bug #2888 : PSR12.Files.FileHeader blank line error with multiple namespaces in one file - - Fixed bug #2926 : phpcs hangs when using arrow functions that return heredoc - - Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed - - Fixed bug #2967 : Markdown generator does not output headings correctly - -- Thanks to Petr Bugyík for the patch - - Fixed bug #2977 : File::isReference() does not detect return by reference for closures - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2994 : Generic.Formatting.DisallowMultipleStatements false positive for FOR loop with no body - - Fixed bug #3033 : Error generated during tokenizing of goto statements on PHP 8 - -- Thanks to Juliette Reinders Folmer for the patch - - - - - 3.5.5 - 3.5.5 - - - stable - stable - - 2020-04-17 - BSD License - - - The T_FN backfill now works more reliably so T_FN tokens only ever represent real arrow functions - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed an issue where including sniffs using paths containing multiple dots would silently fail - - Generic.CodeAnalysis.EmptyPHPStatement now detects empty statements at the start of control structures - - Error wording in PEAR.Functions.FunctionCallSignature now always uses "parenthesis" instead of sometimes using "bracket" - -- Thanks to Vincent Langlet for the patch - - Fixed bug #2787 : Squiz.PHP.DisallowMultipleAssignments not ignoring typed property declarations - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2810 : PHPCBF fails to fix file with empty statement at start on control structure - - Fixed bug #2812 : Squiz.Arrays.ArrayDeclaration not detecting some arrays with multiple arguments on the same line - -- Thanks to Jakub Chábek for the patch - - Fixed bug #2826 : Generic.WhiteSpace.ArbitraryParenthesesSpacing doesn't detect issues for statements directly after a control structure - -- Thanks to Vincent Langlet for the patch - - Fixed bug #2848 : PSR12.Files.FileHeader false positive for file with mixed PHP and HTML and no file header - - Fixed bug #2849 : Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array - - Fixed bug #2850 : Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase - - Fixed bug #2853 : Undefined variable error when using Info report - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2865 : Double arrow tokenized as T_STRING when placed after function named "fn" - - Fixed bug #2867 : Incorrect scope matching when arrow function used inside IF condition - - Fixed bug #2868 : phpcs:ignore annotation doesnt work inside a docblock - - Fixed bug #2878 : PSR12.Files.FileHeader conflicts with Generic.Files.LineEndings - - Fixed bug #2895 : PSR2.Methods.FunctionCallSignature.MultipleArguments false positive with arrow function argument - - - - - 3.5.4 - 3.5.4 - - - stable - stable - - 2020-01-31 - BSD License - - - The PHP 7.4 numeric separator backfill now works correctly for more float formats - -- Thanks to Juliette Reinders Folmer for the patch - - The PHP 7.4 numeric separator backfill is no longer run on PHP version 7.4.0 or greater - - File::getCondition() now accepts a 3rd argument that allows for the closest matching token to be returned - -- By default, it continues to return the first matched token found from the top of the file - - Fixed detection of array return types for arrow functions - - Added Generic.PHP.DisallowRequestSuperglobal to ban the use of the $_REQUEST superglobal - -- Thanks to Morerice for the contribution - - Generic.ControlStructures.InlineControlStructure no longer shows errors for WHILE and FOR statements without a body - -- Previously it required these to have curly braces, but there were no statements to enclose in them - -- Thanks to Juliette Reinders Folmer for the patch - - PSR12.ControlStructures.BooleanOperatorPlacement can now be configured to enforce a specific operator position - -- By default, the sniff ensures that operators are all at the begining or end of lines, but not a mix of both - -- Set the allowOnly property to "first" to enforce all boolean operators to be at the start of a line - -- Set the allowOnly property to "last" to enforce all boolean operators to be at the end of a line - -- Thanks to Vincent Langlet for the patch - - PSR12.Files.ImportStatement now auto-fixes import statements by removing the leading slash - -- Thanks to MichaÅ‚ Bundyra for the patch - - Squiz.ControlStructures.ForLoopDeclaration now has a setting to ignore newline characters - -- Default remains FALSE, so newlines are not allowed within FOR definitions - -- Override the "ignoreNewlines" setting in a ruleset.xml file to change - - Squiz.PHP.InnerFunctions now handles multiple nested anon classes correctly - - Fixed bug #2497 : Sniff properties not set when referencing a sniff using relative paths or non-native slashes - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2657 : Squiz.WhiteSpace.FunctionSpacing can remove spaces between comment and first/last method during auto-fixing - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2688 : Case statements not tokenized correctly when switch is contained within ternary - - Fixed bug #2698 : PHPCS throws errors determining auto report width when shell_exec is disabled - -- Thanks to Matthew Peveler for the patch - - Fixed bug #2730 : PSR12.ControlStructures.ControlStructureSpacing does not ignore comments between conditions - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2732 : PSR12.Files.FileHeader misidentifies file header in mixed content file - - Fixed bug #2745 : AbstractArraySniff wrong indices when mixed coalesce and ternary values - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #2748 : Wrong end of statement for fn closures - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #2751 : Autoload relative paths first to avoid confusion with files from the global include path - -- Thanks to Klaus Purer for the patch - - Fixed bug #2763 : PSR12 standard reports errors for multi-line FOR definitions - - Fixed bug #2768 : Generic.Files.LineLength false positive for non-breakable strings at exactly the soft limit - -- Thanks to Alex Miles for the patch - - Fixed bug #2773 : PSR2.Methods.FunctionCallSignature false positive when arrow function has array return type - - Fixed bug #2790 : PSR12.Traits.UseDeclaration ignores block comments - -- Thanks to Vincent Langlet for the patch - - Fixed bug #2791 : PSR12.Functions.NullableTypeDeclaration false positive when ternary operator used with instanceof - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2802 : Can't specify a report file path using the tilde shortcut - - Fixed bug #2804 : PHP4-style typed properties not tokenized correctly - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2805 : Undefined Offset notice during live coding of arrow functions - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2843 : Tokenizer does not support alternative syntax for declare statements - -- Thanks to Juliette Reinders Folmer for the patch - - - - - 3.5.3 - 3.5.3 - - - stable - stable - - 2019-12-04 - BSD License - - - The PHP 7.4 T_FN token has been made available for older versions - -- T_FN represents the fn string used for arrow functions - -- The double arrow becomes the scope opener, and uses a new T_FN_ARROW token type - -- The token after the statement (normally a semicolon) becomes the scope closer - -- The token is also associated with the opening and closing parenthesis of the statement - -- Any functions named "fn" will cause have a T_FN token for the function name, but have no scope information - -- Thanks to MichaÅ‚ Bundyra for the help with this change - - PHP 7.4 numeric separators are now tokenized in the same way when using older PHP versions - -- Previously, a number like 1_000 would tokenize as T_LNUMBER (1), T_STRING (_000) - -- Now, the number tokenizes as T_LNUMBER (1_000) - -- Sniff developers should consider how numbers with underscores impact their custom sniffs - - The PHPCS file cache now takes file permissions into account - -- The cache is now invalidated for a file when its permissions are changed - - File::getMethodParameters() now supports arrow functions - - File::getMethodProperties() now supports arrow functions - - Added Fixer::changeCodeBlockIndent() to change the indent of a code block while auto-fixing - -- Can be used to either increase or decrease the indent - -- Useful when moving the start position of something like a closure, where you want the content to also move - - Added Generic.Files.ExecutableFile sniff - -- Ensures that files are not executable - -- Thanks to Matthew Peveler for the contribution - - Generic.CodeAnalysis.EmptyPhpStatement now reports unnecessary semicolons after control structure closing braces - -- Thanks to Vincent Langlet for the patch - - Generic.PHP.LowerCaseKeyword now enforces that the "fn" keyword is lowercase - -- Thanks to MichaÅ‚ Bundyra for the patch - - Generic.WhiteSpace.ScopeIndent now supports static arrow functions - - PEAR.Functions.FunctionCallSignature now adjusts the indent of function argument contents during auto-fixing - -- Previously, only the first line of an argument was changed, leading to inconsistent indents - -- This change also applies to PSR2.Methods.FunctionCallSignature - - PSR2.ControlStructures.ControlStructureSpacing now checks whitespace before the closing parenthesis of multi-line control structures - -- Previously, it incorrectly applied the whitespace check for single-line definitions only - - PSR12.Functions.ReturnTypeDeclaration now checks the return type of arrow functions - -- Thanks to MichaÅ‚ Bundyra for the patch - - PSR12.Traits.UseDeclaration now ensures all trait import statements are grouped together - -- Previously, the trait import section of the class ended when the first non-import statement was found - -- Checking now continues throughout the class to ensure all statements are grouped together - -- This also ensures that empty lines are not requested after an import statement that isn't the last one - - Squiz.Functions.LowercaseFunctionKeywords now enforces that the "fn" keyword is lowercase - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #2586 : Generic.WhiteSpace.ScopeIndent false positives when indenting open tags at a non tab-stop - - Fixed bug #2638 : Squiz.CSS.DuplicateClassDefinitionSniff sees comments as part of the class name - -- Thanks to Raphael Horber for the patch - - Fixed bug #2640 : Squiz.WhiteSpace.OperatorSpacing false positives for some negation operators - -- Thanks to Jakub Chábek and Juliette Reinders Folmer for the patch - - Fixed bug #2674 : Squiz.Functions.FunctionDeclarationArgumentSpacing prints wrong argument name in error message - - Fixed bug #2676 : PSR12.Files.FileHeader locks up when file ends with multiple inline comments - - Fixed bug #2678 : PSR12.Classes.AnonClassDeclaration incorrectly enforcing that closing brace be on a line by itself - - Fixed bug #2685 : File::getMethodParameters() setting typeHintEndToken for vars with no type hint - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2694 : AbstractArraySniff produces invalid indices when using ternary operator - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #2702 : Generic.WhiteSpace.ScopeIndent false positive when using ternary operator with short arrays - - - - - 3.5.2 - 3.5.2 - - - stable - stable - - 2019-10-28 - BSD License - - - Generic.ControlStructures.DisallowYodaConditions now returns less false positives - -- False positives were being returned for array comparisions, or when performing some function calls - - Squiz.WhiteSpace.SemicolonSpacing.Incorrect error message now escapes newlines and tabs - -- Provides a clearer error message as whitespace is now visible - -- Also allows for better output for report types such as CSV and XML - - The error message for PSR12.Files.FileHeader.SpacingAfterBlock has been made clearer - -- It now uses the wording from the published PSR-12 standard to indicate that blocks must be separated by a blank line - -- Thanks to Craig Duncan for the patch - - Fixed bug #2654 : Incorrect indentation for arguments of multiline function calls - - Fixed bug #2656 : Squiz.WhiteSpace.MemberVarSpacing removes comments before first member var during auto fixing - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2663 : Generic.NamingConventions.ConstructorName complains about old constructor in interfaces - - Fixed bug #2664 : PSR12.Files.OpenTag incorrectly identifies PHP file with only an opening tag - - Fixed bug #2665 : PSR12.Files.ImportStatement should not apply to traits - - Fixed bug #2673 : PSR12.Traits.UseDeclaration does not allow comments or blank lines between use statements - - - - - 3.5.1 - 3.5.1 - - - stable - stable - - 2019-10-17 - BSD License - - - Very very verbose diff report output has slightly changed to improve readability - -- Output is printed when running PHPCS with the --report=diff and -vvv command line arguments - -- Fully qualified class names have been replaced with sniff codes - -- Tokens being changed now display the line number they are on - - PSR2, PSR12, and PEAR standards now correctly check for blank lines at the start of function calls - -- This check has been missing from these standards, but has now been implemented - -- When using the PEAR standard, the error code is PEAR.Functions.FunctionCallSignature.FirstArgumentPosition - -- When using PSR2 or PSR12, the error code is PSR2.Methods.FunctionCallSignature.FirstArgumentPosition - - PSR12.ControlStructures.BooleanOperatorPlacement no longer complains when multiple expression appears on the same line - -- Previously, boolean operators were enforce to appear at the start or end of lines only - -- Boolean operators can now appear in the middle of the line - - PSR12.Files.FileHeader no longer ignores comments preceding a use, namespace, or declare statement - - PSR12.Files.FileHeader now allows a hashbang line at the top of the file - - Fixed bug #2506 : PSR2 standard can't auto fix multi-line function call inside a string concat statement - - Fixed bug #2530 : PEAR.Commenting.FunctionComment does not support intersection types in comments - - Fixed bug #2615 : Constant visibility false positive on non-class constants - - Fixed bug #2616 : PSR12.Files.FileHeader false positive when file only contains docblock - - Fixed bug #2619 : PSR12.Files.FileHeader locks up when inline comment is the last content in a file - - Fixed bug #2621 : PSR12.Classes.AnonClassDeclaration.CloseBraceSameLine false positive for anon class passed as function argument - -- Thanks to Martins Sipenko for the patch - - Fixed bug #2623 : PSR12.ControlStructures.ControlStructureSpacing not ignoring indentation inside multi-line string arguments - - Fixed bug #2624 : PSR12.Traits.UseDeclaration doesnt apply the correct indent during auto fixing - - Fixed bug #2626 : PSR12.Files.FileHeader detects @var annotations as file docblocks - - Fixed bug #2628 : PSR12.Traits.UseDeclaration does not allow comments above a USE declaration - - Fixed bug #2632 : Incorrect indentation of lines starting with "static" inside closures - - Fixed bug #2641 : PSR12.Functions.NullableTypeDeclaration false positive when using new static() - - - - - 3.5.0 - 3.5.0 - - - stable - stable - - 2019-09-27 - BSD License - - - The included PSR12 standard is now complete and ready to use - -- Check your code using PSR-12 by running PHPCS with --standard=PSR12 - - Added support for PHP 7.4 typed properties - -- The nullable operator is now tokenized as T_NULLABLE inside property types, as it is elsewhere - -- To get the type of a member var, use the File::getMemberProperties() method, which now contains a "type" array index - --- This contains the type of the member var, or a blank string if not specified - --- If the type is nullable, the return type will contain the leading ? - --- If a type is specified, the position of the first token in the type will be set in a "type_token" array index - --- If a type is specified, the position of the last token in the type will be set in a "type_end_token" array index - --- If the type is nullable, a "nullable_type" array index will also be set to TRUE - --- If the type contains namespace information, it will be cleaned of whitespace and comments in the return value - - The PSR1 standard now correctly bans alternate PHP tags - -- Previously, it only banned short open tags and not the pre-7.0 alternate tags - - Added support for only checking files that have been locally staged in a git repo - -- Use --filter=gitstaged to check these files - -- You still need to give PHPCS a list of files or directories in which to apply the filter - -- Thanks to Juliette Reinders Folmer for the contribution - - JSON reports now end with a newline character - - The phpcs.xsd schema now validates phpcs-only and phpcbf-only attributes correctly - -- Thanks to Juliette Reinders Folmer for the patch - - The tokenizer now correctly identifies inline control structures in more cases - - All helper methods inside the File class now throw RuntimeException instead of TokenizerException - -- Some tokenizer methods were also throwing RuntimeExpection but now correctly throw TokenizerException - -- Thanks to Juliette Reinders Folmer for the patch - - The File::getMethodParameters() method now returns more information, and supports closure USE groups - -- If a type hint is specified, the position of the last token in the hint will be set in a "type_hint_end_token" array index - -- If a default is specified, the position of the first token in the default value will be set in a "default_token" array index - -- If a default is specified, the position of the equals sign will be set in a "default_equal_token" array index - -- If the param is not the last, the position of the comma will be set in a "comma_token" array index - -- If the param is passed by reference, the position of the reference operator will be set in a "reference_token" array index - -- If the param is variable length, the position of the variadic operator will be set in a "variadic_token" array index - - The T_LIST token and it's opening and closing parentheses now contain references to each other in the tokens array - -- Uses the same parenthesis_opener/closer/owner indexes as other tokens - -- Thanks to Juliette Reinders Folmer for the patch - - The T_ANON_CLASS token and it's opening and closing parentheses now contain references to each other in the tokens array - -- Uses the same parenthesis_opener/closer/owner indexes as other tokens - -- Only applicable if the anon class is passing arguments to the constructor - -- Thanks to Juliette Reinders Folmer for the patch - - The PHP 7.4 T_BAD_CHARACTER token has been made available for older versions - -- Allows you to safely look for this token, but it will not appear unless checking with PHP 7.4+ - - Metrics are now available for Squiz.WhiteSpace.FunctionSpacing - -- Use the "info" report to see blank lines before/after functions - -- Thanks to Juliette Reinders Folmer for the patch - - Metrics are now available for Squiz.WhiteSpace.MemberVarSpacing - -- Use the "info" report to see blank lines before member vars - -- Thanks to Juliette Reinders Folmer for the patch - - Added Generic.ControlStructures.DisallowYodaConditions sniff - -- Ban the use of Yoda conditions - -- Thanks to Mponos George for the contribution - - Added Generic.PHP.RequireStrictTypes sniff - -- Enforce the use of a strict types declaration in PHP files - - Added Generic.WhiteSpace.SpreadOperatorSpacingAfter sniff - -- Checks whitespace between the spread operator and the variable/function call it applies to - -- Thanks to Juliette Reinders Folmer for the contribution - - Added PSR12.Classes.AnonClassDeclaration sniff - -- Enforces the formatting of anonymous classes - - Added PSR12.Classes.ClosingBrace sniff - -- Enforces that closing braces of classes/interfaces/traits/functions are not followed by a comment or statement - - Added PSR12.ControlStructures.BooleanOperatorPlacement sniff - -- Enforces that boolean operators between conditions are consistently at the start or end of the line - - Added PSR12.ControlStructures.ControlStructureSpacing sniff - -- Enforces that spacing and indents are correct inside control structure parenthesis - - Added PSR12.Files.DeclareStatement sniff - -- Enforces the formatting of declare statements within a file - - Added PSR12.Files.FileHeader sniff - -- Enforces the order and formatting of file header blocks - - Added PSR12.Files.ImportStatement sniff - -- Enforces the formatting of import statements within a file - - Added PSR12.Files.OpenTag sniff - -- Enforces that the open tag is on a line by itself when used at the start of a php-only file - - Added PSR12.Functions.ReturnTypeDeclaration sniff - -- Enforces the formatting of return type declarations in functions and closures - - Added PSR12.Properties.ConstantVisibility sniff - -- Enforces that constants must have their visibility defined - -- Uses a warning instead of an error due to this conditionally requiring the project to support PHP 7.1+ - - Added PSR12.Traits.UseDeclaration sniff - -- Enforces the formatting of trait import statements within a class - - Generic.Files.LineLength ignoreComments property now ignores comments at the end of a line - -- Previously, this property was incorrectly causing the sniff to ignore any line that ended with a comment - -- Now, the trailing comment is not included in the line length, but the rest of the line is still checked - - Generic.Files.LineLength now only ignores unwrappable comments when the comment is on a line by itself - -- Previously, a short unwrappable comment at the end of the line would have the sniff ignore the entire line - - Generic.Functions.FunctionCallArgumentSpacing no longer checks spacing around assignment operators inside function calls - -- Use the Squiz.WhiteSpace.OperatorSpacing sniff to enforce spacing around assignment operators - --- Note that this sniff checks spacing around all assignment operators, not just inside function calls - -- The Generic.Functions.FunctionCallArgumentSpacing.NoSpaceBeforeEquals error has been removed - --- use Squiz.WhiteSpace.OperatorSpacing.NoSpaceBefore instead - -- The Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterEquals error has been removed - --- use Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter instead - -- This also changes the PEAR/PSR2/PSR12 standards so they no longer check assignment operators inside function calls - --- They were previously checking these operators when they should not have - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.WhiteSpace.ScopeIndent no longer performs exact indents checking for chained method calls - -- Other sniffs can be used to enforce chained method call indent rules - -- Thanks to Pieter Frenssen for the patch - - PEAR.WhiteSpace.ObjectOperatorIndent now supports multi-level chained statements - -- When enabled, chained calls must be indented 1 level more or less than the previous line - -- Set the new "multilevel" setting to TRUE in a ruleset.xml file to enable this behaviour - -- Thanks to Marcos Passos for the patch - - PSR2.ControlStructures.ControlStructureSpacing now allows whitespace after the opening parenthesis if followed by a comment - -- Thanks to MichaÅ‚ Bundyra for the patch - - PSR2.Classes.PropertyDeclaration now enforces a single space after a property type keyword - -- The PSR2 standard itself excludes this new check as it is not defined in the written standard - -- Using the PSR12 standard will enforce this check - - Squiz.Commenting.BlockComment no longer requires blank line before comment if it's the first content after the PHP open tag - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Functions.FunctionDeclarationArgumentSpacing now has more accurate error messages - -- This includes renaming the SpaceAfterDefault error code to SpaceAfterEquals, which reflects the real error - - Squiz.Functions.FunctionDeclarationArgumentSpacing now checks for no space after a reference operator - -- If you don't want this new behaviour, exclude the SpacingAfterReference error message in a ruleset.xml file - - Squiz.Functions.FunctionDeclarationArgumentSpacing now checks for no space after a variadic operator - -- If you don't want this new behaviour, exclude the SpacingAfterVariadic error message in a ruleset.xml file - - Squiz.Functions.MultiLineFunctionDeclaration now has improved fixing for the FirstParamSpacing and UseFirstParamSpacing errors - - Squiz.Operators.IncrementDecrementUsage now suggests pre-increment of variables instead of post-increment - -- This change does not enforce pre-increment over post-increment; only the suggestion has changed - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.PHP.DisallowMultipleAssignments now has a second error code for when assignments are found inside control structure conditions - -- The new error code is Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure - -- All other multiple assignment cases use the existing error code Squiz.PHP.DisallowMultipleAssignments.Found - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.FunctionSpacing now applies beforeFirst and afterLast spacing rules to nested functions - -- Previously, these rules only applied to the first and last function in a class, interface, or trait - -- These rules now apply to functions nested in any statement block, including other functions and conditions - - Squiz.WhiteSpace.OperatorSpacing now has improved handling of parse errors - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.OperatorSpacing now checks spacing around the instanceof operator - -- Thanks to Jakub Chábek for the patch - - Squiz.WhiteSpace.OperatorSpacing can now enforce a single space before assignment operators - -- Previously, the sniff this spacing as multiple assignment operators are sometimes aligned - -- Now, you can set the ignoreSpacingBeforeAssignments sniff property to FALSE to enable checking - -- Default remains TRUE, so spacing before assignments is not checked by default - -- Thanks to Jakub Chábek for the patch - - Fixed bug #2391 : Sniff-specific ignore rules inside rulesets are filtering out too many files - -- Thanks to Juliette Reinders Folmer and Willington Vega for the patch - - Fixed bug #2478 : FunctionCommentThrowTag.WrongNumber when exception is thrown once but built conditionally - - Fixed bug #2479 : Generic.WhiteSpace.ScopeIndent error when using array destructing with exact indent checking - - Fixed bug #2498 : Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed autofix breaks heredoc - - Fixed bug #2502 : Generic.WhiteSpace.ScopeIndent false positives with nested switch indentation and case fall-through - - Fixed bug #2504 : Generic.WhiteSpace.ScopeIndent false positives with nested arrays and nowdoc string - - Fixed bug #2511 : PSR2 standard not checking if closing paren of single-line function declaration is on new line - - Fixed bug #2512 : Squiz.PHP.NonExecutableCode does not support alternate SWITCH control structure - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2522 : Text generator throws error when code sample line is too long - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2526 : XML report format has bad syntax on Windows - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2529 : Generic.Formatting.MultipleStatementAlignment wrong error for assign in string concat - - Fixed bug #2534 : Unresolvable installed_paths can lead to open_basedir errors - -- Thanks to Oliver Nowak for the patch - - Fixed bug #2541 : Text doc generator does not allow for multi-line rule explanations - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2549 : Searching for a phpcs.xml file can throw warnings due to open_basedir restrictions - -- Thanks to Matthew Peveler for the patch - - Fixed bug #2558 : PHP 7.4 throwing offset syntax with curly braces is deprecated message - -- Thanks to Matthew Peveler for the patch - - Fixed bug #2561 : PHP 7.4 compatibility fix / implode argument order - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2562 : Inline WHILE triggers SpaceBeforeSemicolon incorrectly - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2565 : Generic.ControlStructures.InlineControlStructure confused by mixed short/long tags - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2566 : Author tag email validation doesn't support all TLDs - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2575 : Custom error messages don't have data replaced when cache is enabled - - Fixed bug #2601 : Squiz.WhiteSpace.FunctionSpacing incorrect fix when spacing is 0 - - Fixed bug #2608 : PSR2 throws errors for use statements when multiple namespaces are defined in a file - - - - - 3.4.2 - 3.4.2 - - - stable - stable - - 2019-04-11 - BSD License - - - Squiz.Arrays.ArrayDeclaration now has improved handling of syntax errors - - Fixed an issue where the PCRE JIT on PHP 7.3 caused PHPCS to die when using the parallel option - -- PHPCS now disables the PCRE JIT before running - - Fixed bug #2368 : MySource.PHP.AjaxNullComparison throws error when first function has no doc comment - - Fixed bug #2414 : Indention false positive in switch/case/if combination - - Fixed bug #2423 : Squiz.Formatting.OperatorBracket.MissingBrackets error with static - - Fixed bug #2450 : Indentation false positive when closure containing nested IF conditions used as function argument - - Fixed bug #2452 : LowercasePHPFunctions sniff failing on "new \File()" - - Fixed bug #2453 : Squiz.CSS.SemicolonSpacingSniff false positive when style name proceeded by an asterisk - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2464 : Fixer conflict between Generic.WhiteSpace.ScopeIndent and Squiz.WhiteSpace.ScopeClosingBrace when class indented 1 space - - Fixed bug #2465 : Excluding a sniff by path is not working - - Fixed bug #2467 : PHP open/close tags inside CSS files are replaced with internal PHPCS token strings when auto fixing - - - - - 3.4.1 - 3.4.1 - - - stable - stable - - 2019-03-19 - BSD License - - - The PEAR installable version of PHPCS was missing some files, which have been re-included in this release - -- The code report was not previously available for PEAR installs - -- The Generic.Formatting.SpaceBeforeCast sniff was not previously available for PEAR installs - -- The Generic.WhiteSpace.LanguageConstructSpacing sniff was not previously available for PEAR installs - -- Thanks to Juliette Reinders Folmer for the patch - - - PHPCS will now refuse to run if any of the required PHP extensions are not loaded - -- Previously, PHPCS only relied on requirements being checked by PEAR and Composer - -- Thanks to Juliette Reinders Folmer for the patch - - Ruleset XML parsing errors are now displayed in a readable format so they are easier to correct - -- Thanks to Juliette Reinders Folmer for the patch - - The PSR2 standard no longer throws duplicate errors for spacing around FOR loop parentheses - -- Thanks to Juliette Reinders Folmer for the patch - - T_PHPCS_SET tokens now contain sniffCode, sniffProperty, and sniffPropertyValue indexes - -- Sniffs can use this information instead of having to parse the token content manually - - Added more guard code for syntax errors to various CSS sniffs - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Commenting.DocComment error messages now contain the name of the comment tag that caused the error - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.ControlStructures.InlineControlStructure now handles syntax errors correctly - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Debug.JSHint now longer requires rhino and can be run directly from the npm install - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Files.LineEndings no longer adds superfluous new line at the end of JS and CSS files - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Formatting.DisallowMultipleStatements no longer tries fix lines containing phpcs:ignore statements - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Functions.FunctionCallArgumentSpacing now has improved performance and anonymous class support - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.WhiteSpace.ScopeIndent now respects changes to the "exact" property using phpcs:set mid-way through a file - -- This allows you change the "exact" rule for only some parts of a file - - Generic.WhiteSpace.ScopeIndent now disables exact indent checking inside all arrays - -- Previously, this was only done when using long array syntax, but it now works for short array syntax as well - - PEAR.Classes.ClassDeclaration now has improved handling of PHPCS annotations and tab indents - - PSR12.Classes.ClassInstantiation has changed it's error code from MissingParenthesis to MissingParentheses - - PSR12.Keywords.ShortFormTypeKeywords now ignores all spacing inside type casts during both checking and fixing - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Classes.LowercaseClassKeywords now examines the class keyword for anonymous classes - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.ControlStructures.ControlSignature now has improved handling of parse errors - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.PostStatementComment fixer no longer adds a blank line at the start of a JS file that begins with a comment - -- Fixes a conflict between this sniff and the Squiz.WhiteSpace.SuperfluousWhitespace sniff - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.PostStatementComment now ignores comments inside control structure conditions, such as FOR loops - -- Fixes a conflict between this sniff and the Squiz.ControlStructures.ForLoopDeclaration sniff - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.FunctionCommentThrowTag now has improved support for unknown exception types and namespaces - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.ControlStructures.ForLoopDeclaration has improved whitespace, closure, and empty expression support - -- The SpacingAfterSecondNoThird error code has been removed as part of these fixes - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.CSS.ClassDefinitionOpeningBraceSpace now handles comments and indentation correctly - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.CSS.ClassDefinitionClosingBrace now handles comments, indentation, and multiple statements on the same line correctly - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.CSS.Opacity now handles comments correctly - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.CSS.SemicolonSpacing now handles comments and syntax errors correctly - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.NamingConventions.ValidVariableName now supports variables inside anonymous classes correctly - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.PHP.LowercasePHPFunctions now handles use statements, namespaces, and comments correctly - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.FunctionSpacing now fixes function spacing correctly when a function is the first content in a file - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.SuperfluousWhitespace no longer throws errors for spacing between functions and properties in anon classes - -- Thanks to Juliette Reinders Folmer for the patch - - Zend.Files.ClosingTag no longer adds a semi-colon during fixing of a file that only contains a comment - -- Thanks to Juliette Reinders Folmer for the patch - - Zend.NamingConventions.ValidVariableName now supports variables inside anonymous classes correctly - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2298 : PSR2.Classes.ClassDeclaration allows extended class on new line - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #2337 : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line function call starts on same line as open tag - - Fixed bug #2348 : Cache not invalidated when changing a ruleset included by another - - Fixed bug #2376 : Using __halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it's last in the function list - -- Thanks to Sijun Zhu for the patch - - Fixed bug #2393 : The gitmodified filter will infinitely loop when encountering deleted file paths - -- Thanks to Lucas Manzke for the patch - - Fixed bug #2396 : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line IF condition mixed with HTML - - Fixed bug #2431 : Use function/const not tokenized as T_STRING when preceded by comment - - - - - 3.4.0 - 3.4.0 - - - stable - stable - - 2018-12-20 - BSD License - - - The Generic.Formatting.NoSpaceAfterCast sniff has been deprecated and will be removed in version 4 - -- The functionality of this sniff is now available in the Generic.Formatting.SpaceAfterCast sniff - --- Include the Generic.Formatting.SpaceAfterCast sniff and set the "spacing" property to "0" - -- As soon as possible, replace all instances of the old sniff code with the new sniff code and property setting - --- The existing sniff will continue to work until version 4 has been released - - - Rule include patterns in a ruleset.xml file are now evaluated as OR instead of AND - -- Previously, a file had to match every include pattern and no exclude patterns to be included - -- Now, a file must match at least one include pattern and no exclude patterns to be included - -- This is a bug fix as include patterns are already documented to work this way - - New token T_BITWISE_NOT added for the bitwise not operator - -- This token was previously tokenized as T_NONE - -- Any sniffs specifically looking for T_NONE tokens with a tilde as the contents must now also look for T_BITWISE_NOT - -- Sniffs can continue looking for T_NONE as well as T_BITWISE_NOT to support older PHP_CodeSniffer versions - - All types of binary casting are now tokenized as T_BINARY_CAST - -- Previously, the 'b' in 'b"some string with $var"' would be a T_BINARY_CAST, but only when the string contained a var - -- This change ensures the 'b' is always tokenized as T_BINARY_CAST - -- This change also converts '(binary)' from T_STRING_CAST to T_BINARY_CAST - -- Thanks to Juliette Reinders Folmer for the help with this patch - - Array properties set inside a ruleset.xml file can now extend a previous value instead of always overwriting it - -- e.g., if you include a ruleset that defines forbidden functions, can you now add to that list instead of having to redefine it - -- To use this feature, add extends="true" to the property tag - --- e.g., property name="forbiddenFunctionNames" type="array" extend="true" - -- Thanks to Michael Moravec for the patch - - If $XDG_CACHE_HOME is set and points to a valid directory, it will be used for caching instead of the system temp directory - - PHPCBF now disables parallel running if you are passing content on STDIN - -- Stops an error from being shown after the fixed output is printed - - The progress report now shows files with tokenizer errors as skipped (S) instead of a warning (W) - -- The tokenizer error is still displayed in reports as normal - -- Thanks to Juliette Reinders Folmer for the patch - - The Squiz standard now ensures there is no space between an increment/decrement operator and its variable - - The File::getMethodProperties() method now includes a has_body array index in the return value - -- FALSE if the method has no body (as with abstract and interface methods) or TRUE otherwise - -- Thanks to Chris Wilkinson for the patch - - The File::getTokensAsString() method now throws an exception if the $start param is invalid - -- If the $length param is invalid, an empty string will be returned - -- Stops an infinite loop when the function is passed invalid data - -- Thanks to Juliette Reinders Folmer for the patch - - Added new Generic.CodeAnalysis.EmptyPHPStatement sniff - -- Warns when it finds empty PHP open/close tag combinations or superfluous semicolons - -- Thanks to Juliette Reinders Folmer for the contribution - - Added new Generic.Formatting.SpaceBeforeCast sniff - -- Ensures there is exactly 1 space before a type cast, unless the cast statement is indented or multi-line - -- Thanks to Juliette Reinders Folmer for the contribution - - Added new Generic.VersionControl.GitMergeConflict sniff - -- Detects merge conflict artifacts left in files - -- Thanks to Juliette Reinders Folmer for the contribution - - Added Generic.WhiteSpace.IncrementDecrementSpacing sniff - -- Ensures there is no space between the operator and the variable it applies to - -- Thanks to Juliette Reinders Folmer for the contribution - - Added PSR12.Functions.NullableTypeDeclaration sniff - -- Ensures there is no space after the question mark in a nullable type declaration - -- Thanks to Timo Schinkel for the contribution - - A number of sniffs have improved support for methods in anonymous classes - -- These sniffs would often throw the same error twice for functions in nested classes - -- Error messages have also been changed to be less confusing - -- The full list of affected sniffs is: - --- Generic.NamingConventions.CamelCapsFunctionName - --- PEAR.NamingConventions.ValidFunctionName - --- PSR1.Methods.CamelCapsMethodName - --- PSR2.Methods.MethodDeclaration - --- Squiz.Scope.MethodScope - --- Squiz.Scope.StaticThisUsage - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.CodeAnalysis.UnusedFunctionParameter now only skips functions with empty bodies when the class implements an interface - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.CodeAnalysis.UnusedFunctionParameter now has additional error codes to indicate where unused params were found - -- The new error code prefixes are: - --- FoundInExtendedClass: when the class extends another - --- FoundInImplementedInterface: when the class implements an interface - --- Found: used in all other cases, including closures - -- The new error code suffixes are: - --- BeforeLastUsed: the unused param was positioned before the last used param in the function signature - --- AfterLastUsed: the unused param was positioned after the last used param in the function signature - -- This makes the new error code list for this sniff: - --- Found - --- FoundBeforeLastUsed - --- FoundAfterLastUsed - --- FoundInExtendedClass - --- FoundInExtendedClassBeforeLastUsed - --- FoundInExtendedClassAfterLastUsed - --- FoundInImplementedInterface - --- FoundInImplementedInterfaceBeforeLastUsed - --- FoundInImplementedInterfaceAfterLastUsed - -- These errors code make it easier for specific cases to be ignored or promoted using a ruleset.xml file - -- Thanks to Juliette Reinders Folmer for the contribution - - Generic.Classes.DuplicateClassName now inspects traits for duplicate names as well as classes and interfaces - -- Thanks to Chris Wilkinson for the patch - - Generic.Files.InlineHTML now ignores a BOM at the start of the file - -- Thanks to Chris Wilkinson for the patch - - Generic.PHP.CharacterBeforePHPOpeningTag now ignores a BOM at the start of the file - -- Thanks to Chris Wilkinson for the patch - - Generic.Formatting.SpaceAfterCast now has a setting to specify how many spaces are required after a type cast - -- Default remains 1 - -- Override the "spacing" setting in a ruleset.xml file to change - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Formatting.SpaceAfterCast now has a setting to ignore newline characters after a type cast - -- Default remains FALSE, so newlines are not allowed - -- Override the "ignoreNewlines" setting in a ruleset.xml file to change - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Formatting.SpaceAfterNot now has a setting to specify how many spaces are required after a NOT operator - -- Default remains 1 - -- Override the "spacing" setting in a ruleset.xml file to change - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Formatting.SpaceAfterNot now has a setting to ignore newline characters after the NOT operator - -- Default remains FALSE, so newlines are not allowed - -- Override the "ignoreNewlines" setting in a ruleset.xml file to change - -- Thanks to Juliette Reinders Folmer for the patch - - PEAR.Functions.FunctionDeclaration now checks spacing before the opening parenthesis of functions with no body - -- Thanks to Chris Wilkinson for the patch - - PEAR.Functions.FunctionDeclaration now enforces no space before the semicolon in functions with no body - -- Thanks to Chris Wilkinson for the patch - - PSR2.Classes.PropertyDeclaration now checks the order of property modifier keywords - -- This is a rule that is documented in PSR-2 but was not enforced by the included PSR2 standard until now - -- This sniff is also able to fix the order of the modifier keywords if they are incorrect - -- Thanks to Juliette Reinders Folmer for the patch - - PSR2.Methods.MethodDeclaration now checks method declarations inside traits - -- Thanks to Chris Wilkinson for the patch - - Squiz.Commenting.InlineComment now has better detection of comment block boundaries - - Squiz.Classes.ClassFileName now checks that a trait name matches the filename - -- Thanks to Chris Wilkinson for the patch - - Squiz.Classes.SelfMemberReference now supports scoped declarations and anonymous classes - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Classes.SelfMemberReference now fixes multiple errors at once, increasing fixer performance - -- Thanks to Gabriel Ostrolucký for the patch - - Squiz.Functions.LowercaseFunctionKeywords now checks abstract and final prefixes, and auto-fixes errors - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Objects.ObjectMemberComma.Missing has been renamed to Squiz.Objects.ObjectMemberComma.Found - -- The error is thrown when the comma is found but not required, so the error code was incorrect - -- If you are referencing the old error code in a ruleset XML file, please use the new code instead - -- If you wish to maintain backwards compatibility, you can provide rules for both the old and new codes - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.ObjectOperatorSpacing is now more tolerant of parse errors - - Squiz.WhiteSpace.ObjectOperatorSpacing now fixes errors more efficiently - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2109 : Generic.Functions.CallTimePassByReference false positive for bitwise and used in function argument - - Fixed bug #2165 : Conflict between Squiz.Arrays.ArrayDeclaration and ScopeIndent sniffs when heredoc used in array - - Fixed bug #2167 : Generic.WhiteSpace.ScopeIndent shows invalid error when scope opener indented inside inline HTML - - Fixed bug #2178 : Generic.NamingConventions.ConstructorName matches methods in anon classes with same name as containing class - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2190 : PEAR.Functions.FunctionCallSignature incorrect error when encountering trailing PHPCS annotation - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2194 : Generic.Whitespace.LanguageConstructSpacing should not be checking namespace operators - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2202 : Squiz.WhiteSpace.OperatorSpacing throws error for negative index when using curly braces for string access - -- Same issue fixed in Squiz.Formatting.OperatorBracket - -- Thanks to Andreas Buchenrieder for the patch - - Fixed bug #2210 : Generic.NamingConventions.CamelCapsFunctionName not ignoring SoapClient __getCookies() method - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2211 : PSR2.Methods.MethodDeclaration gets confused over comments between modifier keywords - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2212 : FUNCTION and CONST in use groups being tokenised as T_FUNCTION and T_CONST - -- Thanks to Chris Wilkinson for the patch - - Fixed bug #2214 : File::getMemberProperties() is recognizing method params as properties - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2236 : Memory info measurement unit is Mb but probably should be MB - - Fixed bug #2246 : CSS tokenizer does not tokenize class names correctly when they contain the string NEW - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2278 : Squiz.Operators.ComparisonOperatorUsage false positive when inline IF contained in parentheses - -- Thanks to Arnout Boks for the patch - - Fixed bug #2284 : Squiz.Functions.FunctionDeclarationArgumentSpacing removing type hint during fixing - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #2297 : Anonymous class not tokenized correctly when used as argument to another anon class - -- Thanks to MichaÅ‚ Bundyra for the patch - - - - - 2.9.2 - 2.9.2 - - - stable - stable - - 2018-11-08 - BSD License - - - PHPCS should now run under PHP 7.3 without deprecation warnings - -- Thanks to Nick Wilde for the patch - - Fixed bug #1496 : Squiz.Strings.DoubleQuoteUsage not unescaping dollar sign when fixing - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #1549 : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1890 : Incorrect Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose error between catch and finally statements - - - - - 3.3.2 - 3.3.2 - - - stable - stable - - 2018-09-24 - BSD License - - - Fixed a problem where the report cache was not being cleared when the sniffs inside a standard were updated - - The info report (--report=info) now has improved formatting for metrics that span multiple lines - -- Thanks to Juliette Reinders Folmer for the patch - - The unit test runner now skips .bak files when looking for test cases - -- Thanks to Juliette Reinders Folmer for the patch - - The Squiz standard now ensures underscores are not used to indicate visibility of private members vars and methods - -- Previously, this standard enforced the use of underscores - - Generic.PHP.NoSilencedErrors error messages now contain a code snippet to show the context of the error - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Arrays.ArrayDeclaration no longer reports errors for a comma on a line new after a here/nowdoc - -- Also stops a parse error being generated when auto-fixing - -- The SpaceBeforeComma error message has been changed to only have one data value instead of two - - Squiz.Commenting.FunctionComment no longer errors when trying to fix indents of multi-line param comments - - Squiz.Formatting.OperatorBracket now correctly fixes statements that contain strings - - Squiz.PHP.CommentedOutCode now ignores more @-style annotations and includes better comment block detection - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed a problem where referencing a relative file path in a ruleset XML file could add unnecessary sniff exclusions - -- This didn't actually exclude anything, but caused verbose output to list strange exclusion rules - - Fixed bug #2110 : Squiz.WhiteSpace.FunctionSpacing is removing indents from the start of functions when fixing - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2115 : Squiz.Commenting.VariableComment not checking var types when the @var line contains a comment - - Fixed bug #2120 : Tokenizer fails to match T_INLINE_ELSE when used after function call containing closure - - Fixed bug #2121 : Squiz.PHP.DisallowMultipleAssignments false positive in while loop conditions - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2127 : File::findExtendedClassName() doesn't support nested classes - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2138 : Tokenizer detects wrong token for php ::class feature with spaces - - Fixed bug #2143 : PSR2.Namespaces.UseDeclaration does not properly fix "use function" and "use const" statements - -- Thanks to Chris Wilkinson for the patch - - Fixed bug #2144 : Squiz.Arrays.ArrayDeclaration does incorrect align calculation in array with cyrillic keys - - Fixed bug #2146 : Zend.Files.ClosingTag removes closing tag from end of file without inserting a semicolon - - Fixed bug #2151 : XML schema not updated with the new array property syntax - - - - - 3.3.1 - 3.3.1 - - - stable - stable - - 2018-07-27 - BSD License - - - Support for HHVM has been dropped due to recent unfixed bugs and HHVM refocus on Hack only - -- Thanks to Walt Sorensen and Juliette Reinders Folmer for helping to remove all HHVM exceptions from the core - - - The full report (the default report) now has improved word wrapping for multi-line messages and sniff codes - -- Thanks to Juliette Reinders Folmer for the patch - - The summary report now sorts files based on their directory location instead of just a basic string sort - -- Thanks to Juliette Reinders Folmer for the patch - - The source report now orders error codes by name when they have the same number of errors - -- Thanks to Juliette Reinders Folmer for the patch - - The junit report no longer generates validation errors with the Jenkins xUnit plugin - -- Thanks to Nikolay Geo for the patch - - Generic.Commenting.DocComment no longer generates the SpacingBeforeTags error if tags are the first content in the docblock - -- The sniff will still generate a MissingShort error if there is no short comment - -- This allows the MissingShort error to be suppressed in a ruleset to make short descriptions optional - - Generic.Functions.FunctionCallArgumentSpacing now properly fixes multi-line function calls with leading commas - -- Previously, newlines between function arguments would be removed - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.PHP.Syntax will now use PHP_BINARY instead of trying to discover the executable path - -- This ensures that the sniff will always syntax check files using the PHP version that PHPCS is running under - -- Setting the php_path config var will still override this value as normal - -- Thanks to Willem Stuursma-Ruwen for the patch - - PSR2.Namespaces.UseDeclaration now supports commas at the end of group use declarations - -- Also improves checking and fixing for use statements containing parse errors - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Arrays.ArrayDeclaration no longer removes the array opening brace while fixing - -- This could occur when the opening brace was on a new line and the first array key directly followed - -- This change also stops the KeyNotAligned error message being incorrectly reported in these cases - - Squiz.Arrays.ArrayDeclaration no longer tries to change multi-line arrays to single line when they contain comments - -- Fixes a conflict between this sniff and some indentation sniffs - - Squiz.Classes.ClassDeclaration no longer enforces spacing rules when a class is followed by a function - -- Fixes a conflict between this sniff and the Squiz.WhiteSpace.FunctionSpacing sniff - - The Squiz.Classes.ValidClassName.NotCamelCaps message now references PascalCase instead of CamelCase - -- The "CamelCase class name" metric produced by the sniff has been changed to "PascalCase class name" - -- This reflects the fact that the class name check is actually a Pascal Case check and not really Camel Case - -- Thanks to Tom H Anderson for the patch - - Squiz.Commenting.InlineComment no longer enforces spacing rules when an inline comment is followed by a docblock - -- Fixes a conflict between this sniff and the Squiz.WhiteSpace.FunctionSpacing sniff - - Squiz.WhiteSpace.OperatorSpacing no longer tries to fix operator spacing if the next content is a comment on a new line - -- Fixes a conflict between this sniff and the Squiz.Commenting.PostStatementComment sniff - -- Also stops PHPCS annotations from being moved to a different line, potentially changing their meaning - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.FunctionSpacing no longer checks spacing of functions at the top of an embedded PHP block - -- Fixes a conflict between this sniff and the Squiz.PHP.EmbeddedPHP sniff - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.MemberVarSpacing no longer checks spacing before member vars that come directly after methods - -- Fixes a conflict between this sniff and the Squiz.WhiteSpace.FunctionSpacing sniff - - Squiz.WhiteSpace.SuperfluousWhitespace now recognizes unicode whitespace at the start and end of a file - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2029 : Squiz.Scope.MemberVarScope throws fatal error when a property is found in an interface - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2047 : PSR12.Classes.ClassInstantiation false positive when instantiating class from array index - - Fixed bug #2048 : GenericFormatting.MultipleStatementAlignment false positive when assigning values inside an array - - Fixed bug #2053 : PSR12.Classes.ClassInstantiation incorrectly fix when using member vars and some variable formats - - Fixed bug #2065 : Generic.ControlStructures.InlineControlStructure fixing fails when inline control structure contains closure - - Fixed bug #2072 : Squiz.Arrays.ArrayDeclaration throws NoComma error when array value is a shorthand IF statement - - Fixed bug #2082 : File with "defined() or define()" syntax triggers PSR1.Files.SideEffects.FoundWithSymbols - - Fixed bug #2095 : PSR2.Namespaces.NamespaceDeclaration does not handle namespaces defined over multiple lines - - - - - 3.3.0 - 3.3.0 - - - stable - stable - - 2018-06-07 - BSD License - - - The Squiz.WhiteSpace.LanguageConstructSpacing sniff has been deprecated and will be removed in version 4 - -- The sniff has been moved to the Generic standard, with a new code of Generic.WhiteSpace.LanguageConstructSpacing - -- As soon as possible, replace all instances of the old sniff code with the new sniff code in your ruleset.xml files - --- The existing Squiz sniff will continue to work until version 4 has been released - -- The new Generic sniff now also checks many more language constructs to enforce additional spacing rules - --- Thanks to Mponos George for the contribution - - - The current method for setting array properties in ruleset files has been deprecated and will be removed in version 4 - -- Currently, setting an array value uses the string syntax "print=>echo,create_function=>null" - -- Now, individual array elements are specified using a new "element" tag with "key" and "value" attributes - --- For example, element key="print" value="echo" - -- Thanks to MichaÅ‚ Bundyra for the patch - - - The T_ARRAY_HINT token has been deprecated and will be removed in version 4 - -- The token was used to ensure array type hints were not tokenized as T_ARRAY, but no other type hints were given a special token - -- Array type hints now use the standard T_STRING token instead - -- Sniffs referencing this token type will continue to run without error until version 4, but will not find any T_ARRAY_HINT tokens - - - The T_RETURN_TYPE token has been deprecated and will be removed in version 4 - -- The token was used to ensure array/self/parent/callable return types were tokenized consistently - -- For namespaced return types, only the last part of the string (the class name) was tokenized as T_RETURN_TYPE - -- This was not consistent and so return types are now left using their original token types so they are not skipped by sniffs - --- The exception are array return types, which are tokenized as T_STRING instead of T_ARRAY, as they are for type hints - -- Sniffs referencing this token type will continue to run without error until version 4, but will not find any T_RETUTN_TYPE tokens - -- To get the return type of a function, use the File::getMethodProperties() method, which now contains a "return_type" array index - --- This contains the return type of the function or closer, or a blank string if not specified - --- If the return type is nullable, the return type will contain the leading ? - ---- A nullable_return_type array index in the return value will also be set to true - --- If the return type contains namespace information, it will be cleaned of whitespace and comments - ---- To access the original return value string, use the main tokens array - - - This release contains an incomplete version of the PSR-12 coding standard - -- Errors found using this standard should be valid, but it will miss a lot of violations until it is complete - -- If you'd like to test and help, you can use the standard by running PHPCS with --standard=PSR12 - - - Config values set using --runtime-set now override any config values set in rulesets or the CodeSniffer.conf file - - You can now apply include-pattern rules to individual message codes in a ruleset like you can with exclude-pattern rules - -- Previously, include-pattern rules only applied to entire sniffs - -- If a message code has both include and exclude patterns, the exclude patterns will be ignored - - Using PHPCS annotations to selectively re-enable sniffs is now more flexible - -- Previously, you could only re-enable a sniff/category/standard using the exact same code that was disabled - -- Now, you can disable a standard and only re-enable a specific category or sniff - -- Or, you can disable a specific sniff and have it re-enable when you re-enable the category or standard - - The value of array sniff properties can now be set using phpcs:set annotations - -- e.g., phpcs:set Standard.Category.SniffName property[] key=>value,key2=>value2 - -- Thanks to MichaÅ‚ Bundyra for the patch - - PHPCS annotations now remain as T_PHPCS_* tokens instead of reverting to comment tokens when --ignore-annotations is used - -- This stops sniffs (especially commenting sniffs) from generating a large number of false errors when ignoring - -- Any custom sniffs that are using the T_PHPCS_* tokens to detect annotations may need to be changed to ignore them - --- Check $phpcsFile->config->annotations to see if annotations are enabled and ignore when false - - You can now use fully or partially qualified class names for custom reports instead of absolute file paths - -- To support this, you must specify an autoload file in your ruleset.xml file and use it to register an autoloader - -- Your autoloader will need to load your custom report class when requested - -- Thanks to Juliette Reinders Folmer for the patch - - The JSON report format now does escaping in error source codes as well as error messages - -- Thanks to Martin Vasel for the patch - - Invalid installed_paths values are now ignored instead of causing a fatal error - - Improved testability of custom rulesets by allowing the installed standards to be overridden - -- Thanks to Timo Schinkel for the patch - - The key used for caching PHPCS runs now includes all set config values - -- This fixes a problem where changing config values (e.g., via --runtime-set) used an incorrect cache file - - The "Function opening brace placement" metric has been separated into function and closure metrics in the info report - -- Closures are no longer included in the "Function opening brace placement" metric - -- A new "Closure opening brace placement" metric now shows information for closures - - Multi-line T_YIELD_FROM statements are now replicated properly for older PHP versions - - The PSR2 standard no longer produces 2 error messages when the AS keyword in a foreach loop is not lowercase - - Specifying a path to a non-existent dir when using the --report-[reportType]=/path/to/report CLI option no longer throws an exception - -- This now prints a readable error message, as it does when using --report-file - - The File::getMethodParamaters() method now includes a type_hint_token array index in the return value - -- Provides the position in the token stack of the first token in the type hint - - The File::getMethodProperties() method now includes a return_type_token array index in the return value - -- Provides the position in the token stack of the first token in the return type - - The File::getTokensAsString() method can now optionally return original (non tab-replaced) content - -- Thanks to Juliette Reinders Folmer for the patch - - Removed Squiz.PHP.DisallowObEndFlush from the Squiz standard - -- If you use this sniff and want to continue banning ob_end_flush(), use Generic.PHP.ForbiddenFunctions instead - -- You will need to set the forbiddenFunctions property in your ruleset.xml file - - Removed Squiz.PHP.ForbiddenFunctions from the Squiz standard - -- Replaced by using the forbiddenFunctions property of Generic.PHP.ForbiddenFunctions in the Squiz ruleset.xml - -- Functionality of the Squiz standard remains the same, but the error codes are now different - -- Previously, Squiz.PHP.ForbiddenFunctions.Found and Squiz.PHP.ForbiddenFunctions.FoundWithAlternative - -- Now, Generic.PHP.ForbiddenFunctions.Found and Generic.PHP.ForbiddenFunctions.FoundWithAlternative - - Added new Generic.PHP.LowerCaseType sniff - -- Ensures PHP types used for type hints, return types, and type casting are lowercase - -- Thanks to Juliette Reinders Folmer for the contribution - - Added new Generic.WhiteSpace.ArbitraryParenthesesSpacing sniff - -- Generates an error for whitespace inside parenthesis that don't belong to a function call/declaration or control structure - -- Generates a warning for any empty parenthesis found - -- Allows the required spacing to be set using the spacing sniff property (default is 0) - -- Allows newlines to be used by setting the ignoreNewlines sniff property (default is false) - -- Thanks to Juliette Reinders Folmer for the contribution - - Added new PSR12.Classes.ClassInstantiation sniff - -- Ensures parenthesis are used when instantiating a new class - - Added new PSR12.Keywords.ShortFormTypeKeywords sniff - -- Ensures the short form of PHP types is used when type casting - - Added new PSR12.Namespaces.CompundNamespaceDepth sniff - -- Ensures compound namespace use statements have a max depth of 2 levels - -- The max depth can be changed by setting the 'maxDepth' sniff property in a ruleset.xml file - - Added new PSR12.Operators.OperatorSpacing sniff - -- Ensures operators are preceded and followed by at least 1 space - - Improved core support for grouped property declarations - -- Also improves support in Squiz.WhiteSpace.ScopeKeywordSpacing and Squiz.WhiteSpace.MemberVarSpacing - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Commenting.DocComment now produces a NonParamGroup error when tags are mixed in with the @param tag group - -- It would previously throw either a NonParamGroup or ParamGroup error depending on the order of tags - -- This change allows the NonParamGroup error to be suppressed in a ruleset to allow the @param group to contain other tags - -- Thanks to Phil Davis for the patch - - Generic.Commenting.DocComment now continues checks param tags even if the doc comment short description is missing - -- This change allows the MissingShort error to be suppressed in a ruleset without all other errors being suppressed as well - -- Thanks to Phil Davis for the patch - - Generic.CodeAnalysis.AssignmentInCondition now reports a different error code for assignments found in WHILE conditions - -- The return value of a function call is often assigned in a WHILE condition, so this change makes it easier to exclude these cases - -- The new code for this error message is Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition - -- The error code for all other cases remains as Generic.CodeAnalysis.AssignmentInCondition.Found - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Functions.OpeningFunctionBraceBsdAllman now longer leaves trailing whitespace when moving the opening brace during fixing - -- Also applies to fixes made by PEAR.Functions.FunctionDeclaration and Squiz.Functions.MultiLineFunctionDeclaration - - Generic.WhiteSpace.ScopeIndent now does a better job of fixing the indent of multi-line comments - - Generic.WhiteSpace.ScopeIndent now does a better job of fixing the indent of PHP open and close tags - - PEAR.Commenting.FunctionComment now report a different error code for param comment lines with too much padding - -- Previously, any lines of a param comment that don't start at the exact comment position got the same error code - -- Now, only comment lines with too little padding use ParamCommentAlignment as they are clearly mistakes - -- Comment lines with too much padding may be using precision alignment as now use ParamCommentAlignmentExceeded - -- This allows for excessive padding to be excluded from a ruleset while continuing to enforce a minimum padding - - PEAR.WhiteSpace.ObjectOperatorIndent now checks the indent of more chained operators - -- Previously, it only checked chains beginning with a variable - -- Now, it checks chains beginning with function calls, static class names, etc - - Squiz.Arrays.ArrayDeclaration now continues checking array formatting even if the key indent is not correct - -- Allows for using different array indent rules while still checking/fixing double arrow and value alignment - - Squiz.Commenting.BlockComment has improved support for tab-indented comments - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.BlockComment auto fixing no longer breaks when two block comments follow each other - -- Also stopped single-line block comments from being auto fixed when they are embedded in other code - -- Also fixed as issue found when PHPCS annotations were used inside a block comment - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.BlockComment.LastLineIndent is now able to be fixed with phpcbf - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.BlockComment now aligns star-prefixed lines under the opening tag while fixing, instead of indenting them - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.FunctionComment.IncorrectTypeHint message no longer contains cut-off suggested type hints - - Squiz.Commenting.InlineComment now uses a new error code for inline comments at the end of a function - -- Previously, all inline comments followed by a blank line threw a Squiz.Commenting.InlineComment.SpacingAfter error - -- Now, inline comments at the end of a function will instead throw Squiz.Commenting.InlineComment.SpacingAfterAtFunctionEnd - -- If you previously excluded SpacingAfter, add an exclusion for SpacingAfterAtFunctionEnd to your ruleset as well - -- If you previously only included SpacingAfter, consider including SpacingAfterAtFunctionEnd as well - -- The Squiz standard now excludes SpacingAfterAtFunctionEnd as the blank line is checked elsewhere - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.ControlStructures.ControlSignature now errors when a comment follows the closing brace of an earlier body - -- Applies to catch, finally, else, elseif, and do/while structures - -- The included PSR2 standard now enforces this rule - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Formatting.OperatorBracket.MissingBrackets message has been changed to remove the word "arithmetic" - -- The sniff checks more than just arithmetic operators, so the message is now clearer - - Sniffs.Operators.ComparisonOperatorUsage now detects more cases of implicit true comparisons - -- It could previously be confused by comparisons used as function arguments - - Squiz.PHP.CommentedOutCode now ignores simple @-style annotation comments so they are not flagged as commented out code - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.PHP.CommentedOutCode now ignores a greater number of short comments so they are not flagged as commented out code - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.PHP.DisallowComparisonAssignment no longer errors when using the null coalescing operator - -- Given this operator is used almost exclusively to assign values, it didn't make sense to generate an error - - Squiz.WhiteSpacing.FunctionSpacing now has a property to specify how many blank lines should be before the first class method - -- Only applies when a method is the first code block in a class (i.e., there are no member vars before it) - -- Override the 'spacingBeforeFirst' property in a ruleset.xml file to change - -- If not set, the sniff will use whatever value is set for the existing 'spacing' property - - Squiz.WhiteSpacing.FunctionSpacing now has a property to specify how many blank lines should be after the last class method - -- Only applies when a method is the last code block in a class (i.e., there are no member vars after it) - -- Override the 'spacingAfterLast' property in a ruleset.xml file to change - -- If not set, the sniff will use whatever value is set for the existing 'spacing' property - - Fixed bug #1863 : File::findEndOfStatement() not working when passed a scope opener - - Fixed bug #1876 : PSR2.Namespaces.UseDeclaration not giving error for use statements before the namespace declaration - -- Adds a new PSR2.Namespaces.UseDeclaration.UseBeforeNamespace error message - - Fixed bug #1881 : Generic.Arrays.ArrayIndent is indenting sub-arrays incorrectly when comma not used after the last value - - Fixed bug #1882 : Conditional with missing braces confused by indirect variables - - Fixed bug #1915 : JS tokenizer fails to tokenize regular expression proceeded by boolean not operator - - Fixed bug #1920 : Directory exclude pattern improperly excludes files with names that start the same - -- Thanks to Jeff Puckett for the patch - - Fixed bug #1922 : Equal sign alignment check broken when list syntax used before assignment operator - - Fixed bug #1925 : Generic.Formatting.MultipleStatementAlignment skipping assignments within closures - - Fixed bug #1931 : Generic opening brace placement sniffs do not correctly support function return types - - Fixed bug #1932 : Generic.ControlStructures.InlineControlStructure fixer moves new PHPCS annotations - - Fixed bug #1938 : Generic opening brace placement sniffs incorrectly move PHPCS annotations - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1939 : phpcs:set annotations do not cause the line they are on to be ignored - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1949 : Squiz.PHP.DisallowMultipleAssignments false positive when using namespaces with static assignments - - Fixed bug #1959 : SquizMultiLineFunctionDeclaration error when param has trailing comment - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1963 : Squiz.Scope.MemberVarScope does not work for multiline member declaration - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1971 : Short array list syntax not correctly tokenized if short array is the first content in a file - - Fixed bug #1979 : Tokenizer does not change heredoc to nowdoc token if the start tag contains spaces - - Fixed bug #1982 : Squiz.Arrays.ArrayDeclaration fixer sometimes puts a comma in front of the last array value - - Fixed bug #1993 : PSR1/PSR2 not reporting or fixing short open tags - - Fixed bug #1996 : Custom report paths don't work on case-sensitive filesystems - - Fixed bug #2006 : Squiz.Functions.FunctionDeclarationArgumentSpacing fixer removes comment between parens when no args - -- The SpacingAfterOpenHint error message has been removed - --- It is replaced by the the existing SpacingAfterOpen message - -- The error message format for the SpacingAfterOpen and SpacingBeforeClose messages has been changed - --- These used to contain 3 pieces of data, but now only contain 2 - -- If you have customised the error messages of this sniff, please review your ruleset after upgrading - - Fixed bug #2018 : Generic.Formatting.MultipleStatementAlignment does see PHP close tag as end of statement block - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #2027 : PEAR.NamingConventions.ValidFunctionName error when function name includes double underscore - -- Thanks to Juliette Reinders Folmer for the patch - - - - - 3.2.3 - 3.2.3 - - - stable - stable - - 2018-02-21 - BSD License - - - The new phpcs: comment syntax can now be prefixed with an at symbol ( @phpcs: ) - -- This restores the behaviour of the previous syntax where these comments are ignored by doc generators - - The current PHP version ID is now used to generate cache files - -- This ensures that only cache files generated by the current PHP version are selected - -- This change fixes caching issues when using sniffs that produce errors based on the current PHP version - - A new Tokens::$phpcsCommentTokens array is now available for sniff developers to detect phpcs: comment syntax - -- Thanks to Juliette Reinders Folmer for the patch - - The PEAR.Commenting.FunctionComment.Missing error message now includes the name of the function - -- Thanks to Yorman Arias for the patch - - The PEAR.Commenting.ClassComment.Missing and Squiz.Commenting.ClassComment.Missing error messages now include the name of the class - -- Thanks to Yorman Arias for the patch - - PEAR.Functions.FunctionCallSignature now only forces alignment at a specific tab stop while fixing - -- It was enforcing this during checking, but this meant invalid errors if the OpeningIndent message was being muted - -- This fixes incorrect errors when using the PSR2 standard with some code blocks - - Generic.Files.LineLength now ignores lines that only contain phpcs: annotation comments - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Formatting.MultipleStatementAlignment now skips over arrays containing comments - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.PHP.Syntax now forces display_errors to ON when linting - -- Thanks to Raúl Arellano for the patch - - PSR2.Namespaces.UseDeclaration has improved syntax error handling and closure detection - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.PHP.CommentedOutCode now has improved comment block detection for improved accuracy - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.PHP.NonExecutableCode could fatal error while fixing file with syntax error - - Squiz.PHP.NonExecutableCode now detects unreachable code after a goto statement - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.LanguageConstructSpacing has improved syntax error handling while fixing - -- Thanks to Juliette Reinders Folmer for the patch - - Improved phpcs: annotation syntax handling for a number of sniffs - -- Thanks to Juliette Reinders Folmer for the patch - - Improved auto-fixing of files with incomplete comment blocks for various commenting sniffs - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed test suite compatibility with PHPUnit 7 - - Fixed bug #1793 : PSR2 forcing exact indent for function call opening statements - - Fixed bug #1803 : Squiz.WhiteSpace.ScopeKeywordSpacing removes member var name while fixing if no space after scope keyword - - Fixed bug #1817 : Blank line not enforced after control structure if comment on same line as closing brace - - Fixed bug #1827 : A phpcs:enable comment is not tokenized correctly if it is outside a phpcs:disable block - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1828 : Squiz.WhiteSpace.SuperfluousWhiteSpace ignoreBlankLines property ignores whitespace after single line comments - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1840 : When a comment has too many asterisks, phpcbf gives FAILED TO FIX error - - Fixed bug #1867 : Cant use phpcs:ignore where the next line is HTML - - Fixed bug #1870 : Invalid warning in multiple assignments alignment with closure or anon class - - Fixed bug #1890 : Incorrect Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose error between catch and finally statements - - Fixed bug #1891 : Comment on last USE statement causes false positive for PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse - -- Thanks to Matt Coleman, Daniel Hensby, and Juliette Reinders Folmer for the patch - - Fixed bug #1901 : Fixed PHPCS annotations in multi-line tab-indented comments + not ignoring whole line for phpcs:set - -- Thanks to Juliette Reinders Folmer for the patch - - - - - 3.2.2 - 3.2.2 - - - stable - stable - - 2017-12-20 - BSD License - - - Disabled STDIN detection on Windows - -- This fixes a problem with IDE plugins (e.g., PHPStorm) hanging on Windows - - - - - 3.2.1 - 3.2.1 - - - stable - stable - - 2017-12-18 - BSD License - - - Fixed problems with some scripts and plugins waiting for STDIN - -- This was a notable problem with IDE plugins (e.g., PHPStorm) and build systems - - Empty diffs are no longer followed by a newline character (request #1781) - - Generic.Functions.OpeningFunctionBraceKernighanRitchie no longer complains when the open brace is followed by a close tag - -- This makes the sniff more useful when used in templates - -- Thanks to Joseph Zidell for the patch - - Fixed bug #1782 : Incorrect detection of operator in ternary + anonymous function - - - - - 3.2.0 - 3.2.0 - - - stable - stable - - 2017-12-13 - BSD License - - - This release deprecates the @codingStandards comment syntax used for sending commands to PHP_CodeSniffer - -- The existing syntax will continue to work in all version 3 releases, but will be removed in version 4 - -- The comment formats have been replaced by a shorter syntax: - --- @codingStandardsIgnoreFile becomes phpcs:ignoreFile - --- @codingStandardsIgnoreStart becomes phpcs:disable - --- @codingStandardsIgnoreEnd becomes phpcs:enable - --- @codingStandardsIgnoreLine becomes phpcs:ignore - --- @codingStandardsChangeSetting becomes phpcs:set - -- The new syntax allows for additional developer comments to be added after a -- separator - --- This is useful for describing why a code block is being ignored, or why a setting is being changed - --- E.g., phpcs:disable -- This code block must be left as-is. - -- Comments using the new syntax are assigned new comment token types to allow them to be detected: - --- phpcs:ignoreFile has the token T_PHPCS_IGNORE_FILE - --- phpcs:disable has the token T_PHPCS_DISABLE - --- phpcs:enable has the token T_PHPCS_ENABLE - --- phpcs:ignore has the token T_PHPCS_IGNORE - --- phpcs:set has the token T_PHPCS_SET - - - The phpcs:disable and phpcs:ignore comments can now selectively ignore specific sniffs (request #604) - -- E.g., phpcs:disable Generic.Commenting.Todo.Found for a specific message - -- E.g., phpcs:disable Generic.Commenting.Todo for a whole sniff - -- E.g., phpcs:disable Generic.Commenting for a whole category of sniffs - -- E.g., phpcs:disable Generic for a whole standard - -- Multiple sniff codes can be specified by comma separating them - --- E.g., phpcs:disable Generic.Commenting.Todo,PSR1.Files - - @codingStandardsIgnoreLine comments now only ignore the following line if they are on a line by themselves - -- If they are at the end of an existing line, they will only ignore the line they are on - -- Stops some lines from accidentally being ignored - -- Same rule applies for the new phpcs:ignore comment syntax - - PSR1.Files.SideEffects now respects the new phpcs:disable comment syntax - -- The sniff will no longer check any code that is between phpcs:disable and phpcs:enable comments - -- The sniff does not support phpcs:ignore; you must wrap code structures with disable/enable comments - -- Previously, there was no way to have this sniff ignore parts of a file - - Fixed a problem where PHPCS would sometimes hang waiting for STDIN, or read incomplete versions of large files - -- Thanks to Arne Jørgensen for the patch - - Array properties specified in ruleset files now have their keys and values trimmed - -- This saves having to do this in individual sniffs and stops errors introduced by whitespace in rulesets - -- Thanks to Juliette Reinders Folmer for the patch - - Added phpcs.xsd to allow validation of ruleset XML files - -- Thanks to Renaat De Muynck for the contribution - - File paths specified using --stdin-path can now point to fake file locations (request #1488) - -- Previously, STDIN files using fake file paths were excluded from checking - - Setting an empty basepath (--basepath=) on the CLI will now clear a basepath set directly in a ruleset - -- Thanks to Xaver Loppenstedt for the patch - - Ignore patterns are now checked on symlink target paths instead of symlink source paths - -- Restores previous behaviour of this feature - - Metrics were being double counted when multiple sniffs were recording the same metric - - Added support for bash process substitution - -- Thanks to Scott Dutton for the contribution - - Files included in the cache file code hash are now sorted to aid in cache file reuse across servers - - Windows BAT files can now be used outside a PEAR install - -- You must have the path to PHP set in your PATH environment variable - -- Thanks to Joris Debonnet for the patch - - The JS unsigned right shift assignment operator is now properly classified as an assignment operator - -- Thanks to Juliette Reinders Folmer for the patch - - The AbstractVariableSniff abstract sniff now supports anonymous classes and nested functions - -- Also fixes an issue with Squiz.Scope.MemberVarScope where member vars of anonymous classes were not being checked - - Added AbstractArraySniff to make it easier to create sniffs that check array formatting - -- Allows for checking of single and multi line arrays easily - -- Provides a parsed structure of the array including positions of keys, values, and double arrows - - Added Generic.Arrays.ArrayIndent to enforce a single tab stop indent for array keys in multi-line arrays - -- Also ensures the close brace is on a new line and indented to the same level as the original statement - -- Allows for the indent size to be set using an "indent" property of the sniff - - Added Generic.PHP.DiscourageGoto to warn about the use of the GOTO language construct - -- Thanks to Juliette Reinders Folmer for the contribution - - Generic.Debug.ClosureLinter was not running the gjslint command - -- Thanks to MichaÅ‚ Bundyra for the patch - - Generic.WhiteSpace.DisallowSpaceIndent now fixes space indents in multi-line block comments - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.WhiteSpace.DisallowSpaceIndent now fixes mixed space/tab indents more accurately - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.WhiteSpace.DisallowTabIndent now fixes tab indents in multi-line block comments - -- Thanks to Juliette Reinders Folmer for the patch - - PEAR.Functions.FunctionDeclaration no longer errors when a function declaration is the first content in a JS file - -- Thanks to Juliette Reinders Folmer for the patch - - PEAR.Functions.FunctionCallSignature now requires the function name to be indented to an exact tab stop - -- If the function name is not the start of the statement, the opening statement must be indented correctly instead - -- Added a new fixable error code PEAR.Functions.FunctionCallSignature.OpeningIndent for this error - - Squiz.Functions.FunctionDeclarationArgumentSpacing is no longer confused about comments in function declarations - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.PHP.NonExecutableCode error messages now indicate which line the code block ending is on - -- Makes it easier to identify where the code block exited or returned - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.FunctionComment now supports nullable type hints - - Squiz.Commenting.FunctionCommentThrowTag no longer assigns throw tags inside anon classes to the enclosing function - - Squiz.WhiteSpace.SemicolonSpacing now ignores semicolons used for empty statements inside FOR conditions - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.ControlStructures.ControlSignature now allows configuring the number of spaces before the colon in alternative syntax - -- Override the 'requiredSpacesBeforeColon' setting in a ruleset.xml file to change - -- Default remains at 1 - -- Thanks to Nikola Kovacs for the patch - - The Squiz standard now ensures array keys are indented 4 spaces from the main statement - -- Previously, this standard aligned keys 1 space from the start of the array keyword - - The Squiz standard now ensures array end braces are aligned with the main statement - -- Previously, this standard aligned the close brace with the start of the array keyword - - The standard for PHP_CodeSniffer itself now enforces short array syntax - - The standard for PHP_CodeSniffer itself now uses the Generic.Arrays/ArrayIndent sniff rules - - Improved fixer conflicts and syntax error handling for a number of sniffs - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1462 : Error processing cyrillic strings in Tokenizer - - Fixed bug #1573 : Squiz.WhiteSpace.LanguageConstructSpacing does not properly check for tabs and newlines - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #1590 : InlineControlStructure CBF issue while adding braces to an if thats returning a nested function - - Fixed bug #1718 : Unclosed strings at EOF sometimes tokenized as T_WHITESPACE by the JS tokenizer - - Fixed bug #1731 : Directory exclusions do not work as expected when a single file name is passed to phpcs - - Fixed bug #1737 : Squiz.CSS.EmptyStyleDefinition sees comment as style definition and fails to report error - - Fixed bug #1746 : Very large reports can sometimes become garbled when using the parallel option - - Fixed bug #1747 : Squiz.Scope.StaticThisUsage incorrectly looking inside closures - - Fixed bug #1757 : Unknown type hint "object" in Squiz.Commenting.FunctionComment - - Fixed bug #1758 : PHPCS gets stuck creating file list when processing circular symlinks - - Fixed bug #1761 : Generic.WhiteSpace.ScopeIndent error on multi-line function call with static closure argument - - Fixed bug #1762 : Generic.WhiteSpace.Disallow[Space/Tab]Indent not inspecting content before open tag - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1769 : Custom "define" function triggers a warning about declaring new symbols - - Fixed bug #1776 : Squiz.Scope.StaticThisUsage incorrectly looking inside anon classes - - Fixed bug #1777 : Generic.WhiteSpace.ScopeIndent incorrect indent errors when self called function proceeded by comment - - - - - 3.1.1 - 3.1.1 - - - stable - stable - - 2017-10-17 - BSD License - - - Restored preference of non-dist files over dist files for phpcs.xml and phpcs.xml.dist - -- The order that the files are searched is now: .phpcs.xml, phpcs.xml, .phpcs.xml.dist, phpcs.xml.dist - -- Thanks to Juliette Reinders Folmer for the patch - - Progress output now correctly shows skipped files - - Progress output now shows 100% when the file list has finished processing (request #1697) - - Stopped some IDEs complaining about testing class aliases - -- Thanks to Vytautas Stankus for the patch - - Squiz.Commenting.InlineComment incorrectly identified comment blocks in some cases, muting some errors - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1512 : PEAR.Functions.FunctionCallSignature enforces spaces when no arguments if required spaces is not 0 - - Fixed bug #1522 : Squiz Arrays.ArrayDeclaration and Strings.ConcatenationSpacing fixers causing parse errors with here/ nowdocs - - Fixed bug #1570 : Squiz.Arrays.ArrayDeclaration fixer removes comments between array keyword and open parentheses - - Fixed bug #1604 : File::isReference has problems with some bitwise operators and class property references - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1645 : Squiz.Commenting.InlineComment will fail to fix comments at the end of the file - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1656 : Using the --sniffs argument has a problem with case sensitivity - - Fixed bug #1657 : Uninitialized string offset: 0 when sniffing CSS - - Fixed bug #1669 : Temporary expression proceeded by curly brace is detected as function call - - Fixed bug #1681 : Huge arrays are super slow to scan with Squiz.Arrays.ArrayDeclaration sniff - - Fixed bug #1694 : Squiz.Arrays.ArrayBracketSpacing is removing some comments during fixing - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1702 : Generic.WhiteSpaceDisallowSpaceIndent fixer bug when line only contains superfluous whitespace - - - - - 3.1.0 - 3.1.0 - - - stable - stable - - 2017-09-20 - BSD License - - - This release includes a change to support newer versions of PHPUnit (versions 4, 5, and 6 are now supported) - -- The custom PHP_CodeSniffer test runner now requires a bootstrap file - -- Developers with custom standards using the PHP_CodeSniffer test runner will need to do one of the following: - --- run your unit tests from the PHP_CodeSniffer root dir so the bootstrap file is included - --- specify the PHP_CodeSniffer bootstrap file on the command line: phpunit --bootstrap=/path/to/phpcs/tests/bootstrap.php - --- require the PHP_CodeSniffer bootstrap file from your own bootstrap file - -- If you don't run PHP_CodeSniffer unit tests, this change will not affect you - -- Thanks to Juliette Reinders Folmer for the patch - - - A phpcs.xml or phpcs.xml.dist file now takes precedence over the default_standard config setting - -- Thanks to Björn Fischer for the patch - - Both phpcs.xml and phpcs.xml.dist files can now be prefixed with a dot (request #1566) - -- The order that the files are searched is: .phpcs.xml, .phpcs.xml.dist, phpcs.xml, phpcs.xml.dist - - The autoloader will now search for files during unit tests runs from the same locations as during normal phpcs runs - -- Allows for easier unit testing of custom standards that use helper classes or custom namespaces - - Include patterns for sniffs now use OR logic instead of AND logic - -- Previously, a file had to be in each of the include patterns to be processed by a sniff - -- Now, a file has to only be in at least one of the patterns - -- This change reflects the original intention of the feature - - PHPCS will now follow symlinks under the list of checked directories - -- This previously only worked if you specified the path to a symlink on the command line - - Output from --config-show, --config-set, and --config-delete now includes the path to the loaded config file - - PHPCS now cleanly exits if its config file is not readable - -- Previously, a combination of PHP notices and PHPCS errors would be generated - - Comment tokens that start with /** are now always tokenized as docblocks - -- Thanks to MichaÅ‚ Bundyra for the patch - - The PHP-supplied T_YIELD and T_YIELD_FROM token have been replicated for older PHP versions - -- Thanks to MichaÅ‚ Bundyra for the patch - - Added new Generic.CodeAnalysis.AssignmentInCondition sniff to warn about variable assignments inside conditions - -- Thanks to Juliette Reinders Folmer for the contribution - - Added Generic.Files.OneObjectStructurePerFile sniff to ensure there is a single class/interface/trait per file - -- Thanks to Mponos George for the contribution - - Function call sniffs now check variable function names and self/static object creation - -- Specific sniffs are Generic.Functions.FunctionCallArgumentSpacing, PEAR.Functions.FunctionCallSignature, and PSR2.Methods.FunctionCallSignature - -- Thanks to MichaÅ‚ Bundyra for the patch - - Generic.Files.LineLength can now be configured to ignore all comment lines, no matter their length - -- Set the ignoreComments property to TRUE (default is FALSE) in your ruleset.xml file to enable this - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.PHP.LowerCaseKeyword now checks self, parent, yield, yield from, and closure (function) keywords - -- Thanks to MichaÅ‚ Bundyra for the patch - - PEAR.Functions.FunctionDeclaration now removes a blank line if it creates one by moving the curly brace during fixing - - Squiz.Commenting.FunctionCommentThrowTag now supports PHP 7.1 multi catch exceptions - - Squiz.Formatting.OperatorBracket no longer throws errors for PHP 7.1 multi catch exceptions - - Squiz.Commenting.LongConditionClosingComment now supports finally statements - - Squiz.Formatting.OperatorBracket now correctly fixes pipe separated flags - - Squiz.Formatting.OperatorBracket now correctly fixes statements containing short array syntax - - Squiz.PHP.EmbeddedPhp now properly fixes cases where the only content in an embedded PHP block is a comment - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.ControlStructureSpacing now ignores comments when checking blank lines at the top of control structures - - Squiz.WhiteSpace.ObjectOperatorSpacing now detects and fixes spaces around double colons - -- Thanks to Julius Å mataviÄius for the patch - - Squiz.WhiteSpace.MemberVarSpacing can now be configured to check any number of blank lines between member vars - -- Set the spacing property (default is 1) in your ruleset.xml file to set the spacing - - Squiz.WhiteSpace.MemberVarSpacing can now be configured to check a different number of blank lines before the first member var - -- Set the spacingBeforeFirst property (default is 1) in your ruleset.xml file to set the spacing - - Added a new PHP_CodeSniffer\Util\Tokens::$ooScopeTokens static member var for quickly checking object scope - -- Includes T_CLASS, T_ANON_CLASS, T_INTERFACE, and T_TRAIT - -- Thanks to Juliette Reinders Folmer for the patch - - PHP_CodeSniffer\Files\File::findExtendedClassName() now supports extended interfaces - -- Thanks to Martin Hujer for the patch - - Fixed bug #1550 : Squiz.Commenting.FunctionComment false positive when function contains closure - - Fixed bug #1577 : Generic.InlineControlStructureSniff breaks with a comment between body and condition in do while loops - - Fixed bug #1581 : Sniffs not loaded when one-standard directories are being registered in installed_paths - - Fixed bug #1591 : Autoloader failing to load arbitrary files when installed_paths only set via a custom ruleset - - Fixed bug #1605 : Squiz.WhiteSpace.OperatorSpacing false positive on unary minus after comment - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1615 : Uncaught RuntimeException when phpcbf fails to fix files - - Fixed bug #1637 : Generic.WhiteSpaceScopeIndent closure argument indenting incorrect with multi-line strings - - Fixed bug #1638 : Squiz.WhiteSpace.ScopeClosingBrace closure argument indenting incorrect with multi-line strings - - Fixed bug #1640 : Squiz.Strings.DoubleQuoteUsage replaces tabs with spaces when fixing - -- Thanks to Juliette Reinders Folmer for the patch - - - - - 3.0.2 - 3.0.2 - - - stable - stable - - 2017-07-18 - BSD License - - - Fixed a problem where the source report was not printing the correct number of errors found - - Fixed a problem where the --cache=/path/to/cachefile CLI argument was not working - - The code report now gracefully handles tokenizer exceptions - - The phpcs and phpcbf scripts and now the only places that exit() in the code - -- This allows for easier usage of core PHPCS functions from external scripts - -- If you are calling Runner::runPHPCS() or Runner::runPHPCBF() directly, you will get back the full range of exit codes - -- If not, catch the new DeepExitException to get the error message ($e->getMessage()) and exit code ($e->getCode()); - - NOWDOC tokens are now considered conditions, just as HEREDOC tokens are - -- This makes it easier to find the start and end of a NOWDOC from any token within it - -- Thanks to MichaÅ‚ Bundyra for the patch - - Custom autoloaders are now only included once in case multiple standards are using the same one - -- Thanks to Juliette Reinders Folmer for the patch - - Improved tokenizing of fallthrough CASE and DEFAULT statements that share a closing statement and use curly braces - - Improved the error message when Squiz.ControlStructures.ControlSignature detects a newline after the closing parenthesis - - Fixed bug #1465 : Generic.WhiteSpace.ScopeIndent reports incorrect errors when indenting double arrows in short arrays - - Fixed bug #1478 : Indentation in fallthrough CASE that contains a closure - - Fixed bug #1497 : Fatal error if composer prepend-autoloader is set to false - -- Thanks to Kunal Mehta for the patch - - Fixed bug #1503 : Alternative control structure syntax not always recognized as scoped - - Fixed bug #1523 : Fatal error when using the --suffix argument - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1526 : Use of basepath setting can stop PHPCBF being able to write fixed files - - Fixed bug #1530 : Generic.WhiteSpace.ScopeIndent can increase indent too much for lines within code blocks - - Fixed bug #1547 : Wrong token type for backslash in use function - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #1549 : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1560 : Squiz.Commenting.FunctionComment fatal error when fixing additional param comment lines that have no indent - - - - - 3.0.1 - 3.0.1 - - - stable - stable - - 2017-06-14 - BSD License - - - This release contains a fix for a security advisory related to the improper handling of a shell command - -- A properly crafted filename would allow for arbitrary code execution when using the --filter=gitmodified command line option - -- All version 3 users are encouraged to upgrade to this version, especially if you are checking 3rd-party code - --- e.g., you run PHPCS over libraries that you did not write - --- e.g., you provide a web service that runs PHPCS over user-uploaded files or 3rd-party repositories - --- e.g., you allow external tool paths to be set by user-defined values - -- If you are unable to upgrade but you check 3rd-party code, ensure you are not using the Git modified filter - -- This advisory does not affect PHP_CodeSniffer version 2. - -- Thanks to Sergei Morozov for the report and patch - - - Arguments on the command line now override or merge with those specified in a ruleset.xml file in all cases - - PHPCS now stops looking for a phpcs.xml file as soon as one is found, favoring the closest one to the current dir - - Added missing help text for the --stdin-path CLI option to --help - - Re-added missing help text for the --file-list and --bootstrap CLI options to --help - - Runner::runPHPCS() and Runner::runPHPCBF() now return an exit code instead of exiting directly (request #1484) - - The Squiz standard now enforces short array syntax by default - - The autoloader is now working correctly with classes created with class_alias() - - The autoloader will now search for files inside all directories in the installed_paths config var - -- This allows autoloading of files inside included custom coding standards without manually requiring them - - You can now specify a namespace for a custom coding standard, used by the autoloader to load non-sniff helper files - -- Also used by the autoloader to help other standards directly include sniffs for your standard - -- Set the value to the namespace prefix you are using for sniff files (everything up to \Sniffs\) - -- e.g., if your namespace format is MyProject\CS\Standard\Sniffs\Category set the namespace to MyProject\CS\Standard - -- If omitted, the namespace is assumed to be the same as the directory name containing the ruleset.xml file - -- The namespace is set in the ruleset tag of the ruleset.xml file - -- e.g., ruleset name="My Coding Standard" namespace="MyProject\CS\Standard" - - Rulesets can now specify custom autoloaders using the new autoload tag - -- Autoloaders are included while the ruleset is being processed and before any custom sniffs are included - -- Allows for very custom autoloading of helper classes well before the boostrap files are included - - The PEAR standard now includes Squiz.Commenting.DocCommentAlignment - -- It previously broke comments onto multiple lines, but didn't align them - - Fixed a problem where excluding a message from a custom standard's own sniff would exclude the whole sniff - -- This caused some PSR2 errors to be under-reported - - Fixed bug #1442 : T_NULLABLE detection not working for nullable parameters and return type hints in some cases - - Fixed bug #1447 : Running the unit tests with a phpunit config file breaks the test suite - -- Unknown arguments were not being handled correctly, but are now stored in $config->unknown - - Fixed bug #1449 : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1450 : Coding standard located under an installed_path with the same directory name throws an error - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1451 : Sniff exclusions/restrictions dont work with custom sniffs unless they use the PHP_CodeSniffer NS - - Fixed bug #1454 : Squiz.WhiteSpace.OperatorSpacing is not checking spacing on either side of a short ternary operator - -- Thanks to Mponos George for the patch - - Fixed bug #1495 : Setting an invalid installed path breaks all commands - - Fixed bug #1496 : Squiz.Strings.DoubleQuoteUsage not unescaping dollar sign when fixing - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #1501 : Interactive mode is broken - - Fixed bug #1504 : PSR2.Namespaces.UseDeclaration hangs fixing use statement with no trailing code - - - - - 2.9.1 - 2.9.1 - - - stable - stable - - 2017-05-22 - BSD License - - - Fixed bug #1442 : T_NULLABLE detection not working for nullable parameters and return type hints in some cases - - Fixed bug #1448 : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace - -- Thanks to Juliette Reinders Folmer for the patch - - - - - 3.0.0 - 3.0.0 - - - stable - stable - - 2017-05-04 - BSD License - - - Added an --ignore-annotations command line argument to ignore all @codingStandards annotations in code comments (request #811) - -- This allows you to force errors to be shown that would otherwise be ignored by code comments - -- Also stop files being able to change sniff properties mid way through processing - - An error is now reported if no sniffs were registered to be run (request #1129) - - The autoloader will now search for files inside the directory of any loaded coding standard - -- This allows autoloading of any file inside a custom coding standard without manually requiring them - -- Ensure your namespace begins with your coding standard's directory name and follows PSR-4 - -- e.g., StandardName\Sniffs\CategoryName\AbstractHelper or StandardName\Helpers\StringSniffHelper - - Fixed an error where STDIN was sometimes not checked when using the --parallel CLI option - - The is_closure index has been removed from the return value of File::getMethodProperties() - -- This value was always false because T_FUNCTION tokens are never closures - -- Closures have a token type of T_CLOSURE - - The File::isAnonymousFunction() method has been removed - -- This function always returned false because it only accepted T_FUNCTION tokens, which are never closures - -- Closures have a token type of T_CLOSURE - - Includes all changes from the 2.9.0 release - - Fixed bug #834 : PSR2.ControlStructures.SwitchDeclaration does not handle if branches with returns - -- Thanks to Fabian Wiget for the patch - - - - - 3.0.0RC4 - 3.0.0RC4 - - - beta - beta - - 2017-03-02 - BSD License - - - This release contains a fix for a security advisory related to the improper handling of shell commands - -- Uses of shell_exec() and exec() were not escaping filenames and configuration settings in most cases - -- A properly crafted filename or configuration option would allow for arbitrary code execution when using some features - -- All users are encouraged to upgrade to this version, especially if you are checking 3rd-party code - --- e.g., you run PHPCS over libraries that you did not write - --- e.g., you provide a web service that runs PHPCS over user-uploaded files or 3rd-party repositories - --- e.g., you allow external tool paths to be set by user-defined values - -- If you are unable to upgrade but you check 3rd-party code, ensure you are not using the following features: - --- The diff report - --- The notify-send report - --- The Generic.PHP.Syntax sniff - --- The Generic.Debug.CSSLint sniff - --- The Generic.Debug.ClosureLinter sniff - --- The Generic.Debug.JSHint sniff - --- The Squiz.Debug.JSLint sniff - --- The Squiz.Debug.JavaScriptLint sniff - --- The Zend.Debug.CodeAnalyzer sniff - -- Thanks to Klaus Purer for the report - - - The indent property of PEAR.Classes.ClassDeclaration has been removed - -- Instead of calculating the indent of the brace, it just ensures the brace is aligned with the class keyword - -- Other sniffs can be used to ensure the class itself is indented correctly - - Invalid exclude rules inside a ruleset.xml file are now ignored instead of potentially causing out of memory errors - -- Using the -vv command line argument now also shows the invalid exclude rule as XML - - Includes all changes from the 2.8.1 release - - Fixed bug #1333 : The new autoloader breaks some frameworks with custom autoloaders - - Fixed bug #1334 : Undefined offset when explaining standard with custom sniffs - - - - - 3.0.0RC3 - 3.0.0RC3 - - - beta - beta - - 2017-02-02 - BSD License - - - Added support for ES6 class declarations - -- Previously, these class were tokenized as JS objects but are now tokenized as normal T_CLASS structures - - Added support for ES6 method declarations, where the "function" keyword is not used - -- Previously, these methods were tokenized as JS objects (fixes bug #1251) - -- The name of the ES6 method is now assigned the T_FUNCTION keyword and treated like a normal function - -- Custom sniffs that support JS and listen for T_FUNCTION tokens can't assume the token represents the word "function" - -- Check the contents of the token first, or use $phpcsFile->getDeclarationName($stackPtr) if you just want its name - -- There is no change for custom sniffs that only check PHP code - - PHPCBF exit codes have been changed so they are now more useful (request #1270) - -- Exit code 0 is now used to indicate that no fixable errors were found, and so nothing was fixed - -- Exit code 1 is now used to indicate that all fixable errors were fixed correctly - -- Exit code 2 is now used to indicate that PHPCBF failed to fix some of the fixable errors it found - -- Exit code 3 is now used for general script execution errors - - Added PEAR.Commenting.FileComment.ParamCommentAlignment to check alignment of multi-line param comments - - Includes all changes from the 2.8.0 release - - Fixed an issue where excluding a file using a @codingStandardsIgnoreFile comment would produce errors - -- For PHPCS, it would show empty files being processed - -- For PHPCBF, it would produce a PHP error - - Fixed bug #1233 : Can't set config data inside ruleset.xml file - - Fixed bug #1241 : CodeSniffer.conf not working with 3.x PHAR file - - - - - 3.0.0RC2 - 3.0.0RC2 - - - beta - beta - - 2016-11-30 - BSD License - - - Fixed an undefined var name error that could be produced while running PHPCBF - - Made the Runner class easier to use with wrapper scripts - - Full usage information is no longer printed when a usage error is encountered (request #1186) - -- Makes it a lot easier to find and read the error message that was printed - - Includes all changes from the 2.7.1 release - - Fixed bug #1167 : 3.0.0RC1 PHAR does not work with PEAR standard - - Fixed bug #1208 : Excluding files doesn't work when using STDIN with a filename specified - - - - - 3.0.0RC1 - 3.0.0RC1 - - - beta - beta - - 2016-09-02 - BSD License - - - Progress output now shows E and W in green when a file has fixable errors or warnings - -- Only supported if colors are enabled - - PHPCBF no longer produces verbose output by default (request #699) - -- Use the -v command line argument to show verbose fixing output - -- Use the -q command line argument to disable verbose information if enabled by default - - PHPBF now prints a summary report after fixing files - -- Report shows files that were fixed, how many errors were fixed, and how many remain - - PHPCBF now supports the -p command line argument to print progress information - -- Prints a green F for files where fixes occurred - -- Prints a red E for files that could not be fixed due to an error - -- Use the -q command line argument to disable progress information if enabled by default - - Running unit tests using --verbose no longer throws errors - - Fixed shell error appearing on some systems when trying to find executable paths - - Includes all changes from the 2.7.0 release - - - - - 3.0.0a1 - 3.0.0a1 - - - alpha - alpha - - 2016-07-20 - BSD License - - - Min PHP version increased from 5.1.2 to 5.4.0 - - Added optional caching of results between runs (request #530) - -- Enable the cache by using the --cache command line argument - -- If you want the cache file written somewhere specific, use --cache=/path/to/cacheFile - -- Use the command "phpcs --config-set cache true" to turn caching on by default - -- Use the --no-cache command line argument to disable caching if it is being turned on automatically - - Add support for checking file in parallel (request #421) - -- Tell PHPCS how many files to check at once using the --parallel command line argument - -- To check 100 files at once, using --parallel=100 - -- To disable parallel checking if it is being turned on automatically, use --parallel=1 - -- Requires PHP to be compiled with the PCNTL package - - The default encoding has been changed from iso-8859-1 to utf-8 (request #760) - -- The --encoding command line argument still works, but you no longer have to set it to process files as utf-8 - -- If encoding is being set to utf-8 in a ruleset or on the CLI, it can be safely removed - -- If the iconv PHP extension is not installed, standard non-multibyte aware functions will be used - - Added a new "code" report type to show a code snippet for each error (request #419) - -- The line containing the error is printed, along with 2 lines above and below it to show context - -- The location of the errors is underlined in the code snippet if you also use --colors - -- Use --report=code to generate this report - - Added support for custom filtering of the file list - -- Developers can write their own filter classes to perform custom filtering of the list before the run starts - -- Use the command line arg --filter=/path/to/filter.php to specify a filter to use - -- Extend \PHP_CodeSniffer\Filters\Filter to also support the core PHPCS extension and path filtering - -- Extend \PHP_CodeSniffer\Filters\ExactMatch to get the core filtering and the ability to use blacklists and whitelists - -- The included \PHP_CodeSniffer\Filters\GitModified filter is a good example of an ExactMatch filter - - Added support for only checking files that have been locally modified or added in a git repo - -- Use --filter=gitmodified to check these files - -- You still need to give PHPCS a list of files or directories in which to check - - Added automatic discovery of executable paths (request #571) - -- Thanks to Sergey Morozov for the patch - - You must now pass "-" on the command line to have PHPCS wait for STDIN - -- E.g., phpcs --standard=PSR2 - - -- You can still pipe content via STDIN as normal as PHPCS will see this and process it - -- But without the "-", PHPCS will throw an error if no content or files are passed to it - - All PHP errors generated by sniffs are caught, re-thrown as exceptions, and reported in the standard error reports - -- This should stop bugs inside sniffs causing infinite loops - -- Also stops invalid reports being produced as errors don't print to the screen directly - - Sniff codes are no longer optional - -- If a sniff throws and error or a warning, it must specify an internal code for that message - - The installed_paths config setting can now point directly to a standard - -- Previously, it had to always point to the directory in which the standard lives - - Multiple reports can now be specified using the --report command line argument - -- Report types are separated by commas - -- E.g., --report=full,summary,info - -- Previously, you had to use one argument for each report such as --report=full --report=summary --report=info - - You can now set the severity, message type, and exclude patterns for and entire sniff, category, or standard - -- Previously, this was only available for a single message - - You can now include a single sniff code in a ruleset instead of having to include an entire sniff - -- Including a sniff code will automatically exclude all other messages from that sniff - -- If the sniff is already included by an imported standard, set the sniff severity to 0 and include the specific message you want - - PHPCBF no longer uses patch - -- Files are now always overwritten - -- The --no-patch option has been removed - - Added a --basepath option to strip a directory from the front of file paths in output (request #470) - -- The basepath is absolute or relative to the current directory - -- E.g., to output paths relative to current dir in reports, use --basepath=. - - Ignore rules are now checked when using STDIN (request #733) - - Added an include-pattern tag to rulesets to include a sniff for specific files and folders only (request #656) - -- This is the exact opposite of the exclude-pattern tag - -- This option is only usable within sniffs, not globally like exclude-patterns are - - Added a new -m option to stop error messages from being recorded, which saves a lot of memory - -- PHPCBF always uses this setting to reduce memory as it never outputs error messages - -- Setting the $recordErrors member var inside custom report classes is no longer supported (use -m instead) - - Exit code 2 is now used to indicate fixable errors were found (request #930) - -- Exit code 3 is now used for general script execution errors - -- Exit code 1 is used to indicate that coding standard errors were found, but none are fixable - -- Exit code 0 is unchanged and continues to mean no coding standard errors found - - The included PHPCS standard has been removed - -- All rules are now found inside the phpcs.xml.dist file - -- Running "phpcs" without any arguments from a git clone will use this ruleset - - The included SVN pre-commit hook has been removed - -- Hooks for version control systems will no longer be maintained within the PHPCS project - - - - - 2.9.0 - 2.9.0 - - - stable - stable - - 2017-05-04 - BSD License - - - Added Generic.Debug.ESLint sniff to run ESLint over JS files and report errors - -- Set eslint path using: phpcs --config-set eslint_path /path/to/eslint - -- Thanks to Ryan McCue for the contribution - - T_POW is now properly considered an arithmetic operator, and will be checked as such - -- Thanks to Juliette Reinders Folmer for the patch - - T_SPACESHIP and T_COALESCE are now properly considered comparison operators, and will be checked as such - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.PHP.DisallowShortOpenTag now warns about possible short open tags even when short_open_tag is set to OFF - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.WhiteSpace.DisallowTabIndent now finds and fixes improper use of spaces anywhere inside the line indent - -- Previously, only the first part of the indent was used to determine the indent type - -- Thanks to Juliette Reinders Folmer for the patch - - PEAR.Commenting.ClassComment now supports checking of traits as well as classes and interfaces - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.FunctionCommentThrowTag now supports re-throwing exceptions (request #946) - -- Thanks to Samuel Levy for the patch - - Squiz.PHP.DisallowMultipleAssignments now ignores PHP4-style member var assignments - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.FunctionSpacing now ignores spacing above functions when they are preceded by inline comments - -- Stops conflicts between this sniff and comment spacing sniffs - - Squiz.WhiteSpace.OperatorSpacing no longer checks the equal sign in declare statements - -- Thanks to Juliette Reinders Folmer for the patch - - Added missing error codes for a couple of sniffs so they can now be customised as normal - - Fixed bug #1266 : PEAR.WhiteSpace.ScopeClosingBrace can throw an error while fixing mixed PHP/HTML - - Fixed bug #1364 : Yield From values are not recognised as returned values in Squiz FunctionComment sniff - - Fixed bug #1373 : Error in tab expansion results in white-space of incorrect size - -- Thanks to Mark Clements for the patch - - Fixed bug #1381 : Tokenizer: dereferencing incorrectly identified as short array - - Fixed bug #1387 : Squiz.ControlStructures.ControlSignature does not handle alt syntax when checking space after closing brace - - Fixed bug #1392 : Scope indent calculated incorrectly when using array destructuring - - Fixed bug #1394 : integer type hints appearing as TypeHintMissing instead of ScalarTypeHintMissing - -- PHP 7 type hints were also being shown when run under PHP 5 in some cases - - Fixed bug #1405 : Squiz.WhiteSpace.ScopeClosingBrace fails to fix closing brace within indented PHP tags - - Fixed bug #1421 : Ternaries used in constant scalar expression for param default misidentified by tokenizer - - Fixed bug #1431 : PHPCBF can't fix short open tags when they are not followed by a space - -- Thanks to Gonçalo Queirós for the patch - - Fixed bug #1432 : PHPCBF can make invalid fixes to inline JS control structures that make use of JS objects - - - - - 2.8.1 - 2.8.1 - - - stable - stable - - 2017-03-02 - BSD License - - - This release contains a fix for a security advisory related to the improper handling of shell commands - -- Uses of shell_exec() and exec() were not escaping filenames and configuration settings in most cases - -- A properly crafted filename or configuration option would allow for arbitrary code execution when using some features - -- All users are encouraged to upgrade to this version, especially if you are checking 3rd-party code - --- e.g., you run PHPCS over libraries that you did not write - --- e.g., you provide a web service that runs PHPCS over user-uploaded files or 3rd-party repositories - --- e.g., you allow external tool paths to be set by user-defined values - -- If you are unable to upgrade but you check 3rd-party code, ensure you are not using the following features: - --- The diff report - --- The notify-send report - --- The Generic.PHP.Syntax sniff - --- The Generic.Debug.CSSLint sniff - --- The Generic.Debug.ClosureLinter sniff - --- The Generic.Debug.JSHint sniff - --- The Squiz.Debug.JSLint sniff - --- The Squiz.Debug.JavaScriptLint sniff - --- The Zend.Debug.CodeAnalyzer sniff - -- Thanks to Klaus Purer for the report - - - - The PHP-supplied T_COALESCE_EQUAL token has been replicated for PHP versions before 7.2 - - PEAR.Functions.FunctionDeclaration now reports an error for blank lines found inside a function declaration - - PEAR.Functions.FunctionDeclaration no longer reports indent errors for blank lines in a function declaration - - Squiz.Functions.MultiLineFunctionDeclaration no longer reports errors for blank lines in a function declaration - -- It would previously report that only one argument is allowed per line - - Squiz.Commenting.FunctionComment now corrects multi-line param comment padding more accurately - - Squiz.Commenting.FunctionComment now properly fixes pipe-separated param types - - Squiz.Commenting.FunctionComment now works correctly when function return types also contain a comment - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.ControlStructures.InlineIfDeclaration now supports the elvis operator - -- As this is not a real PHP operator, it enforces no spaces between ? and : when the THEN statement is empty - - Squiz.ControlStructures.InlineIfDeclaration is now able to fix the spacing errors it reports - - Fixed bug #1340 : STDIN file contents not being populated in some cases - -- Thanks to David Biňovec for the patch - - Fixed bug #1344 : PEAR.Functions.FunctionCallSignatureSniff throws error for blank comment lines - - Fixed bug #1347 : PSR2.Methods.FunctionCallSignature strips some comments during fixing - -- Thanks to Algirdas Gurevicius for the patch - - Fixed bug #1349 : Squiz.Strings.DoubleQuoteUsage.NotRequired message is badly formatted when string contains a CR newline char - -- Thanks to Algirdas Gurevicius for the patch - - Fixed bug #1350 : Invalid Squiz.Formatting.OperatorBracket error when using namespaces - - Fixed bug #1369 : Empty line in multi-line function declaration cause infinite loop - - - - - 2.8.0 - 2.8.0 - - - stable - stable - - 2017-02-02 - BSD License - - - The Internal.NoCodeFound error is no longer generated for content sourced from STDIN - -- This should stop some Git hooks generating errors because PHPCS is trying to process the refs passed on STDIN - - Squiz.Commenting.DocCommentAlignment now checks comments on class properties defined using the VAR keyword - -- Thanks to Klaus Purer for the patch - - The getMethodParameters() method now recognises "self" as a valid type hint - -- The return array now contains a new "content" index containing the raw content of the param definition - -- Thanks to Juliette Reinders Folmer for the patch - - The getMethodParameters() method now supports nullable types - -- The return array now contains a new "nullable_type" index set to true or false for each method param - -- Thanks to Juliette Reinders Folmer for the patch - - The getMethodParameters() method now supports closures - -- Thanks to Juliette Reinders Folmer for the patch - - Added more guard code for JS files with syntax errors (request #1271 and request #1272) - - Added more guard code for CSS files with syntax errors (request #1304) - - PEAR.Commenting.FunctionComment fixers now correctly handle multi-line param comments - - AbstractVariableSniff now supports anonymous classes - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.NamingConventions.ConstructorName and PEAR.NamingConventions.ValidVariable now support anonymous classes - - Generic.NamingConventions.CamelCapsFunctionName and PEAR.NamingConventions.ValidFunctionName now support anonymous classes - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.CodeAnalysis.UnusedFunctionParameter and PEAR.Functions.ValidDefaultValue now support closures - -- Thanks to Juliette Reinders Folmer for the patch - - PEAR.NamingConventions.ValidClassName and Squiz.Classes.ValidClassName now support traits - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.Functions.FunctionCallArgumentSpacing now supports closures other PHP-provided functions - -- Thanks to Algirdas Gurevicius for the patch - - Fixed an error where a nullable type character was detected as an inline then token - -- A new T_NULLABLE token has been added to represent the ? nullable type character - -- Thanks to Jaroslav Hanslík for the patch - - Squiz.WhiteSpace.SemicolonSpacing no longer removes comments while fixing the placement of semicolons - -- Thanks to Algirdas Gurevicius for the patch - - Fixed bug #1230 : JS tokeniser incorrectly tokenises bitwise shifts as comparison - -- Thanks to Ryan McCue for the patch - - Fixed bug #1237 : Uninitialized string offset in PHP Tokenizer on PHP 5.2 - - Fixed bug #1239 : Warning when static method name is 'default' - - Fixed bug #1240 : False positive for function names starting with triple underscore - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1245 : SELF is not recognised as T_SELF token in: return new self - - Fixed bug #1246 : A mix of USE statements with and without braces can cause the tokenizer to mismatch brace tokens - -- Thanks to MichaÅ‚ Bundyra for the patch - - Fixed bug #1249 : GitBlame report requires a .git directory - - Fixed bug #1252 : Squiz.Strings.ConcatenationSpacing fix creates syntax error when joining a number to a string - - Fixed bug #1253 : Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch - - Fixed bug #1255 : Inconsistent indentation check results when ELSE on new line - - Fixed bug #1257 : Double dash in CSS class name can lead to "Named colours are forbidden" false positives - - Fixed bug #1260 : Syntax errors not being shown when error_prepend_string is set - -- Thanks to Juliette Reinders Folmer for the patch - - Fixed bug #1264 : Array return type hint is sometimes detected as T_ARRAY_HINT instead of T_RETURN_TYPE - -- Thanks to Jaroslav Hanslík for the patch - - Fixed bug #1265 : ES6 arrow function raises unexpected operator spacing errors - - Fixed bug #1267 : Fixer incorrectly handles filepaths with repeated dir names - -- Thanks to Sergey Ovchinnikov for the patch - - Fixed bug #1276 : Commenting.FunctionComment.InvalidReturnVoid conditional issue with anonymous classes - - Fixed bug #1277 : Squiz.PHP.DisallowMultipleAssignments.Found error when var assignment is on the same line as an open tag - - Fixed bug #1284 : Squiz.Arrays.ArrayBracketSpacing.SpaceBeforeBracket false positive match for short list syntax - - - - - 2.7.1 - 2.7.1 - - - stable - stable - - 2016-11-30 - BSD License - - - Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis fix now removes unnecessary whitespace - - Squiz.Formatting.OperatorBracket no longer errors for negative array indexes used within a function call - - Squiz.PHP.EmbeddedPhp no longer expects a semicolon after statements that are only opening a scope - - Fixed a problem where the content of T_DOC_COMMENT_CLOSE_TAG tokens could sometimes be (boolean) false - - Developers of custom standards with custom test runners can now have their standards ignored by the built-in test runner - -- Set the value of an environment variable called PHPCS_IGNORE_TESTS with a comma separated list of your standard names - -- Thanks to Juliette Reinders Folmer for the patch - - The unit test runner now loads the test sniff outside of the standard's ruleset so that exclude rules do not get applied - -- This may have caused problems when testing custom sniffs inside custom standards - -- Also makes the unit tests runs a little faster - - The SVN pre-commit hook now works correctly when installed via composer - -- Thanks to Sergey for the patch - - Fixed bug #1135 : PEAR.ControlStructures.MultiLineCondition.CloseBracketNewLine not detected if preceded by multiline function call - - Fixed bug #1138 : PEAR.ControlStructures.MultiLineCondition.Alignment not detected if closing brace is first token on line - - Fixed bug #1141 : Sniffs that check EOF newlines don't detect newlines properly when the last token is a doc block - - Fixed bug #1150 : Squiz.Strings.EchoedStrings does not properly fix bracketed statements - - Fixed bug #1156 : Generic.Formatting.DisallowMultipleStatements errors when multiple short echo tags are used on the same line - -- Thanks to Nikola Kovacs for the patch - - Fixed bug #1161 : Absolute report path is treated like a relative path if it also exists within the current directory - - Fixed bug #1170 : Javascript regular expression literal not recognized after comparison operator - - Fixed bug #1180 : Class constant named FUNCTION is incorrectly tokenized - - Fixed bug #1181 : Squiz.Operators.IncrementDecrementUsage.NoBrackets false positive when incrementing properties - -- Thanks to Jürgen Henge-Ernst for the patch - - Fixed bug #1188 : Generic.WhiteSpace.ScopeIndent issues with inline HTML and multi-line function signatures - - Fixed bug #1190 : phpcbf on if/else with trailing comment generates erroneous code - - Fixed bug #1191 : Javascript sniffer fails with function called "Function" - - Fixed bug #1203 : Inconsistent behavior of PHP_CodeSniffer_File::findEndOfStatement - - Fixed bug #1218 : CASE conditions using class constants named NAMESPACE/INTERFACE/TRAIT etc are incorrectly tokenized - - Fixed bug #1221 : Indented function call with multiple closure arguments can cause scope indent error - - Fixed bug #1224 : PHPCBF fails to fix code with heredoc/nowdoc as first argument to a function - - - - - 2.7.0 - 2.7.0 - - - stable - stable - - 2016-09-02 - BSD License - - - Added --file-list command line argument to allow a list of files and directories to be specified in an external file - -- Useful is you have a generated list of files to check that would be too long for the command line - -- File and directory paths are listed one per line - -- Usage is: phpcs --file-list=/path/to/file-list ... - -- Thanks to Blotzu for the patch - - Values set using @codingStandardsChangeSetting comments can now contain spaces - - Sniff unit tests can now specify a list of test files instead of letting the runner pick them (request #1078) - -- Useful if a sniff needs to exclude files based on the environment, or is checking filenames - -- Override the new getTestFiles() method to specify your own list of test files - - Generic.Functions.OpeningFunctionBraceKernighanRitchie now ignores spacing for function return types - -- The sniff code Generic.Functions.OpeningFunctionBraceKernighanRitchie.SpaceAfterBracket has been removed - -- Replaced by Generic.Functions.OpeningFunctionBraceKernighanRitchie.SpaceBeforeBrace - -- The new error message is slightly clearer as it indicates that a single space is needed before the brace - - Squiz.Commenting.LongConditionClosingComment now allows for the length of a code block to be configured - -- Set the lineLimit property (default is 20) in your ruleset.xml file to set the code block length - -- When the code block length is reached, the sniff will enforce a closing comment after the closing brace - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.Commenting.LongConditionClosingComment now allows for the end comment format to be configured - -- Set the commentFormat property (default is "//end %s") in your ruleset.xml file to set the format - -- The placeholder %s will be replaced with the type of condition opener, e.g., "//end foreach" - -- Thanks to Juliette Reinders Folmer for the patch - - Generic.PHPForbiddenFunctions now allows forbidden functions to have mixed case - -- Previously, it would only do a strtolower comparison - -- Error message now shows what case was found in the code and what the correct case should be - -- Thanks to Juliette Reinders Folmer for the patch - - Added Generic.Classes.OpeningBraceSameLine to ensure opening brace of class/interface/trait is on the same line as the declaration - -- Thanks to Juliette Reinders Folmer for the patch - - Added Generic.PHP.BacktickOperator to ban the use of the backtick operator for running shell commands - -- Thanks to Juliette Reinders Folmer for the patch - - Added Generic.PHP.DisallowAlternativePHPTags to ban the use of alternate PHP tags - -- Thanks to Juliette Reinders Folmer for the patch - - Squiz.WhiteSpace.LanguageConstructSpacing no longer checks for spaces if parenthesis are being used (request #1062) - -- Makes this sniff more compatible with those that check parenthesis spacing of function calls - - Squiz.WhiteSpace.ObjectOperatorSpacing now has a setting to ignore newline characters around object operators - -- Default remains FALSE, so newlines are not allowed - -- Override the "ignoreNewlines" setting in a ruleset.xml file to change - -- Thanks to Alex Howansky for the patch - - Squiz.Scope.MethodScope now sniffs traits as well as classes and interfaces - -- Thanks to Jesse Donat for the patch - - PHPCBF is now able to fix Squiz.SelfMemberReference.IncorrectCase errors - -- Thanks to Nikola Kovacs for the patch - - PHPCBF is now able to fix Squiz.Commenting.VariableComment.IncorrectVarType - -- Thanks to Walt Sorensen for the patch - - PHPCBF is now able to fix Generic.PHP.DisallowShortOpenTag - -- Thanks to Juliette Reinders Folmer for the patch - - Improved the formatting of the end brace when auto fixing InlineControlStructure errors (request #1121) - - Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine fix no longer leaves blank line after brace (request #1085) - - Generic UpperCaseConstantNameSniff now allows lowercase namespaces in constant definitions - -- Thanks to Daniel Schniepp for the patch - - Squiz DoubleQuoteUsageSniff is now more tolerant of syntax errors caused by mismatched string tokens - - A few sniffs that produce errors based on the current PHP version can now be told to run using a specific PHP version - -- Set the php_version config var using --config-set, --runtime-set, or in a ruleset to specify a specific PHP version - -- The format of the PHP version is the same as the PHP_VERSION_ID constant (e.g., 50403 for version 5.4.3) - -- Supported sniffs are Generic.PHP.DisallowAlternativePHPTags, PSR1.Classes.ClassDeclaration, Squiz.Commenting.FunctionComment - -- Thanks to Finlay Beaton for the patch - - Fixed bug #985 : Duplicate class definition detection generates false-positives in media queries - -- Thanks to Raphael Horber for the patch - - Fixed bug #1014 : Squiz VariableCommentSniff doesn't always detect a missing comment - - Fixed bug #1066 : Undefined index: quiet in CLI.php during unit test run with -v command line arg - - Fixed bug #1072 : Squiz.SelfMemberReference.NotUsed not detected if leading namespace separator is used - - Fixed bug #1089 : Rulesets cannot be loaded if the path contains urlencoded characters - - Fixed bug #1091 : PEAR and Squiz FunctionComment sniffs throw errors for some invalid @param line formats - - Fixed bug #1092 : PEAR.Functions.ValidDefaultValue should not flag type hinted methods with a NULL default argument - - Fixed bug #1095 : Generic LineEndings sniff replaces tabs with spaces with --tab-width is set - - Fixed bug #1096 : Squiz FunctionDeclarationArgumentSpacing gives incorrect error/fix when variadic operator is followed by a space - - Fixed bug #1099 : Group use declarations are incorrectly fixed by the PSR2 standard - -- Thanks to Jason McCreary for the patch - - Fixed bug #1101 : Incorrect indent errors when breaking out of PHP inside an IF statement - - Fixed bug #1102 : Squiz.Formatting.OperatorBracket.MissingBrackets faulty bracketing fix - - Fixed bug #1109 : Wrong scope indent reported in anonymous class - - Fixed bug #1112 : File docblock not recognized when require_once follows it - - Fixed bug #1120 : InlineControlStructureSniff does not handle auto-fixing for control structures that make function calls - - Fixed bug #1124 : Squiz.Operators.ComparisonOperatorUsage does not detect bracketed conditions for inline IF statements - -- Thanks to Raphael Horber for the patch - - - - - 2.6.2 - 2.6.2 - - - stable - stable - - 2016-07-14 - BSD License - - - Added a new --exclude CLI argument to exclude a list of sniffs from checking and fixing (request #904) - -- Accepts the same sniff codes as the --sniffs command line argument, but provides the opposite functionality - - Added a new -q command line argument to disable progress and verbose information from being printed (request #969) - -- Useful if a coding standard hard-codes progress or verbose output but you want PHPCS to be quiet - -- Use the command "phpcs --config-set quiet true" to turn quiet mode on by default - - Generic LineLength sniff no longer errors for comments that cannot be broken out onto a new line (request #766) - -- A typical case is a comment that contains a very long URL - -- The comment is ignored if putting the URL on a indented new comment line would be longer than the allowed length - - Settings extensions in a ruleset no longer causes PHP notices during unit testing - -- Thanks to Klaus Purer for the patch - - Version control reports now show which errors are fixable if you are showing sources - - Added a new sniff to enforce a single space after a NOT operator (request #1051) - -- Include in a ruleset using the code Generic.Formatting.SpaceAfterNot - - The Squiz.Commenting.BlockComment sniff now supports tabs for indenting comment lines (request #1056) - - Fixed bug #790 : Incorrect missing @throws error in methods that use closures - - Fixed bug #908 : PSR2 standard is not checking that closing brace is on line following the body - - Fixed bug #945 : Incorrect indent behavior using deep-nested function and arrays - - Fixed bug #961 : Two anonymous functions passed as function/method arguments cause indentation false positive - - Fixed bug #1005 : Using global composer vendor autoload breaks PHP lowercase built-in function sniff - -- Thanks to Michael Butler for the patch - - Fixed bug #1007 : Squiz Unreachable code detection is not working properly with a closure inside a case - - Fixed bug #1023 : PSR2.Classes.ClassDeclaration fails if class extends base class and "implements" is on trailing line - - Fixed bug #1026 : Arrays in comma delimited class properties cause ScopeIndent to increase indent - - Fixed bug #1028 : Squiz ArrayDeclaration incorrectly fixes multi-line array where end bracket is not on a new line - - Fixed bug #1034 : Squiz FunctionDeclarationArgumentSpacing gives incorrect error when first arg is a variadic - - Fixed bug #1036 : Adjacent assignments aligned analysis statement wrong - - Fixed bug #1049 : Version control reports can show notices when the report width is very small - - Fixed bug #21050 : PEAR MultiLineCondition sniff suppresses errors on last condition line - - - - - 2.6.1 - 2.6.1 - - - stable - stable - - 2016-05-31 - BSD License - - - The PHP-supplied T_COALESCE token has been replicated for PHP versions before 7.0 - - Function return types of self, parent and callable are now tokenized as T_RETURN_TYPE - -- Thanks to Jaroslav Hanslík for the patch - - The default_standard config setting now allows multiple standards to be listed, like on the command line - -- Thanks to Michael Mayer for the patch - - Installations done via composer now only include the composer autoloader for PHP 5.3.2+ (request #942) - - Added a rollbackChangeset() method to the Fixer class to purposely rollback the active changeset - - Fixed bug #940 : Auto-fixing issue encountered with inconsistent use of braces - - Fixed bug #943 : Squiz.PHP.InnerFunctions.NotAllowed reported in anonymous classes - - Fixed bug #944 : PHP warning when running the latest phar - - Fixed bug #951 : InlineIfDeclaration: invalid error produced with UTF-8 string - - Fixed bug #957 : Operator spacing sniff errors when plus is used as part of a number - -- Thanks to Klaus Purer for the patch - - Fixed bug #959 : Call-time pass-by-reference false positive if there is a square bracket before the ampersand - -- Thanks to Konstantin Leboev for the patch - - Fixed bug #962 : Null coalescing operator (??) not detected as a token - -- Thanks to Joel Posti for the patch - - Fixed bug #973 : Anonymous class declaration and PSR1.Files.SideEffects.FoundWithSymbols - - Fixed bug #974 : Error when file ends with "function" - - Fixed bug #979 : Anonymous function with return type hint is not refactored as expected - - Fixed bug #983 : Squiz.WhiteSpace.MemberVarSpacing.AfterComment fails to fix error when comment is not a docblock - - Fixed bug #1010 : Squiz NonExecutableCode sniff does not detect boolean OR - -- Thanks to Derek Henderson for the patch - - Fixed bug #1015 : The Squiz.Commenting.FunctionComment sniff doesn't allow description in @return tag - -- Thanks to Alexander Obuhovich for the patch - - Fixed bug #1022 : Duplicate spaces after opening bracket error with PSR2 standard - - Fixed bug #1025 : Syntax error in JS file can cause undefined index for parenthesis_closer - - - - - 2.6.0 - 2.6.0 - - - stable - stable - - 2016-04-04 - BSD License - - - Paths used when setting CLI arguments inside ruleset.xml files are now relative to the ruleset location (request #847) - -- This change only applies to paths within ARG tags, used to set CLI arguments - -- Previously, the paths were relative to the directory PHPCS was being run from - -- Absolute paths are still allowed and work the same way they always have - -- This change allows ruleset.xml files to be more portable - - Content passed via STDIN will now be processed even if files are specified on the command line or in a ruleset - - When passing content via STDIN, you can now specify the file path to use on the command line (request #934) - -- This allows sniffs that check file paths to work correctly - -- This is the same functionality provided by the phpcs_input_file line, except it is available on the command line - - Files processed with custom tokenizers will no longer be skipped if they appear minified (request #877) - -- If the custom tokenizer wants minified files skipped, it can set a $skipMinified member var to TRUE - -- See the included JS and CSS tokenizers for an example - - Config vars set in ruleset.xml files are now processed earlier, allowing them to be used during sniff registration - -- Among other things, this allows the installed_paths config var to be set in ruleset.xml files - -- Thanks to Pieter Frenssen for the patch - - Improved detection of regular expressions in the JS tokenizer - - Generic PHP Syntax sniff now uses PHP_BINARY (if available) to determine the path to PHP if no other path is available - -- You can still manually set php_path to use a specific binary for testing - -- Thanks to Andrew Berry for the patch - - The PHP-supplied T_POW_EQUAL token has been replicated for PHP versions before 5.6 - - Added support for PHP7 use group declarations (request #878) - -- New tokens T_OPEN_USE_GROUP and T_CLOSE_USE_GROUP are assigned to the open and close curly braces - - Generic ScopeIndent sniff now reports errors for every line that needs the indent changed (request #903) - -- Previously, it ignored lines that were indented correctly in the context of their block - -- This change produces more technically accurate error messages, but is much more verbose - - The PSR2 and Squiz standards now allow multi-line default values in function declarations (request #542) - -- Previously, these would automatically make the function a multi-line declaration - - Squiz InlineCommentSniff now allows docblocks on require(_once) and include(_once) statements - -- Thanks to Gary Jones for the patch - - Squiz and PEAR Class and File sniffs no longer assume the first comment in a file is always a file comment - -- phpDocumentor assigns the comment to the file only if it is not followed by a structural element - -- These sniffs now follow this same rule - - Squiz ClassCommentSniff no longer checks for blank lines before class comments - -- Removes the error Squiz.Commenting.ClassComment.SpaceBefore - - Renamed Squiz.CSS.Opacity.SpacingAfterPoint to Squiz.CSS.Opacity.DecimalPrecision - -- Please update your ruleset if you are referencing this error code directly - - Fixed PHP tokenizer problem that caused an infinite loop when checking a comment with specific content - - Generic Disallow Space and Tab indent sniffs now detect and fix indents inside embedded HTML chunks (request #882) - - Squiz CSS IndentationSniff no longer assumes the class opening brace is at the end of a line - - Squiz FunctionCommentThrowTagSniff now ignores non-docblock comments - - Squiz ComparisonOperatorUsageSniff now allows conditions like while(true) - - PEAR FunctionCallSignatureSniff (and the Squiz and PSR2 sniffs that use it) now correctly check the first argument - -- Further fix for bug #698 - - Fixed bug #791 : codingStandardsChangeSetting settings not working with namespaces - - Fixed bug #872 : Incorrect detection of blank lines between CSS class names - - Fixed bug #879 : Generic InlineControlStructureSniff can create parse error when case/if/elseif/else have mixed brace and braceless definitions - - Fixed bug #883 : PSR2 is not checking for blank lines at the start and end of control structures - - Fixed bug #884 : Incorrect indentation notice for anonymous classes - - Fixed bug #887 : Using curly braces for a shared CASE/DEFAULT statement can generate an error in PSR2 SwitchDeclaration - - Fixed bug #889 : Closure inside catch/else/elseif causes indentation error - - Fixed bug #890 : Function call inside returned short array value can cause indentation error inside CASE statements - - Fixed bug #897 : Generic.Functions.CallTimePassByReference.NotAllowed false positive when short array syntax - - Fixed bug #900 : Squiz.Functions.FunctionDeclarationArgumentSpacing bug when no space between type hint and argument - - Fixed bug #902 : T_OR_EQUAL and T_POW_EQUAL are not seen as assignment tokens - - Fixed bug #910 : Unrecognized "extends" and indentation on anonymous classes - - Fixed bug #915 : JS Tokenizer generates errors when processing some decimals - - Fixed bug #928 : Endless loop when sniffing a PHP file with a git merge conflict inside a function - - Fixed bug #937 : Shebang can cause PSR1 SideEffects warning - -- Thanks to Clay Loveless for the patch - - Fixed bug #938 : CallTimePassByReferenceSniff ignores functions with return value - - - - - 2.5.1 - 2.5.1 - - - stable - stable - - 2016-01-20 - BSD License - - - The PHP-supplied T_SPACESHIP token has been replicated for PHP versions before 7.0 - - T_SPACESHIP is now correctly identified as an operator - -- Thanks to Alexander Obuhovich for the patch - - Generic LowerCaseKeyword now ensures array type hints are lowercase as well - -- Thanks to Mathieu Rochette for the patch - - Squiz ComparisonOperatorUsageSniff no longer hangs on JS FOR loops that don't use semicolons - - PHP_CodesSniffer now includes the composer autoload.php file, if there is one - -- Thanks to Klaus Purer for the patch - - Added error Squiz.Commenting.FunctionComment.ScalarTypeHintMissing for PHP7 only (request #858) - -- These errors were previously reported as Squiz.Commenting.FunctionComment.TypeHintMissing on PHP7 - -- Disable this error message in a ruleset.xml file if your code needs to run on both PHP5 and PHP7 - - The PHP 5.6 __debugInfo magic method no longer produces naming convention errors - -- Thanks to Michael Nowack for the patch - - PEAR and Squiz FunctionComment sniffs now support variadic functions (request #841) - - Fixed bug #622 : Wrong detection of Squiz.CSS.DuplicateStyleDefinition with media queries - - Fixed bug #752 : The missing exception error is reported in first found DocBlock - - Fixed bug #794 : PSR2 MultiLineFunctionDeclaration forbids comments after opening parenthesis of a multiline call - - Fixed bug #820 : PEAR/PSR2 FunctionCallSignature sniffs suggest wrong indent when there are multiple arguments on a line - - Fixed bug #822 : Ruleset hard-coded file paths are not used if not running from the same directory as the ruleset - - Fixed bug #825 : FunctionCallArgumentSpacing sniff complains about more than one space before comment in multi-line function call - - Fixed bug #828 : Null classname is tokenized as T_NULL instead of T_STRING - - Fixed bug #829 : Short array argument not fixed correctly when multiple function arguments are on the same line - - Fixed bug #831 : PHPCS freezes in an infinite loop under Windows if no standard is passed - - Fixed bug #832 : Tokenizer does not support context sensitive parsing - -- Thanks to Jaroslav Hanslík for the patch - - Fixed bug #835 : PEAR.Functions.FunctionCallSignature broken when closure uses return types - - Fixed bug #838 : CSS indentation fixer changes color codes - -- Thanks to Klaus Purer for the patch - - Fixed bug #839 : "__()" method is marked as not camel caps - -- Thanks to Tim Bezhashvyly for the patch - - Fixed bug #852 : Generic.Commenting.DocComment not finding errors when long description is omitted - - Fixed bug #854 : Return typehints in interfaces are not reported as T_RETURN_TYPE - -- Thanks to Jaroslav Hanslík for the patch - - Fixed bug #855 : Capital letter detection for multibyte strings doesn't work correctly - - Fixed bug #857 : PSR2.ControlStructure.SwitchDeclaration shouldn't check indent of curly brace closers - - Fixed bug #859 : Switch statement indention issue when returning function call with closure - - Fixed bug #861 : Single-line arrays and function calls can generate incorrect indentation errors - - Fixed bug #867 : Squiz.Strings.DoubleQuoteUsage broken for some escape codes - -- Thanks to Jack Blower for the help with the fix - - Fixed bug #21005 : Incorrect indent detection when multiple properties are initialized to arrays - - Fixed bug #21010 : Incorrect missing colon detection in CSS when first style is not on new line - - Fixed bug #21011 : Incorrect error message text when newline found after opening brace - - - - - 2.5.0 - 2.5.0 - - - stable - stable - - 2015-12-11 - BSD License - - - PHPCS will now look for a phpcs.xml file in parent directories as well as the current directory (request #626) - - PHPCS will now use a phpcs.xml file even if files are specified on the command line - -- This file is still only used if no standard is specified on the command line - - Added support for a phpcs.xml.dist file (request #583) - -- If both a phpcs.xml and phpcs.xml.dist file are present, the phpcs.xml file will be used - - Added support for setting PHP ini values in ruleset.xml files (request #560) - -- Setting the value of the new ini tags to name="memory_limit" value="32M" is the same as -d memory_limit=32M - - Added support for one or more bootstrap files to be run before processing begins - -- Use the --bootstrap=file,file,file command line argument to include bootstrap files - -- Useful if you want to override some of the high-level settings of PHPCS or PHPCBF - -- Thanks to John Maguire for the patch - - Added additional verbose output for CSS tokenizing - - Squiz ComparisonOperatorUsageSniff now checks FOR, WHILE and DO-WHILE statements - -- Thanks to Arnout Boks for the patch - - Fixed bug #660 : Syntax checks can fail on Windows with PHP5.6 - - Fixed bug #784 : $this->trait is seen as a T_TRAIT token - - Fixed bug #786 : Switch indent issue with short array notation - - Fixed bug #787 : SpacingAfterDefaultBreak confused by multi-line statements - - Fixed bug #797 : Parsing CSS url() value breaks further parsing - - Fixed bug #805 : Squiz.Commenting.FunctionComment.InvalidTypeHint on Scalar types on PHP7 - - Fixed bug #807 : Cannot fix line endings when open PHP tag is not on the first line - - Fixed bug #808 : JS tokeniser incorrectly setting some function and class names to control structure tokens - - Fixed bug #809 : PHPCBF can break a require_once statement with a space before the open parenthesis - - Fixed bug #813 : PEAR FunctionCallSignature checks wrong indent when first token on line is part of a multi-line string - - - - - 2.4.0 - 2.4.0 - - - stable - stable - - 2015-11-24 - BSD License - - - Added support for PHP 7 anonymous classes - -- Anonymous classes are now tokenized as T_ANON_CLASS and ignored by normal class sniffs - - Added support for PHP 7 function return type declarations - -- Return types are now tokenized as T_RETURN_TYPE - - Fixed tokenizing of the XOR operator, which was incorrectly identified as a power operator (bug #765) - -- The T_POWER token has been removed and replaced by the T_BITWISE_XOR token - -- The PHP-supplied T_POW token has been replicated for PHP versions before 5.6 - - Traits are now tokenized in PHP versions before 5.4 to make testing easier - - Improved regular expression detection in JS files - - PEAR FunctionCallSignatureSniff now properly detects indents in more mixed HTML/PHP code blocks - - Full report now properly indents lines when newlines are found inside error messages - - Generating documentation without specifying a standard now uses the default standard instead - -- Thanks to Ken Guest for the patch - - Generic InlineControlStructureSniff now supports braceless do/while loops in JS - -- Thanks to Pieter Frenssen for the patch - - Added more guard code for function declarations with syntax errors - -- Thanks to Yun Young-jin for the patch - - Added more guard code for foreach declarations with syntax errors - -- Thanks to Johan de Ruijter for the patch - - Added more guard code for class declarations with syntax errors - - Squiz ArrayDeclarationSniff now has guard code for arrays with syntax errors - - Generic InlineControlStructureSniff now correctly fixes ELSEIF statements - - Fixed bug #601 : Expected type hint int[]; found array in Squiz FunctionCommentSniff - -- Thanks to Scato Eggen for the patch - - Fixed bug #625 : Consider working around T_HASHBANG in HHVM 3.5.x and 3.6.x - -- Thanks to Kunal Mehta for the patch - - Fixed bug #692 : Comment tokenizer can break when using mbstring function overloading - - Fixed bug #694 : Long sniff codes can cause PHP warnings in source report when showing error codes - - Fixed bug #698 : PSR2.Methods.FunctionCallSignature.Indent forces exact indent of ternary operator parameters - - Fixed bug #704 : ScopeIndent can fail when an opening parenthesis is on a line by itself - - Fixed bug #707 : Squiz MethodScopeSniff doesn't handle nested functions - - Fixed bug #709 : Squiz.Sniffs.Whitespace.ScopeClosingBraceSniff marking indented endif in mixed inline HTML blocks - - Fixed bug #711 : Sniffing from STDIN shows Generic.Files.LowercasedFilename.NotFound error - - Fixed bug #714 : Fixes suppression of errors using docblocks - -- Thanks to Andrzej Karmazyn for the patch - - Fixed bug #716 : JSON report is invalid when messages contain newlines or tabs - -- Thanks to Pieter Frenssen for the patch - - Fixed bug #723 : ScopeIndent can fail when multiple array closers are on the same line - - Fixed bug #730 : ScopeIndent can fail when a short array opening square bracket is on a line by itself - - Fixed bug #732 : PHP Notice if @package name is made up of all invalid characters - -- Adds new error code PEAR.Commenting.FileComment.InvalidPackageValue - - Fixed bug #748 : Auto fix for Squiz.Commenting.BlockComment.WrongEnd is incorrect - -- Thanks to J.D. Grimes for the patch - - Fixed bug #753 : PSR2 standard shouldn't require space after USE block when next code is a closing tag - - Fixed bug #768 : PEAR FunctionCallSignature sniff forbids comments after opening parenthesis of a multiline call - - Fixed bug #769 : Incorrect detection of variable reference operator when used with short array syntax - -- Thanks to Klaus Purer for the patch - - Fixed bug #772 : Syntax error when using PHPCBF on alternative style foreach loops - - Fixed bug #773 : Syntax error when stripping trailing PHP close tag and previous statement has no semicolon - - Fixed bug #778 : PHPCBF creates invalid PHP for inline FOREACH containing multiple control structures - - Fixed bug #781 : Incorrect checking for PHP7 return types on multi-line function declarations - - Fixed bug #782 : Conditional function declarations cause fixing conflicts in Squiz standard - -- Squiz.ControlStructures.ControlSignature no longer enforces a single newline after open brace - -- Squiz.WhiteSpace.ControlStructureSpacing can be used to check spacing at the start/end of control structures - - - - - 2.3.4 - 2.3.4 - - - stable - stable - - 2015-09-09 - BSD License - - - JSON report format now includes the fixable status for each error message and the total number of fixable errors - - Added more guard code for function declarations with syntax errors - - Added tokenizer support for the PHP declare construct - -- Thanks to Andy Blyler for the patch - - Generic UnnecessaryStringConcatSniff can now allow strings concatenated over multiple lines - -- Set the allowMultiline property to TRUE (default is FALSE) in your ruleset.xml file to enable this - -- By default, concat used only for getting around line length limits still generates an error - -- Thanks to Stefan Lenselink for the contribution - - Invalid byte sequences no longer throw iconv_strlen() errors (request #639) - -- Thanks to Willem Stuursma for the patch - - Generic TodoSniff and FixmeSniff are now better at processing strings with invalid characters - - PEAR FunctionCallSignatureSniff now ignores indentation of inline HTML content - - Squiz ControlSignatureSniff now supports control structures with only inline HTML content - - Fixed bug #636 : Some class names cause CSS tokenizer to hang - - Fixed bug #638 : VCS blame reports output error content from the blame commands for files not under VC - - Fixed bug #642 : Method params incorrectly detected when default value uses short array syntax - -- Thanks to Josh Davis for the patch - - Fixed bug #644 : PEAR ScopeClosingBrace sniff does not work with mixed HTML/PHP - - Fixed bug #645 : FunctionSignature and ScopeIndent sniffs don't detect indents correctly when PHP open tag is not on a line by itself - - Fixed bug #648 : Namespace not tokenized correctly when followed by multiple use statements - - Fixed bug #654 : Comments affect indent check for BSDAllman brace style - - Fixed bug #658 : Squiz.Functions.FunctionDeclarationSpacing error for multi-line declarations with required spaces greater than zero - -- Thanks to J.D. Grimes for the patch - - Fixed bug #663 : No space after class name generates: Class name "" is not in camel caps format - - Fixed bug #667 : Scope indent check can go into infinite loop due to some parse errors - - Fixed bug #670 : Endless loop in PSR1 SideEffects sniffer if no semicolon after last statement - -- Thanks to Thomas Jarosch for the patch - - Fixed bug #672 : Call-time pass-by-reference false positive - - Fixed bug #683 : Comments are incorrectly reported by PSR2.ControlStructures.SwitchDeclaration sniff - - Fixed bug #687 : ScopeIndent does not check indent correctly for method prefixes like public and abstract - - Fixed bug #689 : False error on some comments after class closing brace - - - - - 2.3.3 - 2.3.3 - - - stable - stable - - 2015-06-24 - BSD License - - - Improved the performance of the CSS tokenizer, especially on very large CSS files (thousands of lines) - -- Thanks to Klaus Purer for the patch - - Defined tokens for lower PHP versions are now phpcs-specific strings instead of ints - -- Stops conflict with other projects, like PHP_CodeCoverage - - Added more guard code for syntax errors to various sniffs - - Improved support for older HHVM versions - -- Thanks to Kunal Mehta for the patch - - Squiz ValidLogicalOperatorsSniff now ignores XOR as type casting is different when using the ^ operator (request #567) - - Squiz CommentedOutCodeSniff is now better at ignoring URLs inside comments - - Squiz ControlSignatureSniff is now better at checking embedded PHP code - - Squiz ScopeClosingBraceSniff is now better at checking embedded PHP code - - Fixed bug #584 : Squiz.Arrays.ArrayDeclaration sniff gives incorrect NoComma error for multiline string values - - Fixed bug #589 : PEAR.Functions.FunctionCallSignature sniff not checking all function calls - - Fixed bug #592 : USE statement tokenising can sometimes result in mismatched scopes - - Fixed bug #594 : Tokenizer issue on closure that returns by reference - - Fixed bug #595 : Colons in CSS selectors within media queries throw false positives - -- Thanks to Klaus Purer for the patch - - Fixed bug #598 : PHPCBF can break function/use closure brace placement - - Fixed bug #603 : Squiz ControlSignatureSniff hard-codes opener type while fixing - - Fixed bug #605 : Auto report-width specified in ruleset.xml ignored - - Fixed bug #611 : Invalid numeric literal on CSS files under PHP7 - - Fixed bug #612 : Multi-file diff generating incorrectly if files do not end with EOL char - - Fixed bug #615 : Squiz OperatorBracketSniff incorrectly reports and fixes operations using self:: - - Fixed bug #616 : Squiz DisallowComparisonAssignmentSniff inconsistent errors with inline IF statements - - Fixed bug #617 : Space after switch keyword in PSR-2 is not being enforced - - Fixed bug #621 : PSR2 SwitchDeclaration sniff doesn't detect, or correctly fix, case body on same line as statement - - - - - 2.3.2 - 2.3.2 - - - stable - stable - - 2015-04-29 - BSD License - - - The error message for PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase is now clearer (request #579) - - Fixed bug #545 : Long list of CASE statements can cause tokenizer to reach a depth limit - - Fixed bug #565 : Squiz.WhiteSpace.OperatorSpacing reports negative number in short array - -- Thanks to VaÅ¡ek Purchart for the patch - -- Same fix also applied to Squiz.Formatting.OperatorBracket - - Fixed bug #569 : Generic ScopeIndentSniff throws PHP notices in JS files - - Fixed bug #570 : Phar class fatals in PHP less than 5.3 - - - - - 2.3.1 - 2.3.1 - - - stable - stable - - 2015-04-23 - BSD License - - - PHPCS can now exit with 0 even if errors are found - -- Set the ignore_errors_on_exit config variable to 1 to set this behaviour - -- Use with the ignore_warnings_on_exit config variable to never return a non-zero exit code - - Added Generic DisallowLongArraySyntaxSniff to enforce the use of the PHP short array syntax (request #483) - -- Thanks to Xaver Loppenstedt for helping with tests - - Added Generic DisallowShortArraySyntaxSniff to ban the use of the PHP short array syntax (request #483) - -- Thanks to Xaver Loppenstedt for helping with tests - - Generic ScopeIndentSniff no longer does exact checking for content inside parenthesis (request #528) - -- Only applies to custom coding standards that set the "exact" flag to TRUE - - Squiz ConcatenationSpacingSniff now has a setting to ignore newline characters around operators (request #511) - -- Default remains FALSE, so newlines are not allowed - -- Override the "ignoreNewlines" setting in a ruleset.xml file to change - - Squiz InlineCommentSniff no longer checks the last char of a comment if the first char is not a letter (request #505) - - The Squiz standard has increased the max padding for statement alignment from 12 to 20 - - Fixed bug #479 : Yielded values are not recognised as returned values in Squiz FunctionComment sniff - - Fixed bug #512 : Endless loop whilst parsing mixture of control structure styles - - Fixed bug #515 : Spaces in JS block incorrectly flagged as indentation error - - Fixed bug #523 : Generic ScopeIndent errors for IF in FINALLY - - Fixed bug #527 : Closure inside IF statement is not tokenized correctly - - Fixed bug #529 : Squiz.Strings.EchoedStrings gives false positive when echo'ing using an inline condition - - Fixed bug #537 : Using --config-set is breaking phpcs.phar - - Fixed bug #543 : SWITCH with closure in condition generates inline control structure error - - Fixed bug #551 : Multiple catch blocks not checked in Squiz.ControlStructures.ControlSignature sniff - - Fixed bug #554 : ScopeIndentSniff causes errors when encountering an unmatched parenthesis - - Fixed bug #558 : PHPCBF adds brace for ELSE IF split over multiple lines - - Fixed bug #564 : Generic MultipleStatementAlignment sniff reports incorrect errors for multiple assignments on a single line - - - - - 2.3.0 - 2.3.0 - - - stable - stable - - 2015-03-04 - BSD License - - - The existence of the main config file is now cached to reduce is_file() calls when it doesn't exist (request #486) - - Abstract classes inside the Sniffs directory are now ignored even if they are named [Name]Sniff.php (request #476) - -- Thanks to David Vernet for the patch - - PEAR and Squiz FileComment sniffs no longer have @ in their error codes - -- e.g., PEAR.Commenting.FileComment.Duplicate@categoryTag becomes PEAR.Commenting.FileComment.DuplicateCategoryTag - -- e.g., Squiz.Commenting.FileComment.Missing@categoryTag becomes Squiz.Commenting.FileComment.MissingCategoryTag - - PEAR MultiLineConditionSniff now allows comment lines inside multi-line IF statement conditions - -- Thanks to Klaus Purer for the patch - - Generic ForbiddenFunctionsSniff now supports setting null replacements in ruleset files (request #263) - - Generic opening function brace sniffs now support checking of closures - -- Set the checkClosures property to TRUE (default is FALSE) in your ruleset.xml file to enable this - -- Can also set the checkFunctions property to FALSE (default is TRUE) in your ruleset.xml file to only check closures - -- Affects OpeningFunctionBraceBsdAllmanSniff and OpeningFunctionBraceKernighanRitchieSniff - - Generic OpeningFunctionBraceKernighanRitchieSniff can now fix all the errors it finds - - Generic OpeningFunctionBraceKernighanRitchieSniff now allows empty functions with braces next to each other - - Generic OpeningFunctionBraceBsdAllmanSniff now allows empty functions with braces next to each other - - Improved auto report width for the "full" report - - Improved conflict detection during auto fixing - - Generic ScopeIndentSniff is no longer confused by empty closures - - Squiz ControlSignatureSniff now always ignores comments (fixes bug #490) - -- Include the Squiz.Commenting.PostStatementComment sniff in your ruleset.xml to ban these comments again - - Squiz OperatorSpacingSniff no longer throws errors for code in the form ($foo || -1 === $bar) - - Fixed errors tokenizing T_ELSEIF tokens on HHVM 3.5 - - Squiz ArrayDeclarationSniff is no longer tricked by comments after array values - - PEAR IncludingFileSniff no longer produces invalid code when removing parenthesis from require/include statements - - Fixed bug #415 : The @codingStandardsIgnoreStart has no effect during fixing - - Fixed bug #432 : Properties of custom sniffs cannot be configured - - Fixed bug #453 : PSR2 standard does not allow closing tag for mixed PHP/HTML files - - Fixed bug #457 : FunctionCallSignature sniffs do not support here/nowdoc syntax and can cause syntax error when fixing - - Fixed bug #466 : PropertyLabelSpacing JS fixer issue when there is no space after colon - - Fixed bug #473 : Writing a report for an empty folder to existing file includes the existing contents - - Fixed bug #485 : PHP notice in Squiz.Commenting.FunctionComment when checking malformed @throws comment - - Fixed bug #491 : Generic InlineControlStructureSniff can correct with missing semicolon - -- Thanks to Jesse Donat for the patch - - Fixed bug #492 : Use statements don't increase the scope indent - - Fixed bug #493 : PSR1_Sniffs_Methods_CamelCapsMethodNameSniff false positives for some magic method detection - -- Thanks to Andreas Möller for the patch - - Fixed bug #496 : Closures in PSR2 are not checked for a space after the function keyword - - Fixed bug #497 : Generic InlineControlStructureSniff does not support alternative SWITCH syntax - - Fixed bug #500 : Functions not supported as values in Squiz ArrayDeclaration sniff - - Fixed bug #501 : ScopeClosingBrace and ScopeIndent conflict with closures used as array values - -- Generic ScopeIndentSniff may now report fewer errors for closures, but perform the same fixes - - Fixed bug #502 : PSR1 SideEffectsSniff sees declare() statements as side effects - - - - - 2.2.0 - 2.2.0 - - - stable - stable - - 2015-01-22 - BSD License - - - Added (hopefully) tastefully used colors to report and progress output for the phpcs command - -- Use the --colors command line argument to use colors in output - -- Use the command "phpcs --config-set colors true" to turn colors on by default - -- Use the --no-colors command line argument to turn colors off when the config value is set - - Added support for using the full terminal width for report output - -- Use the --report-width=auto command line argument to auto-size the reports - -- Use the command "phpcs --config-set report_width auto" to use auto-sizing by default - - Reports will now size to fit inside the report width setting instead of always using padding to fill the space - - If no files or standards are specified, PHPCS will now look for a phpcs.xml file in the current directory - -- This file has the same format as a standard ruleset.xml file - -- The phpcs.xml file should specify (at least) files to process and a standard/sniffs to use - -- Useful for running the phpcs and phpcbf commands without any arguments at the top of a repository - - Default file paths can now be specified in a ruleset.xml file using the "file" tag - -- File paths are only processed if no files were specified on the command line - - Extensions specified on the CLI are now merged with those set in ruleset.xml files - -- Previously, the ruleset.xml file setting replaced the CLI setting completely - - Squiz coding standard now requires lowercase PHP constants (true, false and null) - -- Removed Squiz.NamingConventions.ConstantCase sniff as the rule is now consistent across PHP and JS files - - Squiz FunctionOpeningBraceSpaceSniff no longer does additional checks for JS functions - -- PHP and JS functions and closures are now treated the same way - - Squiz MultiLineFunctionDeclarationSniff now supports JS files - - Interactive mode no longer breaks if you also specify a report type on the command line - - PEAR InlineCommentSniff now fixes the Perl-style comments that it finds (request #375) - - PSR2 standard no longer fixes the placement of docblock open tags as comments are excluded from this standard - - PSR2 standard now sets a default tab width of 4 spaces - - Generic DocCommentSniff now only disallows lowercase letters at the start of a long/short comment (request #377) - -- All non-letter characters are now allowed, including markdown special characters and numbers - - Generic DisallowMultipleStatementsSniff now allows multiple open/close tags on the same line (request #423) - - Generic CharacterBeforePHPOpeningTagSniff now only checks the first PHP tag it finds (request #423) - - Generic CharacterBeforePHPOpeningTagSniff now allows a shebang line at the start of the file (request #20481) - - Generic InlineHTMLUnitTest now allows a shebang line at the start of the file (request #20481) - - PEAR ObjectOperatorIndentSniff now only checks object operators at the start of a line - - PEAR FileComment and ClassComment sniffs no longer have @ in their error codes - -- E.g., PEAR.Commenting.FileComment.Missing@categoryTag becomes PEAR.Commenting.FileComment.MissingCategoryTag - -- Thanks to Grzegorz Rygielski for the patch - - Squiz ControlStructureSpacingSniff no longer enforces a blank line before CATCH statements - - Squiz FunctionCommentSniff now fixes the return type in the @return tag (request #392) - - Squiz BlockCommentSniff now only disallows lowercase letters at the start of the comment - - Squiz InlineCommentSniff now only disallows lowercase letters at the start of the comment - - Squiz OperatorSpacingSniff now has a setting to ignore newline characters around operators (request #348) - -- Default remains FALSE, so newlines are not allowed - -- Override the "ignoreNewlines" setting in a ruleset.xml file to change - - PSR2 ControlStructureSpacingSniff now checks for, and fixes, newlines after the opening parenthesis - - Added a markdown document generator (--generator=markdown to use) - -- Thanks to Stefano Kowalke for the contribution - - Fixed bug #379 : Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast incorrectly detects comments - - Fixed bug #382 : JS tokenizer incorrect for inline conditionally created immediately invoked anon function - - Fixed bug #383 : Squiz.Arrays.ArrayDeclaration.ValueNoNewline incorrectly detects nested arrays - - Fixed bug #386 : Undefined offset in Squiz.FunctionComment sniff when param has no comment - - Fixed bug #390 : Indentation of non-control structures isn't adjusted when containing structure is fixed - - Fixed bug #400 : InlineControlStructureSniff fails to fix when statement has no semicolon - - Fixed bug #401 : PHPCBF no-patch option shows an error when there are no fixable violations in a file - - Fixed bug #405 : The "Squiz.WhiteSpace.FunctionSpacing" sniff removes class "}" during fixing - - Fixed bug #407 : PEAR.ControlStructures.MultiLineCondition doesn't account for comments at the end of lines - - Fixed bug #410 : The "Squiz.WhiteSpace.MemberVarSpacing" not respecting "var" - - Fixed bug #411 : Generic.WhiteSpace.ScopeIndent.Incorrect - false positive with multiple arrays in argument list - - Fixed bug #412 : PSR2 multi-line detection doesn't work for inline IF and string concats - - Fixed bug #414 : Squiz.WhiteSpace.MemberVarSpacing - inconsistent checking of member vars with comment - - Fixed bug #433 : Wrong detection of Squiz.Arrays.ArrayDeclaration.KeyNotAligned when key contains space - - Fixed bug #434 : False positive for spacing around "=>" in inline array within foreach - - Fixed bug #452 : Ruleset exclude-pattern for specific sniff code ignored when using CLI --ignore option - - Fixed bug #20482 : Scope indent sniff can get into infinite loop when processing a parse error - - - - - 2.1.0 - 2.1.0 - - - stable - stable - - 2014-12-18 - BSD License - - - Time and memory output is now shown if progress information is also shown (request #335) - - A tilde can now be used to reference a user's home directory in a path to a standard (request #353) - - Added PHP_CodeSniffer_File::findStartOfStatement() to find the first non-whitespace token in a statement - -- Possible alternative for code using PHP_CodeSniffer_File::findPrevious() with the local flag set - - Added PHP_CodeSniffer_File::findEndOfStatement() to find the last non-whitespace token in a statement - -- Possible alternative for code using PHP_CodeSniffer_File::findNext() with the local flag set - - Generic opening function brace sniffs now ensure the opening brace is the last content on the line - -- Affects OpeningFunctionBraceBsdAllmanSniff and OpeningFunctionBraceKernighanRitchieSniff - -- Also enforced in PEAR FunctionDeclarationSniff and Squiz MultiLineFunctionDeclarationSniff - - Generic DisallowTabIndentSniff now replaces tabs everywhere it finds them, except in strings and here/now docs - - Generic EmptyStatementSniff error codes now contain the type of empty statement detected (request #314) - -- All messages generated by this sniff are now errors (empty CATCH was previously a warning) - -- Message code Generic.CodeAnalysis.EmptyStatement.NotAllowed has been removed - -- Message code Generic.CodeAnalysis.EmptyStatement.NotAllowedWarning has been removed - -- New message codes have the format Generic.CodeAnalysis.EmptyStatement.Detected[TYPE] - -- Example code is Generic.CodeAnalysis.EmptyStatement.DetectedCATCH - -- You can now use a custom ruleset to change messages to warnings and to exclude them - - PEAR and Squiz FunctionCommentSniffs no longer ban @return tags for constructors and destructors - -- Removed message PEAR.Commenting.FunctionComment.ReturnNotRequired - -- Removed message Squiz.Commenting.FunctionComment.ReturnNotRequired - -- Change initiated by request #324 and request #369 - - Squiz EmptyStatementSniff has been removed - -- Squiz standard now includes Generic EmptyStatementSniff and turns off the empty CATCH error - - Squiz ControlSignatureSniff fixes now retain comments between the closing parenthesis and open brace - - Squiz SuperfluousWhitespaceSniff now checks for extra blank lines inside closures - -- Thanks to Sertan Danis for the patch - - Squiz ArrayDeclarationSniff now skips function calls while checking multi-line arrays - - Fixed bug #337 : False positive with anonymous functions in Generic_Sniffs_WhiteSpace_ScopeIndentSniff - - Fixed bug #339 : reformatting brace location can result in broken code - - Fixed bug #342 : Nested ternary operators not tokenized correctly - - Fixed bug #345 : Javascript regex not tokenized when inside array - - Fixed bug #346 : PHP path can't be determined in some cases in "phpcs.bat" (on Windows XP) - - Fixed bug #358 : False positives for Generic_Sniffs_WhiteSpace_ScopeIndentSniff - - Fixed bug #361 : Sniff-specific exclude patterns don't work for Windows - - Fixed bug #364 : Don't interpret "use function" as declaration - - Fixed bug #366 : phpcbf with PSR2 errors on control structure alternative syntax - - Fixed bug #367 : Nested Anonymous Functions Causing False Negative - - Fixed bug #371 : Shorthand binary cast causes tokenizer errors - -- New token T_BINARY_CAST added for the b"string" cast format (the 'b' is the T_BINARY_CAST token) - - Fixed bug #372 : phpcbf parse problem, wrong brace placement for inline IF - - Fixed bug #373 : Double quote usage fix removing too many double quotes - - Fixed bug #20196 : 1.5.2 breaks scope_closer position - - - - - 2.0.0 - 2.0.0 - - - stable - stable - - 2014-12-05 - BSD License - - - JS tokenizer now sets functions as T_CLOSUREs if the function is anonymous - - JS tokenizer now sets all objects to T_OBJECT - -- Object end braces are set to a new token T_CLOSE_OBJECT - -- T_OBJECT tokens no longer act like scopes; i.e., they have no condition/opener/closer - -- T_PROPERTY tokens no longer act like scopes; i.e., they have no condition/opener/closer - -- T_OBJECT tokens have a bracket_closer instead, which can be used to find the ending - -- T_CLOSE_OBJECT tokens have a bracket_opener - - Improved regular expression detection in the JS tokenizer - - You can now get PHP_CodeSniffer to ignore a single line by putting @codingStandardsIgnoreLine in a comment - -- When the comment is found, the comment line and the following line will be ignored - -- Thanks to Andy Bulford for the contribution - - PHPCBF now prints output when it is changing into directories - - Improved conflict detection during auto fixing - - The -vvv command line argument will now output the current file content for each loop during fixing - - Generic ScopeIndentSniff now checks that open/close PHP tags are aligned to the correct column - - PEAR FunctionCallSignatureSniff now checks indent of closing parenthesis even if it is not on a line by itself - - PEAR FunctionCallSignatureSniff now supports JS files - - PEAR MultiLineConditionSniff now supports JS files - - Squiz DocCommentAlignmentSniff now supports JS files - - Fixed a problem correcting the closing brace line in Squiz ArrayDeclarationSniff - - Fixed a problem auto-fixing the Squiz.WhiteSpace.FunctionClosingBraceSpace.SpacingBeforeNestedClose error - - Squiz EmbeddedPhpSniff no longer reports incorrect alignment of tags when they are not on new lines - - Squiz EmbeddedPhpSniff now aligns open tags correctly when moving them onto a new line - - Improved fixing of arrays with multiple values in Squiz ArrayDeclarationSniff - - Improved detection of function comments in Squiz FunctionCommentSpacingSniff - - Improved fixing of lines after cases statements in Squiz SwitchDeclarationSniff - - Fixed bug #311 : Suppression of function prototype breaks checking of lines within function - - Fixed bug #320 : Code sniffer indentation issue - - Fixed bug #333 : Nested ternary operators causing problems - - - - - 2.0.0RC4 - 2.0.0RC4 - - - beta - beta - - 2014-11-07 - BSD License - - - JS tokenizer now detects xor statements correctly - - Improved detection of properties and objects in the JS tokenizer - - Generic ScopeIndentSniff can now fix indents using tabs instead of spaces - -- Set the tabIndent property to TRUE in your ruleset.xml file to enable this - -- It is important to also set a tab-width setting, either in the ruleset or on the command line, for accuracy - - Generic ScopeIndentSniff now checks and auto-fixes JS files - - Generic DisallowSpaceIndentSniff is now able to replace space indents with tab indents during fixing - - Support for phpcs-only and phpcbf-only attributes has been added to all ruleset.xml elements - -- Allows parts of the ruleset to only apply when using a specific tool - -- Useful for doing things like excluding indent fixes but still reporting indent errors - - Unit tests can now set command line arguments during a test run - -- Override getCliValues() and pass an array of CLI arguments for each file being tested - - File-wide sniff properties can now be set using T_INLINE_HTML content during unit test runs - -- Sniffs that start checking at the open tag can only, normally, have properties set using a ruleset - - Generic ConstructorNameSniff no longer errors for PHP4 style constructors when __construct() is present - -- Thanks to Thibaud Fabre for the patch - - Generic DocCommentSniff now checks that the end comment tag is on a new line - - Generic MultipleStatementAlignmentSniff no longer skips assignments for closures - - Squiz DocCommentAlignment sniff now has better checking for single line doc block - - Running unit tests with the -v CLI argument no longer generates PHP errors - - Fixed bug #295 : ScopeIndentSniff hangs when processing nested closures - - Fixed bug #298 : False positive in ScopeIndentSniff when anonymous functions are used with method chaining - - Fixed bug #302 : Fixing code in Squiz InlineComment sniff can remove some comment text - - Fixed bug #303 : Open and close tag on same line can cause a PHP notice checking scope indent - - Fixed bug #306 : File containing only a namespace declaration raises undefined index notice - - Fixed bug #307 : Conditional breaks in case statements get incorrect indentations - - Fixed bug #308 : Squiz InlineIfDeclarationSniff fails on ternary operators inside closure - - Fixed bug #310 : Variadics not recognized by tokenizer - - - - - 2.0.0RC3 - 2.0.0RC3 - - - beta - beta - - 2014-10-16 - BSD License - - - Improved default output for PHPCBF and removed the options to print verbose and progress output - - If a .fixed file is supplied for a unit test file, the auto fixes will be checked against it during testing - -- See Generic ScopeIndentUnitTest.inc and ScopeIndentUnitTest.inc.fixed for an example - - Fixer token replacement methods now return TRUE if the change was accepted and FALSE if rejected - - The --config-show command now pretty-prints the config values - -- Thanks to Ken Guest for the patch - - Setting and removing config values now catches exceptions if the config file is not writable - -- Thanks to Ken Guest for the patch - - Setting and removing config values now prints a message to confirm the action and show old values - - Generic ScopeIndentSniff has been completely rewritten to improve fixing and embedded PHP detection - - Generic DisallowTabIndent and DisallowSpaceIndent sniffs now detect indents at the start of block comments - - Generic DisallowTabIndent and DisallowSpaceIndent sniffs now detect indents inside multi-line strings - - Generic DisallowTabIndentSniff now replaces tabs inside doc block comments - - Squiz ControlStructureSpacingSniff error codes have been corrected; they were reversed - - Squiz EmbeddedPhpSniff now checks open and close tag indents and fixes some errors - - Squiz FileCommentSniff no longer throws incorrect blank line before comment errors in JS files - - Squiz ClassDeclarationSniff now has better checking for blank lines after a closing brace - - Removed error Squiz.Classes.ClassDeclaration.NoNewlineAfterCloseBrace (request #285) - -- Already handled by Squiz.Classes.ClassDeclaration.CloseBraceSameLine - - Fixed bug #280 : The --config-show option generates error when there is no config file - - - - - 2.0.0RC2 - 2.0.0RC2 - - - beta - beta - - 2014-09-26 - BSD License - - - Minified JS and CSS files are now detected and skipped (fixes bug #252 and bug #19899) - -- A warning will be added to the file so it can be found in the report and ignored in the future - - Fixed incorrect length of JS object operator tokens - - PHP tokenizer no longer converts class/function names to special tokens types - -- Class/function names such as parent and true would become special tokens such as T_PARENT and T_TRUE - - PHPCS can now exit with 0 if only warnings were found (request #262) - -- Set the ignore_warnings_on_exit config variable to 1 to set this behaviour - -- Default remains at exiting with 0 only if no errors and no warnings were found - -- Also changes return value of PHP_CodeSniffer_Reporting::printReport() - - Rulesets can now set associative array properties - -- property name="[property]" type="array" value="foo=>bar,baz=>qux" - - Generic ForbiddenFunctionsSniff now has a public property called forbiddenFunctions (request #263) - -- Override the property in a ruleset.xml file to define forbidden functions and their replacements - -- A replacement of NULL indicates that no replacement is available - -- e.g., value="delete=>unset,print=>echo,create_function=>null" - -- Custom sniffs overriding this one will need to change the visibility of their member var - - Improved closure support in Generic ScopeIndentSniff - - Improved indented PHP tag support in Generic ScopeIndentSniff - - Improved fixing of mixed line indents in Generic ScopeIndentSniff - - Added conflict detection to the file fixer - -- If 2 sniffs look to be conflicting, one change will be ignored to allow a fix to occur - - Generic CamelCapsFunctionNameSniff now ignores a single leading underscore - -- Thanks to Alex Slobodiskiy for the patch - - Standards can now be located within hidden directories (further fix for bug #20323) - -- Thanks to Klaus Purer for the patch - - Sniff ignore patterns now replace Win dir separators like file ignore patterns already did - - Exclude patterns now use backtick delimiters, allowing all special characters to work correctly again - -- Thanks to Jeremy Edgell for the patch - - Errors converted to warnings in a ruleset (and vice versa) now retain their fixable status - -- Thanks to Alexander Obuhovich for the patch - - Squiz ConcatenationSpacingSniff now has a setting to specify how many spaces there should around concat operators - -- Default remains at 0 - -- Override the "spacing" setting in a ruleset.xml file to change - - Added auto-fixes for Squiz InlineCommentSniff - - Generic DocCommentSniff now correctly fixes additional blank lines at the end of a comment - - Squiz OperatorBracketSniff now correctly fixes operations that include arrays - - Zend ClosingTagSniff fix now correctly leaves closing tags when followed by HTML - - Added Generic SyntaxSniff to check for syntax errors in PHP files - -- Thanks to Blaine Schmeisser for the contribution - - Added Generic OneTraitPerFileSniff to check that only one trait is defined in each file - -- Thanks to Alexander Obuhovich for the contribution - - Squiz DiscouragedFunctionsSniff now warns about var_dump() - - PEAR ValidFunctionNameSniff no longer throws an error for _() - - Squiz and PEAR FunctionCommentSniffs now support _() - - Generic DisallowTabIndentSniff now checks for, and fixes, mixed indents again - - Generic UpperCaseConstantSniff and LowerCaseConstantSniff now ignore function names - - Fixed bug #243 : Missing DocBlock not detected - - Fixed bug #248 : FunctionCommentSniff expects ampersand on param name - - Fixed bug #265 : False positives with type hints in ForbiddenFunctionsSniff - - Fixed bug #20373 : Inline comment sniff tab handling way - - Fixed bug #20377 : Error when trying to execute phpcs with report=json - - Fixed bug #20378 : Report appended to existing file if no errors found in run - - Fixed bug #20381 : Invalid "Comment closer must be on a new line" - -- Thanks to Brad Kent for the patch - - Fixed bug #20402 : SVN pre-commit hook fails due to unknown argument error - - - - - 2.0.0RC1 - 2.0.0RC1 - - - beta - beta - - 2014-08-06 - BSD License - - - PHPCBF will now fix incorrect newline characters in a file - - PHPCBF now exists cleanly when there are no errors to fix - - Added phpcbf.bat file for Windows - - Verbose option no longer errors when using a phar file with a space in the path - - Fixed a reporting error when using HHVM - -- Thanks to Martins Sipenko for the patch - - addFixableError() and addFixableWarning() now only return true if the fixer is enabled - -- Saves checking ($phpcsFile->fixer->enabled === true) before every fix - - Added addErrorOnLine() and addWarningOnLine() to add a non-fixable violation to a line at column 1 - -- Useful if you are generating errors using an external tool or parser and only know line numbers - -- Thanks to Ondřej Mirtes for the patch - - CSS tokenizer now identifies embedded PHP code using the new T_EMBEDDED_PHP token type - -- The entire string of PHP is contained in a single token - - PHP tokenizer contains better detection of short array syntax - - Unit test runner now also test any standards installed under the installed_paths config var - - Exclude patterns now use {} delimiters, allowing the | special character to work correctly again - - The filtering component of the --extensions argument is now ignored again when passing filenames - -- Can still be used to specify a custom tokenizer for each extension when passing filenames - -- If no tokenizer is specified, default values will be used for common file extensions - - Diff report now produces relative paths on Windows, where possible (further fix for bug #20234) - - If a token's content has been modified by the tab-width setting, it will now have an orig_content in the tokens array - - Generic DisallowSpaceIndent and DisallowTabIndent sniffs now check original indent content even when tab-width is set - -- Previously, setting --tab-width would force both to check the indent as spaces - - Fixed a problem where PHPCBF could replace tabs with too many spaces when changing indents - - Fixed a problem that could occur with line numbers when using HHVM to check files with Windows newline characters - - Removed use of sys_get_temp_dir() as this is not supported by the min PHP version - - Squiz ArrayDeclarationSniff now supports short array syntax - - Squiz ControlSignatureSniff no longer uses the Abstract Pattern sniff - -- If you are extending this sniff, you'll need to rewrite your code - -- The rewrite allows this sniff to fix all control structure formatting issues it finds - - The installed_paths config var now accepts relative paths - -- The paths are relative to the PHP_CodeSniffer install directory - -- Thanks to Weston Ruter for the patch - - Generic ScopeIndentSniff now accounts for different open tag indents - - PEAR FunctionDeclarationSniff now ignores short arrays when checking indent - -- Thanks to Daniel Tschinder for the patch - - PSR2 FunctionCallSignatureSniff now treats multi-line strings as a single-line argument, like arrays and closures - -- Thanks to Dawid Nowak for the patch - - PSR2 UseDeclarationSniff now checks for a single space after the USE keyword - - Generic ForbiddenFunctionsSniff now detects calls to functions in the global namespace - -- Thanks to Ole Martin Handeland for the patch - - Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore namespaces beginning with TRUE/FALSE/NULL - -- Thanks to Renan Gonçalves for the patch - - Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request #20299) - - Squiz SelfMemberReferenceSniff now works correctly with namespaces - - Squiz FunctionCommentSniff is now more relaxed when checking namespaced type hints - - Tab characters are now encoded in abstract pattern errors messages - -- Thanks to Blaine Schmeisser for the patch - - Invalid sniff codes passed to --sniffs now show a friendly error message (request #20313) - - Generic LineLengthSniff now shows a warning if the iconv module is disabled (request #20314) - - Source report no longer shows errors if category or sniff names ends in an uppercase error - -- Thanks to Jonathan Marcil for the patch - - Fixed bug #20261 : phpcbf has an endless fixing loop - - Fixed bug #20268 : Incorrect documentation titles in PEAR documentation - - Fixed bug #20296 : new array notion in function comma check fails - - Fixed bug #20297 : phar does not work when renamed it to phpcs - - Fixed bug #20307 : PHP_CodeSniffer_Standards_AbstractVariableSniff analyze traits - - Fixed bug #20308 : Squiz.ValidVariableNameSniff - wrong variable usage - - Fixed bug #20309 : Use "member variable" term in sniff "processMemberVar" method - - Fixed bug #20310 : PSR2 does not check for space after function name - - Fixed bug #20322 : Display rules set to type=error even when suppressing warnings - - Fixed bug #20323 : PHPCS tries to load sniffs from hidden directories - - Fixed bug #20346 : Fixer endless loop with Squiz.CSS sniffs - - Fixed bug #20355 : No sniffs are registered with PHAR on Windows - - - - - 2.0.0a2 - 2.0.0a2 - - - alpha - alpha - - 2014-05-01 - BSD License - - - Added report type --report=info to show information about the checked code to make building a standard easier - -- Checks a number of things, such as what line length you use, and spacing are brackets, but not everything - -- Still highly experimental - - Generic LineLengthSniff now shows warnings for long lines referring to licence and VCS information - -- It previously ignored these lines, but at the expense of performance - - Generic DisallowTabIndent and DisallowSpaceIndent sniffs no longer error when detecting mixed indent types - -- Only the first type of indent found on a line (space or indent) is considered - - Lots of little performance improvements that can add up to a substantial saving over large code bases - -- Added a "length" array index to tokens so you don't need to call strlen() of them, or deal with encoding - -- Can now use isset() to find tokens inside the PHP_CodeSniffer_Tokens static vars instead of in_array() - - Custom reports can now specify a $recordErrors member var; this previously only worked for built-in reports - -- When set to FALSE, error messages will not be recorded and only totals will be returned - -- This can save significant memory while processing a large code base - - Removed dependence on PHP_Timer - - PHP tokenizer now supports DEFAULT statements opened with a T_SEMICOLON - - The Squiz and PHPCS standards have increased the max padding for statement alignment from 8 to 12 - - Squiz EchoedStringsSniff now supports statements without a semicolon, such as PHP embedded in HTML - - Squiz DoubleQuoteUsageSniff now properly replaces escaped double quotes when fixing a doubled quoted string - - Improved detection of nested IF statements that use the alternate IF/ENDIF syntax - - PSR1 CamelCapsMethodNameSniff now ignores magic methods - -- Thanks to Eser Ozvataf for the patch - - PSR1 SideEffectsSniff now ignores methods named define() - - PSR1 and PEAR ClassDeclarationSniffs now support traits (request #20208) - - PSR2 ControlStructureSpacingSniff now allows newlines before/after parentheses - -- Thanks to Maurus Cuelenaere for the patch - - PSR2 ControlStructureSpacingSniff now checks TRY and CATCH statements - - Squiz SuperfluousWhitespaceSniff now detects whitespace at the end of block comment lines - -- Thanks to Klaus Purer for the patch - - Squiz LowercasePHPFunctionsSniff no longer reports errors for namespaced functions - -- Thanks to Max Galbusera for the patch - - Squiz SwitchDeclarationSniff now allows exit() as a breaking statement for case/default - - Squiz ValidVariableNameSniff and Zend ValidVariableNameSniff now ignore additional PHP reserved vars - -- Thanks to Mikuláš Dítě and Adrian Crepaz for the patch - - Sniff code Squiz.WhiteSpace.MemberVarSpacing.After changed to Squiz.WhiteSpace.MemberVarSpacing.Incorrect (request #20241) - - Fixed bug #20200 : Invalid JSON produced with specific error message - - Fixed bug #20204 : Ruleset exclude checks are case sensitive - - Fixed bug #20213 : Invalid error, Inline IF must be declared on single line - - Fixed bug #20225 : array_merge() that takes more than one line generates error - - Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting - - Fixed bug #20234 : phpcbf patch command absolute paths - - Fixed bug #20240 : Squiz block comment sniff fails when newline present - - Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while - -- Thanks to Alexander Obuhovich for the patch - - Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope - - Fixed bug #20252 : Unitialized string offset when package name starts with underscore - - - - - 2.0.0a1 - 2.0.0a1 - - - alpha - alpha - - 2014-02-05 - BSD License - - - Added the phpcbf script to automatically fix many errors found by the phpcs script - - Added report type --report=diff to show suggested changes to fix coding standard violations - - The --report argument now allows for custom reports to be used - -- Use the full path to your custom report class as the report name - - The --extensions argument is now respected when passing filenames; not just with directories - - The --extensions argument now allows you to specify the tokenizer for each extension - -- e.g., --extensions=module/php,es/js - - Command line arguments can now be set in ruleset files - -- e.g., arg name="report" value="summary" (print summary report; same as --report=summary) - -- e.g., arg value="sp" (print source and progress information; same as -sp) - -- The -vvv, --sniffs, --standard and -l command line arguments cannot be set in this way - - Sniff process() methods can not optionally return a token to ignore up to - -- If returned, the sniff will not be executed again until the passed token is reached in the file - -- Useful if you are looking for tokens like T_OPEN_TAG but only want to process the first one - - Removed the comment parser classes and replaced it with a simple comment tokenizer - -- T_DOC_COMMENT tokens are now tokenized into T_DOC_COMMENT_* tokens so they can be used more easily - -- This change requires a significant rewrite of sniffs that use the comment parser - -- This change requires minor changes to sniffs that listen for T_DOC_COMMENT tokens directly - - Added Generic DocCommentSniff to check generic doc block formatting - -- Removed doc block formatting checks from PEAR ClassCommentSniff - -- Removed doc block formatting checks from PEAR FileCommentSniff - -- Removed doc block formatting checks from PEAR FunctionCommentSniff - -- Removed doc block formatting checks from Squiz ClassCommentSniff - -- Removed doc block formatting checks from Squiz FileCommentSniff - -- Removed doc block formatting checks from Squiz FunctionCommentSniff - -- Removed doc block formatting checks from Squiz VariableCommentSniff - - Squiz DocCommentAlignmentSniff has had its error codes changed - -- NoSpaceBeforeTag becomes NoSpaceAfterStar - -- SpaceBeforeTag becomes SpaceAfterStar - -- SpaceBeforeAsterisk becomes SpaceBeforeStar - - Generic MultipleStatementAlignment now aligns assignments within a block so they fit within their max padding setting - -- The sniff previously requested the padding as 1 space if max padding was exceeded - -- It now aligns the assignment with surrounding assignments if it can - -- Removed property ignoreMultiline as multi-line assignments are now handled correctly and should not be ignored - - Squiz FunctionClosingBraceSpaceSniff now requires a blank line before the brace in all cases except function args - - Added error Squiz.Commenting.ClassComment.SpacingAfter to ensure there are no blank lines after a class comment - - Added error Squiz.WhiteSpace.MemberVarSpacing.AfterComment to ensure there are no blank lines after a member var comment - -- Fixes have also been corrected to not strip the member var comment or indent under some circumstances - -- Thanks to Mark Scherer for help with this fix - - Added error Squiz.Commenting.FunctionCommentThrowTag.Missing to ensure a throw is documented - - Removed error Squiz.Commenting.FunctionCommentThrowTag.WrongType - - Content passed via STDIN can now specify the filename to use so that sniffs can run the correct filename checks - -- Ensure the first line of the content is: phpcs_input_file: /path/to/file - - Squiz coding standard now enforces no closing PHP tag at the end of a pure PHP file - - Squiz coding standard now enforces a single newline character at the end of the file - - Squiz ClassDeclarationSniff no longer checks for a PHP ending tag after a class definition - - Squiz ControlStructureSpacingSniff now checks TRY and CATCH statements as well - - Removed MySource ChannelExceptionSniff - - - - - 1.5.6 - 1.5.6 - - - stable - stable - - 2014-12-05 - BSD License - - - JS tokenizer now detects xor statements correctly - - The --config-show command now pretty-prints the config values - -- Thanks to Ken Guest for the patch - - Setting and removing config values now catches exceptions if the config file is not writable - -- Thanks to Ken Guest for the patch - - Setting and removing config values now prints a message to confirm the action and show old values - - You can now get PHP_CodeSniffer to ignore a single line by putting @codingStandardsIgnoreLine in a comment - -- When the comment is found, the comment line and the following line will be ignored - -- Thanks to Andy Bulford for the contribution - - Generic ConstructorNameSniff no longer errors for PHP4 style constructors when __construct() is present - -- Thanks to Thibaud Fabre for the patch - - Fixed bug #280 : The --config-show option generates error when there is no config file - - Fixed bug #306 : File containing only a namespace declaration raises undefined index notice - - Fixed bug #308 : Squiz InlineIfDeclarationSniff fails on ternary operators inside closure - - Fixed bug #310 : Variadics not recognized by tokenizer - - Fixed bug #311 : Suppression of function prototype breaks checking of lines within function - - - - - 1.5.5 - 1.5.5 - - - stable - stable - - 2014-09-25 - BSD License - - - PHP tokenizer no longer converts class/function names to special tokens types - -- Class/function names such as parent and true would become special tokens such as T_PARENT and T_TRUE - - Improved closure support in Generic ScopeIndentSniff - - Improved indented PHP tag support in Generic ScopeIndentSniff - - Generic CamelCapsFunctionNameSniff now ignores a single leading underscore - -- Thanks to Alex Slobodiskiy for the patch - - Standards can now be located within hidden directories (further fix for bug #20323) - -- Thanks to Klaus Purer for the patch - - Added Generic SyntaxSniff to check for syntax errors in PHP files - -- Thanks to Blaine Schmeisser for the contribution - - Squiz DiscouragedFunctionsSniff now warns about var_dump() - - PEAR ValidFunctionNameSniff no longer throws an error for _() - - Squiz and PEAR FunctionCommentSnif now support _() - - Generic UpperCaseConstantSniff and LowerCaseConstantSniff now ignore function names - - Fixed bug #248 : FunctionCommentSniff expects ampersand on param name - - Fixed bug #265 : False positives with type hints in ForbiddenFunctionsSniff - - Fixed bug #20373 : Inline comment sniff tab handling way - - Fixed bug #20378 : Report appended to existing file if no errors found in run - - Fixed bug #20381 : Invalid "Comment closer must be on a new line" - -- Thanks to Brad Kent for the patch - - Fixed bug #20386 : Squiz.Commenting.ClassComment.SpacingBefore thrown if first block comment - - - - - 1.5.4 - 1.5.4 - - - stable - stable - - 2014-08-06 - BSD License - - - Removed use of sys_get_temp_dir() as this is not supported by the min PHP version - - The installed_paths config var now accepts relative paths - -- The paths are relative to the PHP_CodeSniffer install directory - -- Thanks to Weston Ruter for the patch - - Generic ScopeIndentSniff now accounts for different open tag indents - - PEAR FunctionDeclarationSniff now ignores short arrays when checking indent - -- Thanks to Daniel Tschinder for the patch - - PSR2 FunctionCallSignatureSniff now treats multi-line strings as a single-line argument, like arrays and closures - -- Thanks to Dawid Nowak for the patch - - Generic ForbiddenFunctionsSniff now detects calls to functions in the global namespace - -- Thanks to Ole Martin Handeland for the patch - - Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore namespaces beginning with TRUE/FALSE/NULL - -- Thanks to Renan Gonçalves for the patch - - Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request #20299) - - Squiz SelfMemberReferenceSniff now works correctly with namespaces - - Tab characters are now encoded in abstract pattern errors messages - -- Thanks to Blaine Schmeisser for the patch - - Invalid sniff codes passed to --sniffs now show a friendly error message (request #20313) - - Generic LineLengthSniff now shows a warning if the iconv module is disabled (request #20314) - - Source report no longer shows errors if category or sniff names ends in an uppercase error - -- Thanks to Jonathan Marcil for the patch - - Fixed bug #20268 : Incorrect documentation titles in PEAR documentation - - Fixed bug #20296 : new array notion in function comma check fails - - Fixed bug #20307 : PHP_CodeSniffer_Standards_AbstractVariableSniff analyze traits - - Fixed bug #20308 : Squiz.ValidVariableNameSniff - wrong variable usage - - Fixed bug #20309 : Use "member variable" term in sniff "processMemberVar" method - - Fixed bug #20310 : PSR2 does not check for space after function name - - Fixed bug #20322 : Display rules set to type=error even when suppressing warnings - - Fixed bug #20323 : PHPCS tries to load sniffs from hidden directories - - - - - 1.5.3 - 1.5.3 - - - stable - stable - - 2014-05-01 - BSD License - - - Improved detection of nested IF statements that use the alternate IF/ENDIF syntax - - PHP tokenizer now supports DEFAULT statements opened with a T_SEMICOLON - - PSR1 CamelCapsMethodNameSniff now ignores magic methods - -- Thanks to Eser Ozvataf for the patch - - PSR1 SideEffectsSniff now ignores methods named define() - - PSR1 and PEAR ClassDeclarationSniffs now support traits (request #20208) - - PSR2 ControlStructureSpacingSniff now allows newlines before/after parentheses - -- Thanks to Maurus Cuelenaere for the patch - - Squiz LowercasePHPFunctionsSniff no longer reports errors for namespaced functions - -- Thanks to Max Galbusera for the patch - - Squiz SwitchDeclarationSniff now allows exit() as a breaking statement for case/default - - Squiz ValidVariableNameSniff and Zend ValidVariableNameSniff now ignore additional PHP reserved vars - -- Thanks to Mikuláš Dítě and Adrian Crepaz for the patch - - Sniff code Squiz.WhiteSpace.MemberVarSpacing.After changed to Squiz.WhiteSpace.MemberVarSpacing.Incorrect (request #20241) - - Fixed bug #20200 : Invalid JSON produced with specific error message - - Fixed bug #20204 : Ruleset exclude checks are case sensitive - - Fixed bug #20213 : Invalid error, Inline IF must be declared on single line - - Fixed bug #20225 : array_merge() that takes more than one line generates error - - Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting - - Fixed bug #20240 : Squiz block comment sniff fails when newline present - - Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while - -- Thanks to Alexander Obuhovich for the patch - - Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope - - Fixed bug #20252 : Uninitialized string offset when package name starts with underscore - - - - - 1.5.2 - 1.5.2 - - - stable - stable - - 2014-02-05 - BSD License - - - Improved support for the PHP 5.5. classname::class syntax - -- PSR2 SwitchDeclarationSniff no longer throws errors when this syntax is used in CASE conditions - - Improved support for negative checks of instanceOf in Squiz ComparisonOperatorUsageSniff - -- Thanks to Martin Winkel for the patch - - Generic FunctionCallArgumentSpacingSniff now longer complains about space before comma when using here/nowdocs - -- Thanks to Richard van Velzen for the patch - - Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore class constants - -- Thanks to Kristopher Wilson for the patch - - PEAR FunctionCallSignatureSniff now has settings to specify how many spaces should appear before/after parentheses - -- Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change - -- Default remains at 0 for both - -- Thanks to Astinus Eberhard for the patch - - PSR2 ControlStructureSpacingSniff now has settings to specify how many spaces should appear before/after parentheses - -- Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change - -- Default remains at 0 for both - -- Thanks to Astinus Eberhard for the patch - - Squiz ForEachLoopDeclarationSniff now has settings to specify how many spaces should appear before/after parentheses - -- Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change - -- Default remains at 0 for both - -- Thanks to Astinus Eberhard for the patch - - Squiz ForLoopDeclarationSniff now has settings to specify how many spaces should appear before/after parentheses - -- Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change - -- Default remains at 0 for both - -- Thanks to Astinus Eberhard for the patch - - Squiz FunctionDeclarationArgumentSpacingSniff now has settings to specify how many spaces should appear before/after parentheses - -- Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change - -- Default remains at 0 for both - -- Thanks to Astinus Eberhard for the patch - - Removed UnusedFunctionParameter, CyclomaticComplexity and NestingLevel from the Squiz standard - - Generic FixmeSniff and TodoSniff now work correctly with accented characters - - Fixed bug #20145 : Custom ruleset preferences directory over installed standard - - Fixed bug #20147 : phpcs-svn-pre-commit - no more default error report - - Fixed bug #20151 : Problem handling "if(): ... else: ... endif;" syntax - - Fixed bug #20190 : Invalid regex in Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff - - - - - 1.5.1 - 1.5.1 - - - stable - stable - - 2013-12-12 - BSD License - - - Config values can now be set at runtime using the command line argument [--runtime-set key value] - -- Runtime values are the same as config values, but are not written to the main config file - -- Thanks to Wim Godden for the patch - - Config values can now be set in ruleset files - -- e.g., config name="zend_ca_path" value="/path/to/ZendCodeAnalyzer" - -- Can not be used to set config values that override command line values, such as show_warnings - -- Thanks to Jonathan Marcil for helping with the patch - - Added a new installed_paths config value to allow for the setting of directories that contain standards - -- By default, standards have to be installed into the CodeSniffer/Standards directory to be considered installed - -- New config value allows a list of paths to be set in addition to this internal path - -- Installed standards appear when using the -i arg, and can be referenced in rulesets using only their name - -- Set paths by running: phpcs --config-set installed_paths /path/one,/path/two,... - - PSR2 ClassDeclarationSniff now allows a list of extended interfaces to be split across multiple lines - - Squiz DoubleQuoteUsageSniff now allows \b in double quoted strings - - Generic ForbiddenFunctionsSniff now ignores object creation - -- This is a further fix for bug #20100 : incorrect Function mysql() has been deprecated report - - Fixed bug #20136 : Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff and Traits - - Fixed bug #20138 : Protected property underscore and camel caps issue (in trait with Zend) - -- Thanks to Gaetan Rousseau for the patch - - Fixed bug #20139 : No report file generated on success - - - - - 1.5.0 - 1.5.0 - - - stable - stable - - 2013-11-28 - BSD License - - - Doc generation is now working again for installed standards - -- Includes a fix for limiting the docs to specific sniffs - - Generic ScopeIndentSniff now allows for ignored tokens to be set via ruleset.xml files - -- E.g., to ignore comments, override a property using: - -- name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT" - - PSR2 standard now ignores comments when checking indentation rules - - Generic UpperCaseConstantNameSniff no longer reports errors where constants are used (request #20090) - -- It still reports errors where constants are defined - - Individual messages can now be excluded in ruleset.xml files using the exclude tag (request #20091) - -- Setting message severity to 0 continues to be supported - - Squiz OperatorSpacingSniff no longer throws errors for the ?: short ternary operator - -- Thanks to Antoine Musso for the patch - - Comment parser now supports non-English characters when splitting comment lines into words - -- Thanks to Nik Sun for the patch - - Exit statements are now recognised as valid closers for CASE and DEFAULT blocks - -- Thanks to Maksim Kochkin for the patch - - PHP_CodeSniffer_CLI::process() can now be passed an incomplete array of CLI values - -- Missing values will be set to the CLI defaults - -- Thanks to Maksim Kochkin for the patch - - Fixed bug #20093 : Bug with ternary operator token - - Fixed bug #20097 : CLI.php throws error in php 5.2 - - Fixed bug #20100 : incorrect Function mysql() has been deprecated report - - Fixed bug #20119 : PHP warning: invalid argument to str_repeat() in SVN blame report with -s - - Fixed bug #20123 : PSR2 complains about an empty second statement in for-loop - - Fixed bug #20131 : PHP errors in svnblame report, if there are files not under version control - - Fixed bug #20133 : Allow "HG: hg_id" as value for @version tag - - - - - 1.5.0RC4 - 1.5.0RC4 - - - beta - beta - - 2013-09-26 - BSD License - - - You can now restrict violations to individual sniff codes using the --sniffs command line argument - -- Previously, this only restricted violations to an entire sniff and not individual messages - -- If you have scripts calling PHP_CodeSniffer::process() or creating PHP_CodeSniffer_File objects, you must update your code - -- The array of restrictions passed to PHP_CodeSniffer::process() must now be an array of sniff codes instead of class names - -- The PHP_CodeSniffer_File::__construct() method now requires an array of restrictions to be passed - - Doc generation is now working again - - Progress information now shows the percentage complete at the end of each line - - Added report type --report=junit to show the error list in a JUnit compatible format - -- Thanks to Oleg Lobach for the contribution - - Added support for the PHP 5.4 callable type hint - - Fixed problem where some file content could be ignored when checking STDIN - - Version information is now printed when installed via composer or run from a Git clone (request #20050) - - Added Squiz DisallowBooleanStatementSniff to ban boolean operators outside of control structure conditions - - The CSS tokenizer is now more reliable when encountering 'list' and 'break' strings - - Coding standard ignore comments can now appear instead doc blocks as well as inline comments - -- Thanks to Stuart Langley for the patch - - Generic LineLengthSniff now ignores SVN URL and Head URL comments - -- Thanks to Karl DeBisschop for the patch - - PEAR MultiLineConditionSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - -- Thanks to Szabolcs Sulik for the patch - - PEAR MultiLineAssignmentSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - -- Thanks to Szabolcs Sulik for the patch - - PEAR FunctionDeclarationSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - -- Thanks to Szabolcs Sulik for the patch - - Squiz SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - -- Thanks to Szabolcs Sulik for the patch - - Squiz CSS IndentationSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - -- Thanks to Hugo Fonseca for the patch - - Squiz and MySource File and Function comment sniffs now allow all tags and don't require a particular licence - - Squiz standard now allows lines to be 120 characters long before warning; up from 85 - - Squiz LowercaseStyleDefinitionSniff no longer throws errors for class names in nested style definitions - - Squiz ClassFileNameSniff no longer throws errors when checking STDIN - - Squiz CSS sniffs no longer generate errors for IE filters - - Squiz CSS IndentationSniff no longer sees comments as blank lines - - Squiz LogicalOperatorSpacingSniff now ignores whitespace at the end of a line - - Squiz.Scope.MethodScope.Missing error message now mentions 'visibility' instead of 'scope modifier' - -- Thanks to Renat Akhmedyanov for the patch - - Added support for the PSR2 multi-line arguments errata - - The PSR2 standard no longer throws errors for additional spacing after a type hint - - PSR UseDeclarationSniff no longer throws errors for USE statements inside TRAITs - - Fixed cases where code was incorrectly assigned the T_GOTO_LABEL token when used in a complex CASE condition - - Fixed bug #20026 : Check for multi-line arrays that should be single-line is slightly wrong - -- Adds new error message for single-line arrays that end with a comma - - Fixed bug #20029 : ForbiddenFunction sniff incorrectly recognizes methods in USE clauses - - Fixed bug #20043 : Mis-interpretation of Foo::class - - Fixed bug #20044 : PSR1 camelCase check does not ignore leading underscores - - Fixed bug #20045 : Errors about indentation for closures with multi-line 'use' in functions - - Fixed bug #20051 : Undefined index: scope_opener / scope_closer - -- Thanks to Anthon Pang for the patch - - - - - 1.5.0RC3 - 1.5.0RC3 - - - beta - beta - - 2013-07-25 - BSD License - - - Added report type --report=json to show the error list and total counts for all checked files - -- Thanks to Jeffrey Fisher for the contribution - - PHP_CodeSniffer::isCamelCaps now allows for acronyms at the start of a string if the strict flag is FALSE - -- acronyms are defined as at least 2 uppercase characters in a row - -- e.g., the following is now valid camel caps with strict set to FALSE: XMLParser - - The PHP tokenizer now tokenizes goto labels as T_GOTO_LABEL instead of T_STRING followed by T_COLON - - The JS tokenizer now has support for the T_THROW token - - Symlinked directories inside CodeSniffer/Standards and in ruleset.xml files are now supported - -- Only available since PHP 5.2.11 and 5.3.1 - -- Thanks to Maik Penz for the patch - - The JS tokenizer now correctly identifies T_INLINE_ELSE tokens instead of leaving them as T_COLON - -- Thanks to Arnout Boks for the patch - - Explaining a standard (phpcs -e) that uses namespaces now works correctly - - Restricting a check to specific sniffs (phpcs --sniffs=...) now works correctly with namespaced sniffs - -- Thanks to Maik Penz for the patch - - Docs added for the entire Generic standard, and many sniffs from other standards are now documented as well - -- Thanks to Spencer Rinehart for the contribution - - Clearer error message for when the sniff class name does not match the directory structure - - Generated HTML docs now correctly show the open PHP tag in code comparison blocks - - Added Generic InlineHTMLSniff to ensure a file only contains PHP code - - Added Squiz ShorthandSizeSniff to check that CSS sizes are using shorthand notation only when 1 or 2 values are used - - Added Squiz ForbiddenStylesSniff to ban the use of some deprecated browser-specific styles - - Added Squiz NamedColoursSniff to ban the use of colour names - - PSR2 standard no longer enforces no whitespace between the closing parenthesis of a function call and the semicolon - - PSR2 ClassDeclarationSniff now ignores empty classes when checking the end brace position - - PSR2 SwitchDeclarationSniff no longer reports errors for empty lines between CASE statements - - PEAR ObjectOperatorIndentSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the indent setting in a ruleset.xml file to change - -- Thanks to Andrey Mindubaev for the patch - - Squiz FileExtensionSniff now supports traits - -- Thanks to Lucas Green for the patch - - Squiz ArrayDeclarationSniff no longer reports errors for no comma at the end of a line that contains a function call - - Squiz SwitchDeclarationSniff now supports T_CONTINUE and T_THROW as valid case/default breaking statements - - Squiz CommentedOutCodeSniff is now better at ignoring commented out HTML, XML and regular expressions - - Squiz DisallowComparisonAssignmentSniff no longer throws errors for the third expression in a FOR statement - - Squiz ColourDefinitionSniff no longer throws errors for some CSS class names - - Squiz ControlStructureSpacingSniff now supports all types of CASE/DEFAULT breaking statements - - Generic CallTimePassByReferenceSniff now reports errors for functions called using a variable - -- Thanks to Maik Penz for the patch - - Generic ConstructorNameSniff no longer throws a notice for abstract constructors inside abstract classes - -- Thanks to Spencer Rinehart for the patch - - Squiz ComparisonOperatorUsageSniff now checks inside elseif statements - -- Thanks to Arnout Boks for the patch - - Squiz OperatorSpacingSniff now reports errors for no spacing around inline then and else tokens - -- Thanks to Arnout Boks for the patch - - Fixed bug #19811 : Comments not ignored in all cases in AbstractPatternSniff - -- Thanks to Erik Wiffin for the patch - - Fixed bug #19892 : ELSE with no braces causes incorrect SWITCH break statement indentation error - - Fixed bug #19897 : Indenting warnings in templates not consistent - - Fixed bug #19908 : PEAR MultiLineCondition Does Not Apply elseif - - Fixed bug #19930 : option --report-file generate an empty file - - Fixed bug #19935 : notify-send reports do not vanish in gnome-shell - -- Thanks to Christian Weiske for the patch - - Fixed bug #19944 : docblock squiz sniff "return void" trips over return in lambda function - - Fixed bug #19953 : PSR2 - Spaces before interface name for abstract class - - Fixed bug #19956 : phpcs warns for Type Hint missing Resource - - Fixed bug #19957 : Does not understand trait method aliasing - - Fixed bug #19968 : Permission denied on excluded directory - - Fixed bug #19969 : Sniffs with namespace not recognized in reports - - Fixed bug #19997 : Class names incorrectly detected as constants - - - - - 1.5.0RC2 - 1.5.0RC2 - - - beta - beta - - 2013-04-04 - BSD License - - - Ruleset processing has been rewritten to be more predictable - -- Provides much better support for relative paths inside ruleset files - -- May mean that sniffs that were previously ignored are now being included when importing external rulesets - -- Ruleset processing output can be seen by using the -vv command line argument - -- Internal sniff registering functions have all changed, so please review custom scripts - - You can now pass multiple coding standards on the command line, comma separated (request #19144) - -- Works with built-in or custom standards and rulesets, or a mix of both - - You can now exclude directories or whole standards in a ruleset XML file (request #19731) - -- e.g., exclude "Generic.Commenting" or just "Generic" - -- You can also pass in a path to a directory instead, if you know it - - Added Generic LowerCaseKeywordSniff to ensure all PHP keywords are defined in lowercase - -- The PSR2 and Squiz standards now use this sniff - - Added Generic SAPIUsageSniff to ensure the PHP_SAPI constant is used instead of php_sapi_name() (request #19863) - - Squiz FunctionSpacingSniff now has a setting to specify how many lines there should between functions (request #19843) - -- Default remains at 2 - -- Override the "spacing" setting in a ruleset.xml file to change - - Squiz LowercasePHPFunctionSniff no longer throws errors for the limited set of PHP keywords it was checking - -- Add a rule for Generic.PHP.LowerCaseKeyword to your ruleset to replicate this functionality - - Added support for the PHP 5.4 T_CALLABLE token so it can be used in lower PHP versions - - Generic EndFileNoNewlineSniff now supports checking of CSS and JS files - - PSR2 SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the indent setting in a ruleset.xml file to change - -- Thanks to Asher Snyder for the patch - - Generic ScopeIndentSniff now has a setting to specify a list of tokens that should be ignored - -- The first token on the line is checked and the whole line is ignored if the token is in the array - -- Thanks to Eloy Lafuente for the patch - - Squiz LowercaseClassKeywordsSniff now checks for the TRAIT keyword - -- Thanks to Anthon Pang for the patch - - If you create your own PHP_CodeSniffer object, PHPCS will no longer exit when an unknown argument is found - -- This allows you to create wrapper scripts for PHPCS more easily - - PSR2 MethodDeclarationSniff no longer generates a notice for methods named "_" - -- Thanks to Bart S for the patch - - Squiz BlockCommentSniff no longer reports that a blank line between a scope closer and block comment is invalid - - Generic DuplicateClassNameSniff no longer reports an invalid error if multiple PHP open tags exist in a file - - Generic DuplicateClassNameSniff no longer reports duplicate errors if multiple PHP open tags exist in a file - - Fixed bug #19819 : Freeze with syntax error in use statement - - Fixed bug #19820 : Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff - - Fixed bug #19859 : CodeSniffer::setIgnorePatterns API changed - - Fixed bug #19871 : findExtendedClassName doesn't return FQCN on namespaced classes - - Fixed bug #19879 : bitwise and operator interpreted as reference by value - - - - - 1.5.0RC1 - 1.5.0RC1 - - - beta - beta - - 2013-02-08 - BSD License - - - Reports have been completely rewritten to consume far less memory - -- Each report is incrementally written to the file system during a run and then printed out when the run ends - -- There is no longer a need to keep the list of errors and warnings in memory during a run - - Multi-file sniff support has been removed because they are too memory intensive - -- If you have a custom multi-file sniff, you can convert it into a standard sniff quite easily - -- See CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php for an example - - - - - 1.4.8 - 1.4.8 - - - stable - stable - - 2013-11-26 - BSD License - - - Generic ScopeIndentSniff now allows for ignored tokens to be set via ruleset.xml files - -- E.g., to ignore comments, override a property using: - -- name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT" - - PSR2 standard now ignores comments when checking indentation rules - - Squiz OperatorSpacingSniff no longer throws errors for the ?: short ternary operator - -- Thanks to Antoine Musso for the patch - - Comment parser now supports non-English characters when splitting comment lines into words - -- Thanks to Nik Sun for the patch - - Exit statements are now recognised as valid closers for CASE and DEFAULT blocks - -- Thanks to Maksim Kochkin for the patch - - PHP_CodeSniffer_CLI::process() can now be passed an incomplete array of CLI values - -- Missing values will be set to the CLI defaults - -- Thanks to Maksim Kochkin for the patch - - Fixed bug #20097 : CLI.php throws error in php 5.2 - - Fixed bug #20100 : incorrect Function mysql() has been deprecated report - - Fixed bug #20119 : PHP warning: invalid argument to str_repeat() in SVN blame report with -s - - Fixed bug #20123 : PSR2 complains about an empty second statement in for-loop - - Fixed bug #20131 : PHP errors in svnblame report, if there are files not under version control - - Fixed bug #20133 : Allow "HG: hg_id" as value for @version tag - - - - - 1.4.7 - 1.4.7 - - - stable - stable - - 2013-09-26 - BSD License - - - Added report type --report=junit to show the error list in a JUnit compatible format - -- Thanks to Oleg Lobach for the contribution - - Added support for the PHP 5.4 callable type hint - - Fixed problem where some file content could be ignored when checking STDIN - - Version information is now printed when installed via composer or run from a Git clone (request #20050) - - The CSS tokenizer is now more reliable when encountering 'list' and 'break' strings - - Coding standard ignore comments can now appear instead doc blocks as well as inline comments - -- Thanks to Stuart Langley for the patch - - Generic LineLengthSniff now ignores SVN URL and Head URL comments - -- Thanks to Karl DeBisschop for the patch - - PEAR MultiLineConditionSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - -- Thanks to Szabolcs Sulik for the patch - - PEAR MultiLineAssignmentSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - -- Thanks to Szabolcs Sulik for the patch - - PEAR FunctionDeclarationSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - -- Thanks to Szabolcs Sulik for the patch - - Squiz SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - -- Thanks to Szabolcs Sulik for the patch - - Squiz CSS IndentationSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - -- Thanks to Hugo Fonseca for the patch - - Squiz and MySource File and Function comment sniffs now allow all tags and don't require a particular licence - - Squiz LowercaseStyleDefinitionSniff no longer throws errors for class names in nested style definitions - - Squiz ClassFileNameSniff no longer throws errors when checking STDIN - - Squiz CSS sniffs no longer generate errors for IE filters - - Squiz CSS IndentationSniff no longer sees comments as blank lines - - Squiz LogicalOperatorSpacingSniff now ignores whitespace at the end of a line - - Squiz.Scope.MethodScope.Missing error message now mentions 'visibility' instead of 'scope modifier' - -- Thanks to Renat Akhmedyanov for the patch - - Added support for the PSR2 multi-line arguments errata - - The PSR2 standard no longer throws errors for additional spacing after a type hint - - PSR UseDeclarationSniff no longer throws errors for USE statements inside TRAITs - - Fixed bug #20026 : Check for multi-line arrays that should be single-line is slightly wrong - -- Adds new error message for single-line arrays that end with a comma - - Fixed bug #20029 : ForbiddenFunction sniff incorrectly recognizes methods in USE clauses - - Fixed bug #20043 : Mis-interpretation of Foo::class - - Fixed bug #20044 : PSR1 camelCase check does not ignore leading underscores - - Fixed bug #20045 : Errors about indentation for closures with multi-line 'use' in functions - - - - - 1.4.6 - 1.4.6 - - - stable - stable - - 2013-07-25 - BSD License - - - Added report type --report=json to show the error list and total counts for all checked files - -- Thanks to Jeffrey Fisher for the contribution - - The JS tokenizer now has support for the T_THROW token - - Symlinked directories inside CodeSniffer/Standards and in ruleset.xml files are now supported - -- Only available since PHP 5.2.11 and 5.3.1 - -- Thanks to Maik Penz for the patch - - The JS tokenizer now correctly identifies T_INLINE_ELSE tokens instead of leaving them as T_COLON - -- Thanks to Arnout Boks for the patch - - Explaining a standard (phpcs -e) that uses namespaces now works correctly - - Restricting a check to specific sniffs (phpcs --sniffs=...) now works correctly with namespaced sniffs - -- Thanks to Maik Penz for the patch - - Docs added for the entire Generic standard, and many sniffs from other standards are now documented as well - -- Thanks to Spencer Rinehart for the contribution - - Clearer error message for when the sniff class name does not match the directory structure - - Generated HTML docs now correctly show the open PHP tag in code comparison blocks - - Added Generic InlineHTMLSniff to ensure a file only contains PHP code - - Added Squiz ShorthandSizeSniff to check that CSS sizes are using shorthand notation only when 1 or 2 values are used - - Added Squiz ForbiddenStylesSniff to ban the use of some deprecated browser-specific styles - - Added Squiz NamedColoursSniff to ban the use of colour names - - PSR2 standard no longer enforces no whitespace between the closing parenthesis of a function call and the semicolon - - PSR2 ClassDeclarationSniff now ignores empty classes when checking the end brace position - - PSR2 SwitchDeclarationSniff no longer reports errors for empty lines between CASE statements - - PEAR ObjectOperatorIndentSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the indent setting in a ruleset.xml file to change - -- Thanks to Andrey Mindubaev for the patch - - Squiz FileExtensionSniff now supports traits - -- Thanks to Lucas Green for the patch - - Squiz ArrayDeclarationSniff no longer reports errors for no comma at the end of a line that contains a function call - - Squiz SwitchDeclarationSniff now supports T_CONTINUE and T_THROW as valid case/default breaking statements - - Squiz CommentedOutCodeSniff is now better at ignoring commented out HTML, XML and regular expressions - - Squiz DisallowComparisonAssignmentSniff no longer throws errors for the third expression in a FOR statement - - Squiz ColourDefinitionSniff no longer throws errors for some CSS class names - - Squiz ControlStructureSpacingSniff now supports all types of CASE/DEFAULT breaking statements - - Generic CallTimePassByReferenceSniff now reports errors for functions called using a variable - -- Thanks to Maik Penz for the patch - - Generic ConstructorNameSniff no longer throws a notice for abstract constructors inside abstract classes - -- Thanks to Spencer Rinehart for the patch - - Squiz ComparisonOperatorUsageSniff now checks inside elseif statements - -- Thanks to Arnout Boks for the patch - - Squiz OperatorSpacingSniff now reports errors for no spacing around inline then and else tokens - -- Thanks to Arnout Boks for the patch - - Fixed bug #19811 : Comments not ignored in all cases in AbstractPatternSniff - -- Thanks to Erik Wiffin for the patch - - Fixed bug #19892 : ELSE with no braces causes incorrect SWITCH break statement indentation error - - Fixed bug #19897 : Indenting warnings in templates not consistent - - Fixed bug #19908 : PEAR MultiLineCondition Does Not Apply elseif - - Fixed bug #19913 : Running phpcs in interactive mode causes warnings - -- Thanks to Harald Franndorfer for the patch - - Fixed bug #19935 : notify-send reports do not vanish in gnome-shell - -- Thanks to Christian Weiske for the patch - - Fixed bug #19944 : docblock squiz sniff "return void" trips over return in lambda function - - Fixed bug #19953 : PSR2 - Spaces before interface name for abstract class - - Fixed bug #19956 : phpcs warns for Type Hint missing Resource - - Fixed bug #19957 : Does not understand trait method aliasing - - Fixed bug #19968 : Permission denied on excluded directory - - Fixed bug #19969 : Sniffs with namespace not recognized in reports - - Fixed bug #19997 : Class names incorrectly detected as constants - - - - - 1.4.5 - 1.4.5 - - - stable - stable - - 2013-04-04 - BSD License - - - Added Generic LowerCaseKeywordSniff to ensure all PHP keywords are defined in lowercase - -- The PSR2 and Squiz standards now use this sniff - - Added Generic SAPIUsageSniff to ensure the PHP_SAPI constant is used instead of php_sapi_name() (request #19863) - - Squiz FunctionSpacingSniff now has a setting to specify how many lines there should between functions (request #19843) - -- Default remains at 2 - -- Override the "spacing" setting in a ruleset.xml file to change - - Squiz LowercasePHPFunctionSniff no longer throws errors for the limited set of PHP keywords it was checking - -- Add a rule for Generic.PHP.LowerCaseKeyword to your ruleset to replicate this functionality - - Added support for the PHP 5.4 T_CALLABLE token so it can be used in lower PHP versions - - Generic EndFileNoNewlineSniff now supports checking of CSS and JS files - - PSR2 SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented - -- Default remains at 4; override the indent setting in a ruleset.xml file to change - -- Thanks to Asher Snyder for the patch - - Generic ScopeIndentSniff now has a setting to specify a list of tokens that should be ignored - -- The first token on the line is checked and the whole line is ignored if the token is in the array - -- Thanks to Eloy Lafuente for the patch - - Squiz LowercaseClassKeywordsSniff now checks for the TRAIT keyword - -- Thanks to Anthon Pang for the patch - - If you create your own PHP_CodeSniffer object, PHPCS will no longer exit when an unknown argument is found - -- This allows you to create wrapper scripts for PHPCS more easily - - PSR2 MethodDeclarationSniff no longer generates a notice for methods named "_" - -- Thanks to Bart S for the patch - - Squiz BlockCommentSniff no longer reports that a blank line between a scope closer and block comment is invalid - - Generic DuplicateClassNameSniff no longer reports an invalid error if multiple PHP open tags exist in a file - - Generic DuplicateClassNameSniff no longer reports duplicate errors if multiple PHP open tags exist in a file - - Fixed bug #19819 : Freeze with syntax error in use statement - - Fixed bug #19820 : Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff - - Fixed bug #19859 : CodeSniffer::setIgnorePatterns API changed - - Fixed bug #19871 : findExtendedClassName doesn't return FQCN on namespaced classes - - Fixed bug #19879 : bitwise and operator interpreted as reference by value - - - - - 1.4.4 - 1.4.4 - - - stable - stable - - 2013-02-07 - BSD License - - - Ignored lines no longer cause the summary report to show incorrect error and warning counts - -- Thanks to Bert Van Hauwaert for the patch - - Added Generic CSSLintSniff to run CSSLint over a CSS file and report warnings - -- Set full command to run CSSLint using phpcs --config-set csslint_path /path/to/csslint - -- Thanks to Roman Levishchenko for the contribution - - Added PSR2 ControlStructureSpacingSniff to ensure there are no spaces before and after parenthesis in control structures - -- Fixes bug #19732 : PSR2: some control structures errors not reported - - Squiz commenting sniffs now support non-English characters when checking for capital letters - -- Thanks to Roman Levishchenko for the patch - - Generic EndFileNewlineSniff now supports JS and CSS files - -- Thanks to Denis Ryabkov for the patch - - PSR1 SideEffectsSniff no longer reports constant declarations as side effects - - Notifysend report now supports notify-send versions before 0.7.3 - -- Thanks to Ken Guest for the patch - - PEAR and Squiz FunctionCommentSniffs no longer report errors for misaligned argument comments when they are blank - -- Thanks to Thomas Peterson for the patch - - Squiz FunctionDeclarationArgumentSpacingSniff now works correctly for equalsSpacing values greater than 0 - -- Thanks to Klaus Purer for the patch - - Squiz SuperfluousWhitespaceSniff no longer throws errors for CSS files with no newline at the end - - Squiz SuperfluousWhitespaceSniff now allows a single newline at the end of JS and CSS files - - Fixed bug #19755 : Token of T_CLASS type has no scope_opener and scope_closer keys - - Fixed bug #19759 : Squiz.PHP.NonExecutableCode fails for return function()... - - Fixed bug #19763 : Use statements for traits not recognised correctly for PSR2 code style - - Fixed bug #19764 : Instead of for traits throws uppercase constant name errors - - Fixed bug #19772 : PSR2_Sniffs_Namespaces_UseDeclarationSniff does not properly recognize last use - - Fixed bug #19775 : False positive in NonExecutableCode sniff when not using curly braces - - Fixed bug #19782 : Invalid found size functions in loop when using object operator - - Fixed bug #19799 : config folder is not created automatically - - Fixed bug #19804 : JS Tokenizer wrong /**/ parsing - - - - - 1.4.3 - 1.4.3 - - - stable - stable - - 2012-12-04 - BSD License - - - Added support for the PHP 5.5 T_FINALLY token to detect try/catch/finally statements - - Added empty CodeSniffer.conf to enable config settings for Composer installs - - Added Generic EndFileNoNewlineSniff to ensure there is no newline at the end of a file - - Autoloader can now load PSR-0 compliant classes - -- Thanks to Maik Penz for the patch - - Squiz NonExecutableCodeSniff no longer throws error for multi-line RETURNs inside CASE statements - -- Thanks to Marc Ypes for the patch - - Squiz OperatorSpacingSniff no longer reports errors for negative numbers inside inline THEN statements - -- Thanks to Klaus Purer for the patch - - Squiz OperatorSpacingSniff no longer reports errors for the assignment of operations involving negative numbers - - Squiz SelfMemberReferenceSniff can no longer get into an infinite loop when checking a static call with a namespace - -- Thanks to Andy Grunwald for the patch - - Fixed bug #19699 : Generic.Files.LineLength giving false positives when tab-width is used - - Fixed bug #19726 : Wrong number of spaces expected after instanceof static - - Fixed bug #19727 : PSR2: no error reported when using } elseif { - - - - - 1.4.2 - 1.4.2 - - - stable - stable - - 2012-11-09 - BSD License - - - PHP_CodeSniffer can now be installed using Composer - -- Require squizlabs/php_codesniffer in your composer.json file - -- Thanks to Rob Bast, Stephen Rees-Carter, Stefano Kowalke and Ivan Habunek for help with this - - Squiz BlockCommentSniff and InlineCommentSniff no longer report errors for trait block comments - - Squiz SelfMemberReferenceSniff now supports namespaces - -- Thanks to Andy Grunwald for the patch - - Squiz FileCommentSniff now uses tag names inside the error codes for many messages - -- This allows you to exclude specific missing, out of order etc., tags - - Squiz SuperfluousWhitespaceSniff now has an option to ignore blank lines - -- This will stop errors being reported for lines that contain only whitespace - -- Set the ignoreBlankLines property to TRUE in your ruleset.xml file to enable this - - PSR2 no longer reports errors for whitespace at the end of blank lines - - Fixed gitblame report not working on Windows - -- Thanks to Rogerio Prado de Jesus - - Fixed an incorrect error in Squiz OperatorSpacingSniff for default values inside a closure definition - - Fixed bug #19691 : SubversionPropertiesSniff fails to find missing properties - -- Thanks to Kevin Winahradsky for the patch - - Fixed bug #19692 : DisallowMultipleAssignments is triggered by a closure - - Fixed bug #19693 : exclude-patterns no longer work on specific messages - - Fixed bug #19694 : Squiz.PHP.LowercasePHPFunctions incorrectly matches return by ref functions - - - - - 1.4.1 - 1.4.1 - - - stable - stable - - 2012-11-02 - BSD License - - - All ignore patterns have been reverted to being checked against the absolute path of a file - -- Patterns can be specified to be relative in a ruleset.xml file, but nowhere else - -- e.g., [exclude-pattern type="relative"]^tests/*[/exclude-pattern] (with angle brackets, not square brackets) - - Added support for PHP tokenizing of T_INLINE_ELSE colons, so this token type is now available - -- Custom sniffs that rely on looking for T_COLON tokens inside inline if statements must be changed to use the new token - -- Fixes bug #19666 : PSR1.Files.SideEffects throws a notice Undefined index: scope_closer - - Messages can now be changed from errors to warnings (and vice versa) inside ruleset.xml files - -- As you would with "message" and "severity", specify a "type" tag under a "rule" tag and set the value to "error" or "warning" - - PHP_CodeSniffer will now generate a warning on files that it detects have mixed line endings - -- This warning has the code Internal.LineEndings.Mixed and can be overridden in a ruleset.xml file - -- Thanks to Vit Brunner for help with this - - Sniffs inside PHP 5.3 namespaces are now supported, along with the existing underscore-style emulated namespaces - -- For example: namespace MyStandard\Sniffs\Arrays; class ArrayDeclarationSniff implements \PHP_CodeSniffer_Sniff { ... - -- Thanks to Till Klampaeckel for the patch - - Generic DuplicateClassNameSniff is no longer a multi-file sniff, so it won't max out your memory - -- Multi-file sniff support should be considered deprecated as standard sniffs can now do the same thing - - Added Generic DisallowSpaceIndent to check that files are indented using tabs - - Added Generic OneClassPerFileSniff to check that only one class is defined in each file - -- Thanks to Andy Grunwald for the contribution - - Added Generic OneInterfacePerFileSniff to check that only one interface is defined in each file - -- Thanks to Andy Grunwald for the contribution - - Added Generic LowercasedFilenameSniff to check that filenames are lowercase - -- Thanks to Andy Grunwald for the contribution - - Added Generic ClosingPHPTagSniff to check that each open PHP tag has a corresponding close tag - -- Thanks to Andy Grunwald for the contribution - - Added Generic CharacterBeforePHPOpeningTagSniff to check that the open PHP tag is the first content in a file - -- Thanks to Andy Grunwald for the contribution - - Fixed incorrect errors in Squiz OperatorBracketSniff and OperatorSpacingSniff for negative numbers in CASE statements - -- Thanks to Arnout Boks for the patch - - Generic CamelCapsFunctionNameSniff no longer enforces exact case matching for PHP magic methods - - Generic CamelCapsFunctionNameSniff no longer throws errors for overridden SOAPClient methods prefixed with double underscores - -- Thanks to Dorian Villet for the patch - - PEAR ValidFunctionNameSniff now supports traits - - PSR1 ClassDeclarationSniff no longer throws an error for non-namespaced code if PHP version is less than 5.3.0 - - Fixed bug #19616 : Nested switches cause false error in PSR2 - - Fixed bug #19629 : PSR2 error for inline comments on multi-line argument lists - - Fixed bug #19644 : Alternative syntax, e.g. if/endif triggers Inline Control Structure error - - Fixed bug #19655 : Closures reporting as multi-line when they are not - - Fixed bug #19675 : Improper indent of nested anonymous function bodies in a call - - Fixed bug #19685 : PSR2 catch-22 with empty third statement in for loop - - Fixed bug #19687 : Anonymous functions inside arrays marked as indented incorrectly in PSR2 - - - - - 1.4.0 - 1.4.0 - - - stable - stable - - 2012-09-26 - BSD License - - - Added PSR1 and PSR2 coding standards that can be used to check your code against these guidelines - - PHP 5.4 short array syntax is now detected and tokens are assigned to the open and close characters - -- New tokens are T_OPEN_SHORT_ARRAY and T_CLOSE_SHORT_ARRAY as PHP does not define its own - - Added the ability to explain a coding standard by listing the sniffs that it includes - -- The sniff list includes all imported and native sniffs - -- Explain a standard by using the -e and --standard=[standard] command line arguments - -- E.g., phpcs -e --standard=Squiz - -- Thanks to Ben Selby for the idea - - Added report to show results using notify-send - -- Use --report=notifysend to generate the report - -- Thanks to Christian Weiske for the contribution - - The JS tokenizer now recognises RETURN as a valid closer for CASE and DEFAULT inside switch statements - - AbstractPatternSniff now sets the ignoreComments option using a public var rather than through the constructor - -- This allows the setting to be overwritten in ruleset.xml files - -- Old method remains for backwards compatibility - - Generic LowerCaseConstantSniff and UpperCaseConstantSniff no longer report errors on classes named True, False or Null - - PEAR ValidFunctionNameSniff no longer enforces exact case matching for PHP magic methods - - Squiz SwitchDeclarationSniff now allows RETURN statements to close a CASE or DEFAULT statement - - Squiz BlockCommentSniff now correctly reports an error for blank lines before blocks at the start of a control structure - - Fixed a PHP notice generated when loading custom array settings from a ruleset.xml file - - Fixed bug #17908 : CodeSniffer does not recognise optional @params - -- Thanks to Pete Walker for the patch - - Fixed bug #19538 : Function indentation code sniffer checks inside short arrays - - Fixed bug #19565 : Non-Executable Code Sniff Broken for Case Statements with both return and break - - Fixed bug #19612 : Invalid @package suggestion - - - - - 1.3.6 - 1.3.6 - - - stable - stable - - 2012-08-08 - BSD License - - - Memory usage has been dramatically reduced when using the summary report - -- Reduced memory is only available when displaying a single summary report to the screen - -- PHP_CodeSniffer will not generate any messages in this case, storing only error counts instead - -- Impact is most notable with very high error and warning counts - - Significantly improved the performance of Squiz NonExecutableCodeSniff - - Ignore patterns now check the relative path of a file based on the dir being checked - -- Allows ignore patterns to become more generic as the path to the code is no longer included when checking - -- Thanks to Kristof Coomans for the patch - - Sniff settings can now be changed by specifying a special comment format inside a file - -- e.g., // @codingStandardsChangeSetting PEAR.Functions.FunctionCallSignature allowMultipleArguments false - -- If you change a setting, don't forget to change it back - - Added Generic EndFileNewlineSniff to ensure PHP files end with a newline character - - PEAR FunctionCallSignatureSniff now includes a setting to force one argument per line in multi-line calls - -- Set allowMultipleArguments to false - - Squiz standard now enforces one argument per line in multi-line function calls - - Squiz FunctionDeclarationArgumentSpacingSniff now supports closures - - Squiz OperatorSpacingSniff no longer throws an error for negative values inside an inline THEN statement - -- Thanks to Klaus Purer for the patch - - Squiz FunctionCommentSniff now throws an error for not closing a comment with */ - -- Thanks to Klaus Purer for the patch - - Summary report no longer shows two lines of PHP_Timer output when showing sources - - Fixed undefined variable error in PEAR FunctionCallSignatureSniff for lines with no indent - - Fixed bug #19502 : Generic.Files.LineEndingsSniff fails if no new-lines in file - - Fixed bug #19508 : switch+return: Closing brace indented incorrectly - - Fixed bug #19532 : The PSR-2 standard don't recognize Null in class names - - Fixed bug #19546 : Error thrown for __call() method in traits - - - - - 1.3.5 - 1.3.5 - - - stable - stable - - 2012-07-12 - BSD License - - - Added Generic CamelCapsFunctionNameSniff to just check if function and method names use camel caps - -- Does not allow underscore prefixes for private/protected methods - -- Defaults to strict checking, where two uppercase characters can not be next to each other - -- Strict checking can be disabled in a ruleset.xml file - - Squiz FunctionDeclarationArgumentSpacing now has a setting to specify how many spaces should surround equals signs - -- Default remains at 0 - -- Override the equalsSpacing setting in a ruleset.xml file to change - - Squiz ClassDeclarationSniff now throws errors for > 1 space before extends/implements class name with ns separator - - Squiz standard now warns about deprecated functions using Generic DeprecatedFunctionsSniff - - PEAR FunctionDeclarationSniff now reports an error for multiple spaces after the FUNCTION keyword and around USE - - PEAR FunctionDeclarationSniff now supports closures - - Squiz MultiLineFunctionDeclarationSniff now supports closures - - Exclude rules written for Unix systems will now work correctly on Windows - -- Thanks to Walter Tamboer for the patch - - The PHP tokenizer now recognises T_RETURN as a valid closer for T_CASE and T_DEFAULT inside switch statements - - Fixed duplicate message codes in Generic OpeningFunctionBraceKernighanRitchieSniff - - Fixed bug #18651 : PHPunit Test cases for custom standards are not working on Windows - - Fixed bug #19416 : Shorthand arrays cause bracket spacing errors - - Fixed bug #19421 : phpcs doesn't recognize ${x} as equivalent to $x - - Fixed bug #19428 : PHPCS Report "hgblame" doesn't support windows paths - -- Thanks to Justin Rovang for the patch - - Fixed bug #19448 : Problem with detecting remote standards - - Fixed bug #19463 : Anonymous functions incorrectly being flagged by NonExecutableCodeSniff - - Fixed bug #19469 : PHP_CodeSniffer_File::getMemberProperties() sets wrong scope - - Fixed bug #19471 : phpcs on Windows, when using Zend standard, doesn't catch problems - -- Thanks to Ivan Habunek for the patch - - Fixed bug #19478 : Incorrect indent detection in PEAR standard - -- Thanks to Shane Auckland for the patch - - Fixed bug #19483 : Blame Reports fail with space in directory name - - - - - 1.3.4 - 1.3.4 - - - stable - stable - - 2012-05-17 - BSD License - - - Added missing package.xml entries for new Generic FixmeSniff - -- Thanks to Jaroslav Hanslík for the patch - - Expected indents for PEAR ScopeClosingBraceSniff and FunctionCallSignatureSniff can now be set in ruleset files - -- Both sniffs use a variable called "indent" - -- Thanks to Thomas Despoix for the patch - - Standards designed to be installed in the PHPCS Standards dir will now work outside this dir as well - -- In particular, allows the Drupal CS to work without needing to symlink it into the PHPCS install - -- Thanks to Peter Philipp for the patch - - Rule references for standards, directories and specific sniffs can now be relative in ruleset.xml files - -- For example: ref="../MyStandard/Sniffs/Commenting/DisallowHashCommentsSniff.php" - - Symlinked standards now work correctly, allowing aliasing of installed standards (request #19417) - -- Thanks to Tom Klingenberg for the patch - - Squiz ObjectInstantiationSniff now allows objects to be returned without assigning them to a variable - - Added Squiz.Commenting.FileComment.MissingShort error message for file comments that only contains tags - -- Also stops undefined index errors being generated for these comments - - Debug option -vv now shows tokenizer status for CSS files - - Added support for new gjslint error formats - -- Thanks to Meck for the patch - - Generic ScopeIndentSniff now allows comment indents to not be exact even if the exact flag is set - -- The start of the comment is still checked for exact indentation as normal - - Fixed an issue in AbstractPatternSniff where comments were not being ignored in some cases - - Fixed an issue in Zend ClosingTagSniff where the closing tag was not always being detected correctly - -- Thanks to Jonathan Robson for the patch - - Fixed an issue in Generic FunctionCallArgumentSpacingSniff where closures could cause incorrect errors - - Fixed an issue in Generic UpperCaseConstantNameSniff where errors were incorrectly reported on goto statements - -- Thanks to Tom Klingenberg for the patch - - PEAR FileCommentSniff and ClassCommentSniff now support author emails with a single character in the local part - -- E.g., a@me.com - -- Thanks to Denis Shapkin for the patch - - Fixed bug #19290 : Generic indent sniffer fails for anonymous functions - - Fixed bug #19324 : Setting show_warnings configuration option does not work - - Fixed bug #19354 : Not recognizing references passed to method - - Fixed bug #19361 : CSS tokenizer generates errors when PHP embedded in CSS file - - Fixed bug #19374 : HEREDOC/NOWDOC Indentation problems - - Fixed bug #19381 : traits and indentations in traits are not handled properly - - Fixed bug #19394 : Notice in NonExecutableCodeSniff - - Fixed bug #19402 : Syntax error when executing phpcs on Windows with parens in PHP path - -- Thanks to Tom Klingenberg for the patch - - Fixed bug #19411 : magic method error on __construct() - -- The fix required a rewrite of AbstractScopeSniff, so please test any sniffs that extend this class - - Fixed bug #19412 : Incorrect error about assigning objects to variables when inside inline IF - - Fixed bug #19413 : php_cs thinks I haven't used a parameter when I have - - Fixed bug #19414 : php_cs seems to not track variables correctly in heredocs - - - - - 1.3.3 - 1.3.3 - - - stable - stable - - 2012-02-17 - BSD License - - - Added new Generic FixmeSniff that shows error messages for all FIXME comments left in your code - -- Thanks to Sam Graham for the contribution - - The maxPercentage setting in the Squiz CommentedOutCodeSniff can now be overridden in a ruleset.xml file - -- Thanks to Volker Dusch for the patch - - The Checkstyle and XML reports now use XMLWriter - -- Only change in output is that empty file tags are no longer produced for files with no violations - -- Thanks to Sebastian Bergmann for the patch - - Added PHP_CodeSniffer_Tokens::$bracketTokens to give sniff writers fast access to open and close bracket tokens - - Fixed an issue in AbstractPatternSniff where EOL tokens were not being correctly checked in some cases - - PHP_CodeSniffer_File::getTokensAsString() now detects incorrect length value (request #19313) - - Fixed bug #19114 : CodeSniffer checks extension even for single file - - Fixed bug #19171 : Show sniff codes option is ignored by some report types - -- Thanks to Dominic Scheirlinck for the patch - - Fixed bug #19188 : Lots of PHP Notices when analyzing the Symfony framework - -- First issue was list-style.. lines in CSS files not properly adjusting open/close bracket positions - -- Second issue was notices caused by bug #19137 - - Fixed bug #19208 : UpperCaseConstantName reports class members - -- Was also a problem with LowerCaseConstantName as well - - Fixed bug #19256 : T_DOC_COMMENT in CSS files breaks ClassDefinitionNameSpacingSniff - -- Thanks to Klaus Purer for the patch - - Fixed bug #19264 : Squiz.PHP.NonExecutableCode does not handle RETURN in CASE without BREAK - - Fixed bug #19270 : DuplicateClassName does not handle namespaces correctly - - Fixed bug #19283 : CSS @media rules cause false positives - -- Thanks to Klaus Purer for the patch - - - - - 1.3.2 - 1.3.2 - - - stable - stable - - 2011-12-01 - BSD License - - - Added Generic JSHintSniff to run jshint.js over a JS file and report warnings - -- Set jshint path using phpcs --config-set jshint_path /path/to/jshint-rhino.js - -- Set rhino path using phpcs --config-set rhino_path /path/to/rhino - -- Thanks to Alexander Weiß for the contribution - - Nowdocs are now tokenized using PHP_CodeSniffer specific T_NOWDOC tokens for easier identification - - Generic UpperCaseConstantNameSniff no longer throws errors for namespaces - -- Thanks to Jaroslav Hanslík for the patch - - Squiz NonExecutableCodeSniff now detects code after thrown exceptions - -- Thanks to Jaroslav Hanslík for the patch - - Squiz OperatorSpacingSniff now ignores references - -- Thanks to Jaroslav Hanslík for the patch - - Squiz FunctionCommentSniff now reports a missing function comment if it finds a standard code comment instead - - Squiz FunctionCommentThrownTagSniff no longer reports errors if it can't find a function comment - - Fixed unit tests not running under Windows - -- Thanks to Jaroslav Hanslík for the patch - - Fixed bug #18964 : "$stackPtr must be of type T_VARIABLE" on heredocs and nowdocs - - Fixed bug #18973 : phpcs is looking for variables in a nowdoc - - Fixed bug #18974 : Blank line causes "Multi-line function call not indented correctly" - -- Adds new error message to ban empty lines in multi-line function calls - - Fixed bug #18975 : "Closing parenthesis must be on a line by itself" also causes indentation error - - - - - 1.3.1 - 1.3.1 - - - stable - stable - - 2011-11-03 - BSD License - - - All report file command line arguments now work with relative paths (request #17240) - - The extensions command line argument now supports multi-part file extensions (request #17227) - - Added report type --report=hgblame to show number of errors/warnings committed by authors in a Mercurial repository - -- Has the same functionality as the svnblame report - -- Thanks to Ben Selby for the patch - - Added T_BACKTICK token type to make detection of backticks easier (request #18799) - - Added pattern matching support to Generic ForbiddenFunctionsSniff - -- If you are extending it and overriding register() or addError() you will need to review your sniff - - Namespaces are now recognised as scope openers, although they do not require braces (request #18043) - - Added new ByteOrderMarkSniff to Generic standard (request #18194) - -- Throws an error if a byte order mark is found in any PHP file - -- Thanks to Piotr Karas for the contribution - - PHP_Timer output is no longer included in reports when being written to a file (request #18252) - -- Also now shown for all report types if nothing is being printed to the screen - - Generic DeprecatedFunctionSniff now reports functions as deprecated and not simply forbidden (request #18288) - - PHPCS now accepts file contents from STDIN (request #18447) - -- Example usage: cat temp.php | phpcs [options] -OR- phpcs [options] < temp.php - -- Not every sniff will work correctly due to the lack of a valid file path - - PHP_CodeSniffer_Exception no longer extends PEAR_Exception (request #18483) - -- PEAR_Exception added a requirement that PEAR had to be installed - -- PHP_CodeSniffer is not used as a library, so unlikely to have any impact - - PEAR FileCommentSniff now allows GIT IDs in the version tag (request #14874) - - AbstractVariableSniff now supports heredocs - -- Also includes some variable detection fixes - -- Thanks to Sam Graham for the patch - - Squiz FileCommentSniff now enforces rule that package names cannot start with the word Squiz - - MySource AssignThisSniff now allows "this" to be assigned to the private var _self - - Fixed issue in Squiz FileCommentSniff where suggested package name was the same as the incorrect package name - - Fixed some issues with Squiz ArrayDeclarationSniff when using function calls in array values - - Fixed doc generation so it actually works again - -- Also now works when being run from an SVN checkout as well as when installed as a PEAR package - -- Should fix bug #18949 : Call to private method from static - - PEAR ClassDeclaration sniff now supports indentation checks when using the alternate namespace syntax - -- PEAR.Classes.ClassDeclaration.SpaceBeforeBrace message now contains 2 variables instead of 1 - -- Sniff allows overriding of the default indent level, which is set to 4 - -- Fixes bug #18933 : Alternative namespace declaration syntax confuses scope sniffs - - Fixed bug #18465 : "self::" does not work in lambda functions - -- Also corrects conversion of T_FUNCTION tokens to T_CLOSURE, which was not fixing token condition arrays - - Fixed bug #18543 : CSS Tokenizer deletes too many # - - Fixed bug #18624 : @throws namespace problem - -- Thanks to Gavin Davies for the patch - - Fixed bug #18628 : Generic.Files.LineLength gives incorrect results with Windows line-endings - - Fixed bug #18633 : CSS Tokenizer doesn't replace T_LIST tokens inside some styles - - Fixed bug #18657 : anonymous functions wrongly indented - - Fixed bug #18670 : UpperCaseConstantNameSniff fails on dynamic retrieval of class constant - - Fixed bug #18709 : Code sniffer sniffs file if even if it's in --ignore - -- Thanks to Artem Lopata for the patch - - Fixed bug #18762 : Incorrect handling of define and constant in UpperCaseConstantNameSniff - -- Thanks to Thomas Baker for the patch - - Fixed bug #18769 : CSS Tokenizer doesn't replace T_BREAK tokens inside some styles - - Fixed bug #18835 : Unreachable errors of inline returns of closure functions - -- Thanks to Patrick Schmidt for the patch - - Fixed bug #18839 : Fix miscount of warnings in AbstractSniffUnitTest.php - -- Thanks to Sam Graham for the patch - - Fixed bug #18844 : Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff with empty body - -- Thanks to Dmitri Medvedev for the patch - - Fixed bug #18847 : Running Squiz_Sniffs_Classes_ClassDeclarationSniff results in PHP notice - - Fixed bug #18868 : jslint+rhino: errors/warnings not detected - -- Thanks to Christian Weiske for the patch - - Fixed bug #18879 : phpcs-svn-pre-commit requires escapeshellarg - -- Thanks to Bjorn Katuin for the patch - - Fixed bug #18951 : weird behaviour with closures and multi-line use () params - - - - - 1.3.0 - 1.3.0 - - - stable - stable - - 2011-03-17 - BSD License - - - Add a new token T_CLOSURE that replaces T_FUNCTION if the function keyword is anonymous - - Many Squiz sniffs no longer report errors when checking closures; they are now ignored - - Fixed some error messages in PEAR MultiLineConditionSniff that were not using placeholders for message data - - AbstractVariableSniff now correctly finds variable names wrapped with curly braces inside double quoted strings - - PEAR FunctionDeclarationSniff now ignores arrays in argument default values when checking multi-line declarations - - Fixed bug #18200 : Using custom named ruleset file as standard no longer works - - Fixed bug #18196 : PEAR MultiLineCondition.SpaceBeforeOpenBrace not consistent with newline chars - - Fixed bug #18204 : FunctionCommentThrowTag picks wrong exception type when throwing function call - - Fixed bug #18222 : Add __invoke method to PEAR standard - - Fixed bug #18235 : Invalid error generation in Squiz.Commenting.FunctionCommentThrowTag - - Fixed bug #18250 : --standard with relative path skips Standards' "implicit" sniffs - - Fixed bug #18274 : Multi-line IF and function call indent rules conflict - - Fixed bug #18282 : Squiz doesn't handle final keyword before function comments - -- Thanks to Dave Perrett for the patch - - Fixed bug #18336 : Function isUnderscoreName gives php notices - - - - - 1.3.0RC2 - 1.3.0RC2 - - - beta - beta - - 2011-01-14 - BSD License - - - You can now print multiple reports for each run and print each to the screen or a file (request #12434) - -- Format is --report-[report][=file] (e.g., --report-xml=out.xml) - -- Printing to screen is done by leaving [file] empty (e.g., --report-xml) - -- Multiple reports can be specified in this way (e.g., --report-summary --report-xml=out.xml) - -- The standard --report and --report-file command line arguments are unchanged - - Added -d command line argument to set php.ini settings while running (request #17244) - -- Usage is: phpcs -d memory_limit=32M -d ... - -- Thanks to Ben Selby for the patch - - Added -p command line argument to show progress during a run - -- Dot means pass, E means errors found, W means only warnings found and S means skipped file - -- Particularly good for runs where you are checking more than 100 files - -- Enable by default with --config-set show_progress 1 - -- Will not print anything if you are already printing verbose output - -- This has caused a big change in the way PHP_CodeSniffer processes files (API changes around processing) - - You can now add exclude rules for individual sniffs or error messages (request #17903) - -- Only available when using a ruleset.xml file to specify rules - -- Uses the same exclude-pattern tags as normal but allows them inside rule tags - - Using the -vvv option will now print a list of sniffs executed for each file and how long they took to process - - Added Generic ClosureLinterSniff to run Google's gjslint over your JS files - - The XML and CSV reports now include the severity of the error (request #18165) - -- The Severity column in the CSV report has been renamed to Type, and a new Severity column added for this - - Fixed issue with Squiz FunctionCommentSniff reporting incorrect type hint when default value uses namespace - -- Thanks to Anti Veeranna for the patch - - Generic FileLengthSniff now uses iconv_strlen to check line length if an encoding is specified (request #14237) - - Generic UnnecessaryStringConcatSniff now allows strings to be combined to form a PHP open or close tag - - Squiz SwitchDeclarationSniff no longer reports indentation errors for BREAK statements inside IF conditions - - Interactive mode now always prints the full error report (ignores command line) - - Improved regular expression detection in JavaScript files - -- Added new T_TYPEOF token that can be used to target the typeof JS operator - -- Fixes bug #17611 : Regular expression tokens not recognised - - Squiz ScopeIndentSniff removed - -- Squiz standard no longer requires additional indents between ob_* methods - -- Also removed Squiz OutputBufferingIndentSniff that was checking the same thing - - PHP_CodeSniffer_File::getMemberProperties() performance improved significantly - -- Improves performance of Squiz ValidVariableNameSniff significantly - - Squiz OperatorSpacingSniff performance improved significantly - - Squiz NonExecutableCodeSniff performance improved significantly - -- Will throw duplicate errors in some cases now, but these should be rare - - MySource IncludeSystemSniff performance improved significantly - - MySource JoinStringsSniff no longer reports an error when using join() on a named JS array - - Warnings are now reported for each file when they cannot be opened instead of stopping the script - -- Hide warnings with the -n command line argument - -- Can override the warnings using the code Internal.DetectLineEndings - - Fixed bug #17693 : issue with pre-commit hook script with filenames that start with v - - Fixed bug #17860 : isReference function fails with references in array - -- Thanks to Lincoln Maskey for the patch - - Fixed bug #17902 : Cannot run tests when tests are symlinked into tests dir - -- Thanks to Matt Button for the patch - - Fixed bug #17928 : Improve error message for Generic_Sniffs_PHP_UpperCaseConstantSniff - -- Thanks to Stefano Kowalke for the patch - - Fixed bug #18039 : JS Tokenizer crash when ] is last character in file - - Fixed bug #18047 : Incorrect handling of namespace aliases as constants - -- Thanks to Dmitri Medvedev for the patch - - Fixed bug #18072 : Impossible to exclude path from processing when symlinked - - Fixed bug #18073 : Squiz.PHP.NonExecutableCode fault - - Fixed bug #18117 : PEAR coding standard: Method constructor not sniffed as a function - - Fixed bug #18135 : Generic FunctionCallArgumentSpacingSniff reports function declaration errors - - Fixed bug #18140 : Generic scope indent in exact mode: strange expected/found values for switch - - Fixed bug #18145 : Sniffs are not loaded for custom ruleset file - -- Thanks to Scott McCammon for the patch - - Fixed bug #18152 : While and do-while with AbstractPatternSniff - - Fixed bug #18191 : Squiz.PHP.LowercasePHPFunctions does not work with new Date() - - Fixed bug #18193 : CodeSniffer doesn't reconize CR (\r) line endings - - - - - 1.3.0RC1 - 1.3.0RC1 - - - beta - beta - - 2010-09-03 - BSD License - - - Added exclude pattern support to ruleset.xml file so you can specify ignore patterns in a standard (request #17683) - -- Use new exclude-pattern tags to include the ignore rules into your ruleset.xml file - -- See CodeSniffer/Standards/PHPCS/ruleset.xml for an example - - Added new --encoding command line argument to specify the encoding of the files being checked - -- When set to utf-8, stops the XML-based reports from double-encoding - -- When set to something else, helps the XML-based reports encode to utf-8 - -- Default value is iso-8859-1 but can be changed with --config-set encoding [value] - - The report is no longer printed to screen when using the --report-file command line option (request #17467) - -- If you want to print it to screen as well, use the -v command line argument - - The SVN and GIT blame reports now also show percentage of reported errors per author (request #17606) - -- Thanks to Ben Selby for the patch - - Updated the SVN pre-commit hook to work with the new severity levels feature - - Generic SubversionPropertiesSniff now allows properties to have NULL values (request #17682) - -- A null value indicates that the property should exist but the value should not be checked - - Generic UpperCaseConstantName Sniff now longer complains about the PHPUnit_MAIN_METHOD constant (request #17798) - - Squiz FileComment sniff now checks JS files as well as PHP files - - Squiz FunctionCommentSniff now supports namespaces in type hints - - Fixed a problem in Squiz OutputBufferingIndentSniff where block comments were reported as not indented - - Fixed bug #17092 : Problems with utf8_encode and htmlspecialchars with non-ascii chars - -- Use the new --encoding=utf-8 command line argument if your files are utf-8 encoded - - Fixed bug #17629 : PHP_CodeSniffer_Tokens::$booleanOperators missing T_LOGICAL_XOR - -- Thanks to Matthew Turland for the patch - - Fixed bug #17699 : Fatal error generating code coverage with PHPUnit 5.3.0RC1 - - Fixed bug #17718 : Namespace 'use' statement: used global class name is recognized as constant - - Fixed bug #17734 : Generic SubversionPropertiesSniff complains on non SVN files - - Fixed bug #17742 : EmbeddedPhpSniff reacts negatively to file without closing php tag - - Fixed bug #17823 : Notice: Please no longer include PHPUnit/Framework.php - - - - - 1.3.0a1 - 1.3.0a1 - - - alpha - alpha - - 2010-07-15 - BSD License - - - All CodingStandard.php files have been replaced by ruleset.xml files - -- Custom standards will need to be converted over to this new format to continue working - - You can specify a path to your own custom ruleset.xml file by using the --standard command line arg - -- e.g., phpcs --standard=/path/to/my/ruleset.xml - - Added a new report type --report=gitblame to show how many errors and warnings were committed by each author - -- Has the same functionality as the svnblame report - -- Thanks to Ben Selby for the patch - - A new token type T_DOLLAR has been added to allow you to sniff for variable variables (feature request #17095) - -- Thanks to Ian Young for the patch - - JS tokenizer now supports T_POWER (^) and T_MOD_EQUAL (%=) tokens (feature request #17441) - - If you have PHP_Timer installed, you'll now get a time/memory summary at the end of a script run - -- Only happens when printing reports that are designed to be read on the command line - - Added Generic DeprecatedFunctionsSniff to warn about the use of deprecated functions (feature request #16694) - -- Thanks to Sebastian Bergmann for the patch - - Added Squiz LogicalOperatorSniff to ensure that logical operators are surrounded by single spaces - - Added MySource ChannelExceptionSniff to ensure action files only throw ChannelException - - Added new method getClassProperties() for sniffs to use to determine if a class is abstract and/or final - -- Thanks to Christian Kaps for the patch - - Generic UpperCaseConstantSniff no longer throws errors about namespaces - -- Thanks to Christian Kaps for the patch - - Squiz OperatorBracketSniff now correctly checks value assignments in arrays - - Squiz LongConditionClosingCommentSniff now requires a comment for long CASE statements that use curly braces - - Squiz LongConditionClosingCommentSniff now requires an exact comment match on the brace - - MySource IncludeSystemSniff now ignores DOMDocument usage - - MySource IncludeSystemSniff no longer requires inclusion of systems that are being implemented - - Removed found and expected messages from Squiz ConcatenationSpacingSniff because they were messy and not helpful - - Fixed a problem where Generic CodeAnalysisSniff could show warnings if checking multi-line strings - - Fixed error messages in Squiz ArrayDeclarationSniff reporting incorrect number of found and expected spaces - - Fixed bug #17048 : False positive in Squiz_WhiteSpace_ScopeKeywordSpacingSniff - - Fixed bug #17054 : phpcs more strict than PEAR CS regarding function parameter spacing - - Fixed bug #17096 : Notice: Undefined index: scope_condition in ScopeClosingBraceSniff.php - -- Moved PEAR.Functions.FunctionCallArgumentSpacing to Generic.Functions.FunctionCallArgumentSpacing - - Fixed bug #17144 : Deprecated: Function eregi() is deprecated - - Fixed bug #17236 : PHP Warning due to token_get_all() in DoubleQuoteUsageSniff - - Fixed bug #17243 : Alternate Switch Syntax causes endless loop of Notices in SwitchDeclaration - - Fixed bug #17313 : Bug with switch case structure - - Fixed bug #17331 : Possible parse error: interfaces may not include member vars - - Fixed bug #17337 : CSS tokenizer fails on quotes urls - - Fixed bug #17420 : Uncaught exception when comment before function brace - - Fixed bug #17503 : closures formatting is not supported - - - - - 1.2.2 - 1.2.2 - - - stable - stable - - 2010-01-27 - BSD License - - - The core PHP_CodeSniffer_File methods now understand the concept of closures (feature request #16866) - -- Thanks to Christian Kaps for the sample code - - Sniffs can now specify violation codes for each error and warning they add - -- Future versions will allow you to override messages and severities using these codes - -- Specifying a code is optional, but will be required if you wish to support overriding - - All reports have been broken into separate classes - -- Command line usage and report output remains the same - -- Thanks to Gabriele Santini for the patch - - Added an interactive mode that can be enabled using the -a command line argument - -- Scans files and stops when it finds a file with errors - -- Waits for user input to recheck the file (hopefully you fixed the errors) or skip the file - -- Useful for very large code bases where full rechecks take a while - - The reports now show the correct number of errors and warnings found - - The isCamelCaps method now allows numbers in class names - - The JS tokenizer now correctly identifies boolean and bitwise AND and OR tokens - - The JS tokenizer now correctly identifies regular expressions used in conditions - - PEAR ValidFunctionNameSniff now ignores closures - - Squiz standard now uses the PEAR setting of 85 chars for LineLengthSniff - - Squiz ControlStructureSpacingSniff now ensure there are no spaces around parentheses - - Squiz LongConditionClosingCommentSniff now checks for comments at the end of try/catch statements - - Squiz LongConditionClosingCommentSniff now checks validity of comments for short structures if they exist - - Squiz IncrementDecrementUsageSniff now has better checking to ensure it only looks at simple variable assignments - - Squiz PostStatementCommentSniff no longer throws errors for end function comments - - Squiz InlineCommentSniff no longer throws errors for end function comments - - Squiz OperatorBracketSniff now allows simple arithmetic operations in SWITCH conditions - - Squiz ValidFunctionNameSniff now ignores closures - - Squiz MethodScopeSniff now ignores closures - - Squiz ClosingDeclarationCommentSniff now ignores closures - - Squiz GlobalFunctionSniff now ignores closures - - Squiz DisallowComparisonAssignmentSniff now ignores the assigning of arrays - - Squiz DisallowObjectStringIndexSniff now allows indexes that contain dots and reserved words - - Squiz standard now throws nesting level and cyclomatic complexity errors at much higher levels - - Squiz CommentedOutCodeSniff now ignores common comment framing characters - - Squiz ClassCommentSniff now ensures the open comment tag is the only content on the first line - - Squiz FileCommentSniff now ensures the open comment tag is the only content on the first line - - Squiz FunctionCommentSniff now ensures the open comment tag is the only content on the first line - - Squiz VariableCommentSniff now ensures the open comment tag is the only content on the first line - - Squiz NonExecutableCodeSniff now warns about empty return statements that are not required - - Removed ForbiddenStylesSniff from Squiz standard - -- It is now in in the MySource standard as BrowserSpecificStylesSniff - -- New BrowserSpecificStylesSniff ignores files with browser-specific suffixes - - MySource IncludeSystemSniff no longer throws errors when extending the Exception class - - MySource IncludeSystemSniff no longer throws errors for the abstract widget class - - MySource IncludeSystemSniff and UnusedSystemSniff now allow includes inside IF statements - - MySource IncludeSystemSniff no longer throws errors for included widgets inside methods - - MySource GetRequestDataSniff now throws errors for using $_FILES - - MySource CreateWidgetTypeCallbackSniff now allows return statements in nested functions - - MySource DisallowSelfActionsSniff now ignores abstract classes - - Fixed a problem with the SVN pre-commit hook for PHP versions without vertical whitespace regex support - - Fixed bug #16740 : False positives for heredoc strings and unused parameter sniff - - Fixed bug #16794 : ValidLogicalOperatorsSniff doesn't report operators not in lowercase - - Fixed bug #16804 : Report filename is shortened too much - - Fixed bug #16821 : Bug in Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff - -- Thanks to Jaroslav Hanslík for the patch - - Fixed bug #16836 : Notice raised when using semicolon to open case - - Fixed bug #16855 : Generic standard sniffs incorrectly for define() method - - Fixed bug #16865 : Two bugs in Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff - -- Thanks to Jaroslav Hanslík for the patch - - Fixed bug #16902 : Inline If Declaration bug - - Fixed bug #16960 : False positive for late static binding in Squiz/ScopeKeywordSpacingSniff - -- Thanks to Jakub Tománek for the patch - - Fixed bug #16976 : The phpcs attempts to process symbolic links that don't resolve to files - - Fixed bug #17017 : Including one file in the files sniffed alters errors reported for another file - - - - - 1.2.1 - 1.2.1 - - - stable - stable - - 2009-11-17 - BSD License - - - Added a new report type --report=svnblame to show how many errors and warnings were committed by each author - -- Also shows the percentage of their code that are errors and warnings - -- Requires you to have the SVN command in your path - -- Make sure SVN is storing usernames and passwords (if required) or you will need to enter them for each file - -- You can also use the -s command line argument to see the different types of errors authors are committing - -- You can use the -v command line argument to see all authors, even if they have no errors or warnings - - Added a new command line argument --report-width to allow you to set the column width of screen reports - -- Reports wont accept values less than 70 or else they get too small - -- Can also be set via a config var: phpcs --config-set report_width 100 - - You can now get PHP_CodeSniffer to ignore a whole file by adding @codingStandardsIgnoreFile in the content - -- If you put it in the first two lines the file wont even be tokenized, so it will be much quicker - - Reports now print their file lists in alphabetical order - - PEAR FunctionDeclarationSniff now reports error for incorrect closing bracket placement in multi-line definitions - - Added Generic CallTimePassByReferenceSniff to prohibit the passing of variables into functions by reference - -- Thanks to Florian Grandel for the contribution - - Added Squiz DisallowComparisonAssignmentSniff to ban the assignment of comparison values to a variable - - Added Squiz DuplicateStyleDefinitionSniff to check for duplicate CSS styles in a single class block - - Squiz ArrayDeclarationSniff no longer checks the case of array indexes because that is not its job - - Squiz PostStatementCommentSniff now allows end comments for class member functions - - Squiz InlineCommentSniff now supports the checking of JS files - - MySource CreateWidgetTypeCallbackSniff now allows the callback to be passed to another function - - MySource CreateWidgetTypeCallbackSniff now correctly ignores callbacks used inside conditions - - Generic MultipleStatementAlignmentSniff now enforces a single space before equals sign if max padding is reached - - Fixed a problem in the JS tokenizer where regular expressions containing \// were not converted correctly - - Fixed a problem tokenizing CSS files where multiple ID targets on a line would look like comments - - Fixed a problem tokenizing CSS files where class names containing a colon looked like style definitions - - Fixed a problem tokenizing CSS files when style statements had empty url() calls - - Fixed a problem tokenizing CSS colours with the letter E in first half of the code - - Squiz ColonSpacingSniff now ensures it is only checking style definitions in CSS files and not class names - - Squiz DisallowComparisonAssignmentSniff no longer reports errors when assigning the return value of a function - - CSS tokenizer now correctly supports multi-line comments - - When only the case of var names differ for function comments, the error now indicates the case is different - - Fixed an issue with Generic UnnecessaryStringConcatSniff where it incorrectly suggested removing a concat - - Fixed bug #16530 : ScopeIndentSniff reports false positive - - Fixed bug #16533 : Duplicate errors and warnings - - Fixed bug #16563 : Check file extensions problem in phpcs-svn-pre-commit - -- Thanks to Kaijung Chen for the patch - - Fixed bug #16592 : Object operator indentation incorrect when first operator is on a new line - - Fixed bug #16641 : Notice output - - Fixed bug #16682 : Squiz_Sniffs_Strings_DoubleQuoteUsageSniff reports string "\0" as invalid - - Fixed bug #16683 : Typing error in PHP_CodeSniffer_CommentParser_AbstractParser - - Fixed bug #16684 : Bug in Squiz_Sniffs_PHP_NonExecutableCodeSniff - - Fixed bug #16692 : Spaces in paths in Squiz_Sniffs_Debug_JavaScriptLintSniff - -- Thanks to Jaroslav Hanslík for the patch - - Fixed bug #16696 : Spelling error in MultiLineConditionSniff - - Fixed bug #16697 : MultiLineConditionSniff incorrect result with inline IF - - Fixed bug #16698 : Notice in JavaScript Tokenizer - - Fixed bug #16736 : Multi-files sniffs aren't processed when FILE is a single directory - -- Thanks to Alexey Shein for the patch - - Fixed bug #16792 : Bug in Generic_Sniffs_PHP_ForbiddenFunctionsSniff - - - - - 1.2.0 - 1.2.0 - - - stable - stable - - 2009-08-17 - BSD License - - - Installed standards are now favoured over custom standards when using the cmd line arg with relative paths - - Unit tests now use a lot less memory while running - - Squiz standard now uses Generic EmptyStatementSniff but throws errors instead of warnings - - Squiz standard now uses Generic UnusedFunctionParameterSniff - - Removed unused ValidArrayIndexNameSniff from the Squiz standard - - Fixed bug #16424 : SubversionPropertiesSniff print PHP Warning - - Fixed bug #16450 : Constant PHP_CODESNIFFER_VERBOSITY already defined (unit tests) - - Fixed bug #16453 : function declaration long line splitted error - - Fixed bug #16482 : phpcs-svn-pre-commit ignores extensions parameter - - - - - 1.2.0RC3 - 1.2.0RC3 - - - beta - beta - - 2009-07-07 - BSD License - - - You can now use @codingStandardsIgnoreStart and @...End comments to suppress messages (feature request #14002) - - A warning is now included for files without any code when short_open_tag is set to Off (feature request #12952) - - You can now use relative paths to your custom standards with the --standard cmd line arg (feature request #14967) - - You can now override magic methods and functions in PEAR ValidFunctionNameSniff (feature request #15830) - - MySource IncludeSystemSniff now recognises widget action classes - - MySource IncludeSystemSniff now knows about unit test classes and changes rules accordingly - - - - - 1.2.0RC2 - 1.2.0RC2 - - - beta - beta - - 2009-05-25 - BSD License - - - Test suite can now be run using the full path to AllTests.php (feature request #16179) - - Fixed bug #15980 : PHP_CodeSniffer change php current directory - -- Thanks to Dolly Aswin Harahap for the patch - - Fixed bug #16001 : Notice triggered - - Fixed bug #16054 : phpcs-svn-pre-commit not showing any errors - - Fixed bug #16071 : Fatal error: Uncaught PHP_CodeSniffer_Exception - - Fixed bug #16170 : Undefined Offset -1 in MultiLineConditionSniff.php on line 68 - - Fixed bug #16175 : Bug in Squiz-IncrementDecrementUsageSniff - - - - - 1.2.0RC1 - 1.2.0RC1 - - - beta - beta - - 2009-03-09 - BSD License - - - Reports that are output to a file now include a trailing newline at the end of the file - - Fixed sniff names not shown in -vvv token processing output - - Added Generic SubversionPropertiesSniff to check that specific svn props are set for files - -- Thanks to Jack Bates for the contribution - - The PHP version check can now be overridden in classes that extend PEAR FileCommentSniff - -- Thanks to Helgi Þormar Þorbjörnsson for the suggestion - - Added Generic ConstructorNameSniff to check for PHP4 constructor name usage - -- Thanks to Leif Wickland for the contribution - - Squiz standard now supports multi-line function and condition sniffs from PEAR standard - - Squiz standard now uses Generic ConstructorNameSniff - - Added MySource GetRequestDataSniff to ensure REQUEST, GET and POST are not accessed directly - - Squiz OperatorBracketSniff now allows square brackets in simple unbracketed operations - - Fixed the incorrect tokenizing of multi-line block comments in CSS files - - Fixed bug #15383 : Uncaught PHP_CodeSniffer_Exception - - Fixed bug #15408 : An unexpected exception has been caught: Undefined offset: 2 - - Fixed bug #15519 : Uncaught PHP_CodeSniffer_Exception - - Fixed bug #15624 : Pre-commit hook fails with PHP errors - - Fixed bug #15661 : Uncaught PHP_CodeSniffer_Exception - - Fixed bug #15722 : "declare(encoding = 'utf-8');" leads to "Missing file doc comment" - - Fixed bug #15910 : Object operator indention not calculated correctly - - - - - 1.2.0a1 - 1.2.0a1 - - - alpha - alpha - - 2008-12-18 - BSD License - - - PHP_CodeSniffer now has a CSS tokenizer for checking CSS files - - Added support for a new multi-file sniff that sniffs all processed files at once - - Added new output format --report=emacs to output errors using the emacs standard compile output format - -- Thanks to Len Trigg for the contribution - - Reports can now be written to a file using the --report-file command line argument (feature request #14953) - -- The report is also written to screen when using this argument - - The CheckStyle, CSV and XML reports now include a source for each error and warning (feature request #13242) - -- A new report type --report=source can be used to show you the most common errors in your files - - Added new command line argument -s to show error sources in all reports - - Added new command line argument --sniffs to specify a list of sniffs to restrict checking to - -- Uses the sniff source codes that are optionally displayed in reports - - Changed the max width of error lines from 80 to 79 chars to stop blank lines in the default windows cmd window - - PHP_CodeSniffer now has a token for an asperand (@ symbol) so sniffs can listen for them - -- Thanks to Andy Brockhurst for the patch - - Added Generic DuplicateClassNameSniff that will warn if the same class name is used in multiple files - -- Not currently used by any standard; more of a multi-file sniff sample than anything useful - - Added Generic NoSilencedErrorsSniff that warns if PHP errors are being silenced using the @ symbol - -- Thanks to Andy Brockhurst for the contribution - - Added Generic UnnecessaryStringConcatSniff that checks for two strings being concatenated - - Added PEAR FunctionDeclarationSniff to enforce the new multi-line function declaration PEAR standard - - Added PEAR MultiLineAssignmentSniff to enforce the correct indentation of multi-line assignments - - Added PEAR MultiLineConditionSniff to enforce the new multi-line condition PEAR standard - - Added PEAR ObjectOperatorIndentSniff to enforce the new chained function call PEAR standard - - Added MySource DisallowSelfActionSniff to ban the use of self::method() calls in Action classes - - Added MySource DebugCodeSniff to ban the use of Debug::method() calls - - Added MySource CreateWidgetTypeCallback sniff to check callback usage in widget type create methods - - Added Squiz DisallowObjectStringIndexSniff that forces object dot notation in JavaScript files - -- Thanks to Sertan Danis for the contribution - - Added Squiz DiscouragedFunctionsSniff to warn when using debug functions - - Added Squiz PropertyLabelSniff to check whitespace around colons in JS property and label declarations - - Added Squiz DuplicatePropertySniff to check for duplicate property names in JS classes - - Added Squiz ColonSpacingSniff to check for spacing around colons in CSS style definitions - - Added Squiz SemicolonSpacingSniff to check for spacing around semicolons in CSS style definitions - - Added Squiz IndentationSniff to check for correct indentation of CSS files - - Added Squiz ColourDefinitionSniff to check that CSS colours are defined in uppercase and using shorthand - - Added Squiz EmptyStyleDefinitionSniff to check for CSS style definitions without content - - Added Squiz EmptyClassDefinitionSniff to check for CSS class definitions without content - - Added Squiz ClassDefinitionOpeningBraceSpaceSniff to check for spaces around opening brace of CSS class definitions - - Added Squiz ClassDefinitionClosingBraceSpaceSniff to check for a single blank line after CSS class definitions - - Added Squiz ClassDefinitionNameSpacingSniff to check for a blank lines inside CSS class definition names - - Added Squiz DisallowMultipleStyleDefinitionsSniff to check for multiple style definitions on a single line - - Added Squiz DuplicateClassDefinitionSniff to check for duplicate CSS class blocks that can be merged - - Added Squiz ForbiddenStylesSniff to check for usage of browser specific styles - - Added Squiz OpacitySniff to check for incorrect opacity values in CSS - - Added Squiz LowercaseStyleDefinitionSniff to check for styles that are not defined in lowercase - - Added Squiz MissingColonSniff to check for style definitions where the colon has been forgotten - - Added Squiz MultiLineFunctionDeclarationSniff to check that multi-line declarations contain one param per line - - Added Squiz JSLintSniff to check for JS errors using the jslint.js script through Rhino - -- Set jslint path using phpcs --config-set jslint_path /path/to/jslint.js - -- Set rhino path using phpcs --config-set rhino_path /path/to/rhino - - Added Generic TodoSniff that warns about comments that contain the word TODO - - Removed MultipleStatementAlignmentSniff from the PEAR standard as alignment is now optional - - Generic ForbiddenFunctionsSniff now has protected member var to specify if it should use errors or warnings - - Generic MultipleStatementAlignmentSniff now has correct error message if assignment is on a new line - - Generic MultipleStatementAlignmentSniff now has protected member var to allow it to ignore multi-line assignments - - Generic LineEndingsSniff now supports checking of JS files - - Generic LineEndingsSniff now supports checking of CSS files - - Generic DisallowTabIndentSniff now supports checking of CSS files - - Squiz DoubleQuoteUsageSniff now bans the use of variables in double quoted strings in favour of concatenation - - Squiz SuperfluousWhitespaceSniff now supports checking of JS files - - Squiz SuperfluousWhitespaceSniff now supports checking of CSS files - - Squiz DisallowInlineIfSniff now supports checking of JS files - - Squiz SemicolonSpacingSniff now supports checking of JS files - - Squiz PostStatementCommentSniff now supports checking of JS files - - Squiz FunctionOpeningBraceSpacingSniff now supports checking of JS files - - Squiz FunctionClosingBraceSpacingSniff now supports checking of JS files - -- Empty JS functions must have their opening and closing braces next to each other - - Squiz ControlStructureSpacingSniff now supports checking of JS files - - Squiz LongConditionClosingCommentSniff now supports checking of JS files - - Squiz OperatorSpacingSniff now supports checking of JS files - - Squiz SwitchDeclarationSniff now supports checking of JS files - - Squiz CommentedOutCodeSniff now supports checking of CSS files - - Squiz DisallowSizeFunctionsInLoopsSniff now supports checking of JS files for the use of object.length - - Squiz DisallowSizeFunctionsInLoopsSniff no longer complains about size functions outside of the FOR condition - - Squiz ControlStructureSpacingSniff now bans blank lines at the end of a control structure - - Squiz ForLoopDeclarationSniff no longer throws errors for JS FOR loops without semicolons - - Squiz MultipleStatementAlignmentSniff no longer throws errors if a statement would take more than 8 spaces to align - - Squiz standard now uses Generic TodoSniff - - Squiz standard now uses Generic UnnecessaryStringConcatSniff - - Squiz standard now uses PEAR MultiLineAssignmentSniff - - Squiz standard now uses PEAR MultiLineConditionSniff - - Zend standard now uses OpeningFunctionBraceBsdAllmanSniff (feature request #14647) - - MySource JoinStringsSniff now bans the use of inline array joins and suggests the + operator - - Fixed incorrect errors that can be generated from abstract scope sniffs when moving to a new file - - Core tokenizer now matches orphaned curly braces in the same way as square brackets - - Whitespace tokens at the end of JS files are now added to the token stack - - JavaScript tokenizer now identifies properties and labels as new token types - - JavaScript tokenizer now identifies object definitions as a new token type and matches curly braces for them - - JavaScript tokenizer now identifies DIV_EQUAL and MUL_EQUAL tokens - - Improved regular expression detection in the JavaScript tokenizer - - Improve AbstractPatternSniff support so it can listen for any token type, not just weighted tokens - - Fixed Squiz DoubleQuoteUsageSniff so it works correctly with short_open_tag=Off - - Fixed bug #14409 : Output of warnings to log file - - Fixed bug #14520 : Notice: Undefined offset: 1 in /usr/share/php/PHP/CodeSniffer/File.php on line - - Fixed bug #14637 : Call to processUnknownArguments() misses second parameter $pos - -- Thanks to Peter Buri for the patch - - Fixed bug #14889 : Lack of clarity: licence or license - - Fixed bug #15008 : Nested Parentheses in Control Structure Sniffs - - Fixed bug #15091 : pre-commit hook attempts to sniff folders - -- Thanks to Bruce Weirdan for the patch - - Fixed bug #15124 : AbstractParser.php uses deprecated split() function - -- Thanks to Sebastian Bergmann for the patch - - Fixed bug #15188 : PHPCS vs HEREDOC strings - - Fixed bug #15231 : Notice: Uninitialized string offset: 0 in FileCommentSniff.php on line 555 - - Fixed bug #15336 : Notice: Undefined offset: 2 in /usr/share/php/PHP/CodeSniffer/File.php on line - - - - - 1.1.0 - 1.1.0 - - - stable - stable - - 2008-07-14 - BSD License - - - PEAR FileCommentSniff now allows tag orders to be overridden in child classes - -- Thanks to Jeff Hodsdon for the patch - - Added Generic DisallowMultipleStatementsSniff to ensure there is only one statement per line - - Squiz standard now uses DisallowMultipleStatementsSniff - - Fixed error in Zend ValidVariableNameSniff when checking vars in form: $class->{$var} - - Fixed bug #14077 : Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a class member - - Fixed bug #14168 : Global Function -> Static Method and __autoload() - - Fixed bug #14238 : Line length not checked at last line of a file - - Fixed bug #14249 : wrong detection of scope_opener - - Fixed bug #14250 : ArrayDeclarationSniff emit warnings at malformed array - - Fixed bug #14251 : --extensions option doesn't work - - - - - 1.1.0RC3 - 1.1.0RC3 - - - beta - beta - - 2008-07-03 - BSD License - - - PEAR FileCommentSniff now allows tag orders to be overridden in child classes - -- Thanks to Jeff Hodsdon for the patch - - Added Generic DisallowMultipleStatementsSniff to ensure there is only one statement per line - - Squiz standard now uses DisallowMultipleStatementsSniff - - Fixed error in Zend ValidVariableNameSniff when checking vars in form: $class->{$var} - - Fixed bug #14077 : Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a class member - - Fixed bug #14168 : Global Function -> Static Method and __autoload() - - Fixed bug #14238 : Line length not checked at last line of a file - - Fixed bug #14249 : wrong detection of scope_opener - - Fixed bug #14250 : ArrayDeclarationSniff emit warnings at malformed array - - Fixed bug #14251 : --extensions option doesn't work - - - - - 1.1.0RC2 - 1.1.0RC2 - - - beta - beta - - 2008-06-13 - BSD License - - - Permission denied errors now stop script execution but still display current errors (feature request #14076) - - Added Squiz ValidArrayIndexNameSniff to ensure array indexes do not use camel case - - Squiz ArrayDeclarationSniff now ensures arrays are not declared with camel case index values - - PEAR ValidVariableNameSniff now alerts about a possible parse error for member vars inside an interface - - Fixed bug #13921 : js parsing fails for comments on last line of file - - Fixed bug #13922 : crash in case of malformed (but tokenized) php file - -- PEAR and Squiz ClassDeclarationSniff now throw warnings for possible parse errors - -- Squiz ValidClassNameSniff now throws warning for possible parse errors - -- Squiz ClosingDeclarationCommentSniff now throws additional warnings for parse errors - - - - - 1.1.0RC1 - 1.1.0RC1 - - - beta - beta - - 2008-05-13 - BSD License - - - Added support for multiple tokenizers so PHP_CodeSniffer can check more than just PHP files - -- PHP_CodeSniffer now has a JS tokenizer for checking JavaScript files - -- Sniffs need to be updated to work with additional tokenizers, or new sniffs written for them - - phpcs now exits with status 2 if the tokenizer extension has been disabled (feature request #13269) - - Added scripts/phpcs-svn-pre-commit that can be used as an SVN pre-commit hook - -- Also reworked the way the phpcs script works to make it easier to wrap it with other functionality - -- Thanks to Jack Bates for the contribution - - Fixed error in phpcs error message when a supplied file does not exist - - Fixed a cosmetic error in AbstractPatternSniff where the "found" string was missing some content - - Added sniffs that implement part of the PMD rule catalog to the Generic standard - -- Thanks to Manuel Pichler for the contribution of all these sniffs. - - Squiz FunctionCommentThrowTagSniff no longer throws errors for function that only throw variables - - Generic ScopeIndentSniff now has private member to enforce exact indent matching - - Replaced Squiz DisallowCountInLoopsSniff with Squiz DisallowSizeFunctionsInLoopsSniff - -- Thanks to Jan Miczaika for the sniff - - Squiz BlockCommentSniff now checks inline doc block comments - - Squiz InlineCommentSniff now checks inline doc block comments - - Squiz BlockCommentSniff now checks for no blank line before first comment in a function - - Squiz DocCommentAlignmentSniff now ignores inline doc block comments - - Squiz ControlStructureSpacingSniff now ensures no blank lines at the start of control structures - - Squiz ControlStructureSpacingSniff now ensures no blank lines between control structure closing braces - - Squiz IncrementDecrementUsageSniff now ensures inc/dec ops are bracketed in string concats - - Squiz IncrementDecrementUsageSniff now ensures inc/dec ops are not used in arithmetic operations - - Squiz FunctionCommentSniff no longer throws errors if return value is mixed but function returns void somewhere - - Squiz OperatorBracketSniff no allows function call brackets to count as operator brackets - - Squiz DoubleQuoteUsageSniff now supports \x \f and \v (feature request #13365) - - Squiz ComparisonOperatorUsageSniff now supports JS files - - Squiz ControlSignatureSniff now supports JS files - - Squiz ForLoopDeclarationSniff now supports JS files - - Squiz OperatorBracketSniff now supports JS files - - Squiz InlineControlStructureSniff now supports JS files - - Generic LowerCaseConstantSniff now supports JS files - - Generic DisallowTabIndentSniff now supports JS files - - Generic MultipleStatementAlignmentSniff now supports JS files - - Added Squiz ObjectMemberCommaSniff to ensure the last member of a JS object is not followed by a comma - - Added Squiz ConstantCaseSniff to ensure the PHP constants are uppercase and JS lowercase - - Added Squiz JavaScriptLintSniff to check JS files with JSL - -- Set path using phpcs --config-set jsl_path /path/to/jsl - - Added MySource FirebugConsoleSniff to ban the use of "console" for JS variable and function names - - Added MySource JoinStringsSniff to enforce the use of join() to concatenate JS strings - - Added MySource AssignThisSniff to ensure this is only assigned to a var called self - - Added MySource DisallowNewWidgetSniff to ban manual creation of widget objects - - Removed warning shown in Zend CodeAnalyzerSniff when the ZCA path is not set - - Fixed error in Squiz ValidVariableNameSniff when checking vars in the form $obj->$var - - Fixed error in Squiz DisallowMultipleAssignmentsSniff when checking vars in the form $obj->$var - - Fixed error in Squiz InlineCommentSniff where comments for class constants were seen as inline - - Fixed error in Squiz BlockCommentSniff where comments for class constants were not ignored - - Fixed error in Squiz OperatorBracketSniff where negative numbers were ignored during comparisons - - Fixed error in Squiz FunctionSpacingSniff where functions after member vars reported incorrect spacing - - Fixed bug #13062 : Interface comments aren't handled in PEAR standard - -- Thanks to Manuel Pichler for the path - - Fixed bug #13119 : php minimum requirement need to be fix - - Fixed bug #13156 : Bug in Squiz_Sniffs_PHP_NonExecutableCodeSniff - - Fixed bug #13158 : Strange behaviour in AbstractPatternSniff - - Fixed bug #13169 : Undefined variables - - Fixed bug #13178 : Catch exception in File.php - - Fixed bug #13254 : Notices output in checkstyle report causes XML issues - - Fixed bug #13446 : crash with src of phpMyAdmin - -- Thanks to Manuel Pichler for the path - - - - - 1.1.0a1 - 1.1.0a1 - - - alpha - alpha - - 2008-04-21 - BSD License - - - Fixed error in PEAR ValidClassNameSniff when checking class names with double underscores - - Moved Squiz InlineControlStructureSniff into Generic standard - - PEAR standard now throws warnings for inline control structures - - Squiz OutputBufferingIndentSniff now ignores the indentation of inline HTML - - MySource IncludeSystemSniff now ignores usage of ZipArchive - - Removed "function" from error messages for Generic function brace sniffs (feature request #13820) - - Generic UpperCaseConstantSniff no longer throws errors for declare(ticks = ...) - -- Thanks to Josh Snyder for the patch - - Squiz ClosingDeclarationCommentSniff and AbstractVariableSniff now throw warnings for possible parse errors - - Fixed bug #13827 : AbstractVariableSniff throws "undefined index" - - Fixed bug #13846 : Bug in Squiz.NonExecutableCodeSniff - - Fixed bug #13849 : infinite loop in PHP_CodeSniffer_File::findNext() - - - - - 1.0.1 - 1.0.1 - - - stable - stable - - 2008-02-04 - BSD License - - - Squiz ArrayDeclarationSniff now throws error if the array keyword is followed by a space - - Squiz ArrayDeclarationSniff now throws error for empty multi-line arrays - - Squiz ArrayDeclarationSniff now throws error for multi-line arrays with a single value - - Squiz DocCommentAlignmentSniff now checks for a single space before tags inside docblocks - - Squiz ForbiddenFunctionsSniff now disallows is_null() to force use of (=== NULL) instead - - Squiz VariableCommentSniff now continues throwing errors after the first one is found - - Squiz SuperfluousWhitespaceSniff now throws errors for multiple blank lines inside functions - - MySource IncludedSystemSniff now checks extended class names - - MySource UnusedSystemSniff now checks extended and implemented class names - - MySource IncludedSystemSniff now supports includeWidget() - - MySource UnusedSystemSniff now supports includeWidget() - - Added PEAR ValidVariableNameSniff to check that only private member vars are prefixed with an underscore - - Added Squiz DisallowCountInLoopsSniff to check for the use of count() in FOR and WHILE loop conditions - - Added MySource UnusedSystemSniff to check for included classes that are never used - - Fixed a problem that caused the parentheses map to sometimes contain incorrect values - - Fixed bug #12767 : Cant run phpcs from dir with PEAR subdir - - Fixed bug #12773 : Reserved variables are not detected in strings - -- Thanks to Wilfried Loche for the patch - - Fixed bug #12832 : Tab to space conversion does not work - - Fixed bug #12888 : extra space indentation = Notice: Uninitialized string offset... - - Fixed bug #12909 : Default generateDocs function does not work under linux - -- Thanks to Paul Smith for the patch - - Fixed bug #12957 : PHP 5.3 magic method __callStatic - -- Thanks to Manuel Pichler for the patch - - - - - 1.0.0 - 1.0.0 - - - stable - stable - - 2007-12-21 - BSD License - - - You can now specify the full path to a coding standard on the command line (feature request #11886) - -- This allows you to use standards that are stored outside of PHP_CodeSniffer's own Standard dir - -- You can also specify full paths in the CodingStandard.php include and exclude methods - -- Classes, dirs and files need to be names as if the standard was part of PHP_CodeSniffer - -- Thanks to Dirk Thomas for the doc generator patch and testing - - Modified the scope map to keep checking after 3 lines for some tokens (feature request #12561) - -- Those tokens that must have an opener (like T_CLASS) now keep looking until EOF - -- Other tokens (like T_FUNCTION) still stop after 3 lines for performance - - You can now escape commas in ignore patterns so they can be matched in file names - -- Thanks to Carsten Wiedmann for the patch - - Config data is now cached in a global var so the file system is not hit so often - -- You can also set config data temporarily for the script if you are using your own external script - -- Pass TRUE as the third argument to PHP_CodeSniffer::setConfigData() - - PEAR ClassDeclarationSniff no longer throws errors for multi-line class declarations - - Squiz ClassDeclarationSniff now ensures there is one blank line after a class closing brace - - Squiz ClassDeclarationSniff now throws errors for a missing end PHP tag after the end class tag - - Squiz IncrementDecrementUsageSniff no longer throws errors when -= and += are being used with vars - - Squiz SwitchDeclarationSniff now throws errors for switch statements that do not contain a case statement - -- Thanks to Sertan Danis for the patch - - MySource IncludeSystemSniff no longer throws errors for the Util package - - Fixed bug #12621 : "space after AS" check is wrong - -- Thanks to Satoshi Oikawa for the patch - - Fixed bug #12645 : error message is wrong - -- Thanks to Renoiv for the patch - - Fixed bug #12651 : Increment/Decrement Operators Usage at -1 - - - - - 1.0.0RC3 - 1.0.0RC3 - - - beta - beta - - 2007-11-30 - BSD License - - - Added new command line argument --tab-width that will convert tabs to spaces before testing - -- This allows you to use the existing sniffs that check for spaces even when you use tabs - -- Can also be set via a config var: phpcs --config-set tab_width 4 - -- A value of zero (the default) tells PHP_CodeSniffer not to replace tabs with spaces - - You can now change the default report format from "full" to something else - -- Run: phpcs --config-set report_format [format] - - Improved performance by optimising the way the scope map is created during tokenising - - Added new Squiz DisallowInlineIfSniff to disallow the usage of inline IF statements - - Fixed incorrect errors being thrown for nested switches in Squiz SwitchDeclarationSniff - - PEAR FunctionCommentSniff no longer complains about missing comments for @throws tags - - PEAR FunctionCommentSniff now throws error for missing exception class name for @throws tags - - PHP_CodeSniffer_File::isReference() now correctly returns for functions that return references - - Generic LineLengthSniff no longer warns about @version lines with CVS or SVN id tags - - Generic LineLengthSniff no longer warns about @license lines with long URLs - - Squiz FunctionCommentThrowTagSniff no longer complains about throwing variables - - Squiz ComparisonOperatorUsageSniff no longer throws incorrect errors for inline IF statements - - Squiz DisallowMultipleAssignmentsSniff no longer throws errors for assignments in inline IF statements - - Fixed bug #12455 : CodeSniffer treats content inside heredoc as PHP code - - Fixed bug #12471 : Checkstyle report is broken - - Fixed bug #12476 : PHP4 destructors are reported as error - - Fixed bug #12513 : Checkstyle XML messages need to be utf8_encode()d - -- Thanks to Sebastian Bergmann for the patch. - - Fixed bug #12517 : getNewlineAfter() and dos files - - - - - 1.0.0RC2 - 1.0.0RC2 - - - beta - beta - - 2007-11-14 - BSD License - - - Added a new Checkstyle report format - -- Like the current XML format but modified to look like Checkstyle output - -- Thanks to Manuel Pichler for helping get the format correct - - You can now hide warnings by default - -- Run: phpcs --config-set show_warnings 0 - -- If warnings are hidden by default, use the new -w command line argument to override - - Added new command line argument --config-delete to delete a config value and revert to the default - - Improved overall performance by optimising tokenising and next/prev methods (feature request #12421) - -- Thanks to Christian Weiske for the patch - - Added FunctionCallSignatureSniff to Squiz standard - - Added @subpackage support to file and class comment sniffs in PEAR standard (feature request #12382) - -- Thanks to Carsten Wiedmann for the patch - - An error is now displayed if you use a PHP version less than 5.1.0 (feature request #12380) - -- Thanks to Carsten Wiedmann for the patch - - phpcs now exits with status 2 if it receives invalid input (feature request #12380) - -- This is distinct from status 1, which indicates errors or warnings were found - - Added new Squiz LanguageConstructSpacingSniff to throw errors for additional whitespace after echo etc. - - Removed Squiz ValidInterfaceNameSniff - - PEAR FunctionCommentSniff no longer complains about unknown tags - - Fixed incorrect errors about missing function comments in PEAR FunctionCommentSniff - - Fixed incorrect function docblock detection in Squiz FunctionCommentSniff - - Fixed incorrect errors for list() in Squiz DisallowMultipleAssignmentsSniff - - Errors no longer thrown if control structure is followed by a CASE's BREAK in Squiz ControlStructureSpacingSniff - - Fixed bug #12368 : Autoloader cannot be found due to include_path override - -- Thanks to Richard Quadling for the patch - - Fixed bug #12378 : equal sign alignments problem with while() - - - - - 1.0.0RC1 - 1.0.0RC1 - - - beta - beta - - 2007-11-01 - BSD License - - - Main phpcs script can now be run from a CVS checkout without installing the package - - Added a new CSV report format - -- Header row indicates what position each element is in - -- Always use the header row to determine positions rather than assuming the format, as it may change - - XML and CSV report formats now contain information about which column the error occurred at - -- Useful if you want to highlight the token that caused the error in a custom application - - Square bracket tokens now have bracket_opener and bracket_closer set - - Added new Squiz SemicolonSpacingSniff to throw errors if whitespace is found before a semicolon - - Added new Squiz ArrayBracketSpacingSniff to throw errors if whitespace is found around square brackets - - Added new Squiz ObjectOperatorSpacingSniff to throw errors if whitespace is found around object operators - - Added new Squiz DisallowMultipleAssignmentsSniff to throw errors if multiple assignments are on the same line - - Added new Squiz ScopeKeywordSpacingSniff to throw errors if there is not a single space after a scope modifier - - Added new Squiz ObjectInstantiationSniff to throw errors if new objects are not assigned to a variable - - Added new Squiz FunctionDuplicateArgumentSniff to throw errors if argument is declared multiple times in a function - - Added new Squiz FunctionOpeningBraceSpaceSniff to ensure there are no blank lines after a function open brace - - Added new Squiz CommentedOutCodeSniff to warn about comments that looks like they are commented out code blocks - - Added CyclomaticComplexitySniff to Squiz standard - - Added NestingLevelSniff to Squiz standard - - Squiz ForbiddenFunctionsSniff now recommends echo() instead of print() - - Squiz ValidLogicalOperatorsSniff now recommends ^ instead of xor - - Squiz SwitchDeclarationSniff now contains more checks - -- A single space is required after the case keyword - -- No space is allowed before the colon in a case or default statement - -- All switch statements now require a default case - -- Default case must contain a break statement - -- Empty default case must contain a comment describing why the default is ignored - -- Empty case statements are not allowed - -- Case and default statements must not be followed by a blank line - -- Break statements must be followed by a blank line or the closing brace - -- There must be no blank line before a break statement - - Squiz standard is now using the PEAR IncludingFileSniff - - PEAR ClassCommentSniff no longer complains about unknown tags - - PEAR FileCommentSniff no longer complains about unknown tags - - PEAR FileCommentSniff now accepts multiple @copyright tags - - Squiz BlockCommentSniff now checks that comment starts with a capital letter - - Squiz InlineCommentSniff now has better checking to ensure comment starts with a capital letter - - Squiz ClassCommentSniff now checks that short and long comments start with a capital letter - - Squiz FunctionCommentSniff now checks that short, long and param comments start with a capital letter - - Squiz VariableCommentSniff now checks that short and long comments start with a capital letter - - Fixed error with multi-token array indexes in Squiz ArrayDeclarationSniff - - Fixed error with checking shorthand IF statements without a semicolon in Squiz InlineIfDeclarationSniff - - Fixed error where constants used as default values in function declarations were seen as type hints - - Fixed bug #12316 : PEAR is no longer the default standard - - Fixed bug #12321 : wrong detection of missing function docblock - - - - - 0.9.0 - 0.9.0 - - - beta - beta - - 2007-09-24 - BSD License - - - Added a config system for setting config data across phpcs runs - - You can now change the default coding standard from PEAR to something else - -- Run: phpcs --config-set default_standard [standard] - - Added new Zend coding standard to check code against the Zend Framework standards - -- The complete standard is not yet implemented - -- Specify --standard=Zend to use - -- Thanks to Johann-Peter Hartmann for the contribution of some sniffs - -- Thanks to Holger Kral for the Code Analyzer sniff - - - - - 0.8.0 - 0.8.0 - - - beta - beta - - 2007-08-08 - BSD License - - - Added new XML report format; --report=xml (feature request #11535) - -- Thanks to Brett Bieber for the patch - - Added new command line argument --ignore to specify a list of files to skip (feature request #11556) - - Added PHPCS and MySource coding standards into the core install - - Scope map no longer gets confused by curly braces that act as string offsets - - Removed CodeSniffer/SniffException.php as it is no longer used - - Unit tests can now be run directly from a CVS checkout - - Made private vars and functions protected in PHP_CodeSniffer class so this package can be overridden - - Added new Metrics category to Generic coding standard - -- Contains Cyclomatic Complexity and Nesting Level sniffs - -- Thanks to Johann-Peter Hartmann for the contribution - - Added new Generic DisallowTabIndentSniff to throw errors if tabs are used for indentation (feature request #11738) - -- PEAR and Squiz standards use this new sniff to throw more specific indentation errors - - Generic MultipleStatementAlignmentSniff has new private var to set a padding size limit (feature request #11555) - - Generic MultipleStatementAlignmentSniff can now handle assignments that span multiple lines (feature request #11561) - - Generic LineLengthSniff now has a max line length after which errors are thrown instead of warnings - -- BC BREAK: Override the protected member var absoluteLineLimit and set it to zero in custom LineLength sniffs - -- Thanks to Johann-Peter Hartmann for the contribution - - Comment sniff errors about incorrect tag orders are now more descriptive (feature request #11693) - - Fixed bug #11473 : Invalid CamelCaps name when numbers used in names - - - - - 0.7.0 - 0.7.0 - - - beta - beta - - 2007-07-02 - BSD License - - - BC BREAK: EOL character is now auto-detected and used instead of hard-coded \n - -- Pattern sniffs must now specify "EOL" instead of "\n" or "\r\n" to use auto-detection - -- Please use $phpcsFile->eolChar to check for newlines instead of hard-coding "\n" or "\r\n" - -- Comment parser classes now require you to pass $phpcsFile as an additional argument - - BC BREAK: Included and excluded sniffs now require .php extension - -- Please update your coding standard classes and add ".php" to all sniff entries - -- See CodeSniffer/Standards/PEAR/PEARCodingStandard.php for an example - - - Fixed error where including a directory of sniffs in a coding standard class did not work - - Coding standard classes can now specify a list of sniffs to exclude as well as include (feature request #11056) - - Two uppercase characters can now be placed side-by-side in class names in Squiz ValidClassNameSniff - - SVN tags now allowed in PEAR file doc blocks (feature request #11038) - -- Thanks to Torsten Roehr for the patch - - Private methods in commenting sniffs and comment parser are now protected (feature request #11087) - - Added Generic LineEndingsSniff to check the EOL character of a file - - PEAR standard now only throws one error per file for incorrect line endings (eg. /r/n) - - Command line arg -v now shows number of registered sniffs - - Command line arg -vvv now shows list of registered sniffs - - Squiz ControlStructureSpacingSniff no longer throws errors if the control structure is at the end of the script - - Squiz FunctionCommentSniff now throws error for "return void" if function has return statement - - Squiz FunctionCommentSniff now throws error for functions that return void but specify something else - - Squiz ValidVariableNameSniff now allows multiple uppercase letters in a row - - Squiz ForEachLoopDeclarationSniff now throws error for AS keyword not being lowercase - - Squiz SwitchDeclarationSniff now throws errors for CASE/DEFAULT/BREAK keywords not being lowercase - - Squiz ArrayDeclarationSniff now handles multi-token array values when checking alignment - - Squiz standard now enforces a space after cast tokens - - Generic MultipleStatementAlignmentSniff no longer gets confused by assignments inside FOR conditions - - Generic MultipleStatementAlignmentSniff no longer gets confused by the use of list() - - Added Generic SpaceAfterCastSniff to ensure there is a single space after a cast token - - Added Generic NoSpaceAfterCastSniff to ensure there is no whitespace after a cast token - - Added PEAR ClassDeclarationSniff to ensure the opening brace of a class is on the line after the keyword - - Added Squiz ScopeClosingBraceSniff to ensure closing braces are aligned correctly - - Added Squiz EvalSniff to discourage the use of eval() - - Added Squiz LowercaseDeclarationSniff to ensure all declaration keywords are lowercase - - Added Squiz LowercaseClassKeywordsSniff to ensure all class declaration keywords are lowercase - - Added Squiz LowercaseFunctionKeywordsSniff to ensure all function declaration keywords are lowercase - - Added Squiz LowercasePHPFunctionsSniff to ensure all calls to inbuilt PHP functions are lowercase - - Added Squiz CastSpacingSniff to ensure cast statements dont contain whitespace - - Errors no longer thrown when checking 0 length files with verbosity on - - Fixed bug #11105 : getIncludedSniffs() not working anymore - -- Thanks to Blair Robertson for the patch - - Fixed bug #11120 : Uninitialized string offset in AbstractParser.php on line 200 - - - - - 0.6.0 - 0.6.0 - - - beta - beta - - 2007-05-15 - BSD License - - - The number of errors and warnings found is now shown for each file while checking the file if verbosity is enabled - - Now using PHP_EOL instead of hard-coded \n so output looks good on Windows (feature request #10761) - - Thanks to Carsten Wiedmann for the patch. - - phpcs now exits with status 0 (no errors) or 1 (errors found) (feature request #10348) - - Added new -l command line argument to stop recursion into directories (feature request #10979) - - Fixed variable name error causing incorrect error message in Squiz ValidVariableNameSniff - - Fixed bug #10757 : Error in ControlSignatureSniff - - Fixed bugs #10751, #10777 : Sniffer class paths handled incorrectly in Windows - - Thanks to Carsten Wiedmann for the patch. - - Fixed bug #10961 : Error "Last parameter comment requires a blank newline after it" thrown - - Fixed bug #10983 : phpcs outputs notices when checking invalid PHP - - Fixed bug #10980 : Incorrect warnings for equals sign - - - - - 0.5.0 - 0.5.0 - - - beta - beta - - 2007-04-17 - BSD License - - - BC BREAK: Coding standards now require a class to be added so PHP_CodeSniffer can get information from them - - Please read the end user docs for info about the new class required for all coding standards - - - Coding standards can now include sniffs from other standards, or whole standards, without writing new sniff files - - PHP_CodeSniffer_File::isReference() now correctly returns for references in function declarations - - PHP_CodeSniffer_File::isReference() now returns false if you don't pass it a T_BITWISE_AND token - - PHP_CodeSniffer_File now stores the absolute path to the file so sniffs can check file locations correctly - - Fixed undefined index error in AbstractVariableSniff for variables inside an interface function definition - - Added MemberVarSpacingSniff to Squiz standard to enforce one-line spacing between member vars - - Add FunctionCommentThrowTagSniff to Squiz standard to check that @throws tags are correct - - Fixed problems caused by references and type hints in Squiz FunctionDeclarationArgumentSpacingSniff - - Fixed problems with errors not being thrown for some misaligned @param comments in Squiz FunctionCommentSniff - - Fixed badly spaced comma error being thrown for "extends" class in Squiz ClassDeclarationSniff - - Errors no longer thrown for class method names in Generic ForbiddenFunctionsSniff - - Errors no longer thrown for type hints in front of references in Generic UpperCaseConstantNameSniff - - Errors no longer thrown for correctly indented buffered lines in Squiz ScopeIndexSniff - - Errors no longer thrown for user-defined functions named as forbidden functions in Generic ForbiddenFunctionsSniff - - Errors no longer thrown on __autoload functions in PEAR ValidFunctionNameSniff - - Errors now thrown for __autoload methods in PEAR ValidFunctionNameSniff - - Errors now thrown if constructors or destructors have @return tags in Squiz FunctionCommentSniff - - Errors now thrown if @throws tags dont start with a capital and end with a full stop in Squiz FunctionCommentSniff - - Errors now thrown for invalid @var tag values in Squiz VariableCommentSniff - - Errors now thrown for missing doc comment in Squiz VariableCommentSniff - - Errors now thrown for unspaced operators in FOR loop declarations in Squiz OperatorSpacingSniff - - Errors now thrown for using ob_get_clean/flush functions to end buffers in Squiz OutputBufferingIndentSniff - - Errors now thrown for all missing member variable comments in Squiz VariableCommentSniff - - - - - 0.4.0 - 0.4.0 - - - beta - beta - - 2007-02-19 - BSD License - - - Standard name specified with --standard command line argument is no longer case sensitive - - Long error and warning messages are now wrapped to 80 characters in the full error report (thanks Endre Czirbesz) - - Shortened a lot of error and warning messages so they don't take up so much room - - Squiz FunctionCommentSniff now checks that param comments start with a capital letter and end with a full stop - - Squiz FunctionSpacingSniff now reports incorrect lines below function on closing brace, not function keyword - - Squiz FileCommentSniff now checks that there are no blank lines between the open PHP tag and the comment - - PHP_CodeSniffer_File::isReference() now returns correctly when checking refs on right side of => - - Fixed incorrect error with switch closing brace in Squiz SwitchDeclarationSniff - - Fixed missing error when multiple statements are not aligned correctly with object operators - - Fixed incorrect errors for some PHP special variables in Squiz ValidVariableNameSniff - - Fixed incorrect errors for arrays that only contain other arrays in Squiz ArrayDeclarationSniff - - Fixed bug #9844 : throw new Exception(\n accidentally reported as error but it ain't - - - - - 0.3.0 - 0.3.0 - - - beta - beta - - 2007-01-11 - BSD License - - - Updated package.xml to version 2 - - Specifying coding standard on command line is now optional, even if you have multiple standards installed - - PHP_CodeSniffer uses the PEAR coding standard by default if no standard is specified - - New command line option, --extensions, to specify a comma separated list of file extensions to check - - Converted all unit tests to PHPUnit 3 format - - Added new coding standard, Squiz, that can be used as an alternative to PEAR - - also contains more examples of sniffs - - some may be moved into the Generic coding standard if required - - Added MultipleStatementAlignmentSniff to Generic standard - - Added ScopeIndentSniff to Generic standard - - Added ForbiddenFunctionsSniff to Generic standard - - Added FileCommentSniff to PEAR standard - - Added ClassCommentSniff to PEAR standard - - Added FunctionCommentSniff to PEAR standard - - Change MultipleStatementSniff to MultipleStatementAlignmentSniff in PEAR standard - - Replaced Methods directory with Functions directory in Generic and PEAR standards - - also renamed some of the sniffs in those directories - - Updated file, class and method comments for all files - - Fixed bug #9274 : nested_parenthesis element not set for open and close parenthesis tokens - - Fixed bug #9411 : too few pattern characters cause incorrect error report - - - - - 0.2.1 - 0.2.1 - - - alpha - alpha - - 2006-11-09 - BSD License - - - Fixed bug #9274 : nested_parenthesis element not set for open and close parenthesis tokens - - - - - 0.2.0 - 0.2.0 - - - alpha - alpha - - 2006-10-13 - BSD License - - - Added a generic standards package that will contain generic sniffs to be used in specific coding standards - - thanks to Frederic Poeydomenge for the idea - - Changed PEAR standard to use generic sniffs where available - - Added LowerCaseConstantSniff to Generic standard - - Added UpperCaseConstantSniff to Generic standard - - Added DisallowShortOpenTagSniff to Generic standard - - Added LineLengthSniff to Generic standard - - Added UpperCaseConstantNameSniff to Generic standard - - Added OpeningMethodBraceBsdAllmanSniff to Generic standard (contrib by Frederic Poeydomenge) - - Added OpeningMethodBraceKernighanRitchieSniff to Generic standard (contrib by Frederic Poeydomenge) - - Added framework for core PHP_CodeSniffer unit tests - - Added unit test for PHP_CodeSniffer:isCamelCaps method - - ScopeClosingBraceSniff now checks indentation of BREAK statements - - Added new command line arg (-vv) to show developer debug output - - Fixed some coding standard errors - - Fixed bug #8834 : Massive memory consumption - - Fixed bug #8836 : path case issues in package.xml - - Fixed bug #8843 : confusion on nested switch() - - Fixed bug #8841 : comments taken as whitespace - - Fixed bug #8884 : another problem with nested switch() statements - - - - - 0.1.1 - 0.1.1 - - - alpha - alpha - - 2006-09-25 - BSD License - - - Added unit tests for all PEAR sniffs - - Exception class now extends from PEAR_Exception - - Fixed summary report so files without errors but with warnings are not shown when warnings are hidden - - - - - 0.1.0 - 0.1.0 - - - alpha - alpha - - 2006-09-19 - BSD License - - - Reorganised package contents to conform to PEAR standards - - Changed version numbering to conform to PEAR standards - - Removed duplicate require_once() of Exception.php from CodeSniffer.php - - - - - 0.0.5 - 0.0.5 - - - alpha - alpha - - 2006-09-18 - BSD License - - - Fixed .bat file for situation where php.ini cannot be found so include_path is not set - - - - - 0.0.4 - 0.0.4 - - - alpha - alpha - - 2006-08-28 - BSD License - - - Added .bat file for easier running of PHP_CodeSniffer on Windows - - Sniff that checks method names now works for PHP4 style code where there is no scope keyword - - Sniff that checks method names now works for PHP4 style constructors - - Sniff that checks method names no longer incorrectly reports error with magic methods - - Sniff that checks method names now reports errors with non-magic methods prefixed with __ - - Sniff that checks for constant names no longer incorrectly reports errors with heredoc strings - - Sniff that checks for constant names no longer incorrectly reports errors with created objects - - Sniff that checks indentation no longer incorrectly reports errors with heredoc strings - - Sniff that checks indentation now correctly reports errors with improperly indented multi-line strings - - Sniff that checks function declarations now checks for spaces before and after an equals sign for default values - - Sniff that checks function declarations no longer incorrectly reports errors with multi-line declarations - - Sniff that checks included code no longer incorrectly reports errors when return value is used conditionally - - Sniff that checks opening brace of function no longer incorrectly reports errors with multi-line declarations - - Sniff that checks spacing after commas in function calls no longer reports too many errors for some code - - Sniff that checks control structure declarations now gives more descriptive error message - - - - - 0.0.3 - 0.0.3 - - - alpha - alpha - - 2006-08-22 - BSD License - - - Added sniff to check for invalid class and interface names - - Added sniff to check for invalid function and method names - - Added sniff to warn if line is greater than 85 characters - - Added sniff to check that function calls are in the correct format - - Fixed error where comments were not allowed on the same line as a control structure declaration - - Added command line arg to print current version (--version) - - - - - 0.0.2 - 0.0.2 - - - alpha - alpha - - 2006-07-25 - BSD License - - - Removed the including of checked files to stop errors caused by parsing them - - Removed the use of reflection so checked files do not have to be included - - Memory usage has been greatly reduced - - Much faster tokenising and checking times - - Reworked the PEAR coding standard sniffs (much faster now) - - Fix some bugs with the PEAR scope indentation standard - - Better checking for installed coding standards - - Can now accept multiple files and dirs on the command line - - Added an option to list installed coding standards - - Added an option to print a summary report (number of errors and warnings shown for each file) - - Added an option to hide warnings from reports - - Added an option to print verbose output (so you know what is going on) - - Reordered command line args to put switches first (although order is not enforced) - - Switches can now be specified together (eg. php -nv) as well as separately (phpcs -n -v) - - - - - 0.0.1 - 0.0.1 - - - alpha - alpha - - 2006-07-19 - BSD License - Initial preview release. - - - diff --git a/scripts/ValidatePEAR/ValidatePEARPackageXML.php b/scripts/ValidatePEAR/ValidatePEARPackageXML.php deleted file mode 100644 index 5c1d2d1f0f..0000000000 --- a/scripts/ValidatePEAR/ValidatePEARPackageXML.php +++ /dev/null @@ -1,363 +0,0 @@ - - * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -use PHP_CodeSniffer\Tests\FileList; - -/** - * Validate the PHP_CodeSniffer PEAR package.xml file. - */ -class ValidatePEARPackageXML -{ - - /** - * The root directory of the project. - * - * @var string - */ - protected $projectRoot = ''; - - /** - * The contents of the package.xml file. - * - * @var \SimpleXMLElement - */ - protected $packageXML; - - /** - * List of all files in the repo. - * - * @var array - */ - protected $allFiles = []; - - /** - * Valid file roles. - * - * @var array - * - * @link https://pear.php.net/manual/en/developers.packagedef.intro.php#developers.packagedef.roles - */ - private $validRoles = [ - 'data' => true, - 'doc' => true, - 'ext' => true, - 'extsrc' => true, - 'php' => true, - 'script' => true, - 'src' => true, - 'test' => true, - ]; - - /** - * Files encountered in the package.xml tag. - * - * @var array - */ - private $listedContents = []; - - - /** - * Constructor. - */ - public function __construct() - { - $this->projectRoot = dirname(dirname(__DIR__)).'/'; - $this->packageXML = simplexml_load_file($this->projectRoot.'package.xml'); - - $allFiles = (new FileList($this->projectRoot, $this->projectRoot))->getList(); - $this->allFiles = array_flip($allFiles); - - }//end __construct() - - - /** - * Validate the file listings in the package.xml file. - * - * @return void - */ - public function validate() - { - $exitCode = 0; - if ($this->checkContents() !== true) { - $exitCode = 1; - } - - if ($this->checkPHPRelease() !== true) { - $exitCode = 1; - } - - exit($exitCode); - - }//end validate() - - - /** - * Validate the file listings in the tag. - * - * @return bool - */ - protected function checkContents() - { - echo PHP_EOL.'Checking Contents tag'.PHP_EOL; - echo '====================='.PHP_EOL; - - $valid = true; - - /* - * - Check that every file that is mentioned in the `` tag exists in the repo. - * - Check that the "role" value is valid. - * - Check that the "baseinstalldir" value is valid. - */ - - $valid = $this->walkDirTag($this->packageXML->contents); - if ($valid === true) { - echo "Existing listings in the Contents tag are valid.".PHP_EOL; - } - - /* - * Verify that all files in the `src` and the `tests` directories are listed in the `` tag. - */ - - $srcFiles = (new FileList( - $this->projectRoot.'src/', - $this->projectRoot, - '`\.(css|fixed|inc|js|php|xml)$`Di' - ))->getList(); - $testsFiles = (new FileList( - $this->projectRoot.'tests/', - $this->projectRoot, - '`\.(css|inc|js|php|xml)$`Di' - ))->getList(); - $files = array_merge($srcFiles, $testsFiles); - - foreach ($files as $file) { - if (isset($this->listedContents[$file]) === true) { - continue; - } - - echo "- File '{$file}' is missing from Contents tag.".PHP_EOL; - $valid = false; - } - - if ($valid === true) { - echo "No missing files in the Contents tag.".PHP_EOL; - } - - return $valid; - - }//end checkContents() - - - /** - * Validate all child tags within a tag. - * - * @param \SimpleXMLElement $tag The current XML tag to examine. - * @param string $currentDirectory The complete relative path to the - * directory being examined. - * - * @return bool - */ - protected function walkDirTag($tag, $currentDirectory='') - { - $valid = true; - $name = (string) $tag['name']; - if ($name !== '/' && empty($name) === false) { - $currentDirectory .= $name.'/'; - } - - $children = $tag->children(); - foreach ($children as $key => $value) { - if ($key === 'dir') { - if ($this->walkDirTag($value, $currentDirectory) === false) { - $valid = false; - } - } - - if ($key === 'file') { - if ($this->checkFileTag($value, $currentDirectory) === false) { - $valid = false; - } - } - } - - return $valid; - - }//end walkDirTag() - - - /** - * Validate the information within a tag. - * - * @param \SimpleXMLElement $tag The current XML tag to examine. - * @param string $currentDirectory The complete relative path to the - * directory being examined. - * - * @return bool - */ - protected function checkFileTag($tag, $currentDirectory='') - { - $valid = true; - $attributes = $tag->attributes(); - $baseinstalldir = (string) $attributes['baseinstalldir']; - $name = $currentDirectory.(string) $attributes['name']; - $role = (string) $attributes['role']; - - $this->listedContents[$name] = true; - - if (empty($name) === true) { - echo "- Name attribute missing.".PHP_EOL; - $valid = false; - } else { - if (isset($this->allFiles[$name]) === false) { - echo "- File '{$name}' does not exist.".PHP_EOL; - $valid = false; - } - - if (empty($role) === true) { - echo "- Role attribute missing for file '{$name}'.".PHP_EOL; - $valid = false; - } else { - if (isset($this->validRoles[$role]) === false) { - echo "- Role for file '{$name}' is invalid.".PHP_EOL; - $valid = false; - } else { - // Limited validation of the "role" tags. - if ((strpos($name, 'tests/') === 0 || strpos($name, 'Test.') !== false) && $role !== 'test') { - echo "- Test files should have the role 'test'. Found: '$role' for file '{$name}'.".PHP_EOL; - $valid = false; - } else if (strpos($name, 'tests/') !== 0 - && (strpos($name, 'Standard.xml') !== false || strpos($name, 'Sniff.php') !== false) - && $role !== 'php' - ) { - echo "- Sniff files, including sniff documentation files should have the role 'php'. Found: '$role' for file '{$name}'.".PHP_EOL; - $valid = false; - } - } - - if (empty($baseinstalldir) === true) { - if ($role !== 'script' && strpos($name, 'tests/') !== 0) { - echo "- Baseinstalldir attribute missing for file '{$name}'.".PHP_EOL; - $valid = false; - } - } else { - if ($role === 'script' || strpos($name, 'tests/') === 0) { - echo "- Baseinstalldir for file '{$name}' should be empty.".PHP_EOL; - $valid = false; - } - - if ($role !== 'script' && $baseinstalldir !== 'PHP/CodeSniffer') { - echo "- Baseinstalldir for file '{$name}' is invalid.".PHP_EOL; - $valid = false; - } - } - }//end if - }//end if - - return $valid; - - }//end checkFileTag() - - - /** - * Validate the file listings in the tags. - * - * @return bool True if the info in the "phprelease" tags is valid. False otherwise. - */ - protected function checkPHPRelease() - { - echo PHP_EOL.'Checking PHPRelease tags'.PHP_EOL; - echo '========================'.PHP_EOL; - - $valid = true; - $listedFiles = []; - $releaseTags = 1; - - /* - * - Check that every file that is mentioned in the `` tags exists in the repo. - * - Check that the "as" value is valid. - */ - - foreach ($this->packageXML->phprelease as $release) { - foreach ($release->filelist->install as $install) { - $attributes = $install->attributes(); - $name = (string) $attributes['name']; - $as = (string) $attributes['as']; - - $listedFiles[$releaseTags][$name] = $as; - - if (empty($as) === true || empty($name) === true) { - continue; - } - - if (isset($this->allFiles[$name]) === false) { - echo "- File '{$name}' does not exist.".PHP_EOL; - $valid = false; - } - - // Rest of the checks only apply to the test files. - if (strpos($name, 'tests/') !== 0) { - continue; - } - - // Check validity of the tags for files in the tests root directory. - if (preg_match('`^tests/([^/]+\.php)$`', $name, $matches) === 1 - && ($as === $name || $as === $matches[1]) - ) { - continue; - } - - // Check validity of the tags for files in the tests root subdirectories. - if (preg_match('`^tests/.+\.(php|inc|js|css|xml)$`', $name) === 1 - && $as === str_replace('tests/', 'CodeSniffer/', $name) - ) { - continue; - } - - echo "- Invalid 'as' attribute '{$as}' for test file '{$name}'.".PHP_EOL; - $valid = false; - }//end foreach - - ++$releaseTags; - }//end foreach - - if ($valid === true) { - echo "Existing PHPRelease tags are valid.".PHP_EOL; - } - - /* - * Verify that all files in the `tests` directory are listed in both `` tags. - */ - - $testFiles = (new FileList($this->projectRoot.'tests/', $this->projectRoot, '`\.(inc|php|js|css|xml)$`Di'))->getList(); - - foreach ($testFiles as $file) { - foreach ($listedFiles as $key => $listed) { - if (isset($listed[$file]) === true) { - continue; - } - - echo "- File '{$file}' is missing from PHPRelease tag [{$key}] .".PHP_EOL; - $valid = false; - } - } - - if ($valid === true) { - echo "No missing PHPRelease tags.".PHP_EOL; - } - - return $valid; - - }//end checkPHPRelease() - - -}//end class diff --git a/scripts/validate-pear-package.php b/scripts/validate-pear-package.php deleted file mode 100644 index 1d373f25f9..0000000000 --- a/scripts/validate-pear-package.php +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env php - - * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -require_once dirname(__DIR__).'/tests/FileList.php'; -require_once __DIR__.'/ValidatePEAR/ValidatePEARPackageXML.php'; - -$validate = new ValidatePEARPackageXML(); -$validate->validate(); diff --git a/src/Config.php b/src/Config.php index ffad6cb8f1..aba5450327 100644 --- a/src/Config.php +++ b/src/Config.php @@ -1581,13 +1581,6 @@ public static function setConfigData($key, $value, $temp=false) $configFile = dirname($path).DIRECTORY_SEPARATOR.'CodeSniffer.conf'; } else { $configFile = dirname(__DIR__).DIRECTORY_SEPARATOR.'CodeSniffer.conf'; - if (is_file($configFile) === false - && strpos('@data_dir@', '@data_dir') === false - ) { - // If data_dir was replaced, this is a PEAR install and we can - // use the PEAR data dir to store the conf file. - $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf'; - } } if (is_file($configFile) === true diff --git a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php index 3aae0bab07..e94b5d47ce 100644 --- a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php @@ -22,10 +22,8 @@ class ExecutableFileUnitTest extends AbstractSniffUnitTest */ protected function shouldSkipTest() { - // PEAR doesn't preserve the executable flag, so skip - // tests when running in a PEAR install. - // Also skip on Windows which doesn't have the concept of executable files. - return ($GLOBALS['PHP_CODESNIFFER_PEAR'] || stripos(PHP_OS, 'WIN') === 0); + // Skip on Windows which doesn't have the concept of executable files. + return (stripos(PHP_OS, 'WIN') === 0); }//end shouldSkipTest() diff --git a/tests/AllTests.php b/tests/AllTests.php index cb22aabf1b..5ee125f437 100644 --- a/tests/AllTests.php +++ b/tests/AllTests.php @@ -9,14 +9,8 @@ namespace PHP_CodeSniffer\Tests; -if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === false) { - include_once 'Core/AllTests.php'; - include_once 'Standards/AllSniffs.php'; -} else { - include_once 'CodeSniffer/Core/AllTests.php'; - include_once 'CodeSniffer/Standards/AllSniffs.php'; - include_once 'FileList.php'; -} +require_once 'Core/AllTests.php'; +require_once 'Standards/AllSniffs.php'; // PHPUnit 7 made the TestSuite run() method incompatible with // older PHPUnit versions due to return type hints, so maintain diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index 84c4487abc..83affe9bc1 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -33,23 +33,6 @@ class AcceptTest extends TestCase protected static $ruleset; - /** - * Initialize the test. - * - * @return void - */ - public function setUp() - { - if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { - // PEAR installs test and sniff files into different locations - // so these tests will not pass as they directly reference files - // by relative location. - $this->markTestSkipped('Test cannot run from a PEAR install'); - } - - }//end setUp() - - /** * Initialize the config and ruleset objects based on the `AcceptTest.xml` ruleset file. * @@ -57,11 +40,6 @@ public function setUp() */ public static function setUpBeforeClass() { - if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { - // This test will be skipped. - return; - } - $standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; self::$config = new Config(["--standard=$standard", "--ignore=*/somethingelse/*"]); self::$ruleset = new Ruleset(self::$config); diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php index 079934a6b5..a41c856882 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php @@ -45,13 +45,6 @@ class RuleInclusionAbsoluteLinuxTest extends TestCase */ public function setUp() { - if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { - // PEAR installs test and sniff files into different locations - // so these tests will not pass as they directly reference files - // by relative location. - $this->markTestSkipped('Test cannot run from a PEAR install'); - } - $this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; $repoRootDir = dirname(dirname(dirname(__DIR__))); diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php index 633b729306..b7c4410a06 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php @@ -49,13 +49,6 @@ public function setUp() $this->markTestSkipped('Windows specific test'); } - if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { - // PEAR installs test and sniff files into different locations - // so these tests will not pass as they directly reference files - // by relative location. - $this->markTestSkipped('Test cannot run from a PEAR install'); - } - $this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; $repoRootDir = dirname(dirname(dirname(__DIR__))); diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index 6772d54c76..b74c54d394 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -38,23 +38,6 @@ class RuleInclusionTest extends TestCase private static $contents = ''; - /** - * Initialize the test. - * - * @return void - */ - public function setUp() - { - if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { - // PEAR installs test and sniff files into different locations - // so these tests will not pass as they directly reference files - // by relative location. - $this->markTestSkipped('Test cannot run from a PEAR install'); - } - - }//end setUp() - - /** * Initialize the config and ruleset objects based on the `RuleInclusionTest.xml` ruleset file. * @@ -62,11 +45,6 @@ public function setUp() */ public static function setUpBeforeClass() { - if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { - // This test will be skipped. - return; - } - $standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; self::$standard = $standard; diff --git a/tests/Core/Ruleset/SetSniffPropertyTest.php b/tests/Core/Ruleset/SetSniffPropertyTest.php index 5add67b1e4..5f5b882103 100644 --- a/tests/Core/Ruleset/SetSniffPropertyTest.php +++ b/tests/Core/Ruleset/SetSniffPropertyTest.php @@ -22,23 +22,6 @@ class SetSniffPropertyTest extends TestCase { - /** - * Initialize the test. - * - * @return void - */ - public function setUp() - { - if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { - // PEAR installs test and sniff files into different locations - // so these tests will not pass as they directly reference files - // by relative location. - $this->markTestSkipped('Test cannot run from a PEAR install'); - } - - }//end setUp() - - /** * Test that setting a property via the ruleset works in all situations which allow for it. * diff --git a/tests/Standards/AllSniffs.php b/tests/Standards/AllSniffs.php index ced988e920..e355d90dab 100644 --- a/tests/Standards/AllSniffs.php +++ b/tests/Standards/AllSniffs.php @@ -61,20 +61,11 @@ public static function suite() foreach ($installedStandards as $standard => $details) { Autoload::addSearchPath($details['path'], $details['namespace']); - // If the test is running PEAR installed, the built-in standards - // are split into different directories; one for the sniffs and - // a different file system location for tests. - if ($isInstalled === true && is_dir(dirname($details['path']).DIRECTORY_SEPARATOR.'Generic') === true) { - $testPath = realpath(__DIR__.'/../../src/Standards/'.$standard); - } else { - $testPath = $details['path']; - } - if (in_array($standard, $ignoreTestsForStandards, true) === true) { continue; } - $testsDir = $testPath.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR; + $testsDir = $details['path'].DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR; if (is_dir($testsDir) === false) { // No tests for this standard. continue; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e8020a06fc..8d91b156f7 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -44,13 +44,6 @@ class_alias('PHPUnit_TextUI_TestRunner', 'PHPUnit'.'\TextUI\TestRunner'); class_alias('PHPUnit_Framework_TestResult', 'PHPUnit'.'\Framework\TestResult'); } -// Determine whether this is a PEAR install or not. -$GLOBALS['PHP_CODESNIFFER_PEAR'] = false; - -if (is_file(__DIR__.'/../autoload.php') === false) { - $GLOBALS['PHP_CODESNIFFER_PEAR'] = true; -} - /** * A global util function to help print unit test fixing data. From db037751abef51b84752e110916f70f6e3dd4318 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 7 Nov 2023 00:09:02 +0100 Subject: [PATCH 009/874] README: update URL for downloading the PHAR The GH Pages website has been re-activated under a new domain - phars.phpcodesniffer.com -. The PHARs can now be downloaded from that domain and PHIVE should work as well, though a PR to phar.io will be needed to update the PHIVE alias redirect. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5c71918147..b21da61cfd 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,12 @@ If you're using PHP_CodeSniffer as part of a team, or you're running it on a [CI The easiest way to get started with PHP_CodeSniffer is to download the Phar files for each of the commands: ``` # Download using curl -curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar -curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar +curl -OL https://phars.phpcodesniffer.com/phpcs.phar +curl -OL https://phars.phpcodesniffer.com/phpcbf.phar # Or download using wget -wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar -wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar +wget https://phars.phpcodesniffer.com/phpcs.phar +wget https://phars.phpcodesniffer.com/phpcbf.phar # Then test the downloaded PHARs php phpcs.phar -h From 7b103edd0cd30a5d2cd6361ac20688f49a538a9a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 8 Nov 2023 06:00:06 +0100 Subject: [PATCH 010/874] Changelog for PRs #1, #4 and #5 --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d4f85e60e..f68da9ff92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,17 @@ The file documents changes to the PHP_CodeSniffer project. ## [Unreleased] +[Squizlabs/PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is dead. Long live [PHPCSStandards/PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer)! + +### Breaking Changes +- The `squizlabs/PHP_CodeSniffer` repository has been abandoned. This repository will serve as the continuation of the project. + - Composer users will need to `require-dev` the `phpcsstandards/php_codesniffer` package instead. + - 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 URL from `https://squizlabs.github.io/PHP_CodeSniffer/[phpcs|phpcbf].phar` to `https://phars.phpcodesniffer.com/[phpcs|phpcbf].phar`. + - Installation of PHP_CodeSniffer via PEAR is no longer supported. + - Note: this does not affect the PEAR sniffs. + ### Added - Added support for 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 From 8f43103210f9c8eb0b3f55891ea8fccf0320c6db Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 9 Nov 2023 10:08:04 +0100 Subject: [PATCH 011/874] Tokenizer/PHP: add some extra tests for the `readonly` keyword backfill Includes some minor tweaks to pre-existing tests. --- tests/Core/Tokenizer/BackfillReadonlyTest.inc | 23 +++++++++++------- tests/Core/Tokenizer/BackfillReadonlyTest.php | 24 +++++++++++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.inc b/tests/Core/Tokenizer/BackfillReadonlyTest.inc index eaf0b4b3cc..1e8e59a3b7 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.inc +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.inc @@ -49,9 +49,7 @@ class Foo public ReAdOnLy string $caseInsensitiveProperty; /* testReadonlyConstructorPropertyPromotion */ - public function __construct(private readonly bool $constructorPropertyPromotion) - { - } + public function __construct(private readonly bool $constructorPropertyPromotion) {} /* testReadonlyConstructorPropertyPromotionWithReference */ public function __construct(private ReadOnly bool &$constructorPropertyPromotion) {} @@ -68,8 +66,6 @@ class ClassName { /* testReadonlyUsedAsMethodName */ public function readonly() { - // Do something. - /* testReadonlyUsedAsPropertyName */ $this->readonly = 'foo'; @@ -79,9 +75,10 @@ class ClassName { } /* testReadonlyUsedAsFunctionName */ -function readonly() -{ -} +function readonly() {} + +/* testReadonlyUsedAsFunctionNameWithReturnByRef */ +function &readonly() {} /* testReadonlyUsedAsNamespaceName */ namespace Readonly; @@ -89,6 +86,16 @@ namespace Readonly; namespace My\Readonly\Collection; /* testReadonlyAsFunctionCall */ $var = readonly($a, $b); +/* testReadonlyAsNamespacedFunctionCall */ +$var = My\NS\readonly($a, $b); +/* testReadonlyAsNamespaceRelativeFunctionCall */ +$var = namespace\ReadOnly($a, $b); +/* testReadonlyAsMethodCall */ +$var = $obj->readonly($a, $b); +/* testReadonlyAsNullsafeMethodCall */ +$var = $obj?->readOnly($a, $b); +/* testReadonlyAsStaticMethodCallWithSpace */ +$var = ClassName::readonly ($a, $b); /* testClassConstantFetchWithReadonlyAsConstantName */ echo ClassName::READONLY; diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index eb7ec5d8d7..021dc17db1 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -212,6 +212,10 @@ public function dataNotReadonly() '/* testReadonlyUsedAsFunctionName */', 'readonly', ], + [ + '/* testReadonlyUsedAsFunctionNameWithReturnByRef */', + 'readonly', + ], [ '/* testReadonlyUsedAsNamespaceName */', 'Readonly', @@ -224,6 +228,26 @@ public function dataNotReadonly() '/* testReadonlyAsFunctionCall */', 'readonly', ], + [ + '/* testReadonlyAsNamespacedFunctionCall */', + 'readonly', + ], + [ + '/* testReadonlyAsNamespaceRelativeFunctionCall */', + 'ReadOnly', + ], + [ + '/* testReadonlyAsMethodCall */', + 'readonly', + ], + [ + '/* testReadonlyAsNullsafeMethodCall */', + 'readOnly', + ], + [ + '/* testReadonlyAsStaticMethodCallWithSpace */', + 'readonly', + ], [ '/* testClassConstantFetchWithReadonlyAsConstantName */', 'READONLY', From 1858e46a07679de0940a7649a6c9ce7cacb60dc7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 9 Nov 2023 10:08:41 +0100 Subject: [PATCH 012/874] Fix mis-identification of 'readonly' keyword PHP 8.2 introduces disjunctive normal form types, which use parentheses, which invalidates the previous "special casing" for function/method declarations and calls using the `readonly` keyword. This commit fixes this. Note: this does not (yet) add support for DNF types to the tokenizer or anywhere else in PHPCS, it only fixes the tokenization of `readonly`. Includes additional tests. Ref: https://github.com/php/php-src/commit/08b75395838b4b42a41e3c70684fa6c6b113eee0 Co-authored-by: Dan Wallis --- src/Tokenizers/PHP.php | 91 ++++++++++++++++++- tests/Core/Tokenizer/BackfillReadonlyTest.inc | 36 ++++++++ tests/Core/Tokenizer/BackfillReadonlyTest.php | 42 ++++++++- 3 files changed, 163 insertions(+), 6 deletions(-) diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 42ba192e91..badc9d972b 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -1313,23 +1313,89 @@ protected function tokenize($string) "readonly" keyword for PHP < 8.1 */ - if (PHP_VERSION_ID < 80100 - && $tokenIsArray === true + if ($tokenIsArray === true && strtolower($token[1]) === 'readonly' && isset($this->tstringContexts[$finalTokens[$lastNotEmptyToken]['code']]) === false ) { // Get the next non-whitespace token. for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { if (is_array($tokens[$i]) === false - || $tokens[$i][0] !== T_WHITESPACE + || isset(Util\Tokens::$emptyTokens[$tokens[$i][0]]) === false ) { break; } } + $isReadonlyKeyword = false; + if (isset($tokens[$i]) === false || $tokens[$i] !== '(' ) { + $isReadonlyKeyword = true; + } else if ($tokens[$i] === '(') { + /* + * Skip over tokens which can be used in type declarations. + * At this point, the only token types which need to be taken into consideration + * as potential type declarations are identifier names, T_ARRAY, T_CALLABLE and T_NS_SEPARATOR + * and the union/intersection/dnf parentheses. + */ + + $foundDNFParens = 1; + $foundDNFPipe = 0; + + for (++$i; $i < $numTokens; $i++) { + if (is_array($tokens[$i]) === true) { + $tokenType = $tokens[$i][0]; + } else { + $tokenType = $tokens[$i]; + } + + if (isset(Util\Tokens::$emptyTokens[$tokenType]) === true) { + continue; + } + + if ($tokenType === '|') { + ++$foundDNFPipe; + continue; + } + + if ($tokenType === ')') { + ++$foundDNFParens; + continue; + } + + if ($tokenType === '(') { + ++$foundDNFParens; + continue; + } + + if ($tokenType === T_STRING + || $tokenType === T_NAME_FULLY_QUALIFIED + || $tokenType === T_NAME_RELATIVE + || $tokenType === T_NAME_QUALIFIED + || $tokenType === T_ARRAY + || $tokenType === T_NAMESPACE + || $tokenType === T_NS_SEPARATOR + || $tokenType === T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG // PHP 8.0+. + || $tokenType === '&' // PHP < 8.0. + ) { + continue; + } + + // Reached the next token after. + if (($foundDNFParens % 2) === 0 + && $foundDNFPipe >= 1 + && ($tokenType === T_VARIABLE + || $tokenType === T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG) + ) { + $isReadonlyKeyword = true; + } + + break; + }//end for + }//end if + + if ($isReadonlyKeyword === true) { $finalTokens[$newStackPtr] = [ 'code' => T_READONLY, 'type' => 'T_READONLY', @@ -1337,8 +1403,23 @@ protected function tokenize($string) ]; $newStackPtr++; - continue; - } + if (PHP_CODESNIFFER_VERBOSITY > 1 && $type !== T_READONLY) { + echo "\t\t* token $stackPtr changed from $type to T_READONLY".PHP_EOL; + } + } else { + $finalTokens[$newStackPtr] = [ + 'code' => T_STRING, + 'type' => 'T_STRING', + 'content' => $token[1], + ]; + $newStackPtr++; + + if (PHP_CODESNIFFER_VERBOSITY > 1 && $type !== T_STRING) { + echo "\t\t* token $stackPtr changed from $type to T_STRING".PHP_EOL; + } + }//end if + + continue; }//end if /* diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.inc b/tests/Core/Tokenizer/BackfillReadonlyTest.inc index 1e8e59a3b7..1e66d4643b 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.inc +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.inc @@ -102,6 +102,42 @@ echo ClassName::READONLY; /* testReadonlyUsedAsFunctionCallWithSpaceBetweenKeywordAndParens */ $var = readonly /* comment */ (); +// These test cases are inspired by +// https://github.com/php/php-src/commit/08b75395838b4b42a41e3c70684fa6c6b113eee0 +class ReadonlyWithDisjunctiveNormalForm +{ + /* testReadonlyPropertyDNFTypeUnqualified */ + readonly (B&C)|A $h; + + /* testReadonlyPropertyDNFTypeFullyQualified */ + public readonly (\Fully\Qualified\B&\Full\C)|\Foo\Bar $j; + + /* testReadonlyPropertyDNFTypePartiallyQualified */ + protected readonly (Partially\Qualified&C)|A $l; + + /* testReadonlyPropertyDNFTypeRelativeName */ + private readonly (namespace\Relative&C)|A $n; + + /* testReadonlyPropertyDNFTypeMultipleSets */ + private readonly (A&C)|(B&C)|(C&D) $m; + + /* testReadonlyPropertyDNFTypeWithArray */ + private readonly (B & C)|array $o; + + /* testReadonlyPropertyDNFTypeWithSpacesAndComments */ + private readonly ( B & C /*something*/) | A $q; + + public function __construct( + /* testReadonlyConstructorPropertyPromotionWithDNF */ + private readonly (B&C)|A $b1, + /* testReadonlyConstructorPropertyPromotionWithDNFAndRefence */ + readonly (B&C)|A &$b2, + ) {} + + /* testReadonlyUsedAsMethodNameWithDNFParam */ + public function readonly (A&B $param): void {} +} + /* testParseErrorLiveCoding */ // This must be the last test in the file. readonly diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index 021dc17db1..024220d3bf 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -148,7 +148,39 @@ public function dataReadonly() 'readonly', ], [ - '/* testReadonlyUsedAsFunctionCallWithSpaceBetweenKeywordAndParens */', + '/* testReadonlyPropertyDNFTypeUnqualified */', + 'readonly', + ], + [ + '/* testReadonlyPropertyDNFTypeFullyQualified */', + 'readonly', + ], + [ + '/* testReadonlyPropertyDNFTypePartiallyQualified */', + 'readonly', + ], + [ + '/* testReadonlyPropertyDNFTypeRelativeName */', + 'readonly', + ], + [ + '/* testReadonlyPropertyDNFTypeMultipleSets */', + 'readonly', + ], + [ + '/* testReadonlyPropertyDNFTypeWithArray */', + 'readonly', + ], + [ + '/* testReadonlyPropertyDNFTypeWithSpacesAndComments */', + 'readonly', + ], + [ + '/* testReadonlyConstructorPropertyPromotionWithDNF */', + 'readonly', + ], + [ + '/* testReadonlyConstructorPropertyPromotionWithDNFAndRefence */', 'readonly', ], [ @@ -252,6 +284,14 @@ public function dataNotReadonly() '/* testClassConstantFetchWithReadonlyAsConstantName */', 'READONLY', ], + [ + '/* testReadonlyUsedAsFunctionCallWithSpaceBetweenKeywordAndParens */', + 'readonly', + ], + [ + '/* testReadonlyUsedAsMethodNameWithDNFParam */', + 'readonly', + ], ]; }//end dataNotReadonly() From 1419b6c7d848b1c622bd6e1fd856b3dc5ccd6ed6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 9 Nov 2023 10:30:22 +0100 Subject: [PATCH 013/874] Changelog for upstream #3773 / PR #34 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f68da9ff92..ac65631c91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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 From 520aec2383903e3338759fbb26680a6ea8f0eafd Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 9 Nov 2023 13:29:16 +0100 Subject: [PATCH 014/874] More clean up after removal of PEAR installation support Found another few references which should be removed. --- .gitattributes | 1 - .github/ISSUE_TEMPLATE/bug_report.md | 2 +- bin/phpcbf.bat | 4 +--- bin/phpcs.bat | 4 +--- scripts/build-phar.php | 1 - 5 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.gitattributes b/.gitattributes index 2807459b5e..800d51adec 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,7 +2,6 @@ .gitattributes export-ignore .github/ export-ignore .gitignore export-ignore -package.xml export-ignore phpcs.xml.dist export-ignore phpstan.neon export-ignore phpunit.xml.dist export-ignore diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 5036ca4dcd..fa5c6561bd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -54,7 +54,7 @@ A clear and concise description of what you expected to happen. | PHP version | [e.g., 7.2, 7.4] | PHP_CodeSniffer version | [e.g., 3.5.5, master] | Standard | [e.g., PSR2, PSR12, Squiz, custom] -| Install type | [e.g. Composer (global/local), PHAR, PEAR, git clone, other (please expand)] +| Install type | [e.g. Composer (global/local), PHAR, git clone, other (please expand)] ## Additional context Add any other context about the problem here. diff --git a/bin/phpcbf.bat b/bin/phpcbf.bat index 82e9d561b1..da3b0401a1 100644 --- a/bin/phpcbf.bat +++ b/bin/phpcbf.bat @@ -5,8 +5,6 @@ REM @author Greg Sherwood REM @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) REM @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence -if "%PHP_PEAR_PHP_BIN%" neq "" ( - set PHPBIN=%PHP_PEAR_PHP_BIN% -) else set PHPBIN=php +set PHPBIN=php "%PHPBIN%" "%~dp0\phpcbf" %* diff --git a/bin/phpcs.bat b/bin/phpcs.bat index 7fe506cf98..a95722b4e3 100755 --- a/bin/phpcs.bat +++ b/bin/phpcs.bat @@ -5,8 +5,6 @@ REM @author Greg Sherwood REM @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) REM @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence -if "%PHP_PEAR_PHP_BIN%" neq "" ( - set PHPBIN=%PHP_PEAR_PHP_BIN% -) else set PHPBIN=php +set PHPBIN=php "%PHPBIN%" "%~dp0\phpcs" %* diff --git a/scripts/build-phar.php b/scripts/build-phar.php index 81ee997f19..7bc50a2bca 100644 --- a/scripts/build-phar.php +++ b/scripts/build-phar.php @@ -11,7 +11,6 @@ * @author Greg Sherwood * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer */ use PHP_CodeSniffer\Config; From 4caa4efb2c6b4ba9c73b61207d1bded1bcba0711 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 16 May 2023 17:17:39 +0200 Subject: [PATCH 015/874] CONTRIBUTING: move file to .github directory ... which is nowadays the more common location for this type of file. Includes updating the link in the README file. Ref: https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/setting-guidelines-for-repository-contributors --- CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 .github/pull_request_template.md | 2 +- README.md | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 4afe79d762..7df4a8127d 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -32,7 +32,7 @@ Fixes # ## PR checklist - [ ] I have checked there is no other PR open for the same change. -- [ ] I have read the [Contribution Guidelines](.github/CONTRIBUTING.md). +- [ ] I have read the [Contribution Guidelines](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/.github/CONTRIBUTING.md). - [ ] I grant the project the right to include and distribute the code under the BSD-3-Clause license (and I have the right to grant these rights). - [ ] I have added tests to cover my changes. - [ ] I have verified that the code complies with the projects coding standards. diff --git a/README.md b/README.md index 943c48f47c..788270a1cb 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Bug reports and feature requests can be submitted on the [Github Issue Tracker]( ## Contributing -See [CONTRIBUTING.md](CONTRIBUTING.md) for information. +See [CONTRIBUTING.md](.github/CONTRIBUTING.md) for information. ## Versioning From b5641317fa151ce4caa67214e0fb32e13e1116d9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 17 May 2023 01:10:11 +0200 Subject: [PATCH 016/874] Composer: add scripts for contributors These scripts should make contributing to PHPCS more straight-forward as they document common CI checks and allow for running these locally. --- composer.json | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3a0b91aecf..cfd8b34ee2 100644 --- a/composer.json +++ b/composer.json @@ -48,5 +48,43 @@ "bin": [ "bin/phpcs", "bin/phpcbf" - ] + ], + "scripts": { + "cs": [ + "@php ./bin/phpcs" + ], + "cbf": [ + "@php ./bin/phpcbf" + ], + "test": [ + "Composer\\Config::disableProcessTimeout", + "@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php --no-coverage" + ], + "test-php8": [ + "Composer\\Config::disableProcessTimeout", + "@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php --no-configuration --bootstrap=tests/bootstrap.php --dont-report-useless-tests --no-coverage" + ], + "coverage": [ + "Composer\\Config::disableProcessTimeout", + "@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php -d max_execution_time=0" + ], + "build": [ + "Composer\\Config::disableProcessTimeout", + "@php -d phar.readonly=0 -f ./scripts/build-phar.php" + ], + "check-all": [ + "@cs", + "@test", + "@check-package" + ] + }, + "scripts-descriptions": { + "cs": "Check for code style violations.", + "cbf": "Fix code style violations.", + "test": "Run the unit tests without code coverage.", + "test-php8": "Run the unit tests without code coverage on PHP 8.1 or higher.", + "coverage": "Run the unit tests with code coverage.", + "build": "Create PHAR files for PHPCS and PHPCBF.", + "check-all": "Run all checks (phpcs, tests)." + } } From d464dfb7dba333cbd05e982468069d5817fc07b0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 17 May 2023 01:12:57 +0200 Subject: [PATCH 017/874] CONTRIBUTING: rewrite the contributing guide This is a rewrite of the `CONTRIBUTING.md` file to document expectations and opportunities for contributors. It also answers some common questions previously received from contributors. --- .github/CONTRIBUTING.md | 218 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 212 insertions(+), 6 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5cc7363530..d73fd72ee3 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,13 +1,219 @@ Contributing ------------- -Before you contribute code to PHP\_CodeSniffer, please make sure it conforms to the PHPCS coding standard and that the PHP\_CodeSniffer unit tests still pass. The easiest way to contribute is to work on a checkout of the repository, or your own fork, rather than an installed PEAR version. If you do this, you can run the following commands to check if everything is ready to submit: +Thank you for your interest in contributing to PHP_CodeSniffer! - cd PHP_CodeSniffer - php bin/phpcs -Which should display no coding standard errors. And then: +## Reporting Bugs - phpunit +Please search the [open issues](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues) to see if your issue has been reported already and if so, comment in that issue if you have additional information, instead of opening a new one. -Which should give you no failures or errors. You can ignore any skipped tests as these are for external tools. +Before reporting a bug, you should check what sniff an error is coming from. +Running `phpcs` with the `-s` flag will show the name of the sniff for each error. + +If the error code starts with anything other than `Generic`, `MySource`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend`, the error is likely coming from an external PHP_CodeSniffer standard. +**Please report bugs for externally maintained sniffs to the appropriate repository.** + +Bug reports containing a minimal code sample which can be used to reproduce the issue are highly appreciated as those are most easily actionable. + +:point_right: Reports which only include a _screenshot_ of the code will be closed without hesitation as not actionable. + + +### Reporting Security Issues + +PHP_CodeSniffer is a developer tool and should generally not be used in a production environment. + +Having said that, responsible disclosure of security issues is highly appreciated. +Issues can be reported privately to the maintainers by opening a [Security vulnerability report](https://github.com/PHPCSStandards/PHP_CodeSniffer/security/advisories/new). + + +### Support/Questions About Using PHP_CodeSniffer + +Please read the [documentation in the wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki) before opening an issue with a support question. + +The [discussion forum](https://github.com/PHPCSStandards/PHP_CodeSniffer/discussions) or [StackOverflow](https://stackoverflow.com/questions/tagged/phpcodesniffer) are the appropriate places for support questions. + + +## Contributing Without Writing Code + +### Issue Triage + +We welcome issue triage. + +Issue triage is the action of verifying a reported issue is reproducible and is actually an issue. +This includes checking whether the issue is something which should be fixed in **_this_** repository. + +To find issues which need triage, look for [issues without labels](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) or issues with the ["Status: triage"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20triage) label. + +#### Typical issue triage tasks: +* Verify whether the issue is reproducible with the given information. +* Ask for additional information if it is not. +* If you find the issue is reported to the wrong repo, ask the reporter to report it to the correct external standard repo and suggest closing the issue. + +Additionally for older issues: +* Check whether an issue still exists or has been fixed in `master` since the issue was initially reported. +* If it has been fixed, document (in a comment) which commit/PR was responsible for fixing the issue and suggest closing the ticket. + + +### Testing Open Pull Requests + +Testing pull requests to verify they fix the issue they are supposed to fix without side-effects is an important task. + +To get access to a PHPCS version which includes the patch from a pull request, you can: +* Either use a git clone of the PHP_CodeSniffer repository and check out the PR. +* Or download the PHAR file(s) for the PR, which is available from the [Test workflow](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml) as an artifact of the workflow run. + The PHAR files can be found on the summary page of the test workflow run for the PR. + If the workflow has not been run (yet), the PHAR artifact may not be available (yet). + +#### Typical test tasks: +* Verify that the patch solves the originally reported problem. +* Verify that the tests added in the PR fail without the fix and pass with the fix. +* For a fix for false negatives: verify that the correct error message(s) are thrown by the patched code. +* Run the patched PHPCS version against real codebases to see if the fix creates any side-effects (new false positives/false negatives). + + +### Writing sniff documentation + +Sniffs in PHP_CodeSniffer should preferably be accompanied by documentation. There is currently still a lot of documentation missing. + +Sniff documentation is provided via XML files in the standard's `Docs` directory and is available to end-users via the command-line and/or can be compiled into an HTML or Markdown file. + +To see an example of some of the available documentation, run: +```bash +phpcs --standard=PSR12 --generator=Text +``` + +Pull requests to update existing documentation, or to add documentation for sniffs which currently don't have any, are welcome. + +For the documentation to be recognized, the naming conventions have to be followed. + +For example, for the sniff named `Generic.NamingConventions.ConstructorName`: +* The sniff lives in the `src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php` file. +* The associated documentation should be in a `src/Standards/Generic/Docs/NamingConventions/ConstructorNameStandard.xml` file. + +The XML files consist of several parts: +* The `title` attribute in the `` tag should generally reflect the name of the sniff. +* Each XML file can contain multiple `` blocks. +* Each `` block can be accompanied by one or more `` blocks. +* Each code comparison block should have two `` blocks, the first one showing "valid" code, the second one showing "invalid" code. + +Some guidelines to get you started: +* Keep it as simple as possible. +* When a sniff shows multiple different errors/warnings, it is recommended to have a separate `` block for each error/warning. +* The title of a "good" code sample (on the left) should start with `Valid:`. +* The title of a "bad" code sample (on the right) should start with `Invalid:`. +* Don't use example code which can be traced back to a specific project. +* Each line within the code sample should be max 48 characters. +* Code used in code samples should be valid PHP. +* To highlight the "good" and the "bad" bits in the code examples, surround those bits with ` ...` tags. + These will be removed automatically when using the text generator, but ensure highlighting of the code in Markdown/HTML. +* The indentation in the XML file should use spaces only. Four spaces for each indent. + +Make sure to test the documentation before submitting a PR by running: +```bash +phpcs --standard=StandardName --generator=Text --sniffs=StandardName.Category.SniffName +``` + +Kind request to add only one new XML file per PR to make the PR easier to review. + + +## Contributing With Code + +### Requesting/Submitting New Features + +Ideally, start by [opening an issue](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/new/choose) to check whether the feature is something which is suitable to be included in PHP_CodeSniffer. + +It's possible that a feature may be rejected at an early stage, and it's better to find out before you write the code. + +It is also good to discuss potential different implementation options ahead of time and get guidance for the preferred option from the maintainers. + +Note: There may be an issue or PR open already. If so, please join the discussion in that issue or PR instead of opening a duplicate issue/PR. + +> Please note: Auto-fixers will only be accepted for "non-risky" sniffs. +> If a fixer could cause parse errors or a change in the behaviour of the scanned code, the fixer will **NOT** be accepted in PHP_CodeSniffer and may be better suited to an external standard. + + +### Getting started + +1. Fork/clone the repository. +2. Run `composer install`. + When installing on PHP >= 8.0, use `composer install --ignore-platform-req=php+`. +3. Create a new branch off the `master` branch to hold your patch. + If there is an open issue associated with your patch, including the issue number in the branch name is good practice. + + +### While working on a patch + +Please make sure your code conforms to the PHPCS coding standard, is covered by tests and that all the PHP_CodeSniffer unit tests still pass. + +Also, please make sure your code is compatible with the PHP_CodeSniffer minimum supported PHP version, PHP 5.4. + +To help you with this, a number of convenience scripts are available: +* `composer check-all` will run the `cs` + `test` checks in one go. +* `composer cs` will check for code style violations. +* `composer cbf` will run the autofixers for code style violations. +* `composer test` will run the unit tests (only works when on PHP < 8.1). +* `composer test-php8` will run the unit tests when you are working on PHP 8.1+. + Please note that using a `phpunit.xml` overload config file will not work with this script! +* `composer coverage` will run the unit tests with code coverage (only works when on PHP < 8.1). + Note: you may want to use a custom `phpunit.xml` overload config file to tell PHPUnit where to place an HTML report. + Alternative run it like so: `composer coverage -- --coverage-html /path/to/report-dir/` to specify the location for the HTML report on the command line. +* `composer build` will build the phpcs.phar and phpcbf.phar files. + +N.B.: You can ignore any skipped tests as these are for external tools. + + +### Writing tests + +Tests for the PHP_CodeSniffer engine can be found in the `tests/Core` directory. +Tests for individual sniffs can be found in the `src/Standards/[StandardName]/Tests/[Category]/` directory. + +Tests will, in most cases, consist of a set of related files and follow strict naming conventions. + +For example, for the sniff named `Generic.NamingConventions.ConstructorName`: +* The sniff lives in the `src/Standards/Generic/Sniffs/NamingConventions/` directory. +* The tests live in the `src/Standards/Generic/Tests/NamingConventions/` directory. +* The tests consist of two files: + - `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc` which is the test _case_ file containing code for the sniff to analyse. + - `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php` which is the test file, containing two methods, `getErrorList()` and `getWarningList()`, which should each return an array with as the keys the line number in the test _case_ file and as the values the number of errors or warnings which are expected on each line. + Only lines on which errors/warnings are expected need to be included in the lists. All other lines will automatically be set to expect no errors and no warnings. + +#### Multiple test case files + +At times, one test _case_ file is not enough, for instance when the sniff needs to behave differently depending on whether or code is namespaced or not, or when a sniff needs to check something at the top of a file. + +The test framework allows for multiple test _case_ files. +In that case, the files should be numbered and the number should be placed between the file name and the extension. + +So for the above example, the `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc` would be renamed to `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.1.inc` and additional test case files should be numbered sequentially like `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.2.inc`, `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.3.inc` etc. + +The `getErrorList()` and the `getWarningList()` methods will receive an optional `$testFile=''` parameter with the file name of the file being scanned - `ConstructorNameUnitTest.2.inc` - and should return the appropriate array for each file. + +#### Testing fixers + +If a sniff contains errors/warnings which can be auto-fixed, these fixers should also be tested. + +This is done by adding an additional test _case_ file with an extra `.fixed` extension for each test _case_ file which expects fixes. + +For example, if the above `Generic.NamingConventions.ConstructorName` would contain an auto-fixer, there should be an additional `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc.fixed` file containing the code as it is expected to be after the fixer has run. + +The test framework will compare the actual fixes made with the expected fixes and will fail the tests if these don't match. + +### Submitting your pull request + +Some guidelines for submitting pull requests (PRs) and improving the chance that your PR will be merged: +* Please keep your PR as small as possible, but no smaller than that. + If your change is complex, make sure you add a proper commit message explaining what you have done and why. +* Please clean up your branch before pulling your PR. + Small PRs using atomic, descriptive commits are hugely appreciated as it will make reviewing your changes easier for the maintainers. +* Only open your PR when you've finished work on it and you are confident that it is ready for review. +* Please make sure your pull request passes all continuous integration checks. + PRs which are failing their CI checks will likely be ignored by the maintainers or closed. +* Please respond to PR reviews in a timely manner. + +Your time is valuable and we appreciate your willingness to spend it on this project. +However, the maintainers time is also valuable and often, more scarce, so please be considerate of that. + +## Licensing + +By contributing code to this repository, you agree to license your code for use under the [BSD-3-Clause license](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt). From ea0d287e271c9a647140ba82d554f157a299e19d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 9 Nov 2023 13:30:28 +0100 Subject: [PATCH 018/874] Issue/PR templates: add feature request template + minor other tweaks --- .github/ISSUE_TEMPLATE/bug_report.md | 6 +++--- .github/ISSUE_TEMPLATE/feature_request.md | 24 +++++++++++++++++++++++ .github/pull_request_template.md | 11 +++++++---- 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index fa5c6561bd..e474c86857 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -30,7 +30,7 @@ echo "A short code snippet that can be used to reproduce the bug. Do NOT paste s ```xml - If you are using a custom ruleset, please enter it here. + If you are using a custom ruleset, please enter the relevant part here. ``` @@ -51,8 +51,8 @@ A clear and concise description of what you expected to happen. | | | |-|-| | Operating System | [e.g., Windows 10, MacOS 10.15] -| PHP version | [e.g., 7.2, 7.4] -| PHP_CodeSniffer version | [e.g., 3.5.5, master] +| PHP version | [e.g., 7.2, 8.1] +| PHP_CodeSniffer version | [e.g., 3.7.2, master] | Standard | [e.g., PSR2, PSR12, Squiz, custom] | Install type | [e.g. Composer (global/local), PHAR, git clone, other (please expand)] diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000000..366fc32646 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,24 @@ +--- +name: Feature request +about: I have a suggestion (and may want to implement it). +title: '' +labels: ['Status: triage', 'Type: enhancement'] +assignees: '' + +--- + +## Is your feature request related to a problem? + + +## Describe the solution you'd like + + +## Additional context (optional) + + +- [ ] I intend to create a pull request to implement this feature. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 7df4a8127d..8bbef3d7b5 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,7 @@ +--- +labels: ['Status: triage'] +--- + -### Suggested changelog entry +## Suggested changelog entry -### Related issues/external references +## Related issues/external references Fixes # @@ -37,7 +41,6 @@ Fixes # - [ ] I have added tests to cover my changes. - [ ] I have verified that the code complies with the projects coding standards. - [ ] [Required for new sniffs] I have added XML documentation for the sniff. -- [ ] [Required for new files] I have added any new files to the `package.xml` file. From 9c6a1a1ebcfe0e92074d7955e89ee2fc9fd1044b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 9 Nov 2023 14:06:46 +0100 Subject: [PATCH 019/874] README: various tweaks * Add some additional badges. * Wrap the badges in a div which will hide them for screenreaders. * Add a note at the top of the README about the continuation of the project. --- README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 788270a1cb..3578aa277b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,25 @@ -## About +PHP_CodeSniffer +===================================================== -PHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second `phpcbf` script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. + + +> [!NOTE] +> This package is the continuation of the [PHP_CodeSniffer package which was created by Squizlabs](https://github.com/squizlabs/PHP_CodeSniffer) and has been abandoned. + +## About + +PHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second `phpcbf` script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. + ## Requirements From e9d5c0e429b7777c8f51ed515242e38bc36d377c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 9 Nov 2023 16:23:29 +0100 Subject: [PATCH 020/874] GH Actions: rename label management workflow ... to allow for additional label management workflows. --- .../workflows/{manage-labels.yml => label-remove-outdated.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{manage-labels.yml => label-remove-outdated.yml} (100%) diff --git a/.github/workflows/manage-labels.yml b/.github/workflows/label-remove-outdated.yml similarity index 100% rename from .github/workflows/manage-labels.yml rename to .github/workflows/label-remove-outdated.yml From c11abf40d81e03d337c06d23ba7736ea55dcd305 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 9 Nov 2023 16:24:38 +0100 Subject: [PATCH 021/874] GH Actions: add workflow to label PRs which are in a conflict state Came across this action and sounded like an interesting and helpful one. Let's give it a try. Ref: https://github.com/mschilde/auto-label-merge-conflicts --- .github/workflows/label-merge-conflicts.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/label-merge-conflicts.yml diff --git a/.github/workflows/label-merge-conflicts.yml b/.github/workflows/label-merge-conflicts.yml new file mode 100644 index 0000000000..28f0ecf8d2 --- /dev/null +++ b/.github/workflows/label-merge-conflicts.yml @@ -0,0 +1,19 @@ +name: Check PRs for merge conflicts + +on: + push: + branches: + - master + +jobs: + check-prs: + runs-on: ubuntu-latest + if: github.repository_owner == 'PHPCSStandards' + + name: Check PRs for merge conflicts + + steps: + - uses: mschilde/auto-label-merge-conflicts@master + with: + CONFLICT_LABEL_NAME: "Status: has merge conflict" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0c6e0b42c1d79afd97e98add4f8aae106eb79c2a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 9 Nov 2023 16:26:54 +0100 Subject: [PATCH 022/874] GH Actions: auto-label new PRs Turns out the PR template does not allow for frontmatter which would set a label on new PRs. As I'd prefer all new (non-draft) PRs to be marked with `Status: triage`, I went looking for an action which could do this and ended up with an action which can do a lot more. Again, let's give it a try and see how it goes. Ref: https://github.com/srvaroa/labeler --- .github/labeler.yml | 84 +++++++++++++++++++++++++++++ .github/pull_request_template.md | 4 -- .github/workflows/label-new-prs.yml | 17 ++++++ 3 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/label-new-prs.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000000..e02a50f167 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,84 @@ +version: 1 +appendOnly: true +labels: +- label: "Status: triage" + draft: False + author-can-merge: False + +- label: "Core Component: Config & Ruleset & CLI options" + draft: False + files: + - "src/Config.php$" +- label: "Core Component: Config & Ruleset & CLI options" + draft: False + files: + - "src/Ruleset.php$" +- label: "Core Component: File" + draft: False + files: + - "src/Files/.*" +- label: "Core Component: Fixer" + draft: False + files: + - "src/Fixer.php$" +- label: "Core Component: Reports" + draft: False + files: + - "src/Reports/.*" +- label: "Core Component: Tokenizer" + draft: False + files: + - "src/Tokenizers/.*" +- label: "Core Component: Utils" + draft: False + files: + - "src/Util/.*" + +- label: "Focus: Comments/Docblocks" + draft: False + files: + - "src/Standards/.*/Sniffs/Commenting/" +- label: "Focus: Fixer Conflicts" + draft: False + body: ".* fixer conflict.*" + +- label: "Standard: Generic" + draft: False + files: + - "src/Standards/Generic/.*" +- label: "Standard: MySource" + draft: False + files: + - "src/Standards/MySource/.*" +- label: "Standard: PEAR" + draft: False + files: + - "src/Standards/PEAR/.*" +- label: "Standard: PSR1" + draft: False + files: + - "src/Standards/PSR1/.*" +- label: "Standard: PSR2" + draft: False + files: + - "src/Standards/PSR2/.*" +- label: "Standard: PSR12" + draft: False + files: + - "src/Standards/PSR12/.*" +- label: "Standard: Squiz" + draft: False + files: + - "src/Standards/Squiz/.*" +- label: "Standard: Zend" + draft: False + files: + - "src/Standards/Zend/.*" + +- label: "Type: bug" + draft: False + body: ".* bug .*" +- label: "Type: documentation" + draft: False + files: + - "/Docs/[A-Za-z0-9-]*/.*Standard.xml$" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 8bbef3d7b5..49fe6a5cc9 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,7 +1,3 @@ ---- -labels: ['Status: triage'] ---- - + + error + + tests/bootstrap\.php From ab86e071b02c68551420ae2a15b7ec36bede406f Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Mon, 4 Dec 2023 16:56:42 +0100 Subject: [PATCH 085/874] Add Bash syntax highlighting to `README.md` Verified exhaustiveness thanks to: ```bash grep -r '```' ``` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a2c865c4c..9afd051b16 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ If you're using PHP_CodeSniffer as part of a team, or you're running it on a [CI ## Installation The easiest way to get started with PHP_CodeSniffer is to download the Phar files for each of the commands: -``` +```bash # Download using curl curl -OL https://phars.phpcodesniffer.com/phpcs.phar curl -OL https://phars.phpcodesniffer.com/phpcbf.phar From f4ac65468cfb563feac476e6fbfe2cc018d40599 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 11 Aug 2023 02:17:40 +0200 Subject: [PATCH 086/874] PSR2/PSR12/ControlStructureSpacing: don't listen for `T_ELSE` No functional changes. These sniffs only concerns themselves with control structures which take parentheses, so listening for `T_ELSE` is unnecessary as the sniffs will never do anything for that token (they each bow out on no 'parenthesis_opener'/'parenthesis_closer' found). --- .../Sniffs/ControlStructures/ControlStructureSpacingSniff.php | 1 - .../Sniffs/ControlStructures/ControlStructureSpacingSniff.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index 5f54aa7cc5..499f3a29d1 100644 --- a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -38,7 +38,6 @@ public function register() T_FOREACH, T_FOR, T_SWITCH, - T_ELSE, T_ELSEIF, T_CATCH, T_MATCH, diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index 9382524fee..4a32091cdf 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -44,7 +44,6 @@ public function register() T_FOREACH, T_FOR, T_SWITCH, - T_ELSE, T_ELSEIF, T_CATCH, T_MATCH, From c248a92ae11e79325a1509a8eb604004d8d9cd83 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Dec 2023 17:15:43 +0100 Subject: [PATCH 087/874] Changelog for #121 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37186bdbb5..432e379a98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch - Generic/SpreadOperatorSpacingAfter: minor message readability improvement - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch +- Improved README syntax highlighting + - Thanks to Benjamin Loison (@Benjamin-Loison) for the patch ### Removed - Removed support for installing via PEAR @@ -142,6 +144,8 @@ The file documents changes to the PHP_CodeSniffer project. - Fixed bug #3906 : Tokenizer/CSS: fixed a bug related to the unsupported slash comment syntax - Thanks to Dan Wallis (@fredden) for the patch +Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) for reviewing quite a few of the PRs for this release. + ## [3.7.2] - 2023-02-23 ### Changed - Newer versions of Composer will now suggest installing PHPCS using require-dev instead of require From 7ed1591071520e95d8ca977def94be917149264e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 14 Jul 2023 09:15:56 +0200 Subject: [PATCH 088/874] Tokenizer::$eolChar: change default value ... to be a more logical one. The property is supposed to be a `string`, so having an array as a default value is confusing. --- src/Tokenizers/Tokenizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tokenizers/Tokenizer.php b/src/Tokenizers/Tokenizer.php index 53407a2da0..9ef4a81609 100644 --- a/src/Tokenizers/Tokenizer.php +++ b/src/Tokenizers/Tokenizer.php @@ -27,7 +27,7 @@ abstract class Tokenizer * * @var string */ - protected $eolChar = []; + protected $eolChar = ''; /** * A token-based representation of the content. From 2dfd91282664f8b2d881fc1fa11ef00ca19a3dd8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 15 Apr 2023 09:15:45 +0200 Subject: [PATCH 089/874] File: improve documentation ... of the `getMethodParameters()`, `getMethodProperties()`, `getMemberProperties()` and the `getClassProperties()` methods. Ensuring that the return value format documentation is consistent and correct regarding the type and availability of each index in the returned arrays. --- src/Files/File.php | 92 +++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/Files/File.php b/src/Files/File.php index 50a763dce0..cc3e32f906 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -1303,25 +1303,25 @@ public function getDeclarationName($stackPtr) * * * 0 => array( - * 'name' => '$var', // The variable name. - * 'token' => integer, // The stack pointer to the variable name. - * 'content' => string, // The full content of the variable definition. - * 'has_attributes' => boolean, // Does the parameter have one or more attributes attached ? - * 'pass_by_reference' => boolean, // Is the variable passed by reference? - * 'reference_token' => integer, // The stack pointer to the reference operator - * // or FALSE if the param is not passed by reference. - * 'variable_length' => boolean, // Is the param of variable length through use of `...` ? - * 'variadic_token' => integer, // The stack pointer to the ... operator - * // or FALSE if the param is not variable length. - * 'type_hint' => string, // The type hint for the variable. - * 'type_hint_token' => integer, // The stack pointer to the start of the type hint - * // or FALSE if there is no type hint. - * 'type_hint_end_token' => integer, // The stack pointer to the end of the type hint - * // or FALSE if there is no type hint. - * 'nullable_type' => boolean, // TRUE if the type is preceded by the nullability - * // operator. - * 'comma_token' => integer, // The stack pointer to the comma after the param - * // or FALSE if this is the last param. + * 'name' => string, // The variable name. + * 'token' => integer, // The stack pointer to the variable name. + * 'content' => string, // The full content of the variable definition. + * 'has_attributes' => boolean, // Does the parameter have one or more attributes attached ? + * 'pass_by_reference' => boolean, // Is the variable passed by reference? + * 'reference_token' => integer|false, // The stack pointer to the reference operator + * // or FALSE if the param is not passed by reference. + * 'variable_length' => boolean, // Is the param of variable length through use of `...` ? + * 'variadic_token' => integer|false, // The stack pointer to the ... operator + * // or FALSE if the param is not variable length. + * 'type_hint' => string, // The type hint for the variable. + * 'type_hint_token' => integer|false, // The stack pointer to the start of the type hint + * // or FALSE if there is no type hint. + * 'type_hint_end_token' => integer|false, // The stack pointer to the end of the type hint + * // or FALSE if there is no type hint. + * 'nullable_type' => boolean, // TRUE if the type is preceded by the nullability + * // operator. + * 'comma_token' => integer|false, // The stack pointer to the comma after the param + * // or FALSE if this is the last param. * ) * * @@ -1614,19 +1614,19 @@ public function getMethodParameters($stackPtr) * The format of the return value is: * * array( - * 'scope' => 'public', // Public, private, or protected - * 'scope_specified' => true, // TRUE if the scope keyword was found. - * 'return_type' => '', // The return type of the method. - * 'return_type_token' => integer, // The stack pointer to the start of the return type - * // or FALSE if there is no return type. - * 'return_type_end_token' => integer, // The stack pointer to the end of the return type - * // or FALSE if there is no return type. - * 'nullable_return_type' => false, // TRUE if the return type is preceded by the - * // nullability operator. - * 'is_abstract' => false, // TRUE if the abstract keyword was found. - * 'is_final' => false, // TRUE if the final keyword was found. - * 'is_static' => false, // TRUE if the static keyword was found. - * 'has_body' => false, // TRUE if the method has a body + * 'scope' => string, // Public, private, or protected + * 'scope_specified' => boolean, // TRUE if the scope keyword was found. + * 'return_type' => string, // The return type of the method. + * 'return_type_token' => integer|false, // The stack pointer to the start of the return type + * // or FALSE if there is no return type. + * 'return_type_end_token' => integer|false, // The stack pointer to the end of the return type + * // or FALSE if there is no return type. + * 'nullable_return_type' => boolean, // TRUE if the return type is preceded by the + * // nullability operator. + * 'is_abstract' => boolean, // TRUE if the abstract keyword was found. + * 'is_final' => boolean, // TRUE if the final keyword was found. + * 'is_static' => boolean, // TRUE if the static keyword was found. + * 'has_body' => boolean, // TRUE if the method has a body * ); * * @@ -1789,17 +1789,17 @@ public function getMethodProperties($stackPtr) * * * array( - * 'scope' => string, // Public, private, or protected. - * 'scope_specified' => boolean, // TRUE if the scope was explicitly specified. - * 'is_static' => boolean, // TRUE if the static keyword was found. - * 'is_readonly' => boolean, // TRUE if the readonly keyword was found. - * 'type' => string, // The type of the var (empty if no type specified). - * 'type_token' => integer, // The stack pointer to the start of the type - * // or FALSE if there is no type. - * 'type_end_token' => integer, // The stack pointer to the end of the type - * // or FALSE if there is no type. - * 'nullable_type' => boolean, // TRUE if the type is preceded by the nullability - * // operator. + * 'scope' => string, // Public, private, or protected. + * 'scope_specified' => boolean, // TRUE if the scope was explicitly specified. + * 'is_static' => boolean, // TRUE if the static keyword was found. + * 'is_readonly' => boolean, // TRUE if the readonly keyword was found. + * 'type' => string, // The type of the var (empty if no type specified). + * 'type_token' => integer|false, // The stack pointer to the start of the type + * // or FALSE if there is no type. + * 'type_end_token' => integer|false, // The stack pointer to the end of the type + * // or FALSE if there is no type. + * 'nullable_type' => boolean, // TRUE if the type is preceded by the nullability + * // operator. * ); * * @@ -1977,9 +1977,9 @@ public function getMemberProperties($stackPtr) * The format of the return value is: * * array( - * 'is_abstract' => false, // true if the abstract keyword was found. - * 'is_final' => false, // true if the final keyword was found. - * 'is_readonly' => false, // true if the readonly keyword was found. + * 'is_abstract' => boolean, // TRUE if the abstract keyword was found. + * 'is_final' => boolean, // TRUE if the final keyword was found. + * 'is_readonly' => boolean, // TRUE if the readonly keyword was found. * ); * * From f199b60157fae206d5a905226a3fe4b65cc18d6f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 24 Apr 2023 21:20:03 +0200 Subject: [PATCH 090/874] Docs: various textual tweaks ... picked up along the way. --- src/Files/File.php | 2 +- src/Reports/Info.php | 2 +- tests/Core/Config/ReportWidthTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Files/File.php b/src/Files/File.php index cc3e32f906..f0c2e747a4 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -755,7 +755,7 @@ public function addErrorOnLine( /** - * Records a warning against a specific token in the file. + * Records a warning against a specific line in the file. * * @param string $warning The error message. * @param int $line The line on which the warning occurred. diff --git a/src/Reports/Info.php b/src/Reports/Info.php index e263199be9..4039056169 100644 --- a/src/Reports/Info.php +++ b/src/Reports/Info.php @@ -45,7 +45,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, /** - * Prints the source of all errors and warnings. + * Prints the recorded metrics. * * @param string $cachedData Any partial report data that was returned from * generateFileReport during the run. diff --git a/tests/Core/Config/ReportWidthTest.php b/tests/Core/Config/ReportWidthTest.php index 65d7bb03ee..275a70cab1 100644 --- a/tests/Core/Config/ReportWidthTest.php +++ b/tests/Core/Config/ReportWidthTest.php @@ -56,7 +56,7 @@ public function resetConfig() /** * Reset the static properties in the Config class to their true defaults to prevent this class - * from unfluencing other tests. + * from influencing other tests. * * @afterClass * @@ -287,7 +287,7 @@ public function dataReportWidthInputHandling() * Helper function to set a static property on the Config class. * * @param string $name The name of the property to set. - * @param mixed $value The value to set the propert to. + * @param mixed $value The value to set the property to. * * @return void */ From 471d44f4d02f0e5b04f5f164868eefc575d7c8e2 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 28 Oct 2023 18:56:19 +0200 Subject: [PATCH 091/874] Docs: fix various incorrect type annotations Includes a number of fixes previously pulled in (closed) PR 3703. Co-authored-by: Andrew Dawes --- CHANGELOG.md | 2 ++ src/Config.php | 2 +- src/Files/FileList.php | 2 +- src/Fixer.php | 4 ++-- src/Reports/Hgblame.php | 2 +- src/Reports/Notifysend.php | 2 +- src/Ruleset.php | 2 +- src/Runner.php | 6 +++--- src/Sniffs/AbstractPatternSniff.php | 4 ++-- src/Sniffs/AbstractScopeSniff.php | 2 +- .../Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php | 2 +- .../Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php | 4 ++-- .../ControlStructures/InlineControlStructureSniff.php | 2 +- src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php | 4 ++-- src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php | 2 +- .../Functions/OpeningFunctionBraceKernighanRitchieSniff.php | 2 +- .../Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php | 2 +- .../Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php | 2 +- .../Generic/Sniffs/VersionControl/GitMergeConflictSniff.php | 2 +- .../Sniffs/VersionControl/SubversionPropertiesSniff.php | 4 ++-- .../Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php | 2 +- .../Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php | 2 +- .../Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php | 2 +- .../Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php | 2 +- src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php | 2 +- src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php | 2 +- src/Standards/Generic/Tests/Debug/ESLintUnitTest.php | 2 +- src/Standards/Generic/Tests/Debug/JSHintUnitTest.php | 2 +- .../Generic/Tests/Files/ExecutableFileUnitTest.php | 2 +- .../Tests/VersionControl/SubversionPropertiesUnitTest.php | 2 +- .../MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php | 2 +- .../MySource/Sniffs/Channels/IncludeOwnSystemSniff.php | 2 +- .../MySource/Sniffs/Channels/IncludeSystemSniff.php | 4 ++-- src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php | 2 +- src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php | 2 +- src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php | 4 ++-- src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php | 2 +- .../Sniffs/ControlStructures/SwitchDeclarationSniff.php | 2 +- src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php | 2 +- .../PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php | 2 +- .../Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php | 2 +- .../Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php | 2 +- .../Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php | 2 +- src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php | 2 +- src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php | 2 +- .../Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php | 4 ++-- .../Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php | 2 +- .../Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php | 2 +- .../Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php | 2 +- .../Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php | 2 +- src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php | 2 +- src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php | 2 +- src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php | 2 +- src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php | 2 +- .../Squiz/Sniffs/Commenting/FunctionCommentSniff.php | 2 +- .../Squiz/Sniffs/Commenting/InlineCommentSniff.php | 2 +- .../Sniffs/Functions/MultiLineFunctionDeclarationSniff.php | 2 +- .../Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php | 2 +- .../Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php | 2 +- src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php | 2 +- src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php | 2 +- src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php | 2 +- src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php | 2 +- src/Tokenizers/JS.php | 6 +++--- src/Tokenizers/PHP.php | 2 +- src/Tokenizers/Tokenizer.php | 2 +- src/Util/Cache.php | 2 +- src/Util/Common.php | 4 ++-- 70 files changed, 84 insertions(+), 82 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 432e379a98..bb37bfa86d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,6 +91,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch - Improved README syntax highlighting - Thanks to Benjamin Loison (@Benjamin-Loison) for the patch +- Various documentation improvements + - Thanks to Andrew Dawes (@AndrewDawes) and Juliette Reinders Folmer (@jrfnl) for the patches ### Removed - Removed support for installing via PEAR diff --git a/src/Config.php b/src/Config.php index a13f966a73..55c7598f2b 100644 --- a/src/Config.php +++ b/src/Config.php @@ -27,7 +27,7 @@ * 2: ruleset and file parsing output * 3: sniff execution output * @property bool $interactive Enable interactive checking mode. - * @property bool $parallel Check files in parallel. + * @property int $parallel Check files in parallel. * @property bool $cache Enable the use of the file cache. * @property bool $cacheFile A file where the cache data should be written * @property bool $colors Display colours in output. diff --git a/src/Files/FileList.php b/src/Files/FileList.php index bf98385a35..13357ecdef 100644 --- a/src/Files/FileList.php +++ b/src/Files/FileList.php @@ -199,7 +199,7 @@ public function current() /** * Return the file path of the current file being processed. * - * @return void + * @return string|null Path name or `null` when the end of the iterator has been reached. */ #[ReturnTypeWillChange] public function key() diff --git a/src/Fixer.php b/src/Fixer.php index 2ff09576a7..b54dde94b6 100644 --- a/src/Fixer.php +++ b/src/Fixer.php @@ -70,7 +70,7 @@ class Fixer * If a token is being "fixed" back to its last value, the fix is * probably conflicting with another. * - * @var array + * @var array> */ private $oldTokenValues = []; @@ -349,7 +349,7 @@ public function getTokenContent($stackPtr) /** * Start recording actions for a changeset. * - * @return void + * @return void|false */ public function beginChangeset() { diff --git a/src/Reports/Hgblame.php b/src/Reports/Hgblame.php index 3b4bbcfa1b..2d98c46db6 100644 --- a/src/Reports/Hgblame.php +++ b/src/Reports/Hgblame.php @@ -28,7 +28,7 @@ class Hgblame extends VersionControl * * @param string $line Line to parse. * - * @return mixed string or false if impossible to recover. + * @return string|false String or FALSE if impossible to recover. */ protected function getAuthor($line) { diff --git a/src/Reports/Notifysend.php b/src/Reports/Notifysend.php index 7f5a7e4181..1c296958c2 100644 --- a/src/Reports/Notifysend.php +++ b/src/Reports/Notifysend.php @@ -154,7 +154,7 @@ public function generate( * @param int $totalErrors Total number of errors found during the run. * @param int $totalWarnings Total number of warnings found during the run. * - * @return string Error message or NULL if no error/warning found. + * @return string|null Error message or NULL if no error/warning found. */ protected function generateMessage($checkedFiles, $totalErrors, $totalWarnings) { diff --git a/src/Ruleset.php b/src/Ruleset.php index bd0527dcb5..901fb8e09b 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -47,7 +47,7 @@ class Ruleset * The key is the regular expression and the value is the type * of ignore pattern (absolute or relative). * - * @var array + * @var array */ public $ignorePatterns = []; diff --git a/src/Runner.php b/src/Runner.php index 0f57243c23..107da1816d 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -49,7 +49,7 @@ class Runner /** * Run the PHPCS script. * - * @return array + * @return int */ public function runPHPCS() { @@ -151,7 +151,7 @@ public function runPHPCS() /** * Run the PHPCBF script. * - * @return array + * @return int */ public function runPHPCBF() { @@ -595,7 +595,7 @@ private function run() * @param string $file The path of the file that raised the error. * @param int $line The line number the error was raised at. * - * @return void + * @return bool * @throws \PHP_CodeSniffer\Exceptions\RuntimeException */ public function handleErrors($code, $message, $file, $line) diff --git a/src/Sniffs/AbstractPatternSniff.php b/src/Sniffs/AbstractPatternSniff.php index 8dde80414a..d4135be057 100644 --- a/src/Sniffs/AbstractPatternSniff.php +++ b/src/Sniffs/AbstractPatternSniff.php @@ -250,7 +250,7 @@ final public function process(File $phpcsFile, $stackPtr) * @param int $stackPtr The position in the tokens stack where * the listening token type was found. * - * @return array + * @return array|false */ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr) { @@ -850,7 +850,7 @@ private function parse($pattern) * Creates a skip pattern. * * @param string $pattern The pattern being parsed. - * @param string $from The token content that the skip pattern starts from. + * @param int $from The token position that the skip pattern starts from. * * @return array The pattern step. * @see createTokenPattern() diff --git a/src/Sniffs/AbstractScopeSniff.php b/src/Sniffs/AbstractScopeSniff.php index ef443d20df..ce38ba0c4b 100644 --- a/src/Sniffs/AbstractScopeSniff.php +++ b/src/Sniffs/AbstractScopeSniff.php @@ -42,7 +42,7 @@ abstract class AbstractScopeSniff implements Sniff /** * The type of scope opener tokens that this test wishes to listen to. * - * @var string + * @var array */ private $scopeTokens = []; diff --git a/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php b/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php index ea435321fc..f98277116e 100644 --- a/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php @@ -19,7 +19,7 @@ class DisallowShortArraySyntaxSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php index d4af5776dc..dad82740a9 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php @@ -100,8 +100,8 @@ public function process(File $phpcsFile, $stackPtr) /** * Get all used variables in the incrementer part of a for statement. * - * @param array(integer=>array) $tokens Array with all code sniffer tokens. - * @param array(string=>mixed) $token Current for loop token + * @param array $tokens Array with all code sniffer tokens. + * @param array $token Current for loop token * * @return string[] List of all found incrementer variables. */ diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php index 5ae358ff6a..0d2ede5bf7 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -62,7 +62,7 @@ public function register() * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * - * @return void + * @return void|int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php index 926fec1555..cacb3a7a7e 100644 --- a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php @@ -22,14 +22,14 @@ class ClosureLinterSniff implements Sniff * * All other error codes will show warnings. * - * @var integer + * @var array */ public $errorCodes = []; /** * A list of error codes to ignore. * - * @var integer + * @var array */ public $ignoreCodes = []; diff --git a/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php b/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php index 99e2e91f4b..af546434fa 100644 --- a/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php +++ b/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php @@ -48,7 +48,7 @@ public function register() * @param int $stackPtr The position of the current token in * the stack passed in $tokens. * - * @return int|null + * @return int|void */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php index ad84392e26..ca26fcd561 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php @@ -34,7 +34,7 @@ class OpeningFunctionBraceKernighanRitchieSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return void + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php index 8451f80a6e..e3e852ddd8 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php @@ -28,7 +28,7 @@ class DisallowAlternativePHPTagsSniff implements Sniff /** * The current PHP version. * - * @var integer + * @var integer|string|null */ private $phpVersion = null; diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php index 433ef5cf7f..b7dc75ce6b 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php @@ -46,7 +46,7 @@ public function register() * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return void + * @return void|int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php index 34c825fbff..c2254b34fa 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php @@ -64,7 +64,7 @@ public function register() * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * - * @return void + * @return void|int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php b/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php index 144a0001b2..ffc1ff6daf 100644 --- a/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php @@ -48,7 +48,7 @@ public function register() * @param int $stackPtr The position of the current token in * the stack passed in $tokens. * - * @return void + * @return int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php index 79035abe5d..03028cb7b1 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php @@ -49,7 +49,7 @@ public function register() * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * - * @return void + * @return int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php index 8fc4943003..a15585830f 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php @@ -50,7 +50,7 @@ public function register() * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return void + * @return int */ public function process(File $phpcsFile, $stackPtr) { @@ -113,7 +113,7 @@ public function process(File $phpcsFile, $stackPtr) * * @param string $path The path to return Subversion properties on. * - * @return array + * @return array|null * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If Subversion properties file could * not be opened. */ diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php index 6beec4219b..4d223ee186 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php @@ -78,7 +78,7 @@ public function register() * @param int $stackPtr The position of the current token in * the stack passed in $tokens. * - * @return void + * @return void|int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php index e085e4ae80..b2290cd124 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php @@ -56,7 +56,7 @@ public function register() * @param int $stackPtr The position of the current token in * the stack passed in $tokens. * - * @return void + * @return int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php index 15d4580c94..471bb3d014 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php @@ -56,7 +56,7 @@ public function register() * @param int $stackPtr The position of the current token in * the stack passed in $tokens. * - * @return void + * @return int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index 7789a7a915..2453abdcd8 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -80,7 +80,7 @@ class ScopeIndentSniff implements Sniff * This is a cached copy of the public version of this var, which * can be set in a ruleset file, and some core ignored tokens. * - * @var int[] + * @var array */ private $ignoreIndentation = []; diff --git a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php b/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php index 38ab9a3581..9af0d93093 100644 --- a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php @@ -19,7 +19,7 @@ class CSSLintUnitTest extends AbstractSniffUnitTest /** * Should this test be skipped for some reason. * - * @return void + * @return bool */ protected function shouldSkipTest() { diff --git a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php b/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php index 25a05a34f8..f5054b5c3d 100644 --- a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php @@ -19,7 +19,7 @@ class ClosureLinterUnitTest extends AbstractSniffUnitTest /** * Should this test be skipped for some reason. * - * @return void + * @return bool */ protected function shouldSkipTest() { diff --git a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php index 1aaec09d05..d9d754d731 100644 --- a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php @@ -68,7 +68,7 @@ protected function resetProperties() /** * Should this test be skipped for some reason. * - * @return void + * @return bool */ protected function shouldSkipTest() { diff --git a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php b/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php index 27a56033f8..e7753d0558 100644 --- a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php @@ -19,7 +19,7 @@ class JSHintUnitTest extends AbstractSniffUnitTest /** * Should this test be skipped for some reason. * - * @return void + * @return bool */ protected function shouldSkipTest() { diff --git a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php index e94b5d47ce..c10b34fa88 100644 --- a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php @@ -18,7 +18,7 @@ class ExecutableFileUnitTest extends AbstractSniffUnitTest /** * Should this test be skipped for some reason. * - * @return void + * @return bool */ protected function shouldSkipTest() { diff --git a/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php b/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php index e47d63bcd8..02d6a1289f 100644 --- a/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php +++ b/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php @@ -18,7 +18,7 @@ class SubversionPropertiesUnitTest extends AbstractSniffUnitTest /** * Should this test be skipped for some reason. * - * @return void + * @return bool */ protected function shouldSkipTest() { diff --git a/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php b/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php index ae0f280d31..9d02672d16 100644 --- a/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php +++ b/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php @@ -43,7 +43,7 @@ class BrowserSpecificStylesSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php index 1852756819..7ae09f8710 100644 --- a/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php @@ -82,7 +82,7 @@ public function process(File $phpcsFile, $stackPtr) * @param int $stackPtr The position in the tokens array of the * potentially included class. * - * @return string + * @return bool */ protected function getIncludedClassFromToken( $phpcsFile, diff --git a/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php index 1c9e5727a8..85d7f765a6 100644 --- a/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php @@ -19,7 +19,7 @@ class IncludeSystemSniff extends AbstractScopeSniff /** * A list of classes that don't need to be included. * - * @var string[] + * @var array */ private $ignore = [ 'self' => true, @@ -286,7 +286,7 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) * @param int $stackPtr The position in the tokens array of the * potentially included class. * - * @return string + * @return string|false */ protected function getIncludedClassFromToken(File $phpcsFile, array $tokens, $stackPtr) { diff --git a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php index 2b42648404..2af57b18d5 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php @@ -88,7 +88,7 @@ public function register() * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return int + * @return int|void */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php index a4b19a73bf..e92ffb551d 100644 --- a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php +++ b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php @@ -36,7 +36,7 @@ public function register() * @param int $stackPtr The position of the current token in * the token stack. * - * @return void + * @return int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php index d2b10aef0e..99c9de2bf9 100644 --- a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php @@ -36,7 +36,7 @@ public function register() * @param int $stackPtr The position of the current * token in the stack. * - * @return int|null + * @return int|void */ public function process(File $phpcsFile, $stackPtr) { @@ -284,7 +284,7 @@ public function getHeaderLines(File $phpcsFile, $stackPtr) * @param array $headerLines Header information, as sourced * from getHeaderLines(). * - * @return int|null + * @return void */ public function processHeaderLines(File $phpcsFile, $headerLines) { diff --git a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php index 8770467ee2..109e23e9e6 100644 --- a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php @@ -36,7 +36,7 @@ public function register() * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * - * @return void + * @return void|int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php index 2554226ac6..a63ba88198 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -241,7 +241,7 @@ private function findNextCase($phpcsFile, $stackPtr, $end) * @param int $stackPtr The position to start looking at. * @param int $end The position to stop looking at. * - * @return int|false + * @return int|bool */ private function findNestedTerminator($phpcsFile, $stackPtr, $end) { diff --git a/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php b/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php index 3df15a229b..98693f8615 100644 --- a/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php @@ -38,7 +38,7 @@ public function register() * @param int $stackPtr The position of the current token in * the stack passed in $tokens. * - * @return void + * @return int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php b/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php index c43a747f1a..cee18cacde 100644 --- a/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php +++ b/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php @@ -35,7 +35,7 @@ class FunctionCallSignatureSniff extends PEARFunctionCallSignatureSniff * @param array $tokens The stack of tokens that make up * the file. * - * @return void + * @return bool */ public function isMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens) { diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php index 156c0f114b..fb147582fa 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php @@ -27,7 +27,7 @@ class ClassDefinitionClosingBraceSpaceSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php index b3ea8976d1..7ed872fea3 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php @@ -27,7 +27,7 @@ class ClassDefinitionNameSpacingSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php index 0d12ef09d2..0b84fa6262 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php @@ -27,7 +27,7 @@ class ClassDefinitionOpeningBraceSpaceSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php index d4b18d2df1..07b6088679 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php @@ -27,7 +27,7 @@ class ColonSpacingSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php index f1ede4d628..0f9131e7a2 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php @@ -26,7 +26,7 @@ class ColourDefinitionSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php b/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php index a32de327e6..ddea31403d 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php @@ -18,7 +18,7 @@ class DisallowMultipleStyleDefinitionsSniff implements Sniff /** * A list of tokenizers this sniff supports. * - * @var array + * @var string[] */ public $supportedTokenizers = ['CSS']; @@ -26,7 +26,7 @@ class DisallowMultipleStyleDefinitionsSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php index 8c9cf82a43..97ad572ca2 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php @@ -26,7 +26,7 @@ class DuplicateStyleDefinitionSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php index eccd91e925..e641ed20d6 100644 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php @@ -27,7 +27,7 @@ class EmptyClassDefinitionSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php index c77c2488ac..816bb9b7cb 100644 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php @@ -27,7 +27,7 @@ class EmptyStyleDefinitionSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php index 654ca5f5b9..509e9866b0 100644 --- a/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php @@ -26,7 +26,7 @@ class LowercaseStyleDefinitionSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php b/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php index f3887cd7ff..a9ca371ca2 100644 --- a/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php @@ -26,7 +26,7 @@ class MissingColonSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php b/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php index 90763c80f0..e2a3e8dd9e 100644 --- a/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php @@ -27,7 +27,7 @@ class OpacitySniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php index f668d17f1d..ef9d238c66 100644 --- a/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php @@ -27,7 +27,7 @@ class SemicolonSpacingSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php b/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php index 57570a761a..b59c27963d 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php @@ -41,7 +41,7 @@ class ShorthandSizeSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index 21c8229998..644fd50c7c 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -27,7 +27,7 @@ class FunctionCommentSniff extends PEARFunctionCommentSniff /** * The current PHP version. * - * @var integer + * @var integer|string|null */ private $phpVersion = null; diff --git a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php index 1306d185aa..babe2edc0d 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php @@ -49,7 +49,7 @@ public function register() * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * - * @return void + * @return void|int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php index 635116d2d9..626b330f11 100644 --- a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php @@ -37,7 +37,7 @@ class MultiLineFunctionDeclarationSniff extends PEARFunctionDeclarationSniff * @param array $tokens The stack of tokens that make up * the file. * - * @return void + * @return bool */ public function isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tokens) { diff --git a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php index 58d529ed42..c018142c98 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php @@ -44,7 +44,7 @@ class ComparisonOperatorUsageSniff implements Sniff /** * A list of invalid operators with their alternatives. * - * @var array + * @var array> */ private static $invalidOps = [ 'PHP' => [ diff --git a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php index f2e76f00dc..d08bc3d100 100644 --- a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php @@ -38,7 +38,7 @@ public function register() * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return void + * @return int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php index 2eff82d656..a0c45c1526 100644 --- a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php +++ b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php @@ -19,7 +19,7 @@ class JSLintUnitTest extends AbstractSniffUnitTest /** * Should this test be skipped for some reason. * - * @return void + * @return bool */ protected function shouldSkipTest() { diff --git a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php index dac3b3addf..30108f59b4 100644 --- a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php +++ b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php @@ -19,7 +19,7 @@ class JavaScriptLintUnitTest extends AbstractSniffUnitTest /** * Should this test be skipped for some reason. * - * @return void + * @return bool */ protected function shouldSkipTest() { diff --git a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php index e5e0c22d7a..b67dbf191d 100644 --- a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php @@ -36,7 +36,7 @@ public function register() * @param int $stackPtr The position of the current token in * the stack passed in $tokens. * - * @return void + * @return int */ public function process(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php b/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php index f1e04521c5..9d90fb536d 100644 --- a/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php +++ b/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php @@ -19,7 +19,7 @@ class CodeAnalyzerUnitTest extends AbstractSniffUnitTest /** * Should this test be skipped for some reason. * - * @return void + * @return bool */ protected function shouldSkipTest() { diff --git a/src/Tokenizers/JS.php b/src/Tokenizers/JS.php index 8ef0ad92f1..cb7bd3c193 100644 --- a/src/Tokenizers/JS.php +++ b/src/Tokenizers/JS.php @@ -905,10 +905,10 @@ public function tokenize($string) * * If a regular expression is not found, NULL is returned. * - * @param string $char The index of the possible regex start character. + * @param int $char The index of the possible regex start character. * @param string $string The complete content of the string being tokenized. - * @param string $chars An array of characters being tokenized. - * @param string $tokens The current array of tokens found in the string. + * @param array $chars An array of characters being tokenized. + * @param array $tokens The current array of tokens found in the string. * * @return array|null */ diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 5ca178bd04..e8ad0db793 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -306,7 +306,7 @@ class PHP extends Tokenizer /** * Known lengths of tokens. * - * @var array + * @var array */ public $knownLengths = [ T_ABSTRACT => 8, diff --git a/src/Tokenizers/Tokenizer.php b/src/Tokenizers/Tokenizer.php index 9ef4a81609..bfe8c7a143 100644 --- a/src/Tokenizers/Tokenizer.php +++ b/src/Tokenizers/Tokenizer.php @@ -60,7 +60,7 @@ abstract class Tokenizer /** * Known lengths of tokens. * - * @var array + * @var array */ public $knownLengths = []; diff --git a/src/Util/Cache.php b/src/Util/Cache.php index 3910fabe3b..932952e4be 100644 --- a/src/Util/Cache.php +++ b/src/Util/Cache.php @@ -19,7 +19,7 @@ class Cache /** * The filesystem location of the cache file. * - * @var void + * @var string */ private static $path = ''; diff --git a/src/Util/Common.php b/src/Util/Common.php index b8e3d4f80e..afed49e700 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -35,7 +35,7 @@ class Common * * @param string $path The path to use. * - * @return mixed + * @return bool */ public static function isPharFile($path) { @@ -83,7 +83,7 @@ public static function isReadable($path) * * @param string $path The path to use. * - * @return mixed + * @return string|false */ public static function realpath($path) { From 964dd23e547f25e54fceab14e19ad4a9cfd31a28 Mon Sep 17 00:00:00 2001 From: Danny van der Sluijs Date: Mon, 4 Dec 2023 20:16:56 +0100 Subject: [PATCH 092/874] docs: Correct spelling issues in readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9afd051b16..afca96cbff 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ If you use Phive, you can install PHP_CodeSniffer as a project tool using the fo phive install phpcs phive install phpcbf ``` -You will then be able to run PHP_CodeSniffer from the tools directory: +You will then be able to run PHP_CodeSniffer from the `tools` directory: ```bash ./tools/phpcs -h ./tools/phpcbf -h @@ -107,11 +107,11 @@ Full usage information and example reports are available on the [usage page](htt ## Documentation -The documentation for PHP_CodeSniffer is available on the [Github wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki). +The documentation for PHP_CodeSniffer is available on the [GitHub wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki). ## Issues -Bug reports and feature requests can be submitted on the [Github Issue Tracker](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues). +Bug reports and feature requests can be submitted on the [GitHub Issue Tracker](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues). ## Contributing From 494164553b4bbd274b342e28ecab2c2d0debb3de Mon Sep 17 00:00:00 2001 From: Danny van der Sluijs Date: Mon, 4 Dec 2023 20:39:04 +0100 Subject: [PATCH 093/874] docs: Correct spelling issues in contributing --- .github/CONTRIBUTING.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index deb27c2b5c..843ebe4cd5 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -50,14 +50,14 @@ To find issues which need triage, look for [issues without labels](https://githu * Ask for additional information if it is not. * If you find the issue is reported to the wrong repo, ask the reporter to report it to the correct external standard repo and suggest closing the issue. -Additionally for older issues: +Additionally, for older issues: * Check whether an issue still exists or has been fixed in `master` since the issue was initially reported. * If it has been fixed, document (in a comment) which commit/PR was responsible for fixing the issue and suggest closing the ticket. ### Testing Open Pull Requests -Testing pull requests to verify they fix the issue they are supposed to fix without side-effects is an important task. +Testing pull requests to verify they fix the issue they are supposed to fix without side effects is an important task. To get access to a PHPCS version which includes the patch from a pull request, you can: * Either use a git clone of the PHP_CodeSniffer repository and check out the PR. @@ -69,7 +69,7 @@ To get access to a PHPCS version which includes the patch from a pull request, y * Verify that the patch solves the originally reported problem. * Verify that the tests added in the PR fail without the fix and pass with the fix. * For a fix for false negatives: verify that the correct error message(s) are thrown by the patched code. -* Run the patched PHPCS version against real codebases to see if the fix creates any side-effects (new false positives/false negatives). +* Run the patched PHPCS version against real codebases to see if the fix creates any side effects (new false positives/false negatives). ### Writing sniff documentation @@ -190,7 +190,7 @@ The `getErrorList()` and the `getWarningList()` methods will receive an optional If a sniff contains errors/warnings which can be auto-fixed, these fixers should also be tested. -This is done by adding an additional test _case_ file with an extra `.fixed` extension for each test _case_ file which expects fixes. +This is done by adding a test _case_ file with an extra `.fixed` extension for each test _case_ file which expects fixes. For example, if the above `Generic.NamingConventions.ConstructorName` would contain an auto-fixer, there should be an additional `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc.fixed` file containing the code as it is expected to be after the fixer has run. @@ -203,12 +203,12 @@ Some guidelines for submitting pull requests (PRs) and improving the chance that If your change is complex, make sure you add a proper commit message explaining what you have done and why. * Please clean up your branch before pulling your PR. Small PRs using atomic, descriptive commits are hugely appreciated as it will make reviewing your changes easier for the maintainers. -* Only open your PR when you've finished work on it and you are confident that it is ready for review. +* Only open your PR when you've finished work on it, and you are confident that it is ready for review. * Please make sure your pull request passes all continuous integration checks. PRs which are failing their CI checks will likely be ignored by the maintainers or closed. * Please respond to PR reviews in a timely manner. -Your time is valuable and we appreciate your willingness to spend it on this project. +Your time is valuable, and we appreciate your willingness to spend it on this project. However, the maintainers time is also valuable and often, more scarce, so please be considerate of that. ## Licensing From 4ee1d722816baf59d3826af8d8ab6bba52e9d3b9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Dec 2023 23:46:06 +0100 Subject: [PATCH 094/874] Changelog for #129 and #130 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb37bfa86d..8912e592ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -92,7 +92,7 @@ The file documents changes to the PHP_CodeSniffer project. - Improved README syntax highlighting - Thanks to Benjamin Loison (@Benjamin-Loison) for the patch - Various documentation improvements - - Thanks to Andrew Dawes (@AndrewDawes) and Juliette Reinders Folmer (@jrfnl) for the patches + - Thanks to Andrew Dawes (@AndrewDawes), Danny van der Sluijs (@DannyvdSluijs) and Juliette Reinders Folmer (@jrfnl) for the patches ### Removed - Removed support for installing via PEAR From 84ff93d74af4b2357d76cf0e2ead6fc5bbd16d80 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 28 Oct 2023 22:32:24 +0200 Subject: [PATCH 095/874] Various sniffs: always return EOF pointer ... for files scanning the complete file in one go as if any of the error conditions are hit, it is useless to try again for the same file. --- src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php | 6 +++--- src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php | 6 +++--- src/Standards/Generic/Sniffs/Debug/ESLintSniff.php | 4 ++-- src/Standards/Generic/Sniffs/Debug/JSHintSniff.php | 4 ++-- src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php | 2 +- .../Generic/Sniffs/Files/LowercasedFilenameSniff.php | 2 +- src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php | 2 +- src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php | 4 ++-- src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php | 4 ++-- src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php index 9baad8c97c..4fe8bd7cb1 100644 --- a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php @@ -44,13 +44,13 @@ public function register() * @param int $stackPtr The position in the stack where * the token was found. * - * @return void + * @return int */ public function process(File $phpcsFile, $stackPtr) { $csslintPath = Config::getExecutablePath('csslint'); if ($csslintPath === null) { - return; + return ($phpcsFile->numTokens + 1); } $fileName = $phpcsFile->getFilename(); @@ -59,7 +59,7 @@ public function process(File $phpcsFile, $stackPtr) exec($cmd, $output, $retval); if (is_array($output) === false) { - return; + return ($phpcsFile->numTokens + 1); } $count = count($output); diff --git a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php index cacb3a7a7e..6bcc0a7518 100644 --- a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php @@ -60,14 +60,14 @@ public function register() * @param int $stackPtr The position in the stack where * the token was found. * - * @return void + * @return int * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jslint.js could not be run */ public function process(File $phpcsFile, $stackPtr) { $lintPath = Config::getExecutablePath('gjslint'); if ($lintPath === null) { - return; + return ($phpcsFile->numTokens + 1); } $fileName = $phpcsFile->getFilename(); @@ -77,7 +77,7 @@ public function process(File $phpcsFile, $stackPtr) exec($cmd, $output, $retval); if (is_array($output) === false) { - return; + return ($phpcsFile->numTokens + 1); } foreach ($output as $finding) { diff --git a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php index cf576383f6..8145dc70a1 100644 --- a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php @@ -51,14 +51,14 @@ public function register() * @param int $stackPtr The position in the stack where * the token was found. * - * @return void + * @return int * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jshint.js could not be run */ public function process(File $phpcsFile, $stackPtr) { $eslintPath = Config::getExecutablePath('eslint'); if ($eslintPath === null) { - return; + return ($phpcsFile->numTokens + 1); } $filename = $phpcsFile->getFilename(); diff --git a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php index aa3e6bd7f6..a8f6e2d279 100644 --- a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php @@ -45,7 +45,7 @@ public function register() * @param int $stackPtr The position in the stack where * the token was found. * - * @return void + * @return int * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jshint.js could not be run */ public function process(File $phpcsFile, $stackPtr) @@ -53,7 +53,7 @@ public function process(File $phpcsFile, $stackPtr) $rhinoPath = Config::getExecutablePath('rhino'); $jshintPath = Config::getExecutablePath('jshint'); if ($jshintPath === null) { - return; + return ($phpcsFile->numTokens + 1); } $fileName = $phpcsFile->getFilename(); diff --git a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php index 2a8647e44f..1d17ada436 100644 --- a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php @@ -79,7 +79,7 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$lastToken]['line'] === 1 && $tokens[$lastToken]['content'] !== "\n" ) { - return; + return ($phpcsFile->numTokens + 1); } } diff --git a/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php b/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php index c6ab14ce21..90af44f6e6 100644 --- a/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php @@ -44,7 +44,7 @@ public function process(File $phpcsFile, $stackPtr) { $filename = $phpcsFile->getFilename(); if ($filename === 'STDIN') { - return; + return ($phpcsFile->numTokens + 1); } $filename = basename($filename); diff --git a/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php b/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php index c5cd9d5b6e..bb8a75d0b5 100644 --- a/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php @@ -54,7 +54,7 @@ public function process(File $phpcsFile, $stackPtr) $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); if ($next === false) { // Empty file. - return; + return $phpcsFile->numTokens; } if ($tokens[$next]['line'] === $tokens[$stackPtr]['line']) { diff --git a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php index 11ed4f26c8..67cac55086 100644 --- a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php +++ b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php @@ -44,7 +44,7 @@ public function register() * @param int $stackPtr The position in the stack where * the token was found. * - * @return void + * @return int * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jslint.js could not be run */ public function process(File $phpcsFile, $stackPtr) @@ -52,7 +52,7 @@ public function process(File $phpcsFile, $stackPtr) $rhinoPath = Config::getExecutablePath('rhino'); $jslintPath = Config::getExecutablePath('jslint'); if ($rhinoPath === null || $jslintPath === null) { - return; + return ($phpcsFile->numTokens + 1); } $fileName = $phpcsFile->getFilename(); diff --git a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php index 8eae332f16..8f9989ed23 100644 --- a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php +++ b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php @@ -45,14 +45,14 @@ public function register() * @param int $stackPtr The position in the stack where * the token was found. * - * @return void + * @return int * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If Javascript Lint ran into trouble. */ public function process(File $phpcsFile, $stackPtr) { $jslPath = Config::getExecutablePath('jsl'); if ($jslPath === null) { - return; + return ($phpcsFile->numTokens + 1); } $fileName = $phpcsFile->getFilename(); diff --git a/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php b/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php index a77635eadd..5bcfdc0e1c 100644 --- a/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php +++ b/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php @@ -46,7 +46,7 @@ public function process(File $phpcsFile, $stackPtr) { $analyzerPath = Config::getExecutablePath('zend_ca'); if ($analyzerPath === null) { - return; + return ($phpcsFile->numTokens + 1); } $fileName = $phpcsFile->getFilename(); From a2667bcb4b38c5d0c2a7fd66c450337f4fd971dd Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 13 Jul 2023 10:30:06 +0200 Subject: [PATCH 096/874] Gitblame: fix fatal error on `chdir()` when `basepath` is set and phpcs is run from subdir The `Reporter::prepareFileReport()` method strips the `basepath` off the file name for the `$report['filename']`. https://github.com/squizlabs/PHP_CodeSniffer/blob/276f68cc74a3e4e1855bab6d01f0089337d00ae0/src/Reporter.php#L337 While this is fine in most cases, for "blame" reports, the full path is needed. This changes the path passed to the `getBlameContent()` method in subclasses of the `VersionControl` class to the full path, which fixes the fatal error for the `Gitblame` report (and probably similar/related errors in the `Hgblame` and the `Svnblame` reports, but I don't have any repos to test this on). Fixes 3854 --- CHANGELOG.md | 2 ++ src/Reports/VersionControl.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8912e592ea..e14018ba8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -139,6 +139,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Dan Wallis (@fredden) for the patch - Fixed bug #3816 : PSR12/FileHeader: bug fix - false positives on PHP 8.2+ readonly classes - 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 #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 diff --git a/src/Reports/VersionControl.php b/src/Reports/VersionControl.php index df1cd642db..e3ad74b845 100644 --- a/src/Reports/VersionControl.php +++ b/src/Reports/VersionControl.php @@ -40,7 +40,7 @@ abstract class VersionControl implements Report */ public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) { - $blames = $this->getBlameContent($report['filename']); + $blames = $this->getBlameContent($phpcsFile->getFilename()); $authorCache = []; $praiseCache = []; From ed6c437526c972e08f222165b14368028ead2321 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 5 Jan 2023 03:40:05 +0100 Subject: [PATCH 097/874] PEAR/FunctionDeclaration: bug fix - prevent fixer from creating a parse error Issue as described in 3736. The fixer would try to remove superfluous whitespace remaining after the move of the opening brace to the previous line, but did not take into account that there may not be any whitespace to removed, i.e. that the `$opener +1` token could be the same as the `$next` token. Fixed now. Includes unit test. Fixes 3736 --- CHANGELOG.md | 2 ++ .../PEAR/Sniffs/Functions/FunctionDeclarationSniff.php | 6 ++++-- .../PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc | 9 +++++++++ .../Functions/FunctionDeclarationUnitTest.inc.fixed | 9 +++++++++ .../PEAR/Tests/Functions/FunctionDeclarationUnitTest.php | 1 + 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e14018ba8e..802d42c905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -109,6 +109,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch - Fixed bug #3728 : PHP 8.2 | PSR1/SideEffects: allow for readonly classes - 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 #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 diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index af18a2b82d..58a232107f 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -308,7 +308,7 @@ public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens) $phpcsFile->fixer->addContent($prev, ' {'); // If the opener is on a line by itself, removing it will create - // an empty line, so just remove the entire line instead. + // an empty line, so remove the entire line instead. $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($opener - 1), $closeBracket, true); $next = $phpcsFile->findNext(T_WHITESPACE, ($opener + 1), null, true); @@ -324,7 +324,9 @@ public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens) } else { // Just remove the opener. $phpcsFile->fixer->replaceToken($opener, ''); - if ($tokens[$next]['line'] === $tokens[$opener]['line']) { + if ($tokens[$next]['line'] === $tokens[$opener]['line'] + && ($opener + 1) !== $next + ) { $phpcsFile->fixer->replaceToken(($opener + 1), ''); } } diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc index fb7cb52f4d..52beaff772 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc @@ -465,3 +465,12 @@ new ExceptionMessage(), ) { } } + +// Issue #3736 - prevent the fixer creating a parse error by removing the function close brace. +class Test +{ + public function __construct( + protected int $id + ) + {} +} diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed index f82b5665a5..7d90f9a412 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed @@ -463,3 +463,12 @@ new ExceptionMessage(), ) { } } + +// Issue #3736 - prevent the fixer creating a parse error by removing the function close brace. +class Test +{ + public function __construct( + protected int $id + ) { + } +} diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php index 93a19d1b0d..871374959c 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php @@ -99,6 +99,7 @@ public function getErrorList($testFile='FunctionDeclarationUnitTest.inc') 371 => 1, 402 => 1, 406 => 1, + 475 => 1, ]; } else { $errors = [ From dcc257f5f547c3dc7012b011da0b6ff893e0eb90 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 5 Jan 2023 03:54:22 +0100 Subject: [PATCH 098/874] PEAR/FunctionDeclaration: prevent fixer conflict If a return type declaration was not confined to one line, the sniff could have a fixer conflict with itself. The fixer would also potentially remove a close curly on the same line, causing parse errors. Fixed now. The diff will be most straight forward to review while ignoring whitespace changes. Includes unit tests. --- CHANGELOG.md | 2 + .../Functions/FunctionDeclarationSniff.php | 101 ++++++++++-------- .../Functions/FunctionDeclarationUnitTest.inc | 14 +++ .../FunctionDeclarationUnitTest.inc.fixed | 13 +++ .../Functions/FunctionDeclarationUnitTest.php | 2 + 5 files changed, 86 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 802d42c905..c01e8dd7ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,6 +111,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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 diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index 58a232107f..4cc24a2d19 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -297,65 +297,74 @@ public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens) return; } - // The opening brace needs to be one space away from the closing parenthesis. + // The opening brace needs to be on the same line as the closing parenthesis. + // There should only be one space between the closing parenthesis - or the end of the + // return type - and the opening brace. $opener = $tokens[$stackPtr]['scope_opener']; if ($tokens[$opener]['line'] !== $tokens[$closeBracket]['line']) { $error = 'The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line'; - $fix = $phpcsFile->addFixableError($error, $opener, 'NewlineBeforeOpenBrace'); - if ($fix === true) { - $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), $closeBracket, true); - $phpcsFile->fixer->beginChangeset(); - $phpcsFile->fixer->addContent($prev, ' {'); - - // If the opener is on a line by itself, removing it will create - // an empty line, so remove the entire line instead. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($opener - 1), $closeBracket, true); - $next = $phpcsFile->findNext(T_WHITESPACE, ($opener + 1), null, true); + $code = 'NewlineBeforeOpenBrace'; - if ($tokens[$prev]['line'] < $tokens[$opener]['line'] - && $tokens[$next]['line'] > $tokens[$opener]['line'] - ) { - // Clear the whole line. - for ($i = ($prev + 1); $i < $next; $i++) { - if ($tokens[$i]['line'] === $tokens[$opener]['line']) { - $phpcsFile->fixer->replaceToken($i, ''); - } - } - } else { - // Just remove the opener. - $phpcsFile->fixer->replaceToken($opener, ''); - if ($tokens[$next]['line'] === $tokens[$opener]['line'] - && ($opener + 1) !== $next - ) { - $phpcsFile->fixer->replaceToken(($opener + 1), ''); - } - } - - $phpcsFile->fixer->endChangeset(); - }//end if - } else { - $prev = $tokens[($opener - 1)]; - if ($prev['code'] !== T_WHITESPACE) { - $length = 0; + $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), $closeBracket, true); + if ($tokens[$prev]['line'] === $tokens[$opener]['line']) { + // End of the return type is not on the same line as the close parenthesis. + $phpcsFile->addError($error, $opener, $code); } else { - $length = strlen($prev['content']); - } - - if ($length !== 1) { - $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration; found %s spaces'; - $fix = $phpcsFile->addFixableError($error, ($opener - 1), 'SpaceBeforeOpenBrace', [$length]); + $fix = $phpcsFile->addFixableError($error, $opener, $code); if ($fix === true) { - if ($length === 0) { - $phpcsFile->fixer->addContentBefore($opener, ' '); + $phpcsFile->fixer->beginChangeset(); + $phpcsFile->fixer->addContent($prev, ' {'); + + // If the opener is on a line by itself, removing it will create + // an empty line, so remove the entire line instead. + $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($opener - 1), $closeBracket, true); + $next = $phpcsFile->findNext(T_WHITESPACE, ($opener + 1), null, true); + + if ($tokens[$prev]['line'] < $tokens[$opener]['line'] + && $tokens[$next]['line'] > $tokens[$opener]['line'] + ) { + // Clear the whole line. + for ($i = ($prev + 1); $i < $next; $i++) { + if ($tokens[$i]['line'] === $tokens[$opener]['line']) { + $phpcsFile->fixer->replaceToken($i, ''); + } + } } else { - $phpcsFile->fixer->replaceToken(($opener - 1), ' '); + // Just remove the opener. + $phpcsFile->fixer->replaceToken($opener, ''); + if ($tokens[$next]['line'] === $tokens[$opener]['line'] + && ($opener + 1) !== $next + ) { + $phpcsFile->fixer->replaceToken(($opener + 1), ''); + } } - } + + $phpcsFile->fixer->endChangeset(); + }//end if return; }//end if }//end if + $prev = $tokens[($opener - 1)]; + if ($prev['code'] !== T_WHITESPACE) { + $length = 0; + } else { + $length = strlen($prev['content']); + } + + if ($length !== 1) { + $error = 'There must be a single space between the closing parenthesis/return type and the opening brace of a multi-line function declaration; found %s spaces'; + $fix = $phpcsFile->addFixableError($error, ($opener - 1), 'SpaceBeforeOpenBrace', [$length]); + if ($fix === true) { + if ($length === 0) { + $phpcsFile->fixer->addContentBefore($opener, ' '); + } else { + $phpcsFile->fixer->replaceToken(($opener - 1), ' '); + } + } + } + }//end processMultiLineDeclaration() diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc index 52beaff772..6ba3bd9f6a 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc @@ -474,3 +474,17 @@ class Test ) {} } + +// Prevent fixer conflict with itself. +function foo( + $param1, +) +: \SomeClass + { + } + +function foo( + $param1, + $param2 +) : // comment. + \Package\Sub\SomeClass {} diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed index 7d90f9a412..8248ee1dc8 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed @@ -472,3 +472,16 @@ class Test ) { } } + +// Prevent fixer conflict with itself. +function foo( + $param1, +) +: \SomeClass { + } + +function foo( + $param1, + $param2 +) : // comment. + \Package\Sub\SomeClass {} diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php index 871374959c..d12c8c08bc 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php @@ -100,6 +100,8 @@ public function getErrorList($testFile='FunctionDeclarationUnitTest.inc') 402 => 1, 406 => 1, 475 => 1, + 483 => 1, + 490 => 2, ]; } else { $errors = [ From 884d7028b9f43187f01331047e5d18bc84514d5f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 2 Apr 2023 18:45:12 +0200 Subject: [PATCH 099/874] PSR12/AnonClassDeclaration: prevent fixer creating parse error This fix prevents the fixer from removing the opening brace when there is no whitespace between the last character of the name of an interface and the open brace. With this fix in place, all other symptoms reported are also gone as they were a side-effect of the parse error being created. Includes unit test. Fixes 3790 --- CHANGELOG.md | 2 ++ .../PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php | 6 +++++- .../PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc | 6 ++++++ .../Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed | 7 +++++++ .../PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php | 2 ++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c01e8dd7ec..6b1984a1a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -129,6 +129,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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 diff --git a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php index 6dcd464fb9..fd8e81a3fc 100644 --- a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php @@ -97,7 +97,11 @@ public function process(File $phpcsFile, $stackPtr) $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true); $indent = str_repeat(' ', ($tokens[$first]['column'] - 1)); $phpcsFile->fixer->beginChangeset(); - $phpcsFile->fixer->replaceToken(($prev + 1), ''); + + if ($tokens[($prev + 1)]['code'] === \T_WHITESPACE) { + $phpcsFile->fixer->replaceToken(($prev + 1), ''); + } + $phpcsFile->fixer->addNewline($prev); $phpcsFile->fixer->addContentBefore($opener, $indent); $phpcsFile->fixer->endChangeset(); diff --git a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc index e132b54df1..fe3ee02ef8 100644 --- a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc +++ b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc @@ -82,3 +82,9 @@ $foo->bar( foo(new class { }); + +// Issue #3790: OpenBraceSameLine fixer should not remove open brace. +$instance = new class() extends SomeClass implements + SomeInterface{ + public function __construct() {} +}; diff --git a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed index 921dcc02de..4a6c5a1f1a 100644 --- a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed +++ b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed @@ -84,3 +84,10 @@ $foo->bar( foo(new class { }); + +// Issue #3790: OpenBraceSameLine fixer should not remove open brace. +$instance = new class () extends SomeClass implements + SomeInterface +{ + public function __construct() {} +}; diff --git a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php index 67a3a663e5..6f3962629b 100644 --- a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php @@ -48,6 +48,8 @@ public function getErrorList() 56 => 2, 63 => 1, 75 => 1, + 87 => 1, + 88 => 1, ]; }//end getErrorList() From 98ed2b1a53c02f9f6d972b24426eb0e1123e59e6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Dec 2023 17:22:10 +0100 Subject: [PATCH 100/874] GH Actions/label mngmnt: allow for uppercase X in checkboxes --- .github/labeler.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index fd6f71e11e..bd6a522938 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -77,16 +77,16 @@ labels: - label: "Type: breaking change" draft: false - body: 'x\] Breaking change' + body: '[Xx]\] Breaking change' - label: "Type: bug" draft: false - body: 'x\] Bug fix' + body: '[Xx]\] Bug fix' - label: "Type: enhancement" draft: false - body: 'x\] New feature' + body: '[Xx]\] New feature' - label: "Type: documentation" draft: false - body: 'x\] Documentation improvement' + body: '[Xx]\] Documentation improvement' - label: "Type: documentation" draft: false files: From 8f8e67e29fb5dbb55930be6c4cda329bbbe239d9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 17 Oct 2022 11:11:11 +0200 Subject: [PATCH 101/874] Squiz/OperatorSpacing: minor tweak to the tests PR 2515 introduced a new public property to the sniff, including tests, but the property was not reset after that particular test, which means it could affect all tests added after it. Fixed now. --- .../Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc | 2 +- .../Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed | 2 +- src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js | 1 + .../Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc index 06462acc35..765e7ab717 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc @@ -269,7 +269,7 @@ fn&($x) => $x; // phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false $a = 3; - +// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments true yield -1; echo -1; $a = -1; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed index 8b92a4875a..ada77fa859 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed @@ -263,7 +263,7 @@ fn&($x) => $x; // phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false $a = 3; - +// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments true yield -1; echo -1; $a = -1; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js index 16eb130f55..f37df9d863 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js @@ -101,3 +101,4 @@ var foo = bar.map(baz=> baz.length); // phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false a = 3; +// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments true diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed index 877db4678c..47c89302b3 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed @@ -95,3 +95,4 @@ var foo = bar.map(baz => baz.length); // phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false a = 3; +// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments true From 45699594c5779398de87493ba6e8b4c871eede31 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Sun, 29 Oct 2023 17:19:34 +0000 Subject: [PATCH 102/874] Show warnings in internal coding standard --- phpcs.xml.dist | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 17e2000ade..f5f05f9144 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -15,12 +15,7 @@ - - - - - error - + @@ -32,6 +27,7 @@ + @@ -76,13 +72,6 @@ - - - - - - - @@ -111,11 +100,10 @@ - + - @@ -132,20 +120,8 @@ - - - error - - - - - error - - - - error - + @@ -157,4 +133,14 @@ tests/Core/Tokenizer/StableCommentWhitespaceWinTest\.php + + + src/Standards/Generic/Sniffs/Commenting/TodoSniff\.php + src/Standards/Generic/Tests/Commenting/TodoUnitTest\.php + + + + + src/Util/Tokens\.php + From fed93f1a716560a17a28dfa756a54a36b85065d6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 22 May 2023 19:51:06 +0200 Subject: [PATCH 103/874] Generic/LowerCaseType: fix potential PHP notice The `Generic.PHP.LowerCaseType` sniff calls the `File::getMemberProperties()` method to get information about potential properties. That method throws an exception when the `T_VARIABLE` token passed is not a property, but will create an `Internal.ParseError.InterfaceHasMemberVar` warning and return an empty array when the `T_VARIABLE` passed is an _illegal_ property, i.e. a property in a context in which it is not allowed (interface/enum). As things were, the sniff did not take a potential return value of an empty array into account, which could result in an `Undefined array key "type"` PHP notice. Fixed now. Includes unit test. --- CHANGELOG.md | 2 ++ src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php | 5 +++++ src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc | 7 ++++++- .../Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed | 7 ++++++- src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php | 3 ++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b1984a1a9..02ff99ddde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -145,6 +145,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Dan Wallis (@fredden) for the patch - Fixed bug #3816 : PSR12/FileHeader: bug fix - false positives on PHP 8.2+ readonly classes - Thanks to Juliette Reinders Folmer (@jrfnl) 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 #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 #3867 : Tokenizer/PHP: union type and intersection type operators were not correctly tokenized for static properties without explicit visibility diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php index 28ecb0215f..daa6f0f2e9 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php @@ -98,6 +98,11 @@ public function process(File $phpcsFile, $stackPtr) return; } + if (empty($props) === true) { + // Parse error - property in interface or enum. Ignore. + return; + } + // Strip off potential nullable indication. $type = ltrim($props['type'], '?'); diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc index 98d2aa4b56..56393c0b24 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc @@ -93,4 +93,9 @@ function intersectionReturnTypes ($var): \Package\ClassName&\Package\Other_Class $arrow = fn (int $a, string $b, bool $c, array $d, Foo\Bar $e) : int => $a * $b; $arrow = fn (Int $a, String $b, BOOL $c, Array $d, Foo\Bar $e) : Float => $a * $b; -$cl = function (False $a, TRUE $b, Null $c): ?True {} +$cl = function (False $a, TRUE $b, Null $c): ?True {}; + +// Intentional error, should be ignored by the sniff. +interface PropertiesNotAllowed { + public $notAllowed; +} diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed index 9f17f0f7b1..c1055c726b 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed @@ -93,4 +93,9 @@ function intersectionReturnTypes ($var): \Package\ClassName&\Package\Other_Class $arrow = fn (int $a, string $b, bool $c, array $d, Foo\Bar $e) : int => $a * $b; $arrow = fn (int $a, string $b, bool $c, array $d, Foo\Bar $e) : float => $a * $b; -$cl = function (false $a, true $b, null $c): ?true {} +$cl = function (false $a, true $b, null $c): ?true {}; + +// Intentional error, should be ignored by the sniff. +interface PropertiesNotAllowed { + public $notAllowed; +} diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php index 51c42943bc..29d15c59a6 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php @@ -83,7 +83,8 @@ public function getErrorList() */ public function getWarningList() { - return []; + // Warning from getMemberProperties() about parse error. + return [100 => 1]; }//end getWarningList() From 9e19bd164b6fff6eca3fef2f0b8ada8a8a007923 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 23 Jun 2023 03:26:46 +0200 Subject: [PATCH 104/874] PSR2/ClassDeclaration: bug fix - blank line fixer also removes indent The `PSR2.Classes.ClassDeclaration.CloseBraceAfterBody` related logic checks that there is no blank line between the last content within the class and the close brace. The fixer for this error code, however, does not take indented class declarations into account and inadvertently also removes (correct) indentation. Fixed now. Includes unit test. --- CHANGELOG.md | 2 ++ .../PSR2/Sniffs/Classes/ClassDeclarationSniff.php | 4 ++-- .../PSR2/Tests/Classes/ClassDeclarationUnitTest.inc | 9 +++++++++ .../Tests/Classes/ClassDeclarationUnitTest.inc.fixed | 7 +++++++ .../PSR2/Tests/Classes/ClassDeclarationUnitTest.php | 1 + 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02ff99ddde..7aa67818a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -147,6 +147,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Juliette Reinders Folmer (@jrfnl) 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 #3867 : Tokenizer/PHP: union type and intersection type operators were not correctly tokenized for static properties without explicit visibility diff --git a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php index 3d5b3d8195..6d59b89ae9 100644 --- a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php @@ -492,12 +492,12 @@ public function processClose(File $phpcsFile, $stackPtr) if ($fix === true) { $phpcsFile->fixer->beginChangeset(); - for ($i = ($prevContent + 1); $i < $closeBrace; $i++) { + for ($i = ($prevContent + 1); $tokens[$i]['line'] !== $tokens[$closeBrace]['line']; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } if (strpos($tokens[$prevContent]['content'], $phpcsFile->eolChar) === false) { - $phpcsFile->fixer->replaceToken($closeBrace, $phpcsFile->eolChar.$tokens[$closeBrace]['content']); + $phpcsFile->fixer->addNewline($prevContent); } $phpcsFile->fixer->endChangeset(); diff --git a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc index dd78809366..f241a1a2fc 100644 --- a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc +++ b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc @@ -248,3 +248,12 @@ class Test readonly class Test { } + +if (!class_exists('IndentedDeclaration')) { + class IndentedDeclaration + { + function foo() {} + + + } +} diff --git a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed index 3be473639e..bb72318720 100644 --- a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed +++ b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed @@ -240,3 +240,10 @@ readonly class Test readonly class Test { } + +if (!class_exists('IndentedDeclaration')) { + class IndentedDeclaration + { + function foo() {} + } +} diff --git a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php index 64e451544a..0d94746802 100644 --- a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php @@ -65,6 +65,7 @@ public function getErrorList() 235 => 1, 244 => 1, 248 => 1, + 258 => 1, ]; }//end getErrorList() From 9397de6586507f5146bf5aa37c9e9761017c7cd9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 24 Sep 2023 12:11:50 +0200 Subject: [PATCH 105/874] Generic/DocComment: bug fix - don't remove ignore annotations when fixing The code sample included in the tests would previously result in an "There must be a single blank line after a tag group" error, even though there _is_ a blank line after the `@codeCoverageIgnore` tag. The auto-fixer would subsequently fix this by removing the `@phpcs:disable` comment + the blank line after it. Fixed now. Includes test. --- CHANGELOG.md | 2 ++ .../Generic/Sniffs/Commenting/DocCommentSniff.php | 8 ++++++-- .../Generic/Tests/Commenting/DocCommentUnitTest.inc | 10 ++++++++++ .../Tests/Commenting/DocCommentUnitTest.inc.fixed | 10 ++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aa67818a0..4ab0156be0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -155,6 +155,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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 - Thanks to @simonsan for the patch +- Fixed bug #3893 : Generic/DocComment : the SpacingAfterTagGroup fixer could accidentally remove ignore annotations + - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch - Fixed bug #3906 : Tokenizer/CSS: fixed a bug related to the unsupported slash comment syntax - Thanks to Dan Wallis (@fredden) for the patch diff --git a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php index 1e96e64b75..62c08cea10 100644 --- a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php @@ -11,6 +11,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; class DocCommentSniff implements Sniff { @@ -280,9 +281,12 @@ public function process(File $phpcsFile, $stackPtr) } // Check that there was single blank line after the tag block - // but account for a multi-line tag comments. + // but account for multi-line tag comments. + $find = Tokens::$phpcsCommentTokens; + $find[T_DOC_COMMENT_TAG] = T_DOC_COMMENT_TAG; + $lastTag = $group[$pos]; - $next = $phpcsFile->findNext(T_DOC_COMMENT_TAG, ($lastTag + 3), $commentEnd); + $next = $phpcsFile->findNext($find, ($lastTag + 3), $commentEnd); if ($next !== false) { $prev = $phpcsFile->findPrevious([T_DOC_COMMENT_TAG, T_DOC_COMMENT_STRING], ($next - 1), $commentStart); if ($tokens[$next]['line'] !== ($tokens[$prev]['line'] + 2)) { diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc index 8824166722..bcd8256d7b 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc @@ -249,4 +249,14 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +/** + * Do something. + * + * @codeCoverageIgnore + * + * @phpcs:disable Stnd.Cat.SniffName + * + * @return void + */ + /** No docblock close tag. Must be last test without new line. \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed index 46b4cd05bb..7da1c8ae8e 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed @@ -254,4 +254,14 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +/** + * Do something. + * + * @codeCoverageIgnore + * + * @phpcs:disable Stnd.Cat.SniffName + * + * @return void + */ + /** No docblock close tag. Must be last test without new line. \ No newline at end of file From 17e17ac9f0e6c63522e245161e0dbe51751548cb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 25 Oct 2023 06:11:13 +0200 Subject: [PATCH 106/874] Squiz/FunctionSpacing: bug fix - prevent fixer conflict with itself The `Squiz.WhiteSpace.FunctionSpacing` sniff demands # lines above and below a function declaration, but when determining the number of lines above or below, it does not care for additional code on the same line as the function declaration. I.e.: it does not demand that a function declaration starts on its own line or that the close brace is on its own line (there are other sniffs for that). The sniff also tries to prevent "double" errors for the same issue, i.e. when two functions are each on their own line without blank lines between them, the sniff will only throw one error for "spacing after" the first function and will not throw an error for "spacing before" for the second function. To determine whether the "spacing before" error needs to be hidden, the sniff tries to check whether the tokens on the previous line indicate the line contains a function declaration. As things were, however, this check could _bow out_ too early as it stopped at a scope opener for a wrapping construct (class), however, that wrapping construct _could_ be declared on the same line as the function, which means that in that case, the sniff would not determine the `$foundLines` correctly, as it stops on the current line at the scope opener instead of on a non-blank line above the function line. This commit fixes this bug by changing the `$stopAt` value to contain the wrapping scope opener applicable to the code _before_ the function line. This allows the `$foundLines` to be determined correctly and prevents the fixer conflict. Includes additional tests. Fixes 3904 --- CHANGELOG.md | 2 ++ .../Sniffs/WhiteSpace/FunctionSpacingSniff.php | 15 +++++++-------- .../WhiteSpace/FunctionSpacingUnitTest.1.inc | 8 ++++++++ .../FunctionSpacingUnitTest.1.inc.fixed | 15 +++++++++++++++ .../Tests/WhiteSpace/FunctionSpacingUnitTest.php | 2 ++ 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ab0156be0..504590d55b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -157,6 +157,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to @simonsan for the patch - Fixed bug #3893 : Generic/DocComment : the SpacingAfterTagGroup fixer could accidentally remove ignore annotations - 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: fixed a bug related to the unsupported slash comment syntax - Thanks to Dan Wallis (@fredden) for the patch diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php index 32af8b4ca0..dc99d73f6c 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php @@ -262,22 +262,21 @@ public function process(File $phpcsFile, $stackPtr) $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($tokens[$prevContent]['comment_opener'] - 1), null, true); } - $prevLineToken = $prevContent; - // Before we throw an error, check that we are not throwing an error // for another function. We don't want to error for no blank lines after // the previous function and no blank lines before this one as well. - $prevLine = ($tokens[$prevContent]['line'] - 1); - $i = ($stackPtr - 1); - $foundLines = 0; - $stopAt = 0; - if (isset($tokens[$stackPtr]['conditions']) === true) { - $conditions = $tokens[$stackPtr]['conditions']; + if (isset($tokens[$prevLineToken]['conditions']) === true) { + $conditions = $tokens[$prevLineToken]['conditions']; $conditions = array_keys($conditions); $stopAt = array_pop($conditions); } + $prevLineToken = $prevContent; + $prevLine = ($tokens[$prevContent]['line'] - 1); + $i = ($stackPtr - 1); + $foundLines = 0; + while ($currentLine !== $prevLine && $currentLine > 1 && $i > $stopAt) { if ($tokens[$i]['code'] === T_FUNCTION) { // Found another interface or abstract function. diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc index 36a287f077..b03a0ed82c 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc @@ -574,3 +574,11 @@ class ClassWithAttributes { // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacing 2 // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingBeforeFirst 2 // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingAfterLast 2 + +// Issue #3904. +echo 'this line belongs with the #3904 test'; +class Person {public function __construct($name){}} +echo 'this line belongs with the #3904 test'; + +function Foo() {} function bar($name){} +echo 'this line belongs with the #3904 test'; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc.fixed b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc.fixed index ac2df1cb7b..443824ca14 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc.fixed +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc.fixed @@ -656,3 +656,18 @@ class ClassWithAttributes { // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacing 2 // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingBeforeFirst 2 // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingAfterLast 2 + +// Issue #3904. +echo 'this line belongs with the #3904 test'; + + +class Person {public function __construct($name){}} + + +echo 'this line belongs with the #3904 test'; + + +function Foo() {} function bar($name){} + + +echo 'this line belongs with the #3904 test'; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php index 2a3107c75e..307d481d5f 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php @@ -95,6 +95,8 @@ public function getErrorList($testFile='') 553 => 1, 560 => 1, 566 => 1, + 580 => 2, + 583 => 3, ]; case 'FunctionSpacingUnitTest.2.inc': From b23ed18b5a8bce3df926fd554c9dcbfe727c5eeb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 28 Oct 2023 19:55:57 +0200 Subject: [PATCH 107/874] Config::processLongArgument(): fix storing of unknown arguments These arguments should be stored in the `unknown` property. There is no `values` property. Note: the read/write logic is to prevent a `Indirect modification of overloaded property PHP_CodeSniffer\Config::$unknown has no effect` PHP notice. --- CHANGELOG.md | 2 ++ src/Config.php | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 504590d55b..5899e1e894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -161,6 +161,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch - Fixed bug #3906 : Tokenizer/CSS: fixed a bug related to the unsupported slash comment syntax - Thanks to Dan Wallis (@fredden) for the patch +- Fixed bug #3913 : Config stored unknown "long" arguments in a (dynamic) `$values` property + - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) for reviewing quite a few of the PRs for this release. diff --git a/src/Config.php b/src/Config.php index 55c7598f2b..ee50bc79d9 100644 --- a/src/Config.php +++ b/src/Config.php @@ -1232,13 +1232,17 @@ public function processLongArgument($arg, $pos) if ($this->dieOnUnknownArg === false) { $eqPos = strpos($arg, '='); try { + $unknown = $this->unknown; + if ($eqPos === false) { - $this->values[$arg] = $arg; + $unknown[$arg] = $arg; } else { - $value = substr($arg, ($eqPos + 1)); - $arg = substr($arg, 0, $eqPos); - $this->values[$arg] = $value; + $value = substr($arg, ($eqPos + 1)); + $arg = substr($arg, 0, $eqPos); + $unknown[$arg] = $value; } + + $this->unknown = $unknown; } catch (RuntimeException $e) { // Value is not valid, so just ignore it. } From 5f27b94b66f70298789f101bed17b8c9355c99c0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 9 Aug 2023 19:27:05 +0200 Subject: [PATCH 108/874] Generic/OpeningFunctionBraceKernighanRitchie: check spacing before brace for empty functions As things were, when an empty function was detected, the sniff would bow out and not execute the "SpaceBeforeBrace" check. Fixed now. Includes tests. --- CHANGELOG.md | 2 ++ ...eningFunctionBraceKernighanRitchieSniff.php | 18 ++++++++---------- ...ngFunctionBraceKernighanRitchieUnitTest.inc | 4 ++++ ...tionBraceKernighanRitchieUnitTest.inc.fixed | 4 ++++ ...ngFunctionBraceKernighanRitchieUnitTest.php | 2 ++ 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5899e1e894..14029138ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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.Functions.OpeningFunctionBraceKernighanRitchie will now check the spacing before the opening brace for empty functions + - 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 diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php index ca26fcd561..ca259854e7 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php @@ -130,17 +130,15 @@ public function process(File $phpcsFile, $stackPtr) $ignore[] = T_WHITESPACE; $next = $phpcsFile->findNext($ignore, ($openingBrace + 1), null, true); if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) { - if ($next === $tokens[$stackPtr]['scope_closer'] - || $tokens[$next]['code'] === T_CLOSE_TAG + // Only throw this error when this is not an empty function. + if ($next !== $tokens[$stackPtr]['scope_closer'] + && $tokens[$next]['code'] !== T_CLOSE_TAG ) { - // Ignore empty functions. - return; - } - - $error = 'Opening brace must be the last content on the line'; - $fix = $phpcsFile->addFixableError($error, $openingBrace, 'ContentAfterBrace'); - if ($fix === true) { - $phpcsFile->fixer->addNewline($openingBrace); + $error = 'Opening brace must be the last content on the line'; + $fix = $phpcsFile->addFixableError($error, $openingBrace, 'ContentAfterBrace'); + if ($fix === true) { + $phpcsFile->fixer->addNewline($openingBrace); + } } } diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc index f7b3c922e8..6c937a823b 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc @@ -208,3 +208,7 @@ function myFunction($a, $lot, $of, $params) : array { // phpcs:ignore Standard.Category.Sniff -- for reasons. return null; } + +function myFunction() {} +function myFunction() {} // Too many spaces with an empty function. +function myFunction() {} // Too many spaces (tab) with an empty function. diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc.fixed b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc.fixed index 533fb567d2..bfb2283844 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc.fixed @@ -196,3 +196,7 @@ function myFunction($a, $lot, $of, $params) : array { // phpcs:ignore Standard.Category.Sniff -- for reasons. return null; } + +function myFunction() {} +function myFunction() {} // Too many spaces with an empty function. +function myFunction() {} // Too many spaces (tab) with an empty function. diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php index 7cd60a3023..a2b32a8587 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php @@ -52,6 +52,8 @@ public function getErrorList() 191 => 1, 197 => 1, 203 => 1, + 213 => 1, + 214 => 1, ]; }//end getErrorList() From 1c10cba46dc2e790ab52541e29db4901b7c1f3b5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 9 Aug 2023 19:32:42 +0200 Subject: [PATCH 109/874] Generic/OpeningFunctionBraceBsdAllman: check spacing before brace for empty functions As things were, when an empty function was detected, the sniff would bow out and not execute the "BraceIndent" check. Fixed now. Includes tests. --- CHANGELOG.md | 2 ++ .../OpeningFunctionBraceBsdAllmanSniff.php | 16 +++++++--------- .../OpeningFunctionBraceBsdAllmanUnitTest.inc | 7 +++++++ ...eningFunctionBraceBsdAllmanUnitTest.inc.fixed | 7 +++++++ .../OpeningFunctionBraceBsdAllmanUnitTest.php | 2 ++ 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14029138ec..302fa327fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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.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 - PSR2.Classes.PropertyDeclaration now enforces that the readonly modifier comes after the visibility modifier diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php index de2c083175..d60ab61e7b 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php @@ -170,15 +170,13 @@ public function process(File $phpcsFile, $stackPtr) $ignore[] = T_WHITESPACE; $next = $phpcsFile->findNext($ignore, ($openingBrace + 1), null, true); if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) { - if ($next === $tokens[$stackPtr]['scope_closer']) { - // Ignore empty functions. - return; - } - - $error = 'Opening brace must be the last content on the line'; - $fix = $phpcsFile->addFixableError($error, $openingBrace, 'ContentAfterBrace'); - if ($fix === true) { - $phpcsFile->fixer->addNewline($openingBrace); + // Only throw this error when this is not an empty function. + if ($next !== $tokens[$stackPtr]['scope_closer']) { + $error = 'Opening brace must be the last content on the line'; + $fix = $phpcsFile->addFixableError($error, $openingBrace, 'ContentAfterBrace'); + if ($fix === true) { + $phpcsFile->fixer->addNewline($openingBrace); + } } } diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc index 3ae3b1ed0b..146f9cf6dd 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc @@ -261,3 +261,10 @@ class Issue3357WithComment // code here. } } + + function myFunction() + {} + function myFunction() + {} // Too many spaces indent with an empty function. + function myFunction() +{} // Too little spaces indent with an empty function. diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc.fixed b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc.fixed index f164c4934e..ac4929d7d5 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc.fixed @@ -278,3 +278,10 @@ class Issue3357WithComment // code here. } } + + function myFunction() + {} + function myFunction() + {} // Too many spaces indent with an empty function. + function myFunction() + {} // Too little spaces indent with an empty function. diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php index 6d4abebaad..c8f218dbdc 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php @@ -61,6 +61,8 @@ public function getErrorList() 244 => 1, 252 => 1, 260 => 1, + 268 => 1, + 270 => 1, ]; }//end getErrorList() From fd3fdb573ef21d585d9784c19aa444a8d6a3fc8c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 23 Nov 2022 17:04:25 +0100 Subject: [PATCH 110/874] Generic/RequireStrictTypes: add extra tests These tests safeguard the following, which is already handled correctly by the sniff: * Execution directives are case-insensitive in PHP. * The sniff should ignore docblocks at the top of the file. --- .../Generic/Tests/PHP/RequireStrictTypesUnitTest.3.inc | 5 +++++ .../Generic/Tests/PHP/RequireStrictTypesUnitTest.4.inc | 10 ++++++++++ .../Generic/Tests/PHP/RequireStrictTypesUnitTest.php | 7 ++++--- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.3.inc create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.4.inc diff --git a/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.3.inc b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.3.inc new file mode 100644 index 0000000000..ac5fc1d5bb --- /dev/null +++ b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.3.inc @@ -0,0 +1,5 @@ + 1]; + + default: return []; } - return [1 => 1]; - }//end getErrorList() From f9998fe486630f0b69871476d56dac501ac8a51e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 23 Nov 2022 18:40:12 +0100 Subject: [PATCH 111/874] Generic/RequireStrictTypes: bug fix - limit token search to the statement While hopefully unlikely in real life, the sniff should handle parse errors correctly. Along the same lines, live coding should be handled correctly and a `declare()` statement should only be examined once the statement has been completed. This updates the sniff to handle both situations correctly. Without these fixes, no error would be thrown in test case file 5 or 6 (false negative), while an error would be thrown in test case file 7 (false positive). Includes unit tests. Includes minor efficiency tweak to only start looking for a "next" token _after_ the current token. --- CHANGELOG.md | 2 ++ .../Sniffs/PHP/RequireStrictTypesSniff.php | 31 +++++++++++++------ .../PHP/RequireStrictTypesUnitTest.5.inc | 6 ++++ .../PHP/RequireStrictTypesUnitTest.6.inc | 4 +++ .../PHP/RequireStrictTypesUnitTest.7.inc | 4 +++ .../Tests/PHP/RequireStrictTypesUnitTest.php | 2 ++ 6 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.5.inc create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.6.inc create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.7.inc diff --git a/CHANGELOG.md b/CHANGELOG.md index 302fa327fa..21a3585f91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -109,6 +109,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Volker Dusch (@edorian) 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 #3722 : Potential "Uninitialized string offset 1" in octal notation backfill - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch - Fixed bug #3728 : PHP 8.2 | PSR1/SideEffects: allow for readonly classes diff --git a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php index 0e3fb6dfe3..c4a0ddf294 100644 --- a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php @@ -11,6 +11,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; class RequireStrictTypesSniff implements Sniff { @@ -40,19 +41,31 @@ public function register() public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $declare = $phpcsFile->findNext(T_DECLARE, $stackPtr); - $found = false; + $declare = $phpcsFile->findNext(T_DECLARE, ($stackPtr + 1)); + + $found = false; if ($declare !== false) { - $nextString = $phpcsFile->findNext(T_STRING, $declare); + if (isset($tokens[$declare]['parenthesis_opener'], $tokens[$declare]['parenthesis_closer']) === false) { + // Live coding, ignore for now. + return $phpcsFile->numTokens; + } - if ($nextString !== false) { - if (strtolower($tokens[$nextString]['content']) === 'strict_types') { - // There is a strict types declaration. - $found = true; - } + $next = $phpcsFile->findNext( + Tokens::$emptyTokens, + ($tokens[$declare]['parenthesis_opener'] + 1), + $tokens[$declare]['parenthesis_closer'], + true + ); + + if ($next !== false + && $tokens[$next]['code'] === T_STRING + && strtolower($tokens[$next]['content']) === 'strict_types' + ) { + // There is a strict types declaration. + $found = true; } - } + }//end if if ($found === false) { $error = 'Missing required strict_types declaration'; diff --git a/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.5.inc b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.5.inc new file mode 100644 index 0000000000..b57a4a147d --- /dev/null +++ b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.5.inc @@ -0,0 +1,6 @@ + 1]; default: From 9fa78c28e11067f826f7d111cf4e283c3b0e97da Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 24 Nov 2022 23:15:57 +0100 Subject: [PATCH 112/874] Generic/RequireStrictTypes: bug fix - allow for multi directive statements PHP allows for multiple directives to be passed in one `declare()` statement. The sniff, however, did not allow for this, which could lead to false positives. Fixed now. Includes unit tests. --- CHANGELOG.md | 2 ++ .../Sniffs/PHP/RequireStrictTypesSniff.php | 35 +++++++++++-------- .../PHP/RequireStrictTypesUnitTest.10.inc | 5 +++ .../PHP/RequireStrictTypesUnitTest.8.inc | 5 +++ .../PHP/RequireStrictTypesUnitTest.9.inc | 5 +++ .../Tests/PHP/RequireStrictTypesUnitTest.php | 1 + 6 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.10.inc create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.8.inc create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.9.inc diff --git a/CHANGELOG.md b/CHANGELOG.md index 21a3585f91..230a0cf4d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,6 +111,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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 #3728 : PHP 8.2 | PSR1/SideEffects: allow for readonly classes diff --git a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php index c4a0ddf294..c4e292480d 100644 --- a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php @@ -51,20 +51,27 @@ public function process(File $phpcsFile, $stackPtr) return $phpcsFile->numTokens; } - $next = $phpcsFile->findNext( - Tokens::$emptyTokens, - ($tokens[$declare]['parenthesis_opener'] + 1), - $tokens[$declare]['parenthesis_closer'], - true - ); - - if ($next !== false - && $tokens[$next]['code'] === T_STRING - && strtolower($tokens[$next]['content']) === 'strict_types' - ) { - // There is a strict types declaration. - $found = true; - } + $next = $tokens[$declare]['parenthesis_opener']; + + do { + $next = $phpcsFile->findNext( + Tokens::$emptyTokens, + ($next + 1), + $tokens[$declare]['parenthesis_closer'], + true + ); + + if ($next !== false + && $tokens[$next]['code'] === T_STRING + && strtolower($tokens[$next]['content']) === 'strict_types' + ) { + // There is a strict types declaration. + $found = true; + break; + } + + $next = $phpcsFile->findNext(T_COMMA, ($next + 1), $tokens[$declare]['parenthesis_closer']); + } while ($next !== false && $next < $tokens[$declare]['parenthesis_closer']); }//end if if ($found === false) { diff --git a/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.10.inc b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.10.inc new file mode 100644 index 0000000000..1d12ccbf8d --- /dev/null +++ b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.10.inc @@ -0,0 +1,5 @@ + 1]; default: From 3ff23a336a9501063629943eb34b1f1f937f92ea Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 23 Nov 2022 18:45:06 +0100 Subject: [PATCH 113/874] Generic/RequireStrictTypes: add warning for when value is 0 Strict types is disabled when the value for the `strict_types` directive is `0`. As this sniff is supposed to be about enforcing the use of `strict_types`, `strict_types` declarations which turn the feature off should be flagged as well. Implemented with a separate error code to allow for selectively turning this warning off. Includes dedicated tests. --- CHANGELOG.md | 3 +++ .../Sniffs/PHP/RequireStrictTypesSniff.php | 19 +++++++++++++++++++ .../PHP/RequireStrictTypesUnitTest.11.inc | 5 +++++ .../RequireStrictTypesUnitTest.11.inc.fixed | 5 +++++ .../PHP/RequireStrictTypesUnitTest.12.inc | 5 +++++ .../RequireStrictTypesUnitTest.12.inc.fixed | 5 +++++ .../PHP/RequireStrictTypesUnitTest.13.inc | 3 +++ .../PHP/RequireStrictTypesUnitTest.14.inc | 5 +++++ .../RequireStrictTypesUnitTest.14.inc.fixed | 5 +++++ .../PHP/RequireStrictTypesUnitTest.15.inc | 5 +++++ .../RequireStrictTypesUnitTest.15.inc.fixed | 5 +++++ .../Tests/PHP/RequireStrictTypesUnitTest.php | 16 ++++++++++++---- 12 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.11.inc create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.11.inc.fixed create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.12.inc create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.12.inc.fixed create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.13.inc create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.14.inc create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.14.inc.fixed create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.15.inc create mode 100644 src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.15.inc.fixed diff --git a/CHANGELOG.md b/CHANGELOG.md index 230a0cf4d6..0296bfd63d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,9 @@ The file documents changes to the PHP_CodeSniffer project. - 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.PHP.RequireStrictTypes has a 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 - 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 diff --git a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php index c4e292480d..1e0dc9de59 100644 --- a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php @@ -77,6 +77,25 @@ public function process(File $phpcsFile, $stackPtr) if ($found === false) { $error = 'Missing required strict_types declaration'; $phpcsFile->addError($error, $stackPtr, 'MissingDeclaration'); + + return $phpcsFile->numTokens; + } + + // Strict types declaration found, make sure strict types is enabled. + $skip = Tokens::$emptyTokens; + $skip[] = T_EQUAL; + $valuePtr = $phpcsFile->findNext($skip, ($next + 1), null, true); + + if ($valuePtr !== false + && $tokens[$valuePtr]['code'] === T_LNUMBER + && $tokens[$valuePtr]['content'] === '0' + ) { + $error = 'Required strict_types declaration found, but strict types is disabled. Set the value to 1 to enable'; + $fix = $phpcsFile->addFixableWarning($error, $valuePtr, 'Disabled'); + + if ($fix === true) { + $phpcsFile->fixer->replaceToken($valuePtr, '1'); + } } // Skip the rest of the file so we don't pick up additional diff --git a/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.11.inc b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.11.inc new file mode 100644 index 0000000000..67e21ba0ed --- /dev/null +++ b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.11.inc @@ -0,0 +1,5 @@ + */ - public function getWarningList() + public function getWarningList($testFile='') { - return []; + switch ($testFile) { + case 'RequireStrictTypesUnitTest.11.inc': + case 'RequireStrictTypesUnitTest.12.inc': + case 'RequireStrictTypesUnitTest.14.inc': + case 'RequireStrictTypesUnitTest.15.inc': + return [3 => 1]; + + default: + return []; + } }//end getWarningList() From ad5421c0aec2f4cef2148c4a4a5f867a7cae3668 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 1 Jul 2022 15:56:22 +0200 Subject: [PATCH 114/874] Generic/IncrementDecrementSpacing: handle more situations The `Generic.WhiteSpace.IncrementDecrementSpacing` sniff, so far, only handled incrementors/decrementors when they were directly before/after the variable they apply to. This commit enhances the sniff to also allow for finding superfluous whitespace when incrementing/decrementing a property or an array item. Includes unit tests. --- CHANGELOG.md | 2 ++ .../IncrementDecrementSpacingSniff.php | 8 +++-- .../IncrementDecrementSpacingUnitTest.inc | 20 +++++++++++ ...ncrementDecrementSpacingUnitTest.inc.fixed | 20 +++++++++++ .../IncrementDecrementSpacingUnitTest.php | 33 +++++++++++++------ 5 files changed, 71 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0296bfd63d..6dea0c2182 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,8 @@ The file documents changes to the PHP_CodeSniffer project. - Generic.PHP.RequireStrictTypes has a 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 +- 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 diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php index bde065e1c2..95ba3d82c2 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php @@ -63,7 +63,8 @@ public function process(File $phpcsFile, $stackPtr) // Is this a pre-increment/decrement ? $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($nextNonEmpty !== false - && (($phpcsFile->tokenizerType === 'PHP' && $tokens[$nextNonEmpty]['code'] === T_VARIABLE) + && (($phpcsFile->tokenizerType === 'PHP' + && ($tokens[$nextNonEmpty]['code'] === T_VARIABLE || $tokens[$nextNonEmpty]['code'] === T_STRING)) || ($phpcsFile->tokenizerType === 'JS' && $tokens[$nextNonEmpty]['code'] === T_STRING)) ) { if ($nextNonEmpty === ($stackPtr + 1)) { @@ -116,7 +117,10 @@ public function process(File $phpcsFile, $stackPtr) // Is this a post-increment/decrement ? $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($prevNonEmpty !== false - && (($phpcsFile->tokenizerType === 'PHP' && $tokens[$prevNonEmpty]['code'] === T_VARIABLE) + && (($phpcsFile->tokenizerType === 'PHP' + && ($tokens[$prevNonEmpty]['code'] === T_VARIABLE + || $tokens[$prevNonEmpty]['code'] === T_STRING + || $tokens[$prevNonEmpty]['code'] === T_CLOSE_SQUARE_BRACKET)) || ($phpcsFile->tokenizerType === 'JS' && $tokens[$prevNonEmpty]['code'] === T_STRING)) ) { if ($prevNonEmpty === ($stackPtr - 1)) { diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc index 22c611be92..b674466b1d 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc @@ -15,3 +15,23 @@ $i /*comment*/ --; $i++; $i ++; $i /*comment*/ ++; + +// Handle properties and array access too. +$i['key']++; +$i['key'] ++; +$i['key']['id']++; +$i['key']['id'] ++; + +$obj->prop++; +$obj->prop ++; +$obj?->prop ++; + +$obj->obj->prop++; +$obj->obj->prop ++; +$obj?->obj->prop ++; + +$obj->prop['key']++; +$obj->prop['key'] ++; + +--ClassName::$prop; +-- ClassName::$prop; diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed index 7cf0ab81e9..1049e7e043 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed @@ -14,3 +14,23 @@ $i /*comment*/ --; $i++; $i++; $i /*comment*/ ++; + +// Handle properties and array access too. +$i['key']++; +$i['key']++; +$i['key']['id']++; +$i['key']['id']++; + +$obj->prop++; +$obj->prop++; +$obj?->prop++; + +$obj->obj->prop++; +$obj->obj->prop++; +$obj?->obj->prop++; + +$obj->prop['key']++; +$obj->prop['key']++; + +--ClassName::$prop; +--ClassName::$prop; diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php index 1136bda4e9..9e7644f1f1 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php @@ -27,19 +27,32 @@ class IncrementDecrementSpacingUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='IncrementDecrementSpacingUnitTest.inc') { + $errors = [ + 5 => 1, + 6 => 1, + 8 => 1, + 10 => 1, + 13 => 1, + 14 => 1, + 16 => 1, + 17 => 1, + ]; + switch ($testFile) { case 'IncrementDecrementSpacingUnitTest.inc': + $errors[21] = 1; + $errors[23] = 1; + $errors[26] = 1; + $errors[27] = 1; + $errors[30] = 1; + $errors[31] = 1; + $errors[34] = 1; + $errors[37] = 1; + + return $errors; + case 'IncrementDecrementSpacingUnitTest.js': - return [ - 5 => 1, - 6 => 1, - 8 => 1, - 10 => 1, - 13 => 1, - 14 => 1, - 16 => 1, - 17 => 1, - ]; + return $errors; default: return []; From 782bf7d51cc6d1131c6785c60c2bacc6469c781c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 19 Jul 2023 03:06:15 +0200 Subject: [PATCH 115/874] PSR12.Traits.UseDeclaration: fix typo in error code The `processUseStatement()` method checking single-line trait `use` statements checks the spacing after the `use` keyword, but the error did not have the correct error code. --- CHANGELOG.md | 3 +++ src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dea0c2182..f3b3c0f031 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -164,6 +164,9 @@ The file documents changes to the PHP_CodeSniffer project. - 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 #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 diff --git a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php index 109e23e9e6..78125cb7e1 100644 --- a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php @@ -655,7 +655,7 @@ protected function processUseStatement(File $phpcsFile, $stackPtr) $error = 'Expected 1 space after USE in trait import statement; %s found'; if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { $data = ['0']; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterAs', $data); + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterUse', $data); if ($fix === true) { $phpcsFile->fixer->addContent($stackPtr, ' '); } @@ -668,7 +668,7 @@ protected function processUseStatement(File $phpcsFile, $stackPtr) } $data = [$found]; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterAs', $data); + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterUse', $data); if ($fix === true) { if ($found === 'newline') { $phpcsFile->fixer->beginChangeset(); From 5e282de04ba0b526ceb85fb6f6023164aa72cb18 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 19 Jul 2023 03:13:35 +0200 Subject: [PATCH 116/874] PSR12.Traits.UseDeclaration: check spacing after `use` keyword for multi-line statements While the `processUseStatement()` method checking single-line trait `use` statements would check the spacing after the `use` keyword, the `processUseGroup()` method checking multi-line trait `use` statements did not execute that same check, while the rule applies to both single- as well as multi-line `use` statements. By moving the check for the spacing after the `use` keyword to the `process()` method, it will now be executed for both situations. Tested by adjusting a pre-existing test. --- CHANGELOG.md | 2 + .../Sniffs/Traits/UseDeclarationSniff.php | 64 +++++++++---------- .../Tests/Traits/UseDeclarationUnitTest.inc | 2 +- .../Tests/Traits/UseDeclarationUnitTest.php | 2 +- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3b3c0f031..7b981ccf6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -167,6 +167,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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 diff --git a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php index 78125cb7e1..f9fb808a9b 100644 --- a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php @@ -177,6 +177,38 @@ public function process(File $phpcsFile, $stackPtr) }//end if }//end if + $error = 'Expected 1 space after USE in trait import statement; %s found'; + if ($tokens[($useToken + 1)]['code'] !== T_WHITESPACE) { + $data = ['0']; + $fix = $phpcsFile->addFixableError($error, $useToken, 'SpaceAfterUse', $data); + if ($fix === true) { + $phpcsFile->fixer->addContent($useToken, ' '); + } + } else if ($tokens[($useToken + 1)]['content'] !== ' ') { + $next = $phpcsFile->findNext(T_WHITESPACE, ($useToken + 1), null, true); + if ($tokens[$next]['line'] !== $tokens[$useToken]['line']) { + $found = 'newline'; + } else { + $found = $tokens[($useToken + 1)]['length']; + } + + $data = [$found]; + $fix = $phpcsFile->addFixableError($error, $useToken, 'SpaceAfterUse', $data); + if ($fix === true) { + if ($found === 'newline') { + $phpcsFile->fixer->beginChangeset(); + for ($x = ($useToken + 1); $x < $next; $x++) { + $phpcsFile->fixer->replaceToken($x, ''); + } + + $phpcsFile->fixer->addContent($useToken, ' '); + $phpcsFile->fixer->endChangeset(); + } else { + $phpcsFile->fixer->replaceToken(($useToken + 1), ' '); + } + } + }//end if + // Check the formatting of the statement. if (isset($tokens[$useToken]['scope_opener']) === true) { $this->processUseGroup($phpcsFile, $useToken); @@ -652,38 +684,6 @@ protected function processUseStatement(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $error = 'Expected 1 space after USE in trait import statement; %s found'; - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { - $data = ['0']; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterUse', $data); - if ($fix === true) { - $phpcsFile->fixer->addContent($stackPtr, ' '); - } - } else if ($tokens[($stackPtr + 1)]['content'] !== ' ') { - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { - $found = 'newline'; - } else { - $found = $tokens[($stackPtr + 1)]['length']; - } - - $data = [$found]; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterUse', $data); - if ($fix === true) { - if ($found === 'newline') { - $phpcsFile->fixer->beginChangeset(); - for ($x = ($stackPtr + 1); $x < $next; $x++) { - $phpcsFile->fixer->replaceToken($x, ''); - } - - $phpcsFile->fixer->addContent($stackPtr, ' '); - $phpcsFile->fixer->endChangeset(); - } else { - $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); - } - } - }//end if - $next = $phpcsFile->findNext([T_COMMA, T_SEMICOLON], ($stackPtr + 1)); if ($next !== false && $tokens[$next]['code'] === T_COMMA) { $error = 'Each imported trait must have its own "use" import statement'; diff --git a/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.inc b/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.inc index c8ad746a73..152121cf1e 100644 --- a/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.inc +++ b/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.inc @@ -54,7 +54,7 @@ class ClassName7 class ClassName8 { - use A , B, + use A , B, C { diff --git a/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php index 5c7e237df6..2b895e1973 100644 --- a/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php @@ -30,7 +30,7 @@ public function getErrorList() 29 => 2, 30 => 1, 42 => 1, - 57 => 3, + 57 => 4, 59 => 3, 61 => 1, 63 => 5, From b38787574a7ba921c6b79a4b1d8e00d69addb6b2 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 12 Oct 2023 02:56:07 +0200 Subject: [PATCH 117/874] Squiz/NonExecutableCode: make sniff more code style independent When determining whether a `return` statement is the last code token in a function body, comments should be ignored, but weren't. Fixed now. Includes tests. --- CHANGELOG.md | 2 ++ .../Squiz/Sniffs/PHP/NonExecutableCodeSniff.php | 4 ++-- .../Tests/PHP/NonExecutableCodeUnitTest.1.inc | 17 +++++++++++++++++ .../Tests/PHP/NonExecutableCodeUnitTest.php | 2 ++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b981ccf6d..6f0c5c5deb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -175,6 +175,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to @simonsan for the patch - 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: fixed a bug related to the unsupported slash comment syntax diff --git a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index 7bcb89dcfe..202c338ebe 100644 --- a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -114,9 +114,9 @@ public function process(File $phpcsFile, $stackPtr) } if ($tokens[$stackPtr]['code'] === T_RETURN) { - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($tokens[$next]['code'] === T_SEMICOLON) { - $next = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true); + $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true); if ($tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) { // If this is the closing brace of a function // then this return statement doesn't return anything diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc index 051b6c6b11..347868d404 100644 --- a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc @@ -396,5 +396,22 @@ function executionStoppingThrowExpressionsE() { echo 'non-executable'; } +function returnNotRequiredIgnoreCommentsA() +{ + if ($something === TRUE) { + return /*comment*/; + } + + echo 'foo'; + return /*comment*/; +} + +function returnNotRequiredIgnoreCommentsB() +{ + echo 'foo'; + return; + /*comment*/ +} + // Intentional syntax error. return array_map( diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php index 9097c36196..25cc7211cb 100644 --- a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php @@ -82,6 +82,8 @@ public function getWarningList($testFile='') 386 => 1, 391 => 1, 396 => 1, + 406 => 1, + 412 => 1, ]; case 'NonExecutableCodeUnitTest.2.inc': From fb9447fe08b5942144c0aac46e6670ad8fccd65f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 12 Oct 2023 03:02:31 +0200 Subject: [PATCH 118/874] Squiz/NonExecutableCode: flag redundant `return` statements in closures too A return statement which doesn't return a value at the end of a function body would be flagged as "not required" for named functions, but not so for anonymous functions. Fixed now. Includes tests. --- CHANGELOG.md | 2 ++ src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php | 4 +++- .../Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc | 6 ++++++ src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f0c5c5deb..986dfa413f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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 - Thanks to @Daimona for the patch +- 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 -e (explain) command will now list sniffs in natural order diff --git a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index 202c338ebe..74e00eab47 100644 --- a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -122,7 +122,9 @@ public function process(File $phpcsFile, $stackPtr) // then this return statement doesn't return anything // and is not required anyway. $owner = $tokens[$next]['scope_condition']; - if ($tokens[$owner]['code'] === T_FUNCTION) { + if ($tokens[$owner]['code'] === T_FUNCTION + || $tokens[$owner]['code'] === T_CLOSURE + ) { $warning = 'Empty return statement not required here'; $phpcsFile->addWarning($warning, $stackPtr, 'ReturnNotRequired'); return; diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc index 347868d404..2efcc78e57 100644 --- a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc @@ -413,5 +413,11 @@ function returnNotRequiredIgnoreCommentsB() /*comment*/ } +$closure = function () +{ + echo 'foo'; + return; // This return should be flagged as not required. +}; + // Intentional syntax error. return array_map( diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php index 25cc7211cb..30ccad4d26 100644 --- a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php @@ -84,6 +84,7 @@ public function getWarningList($testFile='') 396 => 1, 406 => 1, 412 => 1, + 419 => 1, ]; case 'NonExecutableCodeUnitTest.2.inc': From 632600bc8287c16029d09c29f35e0d742d42fa45 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 9 Jun 2023 01:00:37 +0200 Subject: [PATCH 119/874] Squiz/NonExecutableCode: fold duplicate code Follow up on commits 0e10f432e18a97135a7ec7ecbe61ad9a8d2e4231 and 01754d9c1a622def2f7d04747ab7ebcce767aef4, which both deal with fixing bugs where the sniff would not handle if/elseif/else conditions without curly braces correctly. This commit merges the two near duplicate code blocks, which the above mentioned commits introduced, each containing code doing essentially the same thing. Also note that `T_ELSE` is handled separately now as `else` does not take parentheses and can therefore not be a parenthesis owner. This change is already covered by pre-existing tests. --- .../Sniffs/PHP/NonExecutableCodeSniff.php | 37 ++++--------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index 74e00eab47..f4bffff75a 100644 --- a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -94,21 +94,13 @@ public function process(File $phpcsFile, $stackPtr) } }//end if - // Check if this token is actually part of a one-line IF or ELSE statement. - for ($i = ($stackPtr - 1); $i > 0; $i--) { - if ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS) { - $i = $tokens[$i]['parenthesis_opener']; - continue; - } else if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) { - continue; - } - - break; - } - - if ($tokens[$i]['code'] === T_IF - || $tokens[$i]['code'] === T_ELSE - || $tokens[$i]['code'] === T_ELSEIF + // This token may be part of an inline condition. + // If we find a closing parenthesis that belongs to a condition, + // or an "else", we should ignore this token. + if ($tokens[$prev]['code'] === T_ELSE + || (isset($tokens[$prev]['parenthesis_owner']) === true + && ($tokens[$tokens[$prev]['parenthesis_owner']]['code'] === T_IF + || $tokens[$tokens[$prev]['parenthesis_owner']]['code'] === T_ELSEIF)) ) { return; } @@ -176,21 +168,6 @@ public function process(File $phpcsFile, $stackPtr) }//end if }//end if - // This token may be part of an inline condition. - // If we find a closing parenthesis that belongs to a condition - // we should ignore this token. - if (isset($tokens[$prev]['parenthesis_owner']) === true) { - $owner = $tokens[$prev]['parenthesis_owner']; - $ignore = [ - T_IF => true, - T_ELSE => true, - T_ELSEIF => true, - ]; - if (isset($ignore[$tokens[$owner]['code']]) === true) { - return; - } - } - $ourConditions = array_keys($tokens[$stackPtr]['conditions']); if (empty($ourConditions) === false) { From f5dec4c45b8e43c92425d4a14a3e538b7186d8db Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 19 Nov 2022 01:52:02 +0100 Subject: [PATCH 120/874] Generic/UnusedFunctionParameter: ignore class context for closures/arrow functions As things were, if a closure or arrow function declared within a class which extends or implements would have an unused function parameter, it would get the `InExtendedClass` or `InImplementedInterface` addition in the error code. Those additions were only intended for function declarations where the declaration would potentially be overloading a method from a parent and would have to comply with the method signature of the method in the parent class/interface. This could lead to underreporting if a standard explicitly excludes the error codes contain `InExtendedClass` and/or `InImplementedInterface`. Fixed now. Includes additional unit test, though the tests don't safeguard this much as they don't check the error codes of the messages thrown. The change can be tested manually by running the new tests against `master`, which will show: ``` 163 | WARNING | The method parameter $d is never used (Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed) 172 | WARNING | The method parameter $d is never used | | (Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed) ``` ... while with the change in this commit, this will be fixed to: ``` 163 | WARNING | The method parameter $d is never used (Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed) 172 | WARNING | The method parameter $d is never used (Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed) ``` --- CHANGELOG.md | 2 ++ .../UnusedFunctionParameterSniff.php | 19 ++++++++++-------- .../UnusedFunctionParameterUnitTest.inc | 20 +++++++++++++++++++ .../UnusedFunctionParameterUnitTest.php | 2 ++ 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 986dfa413f..b5eca8ef86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -114,6 +114,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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 #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 diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php index ac6e599a03..bf6082bb3c 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php @@ -69,14 +69,17 @@ public function process(File $phpcsFile, $stackPtr) $errorCode = 'Found'; $implements = false; $extends = false; - $classPtr = $phpcsFile->getCondition($stackPtr, T_CLASS); - if ($classPtr !== false) { - $implements = $phpcsFile->findImplementedInterfaceNames($classPtr); - $extends = $phpcsFile->findExtendedClassName($classPtr); - if ($extends !== false) { - $errorCode .= 'InExtendedClass'; - } else if ($implements !== false) { - $errorCode .= 'InImplementedInterface'; + + if ($token['code'] === T_FUNCTION) { + $classPtr = $phpcsFile->getCondition($stackPtr, T_CLASS); + if ($classPtr !== false) { + $implements = $phpcsFile->findImplementedInterfaceNames($classPtr); + $extends = $phpcsFile->findExtendedClassName($classPtr); + if ($extends !== false) { + $errorCode .= 'InExtendedClass'; + } else if ($implements !== false) { + $errorCode .= 'InImplementedInterface'; + } } } diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc index d800d690fd..3605fdfc48 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc @@ -152,3 +152,23 @@ class ConstructorPropertyPromotionWithContentInMethod { } $found = in_array_cb($needle, $haystack, fn($array, $needle) => $array[2] === $needle); + + +/* + * Don't adjust the error code for closures and arrow functions in extended classes/classes implementing interfaces. + */ +class MyExtendedClass extends SomeClass { + public function something($a, $b) { + $c = $a + $b; + $closure = function ($c, $d) { + return $c * 2; + }; + } +} + +class MyExtendedClass implements SomeInterface { + public function something($a, $b) { + $c = $a + $b; + $fn = fn($c, $d) => $c[2]; + } +} diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php index b6384888e5..5a7067ebe3 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php @@ -50,6 +50,8 @@ public function getWarningList() 117 => 1, 121 => 2, 125 => 2, + 163 => 1, + 172 => 1, ]; }//end getWarningList() From 78ea17b8a050adce5f6c3082a3e2c4b0cea2baac Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 19 Nov 2022 02:13:54 +0100 Subject: [PATCH 121/874] Generic/UnusedFunctionParameter: ignore magic methods The function signature of magic methods - with the exception of `__construct()` and `__invoke()` - is dictated by PHP and unused parameters cannot be removed, which means that the warnings for these can never be resolved, only ignored via annotations. This commit fixes this by checking whether a function is a magic method and if so, bowing out. Includes unit tests. Note: while not all magic methods take arguments, I'm still including the (nearly) full list of magic methods in the property as the other magic methods can be ignored anyway (no arguments). --- CHANGELOG.md | 2 + .../UnusedFunctionParameterSniff.php | 40 ++++++++- .../UnusedFunctionParameterUnitTest.inc | 87 +++++++++++++++++-- .../UnusedFunctionParameterUnitTest.php | 4 + 4 files changed, 126 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5eca8ef86..c83cef690f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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 diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php index bf6082bb3c..70247c263d 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php @@ -30,6 +30,32 @@ class UnusedFunctionParameterSniff implements Sniff */ public $ignoreTypeHints = []; + /** + * A list of all PHP magic methods with fixed method signatures. + * + * Note: `__construct()` and `__invoke()` are excluded on purpose + * as their method signature is not fixed. + * + * @var array + */ + private $magicMethods = [ + '__destruct' => true, + '__call' => true, + '__callstatic' => true, + '__get' => true, + '__set' => true, + '__isset' => true, + '__unset' => true, + '__sleep' => true, + '__wakeup' => true, + '__serialize' => true, + '__unserialize' => true, + '__tostring' => true, + '__set_state' => true, + '__clone' => true, + '__debuginfo' => true, + ]; + /** * Returns an array of tokens this test wants to listen for. @@ -71,8 +97,18 @@ public function process(File $phpcsFile, $stackPtr) $extends = false; if ($token['code'] === T_FUNCTION) { - $classPtr = $phpcsFile->getCondition($stackPtr, T_CLASS); + $classPtr = $phpcsFile->getCondition($stackPtr, T_CLASS); if ($classPtr !== false) { + // Check for magic methods and ignore these as the method signature cannot be changed. + $methodName = $phpcsFile->getDeclarationName($stackPtr); + if (empty($methodName) === false) { + $methodNameLc = strtolower($methodName); + if (isset($this->magicMethods[$methodNameLc]) === true) { + return; + } + } + + // Check for extends/implements and adjust the error code when found. $implements = $phpcsFile->findImplementedInterfaceNames($classPtr); $extends = $phpcsFile->findExtendedClassName($classPtr); if ($extends !== false) { @@ -81,7 +117,7 @@ public function process(File $phpcsFile, $stackPtr) $errorCode .= 'InImplementedInterface'; } } - } + }//end if $params = []; $methodParams = $phpcsFile->getMethodParameters($stackPtr); diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc index 3605fdfc48..154f03157b 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc @@ -44,13 +44,13 @@ HERE; $x = $parameter; // This line must be immediately after the HERE; with no intervening blank lines. $tango = << $c[2]; } } + + +/** + * Magic methods must match the function signature dictated by PHP. + * Flagging unused parameters leads to notices which cannot be solved. + */ +class MagicMethodsWithParams { + public function __set(string $name, mixed $value) { + // Forbid dynamic properties & overloading inaccessible properties. + throw new RuntimeException('Forbidden'); + } + + public function __get(string $name) { + throw new RuntimeException('Forbidden'); + } + + public function __isset(string $name) { + throw new RuntimeException('Forbidden'); + } + + public function __unset(string $name) { + throw new RuntimeException('Forbidden'); + } + + public function __unserialize( array $data ) { + // Prevent unserializing from a stored representation of the object for security reasons. + $this->instance = new self(); + } + + public static function __set_state(array $properties) { + return new self(); + } + + public function __call(string $name, array $arguments) { + if (method_exists($this, $name)) { + // None of the methods which can be called in this class take arguments, so not passing them. + return $this->$name(); + } + } + + public static function __callStatic(string $name, array $arguments) { + if (method_exists($this, $name)) { + // None of the methods which can be called in this class take arguments, so not passing them. + return self::$name(); + } + } +} + +/** + * Unused parameters in magic methods which have flexible function signatures should still be flagged. + */ +class MagicMethodsWithParamsNotDictatedByPHP { + public $foo; + public function __construct($foo, $bar, $baz) { + $this->foo = $foo; + } + + public function __invoke($foo, $bar, $baz) { + $this->foo = $foo; + } +} + +/** + * Unused parameters in magic methods which have flexible function signatures + * where the method potentially overloads a parent method should still be flagged, + * but should use the `FoundInExtendedClassAfterLastUsed` error code. + */ +class MagicMethodsWithParamsNotDictatedByPHPInChildClass extends SomeParent{ + public $foo; + public function __construct($foo, $bar, $baz) { + $this->foo = $foo; + } + + public function __invoke($foo, $bar, $baz) { + $this->foo = $foo; + } +} diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php index 5a7067ebe3..2f3aab80be 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php @@ -52,6 +52,10 @@ public function getWarningList() 125 => 2, 163 => 1, 172 => 1, + 228 => 2, + 232 => 2, + 244 => 2, + 248 => 2, ]; }//end getWarningList() From 57c40882a0451ed3098f0fe9acd3d893bbb98eb7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 17 Sep 2022 18:59:16 +0200 Subject: [PATCH 122/874] PEAR/FunctionCallSignature: minor tweaks Minor defensive coding and documentation improvements + an additional unit test. --- .../PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php | 7 +++++-- .../PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc | 7 +++++++ .../Functions/FunctionCallSignatureUnitTest.inc.fixed | 7 +++++++ .../PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php | 2 ++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php index 594325ec30..30e0f67aea 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php @@ -340,7 +340,8 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $ // call itself is, so we can work out how far to // indent the arguments. $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true); - if ($tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING + if ($first !== false + && $tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING && $tokens[($first - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING ) { // We are in a multi-line string, so find the start and use @@ -386,8 +387,10 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $ $fix = $phpcsFile->addFixableError($error, $first, 'OpeningIndent', $data); if ($fix === true) { + // Set adjustment for use later to determine whether argument indentation is correct when fixing. $adjustment = ($functionIndent - $foundFunctionIndent); - $padding = str_repeat(' ', $functionIndent); + + $padding = str_repeat(' ', $functionIndent); if ($foundFunctionIndent === 0) { $phpcsFile->fixer->addContentBefore($first, $padding); } else if ($tokens[$first]['code'] === T_INLINE_HTML) { diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc index 612748fedf..fddd3cba18 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc @@ -567,3 +567,10 @@ content

+ + + + + diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed index 00226de562..1c52523075 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed @@ -582,3 +582,10 @@ content

+ + + + + diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php index cebb7a10ea..4e0eeffb20 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php @@ -134,6 +134,8 @@ public function getErrorList($testFile='FunctionCallSignatureUnitTest.inc') 559 => 1, 567 => 1, 568 => 1, + 573 => 1, + 574 => 1, ]; }//end getErrorList() From b5b07c63598961163b97c99dd6ae2add09e15b78 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 24 Apr 2023 21:24:21 +0200 Subject: [PATCH 123/874] Util\Timing: split `printRunTime()` method ... into logical parts to allow the Performance report access to the total run time information (at the point of report creation) as well. --- src/Util/Timing.php | 63 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/src/Util/Timing.php b/src/Util/Timing.php index 8cd3524186..36f4346343 100644 --- a/src/Util/Timing.php +++ b/src/Util/Timing.php @@ -40,6 +40,51 @@ public static function startTiming() }//end startTiming() + /** + * Get the duration of the run up to "now". + * + * @return int Duration in microseconds. + */ + public static function getDuration() + { + if (self::$startTime === null) { + // Timing was never started. + return 0; + } + + return ((microtime(true) - self::$startTime) * 1000); + + }//end getDuration() + + + /** + * Convert a duration in microseconds to a human readable duration string. + * + * @param int $duration Duration in microseconds. + * + * @return string + */ + public static function getHumanReadableDuration($duration) + { + $timeString = ''; + if ($duration > 60000) { + $mins = floor($duration / 60000); + $secs = round((fmod($duration, 60000) / 1000), 2); + $timeString = $mins.' mins'; + if ($secs !== 0) { + $timeString .= ", $secs secs"; + } + } else if ($duration > 1000) { + $timeString = round(($duration / 1000), 2).' secs'; + } else { + $timeString = round($duration).'ms'; + } + + return $timeString; + + }//end getHumanReadableDuration() + + /** * Print information about the run. * @@ -60,23 +105,11 @@ public static function printRunTime($force=false) return; } - $time = ((microtime(true) - self::$startTime) * 1000); - - if ($time > 60000) { - $mins = floor($time / 60000); - $secs = round((fmod($time, 60000) / 1000), 2); - $time = $mins.' mins'; - if ($secs !== 0) { - $time .= ", $secs secs"; - } - } else if ($time > 1000) { - $time = round(($time / 1000), 2).' secs'; - } else { - $time = round($time).'ms'; - } + $duration = self::getDuration(); + $duration = self::getHumanReadableDuration($duration); $mem = round((memory_get_peak_usage(true) / (1024 * 1024)), 2).'MB'; - echo "Time: $time; Memory: $mem".PHP_EOL.PHP_EOL; + echo "Time: $duration; Memory: $mem".PHP_EOL.PHP_EOL; self::$printed = true; From 02338c21edcd39e7d5b919eeb228fcd8956f0122 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 24 Apr 2023 21:25:45 +0200 Subject: [PATCH 124/874] File: add `getListenerTimes()` method ... to allow for access to the recorded listener times from within a report class. --- src/Files/File.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Files/File.php b/src/Files/File.php index f0c2e747a4..bd9e935f87 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -209,6 +209,7 @@ class File * An array of sniffs being processed and how long they took. * * @var array + * @see getListenerTimes() */ protected $listenerTimes = []; @@ -1232,6 +1233,18 @@ public function getMetrics() }//end getMetrics() + /** + * Returns the time taken processing this file for each invoked sniff. + * + * @return array + */ + public function getListenerTimes() + { + return $this->listenerTimes; + + }//end getListenerTimes() + + /** * Returns the absolute filename of this file. * From 3a5ca4d52f226edb2ce6db2d92fd9831a729adc4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 24 Apr 2023 21:37:59 +0200 Subject: [PATCH 125/874] Config: add `trackTime` toggle for whether or not to track listener times As recording the time taken by each sniff has a performance impact in and of itself on a CS run, only record the time taken by each sniff when needed. [*] Originally, this was already done conditionally based on the `PHP_CODESNIFFER_VERBOSITY > 2` condition. However, adding the Performance report would add a second criteria. This commit adds a new (internal) Config setting `trackTime`, which will be set to `true` when `PHP_CODESNIFFER_VERBOSITY > 2`. This commit paves the way for adding the second criteria in the next commit. --- [*] I've done some unscientific benchmarks for this by running PHPCS multiple times, with and without tracking the listener times, over a 300+ file codebase. Without tracking listener times, the run time was always around 39 seconds with 56Mb memory use. With tracking listener times, the run time was always around 54 seconds with 64Mb memory use. This, to me, shows a significant enough difference and sufficient reason to put this toggle in place to only track time when needed. --- src/Config.php | 9 +++++++++ src/Files/File.php | 13 +++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Config.php b/src/Config.php index ee50bc79d9..a12659f855 100644 --- a/src/Config.php +++ b/src/Config.php @@ -143,6 +143,7 @@ class Config 'stdin' => null, 'stdinContent' => null, 'stdinPath' => null, + 'trackTime' => null, 'unknown' => null, ]; @@ -277,6 +278,13 @@ public function __set($name, $value) $value = $cleaned; break; + + // Only track time when explicitly needed. + case 'verbosity': + if ($value > 2) { + $this->settings['trackTime'] = true; + } + break; default : // No validation required. break; @@ -530,6 +538,7 @@ public function restoreDefaults() $this->stdin = false; $this->stdinContent = null; $this->stdinPath = null; + $this->trackTime = false; $this->unknown = []; $standard = self::getConfigData('default_standard'); diff --git a/src/Files/File.php b/src/Files/File.php index bd9e935f87..eb2357a15e 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -254,6 +254,7 @@ public function __construct($path, Ruleset $ruleset, Config $config) $this->configCache['errorSeverity'] = $this->config->errorSeverity; $this->configCache['warningSeverity'] = $this->config->warningSeverity; $this->configCache['recordErrors'] = $this->config->recordErrors; + $this->configCache['trackTime'] = $this->config->trackTime; $this->configCache['ignorePatterns'] = $this->ruleset->ignorePatterns; $this->configCache['includePatterns'] = $this->ruleset->includePatterns; @@ -506,8 +507,11 @@ public function process() $this->activeListener = $class; - if (PHP_CODESNIFFER_VERBOSITY > 2) { + if ($this->configCache['trackTime'] === true) { $startTime = microtime(true); + } + + if (PHP_CODESNIFFER_VERBOSITY > 2) { echo "\t\t\tProcessing ".$this->activeListener.'... '; } @@ -516,14 +520,16 @@ public function process() $listenerIgnoreTo[$this->activeListener] = $ignoreTo; } - if (PHP_CODESNIFFER_VERBOSITY > 2) { + if ($this->configCache['trackTime'] === true) { $timeTaken = (microtime(true) - $startTime); if (isset($this->listenerTimes[$this->activeListener]) === false) { $this->listenerTimes[$this->activeListener] = 0; } $this->listenerTimes[$this->activeListener] += $timeTaken; + } + if (PHP_CODESNIFFER_VERBOSITY > 2) { $timeTaken = round(($timeTaken), 4); echo "DONE in $timeTaken seconds".PHP_EOL; } @@ -557,8 +563,7 @@ public function process() echo "\t*** END TOKEN PROCESSING ***".PHP_EOL; echo "\t*** START SNIFF PROCESSING REPORT ***".PHP_EOL; - asort($this->listenerTimes, SORT_NUMERIC); - $this->listenerTimes = array_reverse($this->listenerTimes, true); + arsort($this->listenerTimes, SORT_NUMERIC); foreach ($this->listenerTimes as $listener => $timeTaken) { echo "\t$listener: ".round(($timeTaken), 4).' secs'.PHP_EOL; } From 70a3d5666a084d5352e76b7ab93d7465c6b3f798 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 24 Apr 2023 21:58:34 +0200 Subject: [PATCH 126/874] New `Performance` report to measure sniff run time performance The report will print the sniff name, cumulative listener run time and % of the total sniff run time for each sniff triggered during a run. The report is ordered by cumulative listener run time in descending order. Additionally, it will highlight sniffs which have a cumulative listener run time more than twice the average run time per sniff in orange and sniffs with a cumulative listener run time of more than three times the average run time per sniff in red. At the bottom of the report it will also compare the total sniff relative run time with the total run time. Fixes 3784 Includes mention of the report in the CLI help text. --- CHANGELOG.md | 3 + src/Config.php | 11 ++- src/Reports/Performance.php | 160 ++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 src/Reports/Performance.php diff --git a/CHANGELOG.md b/CHANGELOG.md index c83cef690f..7197ee5e81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,9 @@ The file documents changes to the PHP_CodeSniffer project. - Generic.PHP.LowerCaseType - PSr12.Functions.NullableTypeDeclaration - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch +- Added a Performance report, mostly useful for sniff maintainers, to allow for finding "slow" sniffs. + - To run this report, run PHPCS with --report=Performance. + - 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: diff --git a/src/Config.php b/src/Config.php index a12659f855..0137f2ddb7 100644 --- a/src/Config.php +++ b/src/Config.php @@ -285,6 +285,13 @@ public function __set($name, $value) $this->settings['trackTime'] = true; } break; + case 'reports': + $reports = array_change_key_case($value, CASE_LOWER); + if (array_key_exists('performance', $reports) === true) { + $this->settings['trackTime'] = true; + } + break; + default : // No validation required. break; @@ -1437,8 +1444,8 @@ public function printPHPCSUsage() echo ' How many files should be checked simultaneously (default is 1)'.PHP_EOL; echo ' Print either the "full", "xml", "checkstyle", "csv"'.PHP_EOL; echo ' "json", "junit", "emacs", "source", "summary", "diff"'.PHP_EOL; - echo ' "svnblame", "gitblame", "hgblame" or "notifysend" report,'.PHP_EOL; - echo ' or specify the path to a custom report class'.PHP_EOL; + echo ' "svnblame", "gitblame", "hgblame", "notifysend" or "performance",'.PHP_EOL; + echo ' report or specify the path to a custom report class'.PHP_EOL; echo ' (the "full" report is printed by default)'.PHP_EOL; echo ' Write the report to the specified file path'.PHP_EOL; echo ' How many columns wide screen reports should be printed'.PHP_EOL; diff --git a/src/Reports/Performance.php b/src/Reports/Performance.php new file mode 100644 index 0000000000..d5b94074d4 --- /dev/null +++ b/src/Reports/Performance.php @@ -0,0 +1,160 @@ + + * @copyright 2023 Juliette Reinders Folmer. All rights reserved. + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Reports; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Util\Common; +use PHP_CodeSniffer\Util\Timing; + +class Performance implements Report +{ + + + /** + * Generate a partial report for a single processed file. + * + * Function should return TRUE if it printed or stored data about the file + * and FALSE if it ignored the file. Returning TRUE indicates that the file and + * its data should be counted in the grand totals. + * + * @param array $report Prepared report data. + * @param \PHP_CodeSniffer\File $phpcsFile The file being reported on. + * @param bool $showSources Show sources? + * @param int $width Maximum allowed line width. + * + * @return bool + */ + public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + { + $times = $phpcsFile->getListenerTimes(); + foreach ($times as $sniff => $time) { + echo "$sniff>>$time".PHP_EOL; + } + + return true; + + }//end generateFileReport() + + + /** + * Prints the sniff performance report. + * + * @param string $cachedData Any partial report data that was returned from + * generateFileReport during the run. + * @param int $totalFiles Total number of files processed during the run. + * @param int $totalErrors Total number of errors found during the run. + * @param int $totalWarnings Total number of warnings found during the run. + * @param int $totalFixable Total number of problems that can be fixed. + * @param bool $showSources Show sources? + * @param int $width Maximum allowed line width. + * @param bool $interactive Are we running in interactive mode? + * @param bool $toScreen Is the report being printed to screen? + * + * @return void + */ + public function generate( + $cachedData, + $totalFiles, + $totalErrors, + $totalWarnings, + $totalFixable, + $showSources=false, + $width=80, + $interactive=false, + $toScreen=true + ) { + $lines = explode(PHP_EOL, $cachedData); + array_pop($lines); + + if (empty($lines) === true) { + return; + } + + // First collect the accumulated timings. + $timings = []; + $totalSniffTime = 0; + foreach ($lines as $line) { + $parts = explode('>>', $line); + $sniffClass = $parts[0]; + $time = $parts[1]; + + if (isset($timings[$sniffClass]) === false) { + $timings[$sniffClass] = 0; + } + + $timings[$sniffClass] += $time; + $totalSniffTime += $time; + } + + // Next, tidy up the sniff names and determine max needed column width. + $totalTimes = []; + $maxNameWidth = 0; + foreach ($timings as $sniffClass => $secs) { + $sniffCode = Common::getSniffCode($sniffClass); + $maxNameWidth = max($maxNameWidth, strlen($sniffCode)); + $totalTimes[$sniffCode] = $secs; + } + + // Leading space + up to 12 chars for the number. + $maxTimeWidth = 13; + // Leading space, open parenthesis, up to 5 chars for the number, space + % and close parenthesis. + $maxPercWidth = 10; + // Calculate the maximum width available for the sniff name. + $maxNameWidth = min(($width - $maxTimeWidth - $maxPercWidth), max(($width - $maxTimeWidth - $maxPercWidth), $maxNameWidth)); + + arsort($totalTimes); + + echo PHP_EOL."\033[1m".'PHP CODE SNIFFER SNIFF PERFORMANCE REPORT'."\033[0m".PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + echo "\033[1m".'SNIFF'.str_repeat(' ', ($width - 31)).'TIME TAKEN (SECS) (%)'."\033[0m".PHP_EOL; + echo str_repeat('-', $width).PHP_EOL; + + // Mark sniffs which take more than twice as long as the average processing time per sniff + // in orange and when they take more than three times as long as the average, + // mark them in red. + $avgSniffTime = ($totalSniffTime / count($totalTimes)); + $doubleAvgSniffTime = (2 * $avgSniffTime); + $tripleAvgSniffTime = (3 * $avgSniffTime); + + $format = "%- {$maxNameWidth}.{$maxNameWidth}s % 12.6f (% 5.1f %%)".PHP_EOL; + $formatBold = "\033[1m%- {$maxNameWidth}.{$maxNameWidth}s % 12.6f (% 5.1f %%)\033[0m".PHP_EOL; + $formatWarning = "%- {$maxNameWidth}.{$maxNameWidth}s \033[33m% 12.6f (% 5.1f %%)\033[0m".PHP_EOL; + $formatError = "%- {$maxNameWidth}.{$maxNameWidth}s \033[31m% 12.6f (% 5.1f %%)\033[0m".PHP_EOL; + + foreach ($totalTimes as $sniff => $time) { + $percent = round((($time / $totalSniffTime) * 100), 1); + + if ($time > $tripleAvgSniffTime) { + printf($formatError, $sniff, $time, $percent); + } else if ($time > $doubleAvgSniffTime) { + printf($formatWarning, $sniff, $time, $percent); + } else { + printf($format, $sniff, $time, $percent); + } + } + + echo str_repeat('-', $width).PHP_EOL; + printf($formatBold, 'TOTAL SNIFF PROCESSING TIME', $totalSniffTime, 100); + + $runTime = (Timing::getDuration() / 1000); + $phpcsTime = ($runTime - $totalSniffTime); + + echo PHP_EOL.str_repeat('-', $width).PHP_EOL; + printf($format, 'Time taken by sniffs', $totalSniffTime, round((($totalSniffTime / $runTime) * 100), 1)); + printf($format, 'Time taken by PHPCS runner', $phpcsTime, round((($phpcsTime / $runTime) * 100), 1)); + + echo str_repeat('-', $width).PHP_EOL; + printf($formatBold, 'TOTAL RUN TIME', $runTime, 100); + echo str_repeat('-', $width).PHP_EOL; + + }//end generate() + + +}//end class From ce365fd5a8f7a16f3347847e04ee64afe5b002b5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 23 Sep 2022 05:01:45 +0200 Subject: [PATCH 127/874] Generic/LowerCaseType: improve performance Someone reported a performance issue with the `Generic.PHP.LowerCaseType` sniff to me. Running the Performance report (PR 3810) over a number of codebases, confirmed that the sniff ranked in the top 10 of "slow" sniffs. As it was, the sniff would examine all variables it comes across and disregard them if they are not properties or not typed. The "disregard when not a property" was done by catching an exception thrown by the `File::getMemberProperties()` method. As the majority of `T_VARIABLE` tokens in the average file are not property declarations, the `File::getMemberProperties()` method would be triggered lots and lots of times, with the majority of those times resulting in the need for creating and then catching and throwing away the above mentioned exception. By changing the logic for the sniff to only look within OO constructs and skip over anything non-property, thus avoiding the unnecessary exception creation, I can see a significant difference in the sniff run time. Using the test file which was originally shared with me and running the below command on PHP 7.4: ```bash phpcs -ps db.php --standard=Generic --report=source -vvv --sniffs=Generic.PHP.LowercaseType ``` ... yielded the following difference in runtime: Base time: ``` *** START SNIFF PROCESSING REPORT *** PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseTypeSniff: 0.3802 secs *** END SNIFF PROCESSING REPORT *** ``` Time with the performance tweak included in this PR: ``` *** START SNIFF PROCESSING REPORT *** PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseTypeSniff: 0.0113 secs *** END SNIFF PROCESSING REPORT *** ``` Using the performance report to benchmark the improvement with a larger number of files, I see improvement across the board as well: Command used: `phpcs -ps . --extensions=php --ignore=/vendor/ --report=performance --standard=psr12` Output for the `Generic.PHP.LowercaseType` sniff: Result | PHPCS itself | Set of Projects A | Set of Projects B | Set of Projects C | ------ | ------------------ | ------------------ | ------------------ | ----------------- | Nr of Files Scanned | 614 | 4115 | 25546 | 2250 | Before | 0.131587 ( 3.9 %) | 1.514729 ( 3.0 %) | 5.390167 ( 3.4 %) | 0.359674 ( 4.2 %) After | 0.029166 ( 0.9 %) | 0.449517 ( 0.9 %) | 1.917077 ( 1.2 %) | 0.181097 ( 2.2 %) --- I've also had a quick look at all other PHPCS native sniffs using the `File::getMemberProperties()` method. As those are all based on the `AbstractVariableSniff`, they don't seem to suffer from the same issue, or at least, nowhere near as badly. I also considered changing the setup of the sniff to start using the `AbstractVariableSniff`, but considering this particular sniff is also examining functions and type casts, I believe that would make the sniff more complex than necessary. --- CHANGELOG.md | 2 + .../Generic/Sniffs/PHP/LowerCaseTypeSniff.php | 82 ++++++++++++------- 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7197ee5e81..6cebe514f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,6 +99,8 @@ The file documents changes to the PHP_CodeSniffer project. - 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.LowerCaseType - 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. diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php index daa6f0f2e9..f309960d12 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php @@ -51,10 +51,10 @@ class LowerCaseTypeSniff implements Sniff public function register() { $tokens = Tokens::$castTokens; + $tokens += Tokens::$ooScopeTokens; $tokens[] = T_FUNCTION; $tokens[] = T_CLOSURE; $tokens[] = T_FN; - $tokens[] = T_VARIABLE; return $tokens; }//end register() @@ -90,40 +90,66 @@ public function process(File $phpcsFile, $stackPtr) * Check property types. */ - if ($tokens[$stackPtr]['code'] === T_VARIABLE) { - try { - $props = $phpcsFile->getMemberProperties($stackPtr); - } catch (RuntimeException $e) { - // Not an OO property. + if (isset(Tokens::$ooScopeTokens[$tokens[$stackPtr]['code']]) === true) { + if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) { return; } - if (empty($props) === true) { - // Parse error - property in interface or enum. Ignore. - return; - } + for ($i = ($tokens[$stackPtr]['scope_opener'] + 1); $i < $tokens[$stackPtr]['scope_closer']; $i++) { + // Skip over potentially large docblocks. + if ($tokens[$i]['code'] === \T_DOC_COMMENT_OPEN_TAG + && isset($tokens[$i]['comment_closer']) === true + ) { + $i = $tokens[$i]['comment_closer']; + continue; + } - // Strip off potential nullable indication. - $type = ltrim($props['type'], '?'); + // Skip over function declarations and everything nested within. + if ($tokens[$i]['code'] === \T_FUNCTION + && isset($tokens[$i]['scope_closer']) === true + ) { + $i = $tokens[$i]['scope_closer']; + continue; + } - if ($type !== '') { - $error = 'PHP property type declarations must be lowercase; expected "%s" but found "%s"'; - $errorCode = 'PropertyTypeFound'; + if ($tokens[$i]['code'] !== \T_VARIABLE) { + continue; + } - if ($props['type_token'] === T_TYPE_INTERSECTION) { - // Intersection types don't support simple types. - } else if (strpos($type, '|') !== false) { - $this->processUnionType( - $phpcsFile, - $props['type_token'], - $props['type_end_token'], - $error, - $errorCode - ); - } else if (isset($this->phpTypes[strtolower($type)]) === true) { - $this->processType($phpcsFile, $props['type_token'], $type, $error, $errorCode); + try { + $props = $phpcsFile->getMemberProperties($i); + } catch (RuntimeException $e) { + // Not an OO property. + continue; } - } + + if (empty($props) === true) { + // Parse error - property in interface or enum. Ignore. + return; + } + + // Strip off potential nullable indication. + $type = ltrim($props['type'], '?'); + + if ($type !== '') { + $error = 'PHP property type declarations must be lowercase; expected "%s" but found "%s"'; + $errorCode = 'PropertyTypeFound'; + + if ($props['type_token'] === T_TYPE_INTERSECTION) { + // Intersection types don't support simple types. + } else if (strpos($type, '|') !== false) { + $this->processUnionType( + $phpcsFile, + $props['type_token'], + $props['type_end_token'], + $error, + $errorCode + ); + } else if (isset($this->phpTypes[strtolower($type)]) === true) { + $this->processType($phpcsFile, $props['type_token'], $type, $error, $errorCode); + } + } + }//end for return; }//end if From 90209514e5f1737e5d78dfa1358ca7d9b5540de5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 2 Jun 2023 11:21:14 +0200 Subject: [PATCH 128/874] PSR12/OpenTag: improve performance No functional changes at all, just improving performance of the sniff by changing the order of certain checks. Some benchmarks for this change run using the Performance report (PR 3810): Command: `phpcs -ps . --extensions=php --ignore=/vendor/ --report=performance --standard=psr12` Output for the `PSR12.Files.OpenTag` sniff: Result | PHPCS itself | Set of Projects A | Set of Projects B | Set of Projects C | ------ | ------------------ | ------------------ | ------------------ | ----------------- | Nr of Files Scanned | 614 | 4115 | 25546 | 2250 | Before | 0.077045 ( 2.3 %) | 0.982014 ( 1.9 %) | 3.267655 ( 2.1 %) | 0.179564 ( 2.1 %) After | 0.000928 ( 0.0 %) | 0.013066 ( 0.0 %) | 0.091816 ( 0.1 %) | 0.109021 ( 1.3 %) With what the sniff does, the impact is biggest for files/codebases which already comply with the expectations of this sniff. --- CHANGELOG.md | 2 ++ .../PSR12/Sniffs/Files/OpenTagSniff.php | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cebe514f7..b1eac49d80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch - The following sniffs have received performance related improvements: - 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. diff --git a/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php b/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php index bb8a75d0b5..6c80d812fa 100644 --- a/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php @@ -44,12 +44,6 @@ public function process(File $phpcsFile, $stackPtr) return $phpcsFile->numTokens; } - $next = $phpcsFile->findNext(T_INLINE_HTML, 0); - if ($next !== false) { - // This rule only applies to PHP-only files. - return $phpcsFile->numTokens; - } - $tokens = $phpcsFile->getTokens(); $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); if ($next === false) { @@ -57,12 +51,21 @@ public function process(File $phpcsFile, $stackPtr) return $phpcsFile->numTokens; } - if ($tokens[$next]['line'] === $tokens[$stackPtr]['line']) { - $error = 'Opening PHP tag must be on a line by itself'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotAlone'); - if ($fix === true) { - $phpcsFile->fixer->addNewline($stackPtr); - } + if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { + // Tag is on a line by itself. + return $phpcsFile->numTokens; + } + + $next = $phpcsFile->findNext(T_INLINE_HTML, 0); + if ($next !== false) { + // This rule only applies to PHP-only files. + return $phpcsFile->numTokens; + } + + $error = 'Opening PHP tag must be on a line by itself'; + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotAlone'); + if ($fix === true) { + $phpcsFile->fixer->addNewline($stackPtr); } return $phpcsFile->numTokens; From 960d54100df050e243d316248b39a9b550d9afaf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 6 Dec 2023 01:09:54 +0100 Subject: [PATCH 129/874] Config: minor documentation touch-up --- src/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Config.php b/src/Config.php index 0137f2ddb7..6687ae8d03 100644 --- a/src/Config.php +++ b/src/Config.php @@ -58,6 +58,7 @@ * @property bool $stdin Read content from STDIN instead of supplied files. * @property string $stdinContent Content passed directly to PHPCS on STDIN. * @property string $stdinPath The path to use for content passed on STDIN. + * @property bool $trackTime Whether or not to track sniff run time. * * @property array $extensions File extensions that should be checked, and what tokenizer to use. * E.g., array('inc' => 'PHP'); From 5194c9c82fbc4d251254e4300b6dbb5af0b59850 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 6 Dec 2023 11:02:35 +0100 Subject: [PATCH 130/874] Composer: revert package name change :warning: **_To be merged once the Packagist edit has been made._** :warning: This reverts commit f6dc841498ab8b056ba0bb8f6785ed634700b34e and updates the information in the changelog for the 3.8.0 release. **Users who already changed the package name in _their_ `composer.json` dependencies, should switch back to the original package name.** Refs: * See [the conversation from this comment down](https://github.com/squizlabs/PHP_CodeSniffer/issues/3932#issuecomment-1841873639). Closes 113, 114 --- CHANGELOG.md | 3 ++- README.md | 8 ++++---- composer.json | 5 +---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1eac49d80..4a2fbfbe2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ The file documents changes to the PHP_CodeSniffer project. ### Breaking Changes - The `squizlabs/PHP_CodeSniffer` repository has been abandoned. This repository will serve as the continuation of the project. - - Composer users will need to `require-dev` the `phpcsstandards/php_codesniffer` package instead. + - For Composer users, nothing changes. + - **In contrast to earlier information, the `squizlabs/php_codesniffer` package will now point to the new repo 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 URL from `https://squizlabs.github.io/PHP_CodeSniffer/[phpcs|phpcbf].phar` to `https://phars.phpcodesniffer.com/[phpcs|phpcbf].phar`. diff --git a/README.md b/README.md index afca96cbff..e65acb61e0 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ PHP_CodeSniffer [![Test](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml) [![License](http://poser.pugx.org/phpcsstandards/php_codesniffer/license)](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt) -![Minimum PHP Version](https://img.shields.io/packagist/php-v/phpcsstandards/php_codesniffer.svg?maxAge=3600) +![Minimum PHP Version](https://img.shields.io/packagist/php-v/squizlabs/php_codesniffer.svg?maxAge=3600) [![Tested on PHP 5.4 to 8.3](https://img.shields.io/badge/tested%20on-PHP%205.4%20|%205.5%20|%205.6%20|%207.0%20|%207.1%20|%207.2%20|%207.3%20|%207.4%20|%208.0%20|%208.1%20|%208.2%20|%208.3-brightgreen.svg?maxAge=2419200)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml) @@ -48,16 +48,16 @@ php phpcbf.phar -h ### Composer If you use Composer, you can install PHP_CodeSniffer system-wide with the following command: ```bash -composer global require "phpcsstandards/php_codesniffer=*" +composer global require "squizlabs/php_codesniffer=*" ``` Make sure you have the composer bin dir in your PATH. The default value is `~/.composer/vendor/bin/`, but you can check the value that you need to use by running `composer global config bin-dir --absolute`. -Or alternatively, include a dependency for `phpcsstandards/php_codesniffer` in your `composer.json` file. For example: +Or alternatively, include a dependency for `squizlabs/php_codesniffer` in your `composer.json` file. For example: ```json { "require-dev": { - "phpcsstandards/php_codesniffer": "^3.0" + "squizlabs/php_codesniffer": "^3.0" } } ``` diff --git a/composer.json b/composer.json index 7abe62e21f..a477d20a2b 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "phpcsstandards/php_codesniffer", + "name": "squizlabs/php_codesniffer", "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", "type": "library", "keywords": [ @@ -43,9 +43,6 @@ "require-dev": { "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" }, - "replace": { - "squizlabs/php_codesniffer": "> 2.0" - }, "bin": [ "bin/phpcs", "bin/phpcbf" From b8065eb87200e01d43ef826d27af7b74c8aeeda1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 7 Dec 2023 16:30:33 +0100 Subject: [PATCH 131/874] Squiz/ControlSignature: add missing property reset --- .../Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc | 3 +++ .../Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc index 8eaf1b0373..8c28609bc1 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc @@ -305,6 +305,9 @@ $r = match ($x) { $r = match($x){1 => 1}; +// Reset property. +// @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 1 + // Intentional parse error. This should be the last test in the file. foreach // Some unrelated comment. diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed index dc5233d917..fbf953428d 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed @@ -309,6 +309,9 @@ $r = match ($x) { $r = match ($x) { 1 => 1}; +// Reset property. +// @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 1 + // Intentional parse error. This should be the last test in the file. foreach // Some unrelated comment. From d46210ef18ca60074876db20f8e0c49c10ba7550 Mon Sep 17 00:00:00 2001 From: Danny van der Sluijs Date: Mon, 4 Dec 2023 20:04:05 +0100 Subject: [PATCH 132/874] Various sniffs: fix grammar for various error messages Correct pluralization of the word space/spaces depending on the spacing value. For these sniffs, the changes are already covered by pre-existing tests. Port squizlabs/PHP_CodeSniffer 3881 to this repo --- .../Sniffs/Formatting/SpaceAfterCastSniff.php | 18 +++++++++++++----- .../Sniffs/Formatting/SpaceAfterNotSniff.php | 18 +++++++++++++----- .../Commenting/DocCommentAlignmentSniff.php | 10 ++++++++-- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php index 36eff864ac..0ab8d3d52c 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php @@ -54,8 +54,12 @@ public function register() */ public function process(File $phpcsFile, $stackPtr) { - $tokens = $phpcsFile->getTokens(); - $this->spacing = (int) $this->spacing; + $tokens = $phpcsFile->getTokens(); + $this->spacing = (int) $this->spacing; + $pluralizeSpace = 's'; + if ($this->spacing === 1) { + $pluralizeSpace = ''; + } if ($tokens[$stackPtr]['code'] === T_BINARY_CAST && $tokens[$stackPtr]['content'] === 'b' @@ -83,8 +87,11 @@ public function process(File $phpcsFile, $stackPtr) $nextNonWhitespace = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); if ($nextNonEmpty !== $nextNonWhitespace) { - $error = 'Expected %s space(s) after cast statement; comment found'; - $data = [$this->spacing]; + $error = 'Expected %s space%s after cast statement; comment found'; + $data = [ + $this->spacing, + $pluralizeSpace, + ]; $phpcsFile->addError($error, $stackPtr, 'CommentFound', $data); if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { @@ -109,9 +116,10 @@ public function process(File $phpcsFile, $stackPtr) return; } - $error = 'Expected %s space(s) after cast statement; %s found'; + $error = 'Expected %s space%s after cast statement; %s found'; $data = [ $this->spacing, + $pluralizeSpace, $found, ]; diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php index 1ff25bdade..99e267d61d 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php @@ -64,8 +64,12 @@ public function register() */ public function process(File $phpcsFile, $stackPtr) { - $tokens = $phpcsFile->getTokens(); - $this->spacing = (int) $this->spacing; + $tokens = $phpcsFile->getTokens(); + $this->spacing = (int) $this->spacing; + $pluralizeSpace = 's'; + if ($this->spacing === 1) { + $pluralizeSpace = ''; + } $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($nextNonEmpty === false) { @@ -84,8 +88,11 @@ public function process(File $phpcsFile, $stackPtr) $nextNonWhitespace = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); if ($nextNonEmpty !== $nextNonWhitespace) { - $error = 'Expected %s space(s) after NOT operator; comment found'; - $data = [$this->spacing]; + $error = 'Expected %s space%s after NOT operator; comment found'; + $data = [ + $this->spacing, + $pluralizeSpace, + ]; $phpcsFile->addError($error, $stackPtr, 'CommentFound', $data); return; } @@ -101,9 +108,10 @@ public function process(File $phpcsFile, $stackPtr) return; } - $error = 'Expected %s space(s) after NOT operator; %s found'; + $error = 'Expected %s space%s after NOT operator; %s found'; $data = [ $this->spacing, + $pluralizeSpace, $found, ]; diff --git a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php index 55cd62526e..7259e533ec 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php @@ -112,9 +112,15 @@ public function process(File $phpcsFile, $stackPtr) } if ($tokens[$i]['column'] !== $requiredColumn) { - $error = 'Expected %s space(s) before asterisk; %s found'; + $pluralizeSpace = 's'; + if (($requiredColumn - 1) === 1) { + $pluralizeSpace = ''; + } + + $error = 'Expected %s space%s before asterisk; %s found'; $data = [ ($requiredColumn - 1), + $pluralizeSpace, ($tokens[$i]['column'] - 1), ]; $fix = $phpcsFile->addFixableError($error, $i, 'SpaceBeforeStar', $data); @@ -126,7 +132,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->replaceToken(($i - 1), $padding); } } - } + }//end if if ($tokens[$i]['code'] !== T_DOC_COMMENT_STAR) { continue; From 4cf6badaf0c177acaf295e2178f4383e2ea71b20 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 7 Dec 2023 17:28:00 +0100 Subject: [PATCH 133/874] Generic/ArrayIndent: fix grammar for various error messages Correct pluralization of the word space/spaces depending on the spacing value. Includes adding tests for the `$indent` property being set to a 1 (open brace) and 0 (item indent, close brace). Co-authored-by: Danny van der Sluijs --- .../Sniffs/Arrays/ArrayIndentSniff.php | 24 ++++++++++-- .../Tests/Arrays/ArrayIndentUnitTest.inc | 38 +++++++++++++++++++ .../Arrays/ArrayIndentUnitTest.inc.fixed | 38 +++++++++++++++++++ .../Tests/Arrays/ArrayIndentUnitTest.php | 8 ++++ 4 files changed, 105 insertions(+), 3 deletions(-) diff --git a/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php b/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php index 9bff5c6354..87da8f3cf9 100644 --- a/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php @@ -76,9 +76,15 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array // check indent levels because it's not valid. But we don't enforce exactly // how far indented it should be. if ($startIndent < $baseIndent) { - $error = 'Array open brace not indented correctly; expected at least %s spaces but found %s'; + $pluralizeSpace = 's'; + if ($baseIndent === 1) { + $pluralizeSpace = ''; + } + + $error = 'Array open brace not indented correctly; expected at least %s space%s but found %s'; $data = [ $baseIndent, + $pluralizeSpace, $startIndent, ]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'OpenBraceIncorrect', $data); @@ -117,9 +123,15 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array continue; } - $error = 'Array key not indented correctly; expected %s spaces but found %s'; + $pluralizeSpace = 's'; + if ($expectedIndent === 1) { + $pluralizeSpace = ''; + } + + $error = 'Array key not indented correctly; expected %s space%s but found %s'; $data = [ $expectedIndent, + $pluralizeSpace, $foundIndent, ]; $fix = $phpcsFile->addFixableError($error, $first, 'KeyIncorrect', $data); @@ -154,9 +166,15 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array return; } - $error = 'Array close brace not indented correctly; expected %s spaces but found %s'; + $pluralizeSpace = 's'; + if ($expectedIndent === 1) { + $pluralizeSpace = ''; + } + + $error = 'Array close brace not indented correctly; expected %s space%s but found %s'; $data = [ $expectedIndent, + $pluralizeSpace, $foundIndent, ]; $fix = $phpcsFile->addFixableError($error, $arrayEnd, 'CloseBraceIncorrect', $data); diff --git a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc index 075fc34c5b..6f418ca1f3 100644 --- a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc +++ b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc @@ -111,3 +111,41 @@ $array = [ name: $value ), ]; + +// phpcs:set Generic.Arrays.ArrayIndent indent 1 + +// Testing pluralization of indent text - open brace indent. + $var = +[ + 1 => 'one', +]; + +// Testing pluralization of indent text - array item indent. +$var = [ + 1 => 'one', + 2 => 'two', + /* three */ 3 => 'three', +]; + +// Testing pluralization of indent text - close brace indent. + $var = [ + 1 => 'one', + ]; + +// phpcs:set Generic.Arrays.ArrayIndent indent 0 + +// No test for open brace indent as that is _minimum_ and any actual value will be 0 or more, so with indent 0, this will never yield an error. + +// Testing pluralization of indent text - array item indent. +$var = [ + 1 => 'one', + 2 => 'two', + /* three */ 3 => 'three', +]; + +// Testing pluralization of indent text - close brace indent. +$var = [ +1 => 'one', + ]; + +// phpcs:set Generic.Arrays.ArrayIndent indent 4 diff --git a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed index 505de5f780..1ea8dd1e6f 100644 --- a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed @@ -112,3 +112,41 @@ $array = [ name: $value ), ]; + +// phpcs:set Generic.Arrays.ArrayIndent indent 1 + +// Testing pluralization of indent text - open brace indent. + $var = + [ + 1 => 'one', + ]; + +// Testing pluralization of indent text - array item indent. +$var = [ + 1 => 'one', + 2 => 'two', + /* three */ 3 => 'three', +]; + +// Testing pluralization of indent text - close brace indent. + $var = [ + 1 => 'one', + ]; + +// phpcs:set Generic.Arrays.ArrayIndent indent 0 + +// No test for open brace indent as that is _minimum_ and any actual value will be 0 or more, so with indent 0, this will never yield an error. + +// Testing pluralization of indent text - array item indent. +$var = [ +1 => 'one', +2 => 'two', +/* three */ 3 => 'three', +]; + +// Testing pluralization of indent text - close brace indent. +$var = [ +1 => 'one', +]; + +// phpcs:set Generic.Arrays.ArrayIndent indent 4 diff --git a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php index 482742a356..e1c83467e0 100644 --- a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php @@ -45,6 +45,14 @@ public function getErrorList() 88 => 1, 98 => 1, 110 => 1, + 119 => 1, + 126 => 1, + 127 => 1, + 133 => 1, + 141 => 1, + 142 => 1, + 143 => 1, + 149 => 1, ]; }//end getErrorList() From d7858153ab4e3ade53befbe404e3c7e568ff966d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 8 Dec 2023 01:31:30 +0100 Subject: [PATCH 134/874] Squiz/ArrayDeclaration: fix grammar for various error messages Correct pluralization of the word space/spaces depending on the spacing value. Includes adding tests for the `CloseBraceNotAligned` error code which would use the "1 space" phrasing. Co-authored-by: Danny van der Sluijs --- .../Sniffs/Arrays/ArrayDeclarationSniff.php | 66 ++++++++++++++----- .../Arrays/ArrayDeclarationUnitTest.1.inc | 6 ++ .../ArrayDeclarationUnitTest.1.inc.fixed | 6 ++ .../Arrays/ArrayDeclarationUnitTest.2.inc | 6 ++ .../ArrayDeclarationUnitTest.2.inc.fixed | 6 ++ .../Tests/Arrays/ArrayDeclarationUnitTest.php | 2 + 6 files changed, 74 insertions(+), 18 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php index 73454fd99f..f9e4ec035a 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -330,11 +330,17 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array } } else if ($tokens[$arrayEnd]['column'] !== $keywordStart) { // Check the closing bracket is lined up under the "a" in array. - $expected = ($keywordStart - 1); - $found = ($tokens[$arrayEnd]['column'] - 1); - $error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s'; - $data = [ + $expected = ($keywordStart - 1); + $found = ($tokens[$arrayEnd]['column'] - 1); + $pluralizeSpace = 's'; + if ($expected === 1) { + $pluralizeSpace = ''; + } + + $error = 'Closing parenthesis not aligned correctly; expected %s space%s but found %s'; + $data = [ $expected, + $pluralizeSpace, $found, ]; @@ -674,12 +680,18 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array } else if ($previousIsWhitespace === true) { $expected = $keywordStart; - $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $valuePointer, true); - $found = ($tokens[$first]['column'] - 1); + $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $valuePointer, true); + $found = ($tokens[$first]['column'] - 1); + $pluralizeSpace = 's'; + if ($expected === 1) { + $pluralizeSpace = ''; + } + if ($found !== $expected) { - $error = 'Array value not aligned correctly; expected %s spaces but found %s'; + $error = 'Array value not aligned correctly; expected %s space%s but found %s'; $data = [ $expected, + $pluralizeSpace, $found, ]; @@ -763,11 +775,17 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array } if ($tokens[$indexPointer]['column'] !== $indicesStart && ($indexPointer - 1) !== $arrayStart) { - $expected = ($indicesStart - 1); - $found = ($tokens[$indexPointer]['column'] - 1); - $error = 'Array key not aligned correctly; expected %s spaces but found %s'; - $data = [ + $expected = ($indicesStart - 1); + $found = ($tokens[$indexPointer]['column'] - 1); + $pluralizeSpace = 's'; + if ($expected === 1) { + $pluralizeSpace = ''; + } + + $error = 'Array key not aligned correctly; expected %s space%s but found %s'; + $data = [ $expected, + $pluralizeSpace, $found, ]; @@ -779,15 +797,21 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array $phpcsFile->fixer->replaceToken(($indexPointer - 1), str_repeat(' ', $expected)); } } - } + }//end if $arrowStart = ($tokens[$indexPointer]['column'] + $maxLength + 1); if ($tokens[$index['arrow']]['column'] !== $arrowStart) { - $expected = ($arrowStart - ($index['index_length'] + $tokens[$indexPointer]['column'])); - $found = ($tokens[$index['arrow']]['column'] - ($index['index_length'] + $tokens[$indexPointer]['column'])); - $error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s'; - $data = [ + $expected = ($arrowStart - ($index['index_length'] + $tokens[$indexPointer]['column'])); + $found = ($tokens[$index['arrow']]['column'] - ($index['index_length'] + $tokens[$indexPointer]['column'])); + $pluralizeSpace = 's'; + if ($expected === 1) { + $pluralizeSpace = ''; + } + + $error = 'Array double arrow not aligned correctly; expected %s space%s but found %s'; + $data = [ $expected, + $pluralizeSpace, $found, ]; @@ -801,7 +825,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array } continue; - } + }//end if $valueStart = ($arrowStart + 3); if ($tokens[$valuePointer]['column'] !== $valueStart) { @@ -811,9 +835,15 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array $found = 'newline'; } - $error = 'Array value not aligned correctly; expected %s space(s) but found %s'; + $pluralizeSpace = 's'; + if ($expected === 1) { + $pluralizeSpace = ''; + } + + $error = 'Array value not aligned correctly; expected %s space%s but found %s'; $data = [ $expected, + $pluralizeSpace, $found, ]; diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc index b96aec7bde..5b539a372a 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc @@ -529,3 +529,9 @@ $x = array( 'bar', 'baz' => 'bar', // KeySpecified (based on first entry). ); + + $x = + array( + 'a', + 'b', + ); diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed index 9da6a4279b..5ebf715024 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed @@ -565,3 +565,9 @@ $x = array( 'bar', 'baz' => 'bar', // KeySpecified (based on first entry). ); + + $x = + array( + 'a', + 'b', + ); diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc index 0c8b48fc89..7bcc5e044e 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc @@ -518,3 +518,9 @@ $x = [ 'bar', 'baz' => 'bar', // KeySpecified (based on first entry). ]; + + $x = + [ + 'a', + 'b', + ]; diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed index 4b09e2f234..d156357c93 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed @@ -552,3 +552,9 @@ $x = [ 'bar', 'baz' => 'bar', // KeySpecified (based on first entry). ]; + + $x = + [ + 'a', + 'b', + ]; diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php index d723e577e0..e4eb4f3b8f 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php @@ -128,6 +128,7 @@ public function getErrorList($testFile='') 516 => 1, 523 => 1, 530 => 1, + 537 => 1, ]; case 'ArrayDeclarationUnitTest.2.inc': return [ @@ -218,6 +219,7 @@ public function getErrorList($testFile='') 505 => 1, 512 => 1, 519 => 1, + 526 => 1, ]; default: return []; From 56323636bddde8c3e1a01c5c7be044b3a653f4fc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 7 Dec 2023 16:34:26 +0100 Subject: [PATCH 135/874] Squiz/ControlSignature: fix grammar for various error messages Correct pluralization of the word space/spaces depending on the spacing value. Includes adding tests for the `$requiredSpacesBeforeColon` property being set to a > 1 value. Co-authored-by: Danny van der Sluijs --- .../ControlSignatureSniff.php | 18 +++++++++++++++--- .../ControlSignatureUnitTest.inc | 11 +++++++++++ .../ControlSignatureUnitTest.inc.fixed | 11 +++++++++++ .../ControlSignatureUnitTest.php | 2 ++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php index e2794aaf02..bb5392364a 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -105,9 +105,15 @@ public function process(File $phpcsFile, $stackPtr) } if ($found !== $expected) { - $error = 'Expected %s space(s) after %s keyword; %s found'; + $pluralizeSpace = 's'; + if ($expected === 1) { + $pluralizeSpace = ''; + } + + $error = 'Expected %s space%s after %s keyword; %s found'; $data = [ $expected, + $pluralizeSpace, strtoupper($tokens[$stackPtr]['content']), $found, ]; @@ -120,7 +126,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr + 1), str_repeat(' ', $expected)); } } - } + }//end if // Single space after closing parenthesis. if (isset($tokens[$stackPtr]['parenthesis_closer']) === true @@ -146,9 +152,15 @@ public function process(File $phpcsFile, $stackPtr) } if ($found !== $expected) { - $error = 'Expected %s space(s) after closing parenthesis; found %s'; + $pluralizeSpace = 's'; + if ($expected === 1) { + $pluralizeSpace = ''; + } + + $error = 'Expected %s space%s after closing parenthesis; found %s'; $data = [ $expected, + $pluralizeSpace, $found, ]; diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc index 8c28609bc1..fe9fea33cd 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc @@ -305,6 +305,17 @@ $r = match ($x) { $r = match($x){1 => 1}; +// @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 2 +if ($a == 5): + echo "a equals 5"; + echo "..."; +elseif ($a == 6) : + echo "a equals 6"; + echo "!!!"; +else : + echo "a is neither 5 nor 6"; +endif; + // Reset property. // @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 1 diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed index fbf953428d..b09c9f2d57 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed @@ -309,6 +309,17 @@ $r = match ($x) { $r = match ($x) { 1 => 1}; +// @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 2 +if ($a == 5) : + echo "a equals 5"; + echo "..."; +elseif ($a == 6) : + echo "a equals 6"; + echo "!!!"; +else : + echo "a is neither 5 nor 6"; +endif; + // Reset property. // @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 1 diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php index 78afbf0e99..ce1323be5f 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -77,6 +77,8 @@ public function getErrorList($testFile='ControlSignatureUnitTest.inc') $errors[279] = 1; $errors[283] = 1; $errors[306] = 3; + $errors[309] = 1; + $errors[315] = 1; }//end if return $errors; From ca9a3b71437d6a84c8e3bfd6528a6b8fc2a296b0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 8 Dec 2023 03:32:14 +0100 Subject: [PATCH 136/874] Squiz/ControlSignature: fix up old-style property set annotations in tests --- .../Tests/ControlStructures/ControlSignatureUnitTest.inc | 6 +++--- .../ControlStructures/ControlSignatureUnitTest.inc.fixed | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc index fe9fea33cd..6496f7fb34 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc @@ -212,7 +212,7 @@ else : echo 'not 1'; endif; -// @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 0 +// phpcs:set Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 0 if ($a == 5): echo "a equals 5"; @@ -305,7 +305,7 @@ $r = match ($x) { $r = match($x){1 => 1}; -// @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 2 +// phpcs:set Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 2 if ($a == 5): echo "a equals 5"; echo "..."; @@ -317,7 +317,7 @@ else : endif; // Reset property. -// @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 1 +// phpcs:set Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 1 // Intentional parse error. This should be the last test in the file. foreach diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed index b09c9f2d57..c8834a3dd1 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed @@ -215,7 +215,7 @@ else : echo 'not 1'; endif; -// @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 0 +// phpcs:set Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 0 if ($a == 5): echo "a equals 5"; @@ -309,7 +309,7 @@ $r = match ($x) { $r = match ($x) { 1 => 1}; -// @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 2 +// phpcs:set Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 2 if ($a == 5) : echo "a equals 5"; echo "..."; @@ -321,7 +321,7 @@ else : endif; // Reset property. -// @codingStandardsChangeSetting Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 1 +// phpcs:set Squiz.ControlStructures.ControlSignature requiredSpacesBeforeColon 1 // Intentional parse error. This should be the last test in the file. foreach From ec2709af434f3aaa25ee7ee735d2e46a2393f8f0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 8 Dec 2023 04:12:13 +0100 Subject: [PATCH 137/874] Changelog for #3881 / #128 --- CHANGELOG.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a2fbfbe2a..6209ee2d30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,8 +108,15 @@ The file documents changes to the PHP_CodeSniffer project. - 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 -- Generic/SpreadOperatorSpacingAfter: minor message readability improvement - - 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 - Thanks to Benjamin Loison (@Benjamin-Loison) for the patch - Various documentation improvements From e5c32123d0fcbcbe514ead2c4e62e34589643bde Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 4 Aug 2023 19:32:24 +0200 Subject: [PATCH 138/874] Generic/LowerCaseConstant: add tests with functions which don't create scope --- .../Generic/Tests/PHP/LowerCaseConstantUnitTest.inc | 9 +++++++++ .../Tests/PHP/LowerCaseConstantUnitTest.inc.fixed | 9 +++++++++ .../Generic/Tests/PHP/LowerCaseConstantUnitTest.php | 2 ++ 3 files changed, 20 insertions(+) diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc index 0307a0559d..c8c7754edf 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc @@ -98,3 +98,12 @@ class TypedThings { } $cl = function (int|FALSE $param = NULL, Type|NULL $obj = new MyObj(FALSE)) : string|FALSE|NULL {}; + +// Adding some extra tests to safeguard that function declarations which don't create scope are handled correctly. +interface InterfaceMethodsWithReturnTypeNoScopeOpener { + private function typed($param = TRUE) : string|FALSE|NULL; +} + +abstract class ClassMethodsWithReturnTypeNoScopeOpener { + abstract public function typed($param = FALSE) : TRUE; +} diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed index 3a6b094c86..cbb864e5fa 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed @@ -98,3 +98,12 @@ class TypedThings { } $cl = function (int|FALSE $param = null, Type|NULL $obj = new MyObj(false)) : string|FALSE|NULL {}; + +// Adding some extra tests to safeguard that function declarations which don't create scope are handled correctly. +interface InterfaceMethodsWithReturnTypeNoScopeOpener { + private function typed($param = true) : string|FALSE|NULL; +} + +abstract class ClassMethodsWithReturnTypeNoScopeOpener { + abstract public function typed($param = false) : TRUE; +} diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php index 582a0f0b45..99b69052fe 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php @@ -51,6 +51,8 @@ public function getErrorList($testFile='LowerCaseConstantUnitTest.inc') 94 => 2, 95 => 1, 100 => 2, + 104 => 1, + 108 => 1, ]; case 'LowerCaseConstantUnitTest.js': From aae1797c954c43a34bd1b8b00435084d9ba4bc3c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 4 Aug 2023 19:33:01 +0200 Subject: [PATCH 139/874] Generic/LowerCaseConstant: improve performance I noticed a PHPCS run on a particular code base being quite slow. Running the Performance report from PR 3810 showed the `Generic.PHP.LowerCaseConstant` sniff being the slowest sniff taking 27 seconds on a total sniff run time of 87 seconds (with a few hundred sniffs being run). A closer look at the sniff pointed to the "skip type declarations for typed properties" part of the sniff as the culprit - in combination with the code base in question having a lot of array properties containing large arrays with mostly `true/false/null` values. Every single one of those `true/false/null` values would trigger a condition check and then a check whether the token was in the property value, causing lots of token walking for those long arrays. This PR should fix that by changing the logic for skipping over the property type declaration. Instead of checking for each `true/false/null` whether it is a property type (or value), the sniff now listens to all property modifier keywords and skips over the type declaration from there, meaning that `true/false/null` found within property values will no longer need to do a conditions check/"am I a value or a type?" check. For this particular code base, with this change, the sniff run time goes down from 27 seconds to 0.102 seconds. Includes additional tests for the "property type skipping" code to verify it works correctly, but also that it won't cause issues with too much/the wrong things being skipped. > Note: an additional performance boost could be gained by not recording metrics and bowing out early for any `true/false/null` which are already lowercase, but that would change the functionality of the sniff. --- CHANGELOG.md | 1 + .../Sniffs/PHP/LowerCaseConstantSniff.php | 85 +++++++++++++++---- .../Tests/PHP/LowerCaseConstantUnitTest.inc | 40 +++++++++ .../PHP/LowerCaseConstantUnitTest.inc.fixed | 40 +++++++++ .../Tests/PHP/LowerCaseConstantUnitTest.php | 6 ++ 5 files changed, 155 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6209ee2d30..221c841e9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,7 @@ The file documents changes to the PHP_CodeSniffer project. - 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 diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php index c2254b34fa..f2e3629df0 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php @@ -37,6 +37,29 @@ class LowerCaseConstantSniff implements Sniff T_NULL => T_NULL, ]; + /** + * Token types which can be encountered in a property type declaration. + * + * @var array + */ + private $propertyTypeTokens = [ + T_CALLABLE => T_CALLABLE, + T_SELF => T_SELF, + T_PARENT => T_PARENT, + T_FALSE => T_FALSE, + T_TRUE => T_TRUE, + T_NULL => T_NULL, + T_STRING => T_STRING, + T_NAME_QUALIFIED => T_NAME_QUALIFIED, + T_NAME_FULLY_QUALIFIED => T_NAME_FULLY_QUALIFIED, + T_NAME_RELATIVE => T_NAME_RELATIVE, + T_NS_SEPARATOR => T_NS_SEPARATOR, + T_NAMESPACE => T_NAMESPACE, + T_TYPE_UNION => T_TYPE_UNION, + T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, + T_NULLABLE => T_NULLABLE, + ]; + /** * Returns an array of tokens this test wants to listen for. @@ -47,7 +70,13 @@ public function register() { $targets = $this->targets; - // Register function keywords to filter out type declarations. + // Register scope modifiers to filter out property type declarations. + $targets += Tokens::$scopeModifiers; + $targets[] = T_VAR; + $targets[] = T_STATIC; + $targets[] = T_READONLY; + + // Register function keywords to filter out param/return type declarations. $targets[] = T_FUNCTION; $targets[] = T_CLOSURE; $targets[] = T_FN; @@ -64,12 +93,43 @@ public function register() * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * - * @return void|int + * @return void|int Optionally returns a stack pointer. The sniff will not be + * called again on the current file until the returned stack + * pointer is reached. */ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); + /* + * Skip over type declarations for properties. + * + * Note: for other uses of the visibility modifiers (functions, constants, trait use), + * nothing relevant will be skipped as the next non-empty token will be an "non-skippable" + * one. + * Functions are handled separately below (and then skip to their scope opener), so + * this should also not cause any confusion for constructor property promotion. + * + * For other uses of the "static" keyword, it also shouldn't be problematic as the only + * time the next non-empty token will be a "skippable" token will be in return type + * declarations, in which case, it is correct to skip over them. + */ + + if (isset(Tokens::$scopeModifiers[$tokens[$stackPtr]['code']]) === true + || $tokens[$stackPtr]['code'] === T_VAR + || $tokens[$stackPtr]['code'] === T_STATIC + || $tokens[$stackPtr]['code'] === T_READONLY + ) { + $skipOver = (Tokens::$emptyTokens + $this->propertyTypeTokens); + $skipTo = $phpcsFile->findNext($skipOver, ($stackPtr + 1), null, true); + if ($skipTo !== false) { + return $skipTo; + } + + // If we're at the end of the file, just return. + return; + } + // Handle function declarations separately as they may contain the keywords in type declarations. if ($tokens[$stackPtr]['code'] === T_FUNCTION || $tokens[$stackPtr]['code'] === T_CLOSURE @@ -79,9 +139,15 @@ public function process(File $phpcsFile, $stackPtr) return; } + // Make sure to skip over return type declarations. $end = $tokens[$stackPtr]['parenthesis_closer']; if (isset($tokens[$stackPtr]['scope_opener']) === true) { $end = $tokens[$stackPtr]['scope_opener']; + } else { + $skipTo = $phpcsFile->findNext([T_SEMICOLON, T_OPEN_CURLY_BRACKET], ($end + 1), null, false, null, true); + if ($skipTo !== false) { + $end = $skipTo; + } } // Do a quick check if any of the targets exist in the declaration. @@ -114,21 +180,6 @@ public function process(File $phpcsFile, $stackPtr) return $end; }//end if - // Handle property declarations separately as they may contain the keywords in type declarations. - if (isset($tokens[$stackPtr]['conditions']) === true) { - $conditions = $tokens[$stackPtr]['conditions']; - $lastCondition = end($conditions); - if (isset(Tokens::$ooScopeTokens[$lastCondition]) === true) { - // This can only be an OO constant or property declaration as methods are handled above. - $equals = $phpcsFile->findPrevious(T_EQUAL, ($stackPtr - 1), null, false, null, true); - if ($equals !== false) { - $this->processConstant($phpcsFile, $stackPtr); - } - - return; - } - } - // Handle everything else. $this->processConstant($phpcsFile, $stackPtr); diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc index c8c7754edf..5dfb75560a 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc @@ -107,3 +107,43 @@ interface InterfaceMethodsWithReturnTypeNoScopeOpener { abstract class ClassMethodsWithReturnTypeNoScopeOpener { abstract public function typed($param = FALSE) : TRUE; } + +// Additional tests to safeguard improved property type skip logic. +readonly class Properties { + use SomeTrait { + sayHello as private myPrivateHello; + } + + public Type|FALSE|NULL $propertyA = array( + 'itemA' => TRUE, + 'itemB' => FALSE, + 'itemC' => NULL, + ), $propertyB = FALSE; + + protected \FullyQualified&Partially\Qualified&namespace\Relative $propertyC; + var ?TRUE $propertyD; + static array|callable|FALSE|self|parent $propertyE = TRUE; + private + // phpcs:ignore Stnd.Cat.Sniff -- for reasons. + TRUE /*comment*/ + $propertyF = TRUE; + + public function __construct( + public FALSE|NULL $promotedPropA, + readonly callable|TRUE $promotedPropB, + ) { + static $var; + echo static::class; + static::foo(); + $var = $var instanceof static; + $obj = new static(); + } + + public static function foo(): static|self|FALSE { + $callable = static function() {}; + } +} + +// Last coding/parse error. +// This has to be the last test in the file. +function UnclosedCurly (): FALSE { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed index cbb864e5fa..6b999cc456 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed @@ -107,3 +107,43 @@ interface InterfaceMethodsWithReturnTypeNoScopeOpener { abstract class ClassMethodsWithReturnTypeNoScopeOpener { abstract public function typed($param = false) : TRUE; } + +// Additional tests to safeguard improved property type skip logic. +readonly class Properties { + use SomeTrait { + sayHello as private myPrivateHello; + } + + public Type|FALSE|NULL $propertyA = array( + 'itemA' => true, + 'itemB' => false, + 'itemC' => null, + ), $propertyB = false; + + protected \FullyQualified&Partially\Qualified&namespace\Relative $propertyC; + var ?TRUE $propertyD; + static array|callable|FALSE|self|parent $propertyE = true; + private + // phpcs:ignore Stnd.Cat.Sniff -- for reasons. + TRUE /*comment*/ + $propertyF = true; + + public function __construct( + public FALSE|NULL $promotedPropA, + readonly callable|TRUE $promotedPropB, + ) { + static $var; + echo static::class; + static::foo(); + $var = $var instanceof static; + $obj = new static(); + } + + public static function foo(): static|self|FALSE { + $callable = static function() {}; + } +} + +// Last coding/parse error. +// This has to be the last test in the file. +function UnclosedCurly (): FALSE { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php index 99b69052fe..5cb253cad4 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php @@ -53,6 +53,12 @@ public function getErrorList($testFile='LowerCaseConstantUnitTest.inc') 100 => 2, 104 => 1, 108 => 1, + 118 => 1, + 119 => 1, + 120 => 1, + 121 => 1, + 125 => 1, + 129 => 1, ]; case 'LowerCaseConstantUnitTest.js': From b6230384f1980042dfdfce019583bd9acf3ff46a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 8 Dec 2023 04:14:30 +0100 Subject: [PATCH 140/874] Changelog: remove link syntax for releases which don't have a git tag --- CHANGELOG.md | 76 ++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 221c841e9a..d7137e43c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4198,7 +4198,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Adds new error message to ban empty lines in multi-line function calls - Fixed bug #18975 : "Closing parenthesis must be on a line by itself" also causes indentation error -## [1.3.1] - 2011-11-03 +## 1.3.1 - 2011-11-03 ### Changed - All report file command line arguments now work with relative paths (request #17240) - The extensions command line argument now supports multi-part file extensions (request #17227) @@ -4265,7 +4265,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Thanks to Bjorn Katuin for the patch - Fixed bug #18951 : weird behaviour with closures and multi-line use () params -## [1.3.0] - 2011-03-17 +## 1.3.0 - 2011-03-17 ### Changed - Add a new token T_CLOSURE that replaces T_FUNCTION if the function keyword is anonymous - Many Squiz sniffs no longer report errors when checking closures; they are now ignored @@ -4285,7 +4285,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Thanks to Dave Perrett for the patch - Fixed bug #18336 : Function isUnderscoreName gives php notices -## [1.3.0RC2] - 2011-01-14 +## 1.3.0RC2 - 2011-01-14 ### Changed - You can now print multiple reports for each run and print each to the screen or a file (request #12434) - Format is --report-[report][=file] (e.g., --report-xml=out.xml) @@ -4353,7 +4353,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #18191 : Squiz.PHP.LowercasePHPFunctions does not work with new Date() - Fixed bug #18193 : CodeSniffer doesn't reconize CR (\r) line endings -## [1.3.0RC1] - 2010-09-03 +## 1.3.0RC1 - 2010-09-03 ### Changed - Added exclude pattern support to ruleset.xml file so you can specify ignore patterns in a standard (request #17683) - Use new exclude-pattern tags to include the ignore rules into your ruleset.xml file @@ -4385,7 +4385,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #17742 : EmbeddedPhpSniff reacts negatively to file without closing php tag - Fixed bug #17823 : Notice: Please no longer include PHPUnit/Framework.php -## [1.3.0a1] - 2010-07-15 +## 1.3.0a1 - 2010-07-15 ### Changed - All CodingStandard.php files have been replaced by ruleset.xml files - Custom standards will need to be converted over to this new format to continue working @@ -4430,7 +4430,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #17420 : Uncaught exception when comment before function brace - Fixed bug #17503 : closures formatting is not supported -## [1.2.2] - 2010-01-27 +## 1.2.2 - 2010-01-27 ### Changed - The core PHP_CodeSniffer_File methods now understand the concept of closures (feature request #16866) - Thanks to Christian Kaps for the sample code @@ -4498,7 +4498,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #16976 : The phpcs attempts to process symbolic links that don't resolve to files - Fixed bug #17017 : Including one file in the files sniffed alters errors reported for another file -## [1.2.1] - 2009-11-17 +## 1.2.1 - 2009-11-17 ### Changed - Added a new report type --report=svnblame to show how many errors and warnings were committed by each author - Also shows the percentage of their code that are errors and warnings @@ -4553,7 +4553,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Thanks to Alexey Shein for the patch - Fixed bug #16792 : Bug in Generic_Sniffs_PHP_ForbiddenFunctionsSniff -## [1.2.0] - 2009-08-17 +## 1.2.0 - 2009-08-17 ### Changed - Installed standards are now favoured over custom standards when using the cmd line arg with relative paths - Unit tests now use a lot less memory while running @@ -4567,7 +4567,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #16453 : function declaration long line splitted error - Fixed bug #16482 : phpcs-svn-pre-commit ignores extensions parameter -## [1.2.0RC3] - 2009-07-07 +## 1.2.0RC3 - 2009-07-07 ### Changed - You can now use @codingStandardsIgnoreStart and @...End comments to suppress messages (feature request #14002) - A warning is now included for files without any code when short_open_tag is set to Off (feature request #12952) @@ -4576,7 +4576,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - MySource IncludeSystemSniff now recognises widget action classes - MySource IncludeSystemSniff now knows about unit test classes and changes rules accordingly -## [1.2.0RC2] - 2009-05-25 +## 1.2.0RC2 - 2009-05-25 ### Changed - Test suite can now be run using the full path to AllTests.php (feature request #16179) @@ -4589,7 +4589,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #16170 : Undefined Offset -1 in MultiLineConditionSniff.php on line 68 - Fixed bug #16175 : Bug in Squiz-IncrementDecrementUsageSniff -## [1.2.0RC1] - 2009-03-09 +## 1.2.0RC1 - 2009-03-09 ### Changed - Reports that are output to a file now include a trailing newline at the end of the file - Fixed sniff names not shown in -vvv token processing output @@ -4614,7 +4614,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #15722 : "declare(encoding = 'utf-8');" leads to "Missing file doc comment" - Fixed bug #15910 : Object operator indention not calculated correctly -## [1.2.0a1] - 2008-12-18 +## 1.2.0a1 - 2008-12-18 ### Changed - PHP_CodeSniffer now has a CSS tokenizer for checking CSS files - Added support for a new multi-file sniff that sniffs all processed files at once @@ -4724,7 +4724,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #15231 : Notice: Uninitialized string offset: 0 in FileCommentSniff.php on line 555 - Fixed bug #15336 : Notice: Undefined offset: 2 in /usr/share/php/PHP/CodeSniffer/File.php on line -## [1.1.0] - 2008-07-14 +## 1.1.0 - 2008-07-14 ### Changed - PEAR FileCommentSniff now allows tag orders to be overridden in child classes - Thanks to Jeff Hodsdon for the patch @@ -4740,7 +4740,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #14250 : ArrayDeclarationSniff emit warnings at malformed array - Fixed bug #14251 : --extensions option doesn't work -## [1.1.0RC3] - 2008-07-03 +## 1.1.0RC3 - 2008-07-03 ### Changed - PEAR FileCommentSniff now allows tag orders to be overridden in child classes - Thanks to Jeff Hodsdon for the patch @@ -4756,7 +4756,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #14250 : ArrayDeclarationSniff emit warnings at malformed array - Fixed bug #14251 : --extensions option doesn't work -## [1.1.0RC2] - 2008-06-13 +## 1.1.0RC2 - 2008-06-13 ### Changed - Permission denied errors now stop script execution but still display current errors (feature request #14076) - Added Squiz ValidArrayIndexNameSniff to ensure array indexes do not use camel case @@ -4770,7 +4770,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Squiz ValidClassNameSniff now throws warning for possible parse errors - Squiz ClosingDeclarationCommentSniff now throws additional warnings for parse errors -## [1.1.0RC1] - 2008-05-13 +## 1.1.0RC1 - 2008-05-13 ### Changed - Added support for multiple tokenizers so PHP_CodeSniffer can check more than just PHP files - PHP_CodeSniffer now has a JS tokenizer for checking JavaScript files @@ -4834,7 +4834,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #13446 : crash with src of phpMyAdmin - Thanks to Manuel Pichler for the path -## [1.0.1a1] - 2008-04-21 +## 1.0.1a1 - 2008-04-21 ### Changed - Fixed error in PEAR ValidClassNameSniff when checking class names with double underscores - Moved Squiz InlineControlStructureSniff into Generic standard @@ -4851,7 +4851,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #13846 : Bug in Squiz.NonExecutableCodeSniff - Fixed bug #13849 : infinite loop in PHP_CodeSniffer_File::findNext() -## [1.0.1] - 2008-02-04 +## 1.0.1 - 2008-02-04 ### Changed - Squiz ArrayDeclarationSniff now throws error if the array keyword is followed by a space - Squiz ArrayDeclarationSniff now throws error for empty multi-line arrays @@ -4880,7 +4880,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #12957 : PHP 5.3 magic method __callStatic - Thanks to Manuel Pichler for the patch -## [1.0.0] - 2007-12-21 +## 1.0.0 - 2007-12-21 ### Changed - You can now specify the full path to a coding standard on the command line (feature request #11886) - This allows you to use standards that are stored outside of PHP_CodeSniffer's own Standard dir @@ -4910,7 +4910,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Thanks to Renoiv for the patch - Fixed bug #12651 : Increment/Decrement Operators Usage at -1 -## [1.0.0RC3] - 2007-11-30 +## 1.0.0RC3 - 2007-11-30 ### Changed - Added new command line argument --tab-width that will convert tabs to spaces before testing - This allows you to use the existing sniffs that check for spaces even when you use tabs @@ -4938,7 +4938,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Thanks to Sebastian Bergmann for the patch. - Fixed bug #12517 : getNewlineAfter() and dos files -## [1.0.0RC2] - 2007-11-14 +## 1.0.0RC2 - 2007-11-14 ### Changed - Added a new Checkstyle report format - Like the current XML format but modified to look like Checkstyle output @@ -4969,7 +4969,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Thanks to Richard Quadling for the patch - Fixed bug #12378 : equal sign alignments problem with while() -## [1.0.0RC1] - 2007-11-01 +## 1.0.0RC1 - 2007-11-01 ### Changed - Main phpcs script can now be run from a CVS checkout without installing the package - Added a new CSV report format @@ -5018,7 +5018,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #12316 : PEAR is no longer the default standard - Fixed bug #12321 : wrong detection of missing function docblock -## [0.9.0] - 2007-09-24 +## 0.9.0 - 2007-09-24 ### Changed - Added a config system for setting config data across phpcs runs - You can now change the default coding standard from PEAR to something else @@ -5029,7 +5029,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Thanks to Johann-Peter Hartmann for the contribution of some sniffs - Thanks to Holger Kral for the Code Analyzer sniff -## [0.8.0] - 2007-08-08 +## 0.8.0 - 2007-08-08 ### Changed - Added new XML report format; --report=xml (feature request #11535) - Thanks to Brett Bieber for the patch @@ -5054,7 +5054,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo ### Fixed - Fixed bug #11473 : Invalid CamelCaps name when numbers used in names -## [0.7.0] - 2007-07-02 +## 0.7.0 - 2007-07-02 ### Changed - BC BREAK: EOL character is now auto-detected and used instead of hard-coded \n - Pattern sniffs must now specify "EOL" instead of "\n" or "\r\n" to use auto-detection @@ -5101,7 +5101,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Thanks to Blair Robertson for the patch - Fixed bug #11120 : Uninitialized string offset in AbstractParser.php on line 200 -## [0.6.0] - 2007-05-15 +## 0.6.0 - 2007-05-15 ### Changed - The number of errors and warnings found is now shown for each file while checking the file if verbosity is enabled - Now using PHP_EOL instead of hard-coded \n so output looks good on Windows (feature request #10761) @@ -5118,7 +5118,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #10983 : phpcs outputs notices when checking invalid PHP - Fixed bug #10980 : Incorrect warnings for equals sign -## [0.5.0] - 2007-04-17 +## 0.5.0 - 2007-04-17 ### Changed - BC BREAK: Coding standards now require a class to be added so PHP_CodeSniffer can get information from them - Please read the end user docs for info about the new class required for all coding standards @@ -5149,7 +5149,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Errors now thrown for using ob_get_clean/flush functions to end buffers in Squiz OutputBufferingIndentSniff - Errors now thrown for all missing member variable comments in Squiz VariableCommentSniff -## [0.4.0] - 2007-02-19 +## 0.4.0 - 2007-02-19 ### Changed - Standard name specified with --standard command line argument is no longer case sensitive - Long error and warning messages are now wrapped to 80 characters in the full error report (thanks Endre Czirbesz) @@ -5166,7 +5166,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed incorrect errors for arrays that only contain other arrays in Squiz ArrayDeclarationSniff - Fixed bug #9844 : throw new Exception(\n accidentally reported as error but it ain't -## [0.3.0] - 2007-01-11 +## 0.3.0 - 2007-01-11 ### Changed - Updated package.xml to version 2 - Specifying coding standard on command line is now optional, even if you have multiple standards installed @@ -5191,11 +5191,11 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #9274 : nested_parenthesis element not set for open and close parenthesis tokens - Fixed bug #9411 : too few pattern characters cause incorrect error report -## [0.2.1] - 2006-11-09 +## 0.2.1 - 2006-11-09 ### Fixed - Fixed bug #9274 : nested_parenthesis element not set for open and close parenthesis tokens -## [0.2.0] - 2006-10-13 +## 0.2.0 - 2006-10-13 ### Changed - Added a generic standards package that will contain generic sniffs to be used in specific coding standards - thanks to Frederic Poeydomenge for the idea @@ -5220,7 +5220,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Fixed bug #8841 : comments taken as whitespace - Fixed bug #8884 : another problem with nested switch() statements -## [0.1.1] - 2006-09-25 +## 0.1.1 - 2006-09-25 ### Changed - Added unit tests for all PEAR sniffs - Exception class now extends from PEAR_Exception @@ -5228,17 +5228,17 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo ### Fixed - Fixed summary report so files without errors but with warnings are not shown when warnings are hidden -## [0.1.0] - 2006-09-19 +## 0.1.0 - 2006-09-19 ### Changed - Reorganised package contents to conform to PEAR standards - Changed version numbering to conform to PEAR standards - Removed duplicate require_once() of Exception.php from CodeSniffer.php -## [0.0.5] - 2006-09-18 +## 0.0.5 - 2006-09-18 ### Fixed - Fixed .bat file for situation where php.ini cannot be found so include_path is not set -## [0.0.4] - 2006-08-28 +## 0.0.4 - 2006-08-28 ### Changed - Added .bat file for easier running of PHP_CodeSniffer on Windows - Sniff that checks method names now works for PHP4 style code where there is no scope keyword @@ -5256,7 +5256,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Sniff that checks spacing after commas in function calls no longer reports too many errors for some code - Sniff that checks control structure declarations now gives more descriptive error message -## [0.0.3] - 2006-08-22 +## 0.0.3 - 2006-08-22 ### Changed - Added sniff to check for invalid class and interface names - Added sniff to check for invalid function and method names @@ -5267,7 +5267,7 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo ### Fixed - Fixed error where comments were not allowed on the same line as a control structure declaration -## [0.0.2] - 2006-07-25 +## 0.0.2 - 2006-07-25 ### Changed - Removed the including of checked files to stop errors caused by parsing them - Removed the use of reflection so checked files do not have to be included @@ -5284,6 +5284,6 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo - Reordered command line args to put switches first (although order is not enforced) - Switches can now be specified together (eg. php -nv) as well as separately (phpcs -n -v) -## [0.0.1] - 2006-07-19 +## 0.0.1 - 2006-07-19 ### Added - Initial preview release From 9f36b173f3f3fa2d4c66da590141fedb080db26d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 8 Dec 2023 04:15:02 +0100 Subject: [PATCH 141/874] Changelog: add diff links for the releases which have a git tag --- CHANGELOG.md | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7137e43c2..96df69fc76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5287,3 +5287,93 @@ Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) fo ## 0.0.1 - 2006-07-19 ### Added - Initial preview release + +[Unreleased]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/master...HEAD +[3.8.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.2...3.8.0 +[3.7.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.1...3.7.2 +[3.7.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.0...3.7.1 +[3.7.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.6.2...3.7.0 +[3.6.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.6.1...3.6.2 +[3.6.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.6.0...3.6.1 +[3.6.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.5.8...3.6.0 +[3.5.8]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.5.7...3.5.8 +[3.5.7]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.5.6...3.5.7 +[3.5.6]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.5.5...3.5.6 +[3.5.5]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.5.4...3.5.5 +[3.5.4]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.5.3...3.5.4 +[3.5.3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.5.2...3.5.3 +[3.5.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.5.1...3.5.2 +[3.5.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.5.0...3.5.1 +[3.5.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.4.2...3.5.0 +[3.4.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.4.1...3.4.2 +[3.4.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.4.0...3.4.1 +[3.4.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.3.2...3.4.0 +[3.3.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.3.1...3.3.2 +[3.3.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.3.0...3.3.1 +[3.3.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.2.3...3.3.0 +[3.2.3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.2.2...3.2.3 +[3.2.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.2.1...3.2.2 +[3.2.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.2.0...3.2.1 +[3.2.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.1.1...3.2.0 +[3.1.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.1.0...3.1.1 +[3.1.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.0.2...3.1.0 +[3.0.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.0.1...3.0.2 +[3.0.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.0.0...3.0.1 +[3.0.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.0.0RC4...3.0.0 +[3.0.0RC4]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.0.0RC3...3.0.0RC4 +[3.0.0RC3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.0.0RC2...3.0.0RC3 +[3.0.0RC2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.0.0RC1...3.0.0RC2 +[3.0.0RC1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.0.0a1...3.0.0RC1 +[3.0.0a1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.9.2...3.0.0a1 +[2.9.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.9.1...2.9.2 +[2.9.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.9.0...2.9.1 +[2.9.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.8.1...2.9.0 +[2.8.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.8.0...2.8.1 +[2.8.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.7.1...2.8.0 +[2.7.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.7.0...2.7.1 +[2.7.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.6.2...2.7.0 +[2.6.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.6.1...2.6.2 +[2.6.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.6.0...2.6.1 +[2.6.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.5.1...2.6.0 +[2.5.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.5.0...2.5.1 +[2.5.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.4.0...2.5.0 +[2.4.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.3.4...2.4.0 +[2.3.4]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.3.3...2.3.4 +[2.3.3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.3.2...2.3.3 +[2.3.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.3.1...2.3.2 +[2.3.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.3.0...2.3.1 +[2.3.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.2.0...2.3.0 +[2.2.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.1.0...2.2.0 +[2.1.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.0.0...2.1.0 +[2.0.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.0.0RC4...2.0.0 +[2.0.0RC4]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.0.0RC3...2.0.0RC4 +[2.0.0RC3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.0.0RC2...2.0.0RC3 +[2.0.0RC2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.0.0RC1...2.0.0RC2 +[2.0.0RC1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.0.0a2...2.0.0RC1 +[2.0.0a2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/2.0.0a1...2.0.0a2 +[2.0.0a1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.6...2.0.0a1 +[1.5.6]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.5...1.5.6 +[1.5.5]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.4...1.5.5 +[1.5.4]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.3...1.5.4 +[1.5.3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.2...1.5.3 +[1.5.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.1...1.5.2 +[1.5.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.0...1.5.1 +[1.5.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.0RC4...1.5.0 +[1.5.0RC4]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.0RC3...1.5.0RC4 +[1.5.0RC3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.0RC2...1.5.0RC3 +[1.5.0RC2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.5.0RC1...1.5.0RC2 +[1.5.0RC1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.4.8...1.5.0RC1 +[1.4.8]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.4.7...1.4.8 +[1.4.7]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.4.6...1.4.7 +[1.4.6]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.4.5...1.4.6 +[1.4.5]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.4.4...1.4.5 +[1.4.4]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.4.3...1.4.4 +[1.4.3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.4.2...1.4.3 +[1.4.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.4.1...1.4.2 +[1.4.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.4.0...1.4.1 +[1.4.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.3.6...1.4.0 +[1.3.6]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.3.5...1.3.6 +[1.3.5]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.3.4...1.3.5 +[1.3.4]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.3.3...1.3.4 +[1.3.3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.3.2...1.3.3 +[1.3.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.3.1...1.3.2 From e021db59ede3f47ae05093f31ee451d48998e641 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 8 Dec 2023 06:10:24 +0100 Subject: [PATCH 142/874] Config: update version tag line --- src/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index 6687ae8d03..141d1bcb5a 100644 --- a/src/Config.php +++ b/src/Config.php @@ -753,7 +753,7 @@ public function processLongArgument($arg, $pos) throw new DeepExitException($output, 0); case 'version': $output = 'PHP_CodeSniffer version '.self::VERSION.' ('.self::STABILITY.') '; - $output .= 'by Squiz (https://www.squiz.net)'.PHP_EOL; + $output .= 'by Squiz and PHPCSStandards'.PHP_EOL; throw new DeepExitException($output, 0); case 'colors': if (isset(self::$overriddenDefaults['colors']) === true) { From 5805f7a4e4958dbb5e944ef1e6edae0a303765e7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 8 Dec 2023 05:46:49 +0100 Subject: [PATCH 143/874] Changelog: touch up for 3.8.0 release Includes making sure issue numbers will link to the correct repo. --- CHANGELOG.md | 189 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 121 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96df69fc76..450dbd4a12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,30 +3,42 @@ The file documents changes to the PHP_CodeSniffer project. ## [Unreleased] +_Nothing yet._ + + +## [3.8.0] - 2023-12-08 + [Squizlabs/PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is dead. Long live [PHPCSStandards/PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer)! ### Breaking Changes -- The `squizlabs/PHP_CodeSniffer` repository has been abandoned. This repository will serve as the continuation of the project. +- 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](https://github.com/squizlabs/PHP_CodeSniffer/issues/3932). + - 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 will now point to the new repo and everything will continue to work as before.** + - **_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 URL from `https://squizlabs.github.io/PHP_CodeSniffer/[phpcs|phpcbf].phar` to `https://phars.phpcodesniffer.com/[phpcs|phpcbf].phar`. - - Installation of PHP_CodeSniffer via PEAR is no longer supported. - - Note: this does not affect the PEAR sniffs. + - 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_CodeSnifffer/releases/latest/download/[phpcs|phpcbf].phar` to `https://phars.phpcodesniffer.com/[phpcs|phpcbf].phar`. + - For users who install PHP_CodeSniffer via the [setup-php](https://github.com/shivammathur/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. +- 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 readonly classes to File::getClassProperties() through a new is_readonly array index in the return value +- 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 readonly class to a number of sniffs +- 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 @@ -34,26 +46,29 @@ The file documents changes to the PHP_CodeSniffer project. - Squiz.Commenting.FileComment - Squiz.Commenting.InlineComment - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch -- Added support for `true` as a stand-alone type declaration - - The `File::getMethodProperties()`, `File::getMethodParameters()` and `File::getMemberProperties()` methods now all support the `true` type. +- 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 `true` as a stand-alone type to a number of sniffs +- 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, mostly useful for sniff maintainers, to allow for finding "slow" sniffs. +- 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 -- Squiz.Commenting.FunctionComment: new ParamNameUnexpectedAmpersandPrefix error for parameters annotated as passed by reference while the parameter is not passed by reference +- 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](https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/59/commits/26384ebfcc0b1c1651b0e1e40c9b6c8c22881832). +- 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](https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/59/commits/26384ebfcc0b1c1651b0e1e40c9b6c8c22881832) - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch ### Changed @@ -66,14 +81,14 @@ The file documents changes to the PHP_CodeSniffer project. - 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. + - 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 an auto width cannot be determined +- 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 @@ -83,16 +98,13 @@ The file documents changes to the PHP_CodeSniffer project. - 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.PHP.RequireStrictTypes has a 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 - 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. +- 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 - Thanks to @Daimona for the patch @@ -124,89 +136,130 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Andrew Dawes (@AndrewDawes), Danny van der Sluijs (@DannyvdSluijs) and Juliette Reinders Folmer (@jrfnl) for the patches ### Removed -- Removed support for installing via PEAR - - Use composer or the phar files +- Removed support for installation via PEAR + - Use composer or the PHAR files instead ### Fixed -- Fixed bug #3386 : PSR1/SideEffects : improved recognition of disable/enable annotations +- 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 #3557 : Squiz.Arrays.ArrayDeclaration will now ignore PHP 7.4 array unpacking when determining whether an array is associative +- 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 #3715 : Generic/UnusedFunctionParameter: fixed incorrect errorcode for closures/arrow functions nested within extended classes/classes which implement. +- 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 #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 +- 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 #3720 : Generic/RequireStrictTypes : did not handle multi-directive declare statements +- 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 #3722 : Potential "Uninitialized string offset 1" in octal notation backfill +- Fixed bug [#3720] : Generic/RequireStrictTypes : did not handle multi-directive declare statements - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch -- Fixed bug #3728 : PHP 8.2 | PSR1/SideEffects: allow for readonly classes +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 : Squiz/LowercasePHPFunctions + Generic/ForbiddenFunctions: bug fix for class names in attributes +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 [#3806] : Squiz.PHP.InnerFunctions sniff now correctly reports inner functions declared within a closure - Thanks to @Daimona for the patch -- Fixed bug #3809 : GitBlame report was broken when passing a basepath +- Fixed bug [#3809] : GitBlame report was broken when passing a basepath - Thanks to Chris (@datengraben) for the patch -- Fixed bug #3813 : Squiz.Commenting.FunctionComment: false positive for parameter name mismatch on parameters annotated as passed by reference +- 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 #3816 : PSR12/FileHeader: bug fix - false positives on PHP 8.2+ readonly classes - - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch -- Fixed bug #3833 : Generic.PHP.LowerCaseType: fixed potential undefined array index notice +- 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 +- 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 +- 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. +- 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 +- 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 +- 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 [#3877] : Filter names can be case-sensitive. The -h help text will now display the correct case for the available filters - Thanks to @simonsan for the patch -- Fixed bug #3893 : Generic/DocComment : the SpacingAfterTagGroup fixer could accidentally remove ignore annotations +- 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 +- 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 +- Fixed bug [#3904] : Squiz/FunctionSpacing : prevent potential fixer conflict - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch -- Fixed bug #3906 : Tokenizer/CSS: fixed a bug related to the unsupported slash comment syntax +- 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 stored unknown "long" arguments in a (dynamic) `$values` property +- 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 -Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) for reviewing quite a few of the PRs for this release. +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. + +[#2857]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2857 +[#3386]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3386 +[#3557]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3557 +[#3592]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3592 +[#3715]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3715 +[#3717]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3717 +[#3720]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3720 +[#3722]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3722 +[#3736]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3736 +[#3739]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3739 +[#3770]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3770 +[#3773]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3773 +[#3776]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3776 +[#3777]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3777 +[#3778]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3778 +[#3779]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3779 +[#3785]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3785 +[#3787]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3787 +[#3789]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3789 +[#3790]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3790 +[#3797]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3797 +[#3801]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3801 +[#3805]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3805 +[#3806]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3806 +[#3809]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3809 +[#3813]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3813 +[#3833]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3833 +[#3846]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3846 +[#3854]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3854 +[#3856]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3856 +[#3867]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3867 +[#3877]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3877 +[#3893]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3893 +[#3898]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3898 +[#3904]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3904 +[#3906]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3906 +[#3913]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3913 ## [3.7.2] - 2023-02-23 ### Changed From 2d9a90d4023d745612f8d09a405849d68c222f0b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 8 Dec 2023 14:22:06 +0100 Subject: [PATCH 144/874] Config: update version nr to next --- src/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index 141d1bcb5a..756b69a5f1 100644 --- a/src/Config.php +++ b/src/Config.php @@ -81,7 +81,7 @@ class Config * * @var string */ - const VERSION = '3.8.0'; + const VERSION = '3.8.1'; /** * Package stability; either stable, beta or alpha. From 9a38a4f0410349a64e874a31f4cc5952f1491c17 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Fri, 8 Dec 2023 20:37:39 +0000 Subject: [PATCH 145/874] Fix PHPStan (#139) Remove an ignore which is no longer needed since PHPStan 1.10.48. --- phpstan.neon.dist | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 92ffb3fc64..d5d4a78f78 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -5,11 +5,6 @@ parameters: - src bootstrapFiles: - tests/bootstrap.php - ignoreErrors: - - - count: 1 - message: '~^Undefined variable: \$phpCodeSnifferConfig$~' - path: src/Config.php dynamicConstantNames: - PHP_CODESNIFFER_IN_TESTS From 222e87d8adfa3752d963c6255ac3742ccaf0c237 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 24 Nov 2023 13:54:52 +0100 Subject: [PATCH 146/874] Composer: sort of "normalize" the file Well, mostly (scripts are not alphabetized, but still grouped by task). Note: this is done as a one-time only action. The normalize script will **_not_** be run in CI to enforce normalization. Style has been standardized to `--indent-style=space --indent-size=4`. Ref: https://github.com/ergebnis/composer-normalize --- composer.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index a477d20a2b..1b18633fb6 100644 --- a/composer.json +++ b/composer.json @@ -1,14 +1,13 @@ { "name": "squizlabs/php_codesniffer", "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "license": "BSD-3-Clause", "type": "library", "keywords": [ "phpcs", "standards", "static analysis" ], - "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", - "license": "BSD-3-Clause", "authors": [ { "name": "Greg Sherwood", @@ -19,34 +18,35 @@ "role": "Current lead" }, { - "name" : "Contributors", - "homepage" : "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "support": { "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki", "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy" }, - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, "require": { "php": ">=5.4.0", + "ext-simplexml": "*", "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "ext-simplexml": "*" + "ext-xmlwriter": "*" }, "require-dev": { "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, "scripts": { "cs": [ "@php ./bin/phpcs" From 0126667bbcdc722ec005abb263e7632f01f9d99f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Dec 2023 11:27:49 +0100 Subject: [PATCH 147/874] GH Actions/label mngmnt: auto-remove merge conflict label on PR merge ... as a PR wouldn't have been merged if the merge conflict still existed. (Adding the "merge conflict" labels works really well, but they don't always seem to get removed quickly enough) --- .github/workflows/label-remove-outdated.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/label-remove-outdated.yml b/.github/workflows/label-remove-outdated.yml index e3229cd7c4..2853873c78 100644 --- a/.github/workflows/label-remove-outdated.yml +++ b/.github/workflows/label-remove-outdated.yml @@ -39,6 +39,7 @@ jobs: labels: | Status: awaiting feedback Status: close candidate + Status: has merge conflict Status: needs investigation Status: triage From 6ea8869fbbb6a92f203ca64dd296a509429829d9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 9 Dec 2023 03:21:34 +0100 Subject: [PATCH 148/874] GH Actions/label mngmnt: add additional triggers for merge conflict check ... in an attempt to get the action runner to remove the "has conflict" label when a PR is updated (which hopefully would have resolved the conflict). --- .github/workflows/label-merge-conflicts.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/label-merge-conflicts.yml b/.github/workflows/label-merge-conflicts.yml index d3d6927281..5ecf4877cd 100644 --- a/.github/workflows/label-merge-conflicts.yml +++ b/.github/workflows/label-merge-conflicts.yml @@ -1,9 +1,17 @@ name: Check PRs for merge conflicts on: + # Check for new conflicts due to merges. push: branches: - master + # Check conflicts in new PRs and for resolved conflicts due to an open PR being updated. + pull_request_target: + types: + - opened + - edited + - synchronize + - reopened # Cancels all previous workflow runs for the same branch that have not yet completed. concurrency: From b8a08c9bad970c13970e28caec79822f66165df9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 9 Dec 2023 04:22:27 +0100 Subject: [PATCH 149/874] GH Actions: split PHAR building task off to own script While it is still a good idea to make sure the PHAR building script works on all supported PHP versions, it is not necessary to run this task against all PHP versions on all pushes, nor to have the test runs wait until all PHAR building builds are done, as for the tests we only need the PHARs generated on PHP 8.0, which are the ones used in a release. This commit splits the PHAR building job off to its own script, only keeping the PHAR build against PHP 8.0 in the `test` workflow. While this does mean there is now some duplication in the scripts, I find it more relevant to make the builds faster. --- .github/workflows/build-phar.yml | 54 ++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 15 ++------- 2 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/build-phar.yml diff --git a/.github/workflows/build-phar.yml b/.github/workflows/build-phar.yml new file mode 100644 index 0000000000..9a75c1db59 --- /dev/null +++ b/.github/workflows/build-phar.yml @@ -0,0 +1,54 @@ +name: Build PHARs + +on: + # Run on pushes to master and on all pull requests. + # Prevent the build from running when there are only irrelevant changes. + push: + branches: + - master + paths-ignore: + - '**.md' + pull_request: + # Allow manually triggering the workflow. + workflow_dispatch: + +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + # Deliberately missing PHP 8.0 as that PHAR is build and used in the test workflow. + php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.1', '8.2', '8.3', '8.4'] + + name: "Build Phar on PHP: ${{ matrix.php }}" + + continue-on-error: ${{ matrix.php == '8.4' }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + ini-values: phar.readonly=Off, error_reporting=-1, display_errors=On + + - name: Build the phars + run: php scripts/build-phar.php + + # Both the below only check a file which is rarely changed and therefore unlikely to have issues. + # This test is about testing that the phars are functional, *not* about whether the code style complies. + - name: 'PHPCS: check code style using the Phar file to test the Phar is functional' + run: php phpcs.phar ./scripts + + - name: 'PHPCBF: fix code style using the Phar file to test the Phar is functional' + run: php phpcbf.phar ./scripts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e39f175dd6..1adf1d4f3b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,14 +19,7 @@ concurrency: jobs: build: runs-on: ubuntu-latest - - strategy: - matrix: - php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] - - name: "Build Phar on PHP: ${{ matrix.php }}" - - continue-on-error: ${{ matrix.php == '8.2' }} + name: "Build Phar on PHP: 8.0" steps: - name: Checkout code @@ -35,7 +28,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} + php-version: '8.0' coverage: none ini-values: phar.readonly=Off, error_reporting=-1, display_errors=On @@ -44,7 +37,6 @@ jobs: - name: Upload the PHPCS phar uses: actions/upload-artifact@v3 - if: ${{ success() && matrix.php == '8.0' }} with: name: phpcs-phar path: ./phpcs.phar @@ -53,14 +45,13 @@ jobs: - name: Upload the PHPCBF phar uses: actions/upload-artifact@v3 - if: ${{ success() && matrix.php == '8.0' }} with: name: phpcbf-phar path: ./phpcbf.phar if-no-files-found: error retention-days: 28 - # Both the below only check a few files which are rarely changed and therefore unlikely to have issues. + # Both the below only check a file which is rarely changed and therefore unlikely to have issues. # This test is about testing that the phars are functional, *not* about whether the code style complies. - name: 'PHPCS: check code style using the Phar file to test the Phar is functional' run: php phpcs.phar ./scripts From fb7390e5e98c4c2bd747a9742e855bfaf028126f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 9 Dec 2023 04:37:12 +0100 Subject: [PATCH 150/874] GH Actions: introduce a quicktest workflow ... which runs only against low/medium/high PHP versions and does not run: - the tests using custom PHP ini settings - the tests related to sniffs using external JS/CSS tooling - test CS check (integration test) using the PHAR This quick test workflow will now run on pushes to all branches except `master`. For pushes to `master`, the full test build will still be run. In the fast majority of cases, this quicktest will already surface any issues and it saves a lot of resources when the same builds don't run twice for every PR. --- .github/workflows/quicktest.yml | 61 +++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 4 ++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/quicktest.yml diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml new file mode 100644 index 0000000000..d00eec5d3c --- /dev/null +++ b/.github/workflows/quicktest.yml @@ -0,0 +1,61 @@ +name: Quicktest + +on: + # Run on pushes to all branches except for `master`. + push: + branches-ignore: + - master + paths-ignore: + - '**.md' + # Allow manually triggering the workflow. + workflow_dispatch: + +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + #### QUICK TEST #### + # This is a much quicker test run which only runs the unit tests against the low/medium/high + # supported PHP versions and skips the PHAR test and the tests for external JS/CSS tooling. + # These are basically the same builds as in the Test->Coverage workflow, but then without doing + # the code-coverage. + quicktest: + runs-on: ubuntu-latest + + strategy: + matrix: + php: ['5.4', '7.2', 'latest'] + + name: "QuickTest: PHP ${{ matrix.php }}" + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + ini-values: 'error_reporting=-1, display_errors=On' + coverage: none + + # Install dependencies and handle caching in one go. + # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer + - name: Install Composer dependencies + uses: "ramsey/composer-install@v2" + with: + # Bust the cache at least once a month - output format: YYYY-MM. + custom-cache-suffix: $(date -u "+%Y-%m") + + - name: 'PHPCS: set the path to PHP' + run: php bin/phpcs --config-set php_path php + + - name: 'PHPUnit: run the tests' + run: vendor/bin/phpunit tests/AllTests.php + + # Note: The code style check is run as an integration test. + - name: 'PHPCS: check code style without cache, no parallel' + run: php bin/phpcs --no-cache --parallel=1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1adf1d4f3b..7dcf4f41b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,11 @@ name: Test on: - # Run on all pushes and on all pull requests. + # Run on pushes to `master` and on all pull requests. # Prevent the build from running when there are only irrelevant changes. push: + branches: + - master paths-ignore: - '**.md' pull_request: From 5f130d8dee15da091d186f11fceb83360285ef04 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 9 Dec 2023 23:02:03 +0100 Subject: [PATCH 151/874] GH Actions: few small workflow tweaks * Remove some information from a step name which is already in a comment above it. * Fold two steps into one (Composer install). * Add a missing condition to prevent a step from running when it is not needed. --- .github/workflows/test.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7dcf4f41b4..46c745d0c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -110,7 +110,7 @@ jobs: tools: cs2pr # This action also handles the caching of the dependencies. - - name: Set up node and enable caching of dependencies + - name: Set up node uses: actions/setup-node@v4 with: node-version: '20' @@ -125,18 +125,9 @@ jobs: # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer - name: Install Composer dependencies - if: ${{ matrix.php != '8.4' }} uses: "ramsey/composer-install@v2" with: - # Bust the cache at least once a month - output format: YYYY-MM. - custom-cache-suffix: $(date -u "+%Y-%m") - - # For PHP "nightly", we install with ignore platform reqs. - - name: Install Composer dependencies - with ignore platform - if: ${{ matrix.php == '8.4' }} - uses: "ramsey/composer-install@v2" - with: - composer-options: --ignore-platform-req=php + composer-options: ${{ matrix.php == '8.4' && '--ignore-platform-req=php' || '' }} custom-cache-suffix: $(date -u "+%Y-%m") # Note: The code style check is run multiple times against every PHP version @@ -161,6 +152,7 @@ jobs: run: cs2pr ./phpcs-report.xml - name: Download the PHPCS phar + if: ${{ matrix.custom_ini == false }} uses: actions/download-artifact@v3 with: name: phpcs-phar From ac4501ffa8059f3a5a4904271731c5ed7ebf9471 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 9 Dec 2023 23:14:28 +0100 Subject: [PATCH 152/874] GH Actions/tests: more workflow tweaks No need to run the tests involving external tooling both with and without custom ini settings as those settings won't make a difference for those anyway. --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 46c745d0c7..4798deab9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -111,11 +111,13 @@ jobs: # This action also handles the caching of the dependencies. - name: Set up node + if: ${{ matrix.custom_ini == false }} uses: actions/setup-node@v4 with: node-version: '20' - name: Install external tools used in tests + if: ${{ matrix.custom_ini == false }} run: > npm install -g --fund false csslint From 40a4bd97d387799422ee8761083313cd61152b69 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Mar 2019 15:05:30 +0100 Subject: [PATCH 153/874] Unit tests: add @covers annotation to all sniff tests --- src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php | 5 +++++ .../Tests/Arrays/DisallowLongArraySyntaxUnitTest.php | 5 +++++ .../Tests/Arrays/DisallowShortArraySyntaxUnitTest.php | 5 +++++ .../Generic/Tests/Classes/DuplicateClassNameUnitTest.php | 5 +++++ .../Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php | 5 +++++ .../Tests/CodeAnalysis/AssignmentInConditionUnitTest.php | 5 +++++ .../Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php | 7 ++++++- .../Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php | 5 +++++ .../CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php | 5 +++++ .../CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php | 5 +++++ .../Tests/CodeAnalysis/JumbledIncrementerUnitTest.php | 5 +++++ .../CodeAnalysis/UnconditionalIfStatementUnitTest.php | 5 +++++ .../CodeAnalysis/UnnecessaryFinalModifierUnitTest.php | 5 +++++ .../Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php | 5 +++++ .../Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php | 5 +++++ .../Generic/Tests/Commenting/DocCommentUnitTest.php | 5 +++++ src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php | 5 +++++ src/Standards/Generic/Tests/Commenting/TodoUnitTest.php | 5 +++++ .../ControlStructures/DisallowYodaConditionsUnitTest.php | 5 +++++ .../ControlStructures/InlineControlStructureUnitTest.php | 5 +++++ src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php | 5 +++++ .../Generic/Tests/Debug/ClosureLinterUnitTest.php | 5 +++++ src/Standards/Generic/Tests/Debug/ESLintUnitTest.php | 5 +++++ src/Standards/Generic/Tests/Debug/JSHintUnitTest.php | 5 +++++ .../Generic/Tests/Files/ByteOrderMarkUnitTest.php | 5 +++++ .../Generic/Tests/Files/EndFileNewlineUnitTest.php | 5 +++++ .../Generic/Tests/Files/EndFileNoNewlineUnitTest.php | 5 +++++ .../Generic/Tests/Files/ExecutableFileUnitTest.php | 5 +++++ src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php | 5 +++++ src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php | 5 +++++ src/Standards/Generic/Tests/Files/LineLengthUnitTest.php | 5 +++++ .../Generic/Tests/Files/LowercasedFilenameUnitTest.php | 5 +++++ .../Generic/Tests/Files/OneClassPerFileUnitTest.php | 5 +++++ .../Generic/Tests/Files/OneInterfacePerFileUnitTest.php | 5 +++++ .../Tests/Files/OneObjectStructurePerFileUnitTest.php | 5 +++++ .../Generic/Tests/Files/OneTraitPerFileUnitTest.php | 5 +++++ .../Formatting/DisallowMultipleStatementsUnitTest.php | 5 +++++ .../Formatting/MultipleStatementAlignmentUnitTest.php | 5 +++++ .../Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php | 5 +++++ .../Generic/Tests/Formatting/SpaceAfterCastUnitTest.php | 5 +++++ .../Generic/Tests/Formatting/SpaceAfterNotUnitTest.php | 5 +++++ .../Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php | 5 +++++ .../Tests/Functions/CallTimePassByReferenceUnitTest.php | 5 +++++ .../Functions/FunctionCallArgumentSpacingUnitTest.php | 5 +++++ .../Functions/OpeningFunctionBraceBsdAllmanUnitTest.php | 5 +++++ .../OpeningFunctionBraceKernighanRitchieUnitTest.php | 5 +++++ .../Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php | 5 +++++ .../Generic/Tests/Metrics/NestingLevelUnitTest.php | 5 +++++ .../NamingConventions/AbstractClassNamePrefixUnitTest.php | 5 +++++ .../NamingConventions/CamelCapsFunctionNameUnitTest.php | 5 +++++ .../Tests/NamingConventions/ConstructorNameUnitTest.php | 5 +++++ .../NamingConventions/InterfaceNameSuffixUnitTest.php | 5 +++++ .../Tests/NamingConventions/TraitNameSuffixUnitTest.php | 5 +++++ .../NamingConventions/UpperCaseConstantNameUnitTest.php | 5 +++++ .../Generic/Tests/PHP/BacktickOperatorUnitTest.php | 5 +++++ .../Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php | 5 +++++ src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php | 5 +++++ .../Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php | 5 +++++ .../Tests/PHP/DisallowAlternativePHPTagsUnitTest.php | 5 +++++ .../Tests/PHP/DisallowRequestSuperglobalUnitTest.php | 5 +++++ .../Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php | 5 +++++ src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php | 5 +++++ .../Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php | 5 +++++ .../Generic/Tests/PHP/LowerCaseConstantUnitTest.php | 5 +++++ .../Generic/Tests/PHP/LowerCaseKeywordUnitTest.php | 5 +++++ src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php | 5 +++++ .../Generic/Tests/PHP/NoSilencedErrorsUnitTest.php | 5 +++++ .../Generic/Tests/PHP/RequireStrictTypesUnitTest.php | 5 +++++ src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php | 5 +++++ src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php | 5 +++++ .../Generic/Tests/PHP/UpperCaseConstantUnitTest.php | 5 +++++ .../Tests/Strings/UnnecessaryStringConcatUnitTest.php | 5 +++++ .../Tests/VersionControl/GitMergeConflictUnitTest.php | 5 +++++ .../Tests/VersionControl/SubversionPropertiesUnitTest.php | 5 +++++ .../WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php | 5 +++++ .../Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php | 5 +++++ .../Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php | 5 +++++ .../Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php | 5 +++++ .../Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php | 5 +++++ .../Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php | 5 +++++ .../WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php | 5 +++++ .../MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php | 5 +++++ .../Tests/Channels/DisallowSelfActionsUnitTest.php | 5 +++++ .../MySource/Tests/Channels/IncludeSystemUnitTest.php | 5 +++++ .../MySource/Tests/Channels/UnusedSystemUnitTest.php | 5 +++++ .../MySource/Tests/Commenting/FunctionCommentUnitTest.php | 5 +++++ src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php | 5 +++++ .../MySource/Tests/Debug/FirebugConsoleUnitTest.php | 5 +++++ .../MySource/Tests/Objects/AssignThisUnitTest.php | 5 +++++ .../Tests/Objects/CreateWidgetTypeCallbackUnitTest.php | 5 +++++ .../MySource/Tests/Objects/DisallowNewWidgetUnitTest.php | 5 +++++ .../MySource/Tests/PHP/AjaxNullComparisonUnitTest.php | 5 +++++ .../MySource/Tests/PHP/EvalObjectFactoryUnitTest.php | 5 +++++ .../MySource/Tests/PHP/GetRequestDataUnitTest.php | 5 +++++ .../MySource/Tests/PHP/ReturnFunctionValueUnitTest.php | 5 +++++ .../MySource/Tests/Strings/JoinStringsUnitTest.php | 5 +++++ .../PEAR/Tests/Classes/ClassDeclarationUnitTest.php | 5 +++++ .../PEAR/Tests/Commenting/ClassCommentUnitTest.php | 5 +++++ .../PEAR/Tests/Commenting/FileCommentUnitTest.php | 5 +++++ .../PEAR/Tests/Commenting/FunctionCommentUnitTest.php | 5 +++++ .../PEAR/Tests/Commenting/InlineCommentUnitTest.php | 5 +++++ .../Tests/ControlStructures/ControlSignatureUnitTest.php | 5 +++++ .../Tests/ControlStructures/MultiLineConditionUnitTest.php | 5 +++++ src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php | 5 +++++ .../PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php | 5 +++++ .../PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php | 5 +++++ .../PEAR/Tests/Functions/FunctionDeclarationUnitTest.php | 5 +++++ .../PEAR/Tests/Functions/ValidDefaultValueUnitTest.php | 5 +++++ .../Tests/NamingConventions/ValidClassNameUnitTest.php | 5 +++++ .../Tests/NamingConventions/ValidFunctionNameUnitTest.php | 5 +++++ .../Tests/NamingConventions/ValidVariableNameUnitTest.php | 5 +++++ .../PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php | 5 +++++ .../PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php | 5 +++++ .../PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php | 5 +++++ .../PSR1/Tests/Classes/ClassDeclarationUnitTest.php | 5 +++++ src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php | 5 +++++ .../PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php | 5 +++++ .../PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php | 5 +++++ .../PSR12/Tests/Classes/ClassInstantiationUnitTest.php | 5 +++++ src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php | 5 +++++ .../PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php | 5 +++++ .../ControlStructures/BooleanOperatorPlacementUnitTest.php | 5 +++++ .../ControlStructures/ControlStructureSpacingUnitTest.php | 5 +++++ .../PSR12/Tests/Files/DeclareStatementUnitTest.php | 5 +++++ src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php | 5 +++++ .../PSR12/Tests/Files/ImportStatementUnitTest.php | 5 +++++ src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php | 5 +++++ .../Tests/Functions/NullableTypeDeclarationUnitTest.php | 5 +++++ .../Tests/Functions/ReturnTypeDeclarationUnitTest.php | 5 +++++ .../PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php | 5 +++++ .../Tests/Namespaces/CompoundNamespaceDepthUnitTest.php | 5 +++++ .../PSR12/Tests/Operators/OperatorSpacingUnitTest.php | 5 +++++ .../PSR12/Tests/Properties/ConstantVisibilityUnitTest.php | 5 +++++ .../PSR12/Tests/Traits/UseDeclarationUnitTest.php | 5 +++++ .../PSR2/Tests/Classes/ClassDeclarationUnitTest.php | 5 +++++ .../PSR2/Tests/Classes/PropertyDeclarationUnitTest.php | 5 +++++ .../ControlStructures/ControlStructureSpacingUnitTest.php | 5 +++++ .../Tests/ControlStructures/ElseIfDeclarationUnitTest.php | 5 +++++ .../Tests/ControlStructures/SwitchDeclarationUnitTest.php | 5 +++++ src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php | 5 +++++ src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php | 5 +++++ .../PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php | 5 +++++ .../PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php | 5 +++++ .../PSR2/Tests/Methods/MethodDeclarationUnitTest.php | 5 +++++ .../PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php | 5 +++++ .../PSR2/Tests/Namespaces/UseDeclarationUnitTest.php | 5 +++++ .../Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php | 5 +++++ .../Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php | 5 +++++ .../Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php | 5 +++++ .../Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php | 5 +++++ .../Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php | 5 +++++ .../Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php | 5 +++++ .../Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php | 5 +++++ .../Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php | 5 +++++ .../Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php | 5 +++++ .../Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php | 5 +++++ .../Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php | 5 +++++ .../Squiz/Tests/Classes/ClassDeclarationUnitTest.php | 5 +++++ .../Squiz/Tests/Classes/ClassFileNameUnitTest.php | 5 +++++ .../Squiz/Tests/Classes/DuplicatePropertyUnitTest.php | 5 +++++ .../Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php | 5 +++++ .../Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php | 5 +++++ .../Squiz/Tests/Classes/ValidClassNameUnitTest.php | 5 +++++ .../Squiz/Tests/Commenting/BlockCommentUnitTest.php | 5 +++++ .../Squiz/Tests/Commenting/ClassCommentUnitTest.php | 5 +++++ .../Tests/Commenting/ClosingDeclarationCommentUnitTest.php | 5 +++++ .../Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php | 5 +++++ .../Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php | 5 +++++ .../Squiz/Tests/Commenting/FileCommentUnitTest.php | 5 +++++ .../Tests/Commenting/FunctionCommentThrowTagUnitTest.php | 5 +++++ .../Squiz/Tests/Commenting/FunctionCommentUnitTest.php | 5 +++++ .../Squiz/Tests/Commenting/InlineCommentUnitTest.php | 5 +++++ .../Commenting/LongConditionClosingCommentUnitTest.php | 5 +++++ .../Tests/Commenting/PostStatementCommentUnitTest.php | 5 +++++ .../Squiz/Tests/Commenting/VariableCommentUnitTest.php | 5 +++++ .../Tests/ControlStructures/ControlSignatureUnitTest.php | 5 +++++ .../Tests/ControlStructures/ElseIfDeclarationUnitTest.php | 5 +++++ .../ControlStructures/ForEachLoopDeclarationUnitTest.php | 5 +++++ .../Tests/ControlStructures/ForLoopDeclarationUnitTest.php | 5 +++++ .../ControlStructures/InlineIfDeclarationUnitTest.php | 5 +++++ .../ControlStructures/LowercaseDeclarationUnitTest.php | 5 +++++ .../Tests/ControlStructures/SwitchDeclarationUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php | 5 +++++ .../Squiz/Tests/Formatting/OperatorBracketUnitTest.php | 5 +++++ .../FunctionDeclarationArgumentSpacingUnitTest.php | 5 +++++ .../Squiz/Tests/Functions/FunctionDeclarationUnitTest.php | 5 +++++ .../Tests/Functions/FunctionDuplicateArgumentUnitTest.php | 5 +++++ .../Squiz/Tests/Functions/GlobalFunctionUnitTest.php | 5 +++++ .../Tests/Functions/LowercaseFunctionKeywordsUnitTest.php | 5 +++++ .../Functions/MultiLineFunctionDeclarationUnitTest.php | 5 +++++ .../Tests/NamingConventions/ValidFunctionNameUnitTest.php | 5 +++++ .../Tests/NamingConventions/ValidVariableNameUnitTest.php | 5 +++++ .../Tests/Objects/DisallowObjectStringIndexUnitTest.php | 5 +++++ .../Squiz/Tests/Objects/ObjectInstantiationUnitTest.php | 5 +++++ .../Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php | 5 +++++ .../Tests/Operators/ComparisonOperatorUsageUnitTest.php | 5 +++++ .../Tests/Operators/IncrementDecrementUsageUnitTest.php | 5 +++++ .../Tests/Operators/ValidLogicalOperatorsUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php | 5 +++++ .../Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php | 5 +++++ .../Tests/PHP/DisallowComparisonAssignmentUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php | 5 +++++ .../Tests/PHP/DisallowMultipleAssignmentsUnitTest.php | 5 +++++ .../Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php | 5 +++++ .../Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/PHP/EvalUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php | 5 +++++ .../Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php | 5 +++++ .../Squiz/Tests/PHP/NonExecutableCodeUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php | 5 +++++ src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php | 5 +++++ .../Squiz/Tests/Scope/StaticThisUsageUnitTest.php | 5 +++++ .../Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php | 5 +++++ .../Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php | 5 +++++ .../Squiz/Tests/Strings/EchoedStringsUnitTest.php | 5 +++++ .../Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php | 5 +++++ .../Tests/WhiteSpace/ControlStructureSpacingUnitTest.php | 5 +++++ .../Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php | 5 +++++ .../Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php | 5 +++++ .../Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php | 5 +++++ .../Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php | 5 +++++ .../Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php | 5 +++++ .../Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php | 5 +++++ .../Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php | 5 +++++ .../Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php | 5 +++++ .../Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php | 5 +++++ .../Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php | 5 +++++ .../Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php | 5 +++++ .../Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php | 5 +++++ .../Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php | 5 +++++ src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php | 5 +++++ src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php | 5 +++++ .../Tests/NamingConventions/ValidVariableNameUnitTest.php | 5 +++++ 247 files changed, 1236 insertions(+), 1 deletion(-) diff --git a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php index e1c83467e0..24b36e6b3e 100644 --- a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ArrayIndent sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff + */ class ArrayIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php b/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php index edd7e6d5a6..1f67229a4d 100644 --- a/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowLongArraySyntax sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff + */ class DisallowLongArraySyntaxUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php b/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php index d9d305db14..5e88348748 100644 --- a/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowShortArraySyntax sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowShortArraySyntaxSniff + */ class DisallowShortArraySyntaxUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php b/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php index 25685d106e..ba7b70eca6 100644 --- a/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php +++ b/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DuplicateClassName sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Classes\DuplicateClassNameSniff + */ class DuplicateClassNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php index 1fa1e4d263..c72d133751 100644 --- a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php +++ b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OpeningBraceSameLine sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Classes\OpeningBraceSameLineSniff + */ class OpeningBraceSameLineUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php index 889b7010e7..a1836217ee 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the AssignmentInCondition sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff + */ class AssignmentInConditionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php index e83dff0a79..2c9c5bffe6 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php @@ -1,6 +1,6 @@ * @copyright 2017 Juliette Reinders Folmer. All rights reserved. @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EmptyPHPStatement sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyPHPStatementSniff + */ class EmptyPHPStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php index 464ea50435..2189d1d7c2 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EmptyStatement sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff + */ class EmptyStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php index b474c086a0..2fcfffb173 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ForLoopShouldBeWhileLoop sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\ForLoopShouldBeWhileLoopSniff + */ class ForLoopShouldBeWhileLoopUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php index c2d45eea7d..29b3b0fa86 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ForLoopWithTestFunctionCall sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\ForLoopWithTestFunctionCallSniff + */ class ForLoopWithTestFunctionCallUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php index 376df0c66c..db5b1e2a4e 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the JumbledIncrementer sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\JumbledIncrementerSniff + */ class JumbledIncrementerUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php index 8f373d929b..48815d6868 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the UnconditionalIfStatement sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnconditionalIfStatementSniff + */ class UnconditionalIfStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php index 5f65d6e3f6..60acbc9a8e 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the UnnecessaryFinalModifier sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnnecessaryFinalModifierSniff + */ class UnnecessaryFinalModifierUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php index 2f3aab80be..298395c5dc 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the UnusedFunctionParameter sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnusedFunctionParameterSniff + */ class UnusedFunctionParameterUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php index b04b2743aa..bd8a99d8fa 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the UselessOverridingMethod sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UselessOverridingMethodSniff + */ class UselessOverridingMethodUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php index 4f2c18f9e4..cacef6bc17 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DocCommentSniff sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\DocCommentSniff + */ class DocCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php index 49104febae..e89b2298e9 100644 --- a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the Fixme sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\FixmeSniff + */ class FixmeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php index 0651595326..30de38383d 100644 --- a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the Todo sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\TodoSniff + */ class TodoUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php index 1fd642c8f3..da347410e3 100644 --- a/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowYodaConditions sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\DisallowYodaConditionsSniff + */ class DisallowYodaConditionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index d7e07bb777..bc61577fb7 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the InlineControlStructure sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\InlineControlStructureSniff + */ class InlineControlStructureUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php b/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php index 9af0d93093..4c17ff25e6 100644 --- a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; use PHP_CodeSniffer\Config; +/** + * Unit test class for the CSSLint sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\CSSLintSniff + */ class CSSLintUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php b/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php index f5054b5c3d..ca51f1340e 100644 --- a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; use PHP_CodeSniffer\Config; +/** + * Unit test class for the ClosureLinter sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\ClosureLinterSniff + */ class ClosureLinterUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php index d9d754d731..584d29c2fa 100644 --- a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; use PHP_CodeSniffer\Config; +/** + * Unit test class for the ESLint sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\ESLintSniff + */ class ESLintUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php b/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php index e7753d0558..ce980e2334 100644 --- a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; use PHP_CodeSniffer\Config; +/** + * Unit test class for the JSHint sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\JSHintSniff + */ class JSHintUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php index 2e9fc9ef7a..b663e2aa00 100644 --- a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ByteOrderMark sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ByteOrderMarkSniff + */ class ByteOrderMarkUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php index ebda19cbb1..f32100b833 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EndFileNewline sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\EndFileNewlineSniff + */ class EndFileNewlineUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php index 1333eb7746..e0b94a05f7 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EndFileNoNewline sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\EndFileNoNewlineSniff + */ class EndFileNoNewlineUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php index c10b34fa88..c42308e235 100644 --- a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ExecutableFile sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ExecutableFileSniff + */ class ExecutableFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php index 5619069c88..570c68822c 100644 --- a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php +++ b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the InlineHTML sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\InlineHTMLSniff + */ class InlineHTMLUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php index 10dcc702b2..bf6289dbe2 100644 --- a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LineEndings sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineEndingsSniff + */ class LineEndingsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php index 89243152fe..bac731eb45 100644 --- a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LineLength sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff + */ class LineLengthUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php index a0033a7a19..0dd18292f6 100644 --- a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LowercasedFilename sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LowercasedFilenameSniff + */ class LowercasedFilenameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php index 984daf7170..5ad4dc932e 100644 --- a/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OneClassPerFile sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneClassPerFileSniff + */ class OneClassPerFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php index deced9a4af..35d5139008 100644 --- a/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OneInterfacePerFile sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneInterfacePerFileSniff + */ class OneInterfacePerFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php index d9e0fc2123..083c8a62ee 100644 --- a/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OneInterfacePerFile sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneObjectStructurePerFileSniff + */ class OneObjectStructurePerFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php index 9fe3e4d284..26c4a5a763 100644 --- a/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OneTraitPerFile sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneTraitPerFileSniff + */ class OneTraitPerFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php b/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php index fb91599052..cc919d2ec7 100644 --- a/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowMultipleStatements sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\DisallowMultipleStatementsSniff + */ class DisallowMultipleStatementsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php index eaf8afa59f..ea27e98dbf 100644 --- a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the MultipleStatementAlignment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\MultipleStatementAlignmentSniff + */ class MultipleStatementAlignmentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php index b2f3f6da34..535cf18801 100644 --- a/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the NoSpaceAfterCast sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\NoSpaceAfterCastSniff + */ class NoSpaceAfterCastUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php index 8507665649..287f4bb5d8 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SpaceAfterCast sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff + */ class SpaceAfterCastUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php index 3b49e07971..cf62c9294c 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SpaceAfterNot sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterNotSniff + */ class SpaceAfterNotUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php index cd2294919e..3bf5944e0a 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SpaceBeforeCast sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceBeforeCastSniff + */ class SpaceBeforeCastUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php b/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php index eee6288a0f..faa37c31ae 100644 --- a/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the CallTimePassByReference sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\CallTimePassByReferenceSniff + */ class CallTimePassByReferenceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php index be92b743db..e325f7f1fb 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionCallArgumentSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\FunctionCallArgumentSpacingSniff + */ class FunctionCallArgumentSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php index c8f218dbdc..160adb22fb 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OpeningFunctionBraceBsdAllman sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\OpeningFunctionBraceBsdAllmanSniff + */ class OpeningFunctionBraceBsdAllmanUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php index a2b32a8587..53ef2a358e 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OpeningFunctionBraceKernighanRitchie sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\OpeningFunctionBraceKernighanRitchieSniff + */ class OpeningFunctionBraceKernighanRitchieUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php index 77a3092984..733f9258aa 100644 --- a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the CyclomaticComplexity sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff + */ class CyclomaticComplexityUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php index e9e44a3d4e..036d1bab8f 100644 --- a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the NestingLevel sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff + */ class NestingLevelUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php index 64450b42a0..90350bdfd4 100644 --- a/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php @@ -10,6 +10,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the AbstractClassNamePrefix sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\AbstractClassNamePrefixSniff + */ class AbstractClassNamePrefixUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php index 795a6a7428..716a423813 100644 --- a/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the CamelCapsFunctionName sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff + */ class CamelCapsFunctionNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php index 2122f16b24..54c3213e27 100644 --- a/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ConstructorName sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\ConstructorNameSniff + */ class ConstructorNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php index 66360bcff0..8411c7246b 100644 --- a/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php @@ -10,6 +10,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the InterfaceNameSuffix sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\InterfaceNameSuffixSniff + */ class InterfaceNameSuffixUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php index b8d5ba7982..351714862b 100644 --- a/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php @@ -10,6 +10,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the TraitNameSuffix sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\TraitNameSuffixSniff + */ class TraitNameSuffixUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php index de68dd6006..de352ce227 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ValidConstantName sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\UpperCaseConstantNameSniff + */ class UpperCaseConstantNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php b/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php index f3e8cfd537..fdbb55f3af 100644 --- a/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the BacktickOperator sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\BacktickOperatorSniff + */ class BacktickOperatorUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php b/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php index 94dfd31390..69b8437e53 100644 --- a/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the CharacterBeforePHPOpeningTag sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\CharacterBeforePHPOpeningTagSniff + */ class CharacterBeforePHPOpeningTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php b/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php index 17efceb580..2e7c779c9d 100644 --- a/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClosingPHPTag sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ClosingPHPTagSniff + */ class ClosingPHPTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php b/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php index 32af71d2d3..1b82da5f10 100644 --- a/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DeprecatedFunctions sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DeprecatedFunctionsSniff + */ class DeprecatedFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php index 90c9c137c2..212f08a09b 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowAlternativePHPTags sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowAlternativePHPTagsSniff + */ class DisallowAlternativePHPTagsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php index 05f6198ee4..b54405ee2f 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php @@ -10,6 +10,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowRequestSuperglobal sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowRequestSuperglobalSniff + */ class DisallowRequestSuperglobalUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php index 3edda9a567..7d11b0b1fd 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowShortOpenTag sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowShortOpenTagSniff + */ class DisallowShortOpenTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php b/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php index f96b41bf2c..315c236158 100644 --- a/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DiscourageGoto sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DiscourageGotoSniff + */ class DiscourageGotoUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php b/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php index a0e86f2393..06be9d758f 100644 --- a/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ForbiddenFunctions sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff + */ class ForbiddenFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php index 5cb253cad4..f047e2609b 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LowerCaseConstant sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseConstantSniff + */ class LowerCaseConstantUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php index 2d415eff1e..a7b708e36b 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LowerCaseKeyword sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseKeywordSniff + */ class LowerCaseKeywordUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php index 29d15c59a6..4e6ccc3bed 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LowerCaseType sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseTypeSniff + */ class LowerCaseTypeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php index a2d3ff8a6e..dc7e754d51 100644 --- a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the NoSilencedErrors sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\NoSilencedErrorsSniff + */ class NoSilencedErrorsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php index 6d37cc5ff2..c311266d3f 100644 --- a/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the RequireStrictType sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\RequireStrictTypesSniff + */ class RequireStrictTypesUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php b/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php index 24229b7536..9835b061ec 100644 --- a/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SAPIUsage sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SAPIUsageSniff + */ class SAPIUsageUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php b/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php index ea6d85d538..0069cf5756 100644 --- a/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the Syntax sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SyntaxSniff + */ class SyntaxUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php index 486ab915bf..dcfe801429 100644 --- a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the UpperCaseConstant sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\UpperCaseConstantSniff + */ class UpperCaseConstantUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php index a435c7f988..25b983d6b5 100644 --- a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php +++ b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the UnnecessaryStringConcat sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Strings\UnnecessaryStringConcatSniff + */ class UnnecessaryStringConcatUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php index 050b08ee9a..1a71c85d58 100644 --- a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php +++ b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the GitMergeConflict sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\GitMergeConflictSniff + */ class GitMergeConflictUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php b/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php index 02d6a1289f..32c7fc9d16 100644 --- a/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php +++ b/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SubversionProperties sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\SubversionPropertiesSniff + */ class SubversionPropertiesUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php index 36c220ae04..124efb7d11 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ArbitraryParenthesesSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ArbitraryParenthesesSpacingSniff + */ class ArbitraryParenthesesSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php index 48c0f312d7..d745785b28 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowSpaceIndent sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\DisallowSpaceIndentSniff + */ class DisallowSpaceIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php index 2be60b7442..de688e0867 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowTabIndent sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\DisallowTabIndentSniff + */ class DisallowTabIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php index 9e7644f1f1..77f20ee397 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the IncrementDecrementSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\IncrementDecrementSpacingSniff + */ class IncrementDecrementSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php index db42ad5b65..b11fedcaba 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LanguageConstructSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\LanguageConstructSpacingSniff + */ class LanguageConstructSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index 23905fdadc..729bea1925 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ScopeIndent sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff + */ class ScopeIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php index c2f342ff57..7192f668bf 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SpreadOperatorSpacingAfter sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\SpreadOperatorSpacingAfterSniff + */ class SpreadOperatorSpacingAfterUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php b/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php index 0018af2418..30049591dd 100644 --- a/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php +++ b/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the BrowserSpecificStyles sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\CSS\BrowserSpecificStylesSniff + */ class BrowserSpecificStylesUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php b/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php index 746637e9ed..9233a2f5b0 100644 --- a/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowSelfActions sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Channels\DisallowSelfActionsSniff + */ class DisallowSelfActionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php b/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php index c48d0fe580..407535655e 100644 --- a/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the IncludeSystem sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Channels\IncludeSystemSniff + */ class IncludeSystemUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php b/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php index 6795d3fb81..b3455ac3fd 100644 --- a/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the UnusedSystem sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Channels\UnusedSystemSniff + */ class UnusedSystemUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php index 53c995c2dd..8a3d706615 100644 --- a/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionComment sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Commenting\FunctionCommentSniff + */ class FunctionCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php b/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php index 73e697dcb8..d8f80118ed 100644 --- a/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php +++ b/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DebugCode sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Debug\DebugCodeSniff + */ class DebugCodeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php b/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php index 039e8e848a..47ce7c1a12 100644 --- a/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php +++ b/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FirebugConsole sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Debug\FirebugConsoleSniff + */ class FirebugConsoleUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php b/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php index e758bd9ef3..be2eacf433 100644 --- a/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the AssignThis sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Objects\AssignThisSniff + */ class AssignThisUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php b/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php index 4c94b00e84..7ae3342f54 100644 --- a/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the CreateWidgetTypeCallback sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Objects\CreateWidgetTypeCallbackSniff + */ class CreateWidgetTypeCallbackUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php b/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php index b562c37974..3fa2453228 100644 --- a/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowNewWidget sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Objects\DisallowNewWidgetSniff + */ class DisallowNewWidgetUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php b/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php index dda88b5319..606b9f40cb 100644 --- a/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the AjaxNullComparison sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\PHP\AjaxNullComparisonSniff + */ class AjaxNullComparisonUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php b/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php index 25f481c734..85a8c3c0a8 100644 --- a/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EvalObjectFactory sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\PHP\EvalObjectFactorySniff + */ class EvalObjectFactoryUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php b/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php index 928de6eb1b..747fae12a4 100644 --- a/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the GetRequestData sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\PHP\GetRequestDataSniff + */ class GetRequestDataUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php b/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php index fcc6bbce68..3859a03b6b 100644 --- a/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ReturnFunctionValue sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\PHP\ReturnFunctionValueSniff + */ class ReturnFunctionValueUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php b/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php index 85dd342d70..dcb397fdae 100644 --- a/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php +++ b/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the JoinStrings sniff. + * + * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Strings\JoinStringsSniff + */ class JoinStringsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php index 2ee177cfa3..b751fd8d25 100644 --- a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Classes\ClassDeclarationSniff + */ class ClassDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php index e0e98bd392..724217662e 100644 --- a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\ClassCommentSniff + */ class ClassCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php index 8d7354e050..3b55cdc3d9 100644 --- a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FileComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\FileCommentSniff + */ class FileCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php index 6283c4a623..bf379c6584 100644 --- a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\FunctionCommentSniff + */ class FunctionCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php index 3c06d151c6..ca2ac643d1 100644 --- a/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the InlineComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\InlineCommentSniff + */ class InlineCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php index f9f72378c6..ef8b946897 100644 --- a/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ControlSignature sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\ControlStructures\ControlSignatureSniff + */ class ControlSignatureUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php index 9a9b1ca40d..821c7bfbee 100644 --- a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php +++ b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the MultiLineCondition sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\ControlStructures\MultiLineConditionSniff + */ class MultiLineConditionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php b/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php index 9661f4409a..5b7aecfdbd 100644 --- a/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php +++ b/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the IncludingFile sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Files\IncludingFileSniff + */ class IncludingFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php b/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php index e419b52b69..d817996a6f 100644 --- a/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php +++ b/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the MultiLineAssignment sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Formatting\MultiLineAssignmentSniff + */ class MultiLineAssignmentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php index 4e0eeffb20..38eff588ba 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionCallSignature sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\FunctionCallSignatureSniff + */ class FunctionCallSignatureUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php index d12c8c08bc..828c7da04c 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\FunctionDeclarationSniff + */ class FunctionDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php b/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php index 668611d876..5c2450b968 100644 --- a/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ValidDefaultValue sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\ValidDefaultValueSniff + */ class ValidDefaultValueUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php index 3fbbb384ef..1b38fde7ee 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ValidClassName sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidClassNameSniff + */ class ValidClassNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php index a3a33d975f..6d92123827 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ValidFunctionName sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff + */ class ValidFunctionNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php index d1a333e751..5b3e58f087 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ValidVariableName sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidVariableNameSniff + */ class ValidVariableNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php index 63a8fc82f9..fa34ed4899 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ObjectOperatorIndent sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ObjectOperatorIndentSniff + */ class ObjectOperatorIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php index 197a50fa63..2683d6b1c1 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ScopeClosingBrace sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ScopeClosingBraceSniff + */ class ScopeClosingBraceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php index ed1825b359..cb350e70d1 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ScopeIndent sniff. + * + * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ScopeIndentSniff + */ class ScopeIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php index 600fec9966..46c3a39ed9 100644 --- a/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR1\Sniffs\Classes\ClassDeclarationSniff + */ class ClassDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php index e53b99a8cc..73c3c79424 100644 --- a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php +++ b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SideEffects sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR1\Sniffs\Files\SideEffectsSniff + */ class SideEffectsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php b/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php index a3133de49f..3b1efeb2b4 100644 --- a/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php +++ b/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the CamelCapsMethodName sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff + */ class CamelCapsMethodNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php index 6f3962629b..736d28cfbf 100644 --- a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the AnonClassDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\AnonClassDeclarationSniff + */ class AnonClassDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php b/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php index 3df377b7ee..1eb233a34a 100644 --- a/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassInstantiation sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClassInstantiationSniff + */ class ClassInstantiationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php b/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php index a397a8d722..ba4be7aaa7 100644 --- a/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClosingBrace sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClosingBraceSniff + */ class ClosingBraceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php b/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php index 3005276fe7..212861e63b 100644 --- a/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OpeningBraceSpace sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\OpeningBraceSpaceSniff + */ class OpeningBraceSpaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php b/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php index d883c5d3d7..f7adc003d4 100644 --- a/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php +++ b/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the BooleanOperatorPlacement sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures\BooleanOperatorPlacementSniff + */ class BooleanOperatorPlacementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php b/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php index 6639e1e828..a3ada241da 100644 --- a/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php +++ b/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ControlStructureSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures\ControlStructureSpacingSniff + */ class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php index acd407be4e..2218b8e918 100644 --- a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DeclareStatement sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\DeclareStatementSniff + */ class DeclareStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php b/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php index 4333f9ba12..58f1ec918f 100644 --- a/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FileHeader sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\FileHeaderSniff + */ class FileHeaderUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php b/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php index 7ddd42beb8..3774a433cd 100644 --- a/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ImportStatement sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\ImportStatementSniff + */ class ImportStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php b/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php index 8ce5633efd..815a4c23d5 100644 --- a/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OpenTag sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\OpenTagSniff + */ class OpenTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php index da11498ad1..ff3e105aa1 100644 --- a/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the NullableWhitespace sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Functions\NullableTypeDeclarationSniff + */ class NullableTypeDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php index edc0d8e0f7..ce059e024e 100644 --- a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ReturnTypeDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Functions\ReturnTypeDeclarationSniff + */ class ReturnTypeDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php b/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php index 3e9d9eca41..5713520f77 100644 --- a/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php +++ b/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ShortFormTypeKeywords sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Keywords\ShortFormTypeKeywordsSniff + */ class ShortFormTypeKeywordsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php b/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php index cbc56809dd..367f8aa6d3 100644 --- a/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php +++ b/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the CompoundNamespaceDepth sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Namespaces\CompoundNamespaceDepthSniff + */ class CompoundNamespaceDepthUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php b/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php index 1a14da8a79..5b17f76616 100644 --- a/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php +++ b/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OperatorSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators\OperatorSpacingSniff + */ class OperatorSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php b/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php index e27bc4875b..98038db6ba 100644 --- a/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php +++ b/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ConstantVisibility sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Properties\ConstantVisibilitySniff + */ class ConstantVisibilityUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php index 2b895e1973..7689388356 100644 --- a/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the UseDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Traits\UseDeclarationSniff + */ class UseDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php index 0d94746802..df574cb35c 100644 --- a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\ClassDeclarationSniff + */ class ClassDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php index 6c6c662eab..377b664fb6 100644 --- a/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the PropertyDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\PropertyDeclarationSniff + */ class PropertyDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php index 7c67b923d8..0ddd9a4464 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ControlStructureSpacingSniff + */ class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php index 6036ab0ff6..d646689637 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ElseIfDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ElseIfDeclarationSniff + */ class ElseIfDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php index 84a1c7e5c4..cd4c19f109 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SwitchDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff + */ class SwitchDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php b/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php index 5be71d12ed..b840ec0e17 100644 --- a/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php +++ b/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClosingTag sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\ClosingTagSniff + */ class ClosingTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php index ccb9fea2c1..f50cbf6dbe 100644 --- a/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EndFileNewline sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\EndFileNewlineSniff + */ class EndFileNewlineUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php b/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php index 7f6ce1f959..6abee067b2 100644 --- a/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionCallSignature sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionCallSignatureSniff + */ class FunctionCallSignatureUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php b/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php index 6e99abecd1..f3def5279a 100644 --- a/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionClosingBrace sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionClosingBraceSniff + */ class FunctionClosingBraceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php index f7a78f2124..e3603c68ca 100644 --- a/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the MethodDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff + */ class MethodDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php index 8579b3b700..999b5b49e9 100644 --- a/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the NamespaceDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Namespaces\NamespaceDeclarationSniff + */ class NamespaceDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php index a62eaad9fa..75aeaab929 100644 --- a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the UseDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Namespaces\UseDeclarationSniff + */ class UseDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php b/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php index ad74ac3fd5..14d13a8135 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ArrayBracketSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayBracketSpacingSniff + */ class ArrayBracketSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php index e4eb4f3b8f..03a4044f7d 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ArrayDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayDeclarationSniff + */ class ArrayDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php index da5ca616e8..af2f8db0a1 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassDefinitionClosingBraceSpace sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ClassDefinitionClosingBraceSpaceSniff + */ class ClassDefinitionClosingBraceSpaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php index db3cfa8941..89c21f3cda 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassDefinitionNameSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ClassDefinitionNameSpacingSniff + */ class ClassDefinitionNameSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php index 69698b1486..6e9faebca0 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassDefinitionOpeningBraceSpace sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ClassDefinitionOpeningBraceSpaceSniff + */ class ClassDefinitionOpeningBraceSpaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php index a7b0307d55..8c79d0c624 100644 --- a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ColonSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ColonSpacingSniff + */ class ColonSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php index 50b6a82b1b..100386a73b 100644 --- a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ColourDefinition sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ColourDefinitionSniff + */ class ColourDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php index 56070b620e..b9efc5dd59 100644 --- a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowMultipleStyleDefinitions sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\DisallowMultipleStyleDefinitionsSniff + */ class DisallowMultipleStyleDefinitionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php index 4361c18e7a..e6d31f31e3 100644 --- a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DuplicateClassDefinition sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\DuplicateClassDefinitionSniff + */ class DuplicateClassDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php index 7c430b2792..2b6e04f85c 100644 --- a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DuplicateStyleDefinition sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\DuplicateStyleDefinitionSniff + */ class DuplicateStyleDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php index 7efde6b5bd..767265dd20 100644 --- a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EmptyClassDefinition sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\EmptyClassDefinitionSniff + */ class EmptyClassDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php index 5118d1b54e..cd591e89a1 100644 --- a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EmptyStyleDefinition sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\EmptyStyleDefinitionSniff + */ class EmptyStyleDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php index 1857f6c61b..b212aec7fe 100644 --- a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ForbiddenStyles sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ForbiddenStylesSniff + */ class ForbiddenStylesUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php index 2fa963f354..0f4fb5de3b 100644 --- a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the Indentation sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\IndentationSniff + */ class IndentationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php index 1c6e86f0fb..ed2ac53e8b 100644 --- a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LowercaseStyleDefinition sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\LowercaseStyleDefinitionSniff + */ class LowercaseStyleDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php b/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php index e1b07f2406..c0ef173881 100644 --- a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the MissingColon sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\MissingColonSniff + */ class MissingColonUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php b/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php index bd880a516c..9a2e25fe53 100644 --- a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the NamedColours sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\NamedColoursSniff + */ class NamedColoursUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php index bde499d62d..c0454a831a 100644 --- a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the Opacity sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\OpacitySniff + */ class OpacityUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php index 980fd96956..334fc7b695 100644 --- a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SemicolonSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\SemicolonSpacingSniff + */ class SemicolonSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php index 4b92b21904..9f5a3bb3db 100644 --- a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ShorthandSize sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ShorthandSizeSniff + */ class ShorthandSizeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php index f4698e74ab..df35d2b2b2 100644 --- a/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ClassDeclarationSniff + */ class ClassDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php index 2a2c2a63bd..1d64fc5e11 100644 --- a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassFileName sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ClassFileNameSniff + */ class ClassFileNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php b/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php index f887aaec9e..a1cfd5b093 100644 --- a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DuplicateProperty sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\DuplicatePropertySniff + */ class DuplicatePropertyUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php index de07e252de..ed6517aacf 100644 --- a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LowercaseClassKeywords sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\LowercaseClassKeywordsSniff + */ class LowercaseClassKeywordsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php b/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php index 63829e3627..703dff3868 100644 --- a/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SelfMemberReference sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\SelfMemberReferenceSniff + */ class SelfMemberReferenceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php b/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php index 2257638af5..e67ca84bb1 100644 --- a/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ValidClassName sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff + */ class ValidClassNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php index aaa1b882c0..982e3f8686 100644 --- a/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the BlockComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\BlockCommentSniff + */ class BlockCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php index ed64d93bfc..c64983cee4 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClassComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\ClassCommentSniff + */ class ClassCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php index 7e44a01c6d..db38e74df5 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClosingDeclarationComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\ClosingDeclarationCommentSniff + */ class ClosingDeclarationCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php index 8ff7ec5eb6..4d735f4ca1 100644 --- a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DocCommentAlignment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\DocCommentAlignmentSniff + */ class DocCommentAlignmentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php index d53429e019..6e795a2c47 100644 --- a/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EmptyCatchComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\EmptyCatchCommentSniff + */ class EmptyCatchCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php index 6e6ad1a031..ab93fc89a2 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FileComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FileCommentSniff + */ class FileCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php index 8b54e400d9..3854846445 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionCommentThrowTag sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentThrowTagSniff + */ class FunctionCommentThrowTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php index 866b1e9664..6433dbe356 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff + */ class FunctionCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php index 04c3ed9973..8be723a4b6 100644 --- a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the InlineComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\InlineCommentSniff + */ class InlineCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php index ad802217e5..fae751d4c2 100644 --- a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LongConditionClosingComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\LongConditionClosingCommentSniff + */ class LongConditionClosingCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php index 5e4c97b80f..acfc8fc954 100644 --- a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the PostStatementComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\PostStatementCommentSniff + */ class PostStatementCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php index a83791c624..0cb3e1964d 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the VariableComment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\VariableCommentSniff + */ class VariableCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php index ce1323be5f..0ea1354399 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ControlSignature sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ControlSignatureSniff + */ class ControlSignatureUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php index f119fe8db8..e8432b6391 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ElseIfDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ElseIfDeclarationSniff + */ class ElseIfDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php index ccb77521fc..da7f144470 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ForEachLoopDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForEachLoopDeclarationSniff + */ class ForEachLoopDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php index 4aef1d7a98..d7701c1310 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ForLoopDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForLoopDeclarationSniff + */ class ForLoopDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php index 87d52fc432..0fa7b26b2c 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the InlineIfDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\InlineIfDeclarationSniff + */ class InlineIfDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php index b0085487b3..2307f9a7dc 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LowercaseDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\LowercaseDeclarationSniff + */ class LowercaseDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php index 4211345db3..1bd84621f3 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SwitchDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\SwitchDeclarationSniff + */ class SwitchDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php index a0c45c1526..5c7b8390fc 100644 --- a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php +++ b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; use PHP_CodeSniffer\Config; +/** + * Unit test class for the JSLint sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug\JSLintSniff + */ class JSLintUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php index 30108f59b4..e7221ed77e 100644 --- a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php +++ b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; use PHP_CodeSniffer\Config; +/** + * Unit test class for the JavaScriptLint sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug\JavaScriptLintSniff + */ class JavaScriptLintUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php b/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php index 992f26221b..fe6388ab8e 100644 --- a/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php +++ b/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FileExtension sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Files\FileExtensionSniff + */ class FileExtensionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php index ff1f7af5b3..f00cd1574d 100644 --- a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php +++ b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OperatorBracket sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Formatting\OperatorBracketSniff + */ class OperatorBracketUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php index 9d97a2bf26..2981af59fe 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionDeclarationArgumentSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDeclarationArgumentSpacingSniff + */ class FunctionDeclarationArgumentSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php index e53e9e7acd..ffb82011f4 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDeclarationSniff + */ class FunctionDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php index 88568b79fd..68ee6be691 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionDuplicateArgument sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDuplicateArgumentSniff + */ class FunctionDuplicateArgumentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php b/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php index efea5445f1..03af0b0fa2 100644 --- a/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the GlobalFunction sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\GlobalFunctionSniff + */ class GlobalFunctionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php b/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php index d2ad14b75e..11b21ba425 100644 --- a/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LowercaseFunctionKeywords sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\LowercaseFunctionKeywordsSniff + */ class LowercaseFunctionKeywordsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php index ac8c1f9992..b3a062b50b 100644 --- a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the MultiLineFunctionDeclaration sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\MultiLineFunctionDeclarationSniff + */ class MultiLineFunctionDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php index 1a58cae166..c3dce6cfe5 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ValidFunctionName sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidFunctionNameSniff + */ class ValidFunctionNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php index e69f2b7bcd..0638d9df4b 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ValidVariableName sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidVariableNameSniff + */ class ValidVariableNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php index f98b13983a..bd83fa2415 100644 --- a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowObjectStringIndex sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects\DisallowObjectStringIndexSniff + */ class DisallowObjectStringIndexUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php b/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php index 8c82d0c3b8..231dd606f4 100644 --- a/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ObjectInstantiation sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects\ObjectInstantiationSniff + */ class ObjectInstantiationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php index 3b37ed55f5..347c69a623 100644 --- a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ObjectMemberComma sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects\ObjectMemberCommaSniff + */ class ObjectMemberCommaUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php index 0cf59a1a1d..d0b1d3800e 100644 --- a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ComparisonOperatorUsage sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators\ComparisonOperatorUsageSniff + */ class ComparisonOperatorUsageUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php index c77425d11e..0393bafe8d 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the IncrementDecrementUsage sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators\IncrementDecrementUsageSniff + */ class IncrementDecrementUsageUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php b/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php index ca38f9ed77..e91f951443 100644 --- a/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ValidLogicalOperators sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators\ValidLogicalOperatorsSniff + */ class ValidLogicalOperatorsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php index f137bbab6e..34b706b22b 100644 --- a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the CommentedOutCode sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\CommentedOutCodeSniff + */ class CommentedOutCodeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php index 348bcd65f7..d2122d420a 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowBooleanStatement sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowBooleanStatementSniff + */ class DisallowBooleanStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php index d4485b8707..e26f7d09f6 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowComparisonAssignment sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowComparisonAssignmentSniff + */ class DisallowComparisonAssignmentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php index 9041d9be87..d913d2f53f 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowObEndFlush sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowInlineIfSniff + */ class DisallowInlineIfUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php index ee4f958fab..c89656d2f5 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowMultipleAssignments sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowMultipleAssignmentsSniff + */ class DisallowMultipleAssignmentsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php index 0e037f0746..424994b20a 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DisallowSizeFunctionsInLoops sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowSizeFunctionsInLoopsSniff + */ class DisallowSizeFunctionsInLoopsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php index 077c896e27..7712e438ff 100644 --- a/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DiscouragedFunctions sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DiscouragedFunctionsSniff + */ class DiscouragedFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php index ef825be46a..dd13cb1753 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EmbeddedPhp sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\EmbeddedPhpSniff + */ class EmbeddedPhpUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php b/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php index bfeb595cd5..277cef9ebe 100644 --- a/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the Eval sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\EvalSniff + */ class EvalUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php b/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php index 1a9f1d0e64..0f602d841f 100644 --- a/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the GlobalKeyword sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\GlobalKeywordSniff + */ class GlobalKeywordUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php index 326d3cada2..90f4cfab66 100644 --- a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the Heredoc sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\HeredocSniff + */ class HeredocUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php index cd3a49d36d..3a5309f60d 100644 --- a/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the InnerFunctions sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\InnerFunctionsSniff + */ class InnerFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php index 83460f2b51..223496d9a7 100644 --- a/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LowercasePHPFunctions sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\LowercasePHPFunctionsSniff + */ class LowercasePHPFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php index 30ccad4d26..275a6c6d64 100644 --- a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the NonExecutableCode sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\NonExecutableCodeSniff + */ class NonExecutableCodeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php b/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php index 7d94ba5322..b269e739e9 100644 --- a/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the MemberVarScope sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MemberVarScopeSniff + */ class MemberVarScopeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php b/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php index cf99afb07b..7325bac295 100644 --- a/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the MethodScope sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MethodScopeSniff + */ class MethodScopeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php b/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php index 076af551cd..9eee8c3cdc 100644 --- a/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the StaticThisUsage sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\StaticThisUsageSniff + */ class StaticThisUsageUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php b/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php index 9818c2c675..6d0181fe53 100644 --- a/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ConcatenationSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Strings\ConcatenationSpacingSniff + */ class ConcatenationSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php index a0330eaeac..e48dada95a 100644 --- a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the DoubleQuoteUsage sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Strings\DoubleQuoteUsageSniff + */ class DoubleQuoteUsageUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php b/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php index 61d5db666c..272275250e 100644 --- a/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the EchoedStrings sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Strings\EchoedStringsSniff + */ class EchoedStringsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php index f87eb7c84a..25465ca477 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the CastSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\CastSpacingSniff + */ class CastSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php index d3cc6e8de1..0a81b71657 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ControlStructureSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ControlStructureSpacingSniff + */ class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php index 81d4aa124c..d2969fc487 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionClosingBraceSpace sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionClosingBraceSpaceSniff + */ class FunctionClosingBraceSpaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php index caef988ef6..55d9432fb9 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionOpeningBraceSpace sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionOpeningBraceSpaceSniff + */ class FunctionOpeningBraceSpaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php index 307d481d5f..d58eb8c6f2 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the FunctionSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionSpacingSniff + */ class FunctionSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php index d8993959c1..196beaceb9 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LanguageConstructSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LanguageConstructSpacingSniff + */ class LanguageConstructSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php index 9b71ceb133..660b7ef23c 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the LogicalOperatorSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LogicalOperatorSpacingSniff + */ class LogicalOperatorSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php index 3819a84e0a..fd3f77d055 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the MemberVarSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\MemberVarSpacingSniff + */ class MemberVarSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php index a9e8ebf6b9..31f6a3ffec 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ObjectOperatorSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ObjectOperatorSpacingSniff + */ class ObjectOperatorSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php index d189e91996..0379d28a97 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the OperatorSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\OperatorSpacingSniff + */ class OperatorSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php index a63070b0d8..32561da9c6 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the PropertyLabel sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\PropertyLabelSpacingSniff + */ class PropertyLabelSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php index 087ac8a446..5a845086e5 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ScopeClosingBrace sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ScopeClosingBraceSniff + */ class ScopeClosingBraceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php index 6862807c1f..aaa49d65d1 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ScopeKeywordSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ScopeKeywordSpacingSniff + */ class ScopeKeywordSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php index 9736634316..9f55e2a302 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SemicolonSpacing sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SemicolonSpacingSniff + */ class SemicolonSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php index f1621b9f7a..cac3416617 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the SuperfluousWhitespace sniff. + * + * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff + */ class SuperfluousWhitespaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php b/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php index 9d90fb536d..ec0e849424 100644 --- a/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php +++ b/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; use PHP_CodeSniffer\Config; +/** + * Unit test class for the CodeAnalyzer sniff. + * + * @covers \PHP_CodeSniffer\Standards\Zend\Sniffs\Debug\CodeAnalyzerSniff + */ class CodeAnalyzerUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php b/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php index f13b78b67a..f20aef4092 100644 --- a/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php +++ b/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ClosingTag sniff. + * + * @covers \PHP_CodeSniffer\Standards\Zend\Sniffs\Files\ClosingTagSniff + */ class ClosingTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php index 7ed046c890..1df307ef69 100644 --- a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +/** + * Unit test class for the ValidVariableName sniff. + * + * @covers \PHP_CodeSniffer\Standards\Zend\Sniffs\NamingConventions\ValidVariableNameSniff + */ class ValidVariableNameUnitTest extends AbstractSniffUnitTest { From 31eb80fb64a2ce0a7ae41121b51f94d74af90d3f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Mar 2019 19:52:55 +0100 Subject: [PATCH 154/874] Unit tests: add @covers annotation to all utility method tests --- .../Autoloader/DetermineLoadedClassTest.php | 5 ++++ tests/Core/Config/ReportWidthTest.php | 28 +++++++++++++++++++ tests/Core/ErrorSuppressionTest.php | 5 ++++ tests/Core/File/FindEndOfStatementTest.php | 7 ++++- tests/Core/File/FindExtendedClassNameTest.php | 7 ++++- .../FindImplementedInterfaceNamesTest.php | 7 ++++- tests/Core/File/FindStartOfStatementTest.php | 5 ++++ tests/Core/File/GetClassPropertiesTest.php | 5 ++++ tests/Core/File/GetMemberPropertiesTest.php | 5 ++++ tests/Core/File/GetMethodParametersTest.php | 7 ++++- tests/Core/File/GetMethodPropertiesTest.php | 7 ++++- tests/Core/File/IsReferenceTest.php | 7 ++++- tests/Core/Filters/Filter/AcceptTest.php | 5 ++++ tests/Core/IsCamelCapsTest.php | 5 ++++ .../RuleInclusionAbsoluteLinuxTest.php | 5 ++++ .../RuleInclusionAbsoluteWindowsTest.php | 5 ++++ tests/Core/Ruleset/RuleInclusionTest.php | 5 ++++ tests/Core/Sniffs/AbstractArraySniffTest.php | 5 ++++ tests/Core/Tokenizer/DefaultKeywordTest.php | 3 ++ 19 files changed, 122 insertions(+), 6 deletions(-) diff --git a/tests/Core/Autoloader/DetermineLoadedClassTest.php b/tests/Core/Autoloader/DetermineLoadedClassTest.php index e4a27258a5..44a4cef079 100644 --- a/tests/Core/Autoloader/DetermineLoadedClassTest.php +++ b/tests/Core/Autoloader/DetermineLoadedClassTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Autoload; use PHPUnit\Framework\TestCase; +/** + * Tests for the \PHP_CodeSniffer\Autoload::determineLoadedClass method. + * + * @covers \PHP_CodeSniffer\Autoload::determineLoadedClass + */ class DetermineLoadedClassTest extends TestCase { diff --git a/tests/Core/Config/ReportWidthTest.php b/tests/Core/Config/ReportWidthTest.php index 275a70cab1..c46dc22e6b 100644 --- a/tests/Core/Config/ReportWidthTest.php +++ b/tests/Core/Config/ReportWidthTest.php @@ -13,6 +13,11 @@ use PHPUnit\Framework\TestCase; use ReflectionProperty; +/** + * Tests for the \PHP_CodeSniffer\Config reportWidth value. + * + * @covers \PHP_CodeSniffer\Config::__get + */ class ReportWidthTest extends TestCase { @@ -76,6 +81,9 @@ public static function resetConfigToDefaults() /** * Test that report width without overrules will always be set to a non-0 positive integer. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::restoreDefaults + * * @return void */ public function testReportWidthDefault() @@ -92,6 +100,9 @@ public function testReportWidthDefault() /** * Test that the report width will be set to a non-0 positive integer when not found in the CodeSniffer.conf file. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::restoreDefaults + * * @return void */ public function testReportWidthWillBeSetFromAutoWhenNotFoundInConfFile() @@ -115,6 +126,10 @@ public function testReportWidthWillBeSetFromAutoWhenNotFoundInConfFile() /** * Test that the report width will be set correctly when found in the CodeSniffer.conf file. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::getConfigData + * @covers \PHP_CodeSniffer\Config::restoreDefaults + * * @return void */ public function testReportWidthCanBeSetFromConfFile() @@ -135,6 +150,9 @@ public function testReportWidthCanBeSetFromConfFile() /** * Test that the report width will be set correctly when passed as a CLI argument. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::processLongArgument + * * @return void */ public function testReportWidthCanBeSetFromCLI() @@ -153,6 +171,9 @@ public function testReportWidthCanBeSetFromCLI() /** * Test that the report width will be set correctly when multiple report widths are passed on the CLI. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::processLongArgument + * * @return void */ public function testReportWidthWhenSetFromCLIFirstValuePrevails() @@ -172,6 +193,10 @@ public function testReportWidthWhenSetFromCLIFirstValuePrevails() /** * Test that a report width passed as a CLI argument will overrule a report width set in a CodeSniffer.conf file. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::processLongArgument + * @covers \PHP_CodeSniffer\Config::getConfigData + * * @return void */ public function testReportWidthSetFromCLIOverrulesConfFile() @@ -200,6 +225,8 @@ public function testReportWidthSetFromCLIOverrulesConfFile() /** * Test that the report width will be set to a non-0 positive integer when set to "auto". * + * @covers \PHP_CodeSniffer\Config::__set + * * @return void */ public function testReportWidthInputHandlingForAuto() @@ -221,6 +248,7 @@ public function testReportWidthInputHandlingForAuto() * @param int $expected Expected report width. * * @dataProvider dataReportWidthInputHandling + * @covers \PHP_CodeSniffer\Config::__set * * @return void */ diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index 3c99f5f999..7fc28d0e2e 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -14,6 +14,11 @@ use PHP_CodeSniffer\Files\DummyFile; use PHPUnit\Framework\TestCase; +/** + * Tests for PHP_CodeSniffer error suppression tags. + * + * @coversNothing + */ class ErrorSuppressionTest extends TestCase { diff --git a/tests/Core/File/FindEndOfStatementTest.php b/tests/Core/File/FindEndOfStatementTest.php index 4f9b3b0604..6296db6756 100644 --- a/tests/Core/File/FindEndOfStatementTest.php +++ b/tests/Core/File/FindEndOfStatementTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::findEndOfStatement method. + * + * @covers \PHP_CodeSniffer\Files\File::findEndOfStatement + */ class FindEndOfStatementTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/FindExtendedClassNameTest.php b/tests/Core/File/FindExtendedClassNameTest.php index a82e1e590e..c54b9cc120 100644 --- a/tests/Core/File/FindExtendedClassNameTest.php +++ b/tests/Core/File/FindExtendedClassNameTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::findExtendedClassName method. + * + * @covers \PHP_CodeSniffer\Files\File::findExtendedClassName + */ class FindExtendedClassNameTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.php b/tests/Core/File/FindImplementedInterfaceNamesTest.php index 4e2885f1ca..6e04805efb 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.php +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::findImplementedInterfaceNames method. + * + * @covers \PHP_CodeSniffer\Files\File::findImplementedInterfaceNames + */ class FindImplementedInterfaceNamesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/FindStartOfStatementTest.php b/tests/Core/File/FindStartOfStatementTest.php index dabb706c78..25b7f6aa73 100644 --- a/tests/Core/File/FindStartOfStatementTest.php +++ b/tests/Core/File/FindStartOfStatementTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File:findStartOfStatement method. + * + * @covers \PHP_CodeSniffer\Files\File::findStartOfStatement + */ class FindStartOfStatementTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetClassPropertiesTest.php b/tests/Core/File/GetClassPropertiesTest.php index c5fe70b690..d7dfce8585 100644 --- a/tests/Core/File/GetClassPropertiesTest.php +++ b/tests/Core/File/GetClassPropertiesTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File:getClassProperties method. + * + * @covers \PHP_CodeSniffer\Files\File::getClassProperties + */ class GetClassPropertiesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index 272f3b2ef1..4ef08b168b 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::getMemberProperties method. + * + * @covers \PHP_CodeSniffer\Files\File::getMemberProperties + */ class GetMemberPropertiesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMethodParametersTest.php b/tests/Core/File/GetMethodParametersTest.php index fd4742aea7..6f9b2adf9e 100644 --- a/tests/Core/File/GetMethodParametersTest.php +++ b/tests/Core/File/GetMethodParametersTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::getMethodParameters method. + * + * @covers \PHP_CodeSniffer\Files\File::getMethodParameters + */ class GetMethodParametersTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMethodPropertiesTest.php b/tests/Core/File/GetMethodPropertiesTest.php index ab8fe66f78..e971611ea4 100644 --- a/tests/Core/File/GetMethodPropertiesTest.php +++ b/tests/Core/File/GetMethodPropertiesTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::getMethodProperties method. + * + * @covers \PHP_CodeSniffer\Files\File::getMethodProperties + */ class GetMethodPropertiesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/IsReferenceTest.php b/tests/Core/File/IsReferenceTest.php index d40bee98ef..5372bf163c 100644 --- a/tests/Core/File/IsReferenceTest.php +++ b/tests/Core/File/IsReferenceTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::isReference method. + * + * @covers \PHP_CodeSniffer\Files\File::isReference + */ class IsReferenceTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index 26e589e010..53d4ba6441 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -15,6 +15,11 @@ use PHP_CodeSniffer\Ruleset; use PHPUnit\Framework\TestCase; +/** + * Tests for the \PHP_CodeSniffer\Filters\Filter::accept method. + * + * @covers \PHP_CodeSniffer\Filters\Filter + */ class AcceptTest extends TestCase { diff --git a/tests/Core/IsCamelCapsTest.php b/tests/Core/IsCamelCapsTest.php index 94766260ff..9a1a737384 100644 --- a/tests/Core/IsCamelCapsTest.php +++ b/tests/Core/IsCamelCapsTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Util\Common; use PHPUnit\Framework\TestCase; +/** + * Tests for the \PHP_CodeSniffer\Util\Common::isCamelCaps method. + * + * @covers \PHP_CodeSniffer\Util\Common::isCamelCaps + */ class IsCamelCapsTest extends TestCase { diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php index 6e9e739a83..786cbe745a 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php @@ -13,6 +13,11 @@ use PHP_CodeSniffer\Ruleset; use PHPUnit\Framework\TestCase; +/** + * Tests for the \PHP_CodeSniffer\Ruleset class using a Linux-style absolute path to include a sniff. + * + * @covers \PHP_CodeSniffer\Ruleset + */ class RuleInclusionAbsoluteLinuxTest extends TestCase { diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php index d838e01fbc..629668c9af 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php @@ -13,6 +13,11 @@ use PHP_CodeSniffer\Ruleset; use PHPUnit\Framework\TestCase; +/** + * Tests for the \PHP_CodeSniffer\Ruleset class using a Windows-style absolute path to include a sniff. + * + * @covers \PHP_CodeSniffer\Ruleset + */ class RuleInclusionAbsoluteWindowsTest extends TestCase { diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index cab58778e5..df4a022636 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -14,6 +14,11 @@ use PHPUnit\Framework\TestCase; use ReflectionObject; +/** + * Tests for the \PHP_CodeSniffer\Ruleset class. + * + * @covers \PHP_CodeSniffer\Ruleset + */ class RuleInclusionTest extends TestCase { diff --git a/tests/Core/Sniffs/AbstractArraySniffTest.php b/tests/Core/Sniffs/AbstractArraySniffTest.php index c74513cac9..cf8a231bc0 100644 --- a/tests/Core/Sniffs/AbstractArraySniffTest.php +++ b/tests/Core/Sniffs/AbstractArraySniffTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Sniffs\AbstractArraySniff. + * + * @covers \PHP_CodeSniffer\Sniffs\AbstractArraySniff + */ class AbstractArraySniffTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/DefaultKeywordTest.php b/tests/Core/Tokenizer/DefaultKeywordTest.php index 9f89ce5948..c4d216dda0 100644 --- a/tests/Core/Tokenizer/DefaultKeywordTest.php +++ b/tests/Core/Tokenizer/DefaultKeywordTest.php @@ -283,6 +283,9 @@ public function dataNotDefaultKeyword() * * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/3326 * + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap + * * @return void */ public function testIssue3326() From c49a2541a7886d5825ac082645105689935ca136 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 7 May 2023 20:03:42 +0200 Subject: [PATCH 155/874] PHPUnit config: set up to allow for recording code coverage The `forceCoversAnnotation` attribute will prevent code coverage from being recorded for tests without a `@covers` tag. As for recording the code coverage: By default, a code coverage text summary will be shown and a `clover.xml` file will be generated in a `build/logs` directory. The clover file can be used to generate code coverage reports via a service like Coveralls. For local development, the `clover.xml` is not very human readable-friendly and the summary is a little too minimal, so an HTML report would be better. To that end, a `coverage-local` script has been added to the `composer.json` to make it straight forward for contributors to generate the HTML report. The HTML report will be placed in a `build/coverage-html` directory. The `build` directory is now excluded via the `.gitignore` file. --- .github/CONTRIBUTING.md | 5 ++--- .gitignore | 1 + composer.json | 5 +++++ phpunit.xml.dist | 16 ++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 843ebe4cd5..b3c188fe5d 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -152,9 +152,8 @@ To help you with this, a number of convenience scripts are available: * `composer cs` will check for code style violations. * `composer cbf` will run the autofixers for code style violations. * `composer test` will run the unit tests. -* `composer coverage` will run the unit tests with code coverage. - Note: you may want to use a custom `phpunit.xml` overload config file to tell PHPUnit where to place an HTML report. - Alternative run it like so: `composer coverage -- --coverage-html /path/to/report-dir/` to specify the location for the HTML report on the command line. +* `composer coverage` will run the unit tests with code coverage and show a text summary. +* `composer coverage-local` will run the unit tests with code coverage and generate an HTML coverage report, which will be placed in a `build/coverage-html` subdirectory. * `composer build` will build the phpcs.phar and phpcbf.phar files. N.B.: You can ignore any skipped tests as these are for external tools. diff --git a/.gitignore b/.gitignore index a6c95c29f6..686e77608f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /phpcs.xml /phpunit.xml .phpunit.result.cache +/build/ .idea/* /vendor/ composer.lock diff --git a/composer.json b/composer.json index 1b18633fb6..c0d0e4e082 100644 --- a/composer.json +++ b/composer.json @@ -62,6 +62,10 @@ "Composer\\Config::disableProcessTimeout", "@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php -d max_execution_time=0" ], + "coverage-local": [ + "Composer\\Config::disableProcessTimeout", + "@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php --coverage-html ./build/coverage-html -d max_execution_time=0" + ], "build": [ "Composer\\Config::disableProcessTimeout", "@php -d phar.readonly=0 -f ./scripts/build-phar.php" @@ -76,6 +80,7 @@ "cbf": "Fix code style violations.", "test": "Run the unit tests without code coverage.", "coverage": "Run the unit tests with code coverage.", + "coverage-local": "Run the unit tests with code coverage and generate an HTML report in a 'build' directory.", "build": "Create PHAR files for PHPCS and PHPCBF.", "check-all": "Run all checks (phpcs, tests)." } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 68b5bac47f..9fb6c304db 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,10 +9,26 @@ convertWarningsToExceptions="true" convertNoticesToExceptions="true" convertDeprecationsToExceptions="true" + forceCoversAnnotation="true" > tests/AllTests.php + + + + ./src + ./autoload.php + + ./src/Standards + + + + + + + + From 3f29c2472369f3a0b852e8ec95cf2c1b885ca293 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 9 Dec 2023 23:24:01 +0100 Subject: [PATCH 156/874] GH Actions: start recording code coverage This commit reworks the `test` workflow to start running the tests with code coverage for low/medium/high PHP and upload the generated reports to Coveralls. * It adds an extra "coverage" job which runs only the unit tests with code coverage against low/medium/high PHP. This job does not run the CS check as an integration test. * Makes minor tweaks to the pre-existing "test" job to prevent duplicate test runs for the exact same PHP/custom ini combinations. No need to run the same check twice. The recorded code coverage reports will be available on: https://coveralls.io/github/PHPCSStandards/PHP_CodeSniffer Includes adding a code coverage badge to the README. --- .github/workflows/quicktest.yml | 2 +- .github/workflows/test.yml | 103 +++++++++++++++++++++++++++++++- README.md | 1 + 3 files changed, 102 insertions(+), 4 deletions(-) diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index d00eec5d3c..417766cc02 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -54,7 +54,7 @@ jobs: run: php bin/phpcs --config-set php_path php - name: 'PHPUnit: run the tests' - run: vendor/bin/phpunit tests/AllTests.php + run: vendor/bin/phpunit tests/AllTests.php --no-coverage # Note: The code style check is run as an integration test. - name: 'PHPCS: check code style without cache, no parallel' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4798deab9e..2527c4b8bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -74,7 +74,14 @@ jobs: custom_ini: [false] include: - # Builds running the basic tests with different PHP ini settings. + # Skip test runs on builds which are also run for in the coverage job. + # Note: the tests on PHP 7.2 will still be run as the coverage build is uses custom_ini for that version. + - php: '5.4' + skip_tests: true + - php: '8.3' + skip_tests: true + + # Extra builds running only the unit tests with different PHP ini settings. - php: '5.5' custom_ini: true - php: '7.0' @@ -137,8 +144,9 @@ jobs: - name: 'PHPCS: set the path to PHP' run: php bin/phpcs --config-set php_path php - - name: 'PHPUnit: run the tests' - run: vendor/bin/phpunit tests/AllTests.php + - name: 'PHPUnit: run the tests without code coverage' + if: ${{ matrix.skip_tests != true }} + run: vendor/bin/phpunit tests/AllTests.php --no-coverage - name: 'PHPCS: check code style without cache, no parallel' if: ${{ matrix.custom_ini == false && matrix.php != '7.4' }} @@ -163,3 +171,92 @@ jobs: - name: 'PHPCS: check code style using the Phar file' if: ${{ matrix.custom_ini == false }} run: php phpcs.phar + + coverage: + runs-on: ubuntu-latest + + strategy: + matrix: + include: + - php: '5.4' + custom_ini: false + - php: '7.2' + custom_ini: true + - php: '8.3' + custom_ini: false + + name: "Coverage: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}" + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup ini config + id: set_ini + run: | + # Set the "short_open_tag" ini to make sure specific conditions are tested. + # Also turn on error_reporting to ensure all notices are shown. + if [[ ${{ matrix.custom_ini }} == true && "${{ startsWith( matrix.php, '5.' ) }}" == true ]]; then + echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On' >> $GITHUB_OUTPUT + elif [[ ${{ matrix.custom_ini }} == true && "${{ startsWith( matrix.php, '7.' ) }}" == true ]]; then + echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On' >> $GITHUB_OUTPUT + else + echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT + fi + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + ini-values: ${{ steps.set_ini.outputs.PHP_INI }} + coverage: xdebug + + # This action also handles the caching of the dependencies. + - name: Set up node + if: ${{ matrix.custom_ini == false }} + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install external tools used in tests + if: ${{ matrix.custom_ini == false }} + run: > + npm install -g --fund false + csslint + eslint + jshint + + # Install dependencies and handle caching in one go. + # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer + - name: Install Composer dependencies + uses: "ramsey/composer-install@v2" + with: + # Bust the cache at least once a month - output format: YYYY-MM. + custom-cache-suffix: $(date -u "+%Y-%m") + + - name: 'PHPCS: set the path to PHP' + run: php bin/phpcs --config-set php_path php + + - name: 'PHPUnit: run the tests with code coverage' + run: vendor/bin/phpunit tests/AllTests.php + + - name: Upload coverage results to Coveralls + if: ${{ success() }} + uses: coverallsapp/github-action@v2 + with: + format: clover + file: build/logs/clover.xml + flag-name: php-${{ matrix.php }}-custom-ini-${{ matrix.custom_ini }} + parallel: true + + coveralls-finish: + needs: coverage + if: always() && needs.coverage.result == 'success' + + runs-on: ubuntu-latest + + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@v2 + with: + parallel-finished: true diff --git a/README.md b/README.md index e65acb61e0..7c9932e9a1 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ PHP_CodeSniffer [![Latest Stable Version](http://poser.pugx.org/phpcsstandards/php_codesniffer/v)](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases) [![Validate](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/validate.yml/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/validate.yml) [![Test](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml) +[![Coverage Status](https://coveralls.io/repos/github/PHPCSStandards/PHP_CodeSniffer/badge.svg?branch=master)](https://coveralls.io/github/PHPCSStandards/PHP_CodeSniffer?branch=master) [![License](http://poser.pugx.org/phpcsstandards/php_codesniffer/license)](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt) ![Minimum PHP Version](https://img.shields.io/packagist/php-v/squizlabs/php_codesniffer.svg?maxAge=3600) From 77e171ee5f1a5b1a70e9a35a034a38a0fb6de3b4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 10 Dec 2023 02:28:59 +0100 Subject: [PATCH 157/874] Squiz/Heredoc: rename the test case file ... to allow for moving the git conflict/parse error test to a secondary test case file. --- ...redocUnitTest.inc => HeredocUnitTest.1.inc} | 0 .../Squiz/Tests/PHP/HeredocUnitTest.php | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) rename src/Standards/Squiz/Tests/PHP/{HeredocUnitTest.inc => HeredocUnitTest.1.inc} (100%) diff --git a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.1.inc similarity index 100% rename from src/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc rename to src/Standards/Squiz/Tests/PHP/HeredocUnitTest.1.inc diff --git a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php index 90f4cfab66..de2d71e48e 100644 --- a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php @@ -26,14 +26,22 @@ class HeredocUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 2 => 1, - 8 => 1, - ]; + switch ($testFile) { + case 'HeredocUnitTest.1.inc': + return [ + 2 => 1, + 8 => 1, + ]; + + default: + return []; + }//end switch }//end getErrorList() From 87f52ede22dac3231eed470273fd28e70b190483 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 10 Dec 2023 02:29:59 +0100 Subject: [PATCH 158/874] Squiz/Heredoc: move a test to its own file Move the git conflict/parse error test to its own file. Related to 143 --- .../Squiz/Tests/PHP/HeredocUnitTest.1.inc | 15 --------------- .../Squiz/Tests/PHP/HeredocUnitTest.2.inc | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 src/Standards/Squiz/Tests/PHP/HeredocUnitTest.2.inc diff --git a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.1.inc index 56f4393aed..d1863c0763 100644 --- a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.1.inc @@ -10,18 +10,3 @@ My name is "$name". I am printing some $foo->foo. Now, I am printing some {$foo->bar[1]}. This should not print a capital 'A': \x41 EOT; - -// The following function has a simulated git conflict for testing. -// This is not a merge conflict - it is a valid test case. -// Please do not remove. -function test() - { - $arr = array( - 'a' => 'a' -<<<<<<< HEAD - 'b' => 'b' -======= - 'c' => 'c' ->>>>>>> master - ); - } diff --git a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.2.inc b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.2.inc new file mode 100644 index 0000000000..eb0062f08e --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.2.inc @@ -0,0 +1,17 @@ + 'a' +<<<<<<< HEAD + 'b' => 'b' +======= + 'c' => 'c' +>>>>>>> master + ); + } From 3d9d85234810f29d00388df32a829ccc34609e66 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 10 Dec 2023 03:13:12 +0100 Subject: [PATCH 159/874] Squiz/NonExecutableCode: move parse error test to its own file --- .../Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc | 3 --- .../Squiz/Tests/PHP/NonExecutableCodeUnitTest.4.inc | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.4.inc diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc index 2efcc78e57..4b1d1ca650 100644 --- a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.1.inc @@ -418,6 +418,3 @@ $closure = function () echo 'foo'; return; // This return should be flagged as not required. }; - -// Intentional syntax error. -return array_map( diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.4.inc b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.4.inc new file mode 100644 index 0000000000..189466b4dd --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.4.inc @@ -0,0 +1,6 @@ + Date: Mon, 11 Dec 2023 16:14:16 +0100 Subject: [PATCH 160/874] Doc: mention the signing key for phars The signing key used for the phars is mentioned in the README. This can serve as a "trust anchor" for consumers. --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c9932e9a1..383fed2ac3 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,9 @@ php phpcs.phar -h php phpcbf.phar -h ``` +These Phars are signed with the official Release key for PHPCS with the +fingerprint `95DE 904A B800 754A 11D8 0B60 5E6D DE99 8AB7 3B8E`. + ### Composer If you use Composer, you can install PHP_CodeSniffer system-wide with the following command: ```bash @@ -71,8 +74,8 @@ You will then be able to run PHP_CodeSniffer from the vendor bin directory: ### Phive If you use Phive, you can install PHP_CodeSniffer as a project tool using the following commands: ```bash -phive install phpcs -phive install phpcbf +phive install --trust-gpg-keys 95DE904AB800754A11D80B605E6DDE998AB73B8E phpcs +phive install --trust-gpg-keys 95DE904AB800754A11D80B605E6DDE998AB73B8E phpcbf ``` You will then be able to run PHP_CodeSniffer from the `tools` directory: ```bash From 18cb0d4b95fff8f8a797aa7bc19b19fec452eb3f Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 11 Dec 2023 12:39:42 -0500 Subject: [PATCH 161/874] Report Full: fix two line wrapping bugs (#125) * Fix two line wrapping bugs in default report formatter The first is that the ANSI escape codes applied to bold the message when `-s` is used were not being taken into account when wrapping the lines for width, causing some lines to be wrapped unnecessarily. The second is that when lines were wrapped in the middle of a long message, the `|` characters making up the table were being bolded along with the message. * Report Full: iterate on line wrapping bug fix This commit takes the fix one step further by adding the padding only after the message has been word-wrapped. Includes correct handling of padding for multi-line error messages. It then takes the last line of the resulting message and determines in isolation whether the source code suffix can fit on that line or needs to be placed on a new line. Co-authored-by: Brad Jorsch Co-authored-by: jrfnl --- src/Reports/Full.php | 61 +++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/src/Reports/Full.php b/src/Reports/Full.php index f6db5833be..ee2b5af203 100644 --- a/src/Reports/Full.php +++ b/src/Reports/Full.php @@ -115,36 +115,51 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, // The maximum amount of space an error message can use. $maxErrorSpace = ($width - $paddingLength - 1); + $beforeMsg = ''; + $afterMsg = ''; + if ($showSources === true) { + $beforeMsg = "\033[1m"; + $afterMsg = "\033[0m"; + } + + $beforeAfterLength = strlen($beforeMsg.$afterMsg); + foreach ($report['messages'] as $line => $lineErrors) { foreach ($lineErrors as $column => $colErrors) { foreach ($colErrors as $error) { - $message = $error['message']; - $msgLines = [$message]; - if (strpos($message, "\n") !== false) { - $msgLines = explode("\n", $message); - } + $errorMsg = wordwrap( + $error['message'], + $maxErrorSpace + ); - $errorMsg = ''; - $lastLine = (count($msgLines) - 1); - foreach ($msgLines as $k => $msgLine) { - if ($k === 0) { - if ($showSources === true) { - $errorMsg .= "\033[1m"; - } - } else { - $errorMsg .= PHP_EOL.$paddingLine2; - } + // Add the padding _after_ the wordwrap as the message itself may contain line breaks + // and those lines will also need to receive padding. + $errorMsg = str_replace("\n", $afterMsg.PHP_EOL.$paddingLine2.$beforeMsg, $errorMsg); + $errorMsg = $beforeMsg.$errorMsg.$afterMsg; - if ($k === $lastLine && $showSources === true) { - $msgLine .= "\033[0m".' ('.$error['source'].')'; + if ($showSources === true) { + $lastMsg = $errorMsg; + $startPosLastLine = strrpos($errorMsg, PHP_EOL.$paddingLine2.$beforeMsg); + if ($startPosLastLine !== false) { + // Message is multiline. Grab the text of last line of the message, including the color codes. + $lastMsg = substr($errorMsg, ($startPosLastLine + strlen(PHP_EOL.$paddingLine2))); } - $errorMsg .= wordwrap( - $msgLine, - $maxErrorSpace, - PHP_EOL.$paddingLine2 - ); - } + // When show sources is used, the message itself will be bolded, so we need to correct the length. + $sourceSuffix = '('.$error['source'].')'; + + $lastMsgPlusSourceLength = strlen($lastMsg); + // Add space + source suffix length. + $lastMsgPlusSourceLength += (1 + strlen($sourceSuffix)); + // Correct for the color codes. + $lastMsgPlusSourceLength -= $beforeAfterLength; + + if ($lastMsgPlusSourceLength > $maxErrorSpace) { + $errorMsg .= PHP_EOL.$paddingLine2.$sourceSuffix; + } else { + $errorMsg .= ' '.$sourceSuffix; + } + }//end if // The padding that goes on the front of the line. $padding = ($maxLineNumLength - strlen($line)); From dff4c58f7672d7a0c4e0e47140ac400364887751 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 10 Dec 2023 17:35:39 +0100 Subject: [PATCH 162/874] Report Full: fix delimiter line bug When determining the max message length, the calculation did not take potential explicit multi-line messages into account and would base the delimiter line length on the length of the complete message, not on the length of the individual lines. Fixed now. --- src/Reports/Full.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Reports/Full.php b/src/Reports/Full.php index ee2b5af203..d0b01da240 100644 --- a/src/Reports/Full.php +++ b/src/Reports/Full.php @@ -64,15 +64,28 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, foreach ($report['messages'] as $line => $lineErrors) { foreach ($lineErrors as $column => $colErrors) { foreach ($colErrors as $error) { - $length = strlen($error['message']); + // Start with the presumption of a single line error message. + $length = strlen($error['message']); + $srcLength = (strlen($error['source']) + 3); if ($showSources === true) { - $length += (strlen($error['source']) + 3); + $length += $srcLength; + } + + // ... but also handle multi-line messages correctly. + if (strpos($error['message'], "\n") !== false) { + $errorLines = explode("\n", $error['message']); + $length = max(array_map('strlen', $errorLines)); + + if ($showSources === true) { + $lastLine = array_pop($errorLines); + $length = max($length, (strlen($lastLine) + $srcLength)); + } } $maxErrorLength = max($maxErrorLength, ($length + 1)); - } - } - } + }//end foreach + }//end foreach + }//end foreach $file = $report['filename']; $fileLength = strlen($file); From 9f44251423a60a78564f98fc21173e9164270fe5 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 12 Dec 2023 12:03:03 -0300 Subject: [PATCH 163/874] Add documentation for the SpaceBeforeCast sniff --- .../Formatting/SpaceBeforeCastStandard.xml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml diff --git a/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml b/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml new file mode 100644 index 0000000000..1ae01bdd28 --- /dev/null +++ b/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml @@ -0,0 +1,31 @@ + + + + + + + (int) $string; + ]]> + + + (int) $string; + ]]> + + + + + (int) $b; + ]]> + + + (int) $b; + ]]> + + + From c9c9b09e939d2ae435eb8c5dc00daffab0677899 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 13 Dec 2023 08:50:16 -0300 Subject: [PATCH 164/874] Minor improvements to the SpaceBeforeCast sniff documentation Suggestions made during the PR review process Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- .../Generic/Docs/Formatting/SpaceBeforeCastStandard.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml b/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml index 1ae01bdd28..b6be1ae301 100644 --- a/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml +++ b/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml @@ -1,7 +1,7 @@ - + From 1f90b17561cd0581ab283bb1db0cb7da9f3054ad Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 13 Dec 2023 09:38:53 -0300 Subject: [PATCH 165/874] Combine code examples into a single `` block Doing this based on the PR review (https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/159#discussion_r1424492090) as the valid code examples are essentially the same. This commit also changes the changes the type cast used in the second example to make it more clear that this sniff is not only about `(int)` type casts. --- .../Docs/Formatting/SpaceBeforeCastStandard.xml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml b/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml index b6be1ae301..09fbc189f3 100644 --- a/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml +++ b/src/Standards/Generic/Docs/Formatting/SpaceBeforeCastStandard.xml @@ -8,23 +8,13 @@ (int) $string; +$c = $a . (string) $b; ]]> - + (int) $string; - ]]> - - - - - (int) $b; - ]]> - - - (int) $b; +$c = $a . (string) $b; ]]> From dce2307b29d1400f52a70db91f7a950b6bce7707 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 12 Dec 2023 15:39:19 -0300 Subject: [PATCH 166/874] Rename test case file for AssignmentInCondition sniff Doing this to be able to add more test case files to cover defensive code in the AssignmentInCondition sniff that protects it when checking code with parse errors. --- ...nc => AssignmentInConditionUnitTest.1.inc} | 0 .../AssignmentInConditionUnitTest.php | 82 ++++++++++--------- 2 files changed, 45 insertions(+), 37 deletions(-) rename src/Standards/Generic/Tests/CodeAnalysis/{AssignmentInConditionUnitTest.inc => AssignmentInConditionUnitTest.1.inc} (100%) diff --git a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.inc b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.inc rename to src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php index a1836217ee..5dd5adc6c1 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php @@ -41,46 +41,54 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return [ - 46 => 1, - 47 => 1, - 48 => 1, - 49 => 1, - 50 => 1, - 51 => 1, - 52 => 1, - 53 => 1, - 54 => 1, - 55 => 1, - 56 => 1, - 57 => 1, - 58 => 1, - 59 => 1, - 60 => 1, - 61 => 2, - 63 => 1, - 64 => 1, - 67 => 1, - 68 => 1, - 69 => 1, - 70 => 1, - 71 => 1, - 72 => 1, - 73 => 1, - 75 => 1, - 77 => 1, - 80 => 2, - 84 => 1, - 85 => 2, - 88 => 1, - 90 => 1, - 92 => 1, - 95 => 1, - ]; + switch ($testFile) { + case 'AssignmentInConditionUnitTest.1.inc': + return [ + 46 => 1, + 47 => 1, + 48 => 1, + 49 => 1, + 50 => 1, + 51 => 1, + 52 => 1, + 53 => 1, + 54 => 1, + 55 => 1, + 56 => 1, + 57 => 1, + 58 => 1, + 59 => 1, + 60 => 1, + 61 => 2, + 63 => 1, + 64 => 1, + 67 => 1, + 68 => 1, + 69 => 1, + 70 => 1, + 71 => 1, + 72 => 1, + 73 => 1, + 75 => 1, + 77 => 1, + 80 => 2, + 84 => 1, + 85 => 2, + 88 => 1, + 90 => 1, + 92 => 1, + 95 => 1, + ]; + + default: + return []; + }//end switch }//end getWarningList() From 1fad6ab87db3f3f9d5f0aeeefdc6123054d5eead Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 13 Dec 2023 10:28:57 -0300 Subject: [PATCH 167/874] Improve test coverage for the AssignmentInCondition sniff This commit improves the test coverage for the AssignmentInCondition sniff by adding a few more test case files to exercise the parts of the sniff code that checks for invalid syntax. --- .../Tests/CodeAnalysis/AssignmentInConditionUnitTest.2.inc | 4 ++++ .../Tests/CodeAnalysis/AssignmentInConditionUnitTest.3.inc | 4 ++++ .../Tests/CodeAnalysis/AssignmentInConditionUnitTest.4.inc | 6 ++++++ .../Tests/CodeAnalysis/AssignmentInConditionUnitTest.5.inc | 6 ++++++ .../Tests/CodeAnalysis/AssignmentInConditionUnitTest.6.inc | 5 +++++ 5 files changed, 25 insertions(+) create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.2.inc create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.3.inc create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.4.inc create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.5.inc create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.6.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.2.inc b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.2.inc new file mode 100644 index 0000000000..123d7f3e9a --- /dev/null +++ b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.2.inc @@ -0,0 +1,4 @@ + Date: Sun, 10 Dec 2023 01:37:06 +0100 Subject: [PATCH 168/874] Squiz/ScopeKeywordSpacing: rename the test case file ... to allow for adding additional test case files for this sniff. --- ....inc => ScopeKeywordSpacingUnitTest.1.inc} | 0 ...> ScopeKeywordSpacingUnitTest.1.inc.fixed} | 0 .../ScopeKeywordSpacingUnitTest.php | 56 +++++++++++-------- 3 files changed, 32 insertions(+), 24 deletions(-) rename src/Standards/Squiz/Tests/WhiteSpace/{ScopeKeywordSpacingUnitTest.inc => ScopeKeywordSpacingUnitTest.1.inc} (100%) rename src/Standards/Squiz/Tests/WhiteSpace/{ScopeKeywordSpacingUnitTest.inc.fixed => ScopeKeywordSpacingUnitTest.1.inc.fixed} (100%) diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc similarity index 100% rename from src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc rename to src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc.fixed b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed similarity index 100% rename from src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc.fixed rename to src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php index aaa49d65d1..8b6562c0f6 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php @@ -26,33 +26,41 @@ class ScopeKeywordSpacingUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 7 => 2, - 8 => 1, - 13 => 1, - 14 => 1, - 15 => 1, - 17 => 2, - 26 => 1, - 28 => 1, - 29 => 1, - 64 => 1, - 67 => 1, - 71 => 1, - 103 => 1, - 106 => 1, - 111 => 1, - 119 => 1, - 121 => 1, - 127 => 2, - 134 => 2, - 138 => 2, - 140 => 3, - ]; + switch ($testFile) { + case 'ScopeKeywordSpacingUnitTest.1.inc': + return [ + 7 => 2, + 8 => 1, + 13 => 1, + 14 => 1, + 15 => 1, + 17 => 2, + 26 => 1, + 28 => 1, + 29 => 1, + 64 => 1, + 67 => 1, + 71 => 1, + 103 => 1, + 106 => 1, + 111 => 1, + 119 => 1, + 121 => 1, + 127 => 2, + 134 => 2, + 138 => 2, + 140 => 3, + ]; + + default: + return []; + }//end switch }//end getErrorList() From 393f2317de6aa936160cccd7a41e2fc152996324 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 10 Dec 2023 02:03:15 +0100 Subject: [PATCH 169/874] Squiz/ScopeKeywordSpacing: add more defensive coding When the sniff would encounter a parse error/be run during live coding, the sniff could trigger an `Undefined array key` notice for the use of `$stackPtr + 2`. Fixed now by bowing out early if the keyword is found at the end of a file. Includes additional tests. --- .../Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php | 3 +++ .../Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.2.inc | 6 ++++++ .../Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.3.inc | 6 ++++++ .../WhiteSpace/ScopeKeywordSpacingUnitTest.3.inc.fixed | 6 ++++++ .../Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php | 3 +++ 5 files changed, 24 insertions(+) create mode 100644 src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.2.inc create mode 100644 src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.3.inc create mode 100644 src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.3.inc.fixed diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php index 1424819f51..6a72c07e19 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php @@ -127,6 +127,9 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { $spacing = 0; + } else if (isset($tokens[($stackPtr + 2)]) === false) { + // Parse error/live coding. Bow out. + return; } else { if ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) { $spacing = 'newline'; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.2.inc b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.2.inc new file mode 100644 index 0000000000..45cfb53431 --- /dev/null +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.2.inc @@ -0,0 +1,6 @@ + 3, ]; + case 'ScopeKeywordSpacingUnitTest.3.inc': + return [6 => 1]; + default: return []; }//end switch From 1a046acbdbdc1e434c3742e6a458a6b766213ed4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 10 Dec 2023 02:07:20 +0100 Subject: [PATCH 170/874] Squiz/ScopeKeywordSpacing: add extra tests with static in a union type This is already handled correctly, the tests just safeguards this. --- .../Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc | 6 +++--- .../WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc index 12685dc97d..a76f42fef4 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc @@ -95,9 +95,9 @@ public static function fCreate($attributes = []): ?static } // Also account for static used within union types. -public function fCreate($attributes = []): object|static -{ -} +public function staticLast($attributes = []): object|static {} +public function staticMiddle(): string|static|object {} +public function staticFirst(): static|object {} // Ensure that static as a scope keyword when preceeded by a colon which is not for a type declaration is still handled. $callback = $cond ? get_fn_name() : static function ($a) { return $a * 10; }; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed index d3b682ed75..7fd80626d5 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed @@ -90,9 +90,9 @@ public static function fCreate($attributes = []): ?static } // Also account for static used within union types. -public function fCreate($attributes = []): object|static -{ -} +public function staticLast($attributes = []): object|static {} +public function staticMiddle(): string|static|object {} +public function staticFirst(): static|object {} // Ensure that static as a scope keyword when preceeded by a colon which is not for a type declaration is still handled. $callback = $cond ? get_fn_name() : static function ($a) { return $a * 10; }; From 8a1e0c2d776ea821a216b3aa3668ab35ccd10593 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 15 Dec 2023 10:10:17 -0300 Subject: [PATCH 171/874] Remove unused first parameter from getErrorList() and getWarningList() This commit removes the first paramter from getErrorList() and getWarningList() when the parameter is not used inside the method. --- src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php | 8 ++------ src/Standards/Generic/Tests/Commenting/TodoUnitTest.php | 8 ++------ .../Tests/Objects/CreateWidgetTypeCallbackUnitTest.php | 4 +--- .../Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php | 4 +--- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php index e89b2298e9..90ee54c499 100644 --- a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php @@ -27,11 +27,9 @@ class FixmeUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='FixmeUnitTest.inc') + public function getErrorList() { return [ 3 => 1, @@ -53,11 +51,9 @@ public function getErrorList($testFile='FixmeUnitTest.inc') * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getWarningList($testFile='FixmeUnitTest.inc') + public function getWarningList() { return []; diff --git a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php index 30de38383d..d3300fb15c 100644 --- a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php @@ -26,11 +26,9 @@ class TodoUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='TodoUnitTest.inc') + public function getErrorList() { return []; @@ -43,11 +41,9 @@ public function getErrorList($testFile='TodoUnitTest.inc') * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getWarningList($testFile='TodoUnitTest.inc') + public function getWarningList() { return [ 3 => 1, diff --git a/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php b/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php index 7ae3342f54..55b93375a9 100644 --- a/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php @@ -26,11 +26,9 @@ class CreateWidgetTypeCallbackUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='CreateWidgetTypeCallbackUnitTest.js') + public function getErrorList() { return [ 18 => 1, diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php index 660b7ef23c..1c985ef8cd 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php @@ -26,11 +26,9 @@ class LogicalOperatorSpacingUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='LogicalOperatorSpacingUnitTest.inc') + public function getErrorList() { return [ 4 => 2, From 4231f693e725077060df2d5acd843a6f22e5a3f7 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 15 Dec 2023 10:13:28 -0300 Subject: [PATCH 172/874] Replace default value of first parameter in getWarningList() with '' Replacing the default value with an empty string. Per Juliette's comment (https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/163#discussion_r1426775588) there are three reasons why we want to do that: - The default value has no value in practice. It is an optional argument which is not enforced via the abstract functions, but is passed in all cases, so the default is never used in practice. - Setting the default value as file 1 also has an assumption implied, while IMO assumptions have no place in a test suite. - Maintainability - one less thing to have to keep in sync and to guard against typos --- .../Tests/Formatting/MultipleStatementAlignmentUnitTest.php | 2 +- src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php | 2 +- .../Tests/ControlStructures/ForLoopDeclarationUnitTest.php | 2 +- .../Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php index ea27e98dbf..b27a7b0306 100644 --- a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php @@ -45,7 +45,7 @@ public function getErrorList() * * @return array */ - public function getWarningList($testFile='MultipleStatementAlignmentUnitTest.inc') + public function getWarningList($testFile='') { switch ($testFile) { case 'MultipleStatementAlignmentUnitTest.inc': diff --git a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php index 3b55cdc3d9..6d62b9c12f 100644 --- a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php @@ -74,7 +74,7 @@ public function getErrorList($testFile='FileCommentUnitTest.inc') * * @return array */ - public function getWarningList($testFile='FileCommentUnitTest.inc') + public function getWarningList($testFile='') { switch ($testFile) { case 'FileCommentUnitTest.1.inc': diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php index d7701c1310..efb1f1e338 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php @@ -118,7 +118,7 @@ public function getErrorList($testFile='ForLoopDeclarationUnitTest.inc') * * @return array */ - public function getWarningList($testFile='ForLoopDeclarationUnitTest.inc') + public function getWarningList($testFile='') { switch ($testFile) { case 'ForLoopDeclarationUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php index 1bd84621f3..bb39572654 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -143,7 +143,7 @@ public function getErrorList($testFile='SwitchDeclarationUnitTest.inc') * * @return array */ - public function getWarningList($testFile='SwitchDeclarationUnitTest.inc') + public function getWarningList($testFile='') { if ($testFile === 'SwitchDeclarationUnitTest.js') { return [273 => 1]; diff --git a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php index 34b706b22b..148d13882f 100644 --- a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php @@ -45,7 +45,7 @@ public function getErrorList() * * @return array */ - public function getWarningList($testFile='CommentedOutCodeUnitTest.inc') + public function getWarningList($testFile='') { switch ($testFile) { case 'CommentedOutCodeUnitTest.inc': From e3d31005eeacc144f7b9df7d28555b7632741d20 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 15 Dec 2023 10:22:13 -0300 Subject: [PATCH 173/874] Replace default value of first parameter in getErrorList() with '' Replacing the default value with an empty string. Per Juliette's comment (https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/163#discussion_r1426775588) there are three reasons why we want to do that: - The default value has no value in practice. It is an optional argument which is not enforced via the abstract functions, but is passed in all cases, so the default is never used in practice. - Setting the default value as file 1 also has an assumption implied, while IMO assumptions have no place in a test suite. - Maintainability - one less thing to have to keep in sync and to guard against typos --- .../Tests/ControlStructures/InlineControlStructureUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php | 2 +- .../Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php | 2 +- .../Generic/Tests/VersionControl/GitMergeConflictUnitTest.php | 2 +- .../Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php | 2 +- .../Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php | 2 +- src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php | 2 +- src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php | 2 +- src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php | 2 +- src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php | 2 +- src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php | 2 +- .../PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php | 2 +- .../PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php | 2 +- .../PEAR/Tests/Functions/FunctionDeclarationUnitTest.php | 2 +- .../Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php | 2 +- src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php | 2 +- src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php | 2 +- .../Tests/Commenting/LongConditionClosingCommentUnitTest.php | 2 +- .../Squiz/Tests/Commenting/PostStatementCommentUnitTest.php | 2 +- .../Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php | 2 +- .../Tests/ControlStructures/ForLoopDeclarationUnitTest.php | 2 +- .../Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php | 2 +- .../Squiz/Tests/Formatting/OperatorBracketUnitTest.php | 2 +- .../Tests/Functions/MultiLineFunctionDeclarationUnitTest.php | 2 +- .../Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php | 2 +- .../Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php | 2 +- .../Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php | 2 +- .../Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php | 2 +- .../Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index bc61577fb7..af4d43ea50 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -30,7 +30,7 @@ class InlineControlStructureUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='InlineControlStructureUnitTest.1.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'InlineControlStructureUnitTest.1.inc': diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php index f047e2609b..fac155c459 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php @@ -30,7 +30,7 @@ class LowerCaseConstantUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='LowerCaseConstantUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'LowerCaseConstantUnitTest.inc': diff --git a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php index 25b983d6b5..ce08934bdf 100644 --- a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php +++ b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php @@ -30,7 +30,7 @@ class UnnecessaryStringConcatUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='UnnecessaryStringConcatUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'UnnecessaryStringConcatUnitTest.inc': diff --git a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php index 1a71c85d58..f67518258d 100644 --- a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php +++ b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php @@ -30,7 +30,7 @@ class GitMergeConflictUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='GitMergeConflictUnitTest.1.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'GitMergeConflictUnitTest.1.inc': diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php index d745785b28..799568a1f7 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php @@ -49,7 +49,7 @@ public function setCliValues($testFile, $config) * * @return array */ - public function getErrorList($testFile='DisallowSpaceIndentUnitTest.1.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'DisallowSpaceIndentUnitTest.1.inc': diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php index 77f20ee397..ce6e114da6 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php @@ -30,7 +30,7 @@ class IncrementDecrementSpacingUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='IncrementDecrementSpacingUnitTest.inc') + public function getErrorList($testFile='') { $errors = [ 5 => 1, diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index 729bea1925..feb4fd67c0 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -50,7 +50,7 @@ public function setCliValues($testFile, $config) * * @return array */ - public function getErrorList($testFile='ScopeIndentUnitTest.inc') + public function getErrorList($testFile='') { if ($testFile === 'ScopeIndentUnitTest.1.js') { return [ diff --git a/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php b/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php index 47ce7c1a12..3a88a0ecdf 100644 --- a/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php +++ b/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php @@ -30,7 +30,7 @@ class FirebugConsoleUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='FirebugConsoleUnitTest.js') + public function getErrorList($testFile='') { if ($testFile !== 'FirebugConsoleUnitTest.js') { return []; diff --git a/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php b/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php index be2eacf433..4b056a7faa 100644 --- a/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php @@ -30,7 +30,7 @@ class AssignThisUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='AssignThisUnitTest.js') + public function getErrorList($testFile='') { if ($testFile !== 'AssignThisUnitTest.js') { return []; diff --git a/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php b/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php index dcb397fdae..a2c43dce03 100644 --- a/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php +++ b/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php @@ -30,7 +30,7 @@ class JoinStringsUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='JoinStringsUnitTest.js') + public function getErrorList($testFile='') { if ($testFile !== 'JoinStringsUnitTest.js') { return []; diff --git a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php index 6d62b9c12f..52bcd5872e 100644 --- a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php @@ -30,7 +30,7 @@ class FileCommentUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='FileCommentUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'FileCommentUnitTest.1.inc': diff --git a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php index 821c7bfbee..aadaea9490 100644 --- a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php +++ b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php @@ -30,7 +30,7 @@ class MultiLineConditionUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='MultiLineConditionUnitTest.inc') + public function getErrorList($testFile='') { $errors = [ 21 => 1, diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php index 38eff588ba..f6d456ac04 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php @@ -30,7 +30,7 @@ class FunctionCallSignatureUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='FunctionCallSignatureUnitTest.inc') + public function getErrorList($testFile='') { if ($testFile === 'FunctionCallSignatureUnitTest.js') { return [ diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php index 828c7da04c..43cffff080 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php @@ -30,7 +30,7 @@ class FunctionDeclarationUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='FunctionDeclarationUnitTest.inc') + public function getErrorList($testFile='') { if ($testFile === 'FunctionDeclarationUnitTest.inc') { $errors = [ diff --git a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php index 4d735f4ca1..6eab274482 100644 --- a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php @@ -30,7 +30,7 @@ class DocCommentAlignmentUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='DocCommentAlignmentUnitTest.inc') + public function getErrorList($testFile='') { $errors = [ 3 => 1, diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php index ab93fc89a2..b7b686d73b 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php @@ -30,7 +30,7 @@ class FileCommentUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='FileCommentUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'FileCommentUnitTest.1.inc': diff --git a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php index 8be723a4b6..dbaccb2cbe 100644 --- a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php @@ -30,7 +30,7 @@ class InlineCommentUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='InlineCommentUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'InlineCommentUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php index fae751d4c2..a24a68a266 100644 --- a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php @@ -30,7 +30,7 @@ class LongConditionClosingCommentUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='LongConditionClosingCommentUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'LongConditionClosingCommentUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php index acfc8fc954..7d7f270ab1 100644 --- a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php @@ -30,7 +30,7 @@ class PostStatementCommentUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='PostStatementCommentUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'PostStatementCommentUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php index 0ea1354399..3187047c7c 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -30,7 +30,7 @@ class ControlSignatureUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='ControlSignatureUnitTest.inc') + public function getErrorList($testFile='') { $errors = [ 7 => 1, diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php index efb1f1e338..5ceba29ed6 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php @@ -30,7 +30,7 @@ class ForLoopDeclarationUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='ForLoopDeclarationUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'ForLoopDeclarationUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php index bb39572654..32f9ce35a5 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -30,7 +30,7 @@ class SwitchDeclarationUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='SwitchDeclarationUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'SwitchDeclarationUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php index f00cd1574d..ee5af1b9d0 100644 --- a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php +++ b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php @@ -30,7 +30,7 @@ class OperatorBracketUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='OperatorBracketUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'OperatorBracketUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php index b3a062b50b..1dd5cca225 100644 --- a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php @@ -30,7 +30,7 @@ class MultiLineFunctionDeclarationUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='MultiLineFunctionDeclarationUnitTest.inc') + public function getErrorList($testFile='') { if ($testFile === 'MultiLineFunctionDeclarationUnitTest.inc') { $errors = [ diff --git a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php index bd83fa2415..f3a71f754d 100644 --- a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php @@ -30,7 +30,7 @@ class DisallowObjectStringIndexUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='DisallowObjectStringIndexUnitTest.js') + public function getErrorList($testFile='') { if ($testFile !== 'DisallowObjectStringIndexUnitTest.js') { return []; diff --git a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php index d0b1d3800e..ffaf905d90 100644 --- a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php @@ -30,7 +30,7 @@ class ComparisonOperatorUsageUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'ComparisonOperatorUsageUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php index d913d2f53f..7e78e97395 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php @@ -30,7 +30,7 @@ class DisallowInlineIfUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='DisallowInlineIfUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'DisallowInlineIfUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php index 424994b20a..8ec0b73c89 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php @@ -30,7 +30,7 @@ class DisallowSizeFunctionsInLoopsUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='DisallowSizeFunctionsInLoopsUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'DisallowSizeFunctionsInLoopsUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php index 0a81b71657..f3820bba8e 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php @@ -30,7 +30,7 @@ class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='ControlStructureSpacingUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'ControlStructureSpacingUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php index d2969fc487..90fd2ae2b3 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php @@ -30,7 +30,7 @@ class FunctionClosingBraceSpaceUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='FunctionClosingBraceSpaceUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'FunctionClosingBraceSpaceUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php index 55d9432fb9..c5525abba7 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php @@ -30,7 +30,7 @@ class FunctionOpeningBraceSpaceUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='FunctionOpeningBraceSpaceUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'FunctionOpeningBraceSpaceUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php index 0379d28a97..66b780a74e 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php @@ -30,7 +30,7 @@ class OperatorSpacingUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='OperatorSpacingUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'OperatorSpacingUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php index 9f55e2a302..2f31ffb8bc 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php @@ -30,7 +30,7 @@ class SemicolonSpacingUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='SemicolonSpacingUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'SemicolonSpacingUnitTest.inc': diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php index cac3416617..7064de21df 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php @@ -30,7 +30,7 @@ class SuperfluousWhitespaceUnitTest extends AbstractSniffUnitTest * * @return array */ - public function getErrorList($testFile='SuperfluousWhitespaceUnitTest.inc') + public function getErrorList($testFile='') { switch ($testFile) { case 'SuperfluousWhitespaceUnitTest.1.inc': From 1ff9ac506fa6437422da18344b0a1fd0a64f2136 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 15 Dec 2023 20:56:24 +0100 Subject: [PATCH 174/874] PR template: clarify when a changelog entry is expected --- .github/pull_request_template.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 49fe6a5cc9..3dc577a2bf 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -12,7 +12,10 @@ Describe your changes in detail and, if relevant, explain which choices you have ## Suggested changelog entry - + ## Related issues/external references From 2c6a5479a0d708f051f146e44d359b2c6b78de53 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 15 Dec 2023 20:59:01 +0100 Subject: [PATCH 175/874] CONTRIBUTING: add some additional information * Clarify the "issue triage" text is actually about _bug_ triage. * Add link to ticket with the list of missing XML documentation. * Add some information about using labels to find tasks. --- .github/CONTRIBUTING.md | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index b3c188fe5d..2f3d5cc292 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -36,17 +36,17 @@ The [discussion forum](https://github.com/PHPCSStandards/PHP_CodeSniffer/discuss ## Contributing Without Writing Code -### Issue Triage +### Bug Triage -We welcome issue triage. +We welcome bug triage. -Issue triage is the action of verifying a reported issue is reproducible and is actually an issue. -This includes checking whether the issue is something which should be fixed in **_this_** repository. +Bug triage is the action of verifying a reported bug is reproducible and is actually an issue. +This includes checking whether the bug is something which should be fixed in **_this_** repository. -To find issues which need triage, look for [issues without labels](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) or issues with the ["Status: triage"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20triage) label. +To find bugs which need triage, look for issues and PRs with the ["Status: triage"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20triage) label. -#### Typical issue triage tasks: -* Verify whether the issue is reproducible with the given information. +#### Typical bug triage tasks: +* Verify whether the bug is reproducible with the given information. * Ask for additional information if it is not. * If you find the issue is reported to the wrong repo, ask the reporter to report it to the correct external standard repo and suggest closing the issue. @@ -74,7 +74,7 @@ To get access to a PHPCS version which includes the patch from a pull request, y ### Writing sniff documentation -Sniffs in PHP_CodeSniffer should preferably be accompanied by documentation. There is currently still a lot of documentation missing. +Sniffs in PHP_CodeSniffer should preferably be accompanied by documentation. There is currently still a lot of [documentation missing](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/148). Sniff documentation is provided via XML files in the standard's `Docs` directory and is available to end-users via the command-line and/or can be compiled into an HTML or Markdown file. @@ -117,6 +117,31 @@ phpcs --standard=StandardName --generator=Text --sniffs=StandardName.Category.Sn Kind request to add only one new XML file per PR to make the PR easier to review. +### Other tasks + +There are also tasks looking for contributions, which don't necessarily fall into the above categories. + +#### Issues marked with "Status: waiting for opinions" + +Proposals for new features, proposals for (structural) changes to PHP_CodeSniffer itself or to the contributor workflow, will initially be marked with the ["Status: waiting for opinions"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20waiting%20for%20opinions) label. + +This is an open invitation for interested parties to gather their thoughts about the issue and to leave their opinion. + +> Kind request: If you don't have something to add to the discussion, but do want to indicate a positive or negative opinion on a topic, please add an emoji on the original post instead of leaving a comment. + +#### Issues marked with "Status: needs investigation" + +Sometimes an issue has been identified, but it has not yet been pinpointed what the exact cause of the problem is. + +Other times, like with syntax changes in PHP itself, PHP_CodeSniffer _may_, or _may not_, handle them correctly and this will need verification. + +Issues like these will be marked with the ["Status: needs investigation"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20needs%20investigation) and investigating those can be a good way to learn more about the source code of PHP_CodeSniffer. + +#### Issues marked with "Status: help wanted" + +If you don't know where to start, having a browse through issues marked with the ["Status: help wanted"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20help%20wanted) and/or the ["Status: good first issue"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20good%20first%20issue) labels. + + ## Contributing With Code ### Requesting/Submitting New Features From 506ab08b04a0eaaa685b63ffa313d3254089970b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 05:22:45 +0000 Subject: [PATCH 176/874] GH Actions: Bump actions/download-artifact from 3 to 4 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2527c4b8bb..1f45a845a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -163,7 +163,7 @@ jobs: - name: Download the PHPCS phar if: ${{ matrix.custom_ini == false }} - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: phpcs-phar From 696465906ff3ed70f262d05b2c2f862b18a8692c Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 18 Dec 2023 11:14:56 -0300 Subject: [PATCH 177/874] Rename test case files for ArbitraryParenthesesSpacing sniff Doing this to be able to add more test case files to cover defensive code in the ArbitraryParenthesesSpacing sniff that protects it when checking code with parse errors. --- ...ArbitraryParenthesesSpacingUnitTest.1.inc} | 0 ...aryParenthesesSpacingUnitTest.1.inc.fixed} | 0 .../ArbitraryParenthesesSpacingUnitTest.php | 98 +++++++++++-------- 3 files changed, 57 insertions(+), 41 deletions(-) rename src/Standards/Generic/Tests/WhiteSpace/{ArbitraryParenthesesSpacingUnitTest.inc => ArbitraryParenthesesSpacingUnitTest.1.inc} (100%) rename src/Standards/Generic/Tests/WhiteSpace/{ArbitraryParenthesesSpacingUnitTest.inc.fixed => ArbitraryParenthesesSpacingUnitTest.1.inc.fixed} (100%) diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.inc b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.inc rename to src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc.fixed similarity index 100% rename from src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.inc.fixed rename to src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc.fixed diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php index 124efb7d11..488754337d 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php @@ -26,45 +26,53 @@ class ArbitraryParenthesesSpacingUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 64 => 4, - 66 => 1, - 68 => 1, - 69 => 1, - 72 => 2, - 73 => 2, - 77 => 2, - 81 => 4, - 90 => 4, - 94 => 1, - 95 => 1, - 97 => 1, - 100 => 2, - 101 => 2, - 104 => 2, - 107 => 2, - 109 => 4, - 111 => 4, - 113 => 2, - 115 => 2, - 123 => 1, - 125 => 2, - 127 => 1, - 131 => 1, - 133 => 1, - 137 => 1, - 139 => 2, - 141 => 1, - 144 => 1, - 146 => 1, - 163 => 1, - 164 => 1, - 165 => 1, - ]; + switch ($testFile) { + case 'ArbitraryParenthesesSpacingUnitTest.1.inc': + return [ + 64 => 4, + 66 => 1, + 68 => 1, + 69 => 1, + 72 => 2, + 73 => 2, + 77 => 2, + 81 => 4, + 90 => 4, + 94 => 1, + 95 => 1, + 97 => 1, + 100 => 2, + 101 => 2, + 104 => 2, + 107 => 2, + 109 => 4, + 111 => 4, + 113 => 2, + 115 => 2, + 123 => 1, + 125 => 2, + 127 => 1, + 131 => 1, + 133 => 1, + 137 => 1, + 139 => 2, + 141 => 1, + 144 => 1, + 146 => 1, + 163 => 1, + 164 => 1, + 165 => 1, + ]; + + default: + return []; + }//end switch }//end getErrorList() @@ -75,14 +83,22 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return [ - 55 => 1, - 56 => 1, - ]; + switch ($testFile) { + case 'ArbitraryParenthesesSpacingUnitTest.1.inc': + return [ + 55 => 1, + 56 => 1, + ]; + + default: + return []; + }//end switch }//end getWarningList() From 77390f43c39aae10f218d7fe3fd06291a3fa58ac Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 18 Dec 2023 11:24:55 -0300 Subject: [PATCH 178/874] Improve test coverage for the ArbitraryParenthesesSpacing sniff This commit improves the test coverage for the ArbitraryParenthesesSpacing sniff by adding one more test case files to exercise a part of the sniff code that checks for invalid syntax. --- .../WhiteSpace/ArbitraryParenthesesSpacingUnitTest.2.inc | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.2.inc diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.2.inc b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.2.inc new file mode 100644 index 0000000000..3d5bcd0a5c --- /dev/null +++ b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.2.inc @@ -0,0 +1,4 @@ + Date: Mon, 18 Dec 2023 05:22:49 +0000 Subject: [PATCH 179/874] GH Actions: Bump actions/upload-artifact from 3 to 4 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f45a845a9..71d8f0c2ec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,7 +38,7 @@ jobs: run: php scripts/build-phar.php - name: Upload the PHPCS phar - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: phpcs-phar path: ./phpcs.phar @@ -46,7 +46,7 @@ jobs: retention-days: 28 - name: Upload the PHPCBF phar - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: phpcbf-phar path: ./phpcbf.phar From afffe6c64935fd4091a70469f802a9a22533ea61 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 19 Dec 2023 10:57:09 -0300 Subject: [PATCH 180/874] Add a test to ensure the sniff is not triggered for the match expression Adding this as `match` was added in PHP 8. --- .../WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc | 5 +++++ .../ArbitraryParenthesesSpacingUnitTest.1.inc.fixed | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc index 2399a387e1..8e17dbb644 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc @@ -175,3 +175,8 @@ class NonArbitraryParenthesesWithKeywords { $d = new parent( $foo,$bar ); } } + +// Test that the match expression does not trigger the sniff. +$b = match ( $a ) { + 1 => true, +}; diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc.fixed index 9162728e17..c215753ccb 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc.fixed @@ -163,3 +163,8 @@ class NonArbitraryParenthesesWithKeywords { $d = new parent( $foo,$bar ); } } + +// Test that the match expression does not trigger the sniff. +$b = match ( $a ) { + 1 => true, +}; From b41ae595f03cff49306ca592c15783034b402ff3 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 20 Dec 2023 10:44:40 -0300 Subject: [PATCH 181/874] Rename test case files for LanguageConstructSpacing sniff Doing this to be able to move tests with syntax errors to their own file. --- ...=> LanguageConstructSpacingUnitTest.1.inc} | 0 ...guageConstructSpacingUnitTest.1.inc.fixed} | 0 .../LanguageConstructSpacingUnitTest.php | 64 +++++++++++-------- 3 files changed, 36 insertions(+), 28 deletions(-) rename src/Standards/Generic/Tests/WhiteSpace/{LanguageConstructSpacingUnitTest.inc => LanguageConstructSpacingUnitTest.1.inc} (100%) rename src/Standards/Generic/Tests/WhiteSpace/{LanguageConstructSpacingUnitTest.inc.fixed => LanguageConstructSpacingUnitTest.1.inc.fixed} (100%) diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc rename to src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed similarity index 100% rename from src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc.fixed rename to src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php index b11fedcaba..185da98ef8 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php @@ -26,37 +26,45 @@ class LanguageConstructSpacingUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 3 => 1, - 7 => 1, - 11 => 1, - 15 => 1, - 19 => 1, - 23 => 1, - 27 => 1, - 30 => 1, - 33 => 1, - 34 => 1, - 35 => 1, - 36 => 1, - 38 => 1, - 44 => 1, - 45 => 1, - 46 => 2, - 49 => 1, - 51 => 1, - 59 => 1, - 61 => 1, - 63 => 1, - 67 => 1, - 70 => 1, - 71 => 1, - 75 => 1, - ]; + switch ($testFile) { + case 'LanguageConstructSpacingUnitTest.1.inc': + return [ + 3 => 1, + 7 => 1, + 11 => 1, + 15 => 1, + 19 => 1, + 23 => 1, + 27 => 1, + 30 => 1, + 33 => 1, + 34 => 1, + 35 => 1, + 36 => 1, + 38 => 1, + 44 => 1, + 45 => 1, + 46 => 2, + 49 => 1, + 51 => 1, + 59 => 1, + 61 => 1, + 63 => 1, + 67 => 1, + 70 => 1, + 71 => 1, + 75 => 1, + ]; + + default: + return []; + }//end switch }//end getErrorList() From 6355e6e024e67045eecb3bd8d5fb9c87d21ec578 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 20 Dec 2023 11:05:32 -0300 Subject: [PATCH 182/874] Move intentional parse error to its own file --- .../Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc | 3 --- .../WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed | 3 --- .../Tests/WhiteSpace/LanguageConstructSpacingUnitTest.2.inc | 4 ++++ 3 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.2.inc diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc index 505cb6e40c..5353321ecc 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc @@ -74,6 +74,3 @@ $newLine; // The following line must have a single space at the end (after return) return $spaceAndNewLine; - -// The following line must be the last line in the file -return diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed index 9934030bbe..9b5ad5816d 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed @@ -68,6 +68,3 @@ return $newLine; // The following line must have a single space at the end (after return) return $spaceAndNewLine; - -// The following line must be the last line in the file -return diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.2.inc b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.2.inc new file mode 100644 index 0000000000..5c9325fcaa --- /dev/null +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.2.inc @@ -0,0 +1,4 @@ + Date: Wed, 20 Dec 2023 11:46:28 -0300 Subject: [PATCH 183/874] Improve test coverage of the LanguageConstructSpacing sniff This sniff has an `else if` condition (https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/c855348766a424d23425eba5cc4420e26e4a3e38/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php#L131) to handle language constructs that are followed by some content without a space or opening parenthesis first. This code was not exercised by the automated tests. This commit adds a few examples to make sure this part of the code is covered. --- .../LanguageConstructSpacingUnitTest.1.inc | 15 +++++++ ...nguageConstructSpacingUnitTest.1.inc.fixed | 15 +++++++ .../LanguageConstructSpacingUnitTest.php | 41 ++++++++++++------- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc index 5353321ecc..1847778d09 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc @@ -2,32 +2,42 @@ echo $blah; echo $blah; echo($blah); +echo$blah; print $blah; print $blah; print($blah); +print$blah; include $blah; include $blah; include($blah); +include$blah; include_once $blah; include_once $blah; include_once($blah); +include_once$blah; require $blah; require $blah; require($blah); +require$blah; require_once $blah; require_once $blah; require_once($blah); +require_once$blah; $obj = new MyClass(); $obj = new MyClass(); +$obj = new $className(); +$obj = new$className(); + yield $blah; yield $blah; +yield$blah; yield from $test(); yield FROM $test(); @@ -39,12 +49,16 @@ yield From $test(); +yield FROM$test(); throw new Exception(); throw new Exception(); throw new Exception(); throw new Exception(); +throw $exception; +throw$exception; + namespace MyClass; namespace MyClass; namespace MyNamespace\MyClass; @@ -66,6 +80,7 @@ return; return $blah; return $blah; return($blah); +return$blah; return $tab; return diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed index 9b5ad5816d..4f5d3cec2f 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.1.inc.fixed @@ -2,30 +2,40 @@ echo $blah; echo $blah; echo($blah); +echo $blah; print $blah; print $blah; print($blah); +print $blah; include $blah; include $blah; include($blah); +include $blah; include_once $blah; include_once $blah; include_once($blah); +include_once $blah; require $blah; require $blah; require($blah); +require $blah; require_once $blah; require_once $blah; require_once($blah); +require_once $blah; $obj = new MyClass(); $obj = new MyClass(); +$obj = new $className(); +$obj = new $className(); + +yield $blah; yield $blah; yield $blah; @@ -35,12 +45,16 @@ YIELD from $test(); yield from $test(); yield from $test(); yield From $test(); +yield FROM $test(); throw new Exception(); throw new Exception(); throw new Exception(); throw new Exception(); +throw $exception; +throw $exception; + namespace MyClass; namespace MyClass; namespace MyNamespace\MyClass; @@ -62,6 +76,7 @@ return; return $blah; return $blah; return($blah); +return $blah; return $tab; return $newLine; diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php index 185da98ef8..0ac7e6d815 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php @@ -36,30 +36,41 @@ public function getErrorList($testFile='') case 'LanguageConstructSpacingUnitTest.1.inc': return [ 3 => 1, - 7 => 1, - 11 => 1, + 5 => 1, + 8 => 1, + 10 => 1, + 13 => 1, 15 => 1, - 19 => 1, + 18 => 1, + 20 => 1, 23 => 1, - 27 => 1, + 25 => 1, + 28 => 1, 30 => 1, 33 => 1, - 34 => 1, - 35 => 1, 36 => 1, - 38 => 1, + 39 => 1, + 40 => 1, + 43 => 1, 44 => 1, 45 => 1, - 46 => 2, - 49 => 1, - 51 => 1, - 59 => 1, - 61 => 1, + 46 => 1, + 48 => 1, + 52 => 1, + 55 => 1, + 56 => 1, + 57 => 2, + 60 => 1, 63 => 1, - 67 => 1, - 70 => 1, - 71 => 1, + 65 => 1, + 73 => 1, 75 => 1, + 77 => 1, + 81 => 1, + 83 => 1, + 85 => 1, + 86 => 1, + 90 => 1, ]; default: From 88ff4f1df16c6834f361d42d6663370264571b31 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 21 Dec 2023 20:50:12 -0300 Subject: [PATCH 184/874] Generic/OpeningBraceSameLine: improve code coverage This commit improves the test code coverage for the Generic.Classes.OpeningBraceSameLine sniff. There was one line that was not exercised by tests that handle cases where the opening and closing brace for the class are on the same line as the class name. --- .../Classes/OpeningBraceSameLineUnitTest.inc | 5 ++++ .../OpeningBraceSameLineUnitTest.inc.fixed | 5 ++++ .../Classes/OpeningBraceSameLineUnitTest.php | 25 ++++++++++--------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.inc b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.inc index fd3abc030e..ce9a69f8d9 100644 --- a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.inc +++ b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.inc @@ -93,3 +93,8 @@ class Test_Class_Bad_G enum Test_Enum { } + +class Test_Class_Good_D {} + +class Test_Class_Bad_H +{} diff --git a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.inc.fixed b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.inc.fixed index a755ae4725..0d5f6b63f3 100644 --- a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.inc.fixed @@ -93,3 +93,8 @@ class Test_Class_Bad_G enum Test_Enum { } + +class Test_Class_Good_D {} + +class Test_Class_Bad_H { +} diff --git a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php index c72d133751..a2df57736f 100644 --- a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php +++ b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php @@ -32,18 +32,19 @@ public function getErrorList() { return [ - 19 => 2, - 23 => 1, - 28 => 2, - 34 => 1, - 38 => 1, - 41 => 1, - 44 => 1, - 47 => 1, - 70 => 1, - 79 => 1, - 90 => 1, - 94 => 1, + 19 => 2, + 23 => 1, + 28 => 2, + 34 => 1, + 38 => 1, + 41 => 1, + 44 => 1, + 47 => 1, + 70 => 1, + 79 => 1, + 90 => 1, + 94 => 1, + 100 => 1, ]; }//end getErrorList() From 3b2f88fc5de630760f6c0db926dd797ebf8caa77 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 22 Dec 2023 11:38:04 -0300 Subject: [PATCH 185/874] Generic/NoSilencedErrors: improve test coverage This commit adds two new tests to cover lines of the Generic.PHP.NoSiliencedErrors that were not covered previously. One has to do with a sniff property that allows users to set this sniff as an error instead of a warning (default value) and the other with calculating $contextLength when its value should be smaller than the default value of 4. --- .../Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc | 6 ++++++ .../Generic/Tests/PHP/NoSilencedErrorsUnitTest.php | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc index 72bffe2c4c..98159b4725 100644 --- a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc +++ b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.inc @@ -8,3 +8,9 @@ if (@in_array($array, $needle)) } $hasValue = @in_array(haystack: $array, needle: $needle); + +// phpcs:set Generic.PHP.NoSilencedErrors error true +$fileContent = @file_get_contents('non_existent_file.txt'); +// phpcs:set Generic.PHP.NoSilencedErrors error false + +echo @$undefinedVariable; diff --git a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php index dc7e754d51..43f762812b 100644 --- a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php @@ -30,7 +30,7 @@ class NoSilencedErrorsUnitTest extends AbstractSniffUnitTest */ public function getErrorList() { - return []; + return [13 => 1]; }//end getErrorList() @@ -48,6 +48,7 @@ public function getWarningList() return [ 5 => 1, 10 => 1, + 16 => 1, ]; }//end getWarningList() From 84acf4e56f110db8e75cb9a575c5727df637643c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 26 Dec 2023 01:29:52 +0100 Subject: [PATCH 186/874] Docs: improve type declarations This commit addresses the `@return` tag for all sniff `register()` methods. Future commits may follow for other parts of the codebase. PHP native tokens will always be integers. PHP_CodeSniffer polyfilled and PHP_CodeSniffer native tokens will always be strings. While some sniffs only return one or the other, I've chosen to update these tags to be the same across all sniffs for consistency. --- src/Sniffs/AbstractArraySniff.php | 2 +- src/Sniffs/AbstractPatternSniff.php | 2 +- src/Sniffs/AbstractScopeSniff.php | 2 +- src/Sniffs/Sniff.php | 10 +++++----- .../Sniffs/Arrays/DisallowLongArraySyntaxSniff.php | 2 +- .../Generic/Sniffs/Classes/DuplicateClassNameSniff.php | 2 +- .../Sniffs/Classes/OpeningBraceSameLineSniff.php | 2 +- .../Sniffs/CodeAnalysis/AssignmentInConditionSniff.php | 2 +- .../Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php | 2 +- .../Sniffs/CodeAnalysis/EmptyStatementSniff.php | 2 +- .../CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php | 2 +- .../CodeAnalysis/ForLoopWithTestFunctionCallSniff.php | 2 +- .../Sniffs/CodeAnalysis/JumbledIncrementerSniff.php | 2 +- .../CodeAnalysis/UnconditionalIfStatementSniff.php | 2 +- .../CodeAnalysis/UnnecessaryFinalModifierSniff.php | 2 +- .../CodeAnalysis/UnusedFunctionParameterSniff.php | 2 +- .../CodeAnalysis/UselessOverridingMethodSniff.php | 2 +- .../Generic/Sniffs/Commenting/DocCommentSniff.php | 2 +- src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php | 2 +- src/Standards/Generic/Sniffs/Commenting/TodoSniff.php | 2 +- .../ControlStructures/DisallowYodaConditionsSniff.php | 2 +- .../ControlStructures/InlineControlStructureSniff.php | 2 +- src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php | 2 +- .../Generic/Sniffs/Debug/ClosureLinterSniff.php | 2 +- src/Standards/Generic/Sniffs/Debug/ESLintSniff.php | 2 +- src/Standards/Generic/Sniffs/Debug/JSHintSniff.php | 2 +- .../Generic/Sniffs/Files/ByteOrderMarkSniff.php | 2 +- .../Generic/Sniffs/Files/EndFileNewlineSniff.php | 2 +- .../Generic/Sniffs/Files/EndFileNoNewlineSniff.php | 2 +- .../Generic/Sniffs/Files/ExecutableFileSniff.php | 2 +- src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php | 2 +- .../Generic/Sniffs/Files/LineEndingsSniff.php | 2 +- src/Standards/Generic/Sniffs/Files/LineLengthSniff.php | 2 +- .../Generic/Sniffs/Files/LowercasedFilenameSniff.php | 2 +- .../Generic/Sniffs/Files/OneClassPerFileSniff.php | 2 +- .../Generic/Sniffs/Files/OneInterfacePerFileSniff.php | 2 +- .../Sniffs/Files/OneObjectStructurePerFileSniff.php | 2 +- .../Generic/Sniffs/Files/OneTraitPerFileSniff.php | 2 +- .../Formatting/DisallowMultipleStatementsSniff.php | 2 +- .../Formatting/MultipleStatementAlignmentSniff.php | 2 +- .../Sniffs/Formatting/NoSpaceAfterCastSniff.php | 2 +- .../Generic/Sniffs/Formatting/SpaceAfterCastSniff.php | 2 +- .../Generic/Sniffs/Formatting/SpaceAfterNotSniff.php | 2 +- .../Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php | 2 +- .../Sniffs/Functions/CallTimePassByReferenceSniff.php | 2 +- .../Functions/FunctionCallArgumentSpacingSniff.php | 2 +- .../Functions/OpeningFunctionBraceBsdAllmanSniff.php | 2 +- .../Sniffs/Metrics/CyclomaticComplexitySniff.php | 2 +- .../Generic/Sniffs/Metrics/NestingLevelSniff.php | 2 +- .../NamingConventions/AbstractClassNamePrefixSniff.php | 2 +- .../NamingConventions/InterfaceNameSuffixSniff.php | 2 +- .../Sniffs/NamingConventions/TraitNameSuffixSniff.php | 2 +- .../NamingConventions/UpperCaseConstantNameSniff.php | 2 +- .../Generic/Sniffs/PHP/BacktickOperatorSniff.php | 2 +- .../Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php | 2 +- .../Generic/Sniffs/PHP/ClosingPHPTagSniff.php | 2 +- .../Sniffs/PHP/DisallowAlternativePHPTagsSniff.php | 2 +- .../Sniffs/PHP/DisallowRequestSuperglobalSniff.php | 2 +- .../Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php | 2 +- .../Generic/Sniffs/PHP/DiscourageGotoSniff.php | 2 +- .../Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php | 2 +- .../Generic/Sniffs/PHP/LowerCaseConstantSniff.php | 2 +- .../Generic/Sniffs/PHP/LowerCaseKeywordSniff.php | 2 +- .../Generic/Sniffs/PHP/LowerCaseTypeSniff.php | 2 +- .../Generic/Sniffs/PHP/NoSilencedErrorsSniff.php | 2 +- .../Generic/Sniffs/PHP/RequireStrictTypesSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php | 2 +- .../Sniffs/Strings/UnnecessaryStringConcatSniff.php | 2 +- .../Sniffs/VersionControl/GitMergeConflictSniff.php | 2 +- .../VersionControl/SubversionPropertiesSniff.php | 2 +- .../WhiteSpace/ArbitraryParenthesesSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php | 2 +- .../Sniffs/WhiteSpace/DisallowTabIndentSniff.php | 2 +- .../WhiteSpace/IncrementDecrementSpacingSniff.php | 2 +- .../WhiteSpace/LanguageConstructSpacingSniff.php | 2 +- .../Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php | 2 +- .../WhiteSpace/SpreadOperatorSpacingAfterSniff.php | 2 +- .../Sniffs/Channels/DisallowSelfActionsSniff.php | 2 +- .../MySource/Sniffs/Channels/IncludeOwnSystemSniff.php | 2 +- .../MySource/Sniffs/Channels/UnusedSystemSniff.php | 2 +- src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php | 2 +- .../MySource/Sniffs/Debug/FirebugConsoleSniff.php | 2 +- .../MySource/Sniffs/Objects/AssignThisSniff.php | 2 +- .../Sniffs/Objects/CreateWidgetTypeCallbackSniff.php | 2 +- .../MySource/Sniffs/Objects/DisallowNewWidgetSniff.php | 2 +- .../MySource/Sniffs/PHP/AjaxNullComparisonSniff.php | 2 +- .../MySource/Sniffs/PHP/EvalObjectFactorySniff.php | 2 +- .../MySource/Sniffs/PHP/GetRequestDataSniff.php | 2 +- .../MySource/Sniffs/PHP/ReturnFunctionValueSniff.php | 2 +- .../MySource/Sniffs/Strings/JoinStringsSniff.php | 2 +- .../PEAR/Sniffs/Classes/ClassDeclarationSniff.php | 2 +- .../PEAR/Sniffs/Commenting/ClassCommentSniff.php | 2 +- .../PEAR/Sniffs/Commenting/FileCommentSniff.php | 2 +- .../PEAR/Sniffs/Commenting/FunctionCommentSniff.php | 2 +- .../PEAR/Sniffs/Commenting/InlineCommentSniff.php | 2 +- .../ControlStructures/MultiLineConditionSniff.php | 2 +- src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php | 2 +- .../Sniffs/Formatting/MultiLineAssignmentSniff.php | 2 +- .../Sniffs/Functions/FunctionCallSignatureSniff.php | 2 +- .../PEAR/Sniffs/Functions/FunctionDeclarationSniff.php | 2 +- .../PEAR/Sniffs/Functions/ValidDefaultValueSniff.php | 2 +- .../Sniffs/NamingConventions/ValidClassNameSniff.php | 2 +- .../Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php | 2 +- .../PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php | 10 +++++----- .../PSR1/Sniffs/Classes/ClassDeclarationSniff.php | 2 +- src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php | 2 +- .../PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php | 2 +- .../PSR12/Sniffs/Classes/ClassInstantiationSniff.php | 2 +- .../PSR12/Sniffs/Classes/ClosingBraceSniff.php | 2 +- .../PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php | 2 +- .../BooleanOperatorPlacementSniff.php | 2 +- .../ControlStructures/ControlStructureSpacingSniff.php | 2 +- .../PSR12/Sniffs/Files/DeclareStatementSniff.php | 2 +- src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php | 2 +- .../PSR12/Sniffs/Files/ImportStatementSniff.php | 2 +- src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php | 2 +- .../Sniffs/Functions/NullableTypeDeclarationSniff.php | 2 +- .../Sniffs/Functions/ReturnTypeDeclarationSniff.php | 2 +- .../Sniffs/Keywords/ShortFormTypeKeywordsSniff.php | 2 +- .../Sniffs/Namespaces/CompoundNamespaceDepthSniff.php | 2 +- .../PSR12/Sniffs/Operators/OperatorSpacingSniff.php | 2 +- .../Sniffs/Properties/ConstantVisibilitySniff.php | 2 +- .../PSR12/Sniffs/Traits/UseDeclarationSniff.php | 2 +- .../ControlStructures/ControlStructureSpacingSniff.php | 2 +- .../ControlStructures/ElseIfDeclarationSniff.php | 2 +- .../ControlStructures/SwitchDeclarationSniff.php | 2 +- src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php | 2 +- .../PSR2/Sniffs/Files/EndFileNewlineSniff.php | 2 +- .../PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php | 2 +- .../Sniffs/Namespaces/NamespaceDeclarationSniff.php | 2 +- .../PSR2/Sniffs/Namespaces/UseDeclarationSniff.php | 2 +- .../Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php | 2 +- .../Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php | 2 +- .../Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php | 2 +- .../Squiz/Sniffs/CSS/ForbiddenStylesSniff.php | 2 +- src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php | 2 +- src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php | 2 +- .../Squiz/Sniffs/Classes/ClassFileNameSniff.php | 2 +- .../Squiz/Sniffs/Classes/DuplicatePropertySniff.php | 2 +- .../Sniffs/Classes/LowercaseClassKeywordsSniff.php | 2 +- .../Squiz/Sniffs/Classes/ValidClassNameSniff.php | 2 +- .../Squiz/Sniffs/Commenting/BlockCommentSniff.php | 2 +- .../Squiz/Sniffs/Commenting/ClassCommentSniff.php | 2 +- .../Commenting/ClosingDeclarationCommentSniff.php | 2 +- .../Sniffs/Commenting/DocCommentAlignmentSniff.php | 2 +- .../Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php | 2 +- .../Squiz/Sniffs/Commenting/FileCommentSniff.php | 2 +- .../Sniffs/Commenting/FunctionCommentThrowTagSniff.php | 2 +- .../Squiz/Sniffs/Commenting/InlineCommentSniff.php | 2 +- .../Commenting/LongConditionClosingCommentSniff.php | 2 +- .../Sniffs/Commenting/PostStatementCommentSniff.php | 2 +- .../Sniffs/ControlStructures/ControlSignatureSniff.php | 2 +- .../ControlStructures/ElseIfDeclarationSniff.php | 2 +- .../ControlStructures/ForEachLoopDeclarationSniff.php | 2 +- .../ControlStructures/ForLoopDeclarationSniff.php | 2 +- .../ControlStructures/InlineIfDeclarationSniff.php | 2 +- .../ControlStructures/LowercaseDeclarationSniff.php | 2 +- .../ControlStructures/SwitchDeclarationSniff.php | 2 +- src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php | 2 +- .../Squiz/Sniffs/Debug/JavaScriptLintSniff.php | 2 +- .../Squiz/Sniffs/Files/FileExtensionSniff.php | 2 +- .../Squiz/Sniffs/Formatting/OperatorBracketSniff.php | 2 +- .../FunctionDeclarationArgumentSpacingSniff.php | 2 +- .../Functions/FunctionDuplicateArgumentSniff.php | 2 +- .../Squiz/Sniffs/Functions/GlobalFunctionSniff.php | 2 +- .../Functions/LowercaseFunctionKeywordsSniff.php | 2 +- .../Sniffs/Objects/DisallowObjectStringIndexSniff.php | 2 +- .../Squiz/Sniffs/Objects/ObjectInstantiationSniff.php | 2 +- .../Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php | 2 +- .../Sniffs/Operators/ComparisonOperatorUsageSniff.php | 2 +- .../Sniffs/Operators/IncrementDecrementUsageSniff.php | 2 +- .../Sniffs/Operators/ValidLogicalOperatorsSniff.php | 2 +- .../Squiz/Sniffs/PHP/CommentedOutCodeSniff.php | 2 +- .../Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php | 2 +- .../Sniffs/PHP/DisallowComparisonAssignmentSniff.php | 2 +- .../Squiz/Sniffs/PHP/DisallowInlineIfSniff.php | 2 +- .../Sniffs/PHP/DisallowMultipleAssignmentsSniff.php | 2 +- .../Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/EvalSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php | 2 +- .../Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php | 2 +- .../Squiz/Sniffs/PHP/NonExecutableCodeSniff.php | 2 +- .../Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php | 2 +- .../Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php | 2 +- .../Squiz/Sniffs/Strings/EchoedStringsSniff.php | 2 +- .../Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/ControlStructureSpacingSniff.php | 2 +- .../WhiteSpace/FunctionClosingBraceSpaceSniff.php | 2 +- .../WhiteSpace/FunctionOpeningBraceSpaceSniff.php | 2 +- .../Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php | 2 +- .../WhiteSpace/LanguageConstructSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php | 2 +- .../Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php | 2 +- .../Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php | 2 +- .../Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php | 2 +- .../Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php | 2 +- src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php | 2 +- src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php | 2 +- 205 files changed, 213 insertions(+), 213 deletions(-) diff --git a/src/Sniffs/AbstractArraySniff.php b/src/Sniffs/AbstractArraySniff.php index 45e1091883..95a0a09088 100644 --- a/src/Sniffs/AbstractArraySniff.php +++ b/src/Sniffs/AbstractArraySniff.php @@ -19,7 +19,7 @@ abstract class AbstractArraySniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ final public function register() { diff --git a/src/Sniffs/AbstractPatternSniff.php b/src/Sniffs/AbstractPatternSniff.php index d4135be057..86dc10d408 100644 --- a/src/Sniffs/AbstractPatternSniff.php +++ b/src/Sniffs/AbstractPatternSniff.php @@ -78,7 +78,7 @@ public function __construct($ignoreComments=null) * Classes extending AbstractPatternTest should implement the * getPatterns() method to register the patterns they wish to test. * - * @return int[] + * @return array * @see process() */ final public function register() diff --git a/src/Sniffs/AbstractScopeSniff.php b/src/Sniffs/AbstractScopeSniff.php index ce38ba0c4b..74201ab8eb 100644 --- a/src/Sniffs/AbstractScopeSniff.php +++ b/src/Sniffs/AbstractScopeSniff.php @@ -104,7 +104,7 @@ public function __construct( * DO NOT OVERRIDE THIS METHOD. Use the constructor of this class to register * for the desired tokens and scope. * - * @return int[] + * @return array * @see __constructor() */ final public function register() diff --git a/src/Sniffs/Sniff.php b/src/Sniffs/Sniff.php index 92acbc4a05..3556edd532 100644 --- a/src/Sniffs/Sniff.php +++ b/src/Sniffs/Sniff.php @@ -28,13 +28,13 @@ interface Sniff * * * return array( - * T_WHITESPACE, - * T_DOC_COMMENT, - * T_COMMENT, - * ); + * T_WHITESPACE, + * T_DOC_COMMENT, + * T_COMMENT, + * ); * * - * @return mixed[] + * @return array * @see Tokens.php */ public function register(); diff --git a/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php b/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php index 5c83895294..58d26325c0 100644 --- a/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php @@ -19,7 +19,7 @@ class DisallowLongArraySyntaxSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php index c14e7ecad3..19ff1edf64 100644 --- a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php +++ b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php @@ -26,7 +26,7 @@ class DuplicateClassNameSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php index a00443b3fa..40291ea47d 100644 --- a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php +++ b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php @@ -19,7 +19,7 @@ class OpeningBraceSameLineSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php index cfde25f59d..fecd16a754 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php @@ -40,7 +40,7 @@ class AssignmentInConditionSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php index 450df7a270..3ebfccc04d 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php @@ -23,7 +23,7 @@ class EmptyPHPStatementSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php index 2e5b7da33b..ded042a9a1 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php @@ -34,7 +34,7 @@ class EmptyStatementSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php index 5835f6ce5d..286ce62704 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php @@ -33,7 +33,7 @@ class ForLoopShouldBeWhileLoopSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php index bbe02a3404..45b4f7306f 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php @@ -37,7 +37,7 @@ class ForLoopWithTestFunctionCallSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php index dad82740a9..63e925fe71 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php @@ -39,7 +39,7 @@ class JumbledIncrementerSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php index ccf902fd0e..db71a9676b 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php @@ -37,7 +37,7 @@ class UnconditionalIfStatementSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php index d66abc2729..2f4faa891c 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php @@ -32,7 +32,7 @@ class UnnecessaryFinalModifierSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php index 70247c263d..66fe781ac7 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php @@ -60,7 +60,7 @@ class UnusedFunctionParameterSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php index ba3553e1f6..1b79fd3393 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php @@ -32,7 +32,7 @@ class UselessOverridingMethodSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php index 62c08cea10..f34ffc2b9c 100644 --- a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php @@ -30,7 +30,7 @@ class DocCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php b/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php index 240c60edb6..b78a6595ee 100644 --- a/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php @@ -31,7 +31,7 @@ class FixmeSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php b/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php index 9b5b34ab6f..d24111cbd3 100644 --- a/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php @@ -30,7 +30,7 @@ class TodoSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php index 7a705747dc..d82931cb6c 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php @@ -21,7 +21,7 @@ class DisallowYodaConditionsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php index 0d2ede5bf7..8a4884d3ce 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -37,7 +37,7 @@ class InlineControlStructureSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php index 4fe8bd7cb1..24028e5cfc 100644 --- a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php @@ -28,7 +28,7 @@ class CSSLintSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php index 6bcc0a7518..8b4798388b 100644 --- a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php @@ -44,7 +44,7 @@ class ClosureLinterSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php index 8145dc70a1..004054dee8 100644 --- a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php @@ -35,7 +35,7 @@ class ESLintSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php index a8f6e2d279..1461d57417 100644 --- a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php @@ -29,7 +29,7 @@ class JSHintSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php b/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php index 23249156bb..d014908320 100644 --- a/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php +++ b/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php @@ -33,7 +33,7 @@ class ByteOrderMarkSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php b/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php index ffca4227a3..a920bdf8a2 100644 --- a/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php +++ b/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php @@ -30,7 +30,7 @@ class EndFileNewlineSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php b/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php index 2e82176b0f..afff5587bc 100644 --- a/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php +++ b/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php @@ -30,7 +30,7 @@ class EndFileNoNewlineSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php b/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php index 7db30618eb..cb199aa691 100644 --- a/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php @@ -19,7 +19,7 @@ class ExecutableFileSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php b/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php index af546434fa..1d79a0ea76 100644 --- a/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php +++ b/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php @@ -32,7 +32,7 @@ class InlineHTMLSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php index 1d17ada436..e44d5147a2 100644 --- a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php @@ -37,7 +37,7 @@ class LineEndingsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php index 56fbe858b2..94d4144a14 100644 --- a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php @@ -50,7 +50,7 @@ class LineLengthSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php b/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php index 90af44f6e6..608fdcf6b0 100644 --- a/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php @@ -19,7 +19,7 @@ class LowercasedFilenameSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php index 9eea7278df..e328e74436 100644 --- a/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php @@ -19,7 +19,7 @@ class OneClassPerFileSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php index 71b6894a38..34211f2f3c 100644 --- a/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php @@ -19,7 +19,7 @@ class OneInterfacePerFileSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php index d94a32db17..459c5d1aae 100644 --- a/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php @@ -19,7 +19,7 @@ class OneObjectStructurePerFileSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php index 0be3734148..309383fcdc 100644 --- a/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php @@ -19,7 +19,7 @@ class OneTraitPerFileSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php b/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php index 5466938d1c..750fdabc58 100644 --- a/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php @@ -19,7 +19,7 @@ class DisallowMultipleStatementsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php index 68ddf53ff7..8916659a9a 100644 --- a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php @@ -58,7 +58,7 @@ class MultipleStatementAlignmentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php b/src/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php index e7d294de6f..f7644df031 100644 --- a/src/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php @@ -23,7 +23,7 @@ class NoSpaceAfterCastSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php index 0ab8d3d52c..d831ea7d03 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php @@ -34,7 +34,7 @@ class SpaceAfterCastSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php index 99e267d61d..a1a6d09367 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php @@ -44,7 +44,7 @@ class SpaceAfterNotSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php index e4d9338401..96082e3fe4 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php @@ -20,7 +20,7 @@ class SpaceBeforeCastSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php b/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php index 33f0c34e65..d97c0f79bf 100644 --- a/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php @@ -20,7 +20,7 @@ class CallTimePassByReferenceSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php index 2b33eeac58..1ae4822569 100644 --- a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php @@ -20,7 +20,7 @@ class FunctionCallArgumentSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php index d60ab61e7b..be96f58580 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php @@ -34,7 +34,7 @@ class OpeningFunctionBraceBsdAllmanSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php index f68666f946..8cba81daf2 100644 --- a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php @@ -38,7 +38,7 @@ class CyclomaticComplexitySniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php index 35b5b29a5f..3c086c7fe4 100644 --- a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php @@ -34,7 +34,7 @@ class NestingLevelSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php index 8f3e5570e6..145dddf746 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php @@ -18,7 +18,7 @@ class AbstractClassNamePrefixSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php index 2e69aea532..637e036f1f 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php @@ -18,7 +18,7 @@ class InterfaceNameSuffixSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php index 81a96b7932..cbd9651ddf 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php @@ -18,7 +18,7 @@ class TraitNameSuffixSniff implements Sniff /** * Registers the tokens that this sniff wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index 4f4ae40e17..1373d3b0e3 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -20,7 +20,7 @@ class UpperCaseConstantNameSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php b/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php index ce9bee3101..f3c56b5888 100644 --- a/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php @@ -19,7 +19,7 @@ class BacktickOperatorSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php b/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php index af9cb9b29f..66f73860ed 100644 --- a/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php @@ -32,7 +32,7 @@ class CharacterBeforePHPOpeningTagSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php b/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php index b8ed0a0aaf..23dd2b6b20 100644 --- a/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php @@ -19,7 +19,7 @@ class ClosingPHPTagSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php index e3e852ddd8..a2cf1b931c 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php @@ -36,7 +36,7 @@ class DisallowAlternativePHPTagsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php index 913e16f9b8..acab6e3f97 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php @@ -19,7 +19,7 @@ class DisallowRequestSuperglobalSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php index b7dc75ce6b..7d68ac9e5a 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php @@ -20,7 +20,7 @@ class DisallowShortOpenTagSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php b/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php index 1a552ee722..063489a724 100644 --- a/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php @@ -19,7 +19,7 @@ class DiscourageGotoSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php b/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php index 9b21db15db..6f5abf8deb 100644 --- a/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php @@ -56,7 +56,7 @@ class ForbiddenFunctionsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php index f2e3629df0..cae35eeb41 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php @@ -64,7 +64,7 @@ class LowerCaseConstantSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php index 542fea5d8b..1a36917171 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php @@ -21,7 +21,7 @@ class LowerCaseKeywordSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php index f309960d12..a835d7ed85 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php @@ -46,7 +46,7 @@ class LowerCaseTypeSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php b/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php index a3db4a167b..87bf11c418 100644 --- a/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php @@ -33,7 +33,7 @@ class NoSilencedErrorsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php index 1e0dc9de59..8e6ef33ed5 100644 --- a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php @@ -20,7 +20,7 @@ class RequireStrictTypesSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php b/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php index 05bac4528a..54b6e69ee4 100644 --- a/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php @@ -19,7 +19,7 @@ class SAPIUsageSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php b/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php index ffc1ff6daf..0005112739 100644 --- a/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php @@ -29,7 +29,7 @@ class SyntaxSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php index 2d2286c9df..ffaa1db121 100644 --- a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php +++ b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php @@ -47,7 +47,7 @@ class UnnecessaryStringConcatSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php index 03028cb7b1..4a573b0687 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php @@ -30,7 +30,7 @@ class GitMergeConflictSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php index a15585830f..446ee98197 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php @@ -34,7 +34,7 @@ class SubversionPropertiesSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php index 4d223ee186..7b4368d6c4 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php @@ -45,7 +45,7 @@ class ArbitraryParenthesesSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php index b2290cd124..e812500e51 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php @@ -37,7 +37,7 @@ class DisallowSpaceIndentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php index 471bb3d014..51a859e84d 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php @@ -37,7 +37,7 @@ class DisallowTabIndentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php index 95ba3d82c2..60ea79ec53 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php @@ -30,7 +30,7 @@ class IncrementDecrementSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php index c577c9dc6f..462027d3d2 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php @@ -21,7 +21,7 @@ class LanguageConstructSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index 2453abdcd8..151cb7d5c1 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -102,7 +102,7 @@ class ScopeIndentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php index 44a05036d6..17708686ab 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php @@ -34,7 +34,7 @@ class SpreadOperatorSpacingAfterSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php b/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php index d8458cadd3..241104d098 100644 --- a/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php @@ -20,7 +20,7 @@ class DisallowSelfActionsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php index 7ae09f8710..2ff91c974f 100644 --- a/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php @@ -19,7 +19,7 @@ class IncludeOwnSystemSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php index 9d6ca03800..7f96051097 100644 --- a/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php @@ -19,7 +19,7 @@ class UnusedSystemSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php b/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php index e43a10db7f..1ae6ba30e1 100644 --- a/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php +++ b/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php @@ -19,7 +19,7 @@ class DebugCodeSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php b/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php index 5e342d3387..77b86669ac 100644 --- a/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php +++ b/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php @@ -26,7 +26,7 @@ class FirebugConsoleSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php b/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php index 7cfe208cb9..a126dce363 100644 --- a/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php @@ -26,7 +26,7 @@ class AssignThisSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php b/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php index 7111e2294d..25e48dc7bd 100644 --- a/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php @@ -27,7 +27,7 @@ class CreateWidgetTypeCallbackSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php b/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php index c53165ffca..ecb57e5320 100644 --- a/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php @@ -19,7 +19,7 @@ class DisallowNewWidgetSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php b/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php index 2037ec14b5..71c31da3be 100644 --- a/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php @@ -22,7 +22,7 @@ class AjaxNullComparisonSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php b/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php index 64492c84e0..3b775aff7d 100644 --- a/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php +++ b/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php @@ -20,7 +20,7 @@ class EvalObjectFactorySniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php b/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php index ff840bf242..bdb3452775 100644 --- a/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php @@ -19,7 +19,7 @@ class GetRequestDataSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php b/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php index 5d11550d50..1696837e26 100644 --- a/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php @@ -19,7 +19,7 @@ class ReturnFunctionValueSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php b/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php index e94eba5e06..968873e7b8 100644 --- a/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php +++ b/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php @@ -27,7 +27,7 @@ class JoinStringsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php index ae9baad41e..893dc9a8df 100644 --- a/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php @@ -19,7 +19,7 @@ class ClassDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php index 0934f11ba0..8fa6bfba79 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php @@ -18,7 +18,7 @@ class ClassCommentSniff extends FileCommentSniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php index 2af57b18d5..1c12e3013f 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php @@ -72,7 +72,7 @@ class FileCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php index ffa5cb8e8b..48ff5f254e 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php @@ -39,7 +39,7 @@ class FunctionCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php index 313f74d25c..71c11808dd 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php @@ -19,7 +19,7 @@ class InlineCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php index f407373566..08752edaa6 100644 --- a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php +++ b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php @@ -37,7 +37,7 @@ class MultiLineConditionSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php index 763b50c432..e0ed0fb1b0 100644 --- a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php +++ b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php @@ -22,7 +22,7 @@ class IncludingFileSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php b/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php index f7b75cb0b8..0f18710df4 100644 --- a/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php +++ b/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php @@ -26,7 +26,7 @@ class MultiLineAssignmentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php index 30e0f67aea..772ab6b8c0 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php @@ -58,7 +58,7 @@ class FunctionCallSignatureSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index 4cc24a2d19..548565f160 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -39,7 +39,7 @@ class FunctionDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php b/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php index 1e38cc092c..9952daa44d 100644 --- a/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php @@ -19,7 +19,7 @@ class ValidDefaultValueSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php index e50fd1f57e..c2ed80ac6e 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php @@ -19,7 +19,7 @@ class ValidClassNameSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php index d333a5530d..9c64c328af 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php @@ -43,7 +43,7 @@ class ObjectOperatorIndentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index 2b51a8a65b..dd395324f3 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -24,11 +24,11 @@ class ScopeClosingBraceSniff implements Sniff public $indent = 4; - /** - * Returns an array of tokens this test wants to listen for. - * - * @return int[] - */ + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ public function register() { return Tokens::$scopeOpeners; diff --git a/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php index 19161d77f3..e3f626b3ce 100644 --- a/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php @@ -19,7 +19,7 @@ class ClassDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php index e92ffb551d..5f22b1f9c5 100644 --- a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php +++ b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php @@ -20,7 +20,7 @@ class SideEffectsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php index fd8e81a3fc..d4792f5e30 100644 --- a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php @@ -36,7 +36,7 @@ class AnonClassDeclarationSniff extends ClassDeclarationSniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php b/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php index 40e928bdc6..2130b8ddbc 100644 --- a/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php @@ -20,7 +20,7 @@ class ClassInstantiationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php b/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php index 6571af5b19..82f215f6ef 100644 --- a/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php @@ -19,7 +19,7 @@ class ClosingBraceSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php b/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php index d2a2c5bd8c..261f7022dc 100644 --- a/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php @@ -20,7 +20,7 @@ class OpeningBraceSpaceSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php b/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php index e86ff4f289..dabb3187b1 100644 --- a/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php +++ b/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php @@ -28,7 +28,7 @@ class BooleanOperatorPlacementSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index 499f3a29d1..2ddb66340b 100644 --- a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -28,7 +28,7 @@ class ControlStructureSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php index 95357a7842..b59d6c5cdb 100644 --- a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php @@ -20,7 +20,7 @@ class DeclareStatementSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php index 99c9de2bf9..f06357d432 100644 --- a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php @@ -20,7 +20,7 @@ class FileHeaderSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php b/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php index 627b32936a..65198e8610 100644 --- a/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php @@ -20,7 +20,7 @@ class ImportStatementSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php b/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php index 6c80d812fa..d0ac5d363d 100644 --- a/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php @@ -19,7 +19,7 @@ class OpenTagSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php index ac0775d13e..4314194d4c 100644 --- a/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php @@ -36,7 +36,7 @@ class NullableTypeDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php index 61c45f5e2e..cf1afc560d 100644 --- a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php @@ -19,7 +19,7 @@ class ReturnTypeDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php b/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php index e79fe38b21..65d39eb915 100644 --- a/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php +++ b/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php @@ -19,7 +19,7 @@ class ShortFormTypeKeywordsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php b/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php index f87ced057b..34e7f461a3 100644 --- a/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php +++ b/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php @@ -26,7 +26,7 @@ class CompoundNamespaceDepthSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php b/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php index c3b48f473d..0e58f18c13 100644 --- a/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php +++ b/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php @@ -20,7 +20,7 @@ class OperatorSpacingSniff extends SquizOperatorSpacingSniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php b/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php index 5d6882585b..8bcf0d5689 100644 --- a/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php +++ b/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php @@ -20,7 +20,7 @@ class ConstantVisibilitySniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php index f9fb808a9b..70e99d7645 100644 --- a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php @@ -20,7 +20,7 @@ class UseDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index 4a32091cdf..d855dbd63c 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -34,7 +34,7 @@ class ControlStructureSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php index fa89cfee22..7f5e97c188 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php @@ -19,7 +19,7 @@ class ElseIfDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php index a63ba88198..4b3b5ad2b8 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -27,7 +27,7 @@ class SwitchDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php index ef1dc052f4..1cb637447d 100644 --- a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php @@ -20,7 +20,7 @@ class ClosingTagSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php b/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php index 98693f8615..d5e3e069e1 100644 --- a/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php @@ -19,7 +19,7 @@ class EndFileNewlineSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php b/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php index 4f1716b187..c4f1a6f4fc 100644 --- a/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php +++ b/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php @@ -19,7 +19,7 @@ class FunctionClosingBraceSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php index 2f6bb64fdd..7b1dad199f 100644 --- a/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php @@ -20,7 +20,7 @@ class NamespaceDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php index ba71c30900..1882fd970a 100644 --- a/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php @@ -20,7 +20,7 @@ class UseDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php index 22dda0edb1..b6bb31de6b 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php @@ -19,7 +19,7 @@ class ArrayBracketSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php index f9e4ec035a..9cd419822d 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -20,7 +20,7 @@ class ArrayDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php index 9f51b524b1..b1c81bd613 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php @@ -27,7 +27,7 @@ class DuplicateClassDefinitionSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php b/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php index 183afdbf21..b6955961f7 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php @@ -66,7 +66,7 @@ class ForbiddenStylesSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php b/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php index a0f0a9bdba..427468ce19 100644 --- a/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php @@ -34,7 +34,7 @@ class IndentationSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php b/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php index 4d599e1be5..9322ef89ec 100644 --- a/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php @@ -53,7 +53,7 @@ class NamedColoursSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php b/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php index 681b5e19e9..fc3ec0473b 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php @@ -19,7 +19,7 @@ class ClassFileNameSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php b/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php index 1638d1f163..0493b774eb 100644 --- a/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php @@ -26,7 +26,7 @@ class DuplicatePropertySniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php b/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php index 1842eea1b2..b9d71db00f 100644 --- a/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php @@ -20,7 +20,7 @@ class LowercaseClassKeywordsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php b/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php index 0f019d35b6..a8975353fd 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php @@ -20,7 +20,7 @@ class ValidClassNameSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php index 81d8580538..9a565123b7 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php @@ -27,7 +27,7 @@ class BlockCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php index 4c4d3badea..60d553fc2e 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php @@ -27,7 +27,7 @@ class ClassCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php index dc4921bcde..45bcdbdef6 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php @@ -19,7 +19,7 @@ class ClosingDeclarationCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php index 7259e533ec..453ff89c16 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php @@ -30,7 +30,7 @@ class DocCommentAlignmentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php index 2ec8add0d4..301537fe72 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php @@ -19,7 +19,7 @@ class EmptyCatchCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php index ec31e4f6d7..d9241f1b66 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php @@ -29,7 +29,7 @@ class FileCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php index 33c558cfe0..4fb332cf48 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php @@ -20,7 +20,7 @@ class FunctionCommentThrowTagSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php index babe2edc0d..3c1ead70a9 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php @@ -30,7 +30,7 @@ class InlineCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php index 33bd8e6cc0..439fc38a81 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php @@ -62,7 +62,7 @@ class LongConditionClosingCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php index 28cb7430d1..9b36abe76f 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php @@ -47,7 +47,7 @@ class PostStatementCommentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php index bb5392364a..06fd3edccc 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -37,7 +37,7 @@ class ControlSignatureSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php index 580f053cbc..3cdb901d5e 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php @@ -19,7 +19,7 @@ class ElseIfDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php index e0d22c3c4a..bd51b265f4 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php @@ -33,7 +33,7 @@ class ForEachLoopDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php index 1c6ffe3dc7..e5e4e66f8e 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php @@ -51,7 +51,7 @@ class ForLoopDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php index c8501116aa..ff39c847fb 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php @@ -19,7 +19,7 @@ class InlineIfDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php index 10d76cd46a..068563c03c 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php @@ -19,7 +19,7 @@ class LowercaseDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php index a5bd11fc86..be46aed55c 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -37,7 +37,7 @@ class SwitchDeclarationSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php index 67cac55086..012a6a3c1f 100644 --- a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php +++ b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php @@ -28,7 +28,7 @@ class JSLintSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php index 8f9989ed23..e055cc1dd8 100644 --- a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php +++ b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php @@ -29,7 +29,7 @@ class JavaScriptLintSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php b/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php index 4069a22e13..4ba28a3eef 100644 --- a/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php +++ b/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php @@ -19,7 +19,7 @@ class FileExtensionSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php index 6e60aadd10..b79e6b3ec6 100644 --- a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php +++ b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php @@ -30,7 +30,7 @@ class OperatorBracketSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php index 2c9e7c56a1..7357a507e0 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php @@ -41,7 +41,7 @@ class FunctionDeclarationArgumentSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php index ecf06ac258..5eafbfdbb5 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php @@ -19,7 +19,7 @@ class FunctionDuplicateArgumentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php b/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php index 3ecb31e305..af3d902ecb 100644 --- a/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php @@ -19,7 +19,7 @@ class GlobalFunctionSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php b/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php index 471c602e68..401b840c5b 100644 --- a/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php @@ -20,7 +20,7 @@ class LowercaseFunctionKeywordsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php b/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php index b8757c5399..7bd14ebd1b 100644 --- a/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php @@ -26,7 +26,7 @@ class DisallowObjectStringIndexSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php b/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php index 5f43d1b770..d408a07cc4 100644 --- a/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php @@ -20,7 +20,7 @@ class ObjectInstantiationSniff implements Sniff /** * Registers the token types that this sniff wishes to listen to. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php b/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php index 7c943a8bee..04bd5d1861 100644 --- a/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php @@ -27,7 +27,7 @@ class ObjectMemberCommaSniff implements Sniff /** * Registers the token types that this sniff wishes to listen to. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php index c018142c98..e9b41d691c 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php @@ -62,7 +62,7 @@ class ComparisonOperatorUsageSniff implements Sniff /** * Registers the token types that this sniff wishes to listen to. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php index af2a377e23..b0af660db5 100644 --- a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php @@ -20,7 +20,7 @@ class IncrementDecrementUsageSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php b/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php index bc964b7e48..720e4724ad 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php @@ -19,7 +19,7 @@ class ValidLogicalOperatorsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php index 87e5d3c80e..59e91f07c8 100644 --- a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php @@ -38,7 +38,7 @@ class CommentedOutCodeSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php index 99171bdb7a..24dc1370db 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php @@ -20,7 +20,7 @@ class DisallowBooleanStatementSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php index 595afc5370..57dabbf12e 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php @@ -20,7 +20,7 @@ class DisallowComparisonAssignmentSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php index 9bd02637c0..f2620c7d71 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php @@ -29,7 +29,7 @@ class DisallowInlineIfSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php index 2598b44859..06df652040 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php @@ -20,7 +20,7 @@ class DisallowMultipleAssignmentsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php index 1842ef87d7..5d71c3ec6b 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php @@ -43,7 +43,7 @@ class DisallowSizeFunctionsInLoopsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 22911d80c6..816c5a07bc 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -20,7 +20,7 @@ class EmbeddedPhpSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php b/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php index 74539d9338..102bd7c3fa 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php @@ -19,7 +19,7 @@ class EvalSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php b/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php index a76fc73a2f..fec3ec8217 100644 --- a/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php @@ -19,7 +19,7 @@ class GlobalKeywordSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php b/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php index 6003dc1891..a3ab8e5a69 100644 --- a/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php @@ -19,7 +19,7 @@ class HeredocSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php index 0d0b93f4f0..5ec0d470be 100644 --- a/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php @@ -20,7 +20,7 @@ class InnerFunctionsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php index 134db8881d..0b671d6291 100644 --- a/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php @@ -39,7 +39,7 @@ public function __construct() /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index f4bffff75a..a5db965b66 100644 --- a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -36,7 +36,7 @@ class NonExecutableCodeSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php index 99b935eded..66c3245486 100644 --- a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php @@ -34,7 +34,7 @@ class ConcatenationSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php index d08bc3d100..fb3b626f06 100644 --- a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php @@ -19,7 +19,7 @@ class DoubleQuoteUsageSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php b/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php index 2bf1b0530c..c167d024c4 100644 --- a/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php @@ -20,7 +20,7 @@ class EchoedStringsSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php index 8162f48817..2ae782cefa 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php @@ -20,7 +20,7 @@ class CastSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index 1500b576bd..eb6e5b2aee 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -30,7 +30,7 @@ class ControlStructureSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php index 83b4a4de62..54b9ca9270 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php @@ -29,7 +29,7 @@ class FunctionClosingBraceSpaceSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php index dc9f32e995..3eff4e0fff 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php @@ -29,7 +29,7 @@ class FunctionOpeningBraceSpaceSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php index dc99d73f6c..01cbd647f7 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php @@ -48,7 +48,7 @@ class FunctionSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php index c6fe537fda..b785f5431a 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php @@ -20,7 +20,7 @@ class LanguageConstructSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php index 2d84b38881..d0f4c80c2b 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php @@ -30,7 +30,7 @@ class LogicalOperatorSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php index 1c1f80c556..1c27be7a3d 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php @@ -26,7 +26,7 @@ class ObjectOperatorSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php index aeeb3665f6..87dbed8818 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php @@ -53,7 +53,7 @@ class OperatorSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php index b21660c439..a41f787806 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php @@ -26,7 +26,7 @@ class PropertyLabelSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index 5251bce874..852759e58a 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -20,7 +20,7 @@ class ScopeClosingBraceSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php index 6a72c07e19..65cc13f91f 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php @@ -20,7 +20,7 @@ class ScopeKeywordSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php index a1aa6c5e5e..e10c5cee71 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php @@ -30,7 +30,7 @@ class SemicolonSpacingSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php index bc24f99766..f13baba9f2 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php @@ -43,7 +43,7 @@ class SuperfluousWhitespaceSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { diff --git a/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php b/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php index 5bcfdc0e1c..ffbab028b4 100644 --- a/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php +++ b/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php @@ -23,7 +23,7 @@ class CodeAnalyzerSniff implements Sniff /** * Returns the token types that this sniff is interested in. * - * @return int[] + * @return array */ public function register() { diff --git a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php index b67dbf191d..5ae72362d4 100644 --- a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php @@ -20,7 +20,7 @@ class ClosingTagSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return array */ public function register() { From 18b72cd2ca177e51948639348ea031331ec0cf2e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 26 Dec 2023 01:45:01 +0100 Subject: [PATCH 187/874] GH Actions: minor tweak to merge conflict workflow Follow up on 141 which added the `pull_request_target` trigger with types to the merge conflict check. The `edited` type seems to include changes to the PR labels, which means that the workflow keeps getting cancelled and retriggered on new PRs due to the label workflow running and adding labels, so let's remove the `edited` type. --- .github/workflows/label-merge-conflicts.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/label-merge-conflicts.yml b/.github/workflows/label-merge-conflicts.yml index 5ecf4877cd..170ac52441 100644 --- a/.github/workflows/label-merge-conflicts.yml +++ b/.github/workflows/label-merge-conflicts.yml @@ -9,7 +9,6 @@ on: pull_request_target: types: - opened - - edited - synchronize - reopened From acd5ebce247e9ba1d3f7f36368f0fcd60d8a8958 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 28 Oct 2023 21:00:45 +0200 Subject: [PATCH 188/874] Runner::processFile(): remove stray passed params The `Reporter::cacheFileReport()` method only takes one parameter. --- src/Runner.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Runner.php b/src/Runner.php index 107da1816d..61013874c9 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -688,7 +688,7 @@ public function processFile($file) $file->addErrorOnLine($error, 1, 'Internal.Exception'); }//end try - $this->reporter->cacheFileReport($file, $this->config); + $this->reporter->cacheFileReport($file); if ($this->config->interactive === true) { /* @@ -723,7 +723,7 @@ public function processFile($file) $file->ruleset->populateTokenListeners(); $file->reloadContent(); $file->process(); - $this->reporter->cacheFileReport($file, $this->config); + $this->reporter->cacheFileReport($file); break; } }//end while From 6dc7e4dbf24f68cb0b3f71c311a70dfe8f72f547 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 26 Dec 2023 04:04:02 +0100 Subject: [PATCH 189/874] Docs: various minor fixes --- src/Config.php | 82 ++++++++++++++++++------------------- src/Reports/Performance.php | 8 ++-- src/Ruleset.php | 2 +- src/Util/Timing.php | 4 +- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/Config.php b/src/Config.php index 756b69a5f1..d92483988b 100644 --- a/src/Config.php +++ b/src/Config.php @@ -19,46 +19,46 @@ /** * Stores the configuration used to run PHPCS and PHPCBF. * - * @property string[] $files The files and directories to check. - * @property string[] $standards The standards being used for checking. - * @property int $verbosity How verbose the output should be. - * 0: no unnecessary output - * 1: basic output for files being checked - * 2: ruleset and file parsing output - * 3: sniff execution output - * @property bool $interactive Enable interactive checking mode. - * @property int $parallel Check files in parallel. - * @property bool $cache Enable the use of the file cache. - * @property bool $cacheFile A file where the cache data should be written - * @property bool $colors Display colours in output. - * @property bool $explain Explain the coding standards. - * @property bool $local Process local files in directories only (no recursion). - * @property bool $showSources Show sniff source codes in report output. - * @property bool $showProgress Show basic progress information while running. - * @property bool $quiet Quiet mode; disables progress and verbose output. - * @property bool $annotations Process phpcs: annotations. - * @property int $tabWidth How many spaces each tab is worth. - * @property string $encoding The encoding of the files being checked. - * @property string[] $sniffs The sniffs that should be used for checking. - * If empty, all sniffs in the supplied standards will be used. - * @property string[] $exclude The sniffs that should be excluded from checking. - * If empty, all sniffs in the supplied standards will be used. - * @property string[] $ignored Regular expressions used to ignore files and folders during checking. - * @property string $reportFile A file where the report output should be written. - * @property string $generator The documentation generator to use. - * @property string $filter The filter to use for the run. - * @property string[] $bootstrap One of more files to include before the run begins. - * @property int $reportWidth The maximum number of columns that reports should use for output. - * Set to "auto" for have this value changed to the width of the terminal. - * @property int $errorSeverity The minimum severity an error must have to be displayed. - * @property int $warningSeverity The minimum severity a warning must have to be displayed. - * @property bool $recordErrors Record the content of error messages as well as error counts. - * @property string $suffix A suffix to add to fixed files. - * @property string $basepath A file system location to strip from the paths of files shown in reports. - * @property bool $stdin Read content from STDIN instead of supplied files. - * @property string $stdinContent Content passed directly to PHPCS on STDIN. - * @property string $stdinPath The path to use for content passed on STDIN. - * @property bool $trackTime Whether or not to track sniff run time. + * @property string[] $files The files and directories to check. + * @property string[] $standards The standards being used for checking. + * @property int $verbosity How verbose the output should be. + * 0: no unnecessary output + * 1: basic output for files being checked + * 2: ruleset and file parsing output + * 3: sniff execution output + * @property bool $interactive Enable interactive checking mode. + * @property int $parallel Check files in parallel. + * @property bool $cache Enable the use of the file cache. + * @property string $cacheFile Path to the file where the cache data should be written + * @property bool $colors Display colours in output. + * @property bool $explain Explain the coding standards. + * @property bool $local Process local files in directories only (no recursion). + * @property bool $showSources Show sniff source codes in report output. + * @property bool $showProgress Show basic progress information while running. + * @property bool $quiet Quiet mode; disables progress and verbose output. + * @property bool $annotations Process phpcs: annotations. + * @property int $tabWidth How many spaces each tab is worth. + * @property string $encoding The encoding of the files being checked. + * @property string[] $sniffs The sniffs that should be used for checking. + * If empty, all sniffs in the supplied standards will be used. + * @property string[] $exclude The sniffs that should be excluded from checking. + * If empty, all sniffs in the supplied standards will be used. + * @property string[] $ignored Regular expressions used to ignore files and folders during checking. + * @property string $reportFile A file where the report output should be written. + * @property string $generator The documentation generator to use. + * @property string $filter The filter to use for the run. + * @property string[] $bootstrap One of more files to include before the run begins. + * @property int|string $reportWidth The maximum number of columns that reports should use for output. + * Set to "auto" for have this value changed to the width of the terminal. + * @property int $errorSeverity The minimum severity an error must have to be displayed. + * @property int $warningSeverity The minimum severity a warning must have to be displayed. + * @property bool $recordErrors Record the content of error messages as well as error counts. + * @property string $suffix A suffix to add to fixed files. + * @property string $basepath A file system location to strip from the paths of files shown in reports. + * @property bool $stdin Read content from STDIN instead of supplied files. + * @property string $stdinContent Content passed directly to PHPCS on STDIN. + * @property string $stdinPath The path to use for content passed on STDIN. + * @property bool $trackTime Whether or not to track sniff run time. * * @property array $extensions File extensions that should be checked, and what tokenizer to use. * E.g., array('inc' => 'PHP'); @@ -169,7 +169,7 @@ class Config /** * Command line values that the user has supplied directly. * - * @var array + * @var array> */ private static $overriddenDefaults = []; diff --git a/src/Reports/Performance.php b/src/Reports/Performance.php index d5b94074d4..78f0f6ae23 100644 --- a/src/Reports/Performance.php +++ b/src/Reports/Performance.php @@ -24,10 +24,10 @@ class Performance implements Report * and FALSE if it ignored the file. Returning TRUE indicates that the file and * its data should be counted in the grand totals. * - * @param array $report Prepared report data. - * @param \PHP_CodeSniffer\File $phpcsFile The file being reported on. - * @param bool $showSources Show sources? - * @param int $width Maximum allowed line width. + * @param array $report Prepared report data. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being reported on. + * @param bool $showSources Show sources? + * @param int $width Maximum allowed line width. * * @return bool */ diff --git a/src/Ruleset.php b/src/Ruleset.php index 901fb8e09b..2e2493037b 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -88,7 +88,7 @@ class Ruleset * The key is the token name being listened for and the value * is the sniff object. * - * @var array + * @var array>> */ public $tokenListeners = []; diff --git a/src/Util/Timing.php b/src/Util/Timing.php index 36f4346343..57470c77ac 100644 --- a/src/Util/Timing.php +++ b/src/Util/Timing.php @@ -43,7 +43,7 @@ public static function startTiming() /** * Get the duration of the run up to "now". * - * @return int Duration in microseconds. + * @return float Duration in microseconds. */ public static function getDuration() { @@ -60,7 +60,7 @@ public static function getDuration() /** * Convert a duration in microseconds to a human readable duration string. * - * @param int $duration Duration in microseconds. + * @param float $duration Duration in microseconds. * * @return string */ From 069331a424842b865f25fa0b6b86314e9521b909 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 28 Oct 2023 20:36:51 +0200 Subject: [PATCH 190/874] PSR12/ControlStructureSpacing: small tweak No need to create a new instance of the PSR2 sniff every single time the sniff is triggered. Re-using the same object, just like is done with sniffs in general, will work just as well. This will have a (tiny) positive impact on performance, though the impact is so small, it can be considered negligible. --- .../ControlStructureSpacingSniff.php | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index 2ddb66340b..9a200aa81c 100644 --- a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ControlStructureSpacingSniff as PSR2Spacing; +use PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ControlStructureSpacingSniff as PSR2ControlStructureSpacing; use PHP_CodeSniffer\Util\Tokens; class ControlStructureSpacingSniff implements Sniff @@ -24,6 +24,23 @@ class ControlStructureSpacingSniff implements Sniff */ public $indent = 4; + /** + * Instance of the PSR2 ControlStructureSpacingSniff sniff. + * + * @var \PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ControlStructureSpacingSniff + */ + private $psr2ControlStructureSpacing; + + + /** + * Constructor. + */ + public function __construct() + { + $this->psr2ControlStructureSpacing = new PSR2ControlStructureSpacing(); + + }//end __construct() + /** * Returns an array of tokens this test wants to listen for. @@ -70,8 +87,7 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$parenOpener]['line'] === $tokens[$parenCloser]['line']) { // Conditions are all on the same line, so follow PSR2. - $sniff = new PSR2Spacing(); - return $sniff->process($phpcsFile, $stackPtr); + return $this->psr2ControlStructureSpacing->process($phpcsFile, $stackPtr); } $next = $phpcsFile->findNext(T_WHITESPACE, ($parenOpener + 1), $parenCloser, true); From 9be358b8bf5e971025e461c82f153f677b60fd86 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 03:39:03 +0100 Subject: [PATCH 191/874] File::findFirstOnLine(): minor correction to the docs --- src/Files/File.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Files/File.php b/src/Files/File.php index eb2357a15e..04eacb007e 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -2647,15 +2647,18 @@ public function findEndOfStatement($start, $ignore=null) * * @param int|string|array $types The type(s) of tokens to search for. * @param int $start The position to start searching from in the - * token stack. The first token matching on - * this line before this token will be returned. + * token stack. * @param bool $exclude If true, find the token that is NOT of * the types specified in $types. * @param string $value The value that the token must be equal to. * If value is omitted, tokens with any value will * be returned. * - * @return int|false + * @return int|false The first token which matches on the line containing the start + * token, between the start of the line and the start token. + * Note: The first token matching might be the start token. + * FALSE when no matching token could be found between the start of + * the line and the start token. */ public function findFirstOnLine($types, $start, $exclude=false, $value=null) { From 97897c64de69d665d6aecc1b21a6c35acb615ae5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Dec 2023 22:55:14 +0100 Subject: [PATCH 192/874] File: update inline comment ... to remove unnecessary use of "whitelist" terminology. --- src/Files/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files/File.php b/src/Files/File.php index 04eacb007e..261ede44e7 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -904,7 +904,7 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s } } - // If it is ignored, make sure it's not whitelisted. + // If it is ignored, make sure there is no exception in place. if ($ignored === true && isset($this->tokenizer->ignoredLines[$line]['.except']) === true ) { From 2e7518daef4b57f4caef273e5e6dd33f159cdc31 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 31 Dec 2023 00:18:15 +0100 Subject: [PATCH 193/874] Tests/Filters: new `AbstractFilterTestCase` ... to contain some basic utilities and logic for use in Filter related tests. Includes switching the `Filter/AcceptTest` to use the new abstract and to use the available utilities. --- tests/Core/Filters/AbstractFilterTestCase.php | 104 ++++++++++++++++++ tests/Core/Filters/Filter/AcceptTest.php | 42 +------ 2 files changed, 110 insertions(+), 36 deletions(-) create mode 100644 tests/Core/Filters/AbstractFilterTestCase.php diff --git a/tests/Core/Filters/AbstractFilterTestCase.php b/tests/Core/Filters/AbstractFilterTestCase.php new file mode 100644 index 0000000000..a745a21481 --- /dev/null +++ b/tests/Core/Filters/AbstractFilterTestCase.php @@ -0,0 +1,104 @@ + + * @copyright 2023 PHPCSStandards Contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Filters; + +use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Filters\Filter; +use PHP_CodeSniffer\Ruleset; +use PHPUnit\Framework\TestCase; +use RecursiveIteratorIterator; + +/** + * Base functionality and utilities for testing Filter classes. + */ +abstract class AbstractFilterTestCase extends TestCase +{ + + /** + * The Config object. + * + * @var \PHP_CodeSniffer\Config + */ + protected static $config; + + /** + * The Ruleset object. + * + * @var \PHP_CodeSniffer\Ruleset + */ + protected static $ruleset; + + + /** + * Initialize the config and ruleset objects. + * + * @beforeClass + * + * @return void + */ + public static function initializeConfigAndRuleset() + { + self::$config = new Config(['--standard=PSR1', '--report-width=80']); + self::$ruleset = new Ruleset(self::$config); + + }//end initializeConfigAndRuleset() + + + /** + * Retrieve an array of files which were accepted by a filter. + * + * @param \PHP_CodeSniffer\Filters\Filter $filter The Filter object under test. + * + * @return array + */ + protected function getFilteredResultsAsArray(Filter $filter) + { + $iterator = new RecursiveIteratorIterator($filter); + $files = []; + foreach ($iterator as $file) { + $files[] = $file; + } + + return $files; + + }//end getFilteredResultsAsArray() + + + /** + * Translate Linux paths to Windows paths, when necessary. + * + * These type of tests should be able to run and pass on both *nix as well as Windows + * based dev systems. This method is a helper to allow for this. + * + * @param array $paths A single or multi-dimensional array containing + * file paths. + * + * @return array + */ + protected static function mapPathsToRuntimeOs(array $paths) + { + if (DIRECTORY_SEPARATOR !== '\\') { + return $paths; + } + + foreach ($paths as $key => $value) { + if (is_string($value) === true) { + $paths[$key] = strtr($value, '/', '\\\\'); + } else if (is_array($value) === true) { + $paths[$key] = self::mapPathsToRuntimeOs($value); + } + } + + return $paths; + + }//end mapPathsToRuntimeOs() + + +}//end class diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index 53d4ba6441..facf9f9535 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -13,30 +13,16 @@ use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Filters\Filter; use PHP_CodeSniffer\Ruleset; -use PHPUnit\Framework\TestCase; +use PHP_CodeSniffer\Tests\Core\Filters\AbstractFilterTestCase; /** * Tests for the \PHP_CodeSniffer\Filters\Filter::accept method. * * @covers \PHP_CodeSniffer\Filters\Filter */ -class AcceptTest extends TestCase +class AcceptTest extends AbstractFilterTestCase { - /** - * The Config object. - * - * @var \PHP_CodeSniffer\Config - */ - protected static $config; - - /** - * The Ruleset object. - * - * @var \PHP_CodeSniffer\Ruleset - */ - protected static $ruleset; - /** * Initialize the config and ruleset objects based on the `AcceptTest.xml` ruleset file. @@ -66,16 +52,10 @@ public static function initializeConfigAndRuleset() */ public function testExcludePatterns($inputPaths, $expectedOutput) { - $fakeDI = new \RecursiveArrayIterator($inputPaths); - $filter = new Filter($fakeDI, '/', self::$config, self::$ruleset); - $iterator = new \RecursiveIteratorIterator($filter); - $files = []; - - foreach ($iterator as $file) { - $files[] = $file; - } + $fakeDI = new \RecursiveArrayIterator($inputPaths); + $filter = new Filter($fakeDI, '/', self::$config, self::$ruleset); - $this->assertEquals($expectedOutput, $files); + $this->assertEquals($expectedOutput, $this->getFilteredResultsAsArray($filter)); }//end testExcludePatterns() @@ -121,17 +101,7 @@ public function dataExcludePatterns() ]; // Allow these tests to work on Windows as well. - if (DIRECTORY_SEPARATOR === '\\') { - foreach ($testCases as $key => $case) { - foreach ($case as $nr => $param) { - foreach ($param as $file => $value) { - $testCases[$key][$nr][$file] = strtr($value, '/', '\\'); - } - } - } - } - - return $testCases; + return self::mapPathsToRuntimeOs($testCases); }//end dataExcludePatterns() From 43c85200a9211102cbf1616814cf2bcf09d009ea Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 10:21:41 +0100 Subject: [PATCH 194/874] Tests/AcceptTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblocks more specific. --- tests/Core/Filters/Filter/AcceptTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index facf9f9535..e6fe2be8a2 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -43,8 +43,8 @@ public static function initializeConfigAndRuleset() /** * Test filtering a file list for excluded paths. * - * @param array $inputPaths List of file paths to be filtered. - * @param array $expectedOutput Expected filtering result. + * @param array $inputPaths List of file paths to be filtered. + * @param array $expectedOutput Expected filtering result. * * @dataProvider dataExcludePatterns * @@ -65,34 +65,34 @@ public function testExcludePatterns($inputPaths, $expectedOutput) * * @see testExcludePatterns * - * @return array + * @return array>> */ public function dataExcludePatterns() { $testCases = [ // Test top-level exclude patterns. - [ - [ + 'Non-sniff specific path based excludes from ruleset and command line are respected and don\'t filter out too much' => [ + 'inputPaths' => [ '/path/to/src/Main.php', '/path/to/src/Something/Main.php', '/path/to/src/Somethingelse/Main.php', '/path/to/src/SomethingelseEvenLonger/Main.php', '/path/to/src/Other/Main.php', ], - [ + 'expectedOutput' => [ '/path/to/src/Main.php', '/path/to/src/SomethingelseEvenLonger/Main.php', ], ], // Test ignoring standard/sniff specific exclude patterns. - [ - [ + 'Filter should not act on standard/sniff specific exclude patterns' => [ + 'inputPaths' => [ '/path/to/src/generic-project/Main.php', '/path/to/src/generic/Main.php', '/path/to/src/anything-generic/Main.php', ], - [ + 'expectedOutput' => [ '/path/to/src/generic-project/Main.php', '/path/to/src/generic/Main.php', '/path/to/src/anything-generic/Main.php', From d9b6f3cde6ff177c8f4496cc37ad8394e9e11b9a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 10:21:41 +0100 Subject: [PATCH 195/874] Tests/AcceptTest: minor tweaks * Import all used classes. * Make the data provider static. * Prevent a potential call to `stty` by setting the report width. --- tests/Core/Filters/Filter/AcceptTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index e6fe2be8a2..fa3c834f77 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -14,6 +14,7 @@ use PHP_CodeSniffer\Filters\Filter; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\Core\Filters\AbstractFilterTestCase; +use RecursiveArrayIterator; /** * Tests for the \PHP_CodeSniffer\Filters\Filter::accept method. @@ -34,7 +35,7 @@ class AcceptTest extends AbstractFilterTestCase public static function initializeConfigAndRuleset() { $standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; - self::$config = new Config(["--standard=$standard", "--ignore=*/somethingelse/*"]); + self::$config = new Config(["--standard=$standard", '--ignore=*/somethingelse/*', '--report-width=80']); self::$ruleset = new Ruleset(self::$config); }//end initializeConfigAndRuleset() @@ -52,7 +53,7 @@ public static function initializeConfigAndRuleset() */ public function testExcludePatterns($inputPaths, $expectedOutput) { - $fakeDI = new \RecursiveArrayIterator($inputPaths); + $fakeDI = new RecursiveArrayIterator($inputPaths); $filter = new Filter($fakeDI, '/', self::$config, self::$ruleset); $this->assertEquals($expectedOutput, $this->getFilteredResultsAsArray($filter)); @@ -67,7 +68,7 @@ public function testExcludePatterns($inputPaths, $expectedOutput) * * @return array>> */ - public function dataExcludePatterns() + public static function dataExcludePatterns() { $testCases = [ // Test top-level exclude patterns. From bea39038937c9b5637bf84b1bb63d05a42f99bff Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 31 Dec 2023 07:38:46 +0100 Subject: [PATCH 196/874] Filters: add tests for `GitModified` and `GitStaged` filters This is an initial set of tests for the `GitModified` and `GitStaged` filters. The tests are largely the same for both filters as the logic under test is also largely the same. Still, having separate test classes will allow for differentiating the tests if the logic in the filters themselves would start to diverge over time or if the output of the individual git commands would give reason to add extra tests. Notes: * To allow for mocking the output of the "git modified"/"git staged" commands, the handling of the function call to `exec` has been moved to a separate method in both the `GitModified`, as well as the `GitStaged` class. * This commit adds three new helper methods to the `AbstractFilterTestCase`: - `getMockedClass()` to handle creating a mock object of the filter under test in a PHPUnit cross-version compatible manner. - `getBaseDir()` to get the project root directory for use as the `$basedir` for the filters. - `getFakeFileList()` to get, as the name says, a fake file list for use in the tests, which contains a range of different file/directory situations which filter may need to take into account. Note: `.` and `..` are not included as the `PHP_CodeSniffer\Files\FileList` (which is basically what we're faking here) does not include those either, so that would create unrealistic test scenarios. Also note that, aside from some non-existent files added to the list for testing purposes, the files in this list _do_ actually need to exist for the tests to be valid. --- src/Filters/GitModified.php | 26 +- src/Filters/GitStaged.php | 26 +- tests/Core/Filters/AbstractFilterTestCase.php | 125 ++++++++- tests/Core/Filters/GitModifiedTest.php | 260 ++++++++++++++++++ tests/Core/Filters/GitStagedTest.php | 260 ++++++++++++++++++ 5 files changed, 692 insertions(+), 5 deletions(-) create mode 100644 tests/Core/Filters/GitModifiedTest.php create mode 100644 tests/Core/Filters/GitStagedTest.php diff --git a/src/Filters/GitModified.php b/src/Filters/GitModified.php index 9bba997c24..b946577909 100644 --- a/src/Filters/GitModified.php +++ b/src/Filters/GitModified.php @@ -37,8 +37,7 @@ protected function getWhitelist() $modified = []; $cmd = 'git ls-files -o -m --exclude-standard -- '.escapeshellarg($this->basedir); - $output = []; - exec($cmd, $output); + $output = $this->exec($cmd); $basedir = $this->basedir; if (is_dir($basedir) === false) { @@ -63,4 +62,27 @@ protected function getWhitelist() }//end getWhitelist() + /** + * Execute an external command. + * + * {@internal This method is only needed to allow for mocking the return value + * to test the class logic.} + * + * @param string $cmd Command. + * + * @return array + */ + protected function exec($cmd) + { + $output = []; + $lastLine = exec($cmd, $output); + if ($lastLine === false) { + return []; + } + + return $output; + + }//end exec() + + }//end class diff --git a/src/Filters/GitStaged.php b/src/Filters/GitStaged.php index 1fdbb952ca..405387ff87 100644 --- a/src/Filters/GitStaged.php +++ b/src/Filters/GitStaged.php @@ -39,8 +39,7 @@ protected function getWhitelist() $modified = []; $cmd = 'git diff --cached --name-only -- '.escapeshellarg($this->basedir); - $output = []; - exec($cmd, $output); + $output = $this->exec($cmd); $basedir = $this->basedir; if (is_dir($basedir) === false) { @@ -65,4 +64,27 @@ protected function getWhitelist() }//end getWhitelist() + /** + * Execute an external command. + * + * {@internal This method is only needed to allow for mocking the return value + * to test the class logic.} + * + * @param string $cmd Command. + * + * @return array + */ + protected function exec($cmd) + { + $output = []; + $lastLine = exec($cmd, $output); + if ($lastLine === false) { + return []; + } + + return $output; + + }//end exec() + + }//end class diff --git a/tests/Core/Filters/AbstractFilterTestCase.php b/tests/Core/Filters/AbstractFilterTestCase.php index a745a21481..b867d7aaf8 100644 --- a/tests/Core/Filters/AbstractFilterTestCase.php +++ b/tests/Core/Filters/AbstractFilterTestCase.php @@ -45,12 +45,56 @@ abstract class AbstractFilterTestCase extends TestCase */ public static function initializeConfigAndRuleset() { - self::$config = new Config(['--standard=PSR1', '--report-width=80']); + self::$config = new Config(['--standard=PSR1', '--extensions=php,inc/php,js,css', '--report-width=80']); self::$ruleset = new Ruleset(self::$config); }//end initializeConfigAndRuleset() + /** + * Helper method to retrieve a mock object for a Filter class. + * + * The `setMethods()` method was silently deprecated in PHPUnit 9 and removed in PHPUnit 10. + * + * Note: direct access to the `getMockBuilder()` method is soft deprecated as of PHPUnit 10, + * and expected to be hard deprecated in PHPUnit 11 and removed in PHPUnit 12. + * Dealing with that is something for a later iteration of the test suite. + * + * @param string $className Fully qualified name of the class under test. + * @param array $constructorArgs Optional. Array of parameters to pass to the class constructor. + * @param array|null $methodsToMock Optional. The methods to mock in the class under test. + * Needed for PHPUnit cross-version support as PHPUnit 4.x does + * not have a `setMethodsExcept()` method yet. + * If not passed, no methods will be replaced. + * + * @return \PHPUnit\Framework\MockObject\MockObject + */ + protected function getMockedClass($className, array $constructorArgs=[], $methodsToMock=null) + { + $mockedObj = $this->getMockBuilder($className); + + if (\method_exists($mockedObj, 'onlyMethods') === true) { + // PHPUnit 8+. + if (is_array($methodsToMock) === true) { + return $mockedObj + ->setConstructorArgs($constructorArgs) + ->onlyMethods($methodsToMock) + ->getMock(); + } + + return $mockedObj->getMock() + ->setConstructorArgs($constructorArgs); + } + + // PHPUnit < 8. + return $mockedObj + ->setConstructorArgs($constructorArgs) + ->setMethods($methodsToMock) + ->getMock(); + + }//end getMockedClass() + + /** * Retrieve an array of files which were accepted by a filter. * @@ -71,6 +115,85 @@ protected function getFilteredResultsAsArray(Filter $filter) }//end getFilteredResultsAsArray() + /** + * Retrieve the basedir to use for tests using the `getFakeFileList()` method. + * + * @return string + */ + protected static function getBaseDir() + { + return dirname(dirname(dirname(__DIR__))); + + }//end getBaseDir() + + + /** + * Retrieve a file list containing a range of paths for testing purposes. + * + * This list **must** contain files which exist in this project (well, except for some which don't exist + * purely for testing purposes), as `realpath()` is used in the logic under test and `realpath()` will + * return `false` for any non-existent files, which will automatically filter them out before + * we get to the code under test. + * + * Note this list does not include `.` and `..` as \PHP_CodeSniffer\Files\FileList uses `SKIP_DOTS`. + * + * @return array + */ + protected static function getFakeFileList() + { + $basedir = self::getBaseDir(); + return [ + $basedir.'/.gitignore', + $basedir.'/.yamllint.yml', + $basedir.'/phpcs.xml', + $basedir.'/phpcs.xml.dist', + $basedir.'/autoload.php', + $basedir.'/bin', + $basedir.'/bin/phpcs', + $basedir.'/bin/phpcs.bat', + $basedir.'/scripts', + $basedir.'/scripts/build-phar.php', + $basedir.'/src', + $basedir.'/src/WillNotExist.php', + $basedir.'/src/WillNotExist.bak', + $basedir.'/src/WillNotExist.orig', + $basedir.'/src/Ruleset.php', + $basedir.'/src/Generators', + $basedir.'/src/Generators/Markdown.php', + $basedir.'/src/Standards', + $basedir.'/src/Standards/Generic', + $basedir.'/src/Standards/Generic/Docs', + $basedir.'/src/Standards/Generic/Docs/Classes', + $basedir.'/src/Standards/Generic/Docs/Classes/DuplicateClassNameStandard.xml', + $basedir.'/src/Standards/Generic/Sniffs', + $basedir.'/src/Standards/Generic/Sniffs/Classes', + $basedir.'/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php', + $basedir.'/src/Standards/Generic/Tests', + $basedir.'/src/Standards/Generic/Tests/Classes', + $basedir.'/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.1.inc', + // Will rarely exist when running the tests. + $basedir.'/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.1.inc.bak', + $basedir.'/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.2.inc', + $basedir.'/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php', + $basedir.'/src/Standards/Squiz', + $basedir.'/src/Standards/Squiz/Docs', + $basedir.'/src/Standards/Squiz/Docs/WhiteSpace', + $basedir.'/src/Standards/Squiz/Docs/WhiteSpace/SemicolonSpacingStandard.xml', + $basedir.'/src/Standards/Squiz/Sniffs', + $basedir.'/src/Standards/Squiz/Sniffs/WhiteSpace', + $basedir.'/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php', + $basedir.'/src/Standards/Squiz/Tests', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php', + ]; + + }//end getFakeFileList() + + /** * Translate Linux paths to Windows paths, when necessary. * diff --git a/tests/Core/Filters/GitModifiedTest.php b/tests/Core/Filters/GitModifiedTest.php new file mode 100644 index 0000000000..b3d11b631f --- /dev/null +++ b/tests/Core/Filters/GitModifiedTest.php @@ -0,0 +1,260 @@ + + * @copyright 2023 PHPCSStandards Contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Filters; + +use PHP_CodeSniffer\Filters\GitModified; +use PHP_CodeSniffer\Tests\Core\Filters\AbstractFilterTestCase; +use RecursiveArrayIterator; +use ReflectionMethod; + +/** + * Tests for the \PHP_CodeSniffer\Filters\GitModified class. + * + * @covers \PHP_CodeSniffer\Filters\GitModified + */ +class GitModifiedTest extends AbstractFilterTestCase +{ + + + /** + * Test filtering a file list for excluded paths. + * + * @return void + */ + public function testFileNamePassesAsBasePathWillTranslateToDirname() + { + $rootFile = self::getBaseDir().'/autoload.php'; + + $fakeDI = new RecursiveArrayIterator(self::getFakeFileList()); + $constructorArgs = [ + $fakeDI, + $rootFile, + self::$config, + self::$ruleset, + ]; + $mockObj = $this->getMockedClass('PHP_CodeSniffer\Filters\GitModified', $constructorArgs, ['exec']); + + $mockObj->expects($this->once()) + ->method('exec') + ->willReturn(['autoload.php']); + + $this->assertEquals([$rootFile], $this->getFilteredResultsAsArray($mockObj)); + + }//end testFileNamePassesAsBasePathWillTranslateToDirname() + + + /** + * Test filtering a file list for excluded paths. + * + * @param array $inputPaths List of file paths to be filtered. + * @param array $outputGitModified Simulated "git modified" output. + * @param array $expectedOutput Expected filtering result. + * + * @dataProvider dataAcceptOnlyGitModified + * + * @return void + */ + public function testAcceptOnlyGitModified($inputPaths, $outputGitModified, $expectedOutput) + { + $fakeDI = new RecursiveArrayIterator($inputPaths); + $constructorArgs = [ + $fakeDI, + self::getBaseDir(), + self::$config, + self::$ruleset, + ]; + $mockObj = $this->getMockedClass('PHP_CodeSniffer\Filters\GitModified', $constructorArgs, ['exec']); + + $mockObj->expects($this->once()) + ->method('exec') + ->willReturn($outputGitModified); + + $this->assertEquals($expectedOutput, $this->getFilteredResultsAsArray($mockObj)); + + }//end testAcceptOnlyGitModified() + + + /** + * Data provider. + * + * @see testAcceptOnlyGitModified + * + * @return array>> + */ + public static function dataAcceptOnlyGitModified() + { + $basedir = self::getBaseDir(); + $fakeFileList = self::getFakeFileList(); + + $testCases = [ + 'no files marked as git modified' => [ + 'inputPaths' => $fakeFileList, + 'outputGitModified' => [], + 'expectedOutput' => [], + ], + + 'files marked as git modified which don\'t actually exist' => [ + 'inputPaths' => $fakeFileList, + 'outputGitModified' => [ + 'src/WillNotExist.php', + 'src/WillNotExist.bak', + 'src/WillNotExist.orig', + ], + 'expectedOutput' => [], + ], + + 'single file marked as git modified - file in root dir' => [ + 'inputPaths' => $fakeFileList, + 'outputGitModified' => ['autoload.php'], + 'expectedOutput' => [ + $basedir.'/autoload.php', + ], + ], + 'single file marked as git modified - file in sub dir' => [ + 'inputPaths' => $fakeFileList, + 'outputGitModified' => ['src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php'], + 'expectedOutput' => [ + $basedir.'/src', + $basedir.'/src/Standards', + $basedir.'/src/Standards/Generic', + $basedir.'/src/Standards/Generic/Sniffs', + $basedir.'/src/Standards/Generic/Sniffs/Classes', + $basedir.'/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php', + ], + ], + + 'multiple files marked as git modified, none valid for scan' => [ + 'inputPaths' => $fakeFileList, + 'outputGitModified' => [ + '.gitignore', + 'phpcs.xml.dist', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed', + ], + 'expectedOutput' => [ + $basedir.'/src', + $basedir.'/src/Standards', + $basedir.'/src/Standards/Squiz', + $basedir.'/src/Standards/Squiz/Tests', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace', + ], + ], + + 'multiple files marked as git modified, only one file valid for scan' => [ + 'inputPaths' => $fakeFileList, + 'outputGitModified' => [ + '.gitignore', + 'src/Standards/Generic/Docs/Classes/DuplicateClassNameStandard.xml', + 'src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php', + ], + 'expectedOutput' => [ + $basedir.'/src', + $basedir.'/src/Standards', + $basedir.'/src/Standards/Generic', + $basedir.'/src/Standards/Generic/Docs', + $basedir.'/src/Standards/Generic/Docs/Classes', + $basedir.'/src/Standards/Generic/Sniffs', + $basedir.'/src/Standards/Generic/Sniffs/Classes', + $basedir.'/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php', + ], + ], + + 'multiple files marked as git modified, multiple files valid for scan' => [ + 'inputPaths' => $fakeFileList, + 'outputGitModified' => [ + '.yamllint.yml', + 'autoload.php', + 'src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php', + ], + 'expectedOutput' => [ + $basedir.'/autoload.php', + $basedir.'/src', + $basedir.'/src/Standards', + $basedir.'/src/Standards/Squiz', + $basedir.'/src/Standards/Squiz/Sniffs', + $basedir.'/src/Standards/Squiz/Sniffs/WhiteSpace', + $basedir.'/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php', + $basedir.'/src/Standards/Squiz/Tests', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php', + ], + ], + ]; + + return $testCases; + + }//end dataAcceptOnlyGitModified() + + + /** + * Test filtering a file list for excluded paths. + * + * @param string $cmd Command to run. + * @param array $expected Expected return value. + * + * @dataProvider dataExecAlwaysReturnsArray + * + * @return void + */ + public function testExecAlwaysReturnsArray($cmd, $expected) + { + $fakeDI = new RecursiveArrayIterator(self::getFakeFileList()); + $filter = new GitModified($fakeDI, '/', self::$config, self::$ruleset); + + $reflMethod = new ReflectionMethod($filter, 'exec'); + $reflMethod->setAccessible(true); + $result = $reflMethod->invoke($filter, $cmd); + + $this->assertSame($expected, $result); + + }//end testExecAlwaysReturnsArray() + + + /** + * Data provider. + * + * @see testExecAlwaysReturnsArray + * + * {@internal Missing: test with a command which yields a `false` return value. + * JRF: I've not managed to find a command which does so, let alone one, which then + * doesn't have side-effects of uncatchable output while running the tests.} + * + * @return array>> + */ + public static function dataExecAlwaysReturnsArray() + { + return [ + 'valid command which won\'t have any output unless files in the bin dir have been modified' => [ + // Largely using the command used in the filter, but only checking the bin dir. + // This should prevent the test unexpectedly failing during local development (in most cases). + 'cmd' => 'git ls-files -o -m --exclude-standard -- '.escapeshellarg(self::getBaseDir().'/bin'), + 'expected' => [], + ], + 'valid command which will have output' => [ + 'cmd' => 'git ls-files --exclude-standard -- '.escapeshellarg(self::getBaseDir().'/bin'), + 'expected' => [ + 'bin/phpcbf', + 'bin/phpcbf.bat', + 'bin/phpcs', + 'bin/phpcs.bat', + ], + ], + ]; + + }//end dataExecAlwaysReturnsArray() + + +}//end class diff --git a/tests/Core/Filters/GitStagedTest.php b/tests/Core/Filters/GitStagedTest.php new file mode 100644 index 0000000000..ebf761c4fe --- /dev/null +++ b/tests/Core/Filters/GitStagedTest.php @@ -0,0 +1,260 @@ + + * @copyright 2023 PHPCSStandards Contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Filters; + +use PHP_CodeSniffer\Filters\GitStaged; +use PHP_CodeSniffer\Tests\Core\Filters\AbstractFilterTestCase; +use RecursiveArrayIterator; +use ReflectionMethod; + +/** + * Tests for the \PHP_CodeSniffer\Filters\GitStaged class. + * + * @covers \PHP_CodeSniffer\Filters\GitStaged + */ +class GitStagedTest extends AbstractFilterTestCase +{ + + + /** + * Test filtering a file list for excluded paths. + * + * @return void + */ + public function testFileNamePassesAsBasePathWillTranslateToDirname() + { + $rootFile = self::getBaseDir().'/autoload.php'; + + $fakeDI = new RecursiveArrayIterator(self::getFakeFileList()); + $constructorArgs = [ + $fakeDI, + $rootFile, + self::$config, + self::$ruleset, + ]; + $mockObj = $this->getMockedClass('PHP_CodeSniffer\Filters\GitStaged', $constructorArgs, ['exec']); + + $mockObj->expects($this->once()) + ->method('exec') + ->willReturn(['autoload.php']); + + $this->assertEquals([$rootFile], $this->getFilteredResultsAsArray($mockObj)); + + }//end testFileNamePassesAsBasePathWillTranslateToDirname() + + + /** + * Test filtering a file list for excluded paths. + * + * @param array $inputPaths List of file paths to be filtered. + * @param array $outputGitStaged Simulated "git staged" output. + * @param array $expectedOutput Expected filtering result. + * + * @dataProvider dataAcceptOnlyGitStaged + * + * @return void + */ + public function testAcceptOnlyGitStaged($inputPaths, $outputGitStaged, $expectedOutput) + { + $fakeDI = new RecursiveArrayIterator($inputPaths); + $constructorArgs = [ + $fakeDI, + self::getBaseDir(), + self::$config, + self::$ruleset, + ]; + $mockObj = $this->getMockedClass('PHP_CodeSniffer\Filters\GitStaged', $constructorArgs, ['exec']); + + $mockObj->expects($this->once()) + ->method('exec') + ->willReturn($outputGitStaged); + + $this->assertEquals($expectedOutput, $this->getFilteredResultsAsArray($mockObj)); + + }//end testAcceptOnlyGitStaged() + + + /** + * Data provider. + * + * @see testAcceptOnlyGitStaged + * + * @return array>> + */ + public static function dataAcceptOnlyGitStaged() + { + $basedir = self::getBaseDir(); + $fakeFileList = self::getFakeFileList(); + + $testCases = [ + 'no files marked as git modified' => [ + 'inputPaths' => $fakeFileList, + 'outputGitStaged' => [], + 'expectedOutput' => [], + ], + + 'files marked as git modified which don\'t actually exist' => [ + 'inputPaths' => $fakeFileList, + 'outputGitStaged' => [ + 'src/WillNotExist.php', + 'src/WillNotExist.bak', + 'src/WillNotExist.orig', + ], + 'expectedOutput' => [], + ], + + 'single file marked as git modified - file in root dir' => [ + 'inputPaths' => $fakeFileList, + 'outputGitStaged' => ['autoload.php'], + 'expectedOutput' => [ + $basedir.'/autoload.php', + ], + ], + 'single file marked as git modified - file in sub dir' => [ + 'inputPaths' => $fakeFileList, + 'outputGitStaged' => ['src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php'], + 'expectedOutput' => [ + $basedir.'/src', + $basedir.'/src/Standards', + $basedir.'/src/Standards/Generic', + $basedir.'/src/Standards/Generic/Sniffs', + $basedir.'/src/Standards/Generic/Sniffs/Classes', + $basedir.'/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php', + ], + ], + + 'multiple files marked as git modified, none valid for scan' => [ + 'inputPaths' => $fakeFileList, + 'outputGitStaged' => [ + '.gitignore', + 'phpcs.xml.dist', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed', + ], + 'expectedOutput' => [ + $basedir.'/src', + $basedir.'/src/Standards', + $basedir.'/src/Standards/Squiz', + $basedir.'/src/Standards/Squiz/Tests', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace', + ], + ], + + 'multiple files marked as git modified, only one file valid for scan' => [ + 'inputPaths' => $fakeFileList, + 'outputGitStaged' => [ + '.gitignore', + 'src/Standards/Generic/Docs/Classes/DuplicateClassNameStandard.xml', + 'src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php', + ], + 'expectedOutput' => [ + $basedir.'/src', + $basedir.'/src/Standards', + $basedir.'/src/Standards/Generic', + $basedir.'/src/Standards/Generic/Docs', + $basedir.'/src/Standards/Generic/Docs/Classes', + $basedir.'/src/Standards/Generic/Sniffs', + $basedir.'/src/Standards/Generic/Sniffs/Classes', + $basedir.'/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php', + ], + ], + + 'multiple files marked as git modified, multiple files valid for scan' => [ + 'inputPaths' => $fakeFileList, + 'outputGitStaged' => [ + '.yamllint.yml', + 'autoload.php', + 'src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php', + ], + 'expectedOutput' => [ + $basedir.'/autoload.php', + $basedir.'/src', + $basedir.'/src/Standards', + $basedir.'/src/Standards/Squiz', + $basedir.'/src/Standards/Squiz/Sniffs', + $basedir.'/src/Standards/Squiz/Sniffs/WhiteSpace', + $basedir.'/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php', + $basedir.'/src/Standards/Squiz/Tests', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js', + $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php', + ], + ], + ]; + + return $testCases; + + }//end dataAcceptOnlyGitStaged() + + + /** + * Test filtering a file list for excluded paths. + * + * @param string $cmd Command to run. + * @param array $expected Expected return value. + * + * @dataProvider dataExecAlwaysReturnsArray + * + * @return void + */ + public function testExecAlwaysReturnsArray($cmd, $expected) + { + $fakeDI = new RecursiveArrayIterator(self::getFakeFileList()); + $filter = new GitStaged($fakeDI, '/', self::$config, self::$ruleset); + + $reflMethod = new ReflectionMethod($filter, 'exec'); + $reflMethod->setAccessible(true); + $result = $reflMethod->invoke($filter, $cmd); + + $this->assertSame($expected, $result); + + }//end testExecAlwaysReturnsArray() + + + /** + * Data provider. + * + * @see testExecAlwaysReturnsArray + * + * {@internal Missing: test with a command which yields a `false` return value. + * JRF: I've not managed to find a command which does so, let alone one, which then + * doesn't have side-effects of uncatchable output while running the tests.} + * + * @return array>> + */ + public static function dataExecAlwaysReturnsArray() + { + return [ + 'valid command which won\'t have any output unless files in the bin dir have been modified & staged' => [ + // Largely using the command used in the filter, but only checking the bin dir. + // This should prevent the test unexpectedly failing during local development (in most cases). + 'cmd' => 'git diff --cached --name-only -- '.escapeshellarg(self::getBaseDir().'/bin'), + 'expected' => [], + ], + 'valid command which will have output' => [ + 'cmd' => 'git ls-files --exclude-standard -- '.escapeshellarg(self::getBaseDir().'/bin'), + 'expected' => [ + 'bin/phpcbf', + 'bin/phpcbf.bat', + 'bin/phpcs', + 'bin/phpcs.bat', + ], + ], + ]; + + }//end dataExecAlwaysReturnsArray() + + +}//end class From 181e2abed876d21b7f7d2adb8b05f0074aae3ccc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 31 Dec 2023 07:58:20 +0100 Subject: [PATCH 197/874] Filters/ExactMatch: rename some private properties Remove the needless use of culturally insensitive blacklist/whitelist terminology used in the property names and the documentation. As these properties are `private`, this is a change which doesn't affect the API and is therefore non-breaking. --- src/Filters/ExactMatch.php | 40 ++++++++++++++++++------------------- src/Filters/GitModified.php | 4 ++-- src/Filters/GitStaged.php | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Filters/ExactMatch.php b/src/Filters/ExactMatch.php index 38a2f05bb8..ce04e02bcd 100644 --- a/src/Filters/ExactMatch.php +++ b/src/Filters/ExactMatch.php @@ -2,7 +2,7 @@ /** * An abstract filter class for checking files and folders against exact matches. * - * Supports both whitelists and blacklists. + * Supports both allowed files and blocked files. * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -21,22 +21,22 @@ abstract class ExactMatch extends Filter * * @var array */ - private $blacklist = null; + private $blockedFiles = null; /** * A list of files to include. * - * If the whitelist is empty, only files in the blacklist will be excluded. + * If the allowed files list is empty, only files in the blocked files list will be excluded. * * @var array */ - private $whitelist = null; + private $allowedFiles = null; /** * Check whether the current element of the iterator is acceptable. * - * If a file is both blacklisted and whitelisted, it will be deemed unacceptable. + * If a file is both blocked and allowed, it will be deemed unacceptable. * * @return bool */ @@ -46,27 +46,27 @@ public function accept() return false; } - if ($this->blacklist === null) { - $this->blacklist = $this->getblacklist(); + if ($this->blockedFiles === null) { + $this->blockedFiles = $this->getblacklist(); } - if ($this->whitelist === null) { - $this->whitelist = $this->getwhitelist(); + if ($this->allowedFiles === null) { + $this->allowedFiles = $this->getwhitelist(); } $filePath = Util\Common::realpath($this->current()); - // If file is both blacklisted and whitelisted, the blacklist takes precedence. - if (isset($this->blacklist[$filePath]) === true) { + // If file is both blocked and allowed, the blocked files list takes precedence. + if (isset($this->blockedFiles[$filePath]) === true) { return false; } - if (empty($this->whitelist) === true && empty($this->blacklist) === false) { - // We are only checking a blacklist, so everything else should be whitelisted. + if (empty($this->allowedFiles) === true && empty($this->blockedFiles) === false) { + // We are only checking a blocked files list, so everything else should be allowed. return true; } - return isset($this->whitelist[$filePath]); + return isset($this->allowedFiles[$filePath]); }//end accept() @@ -74,23 +74,23 @@ public function accept() /** * Returns an iterator for the current entry. * - * Ensures that the blacklist and whitelist are preserved so they don't have + * Ensures that the blocked files list and the allowed files list are preserved so they don't have * to be generated each time. * * @return \RecursiveIterator */ public function getChildren() { - $children = parent::getChildren(); - $children->blacklist = $this->blacklist; - $children->whitelist = $this->whitelist; + $children = parent::getChildren(); + $children->blockedFiles = $this->blockedFiles; + $children->allowedFiles = $this->allowedFiles; return $children; }//end getChildren() /** - * Get a list of blacklisted file paths. + * Get a list of file paths to exclude. * * @return array */ @@ -98,7 +98,7 @@ abstract protected function getBlacklist(); /** - * Get a list of whitelisted file paths. + * Get a list of file paths to include. * * @return array */ diff --git a/src/Filters/GitModified.php b/src/Filters/GitModified.php index b946577909..3395e06d8a 100644 --- a/src/Filters/GitModified.php +++ b/src/Filters/GitModified.php @@ -16,7 +16,7 @@ class GitModified extends ExactMatch /** - * Get a list of blacklisted file paths. + * Get a list of file paths to exclude. * * @return array */ @@ -28,7 +28,7 @@ protected function getBlacklist() /** - * Get a list of whitelisted file paths. + * Get a list of file paths to include. * * @return array */ diff --git a/src/Filters/GitStaged.php b/src/Filters/GitStaged.php index 405387ff87..94c91940b2 100644 --- a/src/Filters/GitStaged.php +++ b/src/Filters/GitStaged.php @@ -18,7 +18,7 @@ class GitStaged extends ExactMatch /** - * Get a list of blacklisted file paths. + * Get a list of file paths to exclude. * * @return array */ @@ -30,7 +30,7 @@ protected function getBlacklist() /** - * Get a list of whitelisted file paths. + * Get a list of file paths to include. * * @return array */ From e629d7f2b05885bee179b269b17b3febec862bd3 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 31 Dec 2023 10:29:53 +0100 Subject: [PATCH 198/874] GH Actions: downgrade actions/[upload|download]-artifact back from 4 to 3 I'm getting sick and tired of having to restart builds due to artifacts not downloading correctly. This bug has been reported to the action runner and upgrading to v4 should not be re-attempted until the issue has been resolved. Effectively reverts Dependabot PR 172 (and 173). Ref: actions/download-artifact 249 --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 71d8f0c2ec..2527c4b8bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,7 +38,7 @@ jobs: run: php scripts/build-phar.php - name: Upload the PHPCS phar - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: phpcs-phar path: ./phpcs.phar @@ -46,7 +46,7 @@ jobs: retention-days: 28 - name: Upload the PHPCBF phar - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: phpcbf-phar path: ./phpcbf.phar @@ -163,7 +163,7 @@ jobs: - name: Download the PHPCS phar if: ${{ matrix.custom_ini == false }} - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: name: phpcs-phar From c1cefb8c774abde23bd5c004bc4a1fb5334184ff Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 01:36:32 +0000 Subject: [PATCH 199/874] Squiz/FileComment: update year in test case fixed file --- .../Squiz/Tests/Commenting/FileCommentUnitTest.1.inc.fixed | 2 +- .../Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.inc.fixed b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.inc.fixed index 3bcd945388..f584c55276 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.inc.fixed @@ -25,7 +25,7 @@ * @author * @copyright 1997 Squiz Pty Ltd (ABN 77 084 670 600) * @copyright 1994-1997 Squiz Pty Ltd (ABN 77 084 670 600) -* @copyright 2023 Squiz Pty Ltd (ABN 77 084 670 600) +* @copyright 2024 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://www.php.net/license/3_0.txt * @summary An unknown summary tag * diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed index 56a392d985..c7f54ffdf9 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed @@ -25,7 +25,7 @@ * @author * @copyright 1997 Squiz Pty Ltd (ABN 77 084 670 600) * @copyright 1994-1997 Squiz Pty Ltd (ABN 77 084 670 600) -* @copyright 2023 Squiz Pty Ltd (ABN 77 084 670 600) +* @copyright 2024 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://www.php.net/license/3_0.txt * @summary An unknown summary tag * From ebb6b37c2329f58ac71014aaa8ce2cb830e6d6c1 Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Fri, 10 Feb 2023 16:41:58 +0100 Subject: [PATCH 200/874] Squiz/VariableComment: allow union and intersection types to be detected If one uses a union type for an object property, the doc-type-hint could not be related to the variable type. Fixed now. Includes unit test. --- .../Commenting/VariableCommentSniff.php | 22 ++++++++++--------- .../Commenting/VariableCommentUnitTest.inc | 16 ++++++++++++++ .../VariableCommentUnitTest.inc.fixed | 16 ++++++++++++++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php index d2d53e2c3b..f7599c779b 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php @@ -30,16 +30,18 @@ public function processMemberVar(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $ignore = [ - T_PUBLIC => T_PUBLIC, - T_PRIVATE => T_PRIVATE, - T_PROTECTED => T_PROTECTED, - T_VAR => T_VAR, - T_STATIC => T_STATIC, - T_READONLY => T_READONLY, - T_WHITESPACE => T_WHITESPACE, - T_STRING => T_STRING, - T_NS_SEPARATOR => T_NS_SEPARATOR, - T_NULLABLE => T_NULLABLE, + T_PUBLIC => T_PUBLIC, + T_PRIVATE => T_PRIVATE, + T_PROTECTED => T_PROTECTED, + T_VAR => T_VAR, + T_STATIC => T_STATIC, + T_READONLY => T_READONLY, + T_WHITESPACE => T_WHITESPACE, + T_STRING => T_STRING, + T_NS_SEPARATOR => T_NS_SEPARATOR, + T_NULLABLE => T_NULLABLE, + T_TYPE_UNION => T_TYPE_UNION, + T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, ]; for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) { diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc index 36efc443bf..928022498a 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc @@ -402,3 +402,19 @@ class ReadOnlyProps private readonly string $variable; } + +class UnionTypes +{ + /** + * @var array|boolean + */ + private array|bool $variableName = array(); +} + +class IntersectionTypes +{ + /** + * @var \Iterator|\Countable + */ + private \Iterator&\Countable $variableName; +} diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed index 5c652f5402..2666c7c553 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed @@ -402,3 +402,19 @@ class ReadOnlyProps private readonly string $variable; } + +class UnionTypes +{ + /** + * @var array|boolean + */ + private array|bool $variableName = array(); +} + +class IntersectionTypes +{ + /** + * @var \Iterator|\Countable + */ + private \Iterator&\Countable $variableName; +} From 8472309837409c498c94909157daf1aa7e8321bc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 2 Jan 2024 09:18:53 +0100 Subject: [PATCH 201/874] Tests/AbstractMethodUnitTest: new `expectRunTimeException()` helper method This commit introduces a new `expectRunTimeException()` test helper method to allow for expecting a PHPCS native `PHP_CodeSniffer\Exceptions\RuntimeException` in a PHPUnit cross-version compatible manner. Includes implementation of the new method in the few test classes which currently need it (and which extend the `AbstractMethodUnitTest` class). --- tests/Core/AbstractMethodUnitTest.php | 24 +++++++++++++++++++++ tests/Core/File/GetClassPropertiesTest.php | 12 +---------- tests/Core/File/GetMemberPropertiesTest.php | 24 ++------------------- 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/tests/Core/AbstractMethodUnitTest.php b/tests/Core/AbstractMethodUnitTest.php index 21216fb684..ced92062f6 100644 --- a/tests/Core/AbstractMethodUnitTest.php +++ b/tests/Core/AbstractMethodUnitTest.php @@ -179,4 +179,28 @@ public function getTargetToken($commentString, $tokenType, $tokenContent=null) }//end getTargetToken() + /** + * Helper method to tell PHPUnit to expect a PHPCS RuntimeException in a PHPUnit cross-version + * compatible manner. + * + * @param string $message The expected exception message. + * + * @return void + */ + public function expectRunTimeException($message) + { + $exception = 'PHP_CodeSniffer\Exceptions\RuntimeException'; + + if (method_exists($this, 'expectException') === true) { + // PHPUnit 5+. + $this->expectException($exception); + $this->expectExceptionMessage($message); + } else { + // PHPUnit 4. + $this->setExpectedException($exception, $message); + } + + }//end expectRunTimeException() + + }//end class diff --git a/tests/Core/File/GetClassPropertiesTest.php b/tests/Core/File/GetClassPropertiesTest.php index d7dfce8585..17d5216040 100644 --- a/tests/Core/File/GetClassPropertiesTest.php +++ b/tests/Core/File/GetClassPropertiesTest.php @@ -32,17 +32,7 @@ class GetClassPropertiesTest extends AbstractMethodUnitTest */ public function testNotAClassException($testMarker, $tokenType) { - $msg = '$stackPtr must be of type T_CLASS'; - $exception = 'PHP_CodeSniffer\Exceptions\RuntimeException'; - - if (\method_exists($this, 'expectException') === true) { - // PHPUnit 5+. - $this->expectException($exception); - $this->expectExceptionMessage($msg); - } else { - // PHPUnit 4. - $this->setExpectedException($exception, $msg); - } + $this->expectRunTimeException('$stackPtr must be of type T_CLASS'); $target = $this->getTargetToken($testMarker, $tokenType); self::$phpcsFile->getClassProperties($target); diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index 4ef08b168b..36bf4d7d3e 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -870,17 +870,7 @@ public function dataGetMemberProperties() */ public function testNotClassPropertyException($identifier) { - $msg = '$stackPtr is not a class member var'; - $exception = 'PHP_CodeSniffer\Exceptions\RuntimeException'; - - if (\method_exists($this, 'expectException') === true) { - // PHPUnit 5+. - $this->expectException($exception); - $this->expectExceptionMessage($msg); - } else { - // PHPUnit 4. - $this->setExpectedException($exception, $msg); - } + $this->expectRunTimeException('$stackPtr is not a class member var'); $variable = $this->getTargetToken($identifier, T_VARIABLE); $result = self::$phpcsFile->getMemberProperties($variable); @@ -917,17 +907,7 @@ public function dataNotClassProperty() */ public function testNotAVariableException() { - $msg = '$stackPtr must be of type T_VARIABLE'; - $exception = 'PHP_CodeSniffer\Exceptions\RuntimeException'; - - if (\method_exists($this, 'expectException') === true) { - // PHPUnit 5+. - $this->expectException($exception); - $this->expectExceptionMessage($msg); - } else { - // PHPUnit 4. - $this->setExpectedException($exception, $msg); - } + $this->expectRunTimeException('$stackPtr must be of type T_VARIABLE'); $next = $this->getTargetToken('/* testNotAVariable */', T_RETURN); $result = self::$phpcsFile->getMemberProperties($next); From 976547dbc5997bcc570ec31b4532111cdd10a2f7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 09:24:45 +0100 Subject: [PATCH 202/874] Tests/FindExtendedClassNameTest: improve test markers Make the test marker names more descriptive --- tests/Core/File/FindExtendedClassNameTest.inc | 10 +++++----- tests/Core/File/FindExtendedClassNameTest.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/Core/File/FindExtendedClassNameTest.inc b/tests/Core/File/FindExtendedClassNameTest.inc index aead06cd9d..cbbec87f60 100644 --- a/tests/Core/File/FindExtendedClassNameTest.inc +++ b/tests/Core/File/FindExtendedClassNameTest.inc @@ -4,22 +4,22 @@ namespace PHP_CodeSniffer\Tests\Core\File; class testFECNClass {} -/* testExtendedClass */ +/* testExtendsUnqualifiedClass */ class testFECNExtendedClass extends testFECNClass {} -/* testNamespacedClass */ +/* testExtendsFullyQualifiedClass */ class testFECNNamespacedClass extends \PHP_CodeSniffer\Tests\Core\File\testFECNClass {} /* testNonExtendedClass */ class testFECNNonExtendedClass {} -/* testInterface */ +/* testNonExtendedInterface */ interface testFECNInterface {} -/* testInterfaceThatExtendsInterface */ +/* testInterfaceExtendsUnqualifiedInterface */ interface testInterfaceThatExtendsInterface extends testFECNInterface{} -/* testInterfaceThatExtendsFQCNInterface */ +/* testInterfaceExtendsFullyQualifiedInterface */ interface testInterfaceThatExtendsFQCNInterface extends \PHP_CodeSniffer\Tests\Core\File\testFECNInterface{} /* testNestedExtendedClass */ diff --git a/tests/Core/File/FindExtendedClassNameTest.php b/tests/Core/File/FindExtendedClassNameTest.php index c54b9cc120..9246742ef6 100644 --- a/tests/Core/File/FindExtendedClassNameTest.php +++ b/tests/Core/File/FindExtendedClassNameTest.php @@ -51,11 +51,11 @@ public function dataExtendedClass() { return [ [ - '/* testExtendedClass */', + '/* testExtendsUnqualifiedClass */', 'testFECNClass', ], [ - '/* testNamespacedClass */', + '/* testExtendsFullyQualifiedClass */', '\PHP_CodeSniffer\Tests\Core\File\testFECNClass', ], [ @@ -63,15 +63,15 @@ public function dataExtendedClass() false, ], [ - '/* testInterface */', + '/* testNonExtendedInterface */', false, ], [ - '/* testInterfaceThatExtendsInterface */', + '/* testInterfaceExtendsUnqualifiedInterface */', 'testFECNInterface', ], [ - '/* testInterfaceThatExtendsFQCNInterface */', + '/* testInterfaceExtendsFullyQualifiedInterface */', '\PHP_CodeSniffer\Tests\Core\File\testFECNInterface', ], [ From f627f0e58e2c4bbd399707b2905d6f275020c91a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 09:11:24 +0100 Subject: [PATCH 203/874] Tests/FindExtendedClassNameTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes fixing the data types in the docblocks and making them more specific, where relevant. --- tests/Core/File/FindExtendedClassNameTest.php | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/Core/File/FindExtendedClassNameTest.php b/tests/Core/File/FindExtendedClassNameTest.php index 9246742ef6..0ba6c47927 100644 --- a/tests/Core/File/FindExtendedClassNameTest.php +++ b/tests/Core/File/FindExtendedClassNameTest.php @@ -24,8 +24,8 @@ class FindExtendedClassNameTest extends AbstractMethodUnitTest * Test retrieving the name of the class being extended by another class * (or interface). * - * @param string $identifier Comment which precedes the test case. - * @param bool $expected Expected function output. + * @param string $identifier Comment which precedes the test case. + * @param string|false $expected Expected function output. * * @dataProvider dataExtendedClass * @@ -45,50 +45,50 @@ public function testFindExtendedClassName($identifier, $expected) * * @see testFindExtendedClassName() * - * @return array + * @return array> */ public function dataExtendedClass() { return [ - [ - '/* testExtendsUnqualifiedClass */', - 'testFECNClass', + 'class extends unqualified class' => [ + 'identifier' => '/* testExtendsUnqualifiedClass */', + 'expected' => 'testFECNClass', ], - [ - '/* testExtendsFullyQualifiedClass */', - '\PHP_CodeSniffer\Tests\Core\File\testFECNClass', + 'class extends fully qualified class' => [ + 'identifier' => '/* testExtendsFullyQualifiedClass */', + 'expected' => '\PHP_CodeSniffer\Tests\Core\File\testFECNClass', ], - [ - '/* testNonExtendedClass */', - false, + 'class does not extend' => [ + 'identifier' => '/* testNonExtendedClass */', + 'expected' => false, ], - [ - '/* testNonExtendedInterface */', - false, + 'interface does not extend' => [ + 'identifier' => '/* testNonExtendedInterface */', + 'expected' => false, ], - [ - '/* testInterfaceExtendsUnqualifiedInterface */', - 'testFECNInterface', + 'interface extends unqualified interface' => [ + 'identifier' => '/* testInterfaceExtendsUnqualifiedInterface */', + 'expected' => 'testFECNInterface', ], - [ - '/* testInterfaceExtendsFullyQualifiedInterface */', - '\PHP_CodeSniffer\Tests\Core\File\testFECNInterface', + 'interface extends fully qualified interface' => [ + 'identifier' => '/* testInterfaceExtendsFullyQualifiedInterface */', + 'expected' => '\PHP_CodeSniffer\Tests\Core\File\testFECNInterface', ], - [ - '/* testNestedExtendedClass */', - false, + 'class does not extend but contains anon class which extends' => [ + 'identifier' => '/* testNestedExtendedClass */', + 'expected' => false, ], - [ - '/* testNestedExtendedAnonClass */', - 'testFECNAnonClass', + 'anon class extends, nested in non-extended class' => [ + 'identifier' => '/* testNestedExtendedAnonClass */', + 'expected' => 'testFECNAnonClass', ], - [ - '/* testClassThatExtendsAndImplements */', - 'testFECNClass', + 'class extends and implements' => [ + 'identifier' => '/* testClassThatExtendsAndImplements */', + 'expected' => 'testFECNClass', ], - [ - '/* testClassThatImplementsAndExtends */', - 'testFECNClass', + 'class implements and extends' => [ + 'identifier' => '/* testClassThatImplementsAndExtends */', + 'expected' => 'testFECNClass', ], ]; From 92ca078a5283b63f649d6bd0e03c6a9e2ff740aa Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 09:52:41 +0100 Subject: [PATCH 204/874] Tests/FindExtendedClassNameTest: add extra tests This adds some extra tests which were already in use in PHPCSUtils. This brings test coverage for this method up to 100%. It also cleans up the test case file a little by removing some code which isn't actually used in the tests (namespace declaration) and moves the "class not extended" test up. --- tests/Core/File/FindExtendedClassNameTest.inc | 23 ++++++-- tests/Core/File/FindExtendedClassNameTest.php | 53 +++++++++++++++++-- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/tests/Core/File/FindExtendedClassNameTest.inc b/tests/Core/File/FindExtendedClassNameTest.inc index cbbec87f60..dae2cd9692 100644 --- a/tests/Core/File/FindExtendedClassNameTest.inc +++ b/tests/Core/File/FindExtendedClassNameTest.inc @@ -1,8 +1,10 @@ findExtendedClassName(100000); + $this->assertFalse($result); + + }//end testNonExistentToken() + + + /** + * Test getting a `false` result when a token other than one of the supported tokens is passed. + * + * @return void + */ + public function testNotAClass() + { + $token = $this->getTargetToken('/* testNotAClass */', [T_FUNCTION]); + $result = self::$phpcsFile->findExtendedClassName($token); + $this->assertFalse($result); + + }//end testNotAClass() + + /** * Test retrieving the name of the class being extended by another class * (or interface). @@ -50,6 +77,10 @@ public function testFindExtendedClassName($identifier, $expected) public function dataExtendedClass() { return [ + 'class does not extend' => [ + 'identifier' => '/* testNonExtendedClass */', + 'expected' => false, + ], 'class extends unqualified class' => [ 'identifier' => '/* testExtendsUnqualifiedClass */', 'expected' => 'testFECNClass', @@ -58,9 +89,9 @@ public function dataExtendedClass() 'identifier' => '/* testExtendsFullyQualifiedClass */', 'expected' => '\PHP_CodeSniffer\Tests\Core\File\testFECNClass', ], - 'class does not extend' => [ - 'identifier' => '/* testNonExtendedClass */', - 'expected' => false, + 'class extends partially qualified class' => [ + 'identifier' => '/* testExtendsPartiallyQualifiedClass */', + 'expected' => 'Core\File\RelativeClass', ], 'interface does not extend' => [ 'identifier' => '/* testNonExtendedInterface */', @@ -74,6 +105,10 @@ public function dataExtendedClass() 'identifier' => '/* testInterfaceExtendsFullyQualifiedInterface */', 'expected' => '\PHP_CodeSniffer\Tests\Core\File\testFECNInterface', ], + 'anon class extends unqualified class' => [ + 'identifier' => '/* testExtendedAnonClass */', + 'expected' => 'testFECNExtendedAnonClass', + ], 'class does not extend but contains anon class which extends' => [ 'identifier' => '/* testNestedExtendedClass */', 'expected' => false, @@ -90,6 +125,18 @@ public function dataExtendedClass() 'identifier' => '/* testClassThatImplementsAndExtends */', 'expected' => 'testFECNClass', ], + 'interface extends multiple interfaces (not supported)' => [ + 'identifier' => '/* testInterfaceMultiExtends */', + 'expected' => '\Package\FooInterface', + ], + 'parse error - extends keyword, but no class name' => [ + 'identifier' => '/* testMissingExtendsName */', + 'expected' => false, + ], + 'parse error - live coding - no curly braces' => [ + 'identifier' => '/* testParseError */', + 'expected' => false, + ], ]; }//end dataExtendedClass() From 623dedad1115eb569ff263e5e7e53188157f8770 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 21:13:38 +0100 Subject: [PATCH 205/874] Tests/FindImplementedInterfaceNamesTest: improve test markers Make the test marker names more descriptive --- .../Core/File/FindImplementedInterfaceNamesTest.inc | 12 ++++++------ .../Core/File/FindImplementedInterfaceNamesTest.php | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.inc b/tests/Core/File/FindImplementedInterfaceNamesTest.inc index 44c0f64321..0974f10d00 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.inc +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.inc @@ -4,16 +4,16 @@ namespace PHP_CodeSniffer\Tests\Core\File; interface testFIINInterface2 {} -/* testInterface */ +/* testPlainInterface */ interface testFIINInterface {} -/* testImplementedClass */ +/* testClassImplementsSingle */ class testFIINImplementedClass implements testFIINInterface {} -/* testMultiImplementedClass */ +/* testClassImplementsMultiple */ class testFIINMultiImplementedClass implements testFIINInterface, testFIINInterface2 {} -/* testNamespacedClass */ +/* testImplementsFullyQualified */ class testFIINNamespacedClass implements \PHP_CodeSniffer\Tests\Core\File\testFIINInterface {} /* testNonImplementedClass */ @@ -28,8 +28,8 @@ class testFECNClassThatImplementsAndExtends implements \InterfaceA, InterfaceB e /* testBackedEnumWithoutImplements */ enum Suit:string {} -/* testEnumImplements */ +/* testEnumImplementsSingle */ enum Suit implements Colorful {} -/* testBackedEnumImplements */ +/* testBackedEnumImplementsMulti */ enum Suit: string implements Colorful, \Deck {} diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.php b/tests/Core/File/FindImplementedInterfaceNamesTest.php index 6e04805efb..795645c58a 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.php +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.php @@ -50,18 +50,18 @@ public function dataImplementedInterface() { return [ [ - '/* testImplementedClass */', + '/* testClassImplementsSingle */', ['testFIINInterface'], ], [ - '/* testMultiImplementedClass */', + '/* testClassImplementsMultiple */', [ 'testFIINInterface', 'testFIINInterface2', ], ], [ - '/* testNamespacedClass */', + '/* testImplementsFullyQualified */', ['\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'], ], [ @@ -69,7 +69,7 @@ public function dataImplementedInterface() false, ], [ - '/* testInterface */', + '/* testPlainInterface */', false, ], [ @@ -91,11 +91,11 @@ public function dataImplementedInterface() false, ], [ - '/* testEnumImplements */', + '/* testEnumImplementsSingle */', ['Colorful'], ], [ - '/* testBackedEnumImplements */', + '/* testBackedEnumImplementsMulti */', [ 'Colorful', '\Deck', From d997e9c67e0941e409d1a563f5632b7dccee96f9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 21:25:50 +0100 Subject: [PATCH 206/874] Tests/FindImplementedInterfaceNamesTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes fixing the data types in the docblocks and making them more specific, where relevant. --- .../FindImplementedInterfaceNamesTest.php | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.php b/tests/Core/File/FindImplementedInterfaceNamesTest.php index 795645c58a..47b08cc98d 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.php +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.php @@ -23,8 +23,8 @@ class FindImplementedInterfaceNamesTest extends AbstractMethodUnitTest /** * Test retrieving the name(s) of the interfaces being implemented by a class. * - * @param string $identifier Comment which precedes the test case. - * @param bool $expected Expected function output. + * @param string $identifier Comment which precedes the test case. + * @param array|false $expected Expected function output. * * @dataProvider dataImplementedInterface * @@ -44,59 +44,59 @@ public function testFindImplementedInterfaceNames($identifier, $expected) * * @see testFindImplementedInterfaceNames() * - * @return array + * @return array>> */ public function dataImplementedInterface() { return [ - [ - '/* testClassImplementsSingle */', - ['testFIINInterface'], + 'class implements single interface, unqualified' => [ + 'identifier' => '/* testClassImplementsSingle */', + 'expected' => ['testFIINInterface'], ], - [ - '/* testClassImplementsMultiple */', - [ + 'class implements multiple interfaces' => [ + 'identifier' => '/* testClassImplementsMultiple */', + 'expected' => [ 'testFIINInterface', 'testFIINInterface2', ], ], - [ - '/* testImplementsFullyQualified */', - ['\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'], + 'class implements single interface, fully qualified' => [ + 'identifier' => '/* testImplementsFullyQualified */', + 'expected' => ['\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'], ], - [ - '/* testNonImplementedClass */', - false, + 'class does not implement' => [ + 'identifier' => '/* testNonImplementedClass */', + 'expected' => false, ], - [ - '/* testPlainInterface */', - false, + 'interface declaration, no implements' => [ + 'identifier' => '/* testPlainInterface */', + 'expected' => false, ], - [ - '/* testClassThatExtendsAndImplements */', - [ + 'class extends and implements' => [ + 'identifier' => '/* testClassThatExtendsAndImplements */', + 'expected' => [ 'InterfaceA', '\NameSpaced\Cat\InterfaceB', ], ], - [ - '/* testClassThatImplementsAndExtends */', - [ + 'class implements and extends' => [ + 'identifier' => '/* testClassThatImplementsAndExtends */', + 'expected' => [ '\InterfaceA', 'InterfaceB', ], ], - [ - '/* testBackedEnumWithoutImplements */', - false, + 'enum does not implement' => [ + 'identifier' => '/* testBackedEnumWithoutImplements */', + 'expected' => false, ], - [ - '/* testEnumImplementsSingle */', - ['Colorful'], + 'enum implements single interface, unqualified' => [ + 'identifier' => '/* testEnumImplementsSingle */', + 'expected' => ['Colorful'], ], - [ - '/* testBackedEnumImplementsMulti */', - [ + 'enum implements multiple interfaces, unqualified + fully qualified' => [ + 'identifier' => '/* testBackedEnumImplementsMulti */', + 'expected' => [ 'Colorful', '\Deck', ], From f3ef81c4ac04f1135954b9fb890cf02ae7542403 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 21:44:18 +0100 Subject: [PATCH 207/874] Tests/FindImplementedInterfaceNamesTest: add extra tests This adds some extra tests which were already in use in PHPCSUtils. This brings test coverage for this method up to 100%. It also cleans up the test case file a little by removing some code which isn't actually used in the tests (namespace declaration) and moves the "class not implementing" test up. --- .../FindImplementedInterfaceNamesTest.inc | 22 +++++-- .../FindImplementedInterfaceNamesTest.php | 57 ++++++++++++++++--- 2 files changed, 67 insertions(+), 12 deletions(-) diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.inc b/tests/Core/File/FindImplementedInterfaceNamesTest.inc index 0974f10d00..3246efa2ce 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.inc +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.inc @@ -1,12 +1,14 @@ findImplementedInterfaceNames(100000); + $this->assertFalse($result); + + }//end testNonExistentToken() + + + /** + * Test getting a `false` result when a token other than one of the supported tokens is passed. + * + * @return void + */ + public function testNotAClass() + { + $token = $this->getTargetToken('/* testNotAClass */', [T_FUNCTION]); + $result = self::$phpcsFile->findImplementedInterfaceNames($token); + $this->assertFalse($result); + + }//end testNotAClass() + + /** * Test retrieving the name(s) of the interfaces being implemented by a class. * @@ -49,6 +76,14 @@ public function testFindImplementedInterfaceNames($identifier, $expected) public function dataImplementedInterface() { return [ + 'interface declaration, no implements' => [ + 'identifier' => '/* testPlainInterface */', + 'expected' => false, + ], + 'class does not implement' => [ + 'identifier' => '/* testNonImplementedClass */', + 'expected' => false, + ], 'class implements single interface, unqualified' => [ 'identifier' => '/* testClassImplementsSingle */', 'expected' => ['testFIINInterface'], @@ -64,13 +99,9 @@ public function dataImplementedInterface() 'identifier' => '/* testImplementsFullyQualified */', 'expected' => ['\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'], ], - 'class does not implement' => [ - 'identifier' => '/* testNonImplementedClass */', - 'expected' => false, - ], - 'interface declaration, no implements' => [ - 'identifier' => '/* testPlainInterface */', - 'expected' => false, + 'class implements single interface, partially qualified' => [ + 'identifier' => '/* testImplementsPartiallyQualified */', + 'expected' => ['Core\File\RelativeInterface'], ], 'class extends and implements' => [ 'identifier' => '/* testClassThatExtendsAndImplements */', @@ -101,6 +132,18 @@ public function dataImplementedInterface() '\Deck', ], ], + 'anon class implements single interface, unqualified' => [ + 'identifier' => '/* testAnonClassImplementsSingle */', + 'expected' => ['testFIINInterface'], + ], + 'parse error - implements keyword, but no interface name' => [ + 'identifier' => '/* testMissingImplementsName */', + 'expected' => false, + ], + 'parse error - live coding - no curly braces' => [ + 'identifier' => '/* testParseError */', + 'expected' => false, + ], ]; }//end dataImplementedInterface() From acdca48777a2ac8e3751ba94fadb89508018bdeb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 2 Jan 2024 10:23:17 +0100 Subject: [PATCH 208/874] Tests/FindStartOfStatementTest: add extra tests This adds some extra tests which were already in use in PHPCSUtils. --- tests/Core/File/FindStartOfStatementTest.inc | 41 ++++++ tests/Core/File/FindStartOfStatementTest.php | 132 +++++++++++++++++++ 2 files changed, 173 insertions(+) diff --git a/tests/Core/File/FindStartOfStatementTest.inc b/tests/Core/File/FindStartOfStatementTest.inc index ce9dfad3f9..148d8103a5 100644 --- a/tests/Core/File/FindStartOfStatementTest.inc +++ b/tests/Core/File/FindStartOfStatementTest.inc @@ -121,3 +121,44 @@ return 0; ?>

Test

', foo(), ''; + +$value = [ + /* testPrecededByArrowFunctionInArray - Expected */ + Url::make('View Song', fn($song) => $song->url()) + /* testPrecededByArrowFunctionInArray */ + ->onlyOnDetail(), + + new Panel('Information', [ + Text::make('Title') + ]), +]; + +switch ($foo) { + /* testCaseStatement */ + case 1: + /* testInsideCaseStatement */ + $var = doSomething(); + /* testInsideCaseBreakStatement */ + break 2; + + case 2: + /* testInsideCaseContinueStatement */ + continue 2; + + case 3: + /* testInsideCaseReturnStatement */ + return false; + + case 4: + /* testInsideCaseExitStatement */ + exit(1); + + case 5: + /* testInsideCaseThrowStatement */ + throw new Exception(); + + /* testDefaultStatement */ + default: + /* testInsideDefaultContinueStatement */ + continue $var; +} diff --git a/tests/Core/File/FindStartOfStatementTest.php b/tests/Core/File/FindStartOfStatementTest.php index 25b7f6aa73..334d05b2b3 100644 --- a/tests/Core/File/FindStartOfStatementTest.php +++ b/tests/Core/File/FindStartOfStatementTest.php @@ -3,7 +3,9 @@ * Tests for the \PHP_CodeSniffer\Files\File:findStartOfStatement method. * * @author Greg Sherwood + * @author Juliette Reinders Folmer * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) + * @copyright 2019-2024 PHPCSStandards Contributors * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ @@ -505,4 +507,134 @@ public function testOpenTagWithEcho() }//end testOpenTagWithEcho() + /** + * Test object call on result of static function call with arrow function as parameter and wrapped within an array. + * + * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/2849 + * @link https://github.com/squizlabs/PHP_CodeSniffer/commit/fbf67efc3fc0c2a355f5585d49f4f6fe160ff2f9 + * + * @return void + */ + public function testObjectCallPrecededByArrowFunctionAsFunctionCallParameterInArray() + { + $expected = $this->getTargetToken('/* testPrecededByArrowFunctionInArray - Expected */', T_STRING, 'Url'); + + $start = $this->getTargetToken('/* testPrecededByArrowFunctionInArray */', T_STRING, 'onlyOnDetail'); + $found = self::$phpcsFile->findStartOfStatement($start); + + $this->assertSame($expected, $found); + + }//end testObjectCallPrecededByArrowFunctionAsFunctionCallParameterInArray() + + + /** + * Test finding the start of a statement inside a switch control structure case/default statement. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int|string $targets The token to search for after the test marker. + * @param string|int $expectedTarget Token code of the expected start of statement stack pointer. + * + * @link https://github.com/squizlabs/php_codesniffer/issues/3192 + * @link https://github.com/squizlabs/PHP_CodeSniffer/pull/3186/commits/18a0e54735bb9b3850fec266e5f4c50dacf618ea + * + * @dataProvider dataFindStartInsideSwitchCaseDefaultStatements + * + * @return void + */ + public function testFindStartInsideSwitchCaseDefaultStatements($testMarker, $targets, $expectedTarget) + { + $testToken = $this->getTargetToken($testMarker, $targets); + $expected = $this->getTargetToken($testMarker, $expectedTarget); + + $found = self::$phpcsFile->findStartOfStatement($testToken); + + $this->assertSame($expected, $found); + + }//end testFindStartInsideSwitchCaseDefaultStatements() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataFindStartInsideSwitchCaseDefaultStatements() + { + return [ + 'Case keyword should be start of case statement - case itself' => [ + 'testMarker' => '/* testCaseStatement */', + 'targets' => T_CASE, + 'expectedTarget' => T_CASE, + ], + 'Case keyword should be start of case statement - number (what\'s being compared)' => [ + 'testMarker' => '/* testCaseStatement */', + 'targets' => T_LNUMBER, + 'expectedTarget' => T_CASE, + ], + 'Variable should be start of arbitrary assignment statement - variable itself' => [ + 'testMarker' => '/* testInsideCaseStatement */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_VARIABLE, + ], + 'Variable should be start of arbitrary assignment statement - equal sign' => [ + 'testMarker' => '/* testInsideCaseStatement */', + 'targets' => T_EQUAL, + 'expectedTarget' => T_VARIABLE, + ], + 'Variable should be start of arbitrary assignment statement - function call' => [ + 'testMarker' => '/* testInsideCaseStatement */', + 'targets' => T_STRING, + 'expectedTarget' => T_VARIABLE, + ], + 'Break should be start for contents of the break statement - contents' => [ + 'testMarker' => '/* testInsideCaseBreakStatement */', + 'targets' => T_LNUMBER, + 'expectedTarget' => T_BREAK, + ], + 'Continue should be start for contents of the continue statement - contents' => [ + 'testMarker' => '/* testInsideCaseContinueStatement */', + 'targets' => T_LNUMBER, + 'expectedTarget' => T_CONTINUE, + ], + 'Return should be start for contents of the return statement - contents' => [ + 'testMarker' => '/* testInsideCaseReturnStatement */', + 'targets' => T_FALSE, + 'expectedTarget' => T_RETURN, + ], + 'Exit should be start for contents of the exit statement - close parenthesis' => [ + // Note: not sure if this is actually correct - should this be the open parenthesis ? + 'testMarker' => '/* testInsideCaseExitStatement */', + 'targets' => T_CLOSE_PARENTHESIS, + 'expectedTarget' => T_EXIT, + ], + 'Throw should be start for contents of the throw statement - new keyword' => [ + 'testMarker' => '/* testInsideCaseThrowStatement */', + 'targets' => T_NEW, + 'expectedTarget' => T_THROW, + ], + 'Throw should be start for contents of the throw statement - exception name' => [ + 'testMarker' => '/* testInsideCaseThrowStatement */', + 'targets' => T_STRING, + 'expectedTarget' => T_THROW, + ], + 'Throw should be start for contents of the throw statement - close parenthesis' => [ + 'testMarker' => '/* testInsideCaseThrowStatement */', + 'targets' => T_CLOSE_PARENTHESIS, + 'expectedTarget' => T_THROW, + ], + 'Default keyword should be start of default statement - default itself' => [ + 'testMarker' => '/* testDefaultStatement */', + 'targets' => T_DEFAULT, + 'expectedTarget' => T_DEFAULT, + ], + 'Return should be start for contents of the return statement (inside default) - variable' => [ + 'testMarker' => '/* testInsideDefaultContinueStatement */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_CONTINUE, + ], + ]; + + }//end dataFindStartInsideSwitchCaseDefaultStatements() + + }//end class From 5630c3b7ea51a4d756b5f18e7169e6257340b2c8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 23:39:50 +0100 Subject: [PATCH 209/874] Tests/GetClassPropertiesTest: : minor improvements * Add parameter names as indexes in the data sets in data providers. * Improve type specificity in the docblocks. --- tests/Core/File/GetClassPropertiesTest.php | 68 +++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/Core/File/GetClassPropertiesTest.php b/tests/Core/File/GetClassPropertiesTest.php index 17d5216040..1cb963c4b1 100644 --- a/tests/Core/File/GetClassPropertiesTest.php +++ b/tests/Core/File/GetClassPropertiesTest.php @@ -23,8 +23,8 @@ class GetClassPropertiesTest extends AbstractMethodUnitTest /** * Test receiving an expected exception when a non class token is passed. * - * @param string $testMarker The comment which prefaces the target token in the test file. - * @param array $tokenType The type of token to look for after the marker. + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int|string $tokenType The type of token to look for after the marker. * * @dataProvider dataNotAClassException * @@ -45,22 +45,22 @@ public function testNotAClassException($testMarker, $tokenType) * * @see testNotAClassException() For the array format. * - * @return array + * @return array> */ public function dataNotAClassException() { return [ 'interface' => [ - '/* testNotAClass */', - \T_INTERFACE, + 'testMarker' => '/* testNotAClass */', + 'tokenType' => \T_INTERFACE, ], 'anon-class' => [ - '/* testAnonClass */', - \T_ANON_CLASS, + 'testMarker' => '/* testAnonClass */', + 'tokenType' => \T_ANON_CLASS, ], 'enum' => [ - '/* testEnum */', - \T_ENUM, + 'testMarker' => '/* testEnum */', + 'tokenType' => \T_ENUM, ], ]; @@ -70,8 +70,8 @@ public function dataNotAClassException() /** * Test retrieving the properties for a class declaration. * - * @param string $testMarker The comment which prefaces the target token in the test file. - * @param array $expected Expected function output. + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param array $expected Expected function output. * * @dataProvider dataGetClassProperties * @@ -91,94 +91,94 @@ public function testGetClassProperties($testMarker, $expected) * * @see testGetClassProperties() For the array format. * - * @return array + * @return array>> */ public function dataGetClassProperties() { return [ 'no-properties' => [ - '/* testClassWithoutProperties */', - [ + 'testMarker' => '/* testClassWithoutProperties */', + 'expected' => [ 'is_abstract' => false, 'is_final' => false, 'is_readonly' => false, ], ], 'abstract' => [ - '/* testAbstractClass */', - [ + 'testMarker' => '/* testAbstractClass */', + 'expected' => [ 'is_abstract' => true, 'is_final' => false, 'is_readonly' => false, ], ], 'final' => [ - '/* testFinalClass */', - [ + 'testMarker' => '/* testFinalClass */', + 'expected' => [ 'is_abstract' => false, 'is_final' => true, 'is_readonly' => false, ], ], 'readonly' => [ - '/* testReadonlyClass */', - [ + 'testMarker' => '/* testReadonlyClass */', + 'expected' => [ 'is_abstract' => false, 'is_final' => false, 'is_readonly' => true, ], ], 'final-readonly' => [ - '/* testFinalReadonlyClass */', - [ + 'testMarker' => '/* testFinalReadonlyClass */', + 'expected' => [ 'is_abstract' => false, 'is_final' => true, 'is_readonly' => true, ], ], 'readonly-final' => [ - '/* testReadonlyFinalClass */', - [ + 'testMarker' => '/* testReadonlyFinalClass */', + 'expected' => [ 'is_abstract' => false, 'is_final' => true, 'is_readonly' => true, ], ], 'abstract-readonly' => [ - '/* testAbstractReadonlyClass */', - [ + 'testMarker' => '/* testAbstractReadonlyClass */', + 'expected' => [ 'is_abstract' => true, 'is_final' => false, 'is_readonly' => true, ], ], 'readonly-abstract' => [ - '/* testReadonlyAbstractClass */', - [ + 'testMarker' => '/* testReadonlyAbstractClass */', + 'expected' => [ 'is_abstract' => true, 'is_final' => false, 'is_readonly' => true, ], ], 'comments-and-new-lines' => [ - '/* testWithCommentsAndNewLines */', - [ + 'testMarker' => '/* testWithCommentsAndNewLines */', + 'expected' => [ 'is_abstract' => true, 'is_final' => false, 'is_readonly' => false, ], ], 'no-properties-with-docblock' => [ - '/* testWithDocblockWithoutProperties */', - [ + 'testMarker' => '/* testWithDocblockWithoutProperties */', + 'expected' => [ 'is_abstract' => false, 'is_final' => false, 'is_readonly' => false, ], ], 'abstract-final-parse-error' => [ - '/* testParseErrorAbstractFinal */', - [ + 'testMarker' => '/* testParseErrorAbstractFinal */', + 'expected' => [ 'is_abstract' => true, 'is_final' => true, 'is_readonly' => false, From 842b42b9f662f55c7cef276c4cd2ddfbc2f3f9a4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 2 Jan 2024 08:36:19 +0100 Subject: [PATCH 210/874] File::[get|has]Conditions(): add tests This imports the tests which were already in use in PHPCSUtils into PHP_CodeSniffer. Includes a minor efficiency fix as the `isset()` check on the `'conditions'` key in the tokens array is non-effective as the `'conditions'` key is always set, but may be empty. The minor adjustment now made will allow the method to bow out early correctly. --- src/Files/File.php | 4 +- tests/Core/File/GetConditionTest.inc | 91 +++++ tests/Core/File/GetConditionTest.php | 494 +++++++++++++++++++++++++++ 3 files changed, 587 insertions(+), 2 deletions(-) create mode 100644 tests/Core/File/GetConditionTest.inc create mode 100644 tests/Core/File/GetConditionTest.php diff --git a/src/Files/File.php b/src/Files/File.php index 261ede44e7..7b54bea179 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -2718,7 +2718,7 @@ public function hasCondition($stackPtr, $types) } // Make sure the token has conditions. - if (isset($this->tokens[$stackPtr]['conditions']) === false) { + if (empty($this->tokens[$stackPtr]['conditions']) === true) { return false; } @@ -2759,7 +2759,7 @@ public function getCondition($stackPtr, $type, $first=true) } // Make sure the token has conditions. - if (isset($this->tokens[$stackPtr]['conditions']) === false) { + if (empty($this->tokens[$stackPtr]['conditions']) === true) { return false; } diff --git a/tests/Core/File/GetConditionTest.inc b/tests/Core/File/GetConditionTest.inc new file mode 100644 index 0000000000..e7684daa97 --- /dev/null +++ b/tests/Core/File/GetConditionTest.inc @@ -0,0 +1,91 @@ + $v) { + + /* condition 11-2: try */ + try { + --$k; + + /* condition 11-3: catch */ + } catch (Exception $e) { + /* testInException */ + echo 'oh darn'; + /* condition 11-4: finally */ + } finally { + return true; + } + } + + $a++; + } + break; + + /* condition 8b: default */ + default: + /* testInDefault */ + $return = 'nada'; + return $return; + } + } + } + } + } + } + } +} diff --git a/tests/Core/File/GetConditionTest.php b/tests/Core/File/GetConditionTest.php new file mode 100644 index 0000000000..e6b01192c5 --- /dev/null +++ b/tests/Core/File/GetConditionTest.php @@ -0,0 +1,494 @@ + + * @copyright 2022-2024 PHPCSStandards Contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\File; + +use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +use PHP_CodeSniffer\Util\Tokens; + +/** + * Tests for the \PHP_CodeSniffer\Files\File:getCondition and \PHP_CodeSniffer\Files\File:hasCondition methods. + * + * @covers \PHP_CodeSniffer\Files\File::getCondition + * @covers \PHP_CodeSniffer\Files\File::hasCondition + */ +class GetConditionTest extends AbstractMethodUnitTest +{ + + /** + * List of all the test markers with their target token in the test case file. + * + * - The startPoint token is left out as it is tested separately. + * - The key is the type of token to look for after the test marker. + * + * @var array + */ + protected static $testTargets = [ + T_VARIABLE => '/* testSeriouslyNestedMethod */', + T_RETURN => '/* testDeepestNested */', + T_ECHO => '/* testInException */', + T_CONSTANT_ENCAPSED_STRING => '/* testInDefault */', + ]; + + /** + * List of all the condition markers in the test case file. + * + * @var array + */ + protected $conditionMarkers = [ + '/* condition 0: namespace */', + '/* condition 1: if */', + '/* condition 2: function */', + '/* condition 3-1: if */', + '/* condition 3-2: else */', + '/* condition 4: if */', + '/* condition 5: nested class */', + '/* condition 6: class method */', + '/* condition 7: switch */', + '/* condition 8a: case */', + '/* condition 9: while */', + '/* condition 10-1: if */', + '/* condition 11-1: nested anonymous class */', + '/* condition 12: nested anonymous class method */', + '/* condition 13: closure */', + '/* condition 10-2: elseif */', + '/* condition 10-3: foreach */', + '/* condition 11-2: try */', + '/* condition 11-3: catch */', + '/* condition 11-4: finally */', + '/* condition 8b: default */', + ]; + + /** + * Base array with all the scope opening tokens. + * + * This array is merged with expected result arrays for various unit tests + * to make sure all possible conditions are tested. + * + * This array should be kept in sync with the Tokens::$scopeOpeners array. + * This array isn't auto-generated based on the array in Tokens as for these + * tests we want to have access to the token constant names, not just their values. + * + * @var array + */ + protected $conditionDefaults = [ + 'T_CLASS' => false, + 'T_ANON_CLASS' => false, + 'T_INTERFACE' => false, + 'T_TRAIT' => false, + 'T_NAMESPACE' => false, + 'T_FUNCTION' => false, + 'T_CLOSURE' => false, + 'T_IF' => false, + 'T_SWITCH' => false, + 'T_CASE' => false, + 'T_DECLARE' => false, + 'T_DEFAULT' => false, + 'T_WHILE' => false, + 'T_ELSE' => false, + 'T_ELSEIF' => false, + 'T_FOR' => false, + 'T_FOREACH' => false, + 'T_DO' => false, + 'T_TRY' => false, + 'T_CATCH' => false, + 'T_FINALLY' => false, + 'T_PROPERTY' => false, + 'T_OBJECT' => false, + 'T_USE' => false, + ]; + + /** + * Cache for the test token stack pointers. + * + * @var array + */ + protected static $testTokens = []; + + /** + * Cache for the marker token stack pointers. + * + * @var array + */ + protected static $markerTokens = []; + + + /** + * Set up the token position caches for the tests. + * + * Retrieves the test tokens and marker token stack pointer positions + * only once and caches them as they won't change between the tests anyway. + * + * @before + * + * @return void + */ + protected function setUpCaches() + { + if (empty(self::$testTokens) === true) { + foreach (self::$testTargets as $targetToken => $marker) { + self::$testTokens[$marker] = $this->getTargetToken($marker, $targetToken); + } + } + + if (empty(self::$markerTokens) === true) { + foreach ($this->conditionMarkers as $marker) { + self::$markerTokens[$marker] = $this->getTargetToken($marker, Tokens::$scopeOpeners); + } + } + + }//end setUpCaches() + + + /** + * Test passing a non-existent token pointer. + * + * @return void + */ + public function testNonExistentToken() + { + $result = self::$phpcsFile->getCondition(100000, Tokens::$ooScopeTokens); + $this->assertFalse($result); + + $result = self::$phpcsFile->hasCondition(100000, T_IF); + $this->assertFalse($result); + + }//end testNonExistentToken() + + + /** + * Test passing a non conditional token. + * + * @return void + */ + public function testNonConditionalToken() + { + $targetType = T_STRING; + $stackPtr = $this->getTargetToken('/* testStartPoint */', $targetType); + + $result = self::$phpcsFile->getCondition($stackPtr, T_IF); + $this->assertFalse($result); + + $result = self::$phpcsFile->hasCondition($stackPtr, Tokens::$ooScopeTokens); + $this->assertFalse($result); + + }//end testNonConditionalToken() + + + /** + * Test retrieving a specific condition from a tokens "conditions" array. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param array $expectedResults Array with the condition token type to search for as key + * and the marker for the expected stack pointer result as a value. + * + * @dataProvider dataGetCondition + * + * @return void + */ + public function testGetCondition($testMarker, $expectedResults) + { + $stackPtr = self::$testTokens[$testMarker]; + + // Add expected results for all test markers not listed in the data provider. + $expectedResults += $this->conditionDefaults; + + foreach ($expectedResults as $conditionType => $expected) { + if (is_string($expected) === true) { + $expected = self::$markerTokens[$expected]; + } + + $result = self::$phpcsFile->getCondition($stackPtr, constant($conditionType)); + $this->assertSame( + $expected, + $result, + "Assertion failed for test marker '{$testMarker}' with condition {$conditionType}" + ); + } + + }//end testGetCondition() + + + /** + * Data provider. + * + * Only the conditions which are expected to be *found* need to be listed here. + * All other potential conditions will automatically also be tested and will expect + * `false` as a result. + * + * @see testGetCondition() For the array format. + * + * @return array>> + */ + public static function dataGetCondition() + { + return [ + 'testSeriouslyNestedMethod' => [ + 'testMarker' => '/* testSeriouslyNestedMethod */', + 'expectedResults' => [ + 'T_CLASS' => '/* condition 5: nested class */', + 'T_NAMESPACE' => '/* condition 0: namespace */', + 'T_FUNCTION' => '/* condition 2: function */', + 'T_IF' => '/* condition 1: if */', + 'T_ELSE' => '/* condition 3-2: else */', + ], + ], + 'testDeepestNested' => [ + 'testMarker' => '/* testDeepestNested */', + 'expectedResults' => [ + 'T_CLASS' => '/* condition 5: nested class */', + 'T_ANON_CLASS' => '/* condition 11-1: nested anonymous class */', + 'T_NAMESPACE' => '/* condition 0: namespace */', + 'T_FUNCTION' => '/* condition 2: function */', + 'T_CLOSURE' => '/* condition 13: closure */', + 'T_IF' => '/* condition 1: if */', + 'T_SWITCH' => '/* condition 7: switch */', + 'T_CASE' => '/* condition 8a: case */', + 'T_WHILE' => '/* condition 9: while */', + 'T_ELSE' => '/* condition 3-2: else */', + ], + ], + 'testInException' => [ + 'testMarker' => '/* testInException */', + 'expectedResults' => [ + 'T_CLASS' => '/* condition 5: nested class */', + 'T_NAMESPACE' => '/* condition 0: namespace */', + 'T_FUNCTION' => '/* condition 2: function */', + 'T_IF' => '/* condition 1: if */', + 'T_SWITCH' => '/* condition 7: switch */', + 'T_CASE' => '/* condition 8a: case */', + 'T_WHILE' => '/* condition 9: while */', + 'T_ELSE' => '/* condition 3-2: else */', + 'T_FOREACH' => '/* condition 10-3: foreach */', + 'T_CATCH' => '/* condition 11-3: catch */', + ], + ], + 'testInDefault' => [ + 'testMarker' => '/* testInDefault */', + 'expectedResults' => [ + 'T_CLASS' => '/* condition 5: nested class */', + 'T_NAMESPACE' => '/* condition 0: namespace */', + 'T_FUNCTION' => '/* condition 2: function */', + 'T_IF' => '/* condition 1: if */', + 'T_SWITCH' => '/* condition 7: switch */', + 'T_DEFAULT' => '/* condition 8b: default */', + 'T_ELSE' => '/* condition 3-2: else */', + ], + ], + ]; + + }//end dataGetCondition() + + + /** + * Test retrieving a specific condition from a tokens "conditions" array. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param array $expectedResults Array with the condition token type to search for as key + * and the marker for the expected stack pointer result as a value. + * + * @dataProvider dataGetConditionReversed + * + * @return void + */ + public function testGetConditionReversed($testMarker, $expectedResults) + { + $stackPtr = self::$testTokens[$testMarker]; + + // Add expected results for all test markers not listed in the data provider. + $expectedResults += $this->conditionDefaults; + + foreach ($expectedResults as $conditionType => $expected) { + if (is_string($expected) === true) { + $expected = self::$markerTokens[$expected]; + } + + $result = self::$phpcsFile->getCondition($stackPtr, constant($conditionType), false); + $this->assertSame( + $expected, + $result, + "Assertion failed for test marker '{$testMarker}' with condition {$conditionType} (reversed)" + ); + } + + }//end testGetConditionReversed() + + + /** + * Data provider. + * + * Only the conditions which are expected to be *found* need to be listed here. + * All other potential conditions will automatically also be tested and will expect + * `false` as a result. + * + * @see testGetConditionReversed() For the array format. + * + * @return array>> + */ + public static function dataGetConditionReversed() + { + $data = self::dataGetCondition(); + + // Set up the data for the reversed results. + $data['testSeriouslyNestedMethod']['expectedResults']['T_IF'] = '/* condition 4: if */'; + + $data['testDeepestNested']['expectedResults']['T_FUNCTION'] = '/* condition 12: nested anonymous class method */'; + $data['testDeepestNested']['expectedResults']['T_IF'] = '/* condition 10-1: if */'; + + $data['testInException']['expectedResults']['T_FUNCTION'] = '/* condition 6: class method */'; + $data['testInException']['expectedResults']['T_IF'] = '/* condition 4: if */'; + + $data['testInDefault']['expectedResults']['T_FUNCTION'] = '/* condition 6: class method */'; + $data['testInDefault']['expectedResults']['T_IF'] = '/* condition 4: if */'; + + return $data; + + }//end dataGetConditionReversed() + + + /** + * Test whether a token has a condition of a certain type. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param array $expectedResults Array with the condition token type to search for as key + * and the expected result as a value. + * + * @dataProvider dataHasCondition + * + * @return void + */ + public function testHasCondition($testMarker, $expectedResults) + { + $stackPtr = self::$testTokens[$testMarker]; + + // Add expected results for all test markers not listed in the data provider. + $expectedResults += $this->conditionDefaults; + + foreach ($expectedResults as $conditionType => $expected) { + $result = self::$phpcsFile->hasCondition($stackPtr, constant($conditionType)); + $this->assertSame( + $expected, + $result, + "Assertion failed for test marker '{$testMarker}' with condition {$conditionType}" + ); + } + + }//end testHasCondition() + + + /** + * Data Provider. + * + * Only list the "true" conditions in the $results array. + * All other potential conditions will automatically also be tested + * and will expect "false" as a result. + * + * @see testHasCondition() For the array format. + * + * @return array>> + */ + public static function dataHasCondition() + { + return [ + 'testSeriouslyNestedMethod' => [ + 'testMarker' => '/* testSeriouslyNestedMethod */', + 'expectedResults' => [ + 'T_CLASS' => true, + 'T_NAMESPACE' => true, + 'T_FUNCTION' => true, + 'T_IF' => true, + 'T_ELSE' => true, + ], + ], + 'testDeepestNested' => [ + 'testMarker' => '/* testDeepestNested */', + 'expectedResults' => [ + 'T_CLASS' => true, + 'T_ANON_CLASS' => true, + 'T_NAMESPACE' => true, + 'T_FUNCTION' => true, + 'T_CLOSURE' => true, + 'T_IF' => true, + 'T_SWITCH' => true, + 'T_CASE' => true, + 'T_WHILE' => true, + 'T_ELSE' => true, + ], + ], + 'testInException' => [ + 'testMarker' => '/* testInException */', + 'expectedResults' => [ + 'T_CLASS' => true, + 'T_NAMESPACE' => true, + 'T_FUNCTION' => true, + 'T_IF' => true, + 'T_SWITCH' => true, + 'T_CASE' => true, + 'T_WHILE' => true, + 'T_ELSE' => true, + 'T_FOREACH' => true, + 'T_CATCH' => true, + ], + ], + 'testInDefault' => [ + 'testMarker' => '/* testInDefault */', + 'expectedResults' => [ + 'T_CLASS' => true, + 'T_NAMESPACE' => true, + 'T_FUNCTION' => true, + 'T_IF' => true, + 'T_SWITCH' => true, + 'T_DEFAULT' => true, + 'T_ELSE' => true, + ], + ], + ]; + + }//end dataHasCondition() + + + /** + * Test whether a token has a condition of a certain type, with multiple allowed possibilities. + * + * @return void + */ + public function testHasConditionMultipleTypes() + { + $stackPtr = self::$testTokens['/* testInException */']; + + $result = self::$phpcsFile->hasCondition($stackPtr, [T_TRY, T_FINALLY]); + $this->assertFalse( + $result, + 'Failed asserting that "testInException" does not have a "try" nor a "finally" condition' + ); + + $result = self::$phpcsFile->hasCondition($stackPtr, [T_TRY, T_CATCH, T_FINALLY]); + $this->assertTrue( + $result, + 'Failed asserting that "testInException" has a "try", "catch" or "finally" condition' + ); + + $stackPtr = self::$testTokens['/* testSeriouslyNestedMethod */']; + + $result = self::$phpcsFile->hasCondition($stackPtr, [T_ANON_CLASS, T_CLOSURE]); + $this->assertFalse( + $result, + 'Failed asserting that "testSeriouslyNestedMethod" does not have an anonymous class nor a closure condition' + ); + + $result = self::$phpcsFile->hasCondition($stackPtr, Tokens::$ooScopeTokens); + $this->assertTrue( + $result, + 'Failed asserting that "testSeriouslyNestedMethod" has an OO Scope token condition' + ); + + }//end testHasConditionMultipleTypes() + + +}//end class From 2feff6b1674bdd65e36c7f5f6d36c1327aac4e97 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 09:36:59 +0100 Subject: [PATCH 211/874] File::getDeclarationName(): add tests This imports the tests which were already in use in PHPCSUtils into PHP_CodeSniffer. --- tests/Core/File/GetDeclarationNameJSTest.js | 23 ++ tests/Core/File/GetDeclarationNameJSTest.php | 158 +++++++++++++ tests/Core/File/GetDeclarationNameTest.inc | 102 +++++++++ tests/Core/File/GetDeclarationNameTest.php | 225 +++++++++++++++++++ 4 files changed, 508 insertions(+) create mode 100644 tests/Core/File/GetDeclarationNameJSTest.js create mode 100644 tests/Core/File/GetDeclarationNameJSTest.php create mode 100644 tests/Core/File/GetDeclarationNameTest.inc create mode 100644 tests/Core/File/GetDeclarationNameTest.php diff --git a/tests/Core/File/GetDeclarationNameJSTest.js b/tests/Core/File/GetDeclarationNameJSTest.js new file mode 100644 index 0000000000..ee0a76a44f --- /dev/null +++ b/tests/Core/File/GetDeclarationNameJSTest.js @@ -0,0 +1,23 @@ +/* testInvalidTokenPassed */ +print something; + +var object = +{ + /* testClosure */ + propertyName: function () {} +} + +/* testFunction */ +function functionName() {} + +/* testClass */ +class ClassName +{ + /* testMethod */ + methodName() { + return false; + } +} + +/* testFunctionUnicode */ +function π() {} diff --git a/tests/Core/File/GetDeclarationNameJSTest.php b/tests/Core/File/GetDeclarationNameJSTest.php new file mode 100644 index 0000000000..a2b8968583 --- /dev/null +++ b/tests/Core/File/GetDeclarationNameJSTest.php @@ -0,0 +1,158 @@ + + * @copyright 2022-2024 PHPCSStandards Contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\File; + +use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; + +/** + * Tests for the \PHP_CodeSniffer\Files\File:getDeclarationName method. + * + * @covers \PHP_CodeSniffer\Files\File::getDeclarationName + */ +class GetDeclarationNameJSTest extends AbstractMethodUnitTest +{ + + /** + * The file extension of the test case file (without leading dot). + * + * @var string + */ + protected static $fileExtension = 'js'; + + + /** + * Test receiving an expected exception when a non-supported token is passed. + * + * @return void + */ + public function testInvalidTokenPassed() + { + $this->expectRunTimeException('Token type "T_STRING" is not T_FUNCTION, T_CLASS, T_INTERFACE, T_TRAIT or T_ENUM'); + + $target = $this->getTargetToken('/* testInvalidTokenPassed */', T_STRING); + self::$phpcsFile->getDeclarationName($target); + + }//end testInvalidTokenPassed() + + + /** + * Test receiving "null" when passed an anonymous construct or in case of a parse error. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int|string $targetType Token type of the token to get as stackPtr. + * + * @dataProvider dataGetDeclarationNameNull + * + * @return void + */ + public function testGetDeclarationNameNull($testMarker, $targetType) + { + $target = $this->getTargetToken($testMarker, $targetType); + $result = self::$phpcsFile->getDeclarationName($target); + $this->assertNull($result); + + }//end testGetDeclarationNameNull() + + + /** + * Data provider. + * + * @see GetDeclarationNameTest::testGetDeclarationNameNull() + * + * @return array> + */ + public static function dataGetDeclarationNameNull() + { + return [ + 'closure' => [ + 'testMarker' => '/* testClosure */', + 'targetType' => T_CLOSURE, + ], + ]; + + }//end dataGetDeclarationNameNull() + + + /** + * Test retrieving the name of a function or OO structure. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param string $expected Expected function output. + * @param array|null $targetType Token type of the token to get as stackPtr. + * + * @dataProvider dataGetDeclarationName + * + * @return void + */ + public function testGetDeclarationName($testMarker, $expected, $targetType=null) + { + if (isset($targetType) === false) { + $targetType = [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_ENUM, + T_FUNCTION, + ]; + } + + $target = $this->getTargetToken($testMarker, $targetType); + $result = self::$phpcsFile->getDeclarationName($target); + $this->assertSame($expected, $result); + + }//end testGetDeclarationName() + + + /** + * Data provider. + * + * @see GetDeclarationNameTest::testGetDeclarationName() + * + * @return array>> + */ + public static function dataGetDeclarationName() + { + return [ + 'function' => [ + 'testMarker' => '/* testFunction */', + 'expected' => 'functionName', + ], + 'class' => [ + 'testMarker' => '/* testClass */', + 'expected' => 'ClassName', + 'targetType' => [ + T_CLASS, + T_STRING, + ], + ], + 'function-unicode-name' => [ + 'testMarker' => '/* testFunctionUnicode */', + 'expected' => 'π', + ], + ]; + + }//end dataGetDeclarationName() + + + /** + * Test retrieving the name of JS ES6 class method. + * + * @return void + */ + public function testGetDeclarationNameES6Method() + { + $target = $this->getTargetToken('/* testMethod */', [T_CLASS, T_INTERFACE, T_TRAIT, T_FUNCTION]); + $result = self::$phpcsFile->getDeclarationName($target); + $this->assertSame('methodName', $result); + + }//end testGetDeclarationNameES6Method() + + +}//end class diff --git a/tests/Core/File/GetDeclarationNameTest.inc b/tests/Core/File/GetDeclarationNameTest.inc new file mode 100644 index 0000000000..14902245bb --- /dev/null +++ b/tests/Core/File/GetDeclarationNameTest.inc @@ -0,0 +1,102 @@ + + * @copyright 2022-2024 PHPCSStandards Contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\File; + +use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; + +/** + * Tests for the \PHP_CodeSniffer\Files\File:getDeclarationName method. + * + * @covers \PHP_CodeSniffer\Files\File::getDeclarationName + */ +class GetDeclarationNameTest extends AbstractMethodUnitTest +{ + + + /** + * Test receiving an expected exception when a non-supported token is passed. + * + * @return void + */ + public function testInvalidTokenPassed() + { + $this->expectRunTimeException('Token type "T_STRING" is not T_FUNCTION, T_CLASS, T_INTERFACE, T_TRAIT or T_ENUM'); + + $target = $this->getTargetToken('/* testInvalidTokenPassed */', T_STRING); + self::$phpcsFile->getDeclarationName($target); + + }//end testInvalidTokenPassed() + + + /** + * Test receiving "null" when passed an anonymous construct or in case of a parse error. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int|string $targetType Token type of the token to get as stackPtr. + * + * @dataProvider dataGetDeclarationNameNull + * + * @return void + */ + public function testGetDeclarationNameNull($testMarker, $targetType) + { + $target = $this->getTargetToken($testMarker, $targetType); + $result = self::$phpcsFile->getDeclarationName($target); + $this->assertNull($result); + + }//end testGetDeclarationNameNull() + + + /** + * Data provider. + * + * @see testGetDeclarationNameNull() For the array format. + * + * @return array> + */ + public static function dataGetDeclarationNameNull() + { + return [ + 'closure' => [ + 'testMarker' => '/* testClosure */', + 'targetType' => T_CLOSURE, + ], + 'anon-class-with-parentheses' => [ + 'testMarker' => '/* testAnonClassWithParens */', + 'targetType' => T_ANON_CLASS, + ], + 'anon-class-with-parentheses-2' => [ + 'testMarker' => '/* testAnonClassWithParens2 */', + 'targetType' => T_ANON_CLASS, + ], + 'anon-class-without-parentheses' => [ + 'testMarker' => '/* testAnonClassWithoutParens */', + 'targetType' => T_ANON_CLASS, + ], + 'anon-class-extends-without-parentheses' => [ + 'testMarker' => '/* testAnonClassExtendsWithoutParens */', + 'targetType' => T_ANON_CLASS, + ], + 'live-coding' => [ + 'testMarker' => '/* testLiveCoding */', + 'targetType' => T_FUNCTION, + ], + ]; + + }//end dataGetDeclarationNameNull() + + + /** + * Test retrieving the name of a function or OO structure. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param string $expected Expected function output. + * @param int|string|null $targetType Token type of the token to get as stackPtr. + * + * @dataProvider dataGetDeclarationName + * + * @return void + */ + public function testGetDeclarationName($testMarker, $expected, $targetType=null) + { + if (isset($targetType) === false) { + $targetType = [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_ENUM, + T_FUNCTION, + ]; + } + + $target = $this->getTargetToken($testMarker, $targetType); + $result = self::$phpcsFile->getDeclarationName($target); + $this->assertSame($expected, $result); + + }//end testGetDeclarationName() + + + /** + * Data provider. + * + * @see testGetDeclarationName() For the array format. + * + * @return array> + */ + public static function dataGetDeclarationName() + { + return [ + 'function' => [ + 'testMarker' => '/* testFunction */', + 'expected' => 'functionName', + ], + 'function-return-by-reference' => [ + 'testMarker' => '/* testFunctionReturnByRef */', + 'expected' => 'functionNameByRef', + ], + 'class' => [ + 'testMarker' => '/* testClass */', + 'expected' => 'ClassName', + ], + 'method' => [ + 'testMarker' => '/* testMethod */', + 'expected' => 'methodName', + ], + 'abstract-method' => [ + 'testMarker' => '/* testAbstractMethod */', + 'expected' => 'abstractMethodName', + ], + 'method-return-by-reference' => [ + 'testMarker' => '/* testMethodReturnByRef */', + 'expected' => 'MethodNameByRef', + ], + 'extended-class' => [ + 'testMarker' => '/* testExtendedClass */', + 'expected' => 'ExtendedClass', + ], + 'interface' => [ + 'testMarker' => '/* testInterface */', + 'expected' => 'InterfaceName', + ], + 'trait' => [ + 'testMarker' => '/* testTrait */', + 'expected' => 'TraitName', + ], + 'function-name-ends-with-number' => [ + 'testMarker' => '/* testFunctionEndingWithNumber */', + 'expected' => 'ValidNameEndingWithNumber5', + ], + 'class-with-numbers-in-name' => [ + 'testMarker' => '/* testClassWithNumber */', + 'expected' => 'ClassWith1Number', + ], + 'interface-with-numbers-in-name' => [ + 'testMarker' => '/* testInterfaceWithNumbers */', + 'expected' => 'InterfaceWith12345Numbers', + ], + 'class-with-comments-and-new-lines' => [ + 'testMarker' => '/* testClassWithCommentsAndNewLines */', + 'expected' => 'ClassWithCommentsAndNewLines', + ], + 'function-named-fn' => [ + 'testMarker' => '/* testFunctionFn */', + 'expected' => 'fn', + ], + 'enum-pure' => [ + 'testMarker' => '/* testPureEnum */', + 'expected' => 'Foo', + ], + 'enum-backed-space-between-name-and-colon' => [ + 'testMarker' => '/* testBackedEnumSpaceBetweenNameAndColon */', + 'expected' => 'Hoo', + ], + 'enum-backed-no-space-between-name-and-colon' => [ + 'testMarker' => '/* testBackedEnumNoSpaceBetweenNameAndColon */', + 'expected' => 'Suit', + ], + 'function-return-by-reference-with-reserved-keyword-each' => [ + 'testMarker' => '/* testFunctionReturnByRefWithReservedKeywordEach */', + 'expected' => 'each', + ], + 'function-return-by-reference-with-reserved-keyword-parent' => [ + 'testMarker' => '/* testFunctionReturnByRefWithReservedKeywordParent */', + 'expected' => 'parent', + ], + 'function-return-by-reference-with-reserved-keyword-self' => [ + 'testMarker' => '/* testFunctionReturnByRefWithReservedKeywordSelf */', + 'expected' => 'self', + ], + 'function-return-by-reference-with-reserved-keyword-static' => [ + 'testMarker' => '/* testFunctionReturnByRefWithReservedKeywordStatic */', + 'expected' => 'static', + ], + ]; + + }//end dataGetDeclarationName() + + +}//end class From 21afc774468cfdfcaf493c5adba79477ffcdaa9d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 22:33:44 +0100 Subject: [PATCH 212/874] Tests/IsReferenceTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes making the data type in the docblock more specific. --- tests/Core/File/IsReferenceTest.php | 296 ++++++++++++++-------------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/tests/Core/File/IsReferenceTest.php b/tests/Core/File/IsReferenceTest.php index 5372bf163c..3dd5ff8501 100644 --- a/tests/Core/File/IsReferenceTest.php +++ b/tests/Core/File/IsReferenceTest.php @@ -44,206 +44,206 @@ public function testIsReference($identifier, $expected) * * @see testIsReference() * - * @return array + * @return array> */ public function dataIsReference() { return [ - [ - '/* testBitwiseAndA */', - false, + 'bitwise and: param in function call' => [ + 'testMarker' => '/* testBitwiseAndA */', + 'expected' => false, ], - [ - '/* testBitwiseAndB */', - false, + 'bitwise and: in unkeyed short array, first value' => [ + 'testMarker' => '/* testBitwiseAndB */', + 'expected' => false, ], - [ - '/* testBitwiseAndC */', - false, + 'bitwise and: in unkeyed short array, last value' => [ + 'testMarker' => '/* testBitwiseAndC */', + 'expected' => false, ], - [ - '/* testBitwiseAndD */', - false, + 'bitwise and: in unkeyed long array, last value' => [ + 'testMarker' => '/* testBitwiseAndD */', + 'expected' => false, ], - [ - '/* testBitwiseAndE */', - false, + 'bitwise and: in keyed short array, last value' => [ + 'testMarker' => '/* testBitwiseAndE */', + 'expected' => false, ], - [ - '/* testBitwiseAndF */', - false, + 'bitwise and: in keyed long array, last value' => [ + 'testMarker' => '/* testBitwiseAndF */', + 'expected' => false, ], - [ - '/* testBitwiseAndG */', - false, + 'bitwise and: in assignment' => [ + 'testMarker' => '/* testBitwiseAndG */', + 'expected' => false, ], - [ - '/* testBitwiseAndH */', - false, + 'bitwise and: in param default value in function declaration' => [ + 'testMarker' => '/* testBitwiseAndH */', + 'expected' => false, ], - [ - '/* testBitwiseAndI */', - false, + 'bitwise and: in param default value in closure declaration' => [ + 'testMarker' => '/* testBitwiseAndI */', + 'expected' => false, ], - [ - '/* testFunctionReturnByReference */', - true, + 'reference: function declared to return by reference' => [ + 'testMarker' => '/* testFunctionReturnByReference */', + 'expected' => true, ], - [ - '/* testFunctionPassByReferenceA */', - true, + 'reference: only param in function declaration, pass by reference' => [ + 'testMarker' => '/* testFunctionPassByReferenceA */', + 'expected' => true, ], - [ - '/* testFunctionPassByReferenceB */', - true, + 'reference: last param in function declaration, pass by reference' => [ + 'testMarker' => '/* testFunctionPassByReferenceB */', + 'expected' => true, ], - [ - '/* testFunctionPassByReferenceC */', - true, + 'reference: only param in closure declaration, pass by reference' => [ + 'testMarker' => '/* testFunctionPassByReferenceC */', + 'expected' => true, ], - [ - '/* testFunctionPassByReferenceD */', - true, + 'reference: last param in closure declaration, pass by reference' => [ + 'testMarker' => '/* testFunctionPassByReferenceD */', + 'expected' => true, ], - [ - '/* testFunctionPassByReferenceE */', - true, + 'reference: typed param in function declaration, pass by reference' => [ + 'testMarker' => '/* testFunctionPassByReferenceE */', + 'expected' => true, ], - [ - '/* testFunctionPassByReferenceF */', - true, + 'reference: typed param in closure declaration, pass by reference' => [ + 'testMarker' => '/* testFunctionPassByReferenceF */', + 'expected' => true, ], - [ - '/* testFunctionPassByReferenceG */', - true, + 'reference: variadic param in function declaration, pass by reference' => [ + 'testMarker' => '/* testFunctionPassByReferenceG */', + 'expected' => true, ], - [ - '/* testForeachValueByReference */', - true, + 'reference: foreach value' => [ + 'testMarker' => '/* testForeachValueByReference */', + 'expected' => true, ], - [ - '/* testForeachKeyByReference */', - true, + 'reference: foreach key' => [ + 'testMarker' => '/* testForeachKeyByReference */', + 'expected' => true, ], - [ - '/* testArrayValueByReferenceA */', - true, + 'reference: keyed short array, first value, value by reference' => [ + 'testMarker' => '/* testArrayValueByReferenceA */', + 'expected' => true, ], - [ - '/* testArrayValueByReferenceB */', - true, + 'reference: keyed short array, last value, value by reference' => [ + 'testMarker' => '/* testArrayValueByReferenceB */', + 'expected' => true, ], - [ - '/* testArrayValueByReferenceC */', - true, + 'reference: unkeyed short array, only value, value by reference' => [ + 'testMarker' => '/* testArrayValueByReferenceC */', + 'expected' => true, ], - [ - '/* testArrayValueByReferenceD */', - true, + 'reference: unkeyed short array, last value, value by reference' => [ + 'testMarker' => '/* testArrayValueByReferenceD */', + 'expected' => true, ], - [ - '/* testArrayValueByReferenceE */', - true, + 'reference: keyed long array, first value, value by reference' => [ + 'testMarker' => '/* testArrayValueByReferenceE */', + 'expected' => true, ], - [ - '/* testArrayValueByReferenceF */', - true, + 'reference: keyed long array, last value, value by reference' => [ + 'testMarker' => '/* testArrayValueByReferenceF */', + 'expected' => true, ], - [ - '/* testArrayValueByReferenceG */', - true, + 'reference: unkeyed long array, only value, value by reference' => [ + 'testMarker' => '/* testArrayValueByReferenceG */', + 'expected' => true, ], - [ - '/* testArrayValueByReferenceH */', - true, + 'reference: unkeyed long array, last value, value by reference' => [ + 'testMarker' => '/* testArrayValueByReferenceH */', + 'expected' => true, ], - [ - '/* testAssignByReferenceA */', - true, + 'reference: variable, assign by reference' => [ + 'testMarker' => '/* testAssignByReferenceA */', + 'expected' => true, ], - [ - '/* testAssignByReferenceB */', - true, + 'reference: variable, assign by reference, spacing variation' => [ + 'testMarker' => '/* testAssignByReferenceB */', + 'expected' => true, ], - [ - '/* testAssignByReferenceC */', - true, + 'reference: variable, assign by reference, concat assign' => [ + 'testMarker' => '/* testAssignByReferenceC */', + 'expected' => true, ], - [ - '/* testAssignByReferenceD */', - true, + 'reference: property, assign by reference' => [ + 'testMarker' => '/* testAssignByReferenceD */', + 'expected' => true, ], - [ - '/* testAssignByReferenceE */', - true, + 'reference: function return value, assign by reference' => [ + 'testMarker' => '/* testAssignByReferenceE */', + 'expected' => true, ], - [ - '/* testPassByReferenceA */', - true, + 'reference: first param in function call, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceA */', + 'expected' => true, ], - [ - '/* testPassByReferenceB */', - true, + 'reference: last param in function call, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceB */', + 'expected' => true, ], - [ - '/* testPassByReferenceC */', - true, + 'reference: property in function call, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceC */', + 'expected' => true, ], - [ - '/* testPassByReferenceD */', - true, + 'reference: hierarchical self property in function call, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceD */', + 'expected' => true, ], - [ - '/* testPassByReferenceE */', - true, + 'reference: hierarchical parent property in function call, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceE */', + 'expected' => true, ], - [ - '/* testPassByReferenceF */', - true, + 'reference: hierarchical static property in function call, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceF */', + 'expected' => true, ], - [ - '/* testPassByReferenceG */', - true, + 'reference: static property in function call, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceG */', + 'expected' => true, ], - [ - '/* testPassByReferenceH */', - true, + 'reference: static property in function call, first with FQN, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceH */', + 'expected' => true, ], - [ - '/* testPassByReferenceI */', - true, + 'reference: static property in function call, last with FQN, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceI */', + 'expected' => true, ], - [ - '/* testPassByReferenceJ */', - true, + 'reference: static property in function call, last with namespace relative name, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceJ */', + 'expected' => true, ], - [ - '/* testNewByReferenceA */', - true, + 'reference: new by reference' => [ + 'testMarker' => '/* testNewByReferenceA */', + 'expected' => true, ], - [ - '/* testNewByReferenceB */', - true, + 'reference: new by reference as function call param' => [ + 'testMarker' => '/* testNewByReferenceB */', + 'expected' => true, ], - [ - '/* testUseByReference */', - true, + 'reference: closure use by reference' => [ + 'testMarker' => '/* testUseByReference */', + 'expected' => true, ], - [ - '/* testArrowFunctionReturnByReference */', - true, + 'reference: arrow fn declared to return by reference' => [ + 'testMarker' => '/* testArrowFunctionReturnByReference */', + 'expected' => true, ], - [ - '/* testArrowFunctionPassByReferenceA */', - true, + 'reference: typed param in arrow fn declaration, pass by reference' => [ + 'testMarker' => '/* testArrowFunctionPassByReferenceA */', + 'expected' => true, ], - [ - '/* testArrowFunctionPassByReferenceB */', - true, + 'reference: variadic param in arrow fn declaration, pass by reference' => [ + 'testMarker' => '/* testArrowFunctionPassByReferenceB */', + 'expected' => true, ], - [ - '/* testClosureReturnByReference */', - true, + 'reference: closure declared to return by reference' => [ + 'testMarker' => '/* testClosureReturnByReference */', + 'expected' => true, ], ]; From 3622657175f647fd5e01d2bab7c15f3b68e2a7c6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 22:54:16 +0100 Subject: [PATCH 213/874] Tests/IsReferenceTest: add extra tests This adds some extra tests which were already in use in PHPCSUtils. This brings test coverage for this method up to 100%. It also cleans up the test case file a little by removing some code which isn't actually used in the tests (namespace declaration). --- tests/Core/File/IsReferenceTest.inc | 62 +++++++++++++++- tests/Core/File/IsReferenceTest.php | 105 ++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 1 deletion(-) diff --git a/tests/Core/File/IsReferenceTest.inc b/tests/Core/File/IsReferenceTest.inc index f71e2639d8..93c7acc677 100644 --- a/tests/Core/File/IsReferenceTest.inc +++ b/tests/Core/File/IsReferenceTest.inc @@ -1,6 +1,8 @@ getValue(); /* testAssignByReferenceE */ $collection = &collector(); +/* testAssignByReferenceF */ +$collection ??= &collector(); + +/* testShortListAssignByReferenceNoKeyA */ +[ + &$a, + /* testShortListAssignByReferenceNoKeyB */ + &$b, + /* testNestedShortListAssignByReferenceNoKey */ + [$c, &$d] +] = $array; + +/* testLongListAssignByReferenceNoKeyA */ +list($a, &$b, list(/* testLongListAssignByReferenceNoKeyB */ &$c, /* testLongListAssignByReferenceNoKeyC */ &$d)) = $array; + +[ + /* testNestedShortListAssignByReferenceWithKeyA */ + 'a' => [&$a, $b], + /* testNestedShortListAssignByReferenceWithKeyB */ + 'b' => [$c, &$d] +] = $array; + + +/* testLongListAssignByReferenceWithKeyA */ +list(get_key()[1] => &$e) = [1, 2, 3]; + /* testPassByReferenceA */ functionCall(&$something, $somethingElse); @@ -128,6 +156,9 @@ functionCall($something, &\SomeNS\SomeClass::$somethingElse); /* testPassByReferenceJ */ functionCall($something, &namespace\SomeClass::$somethingElse); +/* testPassByReferencePartiallyQualifiedName */ +functionCall($something, &Sub\Level\SomeClass::$somethingElse); + /* testNewByReferenceA */ $foobar2 = &new Foobar(); @@ -137,9 +168,27 @@ functionCall( $something , &new Foobar() ); /* testUseByReference */ $closure = function() use (&$var){}; +/* testUseByReferenceWithCommentFirstParam */ +$closure = function() use /*comment*/ (&$this->value){}; + +/* testUseByReferenceWithCommentSecondParam */ +$closure = function() use /*comment*/ ($varA, &$varB){}; + /* testArrowFunctionReturnByReference */ fn&($x) => $x; +$closure = function ( + /* testBitwiseAndExactParameterA */ + $a = MY_CONSTANT & parent::OTHER_CONSTANT, + /* testPassByReferenceExactParameterB */ + &$b, + /* testPassByReferenceExactParameterC */ + &...$c, + /* testBitwiseAndExactParameterD */ + $d = E_NOTICE & E_STRICT, +) {}; + +// Issue PHPCS#3049. /* testArrowFunctionPassByReferenceA */ $fn = fn(array &$one) => 1; @@ -148,3 +197,14 @@ $fn = fn($param, &...$moreParams) => 1; /* testClosureReturnByReference */ $closure = function &($param) use ($value) {}; + +/* testBitwiseAndArrowFunctionInDefault */ +$fn = fn( $one = E_NOTICE & E_STRICT) => 1; + +/* testTokenizerIssue1284PHPCSlt280A */ +if ($foo) {} +[&$a, /* testTokenizerIssue1284PHPCSlt280B */ &$b] = $c; + +/* testTokenizerIssue1284PHPCSlt280C */ +if ($foo) {} +[&$a, $b]; diff --git a/tests/Core/File/IsReferenceTest.php b/tests/Core/File/IsReferenceTest.php index 3dd5ff8501..929779d43b 100644 --- a/tests/Core/File/IsReferenceTest.php +++ b/tests/Core/File/IsReferenceTest.php @@ -20,6 +20,19 @@ class IsReferenceTest extends AbstractMethodUnitTest { + /** + * Test that false is returned when a non-"bitwise and" token is passed. + * + * @return void + */ + public function testNotBitwiseAndToken() + { + $target = $this->getTargetToken('/* testBitwiseAndA */', T_STRING); + $this->assertFalse(self::$phpcsFile->isReference($target)); + + }//end testNotBitwiseAndToken() + + /** * Test correctly identifying whether a "bitwise and" token is a reference or not. * @@ -49,6 +62,14 @@ public function testIsReference($identifier, $expected) public function dataIsReference() { return [ + 'issue-1971-list-first-in-file' => [ + 'testMarker' => '/* testTokenizerIssue1971PHPCSlt330gt271A */', + 'expected' => true, + ], + 'issue-1971-list-first-in-file-nested' => [ + 'testMarker' => '/* testTokenizerIssue1971PHPCSlt330gt271B */', + 'expected' => true, + ], 'bitwise and: param in function call' => [ 'testMarker' => '/* testBitwiseAndA */', 'expected' => false, @@ -177,6 +198,46 @@ public function dataIsReference() 'testMarker' => '/* testAssignByReferenceE */', 'expected' => true, ], + 'reference: function return value, assign by reference, null coalesce assign' => [ + 'testMarker' => '/* testAssignByReferenceF */', + 'expected' => true, + ], + 'reference: unkeyed short list, first var, assign by reference' => [ + 'testMarker' => '/* testShortListAssignByReferenceNoKeyA */', + 'expected' => true, + ], + 'reference: unkeyed short list, second var, assign by reference' => [ + 'testMarker' => '/* testShortListAssignByReferenceNoKeyB */', + 'expected' => true, + ], + 'reference: unkeyed short list, nested var, assign by reference' => [ + 'testMarker' => '/* testNestedShortListAssignByReferenceNoKey */', + 'expected' => true, + ], + 'reference: unkeyed long list, second var, assign by reference' => [ + 'testMarker' => '/* testLongListAssignByReferenceNoKeyA */', + 'expected' => true, + ], + 'reference: unkeyed long list, first nested var, assign by reference' => [ + 'testMarker' => '/* testLongListAssignByReferenceNoKeyB */', + 'expected' => true, + ], + 'reference: unkeyed long list, last nested var, assign by reference' => [ + 'testMarker' => '/* testLongListAssignByReferenceNoKeyC */', + 'expected' => true, + ], + 'reference: keyed short list, first nested var, assign by reference' => [ + 'testMarker' => '/* testNestedShortListAssignByReferenceWithKeyA */', + 'expected' => true, + ], + 'reference: keyed short list, last nested var, assign by reference' => [ + 'testMarker' => '/* testNestedShortListAssignByReferenceWithKeyB */', + 'expected' => true, + ], + 'reference: keyed long list, only var, assign by reference' => [ + 'testMarker' => '/* testLongListAssignByReferenceWithKeyA */', + 'expected' => true, + ], 'reference: first param in function call, pass by reference' => [ 'testMarker' => '/* testPassByReferenceA */', 'expected' => true, @@ -217,6 +278,10 @@ public function dataIsReference() 'testMarker' => '/* testPassByReferenceJ */', 'expected' => true, ], + 'reference: static property in function call, last with PQN, pass by reference' => [ + 'testMarker' => '/* testPassByReferencePartiallyQualifiedName */', + 'expected' => true, + ], 'reference: new by reference' => [ 'testMarker' => '/* testNewByReferenceA */', 'expected' => true, @@ -229,10 +294,34 @@ public function dataIsReference() 'testMarker' => '/* testUseByReference */', 'expected' => true, ], + 'reference: closure use by reference, first param, with comment' => [ + 'testMarker' => '/* testUseByReferenceWithCommentFirstParam */', + 'expected' => true, + ], + 'reference: closure use by reference, last param, with comment' => [ + 'testMarker' => '/* testUseByReferenceWithCommentSecondParam */', + 'expected' => true, + ], 'reference: arrow fn declared to return by reference' => [ 'testMarker' => '/* testArrowFunctionReturnByReference */', 'expected' => true, ], + 'bitwise and: first param default value in closure declaration' => [ + 'testMarker' => '/* testBitwiseAndExactParameterA */', + 'expected' => false, + ], + 'reference: param in closure declaration, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceExactParameterB */', + 'expected' => true, + ], + 'reference: variadic param in closure declaration, pass by reference' => [ + 'testMarker' => '/* testPassByReferenceExactParameterC */', + 'expected' => true, + ], + 'bitwise and: last param default value in closure declaration' => [ + 'testMarker' => '/* testBitwiseAndExactParameterD */', + 'expected' => false, + ], 'reference: typed param in arrow fn declaration, pass by reference' => [ 'testMarker' => '/* testArrowFunctionPassByReferenceA */', 'expected' => true, @@ -245,6 +334,22 @@ public function dataIsReference() 'testMarker' => '/* testClosureReturnByReference */', 'expected' => true, ], + 'bitwise and: param default value in arrow fn declaration' => [ + 'testMarker' => '/* testBitwiseAndArrowFunctionInDefault */', + 'expected' => false, + ], + 'issue-1284-short-list-directly-after-close-curly-control-structure' => [ + 'testMarker' => '/* testTokenizerIssue1284PHPCSlt280A */', + 'expected' => true, + ], + 'issue-1284-short-list-directly-after-close-curly-control-structure-second-item' => [ + 'testMarker' => '/* testTokenizerIssue1284PHPCSlt280B */', + 'expected' => true, + ], + 'issue-1284-short-array-directly-after-close-curly-control-structure' => [ + 'testMarker' => '/* testTokenizerIssue1284PHPCSlt280C */', + 'expected' => true, + ], ]; }//end dataIsReference() From deffca0b2304cb78a7bfe906bbb62eb32cc3a8eb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 2 Jan 2024 14:42:11 +0100 Subject: [PATCH 214/874] GH Actions/merge conflict check: don't cancel on higher prio When this workflow is triggered on the `pull_request_target` event, the branch will identify as `master` (`github.ref`), which means that any push to `master` AND any other PR being opened will cancel the workflow. That is not the intention, jobs for PRs triggering this workflow should always run to completion. However, as the `push` event and the `pull_request_target` events don't really have much overlap in available info, it is not straight forward to set a group name which will prevent the above from happening. With that in mind, I'm removing the concurrency cancellation from this workflow. --- .github/workflows/label-merge-conflicts.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/label-merge-conflicts.yml b/.github/workflows/label-merge-conflicts.yml index 170ac52441..53592314ba 100644 --- a/.github/workflows/label-merge-conflicts.yml +++ b/.github/workflows/label-merge-conflicts.yml @@ -12,12 +12,6 @@ on: - synchronize - reopened -# Cancels all previous workflow runs for the same branch that have not yet completed. -concurrency: - # The concurrency group contains the workflow name and the branch name. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: check-prs: runs-on: ubuntu-latest From 5aa4362eb589e1290c1e23f54e9393a2b26390c5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 22:33:43 +0100 Subject: [PATCH 215/874] AbstractMethodUnitTest: allow for select tests to use tabs in the test case file An individual test can set the `$tabWidth` property in the test file to overwrite the default value. --- tests/Core/AbstractMethodUnitTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/Core/AbstractMethodUnitTest.php b/tests/Core/AbstractMethodUnitTest.php index ced92062f6..abab2d6ffe 100644 --- a/tests/Core/AbstractMethodUnitTest.php +++ b/tests/Core/AbstractMethodUnitTest.php @@ -28,6 +28,15 @@ abstract class AbstractMethodUnitTest extends TestCase */ protected static $fileExtension = 'inc'; + /** + * The tab width setting to use when tokenizing the file. + * + * This allows for test case files to use a different tab width than the default. + * + * @var integer + */ + protected static $tabWidth = 4; + /** * The \PHP_CodeSniffer\Files\File object containing the parsed contents of the test case file. * @@ -63,7 +72,10 @@ public static function initializeFile() self::setStaticConfigProperty('configData', ['report_width' => 80]); self::setStaticConfigProperty('configDataFile', ''); - $config = new Config(); + $config = new Config(); + // Also set a tab-width to enable testing tab-replaced vs `orig_content`. + $config->tabWidth = static::$tabWidth; + $ruleset = new Ruleset($config); // Default to a file with the same name as the test class. Extension is property based. From 88d5c910f55b37be566bbd3f3fbd064301f814cc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 22:38:25 +0100 Subject: [PATCH 216/874] File::getTokensAsString(): add tests This imports the tests which were already in use in PHPCSUtils into PHP_CodeSniffer. --- tests/Core/File/GetTokensAsStringTest.inc | 25 ++ tests/Core/File/GetTokensAsStringTest.php | 334 ++++++++++++++++++++++ 2 files changed, 359 insertions(+) create mode 100644 tests/Core/File/GetTokensAsStringTest.inc create mode 100644 tests/Core/File/GetTokensAsStringTest.php diff --git a/tests/Core/File/GetTokensAsStringTest.inc b/tests/Core/File/GetTokensAsStringTest.inc new file mode 100644 index 0000000000..ace5a9bd41 --- /dev/null +++ b/tests/Core/File/GetTokensAsStringTest.inc @@ -0,0 +1,25 @@ + 20; +} + +/* testEchoWithTabs */ +echo 'foo', + 'bar' , + 'baz'; + +/* testEndOfFile */ +echo $foo; diff --git a/tests/Core/File/GetTokensAsStringTest.php b/tests/Core/File/GetTokensAsStringTest.php new file mode 100644 index 0000000000..5728c481ed --- /dev/null +++ b/tests/Core/File/GetTokensAsStringTest.php @@ -0,0 +1,334 @@ + + * @copyright 2022-2024 PHPCSStandards Contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\File; + +use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; + +/** + * Tests for the \PHP_CodeSniffer\Files\File:getTokensAsString method. + * + * @covers \PHP_CodeSniffer\Files\File::getTokensAsString + */ +class GetTokensAsStringTest extends AbstractMethodUnitTest +{ + + + /** + * Test passing a non-existent token pointer. + * + * @return void + */ + public function testNonExistentToken() + { + $this->expectRunTimeException('The $start position for getTokensAsString() must exist in the token stack'); + + self::$phpcsFile->getTokensAsString(100000, 10); + + }//end testNonExistentToken() + + + /** + * Test passing a non integer `$start`, like the result of a failed $phpcsFile->findNext(). + * + * @return void + */ + public function testNonIntegerStart() + { + $this->expectRunTimeException('The $start position for getTokensAsString() must exist in the token stack'); + + self::$phpcsFile->getTokensAsString(false, 10); + + }//end testNonIntegerStart() + + + /** + * Test passing a non integer `$length`. + * + * @return void + */ + public function testNonIntegerLength() + { + $result = self::$phpcsFile->getTokensAsString(10, false); + $this->assertSame('', $result); + + $result = self::$phpcsFile->getTokensAsString(10, 1.5); + $this->assertSame('', $result); + + }//end testNonIntegerLength() + + + /** + * Test passing a zero or negative `$length`. + * + * @return void + */ + public function testLengthEqualToOrLessThanZero() + { + $result = self::$phpcsFile->getTokensAsString(10, -10); + $this->assertSame('', $result); + + $result = self::$phpcsFile->getTokensAsString(10, 0); + $this->assertSame('', $result); + + }//end testLengthEqualToOrLessThanZero() + + + /** + * Test passing a `$length` beyond the end of the file. + * + * @return void + */ + public function testLengthBeyondEndOfFile() + { + $semicolon = $this->getTargetToken('/* testEndOfFile */', T_SEMICOLON); + $result = self::$phpcsFile->getTokensAsString($semicolon, 20); + $this->assertSame( + '; +', + $result + ); + + }//end testLengthBeyondEndOfFile() + + + /** + * Test getting a token set as a string. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int|string $startTokenType The type of token(s) to look for for the start of the string. + * @param int $length Token length to get. + * @param string $expected The expected function return value. + * + * @dataProvider dataGetTokensAsString() + * + * @return void + */ + public function testGetTokensAsString($testMarker, $startTokenType, $length, $expected) + { + $start = $this->getTargetToken($testMarker, $startTokenType); + $result = self::$phpcsFile->getTokensAsString($start, $length); + $this->assertSame($expected, $result); + + }//end testGetTokensAsString() + + + /** + * Data provider. + * + * @see testGetTokensAsString() For the array format. + * + * @return array> + */ + public static function dataGetTokensAsString() + { + return [ + 'length-0' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 0, + 'expected' => '', + ], + 'length-1' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 1, + 'expected' => '1', + ], + 'length-2' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 2, + 'expected' => '1 ', + ], + 'length-3' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 3, + 'expected' => '1 +', + ], + 'length-4' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 4, + 'expected' => '1 + ', + ], + 'length-5' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 5, + 'expected' => '1 + 2', + ], + 'length-6' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 6, + 'expected' => '1 + 2 ', + ], + 'length-7' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 7, + 'expected' => '1 + 2 +', + ], + 'length-8' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 8, + 'expected' => '1 + 2 + +', + ], + 'length-9' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 9, + 'expected' => '1 + 2 + + ', + ], + 'length-10' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 10, + 'expected' => '1 + 2 + + // Comment. +', + ], + 'length-11' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 11, + 'expected' => '1 + 2 + + // Comment. + ', + ], + 'length-12' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 12, + 'expected' => '1 + 2 + + // Comment. + 3', + ], + 'length-13' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 13, + 'expected' => '1 + 2 + + // Comment. + 3 ', + ], + 'length-14' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 14, + 'expected' => '1 + 2 + + // Comment. + 3 +', + ], + 'length-34' => [ + 'testMarker' => '/* testCalculation */', + 'startTokenType' => T_LNUMBER, + 'length' => 34, + 'expected' => '1 + 2 + + // Comment. + 3 + 4 + + 5 + 6 + 7 > 20;', + ], + 'namespace' => [ + 'testMarker' => '/* testNamespace */', + 'startTokenType' => T_NAMESPACE, + 'length' => 8, + 'expected' => 'namespace Foo\Bar\Baz;', + ], + 'use-with-comments' => [ + 'testMarker' => '/* testUseWithComments */', + 'startTokenType' => T_USE, + 'length' => 17, + 'expected' => 'use Foo /*comment*/ \ Bar + // phpcs:ignore Stnd.Cat.Sniff -- For reasons. + \ Bah;', + ], + 'echo-with-tabs' => [ + 'testMarker' => '/* testEchoWithTabs */', + 'startTokenType' => T_ECHO, + 'length' => 13, + 'expected' => 'echo \'foo\', + \'bar\' , + \'baz\';', + ], + 'end-of-file' => [ + 'testMarker' => '/* testEndOfFile */', + 'startTokenType' => T_ECHO, + 'length' => 4, + 'expected' => 'echo $foo;', + ], + ]; + + }//end dataGetTokensAsString() + + + /** + * Test getting a token set as a string with the original, non tab-replaced content. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int|string $startTokenType The type of token(s) to look for for the start of the string. + * @param int $length Token length to get. + * @param string $expected The expected function return value. + * + * @dataProvider dataGetOrigContent() + * + * @return void + */ + public function testGetOrigContent($testMarker, $startTokenType, $length, $expected) + { + $start = $this->getTargetToken($testMarker, $startTokenType); + $result = self::$phpcsFile->getTokensAsString($start, $length, true); + $this->assertSame($expected, $result); + + }//end testGetOrigContent() + + + /** + * Data provider. + * + * @see testGetOrigContent() For the array format. + * + * @return array> + */ + public static function dataGetOrigContent() + { + return [ + 'use-with-comments' => [ + 'testMarker' => '/* testUseWithComments */', + 'startTokenType' => T_USE, + 'length' => 17, + 'expected' => 'use Foo /*comment*/ \ Bar + // phpcs:ignore Stnd.Cat.Sniff -- For reasons. + \ Bah;', + ], + 'echo-with-tabs' => [ + 'testMarker' => '/* testEchoWithTabs */', + 'startTokenType' => T_ECHO, + 'length' => 13, + 'expected' => 'echo \'foo\', + \'bar\' , + \'baz\';', + ], + 'end-of-file' => [ + 'testMarker' => '/* testEndOfFile */', + 'startTokenType' => T_ECHO, + 'length' => 4, + 'expected' => 'echo $foo;', + ], + ]; + + }//end dataGetOrigContent() + + +}//end class From 2245a6b0a53fe41eebd4402ac09cc903e9d32013 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 19 Dec 2023 16:01:03 -0300 Subject: [PATCH 217/874] Generic/PHP/Syntax: add XML documentation --- .../Generic/Docs/PHP/SyntaxStandard.xml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/Standards/Generic/Docs/PHP/SyntaxStandard.xml diff --git a/src/Standards/Generic/Docs/PHP/SyntaxStandard.xml b/src/Standards/Generic/Docs/PHP/SyntaxStandard.xml new file mode 100644 index 0000000000..1c2457df0a --- /dev/null +++ b/src/Standards/Generic/Docs/PHP/SyntaxStandard.xml @@ -0,0 +1,21 @@ + + + + + + + echo "Hello!"; +$array = [1, 2, 3]; + ]]> + + + // Missing semicolon. +$array = [1, 2, 3; // Missing closing bracket. + ]]> + + + From 8534f8dddaf1c85d07279507f1edc61f4d2a9dba Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 08:15:03 +0100 Subject: [PATCH 218/874] Tests/GetMemberPropertiesTest: minor tweak ... to improve the descriptiveness of one test. --- tests/Core/File/GetMemberPropertiesTest.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Core/File/GetMemberPropertiesTest.inc b/tests/Core/File/GetMemberPropertiesTest.inc index 441bd97772..61ab56564c 100644 --- a/tests/Core/File/GetMemberPropertiesTest.inc +++ b/tests/Core/File/GetMemberPropertiesTest.inc @@ -245,7 +245,7 @@ $anon = class() { public readonly int $readonly; /* testPHP81ReadonlyWithNullableType */ - public readonly ?array $array; + public readonly ?array $readonlyWithNullableType; /* testPHP81ReadonlyWithUnionType */ public readonly string|int $readonlyWithUnionType; From 793bd3cde861b0aa81ddb14ee3626fb10e6123ff Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 08:41:56 +0100 Subject: [PATCH 219/874] Tests/GetMemberPropertiesTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes fixing the data types in the docblocks and making them more specific, where relevant. --- tests/Core/File/GetMemberPropertiesTest.php | 466 ++++++++++---------- 1 file changed, 233 insertions(+), 233 deletions(-) diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index 36bf4d7d3e..e069c20a59 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -23,8 +23,8 @@ class GetMemberPropertiesTest extends AbstractMethodUnitTest /** * Test the getMemberProperties() method. * - * @param string $identifier Comment which precedes the test case. - * @param bool $expected Expected function output. + * @param string $identifier Comment which precedes the test case. + * @param array $expected Expected function output. * * @dataProvider dataGetMemberProperties * @@ -48,14 +48,14 @@ public function testGetMemberProperties($identifier, $expected) * * @see testGetMemberProperties() * - * @return array + * @return array>> */ public function dataGetMemberProperties() { return [ - [ - '/* testVar */', - [ + 'var-modifier' => [ + 'identifier' => '/* testVar */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => false, 'is_static' => false, @@ -64,9 +64,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testVarType */', - [ + 'var-modifier-and-type' => [ + 'identifier' => '/* testVarType */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => false, 'is_static' => false, @@ -75,9 +75,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testPublic */', - [ + 'public-modifier' => [ + 'identifier' => '/* testPublic */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -86,9 +86,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPublicType */', - [ + 'public-modifier-and-type' => [ + 'identifier' => '/* testPublicType */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -97,9 +97,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testProtected */', - [ + 'protected-modifier' => [ + 'identifier' => '/* testProtected */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => false, @@ -108,9 +108,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testProtectedType */', - [ + 'protected-modifier-and-type' => [ + 'identifier' => '/* testProtectedType */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => false, @@ -119,9 +119,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPrivate */', - [ + 'private-modifier' => [ + 'identifier' => '/* testPrivate */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -130,9 +130,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPrivateType */', - [ + 'private-modifier-and-type' => [ + 'identifier' => '/* testPrivateType */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -141,9 +141,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testStatic */', - [ + 'static-modifier' => [ + 'identifier' => '/* testStatic */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => false, 'is_static' => true, @@ -152,9 +152,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testStaticType */', - [ + 'static-modifier-and-type' => [ + 'identifier' => '/* testStaticType */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => false, 'is_static' => true, @@ -163,9 +163,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testStaticVar */', - [ + 'static-and-var-modifier' => [ + 'identifier' => '/* testStaticVar */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => false, 'is_static' => true, @@ -174,9 +174,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testVarStatic */', - [ + 'var-and-static-modifier' => [ + 'identifier' => '/* testVarStatic */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => false, 'is_static' => true, @@ -185,9 +185,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPublicStatic */', - [ + 'public-static-modifiers' => [ + 'identifier' => '/* testPublicStatic */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => true, @@ -196,9 +196,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testProtectedStatic */', - [ + 'protected-static-modifiers' => [ + 'identifier' => '/* testProtectedStatic */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => true, @@ -207,9 +207,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPrivateStatic */', - [ + 'private-static-modifiers' => [ + 'identifier' => '/* testPrivateStatic */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => true, @@ -218,9 +218,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testNoPrefix */', - [ + 'no-modifier' => [ + 'identifier' => '/* testNoPrefix */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => false, 'is_static' => false, @@ -229,9 +229,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPublicStaticWithDocblock */', - [ + 'public-and-static-modifier-with-docblock' => [ + 'identifier' => '/* testPublicStaticWithDocblock */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => true, @@ -240,9 +240,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testProtectedStaticWithDocblock */', - [ + 'protected-and-static-modifier-with-docblock' => [ + 'identifier' => '/* testProtectedStaticWithDocblock */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => true, @@ -251,9 +251,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPrivateStaticWithDocblock */', - [ + 'private-and-static-modifier-with-docblock' => [ + 'identifier' => '/* testPrivateStaticWithDocblock */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => true, @@ -262,9 +262,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupType 1 */', - [ + 'property-group-simple-type-prop-1' => [ + 'identifier' => '/* testGroupType 1 */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -273,9 +273,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupType 2 */', - [ + 'property-group-simple-type-prop-2' => [ + 'identifier' => '/* testGroupType 2 */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -284,9 +284,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupNullableType 1 */', - [ + 'property-group-nullable-type-prop-1' => [ + 'identifier' => '/* testGroupNullableType 1 */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => true, @@ -295,9 +295,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testGroupNullableType 2 */', - [ + 'property-group-nullable-type-prop-2' => [ + 'identifier' => '/* testGroupNullableType 2 */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => true, @@ -306,9 +306,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testGroupProtectedStatic 1 */', - [ + 'property-group-protected-static-prop-1' => [ + 'identifier' => '/* testGroupProtectedStatic 1 */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => true, @@ -317,9 +317,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupProtectedStatic 2 */', - [ + 'property-group-protected-static-prop-2' => [ + 'identifier' => '/* testGroupProtectedStatic 2 */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => true, @@ -328,9 +328,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupProtectedStatic 3 */', - [ + 'property-group-protected-static-prop-3' => [ + 'identifier' => '/* testGroupProtectedStatic 3 */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => true, @@ -339,9 +339,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupPrivate 1 */', - [ + 'property-group-private-prop-1' => [ + 'identifier' => '/* testGroupPrivate 1 */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -350,9 +350,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupPrivate 2 */', - [ + 'property-group-private-prop-2' => [ + 'identifier' => '/* testGroupPrivate 2 */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -361,9 +361,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupPrivate 3 */', - [ + 'property-group-private-prop-3' => [ + 'identifier' => '/* testGroupPrivate 3 */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -372,9 +372,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupPrivate 4 */', - [ + 'property-group-private-prop-4' => [ + 'identifier' => '/* testGroupPrivate 4 */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -383,9 +383,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupPrivate 5 */', - [ + 'property-group-private-prop-5' => [ + 'identifier' => '/* testGroupPrivate 5 */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -394,9 +394,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupPrivate 6 */', - [ + 'property-group-private-prop-6' => [ + 'identifier' => '/* testGroupPrivate 6 */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -405,9 +405,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testGroupPrivate 7 */', - [ + 'property-group-private-prop-7' => [ + 'identifier' => '/* testGroupPrivate 7 */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -416,9 +416,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testMessyNullableType */', - [ + 'messy-nullable-type' => [ + 'identifier' => '/* testMessyNullableType */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -427,9 +427,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testNamespaceType */', - [ + 'fqn-type' => [ + 'identifier' => '/* testNamespaceType */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -438,9 +438,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testNullableNamespaceType 1 */', - [ + 'nullable-classname-type' => [ + 'identifier' => '/* testNullableNamespaceType 1 */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -449,9 +449,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testNullableNamespaceType 2 */', - [ + 'nullable-namespace-relative-class-type' => [ + 'identifier' => '/* testNullableNamespaceType 2 */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => false, @@ -460,9 +460,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testMultilineNamespaceType */', - [ + 'multiline-namespaced-type' => [ + 'identifier' => '/* testMultilineNamespaceType */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -471,9 +471,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPropertyAfterMethod */', - [ + 'property-after-method' => [ + 'identifier' => '/* testPropertyAfterMethod */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => true, @@ -482,13 +482,13 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testInterfaceProperty */', - [], + 'invalid-property-in-interface' => [ + 'identifier' => '/* testInterfaceProperty */', + 'expected' => [], ], - [ - '/* testNestedProperty 1 */', - [ + 'property-in-nested-class-1' => [ + 'identifier' => '/* testNestedProperty 1 */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -497,9 +497,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testNestedProperty 2 */', - [ + 'property-in-nested-class-2' => [ + 'identifier' => '/* testNestedProperty 2 */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -508,9 +508,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8MixedTypeHint */', - [ + 'php8-mixed-type' => [ + 'identifier' => '/* testPHP8MixedTypeHint */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => true, @@ -519,9 +519,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8MixedTypeHintNullable */', - [ + 'php8-nullable-mixed-type' => [ + 'identifier' => '/* testPHP8MixedTypeHintNullable */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -530,9 +530,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testNamespaceOperatorTypeHint */', - [ + 'namespace-operator-type-declaration' => [ + 'identifier' => '/* testNamespaceOperatorTypeHint */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -541,9 +541,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testPHP8UnionTypesSimple */', - [ + 'php8-union-types-simple' => [ + 'identifier' => '/* testPHP8UnionTypesSimple */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -552,9 +552,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8UnionTypesTwoClasses */', - [ + 'php8-union-types-two-classes' => [ + 'identifier' => '/* testPHP8UnionTypesTwoClasses */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -563,9 +563,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8UnionTypesAllBaseTypes */', - [ + 'php8-union-types-all-base-types' => [ + 'identifier' => '/* testPHP8UnionTypesAllBaseTypes */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => false, @@ -574,9 +574,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8UnionTypesAllPseudoTypes */', - [ + 'php8-union-types-all-pseudo-types' => [ + 'identifier' => '/* testPHP8UnionTypesAllPseudoTypes */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => false, 'is_static' => false, @@ -585,9 +585,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8UnionTypesIllegalTypes */', - [ + 'php8-union-types-illegal-types' => [ + 'identifier' => '/* testPHP8UnionTypesIllegalTypes */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -596,9 +596,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8UnionTypesNullable */', - [ + 'php8-union-types-nullable' => [ + 'identifier' => '/* testPHP8UnionTypesNullable */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -607,9 +607,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testPHP8PseudoTypeNull */', - [ + 'php8-union-types-pseudo-type-null' => [ + 'identifier' => '/* testPHP8PseudoTypeNull */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -618,9 +618,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8PseudoTypeFalse */', - [ + 'php8-union-types-pseudo-type-false' => [ + 'identifier' => '/* testPHP8PseudoTypeFalse */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -629,9 +629,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8PseudoTypeFalseAndBool */', - [ + 'php8-union-types-pseudo-type-false-and-bool' => [ + 'identifier' => '/* testPHP8PseudoTypeFalseAndBool */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -640,9 +640,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8ObjectAndClass */', - [ + 'php8-union-types-object-and-class' => [ + 'identifier' => '/* testPHP8ObjectAndClass */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -651,9 +651,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8PseudoTypeIterableAndArray */', - [ + 'php8-union-types-pseudo-type-iterable-and-array' => [ + 'identifier' => '/* testPHP8PseudoTypeIterableAndArray */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -662,9 +662,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8DuplicateTypeInUnionWhitespaceAndComment */', - [ + 'php8-union-types-duplicate-type-with-whitespace-and-comments' => [ + 'identifier' => '/* testPHP8DuplicateTypeInUnionWhitespaceAndComment */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -673,9 +673,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP81Readonly */', - [ + 'php8.1-readonly-property' => [ + 'identifier' => '/* testPHP81Readonly */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -684,9 +684,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP81ReadonlyWithNullableType */', - [ + 'php8.1-readonly-property-with-nullable-type' => [ + 'identifier' => '/* testPHP81ReadonlyWithNullableType */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -695,9 +695,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testPHP81ReadonlyWithUnionType */', - [ + 'php8.1-readonly-property-with-union-type' => [ + 'identifier' => '/* testPHP81ReadonlyWithUnionType */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -706,9 +706,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP81ReadonlyWithUnionTypeWithNull */', - [ + 'php8.1-readonly-property-with-union-type-with-null' => [ + 'identifier' => '/* testPHP81ReadonlyWithUnionTypeWithNull */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => false, @@ -717,9 +717,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP81OnlyReadonlyWithUnionType */', - [ + 'php8.1-readonly-property-with-union-type-no-visibility' => [ + 'identifier' => '/* testPHP81OnlyReadonlyWithUnionType */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => false, 'is_static' => false, @@ -728,9 +728,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8PropertySingleAttribute */', - [ + 'php8-property-with-single-attribute' => [ + 'identifier' => '/* testPHP8PropertySingleAttribute */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -739,9 +739,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP8PropertyMultipleAttributes */', - [ + 'php8-property-with-multiple-attributes' => [ + 'identifier' => '/* testPHP8PropertyMultipleAttributes */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => false, @@ -750,9 +750,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testPHP8PropertyMultilineAttribute */', - [ + 'php8-property-with-multiline-attribute' => [ + 'identifier' => '/* testPHP8PropertyMultilineAttribute */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -761,13 +761,13 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testEnumProperty */', - [], + 'invalid-property-in-enum' => [ + 'identifier' => '/* testEnumProperty */', + 'expected' => [], ], - [ - '/* testPHP81IntersectionTypes */', - [ + 'php8.1-single-intersection-type' => [ + 'identifier' => '/* testPHP81IntersectionTypes */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -776,9 +776,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP81MoreIntersectionTypes */', - [ + 'php8.1-multi-intersection-type' => [ + 'identifier' => '/* testPHP81MoreIntersectionTypes */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -787,9 +787,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP81IllegalIntersectionTypes */', - [ + 'php8.1-illegal-intersection-type' => [ + 'identifier' => '/* testPHP81IllegalIntersectionTypes */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -798,9 +798,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP81NullableIntersectionType */', - [ + 'php8.1-nullable-intersection-type' => [ + 'identifier' => '/* testPHP81NullableIntersectionType */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -809,9 +809,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testPHP82PseudoTypeTrue */', - [ + 'php8.2-pseudo-type-true' => [ + 'identifier' => '/* testPHP82PseudoTypeTrue */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => true, 'is_static' => false, @@ -820,9 +820,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP82NullablePseudoTypeTrue */', - [ + 'php8.2-pseudo-type-true-nullable' => [ + 'identifier' => '/* testPHP82NullablePseudoTypeTrue */', + 'expected' => [ 'scope' => 'protected', 'scope_specified' => true, 'is_static' => true, @@ -831,9 +831,9 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], - [ - '/* testPHP82PseudoTypeTrueInUnion */', - [ + 'php8.2-pseudo-type-true-in-union' => [ + 'identifier' => '/* testPHP82PseudoTypeTrueInUnion */', + 'expected' => [ 'scope' => 'private', 'scope_specified' => true, 'is_static' => false, @@ -842,9 +842,9 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], - [ - '/* testPHP82PseudoTypeFalseAndTrue */', - [ + 'php8.2-pseudo-type-invalid-true-false-union' => [ + 'identifier' => '/* testPHP82PseudoTypeFalseAndTrue */', + 'expected' => [ 'scope' => 'public', 'scope_specified' => false, 'is_static' => false, @@ -883,18 +883,18 @@ public function testNotClassPropertyException($identifier) * * @see testNotClassPropertyException() * - * @return array + * @return array> */ public function dataNotClassProperty() { return [ - ['/* testMethodParam */'], - ['/* testImportedGlobal */'], - ['/* testLocalVariable */'], - ['/* testGlobalVariable */'], - ['/* testNestedMethodParam 1 */'], - ['/* testNestedMethodParam 2 */'], - ['/* testEnumMethodParamNotProperty */'], + 'method parameter' => ['/* testMethodParam */'], + 'variable import using global keyword' => ['/* testImportedGlobal */'], + 'function local variable' => ['/* testLocalVariable */'], + 'global variable' => ['/* testGlobalVariable */'], + 'method parameter in anon class nested in ternary' => ['/* testNestedMethodParam 1 */'], + 'method parameter in anon class nested in function call' => ['/* testNestedMethodParam 2 */'], + 'method parameter in enum' => ['/* testEnumMethodParamNotProperty */'], ]; }//end dataNotClassProperty() From 7907530c71b1d7fcd81a01287d30eba0c8482a05 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 08:55:41 +0100 Subject: [PATCH 220/874] Tests/GetMemberPropertiesTest: more thoroughly test existing tests This adds testing of the `type_token` and `type_end_token` return value indexes to the pre-existing tests, same as was already being tested in PHPCSUtils. --- tests/Core/File/GetMemberPropertiesTest.php | 159 +++++++++++++++++++- 1 file changed, 157 insertions(+), 2 deletions(-) diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index e069c20a59..333dc98ae7 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -35,8 +35,14 @@ public function testGetMemberProperties($identifier, $expected) $variable = $this->getTargetToken($identifier, T_VARIABLE); $result = self::$phpcsFile->getMemberProperties($variable); - // Unset those indexes which are not being tested. - unset($result['type_token'], $result['type_end_token']); + // Convert offsets to absolute positions in the token stream. + if (isset($expected['type_token']) === true && is_int($expected['type_token']) === true) { + $expected['type_token'] += $variable; + } + + if (isset($expected['type_end_token']) === true && is_int($expected['type_end_token']) === true) { + $expected['type_end_token'] += $variable; + } $this->assertSame($expected, $result); @@ -46,6 +52,10 @@ public function testGetMemberProperties($identifier, $expected) /** * Data provider for the GetMemberProperties test. * + * Note: the `expected - type_token` and `expected - type_end_token` indexes should + * contain either `false` (no type) or the _offset_ of the type start/end token in + * relation to the `T_VARIABLE` token which is passed to the getMemberProperties() method. + * * @see testGetMemberProperties() * * @return array>> @@ -61,6 +71,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -72,6 +84,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '?int', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -83,6 +97,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -94,6 +110,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'string', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -105,6 +123,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -116,6 +136,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'bool', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -127,6 +149,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -138,6 +162,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'array', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -149,6 +175,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -160,6 +188,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '?string', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -171,6 +201,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -182,6 +214,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -193,6 +227,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -204,6 +240,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -215,6 +253,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -226,6 +266,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -237,6 +279,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -248,6 +292,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -259,6 +305,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -270,6 +318,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'float', + 'type_token' => -6, + 'type_end_token' => -6, 'nullable_type' => false, ], ], @@ -281,6 +331,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'float', + 'type_token' => -13, + 'type_end_token' => -13, 'nullable_type' => false, ], ], @@ -292,6 +344,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '?string', + 'type_token' => -6, + 'type_end_token' => -6, 'nullable_type' => true, ], ], @@ -303,6 +357,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '?string', + 'type_token' => -17, + 'type_end_token' => -17, 'nullable_type' => true, ], ], @@ -314,6 +370,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -325,6 +383,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -336,6 +396,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -347,6 +409,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -358,6 +422,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -369,6 +435,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -380,6 +448,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -391,6 +461,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -402,6 +474,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -413,6 +487,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -424,6 +500,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '?array', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -435,6 +513,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '\MyNamespace\MyClass', + 'type_token' => -5, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -446,6 +526,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '?ClassName', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -457,6 +539,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '?Folder\ClassName', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -468,6 +552,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '\MyNamespace\MyClass\Foo', + 'type_token' => -18, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -479,6 +565,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -494,6 +582,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -505,6 +595,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '', + 'type_token' => false, + 'type_end_token' => false, 'nullable_type' => false, ], ], @@ -516,6 +608,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => 'miXed', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -527,6 +621,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '?mixed', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -538,6 +634,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '?namespace\Name', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -549,6 +647,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'int|float', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -560,6 +660,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'MyClassA|\Package\MyClassB', + 'type_token' => -7, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -571,6 +673,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'array|bool|int|float|NULL|object|string', + 'type_token' => -14, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -582,6 +686,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'false|mixed|self|parent|iterable|Resource', + 'type_token' => -12, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -592,7 +698,10 @@ public function dataGetMemberProperties() 'scope_specified' => true, 'is_static' => false, 'is_readonly' => false, + // Missing static, but that's OK as not an allowed syntax. 'type' => 'callable|void', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -604,6 +713,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '?int|float', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -615,6 +726,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'null', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -626,6 +739,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'false', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -637,6 +752,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'bool|FALSE', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -648,6 +765,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'object|ClassName', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -659,6 +778,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'iterable|array|Traversable', + 'type_token' => -6, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -670,6 +791,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'int|string|INT', + 'type_token' => -10, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -681,6 +804,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => true, 'type' => 'int', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -692,6 +817,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => true, 'type' => '?array', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -703,6 +830,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => true, 'type' => 'string|int', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -714,6 +843,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => true, 'type' => 'string|null', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -725,6 +856,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => true, 'type' => 'string|int', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -736,6 +869,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'string', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -747,6 +882,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '?int|float', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -758,6 +895,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'mixed', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -773,6 +912,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'Foo&Bar', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -784,6 +925,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'Foo&Bar&Baz', + 'type_token' => -6, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -795,6 +938,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'int&string', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -806,6 +951,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => '?Foo&Bar', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -817,6 +964,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'true', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -828,6 +977,8 @@ public function dataGetMemberProperties() 'is_static' => true, 'is_readonly' => false, 'type' => '?true', + 'type_token' => -2, + 'type_end_token' => -2, 'nullable_type' => true, ], ], @@ -839,6 +990,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => false, 'type' => 'int|string|true', + 'type_token' => -6, + 'type_end_token' => -2, 'nullable_type' => false, ], ], @@ -850,6 +1003,8 @@ public function dataGetMemberProperties() 'is_static' => false, 'is_readonly' => true, 'type' => 'true|FALSE', + 'type_token' => -4, + 'type_end_token' => -2, 'nullable_type' => false, ], ], From fcc764b300b229d405af7a2c7d168cc2ef2bd8ff Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 09:05:49 +0100 Subject: [PATCH 221/874] Tests/GetMemberPropertiesTest: add extra tests This adds some extra tests which were already in use in PHPCSUtils. --- tests/Core/File/GetMemberPropertiesTest.inc | 23 ++++++- tests/Core/File/GetMemberPropertiesTest.php | 66 +++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/tests/Core/File/GetMemberPropertiesTest.inc b/tests/Core/File/GetMemberPropertiesTest.inc index 61ab56564c..f69a685ecf 100644 --- a/tests/Core/File/GetMemberPropertiesTest.inc +++ b/tests/Core/File/GetMemberPropertiesTest.inc @@ -39,7 +39,10 @@ class TestMemberProperties var static $varG = true; /* testPublicStatic */ - public static $varH = true; + public // comment + // phpcs:ignore Stnd.Cat.Sniff -- For reasons. + static + $varH = true; /* testProtectedStatic */ static protected $varI = true; @@ -255,6 +258,16 @@ $anon = class() { /* testPHP81OnlyReadonlyWithUnionType */ readonly string|int $onlyReadonly; + + /* testPHP81OnlyReadonlyWithUnionTypeMultiple */ + readonly \InterfaceA|\Sub\InterfaceB|false + $onlyReadonly; + + /* testPHP81ReadonlyAndStatic */ + readonly private static ?string $readonlyAndStatic; + + /* testPHP81ReadonlyMixedCase */ + public ReadONLY static $readonlyMixedCase; }; $anon = class { @@ -318,3 +331,11 @@ $anon = class() { // Intentional fatal error - Type contains both true and false, bool should be used instead, but that's not the concern of the method. readonly true|FALSE $pseudoTypeFalseAndTrue; }; + +class WhitespaceAndCommentsInTypes { + /* testUnionTypeWithWhitespaceAndComment */ + public int | /*comment*/ string $hasWhitespaceAndComment; + + /* testIntersectionTypeWithWhitespaceAndComment */ + public \Foo /*comment*/ & Bar $hasWhitespaceAndComment; +} diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index 333dc98ae7..24a170ae92 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -861,6 +861,45 @@ public function dataGetMemberProperties() 'nullable_type' => false, ], ], + 'php8.1-readonly-property-with-multi-union-type-no-visibility' => [ + 'identifier' => '/* testPHP81OnlyReadonlyWithUnionTypeMultiple */', + 'expected' => [ + 'scope' => 'public', + 'scope_specified' => false, + 'is_static' => false, + 'is_readonly' => true, + 'type' => '\InterfaceA|\Sub\InterfaceB|false', + 'type_token' => -11, + 'type_end_token' => -3, + 'nullable_type' => false, + ], + ], + 'php8.1-readonly-and-static-property' => [ + 'identifier' => '/* testPHP81ReadonlyAndStatic */', + 'expected' => [ + 'scope' => 'private', + 'scope_specified' => true, + 'is_static' => true, + 'is_readonly' => true, + 'type' => '?string', + 'type_token' => -2, + 'type_end_token' => -2, + 'nullable_type' => true, + ], + ], + 'php8.1-readonly-mixed-case-keyword' => [ + 'identifier' => '/* testPHP81ReadonlyMixedCase */', + 'expected' => [ + 'scope' => 'public', + 'scope_specified' => true, + 'is_static' => true, + 'is_readonly' => true, + 'type' => '', + 'type_token' => false, + 'type_end_token' => false, + 'nullable_type' => false, + ], + ], 'php8-property-with-single-attribute' => [ 'identifier' => '/* testPHP8PropertySingleAttribute */', 'expected' => [ @@ -956,6 +995,33 @@ public function dataGetMemberProperties() 'nullable_type' => true, ], ], + + 'php8.0-union-type-with-whitespace-and-comment' => [ + 'identifier' => '/* testUnionTypeWithWhitespaceAndComment */', + 'expected' => [ + 'scope' => 'public', + 'scope_specified' => true, + 'is_static' => false, + 'is_readonly' => false, + 'type' => 'int|string', + 'type_token' => -8, + 'type_end_token' => -2, + 'nullable_type' => false, + ], + ], + 'php8.1-intersection-type-with-whitespace-and-comment' => [ + 'identifier' => '/* testIntersectionTypeWithWhitespaceAndComment */', + 'expected' => [ + 'scope' => 'public', + 'scope_specified' => true, + 'is_static' => false, + 'is_readonly' => false, + 'type' => '\Foo&Bar', + 'type_token' => -9, + 'type_end_token' => -2, + 'nullable_type' => false, + ], + ], 'php8.2-pseudo-type-true' => [ 'identifier' => '/* testPHP82PseudoTypeTrue */', 'expected' => [ From 4a759e3a54a2cb9ae45834f2449ef430f934c186 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 18:03:21 +0100 Subject: [PATCH 222/874] Tests/GetMethodPropertiesTest: more thoroughly test existing tests This adds testing of the `return_type_token` and `return_type_end_token` return value indexes to the pre-existing tests, same as was already being tested in PHPCSUtils. :point_right: the diff will be easiest to review while ignoring whitespace differences due to the array alignment changes to comply with CS. --- tests/Core/File/GetMethodPropertiesTest.php | 770 ++++++++++++-------- 1 file changed, 446 insertions(+), 324 deletions(-) diff --git a/tests/Core/File/GetMethodPropertiesTest.php b/tests/Core/File/GetMethodPropertiesTest.php index e971611ea4..4177537ff3 100644 --- a/tests/Core/File/GetMethodPropertiesTest.php +++ b/tests/Core/File/GetMethodPropertiesTest.php @@ -28,14 +28,16 @@ class GetMethodPropertiesTest extends AbstractMethodUnitTest public function testBasicFunction() { $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '', + 'return_type_token' => false, + 'return_type_end_token' => false, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -50,15 +52,18 @@ public function testBasicFunction() */ public function testReturnFunction() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'array', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'array', + 'return_type_token' => 11, + 'return_type_end_token' => 11, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -73,15 +78,18 @@ public function testReturnFunction() */ public function testNestedClosure() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'int', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'int', + 'return_type_token' => 8, + 'return_type_end_token' => 8, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -97,14 +105,16 @@ public function testNestedClosure() public function testBasicMethod() { $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '', + 'return_type_token' => false, + 'return_type_end_token' => false, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -120,14 +130,16 @@ public function testBasicMethod() public function testPrivateStaticMethod() { $expected = [ - 'scope' => 'private', - 'scope_specified' => true, - 'return_type' => '', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => true, - 'has_body' => true, + 'scope' => 'private', + 'scope_specified' => true, + 'return_type' => '', + 'return_type_token' => false, + 'return_type_end_token' => false, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => true, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -143,14 +155,16 @@ public function testPrivateStaticMethod() public function testFinalMethod() { $expected = [ - 'scope' => 'public', - 'scope_specified' => true, - 'return_type' => '', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => true, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => true, + 'return_type' => '', + 'return_type_token' => false, + 'return_type_end_token' => false, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => true, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -165,15 +179,18 @@ public function testFinalMethod() */ public function testProtectedReturnMethod() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'protected', - 'scope_specified' => true, - 'return_type' => 'int', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'protected', + 'scope_specified' => true, + 'return_type' => 'int', + 'return_type_token' => 8, + 'return_type_end_token' => 8, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -188,15 +205,18 @@ public function testProtectedReturnMethod() */ public function testPublicReturnMethod() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => true, - 'return_type' => 'array', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => true, + 'return_type' => 'array', + 'return_type_token' => 7, + 'return_type_end_token' => 7, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -211,15 +231,18 @@ public function testPublicReturnMethod() */ public function testNullableReturnMethod() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => true, - 'return_type' => '?array', - 'nullable_return_type' => true, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => true, + 'return_type' => '?array', + 'return_type_token' => 8, + 'return_type_end_token' => 8, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -234,15 +257,18 @@ public function testNullableReturnMethod() */ public function testMessyNullableReturnMethod() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => true, - 'return_type' => '?array', - 'nullable_return_type' => true, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => true, + 'return_type' => '?array', + 'return_type_token' => 18, + 'return_type_end_token' => 18, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -257,15 +283,18 @@ public function testMessyNullableReturnMethod() */ public function testReturnNamespace() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '\MyNamespace\MyClass', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '\MyNamespace\MyClass', + 'return_type_token' => 7, + 'return_type_end_token' => 10, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -280,15 +309,18 @@ public function testReturnNamespace() */ public function testReturnMultilineNamespace() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '\MyNamespace\MyClass\Foo', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '\MyNamespace\MyClass\Foo', + 'return_type_token' => 7, + 'return_type_end_token' => 23, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -304,14 +336,16 @@ public function testReturnMultilineNamespace() public function testAbstractMethod() { $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '', - 'nullable_return_type' => false, - 'is_abstract' => true, - 'is_final' => false, - 'is_static' => false, - 'has_body' => false, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '', + 'return_type_token' => false, + 'return_type_end_token' => false, + 'nullable_return_type' => false, + 'is_abstract' => true, + 'is_final' => false, + 'is_static' => false, + 'has_body' => false, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -326,15 +360,18 @@ public function testAbstractMethod() */ public function testAbstractReturnMethod() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'protected', - 'scope_specified' => true, - 'return_type' => 'bool', - 'nullable_return_type' => false, - 'is_abstract' => true, - 'is_final' => false, - 'is_static' => false, - 'has_body' => false, + 'scope' => 'protected', + 'scope_specified' => true, + 'return_type' => 'bool', + 'return_type_token' => 7, + 'return_type_end_token' => 7, + 'nullable_return_type' => false, + 'is_abstract' => true, + 'is_final' => false, + 'is_static' => false, + 'has_body' => false, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -350,14 +387,16 @@ public function testAbstractReturnMethod() public function testInterfaceMethod() { $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => false, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '', + 'return_type_token' => false, + 'return_type_end_token' => false, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => false, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -372,15 +411,18 @@ public function testInterfaceMethod() */ public function testArrowFunction() { + // Offsets are relative to the T_FN token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'int', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => true, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'int', + 'return_type_token' => 9, + 'return_type_end_token' => 9, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => true, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -395,15 +437,18 @@ public function testArrowFunction() */ public function testReturnTypeStatic() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'private', - 'scope_specified' => true, - 'return_type' => 'static', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'private', + 'scope_specified' => true, + 'return_type' => 'static', + 'return_type_token' => 7, + 'return_type_end_token' => 7, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -418,15 +463,18 @@ public function testReturnTypeStatic() */ public function testPHP8MixedTypeHint() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'mixed', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'mixed', + 'return_type_token' => 7, + 'return_type_end_token' => 7, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -441,15 +489,18 @@ public function testPHP8MixedTypeHint() */ public function testPHP8MixedTypeHintNullable() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '?mixed', - 'nullable_return_type' => true, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '?mixed', + 'return_type_token' => 8, + 'return_type_end_token' => 8, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -464,15 +515,18 @@ public function testPHP8MixedTypeHintNullable() */ public function testNamespaceOperatorTypeHint() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '?namespace\Name', - 'nullable_return_type' => true, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '?namespace\Name', + 'return_type_token' => 9, + 'return_type_end_token' => 11, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -487,15 +541,18 @@ public function testNamespaceOperatorTypeHint() */ public function testPHP8UnionTypesSimple() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'int|float', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'int|float', + 'return_type_token' => 9, + 'return_type_end_token' => 11, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -510,15 +567,18 @@ public function testPHP8UnionTypesSimple() */ public function testPHP8UnionTypesTwoClasses() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'MyClassA|\Package\MyClassB', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'MyClassA|\Package\MyClassB', + 'return_type_token' => 6, + 'return_type_end_token' => 11, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -533,15 +593,18 @@ public function testPHP8UnionTypesTwoClasses() */ public function testPHP8UnionTypesAllBaseTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'array|bool|callable|int|float|null|Object|string', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'array|bool|callable|int|float|null|Object|string', + 'return_type_token' => 8, + 'return_type_end_token' => 22, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -552,19 +615,24 @@ public function testPHP8UnionTypesAllBaseTypes() /** * Verify recognition of PHP8 union type declaration with all pseudo types. * + * Note: "Resource" is not a type, but seen as a class name. + * * @return void */ public function testPHP8UnionTypesAllPseudoTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'false|MIXED|self|parent|static|iterable|Resource|void', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'false|MIXED|self|parent|static|iterable|Resource|void', + 'return_type_token' => 9, + 'return_type_end_token' => 23, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -579,15 +647,18 @@ public function testPHP8UnionTypesAllPseudoTypes() */ public function testPHP8UnionTypesNullable() { + // Offsets are relative to the T_CLOSURE token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '?int|float', - 'nullable_return_type' => true, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '?int|float', + 'return_type_token' => 12, + 'return_type_end_token' => 14, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -602,15 +673,18 @@ public function testPHP8UnionTypesNullable() */ public function testPHP8PseudoTypeNull() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'null', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'null', + 'return_type_token' => 7, + 'return_type_end_token' => 7, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -625,15 +699,18 @@ public function testPHP8PseudoTypeNull() */ public function testPHP8PseudoTypeFalse() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'false', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'false', + 'return_type_token' => 7, + 'return_type_end_token' => 7, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -648,15 +725,18 @@ public function testPHP8PseudoTypeFalse() */ public function testPHP8PseudoTypeFalseAndBool() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'bool|false', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'bool|false', + 'return_type_token' => 7, + 'return_type_end_token' => 9, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -671,15 +751,18 @@ public function testPHP8PseudoTypeFalseAndBool() */ public function testPHP8ObjectAndClass() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'object|ClassName', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'object|ClassName', + 'return_type_token' => 7, + 'return_type_end_token' => 9, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -694,15 +777,18 @@ public function testPHP8ObjectAndClass() */ public function testPHP8PseudoTypeIterableAndArray() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => true, - 'return_type' => 'iterable|array|Traversable', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => false, + 'scope' => 'public', + 'scope_specified' => true, + 'return_type' => 'iterable|array|Traversable', + 'return_type_token' => 7, + 'return_type_end_token' => 11, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => false, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -717,15 +803,18 @@ public function testPHP8PseudoTypeIterableAndArray() */ public function testPHP8DuplicateTypeInUnionWhitespaceAndComment() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'int|string|INT', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'int|string|INT', + 'return_type_token' => 7, + 'return_type_end_token' => 17, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -740,15 +829,18 @@ public function testPHP8DuplicateTypeInUnionWhitespaceAndComment() */ public function testPHP81NeverType() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'never', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'never', + 'return_type_token' => 7, + 'return_type_end_token' => 7, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -763,15 +855,18 @@ public function testPHP81NeverType() */ public function testPHP81NullableNeverType() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '?never', - 'nullable_return_type' => true, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '?never', + 'return_type_token' => 8, + 'return_type_end_token' => 8, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -786,15 +881,18 @@ public function testPHP81NullableNeverType() */ public function testPHP8IntersectionTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'Foo&Bar', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'Foo&Bar', + 'return_type_token' => 7, + 'return_type_end_token' => 9, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -809,15 +907,18 @@ public function testPHP8IntersectionTypes() */ public function testPHP81MoreIntersectionTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'MyClassA&\Package\MyClassB&\Package\MyClassC', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'MyClassA&\Package\MyClassB&\Package\MyClassC', + 'return_type_token' => 7, + 'return_type_end_token' => 17, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -832,15 +933,18 @@ public function testPHP81MoreIntersectionTypes() */ public function testPHP81IntersectionArrowFunction() { + // Offsets are relative to the T_FN token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'MyClassA&\Package\MyClassB', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'MyClassA&\Package\MyClassB', + 'return_type_token' => 6, + 'return_type_end_token' => 11, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -855,15 +959,18 @@ public function testPHP81IntersectionArrowFunction() */ public function testPHP81IllegalIntersectionTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'string&int', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'string&int', + 'return_type_token' => 6, + 'return_type_end_token' => 8, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -878,15 +985,18 @@ public function testPHP81IllegalIntersectionTypes() */ public function testPHP81NullableIntersectionTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '?Foo&Bar', - 'nullable_return_type' => true, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '?Foo&Bar', + 'return_type_token' => 7, + 'return_type_end_token' => 9, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -901,15 +1011,18 @@ public function testPHP81NullableIntersectionTypes() */ public function testPHP82PseudoTypeTrue() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => '?true', - 'nullable_return_type' => true, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '?true', + 'return_type_token' => 8, + 'return_type_end_token' => 8, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -924,15 +1037,18 @@ public function testPHP82PseudoTypeTrue() */ public function testPHP82PseudoTypeFalseAndTrue() { + // Offsets are relative to the T_FUNCTION token. $expected = [ - 'scope' => 'public', - 'scope_specified' => false, - 'return_type' => 'true|false', - 'nullable_return_type' => false, - 'is_abstract' => false, - 'is_final' => false, - 'is_static' => false, - 'has_body' => true, + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'true|false', + 'return_type_token' => 7, + 'return_type_end_token' => 9, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, ]; $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -943,8 +1059,8 @@ public function testPHP82PseudoTypeFalseAndTrue() /** * Test helper. * - * @param string $commentString The comment which preceeds the test. - * @param array $expected The expected function output. + * @param string $commentString The comment which preceeds the test. + * @param array $expected The expected function output. * * @return void */ @@ -953,8 +1069,14 @@ private function getMethodPropertiesTestHelper($commentString, $expected) $function = $this->getTargetToken($commentString, [T_FUNCTION, T_CLOSURE, T_FN]); $found = self::$phpcsFile->getMethodProperties($function); - // Unset those indexes which are not being tested. - unset($found['return_type_token'], $found['return_type_end_token']); + // Convert offsets to absolute positions in the token stream. + if (is_int($expected['return_type_token']) === true) { + $expected['return_type_token'] += $function; + } + + if (is_int($expected['return_type_end_token']) === true) { + $expected['return_type_end_token'] += $function; + } $this->assertSame($expected, $found); From 5971a5f21384bff28966f4700f3bcb53915b3185 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 1 Jan 2024 18:14:33 +0100 Subject: [PATCH 223/874] Tests/GetMethodPropertiesTest: add extra tests This adds some extra tests which were already in use in PHPCSUtils. --- tests/Core/File/GetMethodPropertiesTest.inc | 33 ++- tests/Core/File/GetMethodPropertiesTest.php | 215 ++++++++++++++++++++ 2 files changed, 247 insertions(+), 1 deletion(-) diff --git a/tests/Core/File/GetMethodPropertiesTest.inc b/tests/Core/File/GetMethodPropertiesTest.inc index 5ebee67947..1bc570595e 100644 --- a/tests/Core/File/GetMethodPropertiesTest.inc +++ b/tests/Core/File/GetMethodPropertiesTest.inc @@ -34,16 +34,23 @@ class MyClass { /* testMessyNullableReturnMethod */ public function myFunction() /* comment */ : - /* comment */ ? //comment + /* comment */ ? // phpcs:ignore Stnd.Cat.Sniff -- For reasons. array {} /* testReturnNamespace */ function myFunction(): \MyNamespace\MyClass {} /* testReturnMultilineNamespace */ + // Parse error in PHP 8.0. function myFunction(): \MyNamespace /** comment *\/ comment */ \MyClass /* comment */ \Foo {} + + /* testReturnUnqualifiedName */ + private function myFunction(): ?MyClass {} + + /* testReturnPartiallyQualifiedName */ + function myFunction(): Sub\Level\MyClass {} } abstract class MyClass @@ -157,3 +164,27 @@ function pseudoTypeTrue(): ?true {} /* testPHP82PseudoTypeFalseAndTrue */ // Intentional fatal error - Type contains both true and false, bool should be used instead, but that's not the concern of the method. function pseudoTypeFalseAndTrue(): true|false {} + +/* testNotAFunction */ +return true; + +/* testPhpcsIssue1264 */ +function foo() : array { + echo $foo; +} + +/* testArrowFunctionArrayReturnValue */ +$fn = fn(): array => [a($a, $b)]; + +/* testArrowFunctionReturnByRef */ +fn&(?string $a) : ?string => $b; + +/* testFunctionCallFnPHPCS353-354 */ +$value = $obj->fn(true); + +/* testFunctionDeclarationNestedInTernaryPHPCS2975 */ +return (!$a ? [ new class { public function b(): c {} } ] : []); + +/* testArrowFunctionLiveCoding */ +// Intentional parse error. This has to be the last test in the file. +$fn = fn diff --git a/tests/Core/File/GetMethodPropertiesTest.php b/tests/Core/File/GetMethodPropertiesTest.php index 4177537ff3..b7c8bc928c 100644 --- a/tests/Core/File/GetMethodPropertiesTest.php +++ b/tests/Core/File/GetMethodPropertiesTest.php @@ -20,6 +20,59 @@ class GetMethodPropertiesTest extends AbstractMethodUnitTest { + /** + * Test receiving an expected exception when a non function token is passed. + * + * @param string $commentString The comment which preceeds the test. + * @param string|int|array $targetTokenType The token type to search for after $commentString. + * + * @dataProvider dataNotAFunctionException + * + * @return void + */ + public function testNotAFunctionException($commentString, $targetTokenType) + { + $this->expectRunTimeException('$stackPtr must be of type T_FUNCTION or T_CLOSURE or T_FN'); + + $next = $this->getTargetToken($commentString, $targetTokenType); + self::$phpcsFile->getMethodProperties($next); + + }//end testNotAFunctionException() + + + /** + * Data Provider. + * + * @see testNotAFunctionException() For the array format. + * + * @return array>> + */ + public static function dataNotAFunctionException() + { + return [ + 'return' => [ + 'commentString' => '/* testNotAFunction */', + 'targetTokenType' => T_RETURN, + ], + 'function-call-fn-phpcs-3.5.3-3.5.4' => [ + 'commentString' => '/* testFunctionCallFnPHPCS353-354 */', + 'targetTokenType' => [ + T_FN, + T_STRING, + ], + ], + 'fn-live-coding' => [ + 'commentString' => '/* testArrowFunctionLiveCoding */', + 'targetTokenType' => [ + T_FN, + T_STRING, + ], + ], + ]; + + }//end dataNotAFunctionException() + + /** * Test a basic function. * @@ -328,6 +381,58 @@ public function testReturnMultilineNamespace() }//end testReturnMultilineNamespace() + /** + * Test a method with an unqualified named return type. + * + * @return void + */ + public function testReturnUnqualifiedName() + { + // Offsets are relative to the T_FUNCTION token. + $expected = [ + 'scope' => 'private', + 'scope_specified' => true, + 'return_type' => '?MyClass', + 'return_type_token' => 8, + 'return_type_end_token' => 8, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testReturnUnqualifiedName() + + + /** + * Test a method with a partially qualified namespaced return type. + * + * @return void + */ + public function testReturnPartiallyQualifiedName() + { + // Offsets are relative to the T_FUNCTION token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'Sub\Level\MyClass', + 'return_type_token' => 7, + 'return_type_end_token' => 11, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testReturnPartiallyQualifiedName() + + /** * Test a basic abstract method. * @@ -1056,6 +1161,116 @@ public function testPHP82PseudoTypeFalseAndTrue() }//end testPHP82PseudoTypeFalseAndTrue() + /** + * Test for incorrect tokenization of array return type declarations in PHPCS < 2.8.0. + * + * @link https://github.com/squizlabs/PHP_CodeSniffer/pull/1264 + * + * @return void + */ + public function testPhpcsIssue1264() + { + // Offsets are relative to the T_FUNCTION token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'array', + 'return_type_token' => 8, + 'return_type_end_token' => 8, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPhpcsIssue1264() + + + /** + * Test handling of incorrect tokenization of array return type declarations for arrow functions + * in a very specific code sample in PHPCS < 3.5.4. + * + * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/2773 + * + * @return void + */ + public function testArrowFunctionArrayReturnValue() + { + // Offsets are relative to the T_FN token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'array', + 'return_type_token' => 5, + 'return_type_end_token' => 5, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testArrowFunctionArrayReturnValue() + + + /** + * Test handling of an arrow function returning by reference. + * + * @return void + */ + public function testArrowFunctionReturnByRef() + { + // Offsets are relative to the T_FN token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '?string', + 'return_type_token' => 12, + 'return_type_end_token' => 12, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testArrowFunctionReturnByRef() + + + /** + * Test handling of function declaration nested in a ternary, where the colon for the + * return type was incorrectly tokenized as T_INLINE_ELSE prior to PHPCS 3.5.7. + * + * @return void + */ + public function testFunctionDeclarationNestedInTernaryPHPCS2975() + { + // Offsets are relative to the T_FN token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => true, + 'return_type' => 'c', + 'return_type_token' => 7, + 'return_type_end_token' => 7, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testFunctionDeclarationNestedInTernaryPHPCS2975() + + /** * Test helper. * From bbe90b005d67ea37ec6b774df5a5dd55fbf37b32 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 2 Jan 2024 11:30:58 +0100 Subject: [PATCH 224/874] Tests/GetMethodParametersTest: more thoroughly test existing tests This adds testing of various `*_token` return value indexes to the pre-existing tests, same as was already being tested in PHPCSUtils. :point_right: the diff will be easiest to review while ignoring whitespace differences due to the array alignment changes to comply with CS. --- tests/Core/File/GetMethodParametersTest.php | 1215 +++++++++++++------ 1 file changed, 854 insertions(+), 361 deletions(-) diff --git a/tests/Core/File/GetMethodParametersTest.php b/tests/Core/File/GetMethodParametersTest.php index 6f9b2adf9e..b383fb7568 100644 --- a/tests/Core/File/GetMethodParametersTest.php +++ b/tests/Core/File/GetMethodParametersTest.php @@ -3,7 +3,9 @@ * Tests for the \PHP_CodeSniffer\Files\File::getMethodParameters method. * * @author Greg Sherwood + * @author Juliette Reinders Folmer * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) + * @copyright 2019-2024 PHPCSStandards Contributors * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ @@ -27,15 +29,22 @@ class GetMethodParametersTest extends AbstractMethodUnitTest */ public function testPassByReference() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => '&$var', - 'has_attributes' => false, - 'pass_by_reference' => true, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, + 'token' => 5, + 'name' => '$var', + 'content' => '&$var', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 4, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -50,15 +59,22 @@ public function testPassByReference() */ public function testArrayHint() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'array $var', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'array', - 'nullable_type' => false, + 'token' => 6, + 'name' => '$var', + 'content' => 'array $var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'array', + 'type_hint_token' => 4, + 'type_hint_end_token' => 4, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -73,15 +89,22 @@ public function testArrayHint() */ public function testVariable() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => '$var', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, + 'token' => 4, + 'name' => '$var', + 'content' => '$var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -96,16 +119,25 @@ public function testVariable() */ public function testSingleDefaultValue() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var1', - 'content' => '$var1=self::CONSTANT', - 'default' => 'self::CONSTANT', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, + 'token' => 4, + 'name' => '$var1', + 'content' => '$var1=self::CONSTANT', + 'default' => 'self::CONSTANT', + 'default_token' => 6, + 'default_equal_token' => 5, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -120,26 +152,43 @@ public function testSingleDefaultValue() */ public function testDefaultValues() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var1', - 'content' => '$var1=1', - 'default' => '1', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, + 'token' => 4, + 'name' => '$var1', + 'content' => '$var1=1', + 'default' => '1', + 'default_token' => 6, + 'default_equal_token' => 5, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 7, ]; $expected[1] = [ - 'name' => '$var2', - 'content' => "\$var2='value'", - 'default' => "'value'", - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, + 'token' => 9, + 'name' => '$var2', + 'content' => "\$var2='value'", + 'default' => "'value'", + 'default_token' => 11, + 'default_equal_token' => 10, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -154,25 +203,38 @@ public function testDefaultValues() */ public function testTypeHint() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var1', - 'content' => 'foo $var1', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'foo', - 'nullable_type' => false, + 'token' => 6, + 'name' => '$var1', + 'content' => 'foo $var1', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'foo', + 'type_hint_token' => 4, + 'type_hint_end_token' => 4, + 'nullable_type' => false, + 'comma_token' => 7, ]; $expected[1] = [ - 'name' => '$var2', - 'content' => 'bar $var2', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'bar', - 'nullable_type' => false, + 'token' => 11, + 'name' => '$var2', + 'content' => 'bar $var2', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'bar', + 'type_hint_token' => 9, + 'type_hint_end_token' => 9, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -187,15 +249,22 @@ public function testTypeHint() */ public function testSelfTypeHint() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'self $var', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'self', - 'nullable_type' => false, + 'token' => 6, + 'name' => '$var', + 'content' => 'self $var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'self', + 'type_hint_token' => 4, + 'type_hint_end_token' => 4, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -210,25 +279,38 @@ public function testSelfTypeHint() */ public function testNullableTypeHint() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var1', - 'content' => '?int $var1', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?int', - 'nullable_type' => true, + 'token' => 7, + 'name' => '$var1', + 'content' => '?int $var1', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?int', + 'type_hint_token' => 5, + 'type_hint_end_token' => 5, + 'nullable_type' => true, + 'comma_token' => 8, ]; $expected[1] = [ - 'name' => '$var2', - 'content' => '?\bar $var2', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?\bar', - 'nullable_type' => true, + 'token' => 14, + 'name' => '$var2', + 'content' => '?\bar $var2', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?\bar', + 'type_hint_token' => 11, + 'type_hint_end_token' => 12, + 'nullable_type' => true, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -243,16 +325,25 @@ public function testNullableTypeHint() */ public function testBitwiseAndConstantExpressionDefaultValue() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$a', - 'content' => '$a = 10 & 20', - 'default' => '10 & 20', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, + 'token' => 4, + 'name' => '$a', + 'content' => '$a = 10 & 20', + 'default' => '10 & 20', + 'default_token' => 8, + 'default_equal_token' => 6, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -267,25 +358,38 @@ public function testBitwiseAndConstantExpressionDefaultValue() */ public function testArrowFunction() { + // Offsets are relative to the T_FN token. $expected = []; $expected[0] = [ - 'name' => '$a', - 'content' => 'int $a', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'int', - 'nullable_type' => false, + 'token' => 4, + 'name' => '$a', + 'content' => 'int $a', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'int', + 'type_hint_token' => 2, + 'type_hint_end_token' => 2, + 'nullable_type' => false, + 'comma_token' => 5, ]; $expected[1] = [ - 'name' => '$b', - 'content' => '...$b', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => true, - 'type_hint' => '', - 'nullable_type' => false, + 'token' => 8, + 'name' => '$b', + 'content' => '...$b', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => true, + 'variadic_token' => 7, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -300,15 +404,22 @@ public function testArrowFunction() */ public function testPHP8MixedTypeHint() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var1', - 'content' => 'mixed &...$var1', - 'has_attributes' => false, - 'pass_by_reference' => true, - 'variable_length' => true, - 'type_hint' => 'mixed', - 'nullable_type' => false, + 'token' => 8, + 'name' => '$var1', + 'content' => 'mixed &...$var1', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 6, + 'variable_length' => true, + 'variadic_token' => 7, + 'type_hint' => 'mixed', + 'type_hint_token' => 4, + 'type_hint_end_token' => 4, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -323,15 +434,22 @@ public function testPHP8MixedTypeHint() */ public function testPHP8MixedTypeHintNullable() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var1', - 'content' => '?Mixed $var1', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?Mixed', - 'nullable_type' => true, + 'token' => 7, + 'name' => '$var1', + 'content' => '?Mixed $var1', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?Mixed', + 'type_hint_token' => 5, + 'type_hint_end_token' => 5, + 'nullable_type' => true, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -346,15 +464,22 @@ public function testPHP8MixedTypeHintNullable() */ public function testNamespaceOperatorTypeHint() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var1', - 'content' => '?namespace\Name $var1', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?namespace\Name', - 'nullable_type' => true, + 'token' => 9, + 'name' => '$var1', + 'content' => '?namespace\Name $var1', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?namespace\Name', + 'type_hint_token' => 5, + 'type_hint_end_token' => 7, + 'nullable_type' => true, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -369,24 +494,37 @@ public function testNamespaceOperatorTypeHint() */ public function testPHP8UnionTypesSimple() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$number', - 'content' => 'int|float $number', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'int|float', - 'nullable_type' => false, + 'token' => 8, + 'name' => '$number', + 'content' => 'int|float $number', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'int|float', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => false, + 'comma_token' => 9, ]; $expected[1] = [ - 'name' => '$obj', - 'content' => 'self|parent &...$obj', - 'has_attributes' => false, - 'pass_by_reference' => true, - 'variable_length' => true, - 'type_hint' => 'self|parent', - 'nullable_type' => false, + 'token' => 17, + 'name' => '$obj', + 'content' => 'self|parent &...$obj', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 15, + 'variable_length' => true, + 'variadic_token' => 16, + 'type_hint' => 'self|parent', + 'type_hint_token' => 11, + 'type_hint_end_token' => 13, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -401,24 +539,37 @@ public function testPHP8UnionTypesSimple() */ public function testPHP8UnionTypesWithSpreadOperatorAndReference() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$paramA', - 'content' => 'float|null &$paramA', - 'has_attributes' => false, - 'pass_by_reference' => true, - 'variable_length' => false, - 'type_hint' => 'float|null', - 'nullable_type' => false, + 'token' => 9, + 'name' => '$paramA', + 'content' => 'float|null &$paramA', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 8, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'float|null', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => false, + 'comma_token' => 10, ]; $expected[1] = [ - 'name' => '$paramB', - 'content' => 'string|int ...$paramB', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => true, - 'type_hint' => 'string|int', - 'nullable_type' => false, + 'token' => 17, + 'name' => '$paramB', + 'content' => 'string|int ...$paramB', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => true, + 'variadic_token' => 16, + 'type_hint' => 'string|int', + 'type_hint_token' => 12, + 'type_hint_end_token' => 14, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -433,16 +584,25 @@ public function testPHP8UnionTypesWithSpreadOperatorAndReference() */ public function testPHP8UnionTypesSimpleWithBitwiseOrInDefault() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'int|float $var = CONSTANT_A | CONSTANT_B', - 'default' => 'CONSTANT_A | CONSTANT_B', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'int|float', - 'nullable_type' => false, + 'token' => 6, + 'name' => '$var', + 'content' => 'int|float $var = CONSTANT_A | CONSTANT_B', + 'default' => 'CONSTANT_A | CONSTANT_B', + 'default_token' => 10, + 'default_equal_token' => 8, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'int|float', + 'type_hint_token' => 2, + 'type_hint_end_token' => 4, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -457,15 +617,22 @@ public function testPHP8UnionTypesSimpleWithBitwiseOrInDefault() */ public function testPHP8UnionTypesTwoClasses() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'MyClassA|\Package\MyClassB $var', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'MyClassA|\Package\MyClassB', - 'nullable_type' => false, + 'token' => 11, + 'name' => '$var', + 'content' => 'MyClassA|\Package\MyClassB $var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'MyClassA|\Package\MyClassB', + 'type_hint_token' => 4, + 'type_hint_end_token' => 9, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -480,15 +647,22 @@ public function testPHP8UnionTypesTwoClasses() */ public function testPHP8UnionTypesAllBaseTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'array|bool|callable|int|float|null|object|string $var', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'array|bool|callable|int|float|null|object|string', - 'nullable_type' => false, + 'token' => 20, + 'name' => '$var', + 'content' => 'array|bool|callable|int|float|null|object|string $var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'array|bool|callable|int|float|null|object|string', + 'type_hint_token' => 4, + 'type_hint_end_token' => 18, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -499,19 +673,28 @@ public function testPHP8UnionTypesAllBaseTypes() /** * Verify recognition of PHP8 union type declaration with all pseudo types. * + * Note: "Resource" is not a type, but seen as a class name. + * * @return void */ public function testPHP8UnionTypesAllPseudoTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'false|mixed|self|parent|iterable|Resource $var', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'false|mixed|self|parent|iterable|Resource', - 'nullable_type' => false, + 'token' => 16, + 'name' => '$var', + 'content' => 'false|mixed|self|parent|iterable|Resource $var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'false|mixed|self|parent|iterable|Resource', + 'type_hint_token' => 4, + 'type_hint_end_token' => 14, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -526,15 +709,22 @@ public function testPHP8UnionTypesAllPseudoTypes() */ public function testPHP8UnionTypesNullable() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$number', - 'content' => '?int|float $number', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?int|float', - 'nullable_type' => true, + 'token' => 8, + 'name' => '$number', + 'content' => '?int|float $number', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?int|float', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => true, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -549,16 +739,25 @@ public function testPHP8UnionTypesNullable() */ public function testPHP8PseudoTypeNull() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'null $var = null', - 'default' => 'null', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'null', - 'nullable_type' => false, + 'token' => 6, + 'name' => '$var', + 'content' => 'null $var = null', + 'default' => 'null', + 'default_token' => 10, + 'default_equal_token' => 8, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'null', + 'type_hint_token' => 4, + 'type_hint_end_token' => 4, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -573,16 +772,25 @@ public function testPHP8PseudoTypeNull() */ public function testPHP8PseudoTypeFalse() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'false $var = false', - 'default' => 'false', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'false', - 'nullable_type' => false, + 'token' => 6, + 'name' => '$var', + 'content' => 'false $var = false', + 'default' => 'false', + 'default_token' => 10, + 'default_equal_token' => 8, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'false', + 'type_hint_token' => 4, + 'type_hint_end_token' => 4, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -597,16 +805,25 @@ public function testPHP8PseudoTypeFalse() */ public function testPHP8PseudoTypeFalseAndBool() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'bool|false $var = false', - 'default' => 'false', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'bool|false', - 'nullable_type' => false, + 'token' => 8, + 'name' => '$var', + 'content' => 'bool|false $var = false', + 'default' => 'false', + 'default_token' => 12, + 'default_equal_token' => 10, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'bool|false', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -621,15 +838,22 @@ public function testPHP8PseudoTypeFalseAndBool() */ public function testPHP8ObjectAndClass() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'object|ClassName $var', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'object|ClassName', - 'nullable_type' => false, + 'token' => 8, + 'name' => '$var', + 'content' => 'object|ClassName $var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'object|ClassName', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -644,15 +868,22 @@ public function testPHP8ObjectAndClass() */ public function testPHP8PseudoTypeIterableAndArray() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'iterable|array|Traversable $var', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'iterable|array|Traversable', - 'nullable_type' => false, + 'token' => 10, + 'name' => '$var', + 'content' => 'iterable|array|Traversable $var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'iterable|array|Traversable', + 'type_hint_token' => 4, + 'type_hint_end_token' => 8, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -667,15 +898,22 @@ public function testPHP8PseudoTypeIterableAndArray() */ public function testPHP8DuplicateTypeInUnionWhitespaceAndComment() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'int | string /*comment*/ | INT $var', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'int|string|INT', - 'nullable_type' => false, + 'token' => 17, + 'name' => '$var', + 'content' => 'int | string /*comment*/ | INT $var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'int|string|INT', + 'type_hint_token' => 5, + 'type_hint_end_token' => 15, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -690,42 +928,70 @@ public function testPHP8DuplicateTypeInUnionWhitespaceAndComment() */ public function testPHP8ConstructorPropertyPromotionNoTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ + 'token' => 8, 'name' => '$x', 'content' => 'public $x = 0.0', 'default' => '0.0', + 'default_token' => 12, + 'default_equal_token' => 10, 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, 'nullable_type' => false, 'property_visibility' => 'public', + 'visibility_token' => 6, 'property_readonly' => false, + 'comma_token' => 13, ]; $expected[1] = [ + 'token' => 18, 'name' => '$y', 'content' => 'protected $y = \'\'', 'default' => "''", + 'default_token' => 22, + 'default_equal_token' => 20, 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, 'nullable_type' => false, 'property_visibility' => 'protected', + 'visibility_token' => 16, 'property_readonly' => false, + 'comma_token' => 23, ]; $expected[2] = [ + 'token' => 28, 'name' => '$z', 'content' => 'private $z = null', 'default' => 'null', + 'default_token' => 32, + 'default_equal_token' => 30, 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, 'nullable_type' => false, 'property_visibility' => 'private', + 'visibility_token' => 26, 'property_readonly' => false, + 'comma_token' => 33, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -740,40 +1006,64 @@ public function testPHP8ConstructorPropertyPromotionNoTypes() */ public function testPHP8ConstructorPropertyPromotionWithTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ + 'token' => 10, 'name' => '$x', 'content' => 'protected float|int $x', 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => 'float|int', + 'type_hint_token' => 6, + 'type_hint_end_token' => 8, 'nullable_type' => false, 'property_visibility' => 'protected', + 'visibility_token' => 4, 'property_readonly' => false, + 'comma_token' => 11, ]; $expected[1] = [ + 'token' => 19, 'name' => '$y', 'content' => 'public ?string &$y = \'test\'', 'default' => "'test'", + 'default_token' => 23, + 'default_equal_token' => 21, 'has_attributes' => false, 'pass_by_reference' => true, + 'reference_token' => 18, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => '?string', + 'type_hint_token' => 16, + 'type_hint_end_token' => 16, 'nullable_type' => true, 'property_visibility' => 'public', + 'visibility_token' => 13, 'property_readonly' => false, + 'comma_token' => 24, ]; $expected[2] = [ + 'token' => 30, 'name' => '$z', 'content' => 'private mixed $z', 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => 'mixed', + 'type_hint_token' => 28, + 'type_hint_end_token' => 28, 'nullable_type' => false, 'property_visibility' => 'private', + 'visibility_token' => 26, 'property_readonly' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -788,26 +1078,40 @@ public function testPHP8ConstructorPropertyPromotionWithTypes() */ public function testPHP8ConstructorPropertyPromotionAndNormalParam() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ + 'token' => 8, 'name' => '$promotedProp', 'content' => 'public int $promotedProp', 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => 'int', + 'type_hint_token' => 6, + 'type_hint_end_token' => 6, 'nullable_type' => false, 'property_visibility' => 'public', + 'visibility_token' => 4, 'property_readonly' => false, + 'comma_token' => 9, ]; $expected[1] = [ - 'name' => '$normalArg', - 'content' => '?int $normalArg', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?int', - 'nullable_type' => true, + 'token' => 14, + 'name' => '$normalArg', + 'content' => '?int $normalArg', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?int', + 'type_hint_token' => 12, + 'type_hint_end_token' => 12, + 'nullable_type' => true, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -822,28 +1126,45 @@ public function testPHP8ConstructorPropertyPromotionAndNormalParam() */ public function testPHP81ConstructorPropertyPromotionWithReadOnly() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ + 'token' => 11, 'name' => '$promotedProp', 'content' => 'public readonly ?int $promotedProp', 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => '?int', + 'type_hint_token' => 9, + 'type_hint_end_token' => 9, 'nullable_type' => true, 'property_visibility' => 'public', + 'visibility_token' => 4, 'property_readonly' => true, + 'readonly_token' => 6, + 'comma_token' => 12, ]; $expected[1] = [ + 'token' => 23, 'name' => '$promotedToo', 'content' => 'readonly private string|bool &$promotedToo', 'has_attributes' => false, 'pass_by_reference' => true, + 'reference_token' => 22, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => 'string|bool', + 'type_hint_token' => 18, + 'type_hint_end_token' => 20, 'nullable_type' => false, 'property_visibility' => 'private', + 'visibility_token' => 16, 'property_readonly' => true, + 'readonly_token' => 14, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -859,28 +1180,45 @@ public function testPHP81ConstructorPropertyPromotionWithReadOnly() */ public function testPHP81ConstructorPropertyPromotionWithOnlyReadOnly() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ + 'token' => 10, 'name' => '$promotedProp', 'content' => 'readonly Foo&Bar $promotedProp', 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => 'Foo&Bar', + 'type_hint_token' => 6, + 'type_hint_end_token' => 8, 'nullable_type' => false, 'property_visibility' => 'public', + 'visibility_token' => false, 'property_readonly' => true, + 'readonly_token' => 4, + 'comma_token' => 11, ]; $expected[1] = [ + 'token' => 18, 'name' => '$promotedToo', 'content' => 'readonly ?bool $promotedToo', 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => '?bool', + 'type_hint_token' => 16, + 'type_hint_end_token' => 16, 'nullable_type' => true, 'property_visibility' => 'public', + 'visibility_token' => false, 'property_readonly' => true, + 'readonly_token' => 13, + 'comma_token' => 19, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -895,17 +1233,25 @@ public function testPHP81ConstructorPropertyPromotionWithOnlyReadOnly() */ public function testPHP8ConstructorPropertyPromotionGlobalFunction() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ + 'token' => 6, 'name' => '$x', 'content' => 'private $x', 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, 'nullable_type' => false, 'property_visibility' => 'private', + 'visibility_token' => 4, 'property_readonly' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -920,28 +1266,43 @@ public function testPHP8ConstructorPropertyPromotionGlobalFunction() */ public function testPHP8ConstructorPropertyPromotionAbstractMethod() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ + 'token' => 8, 'name' => '$y', 'content' => 'public callable $y', 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => 'callable', + 'type_hint_token' => 6, + 'type_hint_end_token' => 6, 'nullable_type' => false, 'property_visibility' => 'public', + 'visibility_token' => 4, 'property_readonly' => false, + 'comma_token' => 9, ]; $expected[1] = [ + 'token' => 14, 'name' => '$x', 'content' => 'private ...$x', 'has_attributes' => false, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => true, + 'variadic_token' => 13, 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, 'nullable_type' => false, 'property_visibility' => 'private', + 'visibility_token' => 11, 'property_readonly' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -956,17 +1317,26 @@ public function testPHP8ConstructorPropertyPromotionAbstractMethod() */ public function testCommentsInParameter() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$param', - 'content' => '// Leading comment. + 'token' => 19, + 'name' => '$param', + 'content' => '// Leading comment. ?MyClass /*-*/ & /*-*/.../*-*/ $param /*-*/ = /*-*/ \'default value\' . /*-*/ \'second part\' // Trailing comment.', - 'default' => '\'default value\' . /*-*/ \'second part\' // Trailing comment.', - 'has_attributes' => false, - 'pass_by_reference' => true, - 'variable_length' => true, - 'type_hint' => '?MyClass', - 'nullable_type' => true, + 'default' => '\'default value\' . /*-*/ \'second part\' // Trailing comment.', + 'default_token' => 27, + 'default_equal_token' => 23, + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 13, + 'variable_length' => true, + 'variadic_token' => 16, + 'type_hint' => '?MyClass', + 'type_hint_token' => 9, + 'type_hint_end_token' => 9, + 'nullable_type' => true, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -981,56 +1351,88 @@ public function testCommentsInParameter() */ public function testParameterAttributesInFunctionDeclaration() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ + 'token' => 17, 'name' => '$constructorPropPromTypedParamSingleAttribute', 'content' => '#[\MyExample\MyAttribute] private string $constructorPropPromTypedParamSingleAttribute', 'has_attributes' => true, 'pass_by_reference' => false, + 'reference_token' => false, 'variable_length' => false, + 'variadic_token' => false, 'type_hint' => 'string', + 'type_hint_token' => 15, + 'type_hint_end_token' => 15, 'nullable_type' => false, 'property_visibility' => 'private', + 'visibility_token' => 13, 'property_readonly' => false, + 'comma_token' => 18, ]; $expected[1] = [ - 'name' => '$typedParamSingleAttribute', - 'content' => '#[MyAttr([1, 2])] + 'token' => 39, + 'name' => '$typedParamSingleAttribute', + 'content' => '#[MyAttr([1, 2])] Type|false $typedParamSingleAttribute', - 'has_attributes' => true, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'Type|false', - 'nullable_type' => false, + 'has_attributes' => true, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'Type|false', + 'type_hint_token' => 34, + 'type_hint_end_token' => 36, + 'nullable_type' => false, + 'comma_token' => 40, ]; $expected[2] = [ - 'name' => '$nullableTypedParamMultiAttribute', - 'content' => '#[MyAttribute(1234), MyAttribute(5678)] ?int $nullableTypedParamMultiAttribute', - 'has_attributes' => true, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?int', - 'nullable_type' => true, + 'token' => 59, + 'name' => '$nullableTypedParamMultiAttribute', + 'content' => '#[MyAttribute(1234), MyAttribute(5678)] ?int $nullableTypedParamMultiAttribute', + 'has_attributes' => true, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?int', + 'type_hint_token' => 57, + 'type_hint_end_token' => 57, + 'nullable_type' => true, + 'comma_token' => 60, ]; $expected[3] = [ - 'name' => '$nonTypedParamTwoAttributes', - 'content' => '#[WithoutArgument] #[SingleArgument(0)] $nonTypedParamTwoAttributes', - 'has_attributes' => true, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '', - 'nullable_type' => false, + 'token' => 74, + 'name' => '$nonTypedParamTwoAttributes', + 'content' => '#[WithoutArgument] #[SingleArgument(0)] $nonTypedParamTwoAttributes', + 'has_attributes' => true, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 75, ]; $expected[4] = [ - 'name' => '$otherParam', - 'content' => '#[MyAttribute(array("key" => "value"))] + 'token' => 95, + 'name' => '$otherParam', + 'content' => '#[MyAttribute(array("key" => "value"))] &...$otherParam', - 'has_attributes' => true, - 'pass_by_reference' => true, - 'variable_length' => true, - 'type_hint' => '', - 'nullable_type' => false, + 'has_attributes' => true, + 'pass_by_reference' => true, + 'reference_token' => 93, + 'variable_length' => true, + 'variadic_token' => 94, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 96, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -1045,24 +1447,37 @@ public function testParameterAttributesInFunctionDeclaration() */ public function testPHP8IntersectionTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$obj1', - 'content' => 'Foo&Bar $obj1', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'Foo&Bar', - 'nullable_type' => false, + 'token' => 8, + 'name' => '$obj1', + 'content' => 'Foo&Bar $obj1', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'Foo&Bar', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => false, + 'comma_token' => 9, ]; $expected[1] = [ - 'name' => '$obj2', - 'content' => 'Boo&Bar $obj2', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'Boo&Bar', - 'nullable_type' => false, + 'token' => 15, + 'name' => '$obj2', + 'content' => 'Boo&Bar $obj2', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'Boo&Bar', + 'type_hint_token' => 11, + 'type_hint_end_token' => 13, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -1071,30 +1486,44 @@ public function testPHP8IntersectionTypes() /** - * Verify recognition of PHP8 intersection type declaration when the variable has either a spread operator or a reference. + * Verify recognition of PHP8 intersection type declaration when the variable + * has either a spread operator or a reference. * * @return void */ public function testPHP81IntersectionTypesWithSpreadOperatorAndReference() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$paramA', - 'content' => 'Boo&Bar &$paramA', - 'has_attributes' => false, - 'pass_by_reference' => true, - 'variable_length' => false, - 'type_hint' => 'Boo&Bar', - 'nullable_type' => false, + 'token' => 9, + 'name' => '$paramA', + 'content' => 'Boo&Bar &$paramA', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 8, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'Boo&Bar', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => false, + 'comma_token' => 10, ]; $expected[1] = [ - 'name' => '$paramB', - 'content' => 'Foo&Bar ...$paramB', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => true, - 'type_hint' => 'Foo&Bar', - 'nullable_type' => false, + 'token' => 17, + 'name' => '$paramB', + 'content' => 'Foo&Bar ...$paramB', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => true, + 'variadic_token' => 16, + 'type_hint' => 'Foo&Bar', + 'type_hint_token' => 12, + 'type_hint_end_token' => 14, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -1109,15 +1538,22 @@ public function testPHP81IntersectionTypesWithSpreadOperatorAndReference() */ public function testPHP81MoreIntersectionTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'MyClassA&\Package\MyClassB&\Package\MyClassC $var', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'MyClassA&\Package\MyClassB&\Package\MyClassC', - 'nullable_type' => false, + 'token' => 16, + 'name' => '$var', + 'content' => 'MyClassA&\Package\MyClassB&\Package\MyClassC $var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'MyClassA&\Package\MyClassB&\Package\MyClassC', + 'type_hint_token' => 4, + 'type_hint_end_token' => 14, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -1132,15 +1568,22 @@ public function testPHP81MoreIntersectionTypes() */ public function testPHP81IllegalIntersectionTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$numeric_string', - 'content' => 'string&int $numeric_string', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'string&int', - 'nullable_type' => false, + 'token' => 7, + 'name' => '$numeric_string', + 'content' => 'string&int $numeric_string', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'string&int', + 'type_hint_token' => 3, + 'type_hint_end_token' => 5, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -1155,15 +1598,22 @@ public function testPHP81IllegalIntersectionTypes() */ public function testPHP81NullableIntersectionTypes() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$object', - 'content' => '?Foo&Bar $object', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?Foo&Bar', - 'nullable_type' => true, + 'token' => 8, + 'name' => '$object', + 'content' => '?Foo&Bar $object', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?Foo&Bar', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => true, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -1178,16 +1628,25 @@ public function testPHP81NullableIntersectionTypes() */ public function testPHP82PseudoTypeTrue() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => '?true $var = true', - 'default' => 'true', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => '?true', - 'nullable_type' => true, + 'token' => 7, + 'name' => '$var', + 'content' => '?true $var = true', + 'default' => 'true', + 'default_token' => 11, + 'default_equal_token' => 9, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?true', + 'type_hint_token' => 5, + 'type_hint_end_token' => 5, + 'nullable_type' => true, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -1202,16 +1661,25 @@ public function testPHP82PseudoTypeTrue() */ public function testPHP82PseudoTypeFalseAndTrue() { + // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'name' => '$var', - 'content' => 'true|false $var = true', - 'default' => 'true', - 'has_attributes' => false, - 'pass_by_reference' => false, - 'variable_length' => false, - 'type_hint' => 'true|false', - 'nullable_type' => false, + 'token' => 8, + 'name' => '$var', + 'content' => 'true|false $var = true', + 'default' => 'true', + 'default_token' => 12, + 'default_equal_token' => 10, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'true|false', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => false, + 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); @@ -1222,31 +1690,56 @@ public function testPHP82PseudoTypeFalseAndTrue() /** * Test helper. * - * @param string $commentString The comment which preceeds the test. - * @param array $expected The expected function output. + * @param string $commentString The comment which preceeds the test. + * @param array> $expected The expected function output. * * @return void */ private function getMethodParametersTestHelper($commentString, $expected) { - $function = $this->getTargetToken($commentString, [T_FUNCTION, T_CLOSURE, T_FN]); - $found = self::$phpcsFile->getMethodParameters($function); - - // Unset those indexes which are not being tested. - foreach ($found as $i => $param) { - unset( - $found[$i]['token'], - $found[$i]['reference_token'], - $found[$i]['variadic_token'], - $found[$i]['type_hint_token'], - $found[$i]['type_hint_end_token'], - $found[$i]['comma_token'], - $found[$i]['default_token'], - $found[$i]['default_equal_token'], - $found[$i]['visibility_token'], - $found[$i]['readonly_token'] - ); - } + $target = $this->getTargetToken($commentString, [T_FUNCTION, T_CLOSURE, T_FN]); + $found = self::$phpcsFile->getMethodParameters($target); + + // Convert offsets to absolute positions in the token stream. + foreach ($expected as $key => $param) { + $expected[$key]['token'] += $target; + + if (is_int($param['reference_token']) === true) { + $expected[$key]['reference_token'] += $target; + } + + if (is_int($param['variadic_token']) === true) { + $expected[$key]['variadic_token'] += $target; + } + + if (is_int($param['type_hint_token']) === true) { + $expected[$key]['type_hint_token'] += $target; + } + + if (is_int($param['type_hint_end_token']) === true) { + $expected[$key]['type_hint_end_token'] += $target; + } + + if (is_int($param['comma_token']) === true) { + $expected[$key]['comma_token'] += $target; + } + + if (isset($param['default_token']) === true) { + $expected[$key]['default_token'] += $target; + } + + if (isset($param['default_equal_token']) === true) { + $expected[$key]['default_equal_token'] += $target; + } + + if (isset($param['visibility_token']) === true && is_int($param['visibility_token']) === true) { + $expected[$key]['visibility_token'] += $target; + } + + if (isset($param['readonly_token']) === true) { + $expected[$key]['readonly_token'] += $target; + } + }//end foreach $this->assertSame($expected, $found); From 5901a6dc4153a0ea6a251603be78d611a9036963 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 2 Jan 2024 12:04:08 +0100 Subject: [PATCH 225/874] Tests/GetMethodParametersTest: add extra tests This adds some extra tests which were already in use in PHPCSUtils. --- .../GetMethodParametersParseError1Test.inc | 4 + .../GetMethodParametersParseError1Test.php | 38 + .../GetMethodParametersParseError2Test.inc | 4 + .../GetMethodParametersParseError2Test.php | 38 + tests/Core/File/GetMethodParametersTest.inc | 149 +- tests/Core/File/GetMethodParametersTest.php | 1498 +++++++++++++++-- 6 files changed, 1617 insertions(+), 114 deletions(-) create mode 100644 tests/Core/File/GetMethodParametersParseError1Test.inc create mode 100644 tests/Core/File/GetMethodParametersParseError1Test.php create mode 100644 tests/Core/File/GetMethodParametersParseError2Test.inc create mode 100644 tests/Core/File/GetMethodParametersParseError2Test.php diff --git a/tests/Core/File/GetMethodParametersParseError1Test.inc b/tests/Core/File/GetMethodParametersParseError1Test.inc new file mode 100644 index 0000000000..465679eb36 --- /dev/null +++ b/tests/Core/File/GetMethodParametersParseError1Test.inc @@ -0,0 +1,4 @@ + + * @copyright 2019-2024 PHPCSStandards Contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\File; + +use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; + +/** + * Tests for the \PHP_CodeSniffer\Files\File::getMethodParameters method. + * + * @covers \PHP_CodeSniffer\Files\File::getMethodParameters + */ +class GetMethodParametersParseError1Test extends AbstractMethodUnitTest +{ + + + /** + * Test receiving an empty array when encountering a specific parse error. + * + * @return void + */ + public function testParseError() + { + $target = $this->getTargetToken('/* testParseError */', [T_FUNCTION, T_CLOSURE, T_FN]); + $result = self::$phpcsFile->getMethodParameters($target); + + $this->assertSame([], $result); + + }//end testParseError() + + +}//end class diff --git a/tests/Core/File/GetMethodParametersParseError2Test.inc b/tests/Core/File/GetMethodParametersParseError2Test.inc new file mode 100644 index 0000000000..667cb5ed2f --- /dev/null +++ b/tests/Core/File/GetMethodParametersParseError2Test.inc @@ -0,0 +1,4 @@ + + * @copyright 2019-2024 PHPCSStandards Contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\File; + +use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; + +/** + * Tests for the \PHP_CodeSniffer\Files\File::getMethodParameters method. + * + * @covers \PHP_CodeSniffer\Files\File::getMethodParameters + */ +class GetMethodParametersParseError2Test extends AbstractMethodUnitTest +{ + + + /** + * Test receiving an empty array when encountering a specific parse error. + * + * @return void + */ + public function testParseError() + { + $target = $this->getTargetToken('/* testParseError */', [T_FUNCTION, T_CLOSURE, T_FN]); + $result = self::$phpcsFile->getMethodParameters($target); + + $this->assertSame([], $result); + + }//end testParseError() + + +}//end class diff --git a/tests/Core/File/GetMethodParametersTest.inc b/tests/Core/File/GetMethodParametersTest.inc index 2635e092c0..f6f3cd9ebf 100644 --- a/tests/Core/File/GetMethodParametersTest.inc +++ b/tests/Core/File/GetMethodParametersTest.inc @@ -1,5 +1,29 @@ $b; +/* testArrowFunctionReturnByRef */ +fn&(?string $a) => $b; + +/* testArrayDefaultValues */ +function arrayDefaultValues($var1 = [], $var2 = array(1, 2, 3) ) {} + +/* testConstantDefaultValueSecondParam */ +function constantDefaultValueSecondParam($var1, $var2 = M_PI) {} + +/* testScalarTernaryExpressionInDefault */ +function ternayInDefault( $a = FOO ? 'bar' : 10, ? bool $b ) {} + +/* testVariadicFunction */ +function variadicFunction( int ... $a ) {} + +/* testVariadicByRefFunction */ +function variadicByRefFunction( &...$a ) {} + +/* testVariadicFunctionClassType */ +function variableLengthArgument($unit, DateInterval ...$intervals) {} + +/* testNameSpacedTypeDeclaration */ +function namespacedClassType( \Package\Sub\ClassName $a, ?Sub\AnotherClass $b ) {} + +/* testWithAllTypes */ +class testAllTypes { + function allTypes( + ?ClassName $a, + self $b, + parent $c, + object $d, + ?int $e, + string &$f, + iterable $g, + bool $h = true, + callable $i = 'is_null', + float $j = 1.1, + array ...$k + ) {} +} + +/* testArrowFunctionWithAllTypes */ +$fn = fn( + ?ClassName $a, + self $b, + parent $c, + object $d, + ?int $e, + string &$f, + iterable $g, + bool $h = true, + callable $i = 'is_null', + float $j = 1.1, + array ...$k +) => $something; + +/* testMessyDeclaration */ +function messyDeclaration( + // comment + ?\MyNS /* comment */ + \ SubCat // phpcs:ignore Standard.Cat.Sniff -- for reasons. + \ MyClass $a, + $b /* test */ = /* test */ 'default' /* test*/, + // phpcs:ignore Stnd.Cat.Sniff -- For reasons. + ? /*comment*/ + bool // phpcs:disable Stnd.Cat.Sniff -- For reasons. + & /*test*/ ... /* phpcs:ignore */ $c +) {} + /* testPHP8MixedTypeHint */ function mixedTypeHint(mixed &...$var1) {} @@ -46,7 +139,7 @@ function namespaceOperatorTypeHint(?namespace\Name $var1) {} function unionTypeSimple(int|float $number, self|parent &...$obj) {} /* testPHP8UnionTypesWithSpreadOperatorAndReference */ -function globalFunctionWithSpreadAndReference(float|null &$paramA, string|int ...$paramB) {} +function globalFunctionWithSpreadAndReference(float|null &$paramA, string|int ...$paramB ) {} /* testPHP8UnionTypesSimpleWithBitwiseOrInDefault */ $fn = fn(int|float $var = CONSTANT_A | CONSTANT_B) => $var; @@ -110,7 +203,13 @@ class ConstructorPropertyPromotionAndNormalParams { class ConstructorPropertyPromotionWithReadOnly { /* testPHP81ConstructorPropertyPromotionWithReadOnly */ - public function __construct(public readonly ?int $promotedProp, readonly private string|bool &$promotedToo) {} + public function __construct(public readonly ?int $promotedProp, ReadOnly private string|bool &$promotedToo) {} +} + +class ConstructorPropertyPromotionWithReadOnlyNoTypeDeclaration { + /* testPHP81ConstructorPropertyPromotionWithReadOnlyNoTypeDeclaration */ + // Intentional fatal error. Readonly properties MUST be typed. + public function __construct(public readonly $promotedProp, ReadOnly private &$promotedToo) {} } class ConstructorPropertyPromotionWithOnlyReadOnly { @@ -174,3 +273,49 @@ function pseudoTypeTrue(?true $var = true) {} /* testPHP82PseudoTypeFalseAndTrue */ // Intentional fatal error - Type contains both true and false, bool should be used instead, but that's not the concern of the method. function pseudoTypeFalseAndTrue(true|false $var = true) {} + +/* testPHP81NewInInitializers */ +function newInInitializers( + TypeA $new = new TypeA(self::CONST_VALUE), + \Package\TypeB $newToo = new \Package\TypeB(10, 'string'), +) {} + +/* testFunctionCallFnPHPCS353-354 */ +$value = $obj->fn(true); + +/* testClosureNoParams */ +function() {}; + +/* testClosure */ +function( $a = 'test' ) {}; + +/* testClosureUseNoParams */ +function() use() {}; + +/* testClosureUse */ +function() use( $foo, $bar ) {}; + +/* testFunctionParamListWithTrailingComma */ +function trailingComma( + ?string $foo /*comment*/ , + $bar = 0, +) {} + +/* testClosureParamListWithTrailingComma */ +function( + $foo, + $bar, +) {}; + +/* testArrowFunctionParamListWithTrailingComma */ +$fn = fn( ?int $a , ...$b, ) => $b; + +/* testClosureUseWithTrailingComma */ +function() use( + $foo /*comment*/ , + $bar, +) {}; + +/* testArrowFunctionLiveCoding */ +// Intentional parse error. This has to be the last test in the file. +$fn = fn diff --git a/tests/Core/File/GetMethodParametersTest.php b/tests/Core/File/GetMethodParametersTest.php index b383fb7568..d0b75a94b6 100644 --- a/tests/Core/File/GetMethodParametersTest.php +++ b/tests/Core/File/GetMethodParametersTest.php @@ -22,6 +22,138 @@ class GetMethodParametersTest extends AbstractMethodUnitTest { + /** + * Test receiving an expected exception when a non function/use token is passed. + * + * @param string $commentString The comment which preceeds the test. + * @param int|string|array $targetTokenType The token type to search for after $commentString. + * + * @dataProvider dataUnexpectedTokenException + * + * @return void + */ + public function testUnexpectedTokenException($commentString, $targetTokenType) + { + $this->expectRunTimeException('$stackPtr must be of type T_FUNCTION or T_CLOSURE or T_USE or T_FN'); + + $target = $this->getTargetToken($commentString, $targetTokenType); + self::$phpcsFile->getMethodParameters($target); + + }//end testUnexpectedTokenException() + + + /** + * Data Provider. + * + * @see testUnexpectedTokenException() For the array format. + * + * @return array>> + */ + public static function dataUnexpectedTokenException() + { + return [ + 'interface' => [ + 'commentString' => '/* testNotAFunction */', + 'targetTokenType' => T_INTERFACE, + ], + 'function-call-fn-phpcs-3.5.3-3.5.4' => [ + 'commentString' => '/* testFunctionCallFnPHPCS353-354 */', + 'targetTokenType' => [ + T_FN, + T_STRING, + ], + ], + 'fn-live-coding' => [ + 'commentString' => '/* testArrowFunctionLiveCoding */', + 'targetTokenType' => [ + T_FN, + T_STRING, + ], + ], + ]; + + }//end dataUnexpectedTokenException() + + + /** + * Test receiving an expected exception when a non-closure use token is passed. + * + * @param string $identifier The comment which preceeds the test. + * + * @dataProvider dataInvalidUse + * + * @return void + */ + public function testInvalidUse($identifier) + { + $this->expectRunTimeException('$stackPtr was not a valid T_USE'); + + $use = $this->getTargetToken($identifier, [T_USE]); + self::$phpcsFile->getMethodParameters($use); + + }//end testInvalidUse() + + + /** + * Data Provider. + * + * @see testInvalidUse() For the array format. + * + * @return array> + */ + public static function dataInvalidUse() + { + return [ + 'ImportUse' => ['/* testImportUse */'], + 'ImportGroupUse' => ['/* testImportGroupUse */'], + 'TraitUse' => ['/* testTraitUse */'], + ]; + + }//end dataInvalidUse() + + + /** + * Test receiving an empty array when there are no parameters. + * + * @param string $commentString The comment which preceeds the test. + * @param int|string|array $targetTokenType Optional. The token type to search for after $commentString. + * Defaults to the function/closure/arrow tokens. + * + * @dataProvider dataNoParams + * + * @return void + */ + public function testNoParams($commentString, $targetTokenType=[T_FUNCTION, T_CLOSURE, T_FN]) + { + $target = $this->getTargetToken($commentString, $targetTokenType); + $result = self::$phpcsFile->getMethodParameters($target); + + $this->assertSame([], $result); + + }//end testNoParams() + + + /** + * Data Provider. + * + * @see testNoParams() For the array format. + * + * @return array>> + */ + public static function dataNoParams() + { + return [ + 'FunctionNoParams' => ['/* testFunctionNoParams */'], + 'ClosureNoParams' => ['/* testClosureNoParams */'], + 'ClosureUseNoParams' => [ + '/* testClosureUseNoParams */', + T_USE, + ], + ]; + + }//end dataNoParams() + + /** * Verify pass-by-reference parsing. * @@ -398,261 +530,1035 @@ public function testArrowFunction() /** - * Verify recognition of PHP8 mixed type declaration. + * Verify that arrow functions are supported. * * @return void */ - public function testPHP8MixedTypeHint() + public function testArrowFunctionReturnByRef() { - // Offsets are relative to the T_FUNCTION token. + // Offsets are relative to the T_FN token. $expected = []; $expected[0] = [ - 'token' => 8, - 'name' => '$var1', - 'content' => 'mixed &...$var1', + 'token' => 6, + 'name' => '$a', + 'content' => '?string $a', 'has_attributes' => false, - 'pass_by_reference' => true, - 'reference_token' => 6, - 'variable_length' => true, - 'variadic_token' => 7, - 'type_hint' => 'mixed', + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?string', 'type_hint_token' => 4, 'type_hint_end_token' => 4, - 'nullable_type' => false, + 'nullable_type' => true, 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); - }//end testPHP8MixedTypeHint() + }//end testArrowFunctionReturnByRef() /** - * Verify recognition of PHP8 mixed type declaration with nullability. + * Verify default value parsing with array values. * * @return void */ - public function testPHP8MixedTypeHintNullable() + public function testArrayDefaultValues() { // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'token' => 7, + 'token' => 4, 'name' => '$var1', - 'content' => '?Mixed $var1', + 'content' => '$var1 = []', + 'default' => '[]', + 'default_token' => 8, + 'default_equal_token' => 6, 'has_attributes' => false, 'pass_by_reference' => false, 'reference_token' => false, 'variable_length' => false, 'variadic_token' => false, - 'type_hint' => '?Mixed', - 'type_hint_token' => 5, - 'type_hint_end_token' => 5, - 'nullable_type' => true, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 10, + ]; + $expected[1] = [ + 'token' => 12, + 'name' => '$var2', + 'content' => '$var2 = array(1, 2, 3)', + 'default' => 'array(1, 2, 3)', + 'default_token' => 16, + 'default_equal_token' => 14, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); - }//end testPHP8MixedTypeHintNullable() + }//end testArrayDefaultValues() /** - * Verify recognition of type declarations using the namespace operator. + * Verify having a T_STRING constant as a default value for the second parameter. * * @return void */ - public function testNamespaceOperatorTypeHint() + public function testConstantDefaultValueSecondParam() { // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'token' => 9, + 'token' => 4, 'name' => '$var1', - 'content' => '?namespace\Name $var1', + 'content' => '$var1', 'has_attributes' => false, 'pass_by_reference' => false, 'reference_token' => false, 'variable_length' => false, 'variadic_token' => false, - 'type_hint' => '?namespace\Name', - 'type_hint_token' => 5, - 'type_hint_end_token' => 7, - 'nullable_type' => true, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 5, + ]; + $expected[1] = [ + 'token' => 7, + 'name' => '$var2', + 'content' => '$var2 = M_PI', + 'default' => 'M_PI', + 'default_token' => 11, + 'default_equal_token' => 9, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); - }//end testNamespaceOperatorTypeHint() + }//end testConstantDefaultValueSecondParam() /** - * Verify recognition of PHP8 union type declaration. + * Verify distinquishing between a nullable type and a ternary within a default expression. * * @return void */ - public function testPHP8UnionTypesSimple() + public function testScalarTernaryExpressionInDefault() { // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'token' => 8, - 'name' => '$number', - 'content' => 'int|float $number', + 'token' => 5, + 'name' => '$a', + 'content' => '$a = FOO ? \'bar\' : 10', + 'default' => 'FOO ? \'bar\' : 10', + 'default_token' => 9, + 'default_equal_token' => 7, 'has_attributes' => false, 'pass_by_reference' => false, 'reference_token' => false, 'variable_length' => false, 'variadic_token' => false, - 'type_hint' => 'int|float', - 'type_hint_token' => 4, - 'type_hint_end_token' => 6, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, 'nullable_type' => false, - 'comma_token' => 9, + 'comma_token' => 18, ]; $expected[1] = [ - 'token' => 17, - 'name' => '$obj', - 'content' => 'self|parent &...$obj', + 'token' => 24, + 'name' => '$b', + 'content' => '? bool $b', 'has_attributes' => false, - 'pass_by_reference' => true, - 'reference_token' => 15, - 'variable_length' => true, - 'variadic_token' => 16, - 'type_hint' => 'self|parent', - 'type_hint_token' => 11, - 'type_hint_end_token' => 13, - 'nullable_type' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?bool', + 'type_hint_token' => 22, + 'type_hint_end_token' => 22, + 'nullable_type' => true, 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); - }//end testPHP8UnionTypesSimple() + }//end testScalarTernaryExpressionInDefault() /** - * Verify recognition of PHP8 union type declaration when the variable has either a spread operator or a reference. + * Verify a variadic parameter being recognized correctly. * * @return void */ - public function testPHP8UnionTypesWithSpreadOperatorAndReference() + public function testVariadicFunction() { // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ 'token' => 9, - 'name' => '$paramA', - 'content' => 'float|null &$paramA', - 'has_attributes' => false, - 'pass_by_reference' => true, - 'reference_token' => 8, - 'variable_length' => false, - 'variadic_token' => false, - 'type_hint' => 'float|null', - 'type_hint_token' => 4, - 'type_hint_end_token' => 6, - 'nullable_type' => false, - 'comma_token' => 10, - ]; - $expected[1] = [ - 'token' => 17, - 'name' => '$paramB', - 'content' => 'string|int ...$paramB', + 'name' => '$a', + 'content' => 'int ... $a', 'has_attributes' => false, 'pass_by_reference' => false, 'reference_token' => false, 'variable_length' => true, - 'variadic_token' => 16, - 'type_hint' => 'string|int', - 'type_hint_token' => 12, - 'type_hint_end_token' => 14, + 'variadic_token' => 7, + 'type_hint' => 'int', + 'type_hint_token' => 5, + 'type_hint_end_token' => 5, 'nullable_type' => false, 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); - }//end testPHP8UnionTypesWithSpreadOperatorAndReference() + }//end testVariadicFunction() /** - * Verify recognition of PHP8 union type declaration with a bitwise or in the default value. + * Verify a variadic parameter passed by reference being recognized correctly. * * @return void */ - public function testPHP8UnionTypesSimpleWithBitwiseOrInDefault() + public function testVariadicByRefFunction() { // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'token' => 6, - 'name' => '$var', - 'content' => 'int|float $var = CONSTANT_A | CONSTANT_B', - 'default' => 'CONSTANT_A | CONSTANT_B', - 'default_token' => 10, - 'default_equal_token' => 8, + 'token' => 7, + 'name' => '$a', + 'content' => '&...$a', 'has_attributes' => false, - 'pass_by_reference' => false, - 'reference_token' => false, - 'variable_length' => false, - 'variadic_token' => false, - 'type_hint' => 'int|float', - 'type_hint_token' => 2, - 'type_hint_end_token' => 4, + 'pass_by_reference' => true, + 'reference_token' => 5, + 'variable_length' => true, + 'variadic_token' => 6, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, 'nullable_type' => false, 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); - }//end testPHP8UnionTypesSimpleWithBitwiseOrInDefault() + }//end testVariadicByRefFunction() /** - * Verify recognition of PHP8 union type declaration with two classes. + * Verify handling of a variadic parameter with a class based type declaration. * * @return void */ - public function testPHP8UnionTypesTwoClasses() + public function testVariadicFunctionClassType() { // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'token' => 11, - 'name' => '$var', - 'content' => 'MyClassA|\Package\MyClassB $var', + 'token' => 4, + 'name' => '$unit', + 'content' => '$unit', 'has_attributes' => false, 'pass_by_reference' => false, 'reference_token' => false, 'variable_length' => false, 'variadic_token' => false, - 'type_hint' => 'MyClassA|\Package\MyClassB', - 'type_hint_token' => 4, - 'type_hint_end_token' => 9, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 5, + ]; + $expected[1] = [ + 'token' => 10, + 'name' => '$intervals', + 'content' => 'DateInterval ...$intervals', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => true, + 'variadic_token' => 9, + 'type_hint' => 'DateInterval', + 'type_hint_token' => 7, + 'type_hint_end_token' => 7, 'nullable_type' => false, 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); - }//end testPHP8UnionTypesTwoClasses() + }//end testVariadicFunctionClassType() /** - * Verify recognition of PHP8 union type declaration with all base types. + * Verify distinquishing between a nullable type and a ternary within a default expression. * * @return void */ - public function testPHP8UnionTypesAllBaseTypes() + public function testNameSpacedTypeDeclaration() { // Offsets are relative to the T_FUNCTION token. $expected = []; $expected[0] = [ - 'token' => 20, - 'name' => '$var', - 'content' => 'array|bool|callable|int|float|null|object|string $var', + 'token' => 12, + 'name' => '$a', + 'content' => '\Package\Sub\ClassName $a', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '\Package\Sub\ClassName', + 'type_hint_token' => 5, + 'type_hint_end_token' => 10, + 'nullable_type' => false, + 'comma_token' => 13, + ]; + $expected[1] = [ + 'token' => 20, + 'name' => '$b', + 'content' => '?Sub\AnotherClass $b', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?Sub\AnotherClass', + 'type_hint_token' => 16, + 'type_hint_end_token' => 18, + 'nullable_type' => true, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testNameSpacedTypeDeclaration() + + + /** + * Verify correctly recognizing all type declarations supported by PHP. + * + * @return void + */ + public function testWithAllTypes() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 9, + 'name' => '$a', + 'content' => '?ClassName $a', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?ClassName', + 'type_hint_token' => 7, + 'type_hint_end_token' => 7, + 'nullable_type' => true, + 'comma_token' => 10, + ]; + $expected[1] = [ + 'token' => 15, + 'name' => '$b', + 'content' => 'self $b', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'self', + 'type_hint_token' => 13, + 'type_hint_end_token' => 13, + 'nullable_type' => false, + 'comma_token' => 16, + ]; + $expected[2] = [ + 'token' => 21, + 'name' => '$c', + 'content' => 'parent $c', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'parent', + 'type_hint_token' => 19, + 'type_hint_end_token' => 19, + 'nullable_type' => false, + 'comma_token' => 22, + ]; + $expected[3] = [ + 'token' => 27, + 'name' => '$d', + 'content' => 'object $d', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'object', + 'type_hint_token' => 25, + 'type_hint_end_token' => 25, + 'nullable_type' => false, + 'comma_token' => 28, + ]; + $expected[4] = [ + 'token' => 34, + 'name' => '$e', + 'content' => '?int $e', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?int', + 'type_hint_token' => 32, + 'type_hint_end_token' => 32, + 'nullable_type' => true, + 'comma_token' => 35, + ]; + $expected[5] = [ + 'token' => 41, + 'name' => '$f', + 'content' => 'string &$f', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 40, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'string', + 'type_hint_token' => 38, + 'type_hint_end_token' => 38, + 'nullable_type' => false, + 'comma_token' => 42, + ]; + $expected[6] = [ + 'token' => 47, + 'name' => '$g', + 'content' => 'iterable $g', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'iterable', + 'type_hint_token' => 45, + 'type_hint_end_token' => 45, + 'nullable_type' => false, + 'comma_token' => 48, + ]; + $expected[7] = [ + 'token' => 53, + 'name' => '$h', + 'content' => 'bool $h = true', + 'default' => 'true', + 'default_token' => 57, + 'default_equal_token' => 55, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'bool', + 'type_hint_token' => 51, + 'type_hint_end_token' => 51, + 'nullable_type' => false, + 'comma_token' => 58, + ]; + $expected[8] = [ + 'token' => 63, + 'name' => '$i', + 'content' => 'callable $i = \'is_null\'', + 'default' => "'is_null'", + 'default_token' => 67, + 'default_equal_token' => 65, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'callable', + 'type_hint_token' => 61, + 'type_hint_end_token' => 61, + 'nullable_type' => false, + 'comma_token' => 68, + ]; + $expected[9] = [ + 'token' => 73, + 'name' => '$j', + 'content' => 'float $j = 1.1', + 'default' => '1.1', + 'default_token' => 77, + 'default_equal_token' => 75, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'float', + 'type_hint_token' => 71, + 'type_hint_end_token' => 71, + 'nullable_type' => false, + 'comma_token' => 78, + ]; + $expected[10] = [ + 'token' => 84, + 'name' => '$k', + 'content' => 'array ...$k', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => true, + 'variadic_token' => 83, + 'type_hint' => 'array', + 'type_hint_token' => 81, + 'type_hint_end_token' => 81, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testWithAllTypes() + + + /** + * Verify correctly recognizing all type declarations supported by PHP when used with an arrow function. + * + * @return void + */ + public function testArrowFunctionWithAllTypes() + { + // Offsets are relative to the T_FN token. + $expected = []; + $expected[0] = [ + 'token' => 7, + 'name' => '$a', + 'content' => '?ClassName $a', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?ClassName', + 'type_hint_token' => 5, + 'type_hint_end_token' => 5, + 'nullable_type' => true, + 'comma_token' => 8, + ]; + $expected[1] = [ + 'token' => 13, + 'name' => '$b', + 'content' => 'self $b', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'self', + 'type_hint_token' => 11, + 'type_hint_end_token' => 11, + 'nullable_type' => false, + 'comma_token' => 14, + ]; + $expected[2] = [ + 'token' => 19, + 'name' => '$c', + 'content' => 'parent $c', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'parent', + 'type_hint_token' => 17, + 'type_hint_end_token' => 17, + 'nullable_type' => false, + 'comma_token' => 20, + ]; + $expected[3] = [ + 'token' => 25, + 'name' => '$d', + 'content' => 'object $d', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'object', + 'type_hint_token' => 23, + 'type_hint_end_token' => 23, + 'nullable_type' => false, + 'comma_token' => 26, + ]; + $expected[4] = [ + 'token' => 32, + 'name' => '$e', + 'content' => '?int $e', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?int', + 'type_hint_token' => 30, + 'type_hint_end_token' => 30, + 'nullable_type' => true, + 'comma_token' => 33, + ]; + $expected[5] = [ + 'token' => 39, + 'name' => '$f', + 'content' => 'string &$f', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 38, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'string', + 'type_hint_token' => 36, + 'type_hint_end_token' => 36, + 'nullable_type' => false, + 'comma_token' => 40, + ]; + $expected[6] = [ + 'token' => 45, + 'name' => '$g', + 'content' => 'iterable $g', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'iterable', + 'type_hint_token' => 43, + 'type_hint_end_token' => 43, + 'nullable_type' => false, + 'comma_token' => 46, + ]; + $expected[7] = [ + 'token' => 51, + 'name' => '$h', + 'content' => 'bool $h = true', + 'default' => 'true', + 'default_token' => 55, + 'default_equal_token' => 53, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'bool', + 'type_hint_token' => 49, + 'type_hint_end_token' => 49, + 'nullable_type' => false, + 'comma_token' => 56, + ]; + $expected[8] = [ + 'token' => 61, + 'name' => '$i', + 'content' => 'callable $i = \'is_null\'', + 'default' => "'is_null'", + 'default_token' => 65, + 'default_equal_token' => 63, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'callable', + 'type_hint_token' => 59, + 'type_hint_end_token' => 59, + 'nullable_type' => false, + 'comma_token' => 66, + ]; + $expected[9] = [ + 'token' => 71, + 'name' => '$j', + 'content' => 'float $j = 1.1', + 'default' => '1.1', + 'default_token' => 75, + 'default_equal_token' => 73, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'float', + 'type_hint_token' => 69, + 'type_hint_end_token' => 69, + 'nullable_type' => false, + 'comma_token' => 76, + ]; + $expected[10] = [ + 'token' => 82, + 'name' => '$k', + 'content' => 'array ...$k', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => true, + 'variadic_token' => 81, + 'type_hint' => 'array', + 'type_hint_token' => 79, + 'type_hint_end_token' => 79, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testArrowFunctionWithAllTypes() + + + /** + * Verify handling of a declaration interlaced with whitespace and comments. + * + * @return void + */ + public function testMessyDeclaration() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 25, + 'name' => '$a', + 'content' => '// comment + ?\MyNS /* comment */ + \ SubCat // phpcs:ignore Standard.Cat.Sniff -- for reasons. + \ MyClass $a', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?\MyNS\SubCat\MyClass', + 'type_hint_token' => 9, + 'type_hint_end_token' => 23, + 'nullable_type' => true, + 'comma_token' => 26, + ]; + $expected[1] = [ + 'token' => 29, + 'name' => '$b', + 'content' => "\$b /* test */ = /* test */ 'default' /* test*/", + 'default' => "'default' /* test*/", + 'default_token' => 37, + 'default_equal_token' => 33, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 40, + ]; + $expected[2] = [ + 'token' => 62, + 'name' => '$c', + 'content' => '// phpcs:ignore Stnd.Cat.Sniff -- For reasons. + ? /*comment*/ + bool // phpcs:disable Stnd.Cat.Sniff -- For reasons. + & /*test*/ ... /* phpcs:ignore */ $c', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 54, + 'variable_length' => true, + 'variadic_token' => 58, + 'type_hint' => '?bool', + 'type_hint_token' => 50, + 'type_hint_end_token' => 50, + 'nullable_type' => true, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testMessyDeclaration() + + + /** + * Verify recognition of PHP8 mixed type declaration. + * + * @return void + */ + public function testPHP8MixedTypeHint() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 8, + 'name' => '$var1', + 'content' => 'mixed &...$var1', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 6, + 'variable_length' => true, + 'variadic_token' => 7, + 'type_hint' => 'mixed', + 'type_hint_token' => 4, + 'type_hint_end_token' => 4, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP8MixedTypeHint() + + + /** + * Verify recognition of PHP8 mixed type declaration with nullability. + * + * @return void + */ + public function testPHP8MixedTypeHintNullable() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 7, + 'name' => '$var1', + 'content' => '?Mixed $var1', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?Mixed', + 'type_hint_token' => 5, + 'type_hint_end_token' => 5, + 'nullable_type' => true, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP8MixedTypeHintNullable() + + + /** + * Verify recognition of type declarations using the namespace operator. + * + * @return void + */ + public function testNamespaceOperatorTypeHint() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 9, + 'name' => '$var1', + 'content' => '?namespace\Name $var1', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?namespace\Name', + 'type_hint_token' => 5, + 'type_hint_end_token' => 7, + 'nullable_type' => true, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testNamespaceOperatorTypeHint() + + + /** + * Verify recognition of PHP8 union type declaration. + * + * @return void + */ + public function testPHP8UnionTypesSimple() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 8, + 'name' => '$number', + 'content' => 'int|float $number', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'int|float', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => false, + 'comma_token' => 9, + ]; + $expected[1] = [ + 'token' => 17, + 'name' => '$obj', + 'content' => 'self|parent &...$obj', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 15, + 'variable_length' => true, + 'variadic_token' => 16, + 'type_hint' => 'self|parent', + 'type_hint_token' => 11, + 'type_hint_end_token' => 13, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP8UnionTypesSimple() + + + /** + * Verify recognition of PHP8 union type declaration when the variable has either a spread operator or a reference. + * + * @return void + */ + public function testPHP8UnionTypesWithSpreadOperatorAndReference() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 9, + 'name' => '$paramA', + 'content' => 'float|null &$paramA', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 8, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'float|null', + 'type_hint_token' => 4, + 'type_hint_end_token' => 6, + 'nullable_type' => false, + 'comma_token' => 10, + ]; + $expected[1] = [ + 'token' => 17, + 'name' => '$paramB', + 'content' => 'string|int ...$paramB', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => true, + 'variadic_token' => 16, + 'type_hint' => 'string|int', + 'type_hint_token' => 12, + 'type_hint_end_token' => 14, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP8UnionTypesWithSpreadOperatorAndReference() + + + /** + * Verify recognition of PHP8 union type declaration with a bitwise or in the default value. + * + * @return void + */ + public function testPHP8UnionTypesSimpleWithBitwiseOrInDefault() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 6, + 'name' => '$var', + 'content' => 'int|float $var = CONSTANT_A | CONSTANT_B', + 'default' => 'CONSTANT_A | CONSTANT_B', + 'default_token' => 10, + 'default_equal_token' => 8, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'int|float', + 'type_hint_token' => 2, + 'type_hint_end_token' => 4, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP8UnionTypesSimpleWithBitwiseOrInDefault() + + + /** + * Verify recognition of PHP8 union type declaration with two classes. + * + * @return void + */ + public function testPHP8UnionTypesTwoClasses() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 11, + 'name' => '$var', + 'content' => 'MyClassA|\Package\MyClassB $var', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'MyClassA|\Package\MyClassB', + 'type_hint_token' => 4, + 'type_hint_end_token' => 9, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP8UnionTypesTwoClasses() + + + /** + * Verify recognition of PHP8 union type declaration with all base types. + * + * @return void + */ + public function testPHP8UnionTypesAllBaseTypes() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 20, + 'name' => '$var', + 'content' => 'array|bool|callable|int|float|null|object|string $var', 'has_attributes' => false, 'pass_by_reference' => false, 'reference_token' => false, @@ -1150,7 +2056,7 @@ public function testPHP81ConstructorPropertyPromotionWithReadOnly() $expected[1] = [ 'token' => 23, 'name' => '$promotedToo', - 'content' => 'readonly private string|bool &$promotedToo', + 'content' => 'ReadOnly private string|bool &$promotedToo', 'has_attributes' => false, 'pass_by_reference' => true, 'reference_token' => 22, @@ -1161,15 +2067,69 @@ public function testPHP81ConstructorPropertyPromotionWithReadOnly() 'type_hint_end_token' => 20, 'nullable_type' => false, 'property_visibility' => 'private', - 'visibility_token' => 16, + 'visibility_token' => 16, + 'property_readonly' => true, + 'readonly_token' => 14, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP81ConstructorPropertyPromotionWithReadOnly() + + + /** + * Verify recognition of PHP8 constructor with property promotion using PHP 8.1 readonly keyword + * without a property type. + * + * @return void + */ + public function testPHP81ConstructorPropertyPromotionWithReadOnlyNoTypeDeclaration() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 8, + 'name' => '$promotedProp', + 'content' => 'public readonly $promotedProp', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'property_visibility' => 'public', + 'visibility_token' => 4, + 'property_readonly' => true, + 'readonly_token' => 6, + 'comma_token' => 9, + ]; + $expected[1] = [ + 'token' => 16, + 'name' => '$promotedToo', + 'content' => 'ReadOnly private &$promotedToo', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 15, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'property_visibility' => 'private', + 'visibility_token' => 13, 'property_readonly' => true, - 'readonly_token' => 14, + 'readonly_token' => 11, 'comma_token' => false, ]; $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); - }//end testPHP81ConstructorPropertyPromotionWithReadOnly() + }//end testPHP81ConstructorPropertyPromotionWithReadOnlyNoTypeDeclaration() /** @@ -1687,17 +2647,331 @@ public function testPHP82PseudoTypeFalseAndTrue() }//end testPHP82PseudoTypeFalseAndTrue() + /** + * Verify behaviour when the default value uses the "new" keyword, as is allowed per PHP 8.1. + * + * @return void + */ + public function testPHP81NewInInitializers() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 8, + 'name' => '$new', + 'content' => 'TypeA $new = new TypeA(self::CONST_VALUE)', + 'default' => 'new TypeA(self::CONST_VALUE)', + 'default_token' => 12, + 'default_equal_token' => 10, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'TypeA', + 'type_hint_token' => 6, + 'type_hint_end_token' => 6, + 'nullable_type' => false, + 'comma_token' => 20, + ]; + $expected[1] = [ + 'token' => 28, + 'name' => '$newToo', + 'content' => '\Package\TypeB $newToo = new \Package\TypeB(10, \'string\')', + 'default' => "new \Package\TypeB(10, 'string')", + 'default_token' => 32, + 'default_equal_token' => 30, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '\Package\TypeB', + 'type_hint_token' => 23, + 'type_hint_end_token' => 26, + 'nullable_type' => false, + 'comma_token' => 44, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP81NewInInitializers() + + + /** + * Verify handling of a closure. + * + * @return void + */ + public function testClosure() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 3, + 'name' => '$a', + 'content' => '$a = \'test\'', + 'default' => "'test'", + 'default_token' => 7, + 'default_equal_token' => 5, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testClosure() + + + /** + * Verify handling of a closure T_USE token correctly. + * + * @return void + */ + public function testClosureUse() + { + // Offsets are relative to the T_USE token. + $expected = []; + $expected[0] = [ + 'token' => 3, + 'name' => '$foo', + 'content' => '$foo', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 4, + ]; + $expected[1] = [ + 'token' => 6, + 'name' => '$bar', + 'content' => '$bar', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected, [T_USE]); + + }//end testClosureUse() + + + /** + * Verify function declarations with trailing commas are handled correctly. + * + * @return void + */ + public function testFunctionParamListWithTrailingComma() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 9, + 'name' => '$foo', + 'content' => '?string $foo /*comment*/', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?string', + 'type_hint_token' => 7, + 'type_hint_end_token' => 7, + 'nullable_type' => true, + 'comma_token' => 13, + ]; + $expected[1] = [ + 'token' => 16, + 'name' => '$bar', + 'content' => '$bar = 0', + 'default' => '0', + 'default_token' => 20, + 'default_equal_token' => 18, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 21, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testFunctionParamListWithTrailingComma() + + + /** + * Verify closure declarations with trailing commas are handled correctly. + * + * @return void + */ + public function testClosureParamListWithTrailingComma() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 4, + 'name' => '$foo', + 'content' => '$foo', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 5, + ]; + $expected[1] = [ + 'token' => 8, + 'name' => '$bar', + 'content' => '$bar', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 9, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testClosureParamListWithTrailingComma() + + + /** + * Verify arrow function declarations with trailing commas are handled correctly. + * + * @return void + */ + public function testArrowFunctionParamListWithTrailingComma() + { + // Offsets are relative to the T_FN token. + $expected = []; + $expected[0] = [ + 'token' => 6, + 'name' => '$a', + 'content' => '?int $a', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '?int', + 'type_hint_token' => 4, + 'type_hint_end_token' => 4, + 'nullable_type' => true, + 'comma_token' => 8, + ]; + $expected[1] = [ + 'token' => 11, + 'name' => '$b', + 'content' => '...$b', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => true, + 'variadic_token' => 10, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 12, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testArrowFunctionParamListWithTrailingComma() + + + /** + * Verify closure T_USE statements with trailing commas are handled correctly. + * + * @return void + */ + public function testClosureUseWithTrailingComma() + { + // Offsets are relative to the T_USE token. + $expected = []; + $expected[0] = [ + 'token' => 4, + 'name' => '$foo', + 'content' => '$foo /*comment*/', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 8, + ]; + $expected[1] = [ + 'token' => 11, + 'name' => '$bar', + 'content' => '$bar', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 12, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected, [T_USE]); + + }//end testClosureUseWithTrailingComma() + + /** * Test helper. * * @param string $commentString The comment which preceeds the test. * @param array> $expected The expected function output. + * @param int|string|array $targetType Optional. The token type to search for after $marker. + * Defaults to the function/closure/arrow tokens. * * @return void */ - private function getMethodParametersTestHelper($commentString, $expected) + private function getMethodParametersTestHelper($commentString, $expected, $targetType=[T_FUNCTION, T_CLOSURE, T_FN]) { - $target = $this->getTargetToken($commentString, [T_FUNCTION, T_CLOSURE, T_FN]); + $target = $this->getTargetToken($commentString, $targetType); $found = self::$phpcsFile->getMethodParameters($target); // Convert offsets to absolute positions in the token stream. From ed7c50930710806f63ecb6a8f1ce6e10619001be Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Dec 2023 03:25:46 +0100 Subject: [PATCH 226/874] Tests: move `IsCamelCapsTest` to `Util` subdirectory --- tests/Core/{ => Util}/IsCamelCapsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/Core/{ => Util}/IsCamelCapsTest.php (99%) diff --git a/tests/Core/IsCamelCapsTest.php b/tests/Core/Util/IsCamelCapsTest.php similarity index 99% rename from tests/Core/IsCamelCapsTest.php rename to tests/Core/Util/IsCamelCapsTest.php index 9a1a737384..2a1729b2a3 100644 --- a/tests/Core/IsCamelCapsTest.php +++ b/tests/Core/Util/IsCamelCapsTest.php @@ -7,7 +7,7 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core; +namespace PHP_CodeSniffer\Tests\Core\Util; use PHP_CodeSniffer\Util\Common; use PHPUnit\Framework\TestCase; From 91ae2f46f27345275d3c20f16e1db4eeeb83ecd9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 05:50:47 +0100 Subject: [PATCH 227/874] CS rules: tweak array rules for test files Test files often use data providers (or should). Data providers are provided as arrays (as `yield` is not supported in the minimum supported PHP version of PHPCS). As things were, single item arrays would be forced to be single-line, while multi-item arrays would be forced to be multi-line. For large data provider arrays which have a mix of single item and multi-item sub-arrays, this decreases the scannability of the test cases. For that reason, I'm disabling the enforcement of "single item arrays should be single line" for all test files. In practice this means that multi-item arrays still need to be multi-line, but that single item arrays can be either single line or multi-line, whichever is best for readability of the test data. Related to 155 --- phpcs.xml.dist | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index f5f05f9144..a5fa45793e 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -87,6 +87,12 @@ 0
+ + + tests/*\.php$ + Standards/*/Tests/*/*UnitTest\.php$ + + From e50784d443b4966109319b495b91fb2fa4f82572 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 3 Jan 2024 11:39:29 -0300 Subject: [PATCH 228/874] Generic/ForLoopShouldBeWhileLoop: rename test case file Doing this to be able to create a test with a syntax error on a separate file. --- ...c => ForLoopShouldBeWhileLoopUnitTest.1.inc} | 0 .../ForLoopShouldBeWhileLoopUnitTest.php | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) rename src/Standards/Generic/Tests/CodeAnalysis/{ForLoopShouldBeWhileLoopUnitTest.inc => ForLoopShouldBeWhileLoopUnitTest.1.inc} (100%) diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.inc rename to src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php index 2fcfffb173..662f9f2a68 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php @@ -41,14 +41,21 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the test file being tested. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return [ - 6 => 1, - 10 => 1, - ]; + switch ($testFile) { + case 'ForLoopShouldBeWhileLoopUnitTest.1.inc': + return [ + 6 => 1, + 10 => 1, + ]; + default: + return []; + } }//end getWarningList() From d783b206bd91e92c53caa02ebf3737c588d76a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C5=BDoljom?= Date: Wed, 3 Jan 2024 19:47:15 +0100 Subject: [PATCH 229/874] [Documentation] PSR12 - Closing Brace (#170) * Add the documentation for the PSR12 Closing Brace Sniff --- .../Docs/Classes/ClosingBraceStandard.xml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/Standards/PSR12/Docs/Classes/ClosingBraceStandard.xml diff --git a/src/Standards/PSR12/Docs/Classes/ClosingBraceStandard.xml b/src/Standards/PSR12/Docs/Classes/ClosingBraceStandard.xml new file mode 100644 index 0000000000..b59d734fe0 --- /dev/null +++ b/src/Standards/PSR12/Docs/Classes/ClosingBraceStandard.xml @@ -0,0 +1,35 @@ + + + + + + + + +function bar() +{ + // Function content. +} + ]]> + + + echo 'Hello!'; + +function bar() +{ + // Function content. +} //end bar() + ]]> + + + From 092ecd999b0994afe36843205fb9f8f5e87962d2 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 3 Jan 2024 15:53:27 -0300 Subject: [PATCH 230/874] Generic/LanguageConstructSpacing: add XML documentation (#177) * Generic/LanguageConstructSpacing: add XML documentation --- .../LanguageConstructSpacingStandard.xml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/Standards/Generic/Docs/WhiteSpace/LanguageConstructSpacingStandard.xml diff --git a/src/Standards/Generic/Docs/WhiteSpace/LanguageConstructSpacingStandard.xml b/src/Standards/Generic/Docs/WhiteSpace/LanguageConstructSpacingStandard.xml new file mode 100644 index 0000000000..a9cd5a65cb --- /dev/null +++ b/src/Standards/Generic/Docs/WhiteSpace/LanguageConstructSpacingStandard.xml @@ -0,0 +1,44 @@ + + + + + + + 'Hello, World!'; +throw new Exception(); +return $newLine; + ]]> + + + 'Hello, World!'; +throw new Exception(); +return +$newLine; + ]]> + + + + + + + + from [1, 2, 3]; + ]]> + + + from [1, 2, 3]; +yield from [1, 2, 3]; +yield +from [1, 2, 3]; + ]]> + + + From 269098eb11928792720a5a488e3f46d9b26655c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C5=BDoljom?= Date: Thu, 4 Jan 2024 09:40:08 +0100 Subject: [PATCH 231/874] [Documentation] PSR12 - Opening Brace Space (#171) * Add the documentation for the PSR12 Opening Brace Space sniff --- .../Classes/OpeningBraceSpaceStandard.xml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Standards/PSR12/Docs/Classes/OpeningBraceSpaceStandard.xml diff --git a/src/Standards/PSR12/Docs/Classes/OpeningBraceSpaceStandard.xml b/src/Standards/PSR12/Docs/Classes/OpeningBraceSpaceStandard.xml new file mode 100644 index 0000000000..818bbe83a4 --- /dev/null +++ b/src/Standards/PSR12/Docs/Classes/OpeningBraceSpaceStandard.xml @@ -0,0 +1,32 @@ + + + + + + + + public function bar() + { + // Method content. + } +} + ]]> + + + + public function bar() + { + // Method content. + } +} + ]]> + + + From 64a90e2fce71e11313d5d8a2f551454e31d00e37 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 4 Jan 2024 09:58:19 +0100 Subject: [PATCH 232/874] QA: fix up license links in newly merged files Follow up on 1. Some PRs which were ported over from the Squizlabs repo introduced new files in which the old license link was still included. Fixed now. --- src/Reports/Performance.php | 2 +- tests/Core/Ruleset/ExplainTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Reports/Performance.php b/src/Reports/Performance.php index 78f0f6ae23..ea90d0a84c 100644 --- a/src/Reports/Performance.php +++ b/src/Reports/Performance.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2023 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Reports; diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index 934801b674..065a73cfba 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2023 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Ruleset; From 9c4b38c76d48dbffbf53ac580767e90923296cfc Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 3 Jan 2024 11:49:48 -0300 Subject: [PATCH 233/874] Generic/ForLoopShouldBeWhileLoop: improve test coverage This commit adds the following groups of tests: - A few tests that do not trigger the sniff but should help to protect against regressions in the future. Including tests using the for loop alternative syntax. - A test to exercise code in the sniff to bail early if the `for` keyword is found without a opening parenthesis. This part was not covered before. --- .../ForLoopShouldBeWhileLoopUnitTest.1.inc | 26 ++++++++++++++++++- .../ForLoopShouldBeWhileLoopUnitTest.2.inc | 4 +++ .../ForLoopShouldBeWhileLoopUnitTest.php | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.2.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.1.inc b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.1.inc index cc69c67963..3b47942a9a 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.1.inc +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.1.inc @@ -10,4 +10,28 @@ for (; $it->valid();) { for (;(($it1->valid() && $foo) || (!$it2->value && ($bar || false)));/*Could be ignored*/) { $it1->next(); $it2->next(); -} \ No newline at end of file +} + +for ($i = 0, $j = 10; $i < $j; $i++, $j--) { + echo "i: $i, j: $j\n"; +} + +for (;;) { + if ($i >= 10) { + break; + } + echo $i++; +} + +for ($i = 0; $i < 10; $i++): ?> +

+ 1, 10 => 1, + 34 => 1, ]; default: return []; From f8e0b67f6596b06af42802cedc965236cb4efa8f Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 5 Jan 2024 06:40:01 -0300 Subject: [PATCH 234/874] Generic/EmptyPHPStatement: add XML documentation (#166) * Generic/EmptyPHPStatement: add documentation * Fix one of the invalid examples in EmptyPHPStatementStandard.xml --- .../EmptyPHPStatementStandard.xml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/Standards/Generic/Docs/CodeAnalysis/EmptyPHPStatementStandard.xml diff --git a/src/Standards/Generic/Docs/CodeAnalysis/EmptyPHPStatementStandard.xml b/src/Standards/Generic/Docs/CodeAnalysis/EmptyPHPStatementStandard.xml new file mode 100644 index 0000000000..5652f657af --- /dev/null +++ b/src/Standards/Generic/Docs/CodeAnalysis/EmptyPHPStatementStandard.xml @@ -0,0 +1,44 @@ + + + + + + + echo 'Hello World'; ?> +'Hello World'; ?> + ]]> + + + ; ?> + ?> + ]]> + + + + + + + + ; +if (true) { + echo 'Hello World'; +} + ]]> + + + ;;; +if (true) { + echo 'Hello World'; +}; + ]]> + + + From 91c0d4b06fa1783b723e3a78b10145a1932782fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C5=BDoljom?= Date: Fri, 5 Jan 2024 11:57:58 +0100 Subject: [PATCH 235/874] Add the documentation for the PSR12 Open Tag sniff --- .../PSR12/Docs/Files/OpenTagStandard.xml | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/Standards/PSR12/Docs/Files/OpenTagStandard.xml diff --git a/src/Standards/PSR12/Docs/Files/OpenTagStandard.xml b/src/Standards/PSR12/Docs/Files/OpenTagStandard.xml new file mode 100644 index 0000000000..20db18b213 --- /dev/null +++ b/src/Standards/PSR12/Docs/Files/OpenTagStandard.xml @@ -0,0 +1,40 @@ + + + + + + + + +echo 'hi'; + ]]> + + + echo 'hi'; + ]]> + + + + + + + + + + + ]]> + + + + ]]> + + + From b3ddd0db92afcdf398a7d4cedf3c97a133681453 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 5 Jan 2024 12:51:52 +0100 Subject: [PATCH 236/874] PSR12 ruleset: minor documentation tweak Noticed this reference was missing while reviewing 233. --- src/Standards/PSR12/ruleset.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Standards/PSR12/ruleset.xml b/src/Standards/PSR12/ruleset.xml index ce8b71a756..a631fed602 100644 --- a/src/Standards/PSR12/ruleset.xml +++ b/src/Standards/PSR12/ruleset.xml @@ -96,6 +96,7 @@ + From 1ebc09edd54c3193ba3842781d271d06f56c6131 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 4 Jan 2024 11:32:56 -0300 Subject: [PATCH 237/874] Generic/ForLoopShouldBeWhileLoop: fix E_DEPRECATED error This commit fixes an issue in the sniff that could result in the following E_DEPRECATED error when running PHP 8.3: ``` Decrement on type null has no effect, this will change in the next major version of PHP src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php:65 ``` This sniff relies on finding the position of the open and closing parentheses for a given `for` loop. However, the problem was that there was no defensive code for cases when the closing parenthesis is missing. The sniff would still work when running PHP >= 8.2, but on PHP 8.3 it would throw the deprecated message above. This would happen because since there is no closing parenthesis `$end` is set to null, and $next <= $end always evaluates to false (https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/84acf4e56f110db8e75cb9a575c5727df637643c/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php#L74). The issue was fixed by bailing early if the closing parenthesis is missing. A test with a `for` loop without the closing parenthesis was added. --- .../Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php | 2 +- .../CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.3.inc | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.3.inc diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php index 286ce62704..726b32c552 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php @@ -57,7 +57,7 @@ public function process(File $phpcsFile, $stackPtr) $token = $tokens[$stackPtr]; // Skip invalid statement. - if (isset($token['parenthesis_opener']) === false) { + if (isset($token['parenthesis_opener'], $token['parenthesis_closer']) === false) { return; } diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.3.inc b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.3.inc new file mode 100644 index 0000000000..5502b61438 --- /dev/null +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.3.inc @@ -0,0 +1,6 @@ + Date: Sat, 23 Dec 2023 10:52:37 +0100 Subject: [PATCH 238/874] Add the documentation for the PSR12 Boolean Operator Placement sniff Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- .../BooleanOperatorPlacementStandard.xml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/Standards/PSR12/Docs/ControlStructures/BooleanOperatorPlacementStandard.xml diff --git a/src/Standards/PSR12/Docs/ControlStructures/BooleanOperatorPlacementStandard.xml b/src/Standards/PSR12/Docs/ControlStructures/BooleanOperatorPlacementStandard.xml new file mode 100644 index 0000000000..805e15c660 --- /dev/null +++ b/src/Standards/PSR12/Docs/ControlStructures/BooleanOperatorPlacementStandard.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + From 26a58f04ec6cb4856f2a512a59ee1e58fc31687b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 10 Dec 2023 23:18:44 +0100 Subject: [PATCH 239/874] Changelog: add links to contributors Prior to the repo take-over, the changelog was maintained in a PEAR `package.xml` file using a format as expected for that file, which did not allow for links. Since PEAR support has been dropped in version 3.8.0, the changelog was moved to a Markdown file. This PR is a first effort to improve the usefulness of the changelog by improving the "giving credit where credit is due" part of the changelog. A best effort has been made to add links for all contributors named in the changelog. * Whenever possible, a GitHub profile link has been used. * For older contributions via PEAR, the PEAR user profile link has been used unless their GitHub username could be determined with a high degree of certainty. Unfortunately, for some contributions, my code archaeology effort have proven in vain and I have not been able to trace the name of the contributor back to a user profile. :point_right: If this applies to a contribution **_you_** made, please submit a pull request to update the changelog to include a link to your profile. Note: this may seem like a lot of effort for a changelog/historical information. However, to me, this is about creating a positive climate open for contributions and that makes it important (to me). --- CHANGELOG.md | 1841 ++++++++++++++++++++++++++++---------------------- 1 file changed, 1038 insertions(+), 803 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 450dbd4a12..cde2c338c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,9 +29,9 @@ _Nothing yet._ - 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 + - 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 + - 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 @@ -45,31 +45,31 @@ _Nothing yet._ - Squiz.Commenting.DocCommentAlignment - Squiz.Commenting.FileComment - Squiz.Commenting.InlineComment - - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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](https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/59/commits/26384ebfcc0b1c1651b0e1e40c9b6c8c22881832) - - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch + - 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 @@ -82,45 +82,45 @@ _Nothing yet._ - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 - - Thanks to @Daimona for the patch + - Thanks to [@Daimona] for the patch - 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 + - 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 + - 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 + - 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 + - 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 + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The following sniffs have received minor message readability improvements: - Generic.Arrays.ArrayIndent - Generic.Formatting.SpaceAfterCast @@ -129,11 +129,11 @@ _Nothing yet._ - Squiz.Arrays.ArrayDeclaration - Squiz.Commenting.DocCommentAlignment - Squiz.ControlStructures.ControlSignature - - Thanks to Danny van der Sluijs (@DannyvdSluijs) and Juliette Reinders Folmer (@jrfnl) for the patches + - Thanks to [Danny van der Sluijs][@DannyvdSluijs] and [Juliette Reinders Folmer][@jrfnl] for the patches - Improved README syntax highlighting - - Thanks to Benjamin Loison (@Benjamin-Loison) for the patch + - Thanks to [Benjamin Loison][@Benjamin-Loison] for the patch - Various documentation improvements - - Thanks to Andrew Dawes (@AndrewDawes), Danny van der Sluijs (@DannyvdSluijs) and Juliette Reinders Folmer (@jrfnl) for the patches + - Thanks to [Andrew Dawes][@AndrewDawes], [Danny van der Sluijs][@DannyvdSluijs] and [Juliette Reinders Folmer][@jrfnl] for the patches ### Removed - Removed support for installation via PEAR @@ -141,87 +141,87 @@ _Nothing yet._ ### 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 - - Thanks to @Daimona for the patch + - Thanks to [@Daimona] for the patch - Fixed bug [#3809] : GitBlame report was broken when passing a basepath - - Thanks to Chris (@datengraben) for the patch + - Thanks to [Chris][@datengraben] for the patch - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 - - Thanks to @simonsan for the patch + - Thanks to [@simonsan] for the patch - Fixed bug [#3893] : Generic/DocComment : the SpacingAfterTagGroup fixer could accidentally remove ignore annotations - - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch + - 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 + - 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 + - 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 + - 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 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. +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. [#2857]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2857 [#3386]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3386 @@ -264,59 +264,59 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ## [3.7.2] - 2023-02-23 ### Changed - Newer versions of Composer will now suggest installing PHPCS using require-dev instead of require - - Thanks to Gary Jones (@GaryJones) for the patch + - Thanks to [Gary Jones][@GaryJones] for the patch - 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 + - 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 + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Formatting.OperatorBracket no longer reports false positives in match() structures ### Fixed - Fixed bug #3616 : Squiz.PHP.DisallowComparisonAssignment false positive for PHP 8 match expression - - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - 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 + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.7.1] - 2022-06-18 ### Fixed - Fixed bug #3609 : Methods/constants with name empty/isset/unset are always reported as error - - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.7.0] - 2022-06-13 ### Added - 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 for the patch - - Thanks to Juliette Reinders Folmer for additional fixes + - 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 for the patch - - Thanks to Juliette Reinders Folmer for additional core and sniff support + - 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 for the patch + - 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 for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch ### Changed - File::getMethodParameters now supports the new PHP 8.1 readonly token @@ -324,7 +324,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - 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 for the patch + - 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 @@ -332,75 +332,75 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz.Commenting.DocCommentAlignment - Squiz.Commenting.VariableComment - Squiz.WhiteSpace.ScopeKeywordSpacing - - Thanks to Juliette Reinders Folmer for the patches + - 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 for the patch + - 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 for the patch + - 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 for the patch + - 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 for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch ### Fixed - 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 - Fixed bug #3505 : The nullsafe operator is not counted in Generic.Metrics.CyclomaticComplexity - - Thanks to Mark Baker for the patch + - Thanks to [Mark Baker][@MarkBaker] for the patch - Fixed bug #3526 : PSR12.Properties.ConstantVisibility false positive when using public final const syntax - - Thanks to Juliette Reinders Folmer for the patch + - 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 for the patch + - 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 for the patch + - 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 for the patch + - 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 for the patch + - 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 for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.6.2] - 2021-12-13 ### Changed - Processing large code bases that use tab indenting inside comments and strings will now be faster - - Thanks to Thiemo Kreuz for the patch + - Thanks to [Thiemo Kreuz][@thiemowmde] for the patch ### Fixed - Fixed bug #3388 : phpcs does not work when run from WSL drives - - Thanks to Juliette Reinders Folmer and Graham Wharton for the patch + - 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 for the patch + - 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 for the patch + - 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 and Andy Postnikov for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] and Andy Postnikov for the patch - Fixed bug #3456 : PSR12.Classes.ClassInstantiation.MissingParentheses false positive using attributes on anonymous class - - Thanks to Juliette Reinders Folmer for the patch + - 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 for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3468 : do/while loops are double-counted in Generic.Metrics.CyclomaticComplexity - - Thanks to Mark Baker for the patch + - Thanks to [Mark Baker][@MarkBaker] for the patch - Fixed bug #3469 : Ternary Operator and Null Coalescing Operator are not counted in Generic.Metrics.CyclomaticComplexity - - Thanks to Mark Baker for the patch + - Thanks to [Mark Baker][@MarkBaker] for the patch - Fixed bug #3472 : PHP 8 match() expression is not counted in Generic.Metrics.CyclomaticComplexity - - Thanks to Mark Baker for the patch + - Thanks to [Mark Baker][@MarkBaker] for the patch ## [3.6.1] - 2021-10-11 ### Changed - PHPCS annotations can now be specified using hash-style comments - Previously, only slash-style and block-style comments could be used to do things like disable errors - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The new PHP 8.1 tokenisation for ampersands has been reverted to use the existing PHP_CodeSniffer method - The PHP 8.1 tokens T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG and T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG are unsued - Ampersands continue to be tokenized as T_BITWISE_AND for all PHP versions - - Thanks to Juliette Reinders Folmer and Anna Filina for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] and [Anna Filina][@afilina] for the patch - File::getMethodParameters() no longer incorrectly returns argument attributes in the type hint array index - A new has_attributes array index is available and set to TRUE if the argument has attributes defined - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed an issue where some sniffs would not run on PHP files that only used the short echo tag - The following sniffs were affected: - Generic.Files.ExecutableFile @@ -413,68 +413,68 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Generic.VersionControl.GitMergeConflict - Generic.WhiteSpace.DisallowSpaceIndent - Generic.WhiteSpace.DisallowTabIndent - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.BlockComment now correctly applies rules for block comments after a short echo tag - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed - Generic.NamingConventions.ConstructorName no longer throws deprecation notices on PHP 8.1 - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed false positives when using attributes in the following sniffs: - PEAR.Commenting.FunctionComment - Squiz.Commenting.InlineComment - Squiz.Commenting.BlockComment - Squiz.Commenting.VariableComment - Squiz.WhiteSpace.MemberVarSpacing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3294 : Bug in attribute tokenization when content contains PHP end token or attribute closer on new line - - Thanks to Alessandro Chitolina for the patch - - Thanks to Juliette Reinders Folmer for the tests + - Thanks to [Alessandro Chitolina][@alekitto] for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the tests - Fixed bug #3296 : PSR2.ControlStructures.SwitchDeclaration takes phpcs:ignore as content of case body - Fixed bug #3297 : PSR2.ControlStructures.SwitchDeclaration.TerminatingComment does not handle try/finally blocks - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3302 : PHP 8.0 | Tokenizer/PHP: bugfix for union types using namespace operator - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3303 : findStartOfStatement() doesn't work with T_OPEN_TAG_WITH_ECHO - Fixed bug #3316 : Arrow function not tokenized correctly when using null in union type - Fixed bug #3317 : Problem with how phpcs handles ignored files when running in parallel - - Thanks to Emil Andersson for the patch + - Thanks to [Emil Andersson][@emil-nasso] for the patch - Fixed bug #3324 : PHPCS hangs processing some nested arrow functions inside a function call - Fixed bug #3326 : Generic.Formatting.MultipleStatementAlignment error with const DEFAULT - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3333 : Squiz.Objects.ObjectInstantiation: null coalesce operators are not recognized as assignment - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3340 : Ensure interface and trait names are always tokenized as T_STRING - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3342 : PSR12/Squiz/PEAR standards all error on promoted properties with docblocks - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3345 : IF statement with no braces and double catch turned into syntax error by auto-fixer - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3352 : PSR2.ControlStructures.SwitchDeclaration can remove comments on the same line as the case statement while fixing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3357 : Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3362 : Generic.WhiteSpace.ScopeIndent false positive for arrow functions inside arrays - Fixed bug #3384 : Squiz.Commenting.FileComment.SpacingAfterComment false positive on empty file - Fixed bug #3394 : Fix PHP 8.1 auto_detect_line_endings deprecation notice - Fixed bug #3400 : PHP 8.1: prevent deprecation notices about missing return types - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3424 : PHPCS fails when using PHP 8 Constructor property promotion with attributes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3425 : PHP 8.1 | Runner::processChildProcs(): fix passing null to non-nullable bug - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3445 : Nullable parameter after attribute incorrectly tokenized as ternary operator - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.6.0] - 2021-04-09 ### Added - Added support for PHP 8.0 union types - A new T_TYPE_UNION token is available to represent the pipe character - File::getMethodParameters(), getMethodProperties(), and getMemberProperties() will now return union types - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added support for PHP 8.0 named function call arguments - A new T_PARAM_NAME token is available to represent the label with the name of the function argument in it - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added support for PHP 8.0 attributes - The PHP-supplied T_ATTRIBUTE token marks the start of an attribute - A new T_ATTRIBUTE_END token is available to mark the end of an attribute @@ -488,10 +488,10 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz.Commenting.ClassComment - Squiz.Commenting.FileComment - Squiz.WhiteSpace.FunctionSpacing - - Thanks to Vadim Borodavko for the patch - - Thanks to Alessandro Chitolina for the patch + - Thanks to [Vadim Borodavko][@javer] for the patch + - Thanks to [Alessandro Chitolina][@alekitto] for the patch - Added support for PHP 8.0 dereferencing of text strings with interpolated variables - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added support for PHP 8.0 match expressions - Match expressions are now tokenised with parenthesis and scope openers and closers - Sniffs can listen for the T_MATCH token to process match expressions @@ -502,7 +502,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The following sniffs have been updated to support match expressions: - Generic.CodeAnalysis.AssignmentInCondition - Generic.CodeAnalysis.EmptyPHPStatement - - Thanks to Vadim Borodavko for the patch + - Thanks to [Vadim Borodavko][@javer] for the patch - Generic.CodeAnalysis.EmptyStatement - Generic.PHP.LowerCaseKeyword - PEAR.ControlStructures.ControlSignature @@ -515,107 +515,107 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz.PHP.DisallowMultipleAssignments - Squiz.Objects.ObjectInstantiation - Squiz.WhiteSpace.ControlStructureSpacing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added Generic.NamingConventions.AbstractClassNamePrefix to enforce that class names are prefixed with "Abstract" - - Thanks to Anna Borzenko for the contribution + - Thanks to [Anna Borzenko][@annechko] for the contribution - Added Generic.NamingConventions.InterfaceNameSuffix to enforce that interface names are suffixed with "Interface" - - Thanks to Anna Borzenko for the contribution + - Thanks to [Anna Borzenko][@annechko] for the contribution - Added Generic.NamingConventions.TraitNameSuffix to enforce that trait names are suffixed with "Trait" - - Thanks to Anna Borzenko for the contribution + - Thanks to [Anna Borzenko][@annechko] for the contribution ### Changed - The value of the T_FN_ARROW token has changed from "T_FN_ARROW" to "PHPCS_T_FN_ARROW" to avoid package conflicts - This will have no impact on custom sniffs unless they are specifically looking at the value of the T_FN_ARROW constant - If sniffs are just using constant to find arrow functions, they will continue to work without modification - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - File::findStartOfStatement() now works correctly when passed the last token in a statement - File::getMethodParameters() now supports PHP 8.0 constructor property promotion - Returned method params now include a "property_visibility" and "visibility_token" index if property promotion is detected - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - File::getMethodProperties() now includes a "return_type_end_token" index in the return value - This indicates the last token in the return type, which is helpful when checking union types - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Include patterns are now ignored when processing STDIN - Previously, checks using include patterns were excluded when processing STDIN when no file path was provided via --stdin-path - Now, all include and exclude rules are ignored when no file path is provided, allowing all checks to run - If you want include and exclude rules enforced when checking STDIN, use --stdin-path to set the file path - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Spaces are now correctly escaped in the paths to external on Windows - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.CodeAnalysis.UnusedFunctionParameter can now be configured to ignore variable usage for specific type hints -- This allows you to suppress warnings for some variables that are not required, but leave warnings for others -- Set the ignoreTypeHints array property to a list of type hints to ignore - -- Thanks to Petr Bugyík for the patch + -- Thanks to [Petr Bugyík][@o5] for the patch - Generic.Formatting.MultipleStatementAlignment can now align statements at the start of the assignment token - Previously, the sniff enforced that the values were aligned, even if this meant the assignment tokens were not - Now, the sniff can enforce that the assignment tokens are aligned, even if this means the values are not - Set the "alignAtEnd" sniff property to "false" to align the assignment tokens - The default remains at "true", so the assigned values are aligned - - Thanks to John P. Bloch for the patch + - Thanks to [John P. Bloch][@johnpbloch] for the patch - Generic.PHP.LowerCaseType now supports checking of typed properties - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.PHP.LowerCaseType now supports checking of union types - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PEAR.Commenting.FunctionComment and Squiz.Commenting.FunctionComment sniffs can now ignore private and protected methods - Set the "minimumVisibility" sniff property to "protected" to ignore private methods - Set the "minimumVisibility" sniff property to "public" to ignore both private and protected methods - The default remains at "private", so all methods are checked - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - PEAR.Commenting.FunctionComment and Squiz.Commenting.FunctionComment sniffs can now ignore return tags in any method - Previously, only __construct and __destruct were ignored - Set the list of method names to ignore in the "specialMethods" sniff property - The default remains at "__construct" and "__destruct" only - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - PSR2.ControlStructures.SwitchDeclaration now supports nested switch statements where every branch terminates - Previously, if a CASE only contained a SWITCH and no direct terminating statement, a fall-through error was displayed - Now, the error is surpressed if every branch of the SWITCH has a terminating statement - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - The PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket error message is now reported on the closing parenthesis token - Previously, the error was being reported on the function keyword, leading to confusing line numbers in the error report - Squiz.Commenting.FunctionComment is now able to ignore function comments that are only inheritdoc statements - Set the skipIfInheritdoc sniff property to "true" to skip checking function comments if the content is only {@inhertidoc} - The default remains at "false", so these comments will continue to report errors - - Thanks to Jess Myrbo for the patch + - Thanks to [Jess Myrbo][@xjm] for the patch - Squiz.Commenting.FunctionComment now supports the PHP 8 mixed type - - Thanks to Vadim Borodavko for the patch + - Thanks to [Vadim Borodavko][@javer] for the patch - Squiz.PHP.NonExecutableCode now has improved handling of syntax errors - - Thanks to Thiemo Kreuz for the patch + - Thanks to [Thiemo Kreuz][@thiemowmde] for the patch - Squiz.WhiteSpace.ScopeKeywordSpacing now checks spacing when using PHP 8.0 constructor property promotion - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed -- Fixed an issue that could occurr when checking files on network drives, such as with WSL2 on Windows 10 +- Fixed an issue that could occur when checking files on network drives, such as with WSL2 on Windows 10 - This works around a long-standing PHP bug with is_readable() - - Thanks to Michael S for the patch + - Thanks to [Michael S][@codebymikey] for the patch - Fixed a number of false positives in the Squiz.PHP.DisallowMultipleAssignments sniff - Sniff no longer errors for default value assignments in arrow functions - Sniff no longer errors for assignments on first line of closure - Sniff no longer errors for assignments after a goto label - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Fixed bug #2913 : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional - Fixed bug #2992 : Enabling caching using a ruleset produces invalid cache files when using --sniffs and --exclude CLI args - Fixed bug #3003 : Squiz.Formatting.OperatorBracket autofix incorrect when assignment used with null coalescing operator - Fixed bug #3145 : Autoloading of sniff fails when multiple classes declared in same file - Fixed bug #3157 : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented - Fixed bug #3163 : Undefined index error with pre-commit hook using husky on PHP 7.4 - - Thanks to Ismo Vuorinen for the patch + - Thanks to [Ismo Vuorinen][@ivuorinen] for the patch - Fixed bug #3165 : Squiz.PHP.DisallowComparisonAssignment false positive when comparison inside closure - Fixed bug #3167 : Generic.WhiteSpace.ScopeIndent false positive when using PHP 8.0 constructor property promotion - Fixed bug #3170 : Squiz.WhiteSpace.OperatorSpacing false positive when using negation with string concat - This also fixes the same issue in the PSR12.Operators.OperatorSpacing sniff - Fixed bug #3177 : Incorrect tokenization of GOTO statements in mixed PHP/HTML files - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3184 : PSR2.Namespace.NamespaceDeclaration false positive on namespace operator - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3188 : Squiz.WhiteSpace.ScopeKeywordSpacing false positive for static return type - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3192 : findStartOfStatement doesn't work correctly inside switch - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - Fixed bug #3195 : Generic.WhiteSpace.ScopeIndent confusing message when combination of tabs and spaces found - Fixed bug #3197 : Squiz.NamingConventions.ValidVariableName does not use correct error code for all member vars - Fixed bug #3219 : Generic.Formatting.MultipleStatementAlignment false positive for empty anonymous classes and closures - Fixed bug #3258 : Squiz.Formatting.OperatorBracket duplicate error messages for unary minus - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3273 : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis - Fixed bug #3277 : Nullable static return typehint causes whitespace error - Fixed bug #3284 : Unused parameter false positive when using array index in arrow function @@ -629,24 +629,24 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Added - The PHP 8.0 T_NULLSAFE_OBJECT_OPERATOR token has been made available for older versions - Existing sniffs that check for T_OBJECT_OPERATOR have been modified to apply the same rules for the nullsafe object operator - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The new method of PHP 8.0 tokenizing for namespaced names has been revert to thr pre 8.0 method - This maintains backwards compatible for existing sniffs on PHP 8.0 - This change will be removed in PHPCS 4.0 as the PHP 8.0 tokenizing method will be backported for pre 8.0 versions - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added support for changes to the way PHP 8.0 tokenizes hash comments - The existing PHP 5-7 behaviour has been replicated for version 8, so no sniff changes are required - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Running the unit tests now includes warnings in the found and fixable error code counts - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PSR12.Functions.NullableTypeDeclaration now supports the PHP8 static return type - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Changed - The autoloader has been changed to fix sniff class name detection issues that may occur when running on PHP 7.4+ - - Thanks to Eloy Lafuente for the patch + - Thanks to [Eloy Lafuente][@stronk7] for the patch - PSR12.ControlStructures.BooleanOperatorPlacement.FoundMixed error message is now more accurate when using the allowOnly setting - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch ### Fixed - Fixed Squiz.Formatting.OperatorBracket false positive when exiting with a negative number @@ -655,92 +655,92 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #2883 : Generic.WhiteSpace.ScopeIndent.Incorrect issue after NOWDOC - Fixed bug #2975 : Undefined offset in PSR12.Functions.ReturnTypeDeclaration when checking function return type inside ternary - Fixed bug #2988 : Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding - - Thanks to Thiemo Kreuz for the patch + - Thanks to [Thiemo Kreuz][@thiemowmde] for the patch - Fixed bug #2989 : Incorrect auto-fixing in Generic.ControlStructures.InlineControlStructure during live coding - - Thanks to Thiemo Kreuz for the patch + - Thanks to [Thiemo Kreuz][@thiemowmde] for the patch - Fixed bug #3007 : Directory exclude pattern improperly excludes directories with names that start the same - - Thanks to Steve Talbot for the patch + - Thanks to [Steve Talbot][@SteveTalbot] for the patch - Fixed bug #3043 : Squiz.WhiteSpace.OperatorSpacing false positive for negation in arrow function - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3049 : Incorrect error with arrow function and parameter passed as reference - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3053 : PSR2 incorrect fix when multiple use statements on same line do not have whitespace between them - Fixed bug #3058 : Progress gets unaligned when 100% happens at the end of the available dots - Fixed bug #3059 : Squiz.Arrays.ArrayDeclaration false positive when using type casting - - Thanks to Sergei Morozov for the patch + - Thanks to [Sergei Morozov][@morozov] for the patch - Fixed bug #3060 : Squiz.Arrays.ArrayDeclaration false positive for static functions - - Thanks to Sergei Morozov for the patch + - Thanks to [Sergei Morozov][@morozov] for the patch - Fixed bug #3065 : Should not fix Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma if comment between element and comma - - Thanks to Sergei Morozov for the patch + - Thanks to [Sergei Morozov][@morozov] for the patch - Fixed bug #3066 : No support for namespace operator used in type declarations - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3075 : PSR12.ControlStructures.BooleanOperatorPlacement false positive when operator is the only content on line - Fixed bug #3099 : Squiz.WhiteSpace.OperatorSpacing false positive when exiting with negative number - - Thanks to Sergei Morozov for the patch + - Thanks to [Sergei Morozov][@morozov] for the patch - Fixed bug #3102 : PSR12.Squiz.OperatorSpacing false positive for default values of arrow functions - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #3124 : PSR-12 not reporting error for empty lines with only whitespace - Fixed bug #3135 : Ignore annotations are broken on PHP 8.0 - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.5.6] - 2020-08-10 ### Added - Added support for PHP 8.0 magic constant dereferencing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added support for changes to the way PHP 8.0 tokenizes comments - The existing PHP 5-7 behaviour has been replicated for version 8, so no sniff changes are required - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - `File::getMethodProperties()` now detects the PHP 8.0 static return type - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The PHP 8.0 static return type is now supported for arrow functions - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Changed - The cache is no longer used if the list of loaded PHP extensions changes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - `Generic.NamingConventions.CamelCapsFunctionName` no longer reports `__serialize` and `__unserialize` as invalid names - - Thanks to Filip Å  for the patch + - Thanks to [Filip Å][@filips123]  for the patch - `PEAR.NamingConventions.ValidFunctionName` no longer reports `__serialize` and `__unserialize` as invalid names - - Thanks to Filip Å  for the patch + - Thanks to [Filip Å][@filips123]  for the patch - `Squiz.Scope.StaticThisUsage` now detects usage of `$this` inside closures and arrow functions - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch ### Fixed - Fixed bug #2877 : PEAR.Functions.FunctionCallSignature false positive for array of functions - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - Fixed bug #2888 : PSR12.Files.FileHeader blank line error with multiple namespaces in one file - Fixed bug #2926 : phpcs hangs when using arrow functions that return heredoc - Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed - Fixed bug #2967 : Markdown generator does not output headings correctly - - Thanks to Petr Bugyík for the patch + - Thanks to [Petr Bugyík][@o5] for the patch - Fixed bug #2977 : File::isReference() does not detect return by reference for closures - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2994 : Generic.Formatting.DisallowMultipleStatements false positive for FOR loop with no body - Fixed bug #3033 : Error generated during tokenizing of goto statements on PHP 8 - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.5.5] - 2020-04-17 ### Changed - The T_FN backfill now works more reliably so T_FN tokens only ever represent real arrow functions - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed an issue where including sniffs using paths containing multiple dots would silently fail - Generic.CodeAnalysis.EmptyPHPStatement now detects empty statements at the start of control structures ### Fixed - Error wording in PEAR.Functions.FunctionCallSignature now always uses "parenthesis" instead of sometimes using "bracket" - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - Fixed bug #2787 : Squiz.PHP.DisallowMultipleAssignments not ignoring typed property declarations - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2810 : PHPCBF fails to fix file with empty statement at start on control structure - Fixed bug #2812 : Squiz.Arrays.ArrayDeclaration not detecting some arrays with multiple arguments on the same line - - Thanks to Jakub Chábek for the patch + - Thanks to [Jakub Chábek][@grongor] for the patch - Fixed bug #2826 : Generic.WhiteSpace.ArbitraryParenthesesSpacing doesn't detect issues for statements directly after a control structure - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - Fixed bug #2848 : PSR12.Files.FileHeader false positive for file with mixed PHP and HTML and no file header - Fixed bug #2849 : Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array - Fixed bug #2850 : Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase - Fixed bug #2853 : Undefined variable error when using Info report - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2865 : Double arrow tokenized as T_STRING when placed after function named "fn" - Fixed bug #2867 : Incorrect scope matching when arrow function used inside IF condition - Fixed bug #2868 : phpcs:ignore annotation doesnt work inside a docblock @@ -750,23 +750,23 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ## [3.5.4] - 2020-01-31 ### Changed - The PHP 7.4 numeric separator backfill now works correctly for more float formats - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The PHP 7.4 numeric separator backfill is no longer run on PHP version 7.4.0 or greater - File::getCondition() now accepts a 3rd argument that allows for the closest matching token to be returned - By default, it continues to return the first matched token found from the top of the file - Fixed detection of array return types for arrow functions - Added Generic.PHP.DisallowRequestSuperglobal to ban the use of the $_REQUEST superglobal - - Thanks to Morerice for the contribution + - Thanks to [Jeantwan Teuma][@Morerice] for the contribution - Generic.ControlStructures.InlineControlStructure no longer shows errors for WHILE and FOR statements without a body - Previously it required these to have curly braces, but there were no statements to enclose in them - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PSR12.ControlStructures.BooleanOperatorPlacement can now be configured to enforce a specific operator position - By default, the sniff ensures that operators are all at the begining or end of lines, but not a mix of both - Set the allowOnly property to "first" to enforce all boolean operators to be at the start of a line - Set the allowOnly property to "last" to enforce all boolean operators to be at the end of a line - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - PSR12.Files.ImportStatement now auto-fixes import statements by removing the leading slash - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Squiz.ControlStructures.ForLoopDeclaration now has a setting to ignore newline characters - Default remains FALSE, so newlines are not allowed within FOR definitions - Override the "ignoreNewlines" setting in a ruleset.xml file to change @@ -774,36 +774,36 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed bug #2497 : Sniff properties not set when referencing a sniff using relative paths or non-native slashes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2657 : Squiz.WhiteSpace.FunctionSpacing can remove spaces between comment and first/last method during auto-fixing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2688 : Case statements not tokenized correctly when switch is contained within ternary - Fixed bug #2698 : PHPCS throws errors determining auto report width when shell_exec is disabled - - Thanks to Matthew Peveler for the patch + - Thanks to [Matthew Peveler][@MasterOdin] for the patch - Fixed bug #2730 : PSR12.ControlStructures.ControlStructureSpacing does not ignore comments between conditions - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2732 : PSR12.Files.FileHeader misidentifies file header in mixed content file - Fixed bug #2745 : AbstractArraySniff wrong indices when mixed coalesce and ternary values - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Fixed bug #2748 : Wrong end of statement for fn closures - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Fixed bug #2751 : Autoload relative paths first to avoid confusion with files from the global include path - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Fixed bug #2763 : PSR12 standard reports errors for multi-line FOR definitions - Fixed bug #2768 : Generic.Files.LineLength false positive for non-breakable strings at exactly the soft limit - - Thanks to Alex Miles for the patch + - Thanks to [Alex Miles][@ghostal] for the patch - Fixed bug #2773 : PSR2.Methods.FunctionCallSignature false positive when arrow function has array return type - Fixed bug #2790 : PSR12.Traits.UseDeclaration ignores block comments - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - Fixed bug #2791 : PSR12.Functions.NullableTypeDeclaration false positive when ternary operator used with instanceof - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2802 : Can't specify a report file path using the tilde shortcut - Fixed bug #2804 : PHP4-style typed properties not tokenized correctly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2805 : Undefined Offset notice during live coding of arrow functions - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2843 : Tokenizer does not support alternative syntax for declare statements - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.5.3] - 2019-12-04 ### Changed @@ -813,7 +813,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The token after the statement (normally a semicolon) becomes the scope closer - The token is also associated with the opening and closing parenthesis of the statement - Any functions named "fn" will cause have a T_FN token for the function name, but have no scope information - - Thanks to MichaÅ‚ Bundyra for the help with this change + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the help with this change - PHP 7.4 numeric separators are now tokenized in the same way when using older PHP versions - Previously, a number like 1_000 would tokenize as T_LNUMBER (1), T_STRING (_000) - Now, the number tokenizes as T_LNUMBER (1_000) @@ -827,11 +827,11 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Useful when moving the start position of something like a closure, where you want the content to also move - Added Generic.Files.ExecutableFile sniff - Ensures that files are not executable - - Thanks to Matthew Peveler for the contribution + - Thanks to [Matthew Peveler][@MasterOdin] for the contribution - Generic.CodeAnalysis.EmptyPhpStatement now reports unnecessary semicolons after control structure closing braces - - Thanks to Vincent Langlet for the patch + - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - Generic.PHP.LowerCaseKeyword now enforces that the "fn" keyword is lowercase - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Generic.WhiteSpace.ScopeIndent now supports static arrow functions - PEAR.Functions.FunctionCallSignature now adjusts the indent of function argument contents during auto-fixing - Previously, only the first line of an argument was changed, leading to inconsistent indents @@ -839,27 +839,27 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - PSR2.ControlStructures.ControlStructureSpacing now checks whitespace before the closing parenthesis of multi-line control structures - Previously, it incorrectly applied the whitespace check for single-line definitions only - PSR12.Functions.ReturnTypeDeclaration now checks the return type of arrow functions - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - PSR12.Traits.UseDeclaration now ensures all trait import statements are grouped together - Previously, the trait import section of the class ended when the first non-import statement was found - Checking now continues throughout the class to ensure all statements are grouped together - This also ensures that empty lines are not requested after an import statement that isn't the last one - Squiz.Functions.LowercaseFunctionKeywords now enforces that the "fn" keyword is lowercase - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch ### Fixed - Fixed bug #2586 : Generic.WhiteSpace.ScopeIndent false positives when indenting open tags at a non tab-stop - Fixed bug #2638 : Squiz.CSS.DuplicateClassDefinitionSniff sees comments as part of the class name - - Thanks to Raphael Horber for the patch + - Thanks to [Raphael Horber][@rhorber] for the patch - Fixed bug #2640 : Squiz.WhiteSpace.OperatorSpacing false positives for some negation operators - - Thanks to Jakub Chábek and Juliette Reinders Folmer for the patch + - Thanks to [Jakub Chábek][@grongor] and [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2674 : Squiz.Functions.FunctionDeclarationArgumentSpacing prints wrong argument name in error message - Fixed bug #2676 : PSR12.Files.FileHeader locks up when file ends with multiple inline comments - Fixed bug #2678 : PSR12.Classes.AnonClassDeclaration incorrectly enforcing that closing brace be on a line by itself - Fixed bug #2685 : File::getMethodParameters() setting typeHintEndToken for vars with no type hint - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2694 : AbstractArraySniff produces invalid indices when using ternary operator - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Fixed bug #2702 : Generic.WhiteSpace.ScopeIndent false positive when using ternary operator with short arrays ## [3.5.2] - 2019-10-28 @@ -871,12 +871,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Also allows for better output for report types such as CSV and XML - The error message for PSR12.Files.FileHeader.SpacingAfterBlock has been made clearer - It now uses the wording from the published PSR-12 standard to indicate that blocks must be separated by a blank line - - Thanks to Craig Duncan for the patch + - Thanks to [Craig Duncan][@duncan3dc] for the patch ### Fixed - Fixed bug #2654 : Incorrect indentation for arguments of multiline function calls - Fixed bug #2656 : Squiz.WhiteSpace.MemberVarSpacing removes comments before first member var during auto fixing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2663 : Generic.NamingConventions.ConstructorName complains about old constructor in interfaces - Fixed bug #2664 : PSR12.Files.OpenTag incorrectly identifies PHP file with only an opening tag - Fixed bug #2665 : PSR12.Files.ImportStatement should not apply to traits @@ -905,7 +905,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #2616 : PSR12.Files.FileHeader false positive when file only contains docblock - Fixed bug #2619 : PSR12.Files.FileHeader locks up when inline comment is the last content in a file - Fixed bug #2621 : PSR12.Classes.AnonClassDeclaration.CloseBraceSameLine false positive for anon class passed as function argument - - Thanks to Martins Sipenko for the patch + - Thanks to [Martins Sipenko][@martinssipenko] for the patch - Fixed bug #2623 : PSR12.ControlStructures.ControlStructureSpacing not ignoring indentation inside multi-line string arguments - Fixed bug #2624 : PSR12.Traits.UseDeclaration doesnt apply the correct indent during auto fixing - Fixed bug #2626 : PSR12.Files.FileHeader detects @var annotations as file docblocks @@ -931,14 +931,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Added support for only checking files that have been locally staged in a git repo - Use --filter=gitstaged to check these files - You still need to give PHPCS a list of files or directories in which to apply the filter - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - JSON reports now end with a newline character - The phpcs.xsd schema now validates phpcs-only and phpcbf-only attributes correctly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The tokenizer now correctly identifies inline control structures in more cases - All helper methods inside the File class now throw RuntimeException instead of TokenizerException - Some tokenizer methods were also throwing RuntimeExpection but now correctly throw TokenizerException - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The File::getMethodParameters() method now returns more information, and supports closure USE groups - If a type hint is specified, the position of the last token in the hint will be set in a "type_hint_end_token" array index - If a default is specified, the position of the first token in the default value will be set in a "default_token" array index @@ -948,27 +948,27 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - If the param is variable length, the position of the variadic operator will be set in a "variadic_token" array index - The T_LIST token and it's opening and closing parentheses now contain references to each other in the tokens array - Uses the same parenthesis_opener/closer/owner indexes as other tokens - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The T_ANON_CLASS token and it's opening and closing parentheses now contain references to each other in the tokens array - Uses the same parenthesis_opener/closer/owner indexes as other tokens - Only applicable if the anon class is passing arguments to the constructor - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The PHP 7.4 T_BAD_CHARACTER token has been made available for older versions - Allows you to safely look for this token, but it will not appear unless checking with PHP 7.4+ - Metrics are now available for Squiz.WhiteSpace.FunctionSpacing - Use the "info" report to see blank lines before/after functions - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Metrics are now available for Squiz.WhiteSpace.MemberVarSpacing - Use the "info" report to see blank lines before member vars - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added Generic.ControlStructures.DisallowYodaConditions sniff - Ban the use of Yoda conditions - - Thanks to Mponos George for the contribution + - Thanks to [Mponos George][@gmponos] for the contribution - Added Generic.PHP.RequireStrictTypes sniff - Enforce the use of a strict types declaration in PHP files - Added Generic.WhiteSpace.SpreadOperatorSpacingAfter sniff - Checks whitespace between the spread operator and the variable/function call it applies to - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - Added PSR12.Classes.AnonClassDeclaration sniff - Enforces the formatting of anonymous classes - Added PSR12.Classes.ClosingBrace sniff @@ -1006,21 +1006,21 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - use Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter instead - This also changes the PEAR/PSR2/PSR12 standards so they no longer check assignment operators inside function calls - They were previously checking these operators when they should not have - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.WhiteSpace.ScopeIndent no longer performs exact indents checking for chained method calls - Other sniffs can be used to enforce chained method call indent rules - - Thanks to Pieter Frenssen for the patch + - Thanks to [Pieter Frenssen][@pfrenssen] for the patch - PEAR.WhiteSpace.ObjectOperatorIndent now supports multi-level chained statements - When enabled, chained calls must be indented 1 level more or less than the previous line - Set the new "multilevel" setting to TRUE in a ruleset.xml file to enable this behaviour - - Thanks to Marcos Passos for the patch + - Thanks to [Marcos Passos][@marcospassos] for the patch - PSR2.ControlStructures.ControlStructureSpacing now allows whitespace after the opening parenthesis if followed by a comment - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - PSR2.Classes.PropertyDeclaration now enforces a single space after a property type keyword - The PSR2 standard itself excludes this new check as it is not defined in the written standard - Using the PSR12 standard will enforce this check - Squiz.Commenting.BlockComment no longer requires blank line before comment if it's the first content after the PHP open tag - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Functions.FunctionDeclarationArgumentSpacing now has more accurate error messages - This includes renaming the SpaceAfterDefault error code to SpaceAfterEquals, which reflects the real error - Squiz.Functions.FunctionDeclarationArgumentSpacing now checks for no space after a reference operator @@ -1030,27 +1030,27 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz.Functions.MultiLineFunctionDeclaration now has improved fixing for the FirstParamSpacing and UseFirstParamSpacing errors - Squiz.Operators.IncrementDecrementUsage now suggests pre-increment of variables instead of post-increment - This change does not enforce pre-increment over post-increment; only the suggestion has changed - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.PHP.DisallowMultipleAssignments now has a second error code for when assignments are found inside control structure conditions - The new error code is Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure - All other multiple assignment cases use the existing error code Squiz.PHP.DisallowMultipleAssignments.Found - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.FunctionSpacing now applies beforeFirst and afterLast spacing rules to nested functions - Previously, these rules only applied to the first and last function in a class, interface, or trait - These rules now apply to functions nested in any statement block, including other functions and conditions - Squiz.WhiteSpace.OperatorSpacing now has improved handling of parse errors - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.OperatorSpacing now checks spacing around the instanceof operator - - Thanks to Jakub Chábek for the patch + - Thanks to [Jakub Chábek][@grongor] for the patch - Squiz.WhiteSpace.OperatorSpacing can now enforce a single space before assignment operators - Previously, the sniff this spacing as multiple assignment operators are sometimes aligned - Now, you can set the ignoreSpacingBeforeAssignments sniff property to FALSE to enable checking - Default remains TRUE, so spacing before assignments is not checked by default - - Thanks to Jakub Chábek for the patch + - Thanks to [Jakub Chábek][@grongor] for the patch ### Fixed - Fixed bug #2391 : Sniff-specific ignore rules inside rulesets are filtering out too many files - - Thanks to Juliette Reinders Folmer and Willington Vega for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] and [Willington Vega][@wvega] for the patch - Fixed bug #2478 : FunctionCommentThrowTag.WrongNumber when exception is thrown once but built conditionally - Fixed bug #2479 : Generic.WhiteSpace.ScopeIndent error when using array destructing with exact indent checking - Fixed bug #2498 : Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed autofix breaks heredoc @@ -1058,28 +1058,28 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #2504 : Generic.WhiteSpace.ScopeIndent false positives with nested arrays and nowdoc string - Fixed bug #2511 : PSR2 standard not checking if closing paren of single-line function declaration is on new line - Fixed bug #2512 : Squiz.PHP.NonExecutableCode does not support alternate SWITCH control structure - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2522 : Text generator throws error when code sample line is too long - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2526 : XML report format has bad syntax on Windows - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2529 : Generic.Formatting.MultipleStatementAlignment wrong error for assign in string concat - Fixed bug #2534 : Unresolvable installed_paths can lead to open_basedir errors - - Thanks to Oliver Nowak for the patch + - Thanks to [Oliver Nowak][@ndm2] for the patch - Fixed bug #2541 : Text doc generator does not allow for multi-line rule explanations - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2549 : Searching for a phpcs.xml file can throw warnings due to open_basedir restrictions - - Thanks to Matthew Peveler for the patch + - Thanks to [Matthew Peveler][@MasterOdin] for the patch - Fixed bug #2558 : PHP 7.4 throwing offset syntax with curly braces is deprecated message - - Thanks to Matthew Peveler for the patch + - Thanks to [Matthew Peveler][@MasterOdin] for the patch - Fixed bug #2561 : PHP 7.4 compatibility fix / implode argument order - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2562 : Inline WHILE triggers SpaceBeforeSemicolon incorrectly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2565 : Generic.ControlStructures.InlineControlStructure confused by mixed short/long tags - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2566 : Author tag email validation doesn't support all TLDs - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2575 : Custom error messages don't have data replaced when cache is enabled - Fixed bug #2601 : Squiz.WhiteSpace.FunctionSpacing incorrect fix when spacing is 0 - Fixed bug #2608 : PSR2 throws errors for use statements when multiple namespaces are defined in a file @@ -1097,7 +1097,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #2450 : Indentation false positive when closure containing nested IF conditions used as function argument - Fixed bug #2452 : LowercasePHPFunctions sniff failing on "new \File()" - Fixed bug #2453 : Squiz.CSS.SemicolonSpacingSniff false positive when style name proceeded by an asterisk - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2464 : Fixer conflict between Generic.WhiteSpace.ScopeIndent and Squiz.WhiteSpace.ScopeClosingBrace when class indented 1 space - Fixed bug #2465 : Excluding a sniff by path is not working - Fixed bug #2467 : PHP open/close tags inside CSS files are replaced with internal PHPCS token strings when auto fixing @@ -1108,30 +1108,30 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The code report was not previously available for PEAR installs - The Generic.Formatting.SpaceBeforeCast sniff was not previously available for PEAR installs - The Generic.WhiteSpace.LanguageConstructSpacing sniff was not previously available for PEAR installs - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PHPCS will now refuse to run if any of the required PHP extensions are not loaded - Previously, PHPCS only relied on requirements being checked by PEAR and Composer - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Ruleset XML parsing errors are now displayed in a readable format so they are easier to correct - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The PSR2 standard no longer throws duplicate errors for spacing around FOR loop parentheses - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - T_PHPCS_SET tokens now contain sniffCode, sniffProperty, and sniffPropertyValue indexes - Sniffs can use this information instead of having to parse the token content manually - Added more guard code for syntax errors to various CSS sniffs - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Commenting.DocComment error messages now contain the name of the comment tag that caused the error - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.ControlStructures.InlineControlStructure now handles syntax errors correctly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Debug.JSHint now longer requires rhino and can be run directly from the npm install - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Files.LineEndings no longer adds superfluous new line at the end of JS and CSS files - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Formatting.DisallowMultipleStatements no longer tries fix lines containing phpcs:ignore statements - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Functions.FunctionCallArgumentSpacing now has improved performance and anonymous class support - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.WhiteSpace.ScopeIndent now respects changes to the "exact" property using phpcs:set mid-way through a file - This allows you change the "exact" rule for only some parts of a file - Generic.WhiteSpace.ScopeIndent now disables exact indent checking inside all arrays @@ -1139,52 +1139,52 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - PEAR.Classes.ClassDeclaration now has improved handling of PHPCS annotations and tab indents - PSR12.Classes.ClassInstantiation has changed it's error code from MissingParenthesis to MissingParentheses - PSR12.Keywords.ShortFormTypeKeywords now ignores all spacing inside type casts during both checking and fixing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Classes.LowercaseClassKeywords now examines the class keyword for anonymous classes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.ControlStructures.ControlSignature now has improved handling of parse errors - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.PostStatementComment fixer no longer adds a blank line at the start of a JS file that begins with a comment - Fixes a conflict between this sniff and the Squiz.WhiteSpace.SuperfluousWhitespace sniff - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.PostStatementComment now ignores comments inside control structure conditions, such as FOR loops - Fixes a conflict between this sniff and the Squiz.ControlStructures.ForLoopDeclaration sniff - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.FunctionCommentThrowTag now has improved support for unknown exception types and namespaces - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.ControlStructures.ForLoopDeclaration has improved whitespace, closure, and empty expression support - The SpacingAfterSecondNoThird error code has been removed as part of these fixes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.CSS.ClassDefinitionOpeningBraceSpace now handles comments and indentation correctly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.CSS.ClassDefinitionClosingBrace now handles comments, indentation, and multiple statements on the same line correctly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.CSS.Opacity now handles comments correctly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.CSS.SemicolonSpacing now handles comments and syntax errors correctly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.NamingConventions.ValidVariableName now supports variables inside anonymous classes correctly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.PHP.LowercasePHPFunctions now handles use statements, namespaces, and comments correctly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.FunctionSpacing now fixes function spacing correctly when a function is the first content in a file - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.SuperfluousWhitespace no longer throws errors for spacing between functions and properties in anon classes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Zend.Files.ClosingTag no longer adds a semi-colon during fixing of a file that only contains a comment - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Zend.NamingConventions.ValidVariableName now supports variables inside anonymous classes correctly - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed - Fixed bug #2298 : PSR2.Classes.ClassDeclaration allows extended class on new line - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Fixed bug #2337 : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line function call starts on same line as open tag - Fixed bug #2348 : Cache not invalidated when changing a ruleset included by another - Fixed bug #2376 : Using __halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it's last in the function list - - Thanks to Sijun Zhu for the patch + - Thanks to [Sijun Zhu][@Billz95] for the patch - Fixed bug #2393 : The gitmodified filter will infinitely loop when encountering deleted file paths - - Thanks to Lucas Manzke for the patch + - Thanks to [Lucas Manzke][@lmanzke] for the patch - Fixed bug #2396 : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line IF condition mixed with HTML - Fixed bug #2431 : Use function/const not tokenized as T_STRING when preceded by comment @@ -1209,41 +1209,41 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Previously, the 'b' in 'b"some string with $var"' would be a T_BINARY_CAST, but only when the string contained a var - This change ensures the 'b' is always tokenized as T_BINARY_CAST - This change also converts '(binary)' from T_STRING_CAST to T_BINARY_CAST - - Thanks to Juliette Reinders Folmer for the help with this patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the help with this patch - Array properties set inside a ruleset.xml file can now extend a previous value instead of always overwriting it - e.g., if you include a ruleset that defines forbidden functions, can you now add to that list instead of having to redefine it - To use this feature, add extends="true" to the property tag - e.g., property name="forbiddenFunctionNames" type="array" extend="true" - - Thanks to Michael Moravec for the patch + - Thanks to [Michael Moravec][@Majkl578] for the patch - If $XDG_CACHE_HOME is set and points to a valid directory, it will be used for caching instead of the system temp directory - PHPCBF now disables parallel running if you are passing content on STDIN - Stops an error from being shown after the fixed output is printed - The progress report now shows files with tokenizer errors as skipped (S) instead of a warning (W) - The tokenizer error is still displayed in reports as normal - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The Squiz standard now ensures there is no space between an increment/decrement operator and its variable - The File::getMethodProperties() method now includes a has_body array index in the return value - FALSE if the method has no body (as with abstract and interface methods) or TRUE otherwise - - Thanks to Chris Wilkinson for the patch + - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - The File::getTokensAsString() method now throws an exception if the $start param is invalid - If the $length param is invalid, an empty string will be returned - Stops an infinite loop when the function is passed invalid data - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added new Generic.CodeAnalysis.EmptyPHPStatement sniff - Warns when it finds empty PHP open/close tag combinations or superfluous semicolons - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - Added new Generic.Formatting.SpaceBeforeCast sniff - Ensures there is exactly 1 space before a type cast, unless the cast statement is indented or multi-line - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - Added new Generic.VersionControl.GitMergeConflict sniff - Detects merge conflict artifacts left in files - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - Added Generic.WhiteSpace.IncrementDecrementSpacing sniff - Ensures there is no space between the operator and the variable it applies to - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - Added PSR12.Functions.NullableTypeDeclaration sniff - Ensures there is no space after the question mark in a nullable type declaration - - Thanks to Timo Schinkel for the contribution + - Thanks to [Timo Schinkel][@timoschinkel] for the contribution - A number of sniffs have improved support for methods in anonymous classes - These sniffs would often throw the same error twice for functions in nested classes - Error messages have also been changed to be less confusing @@ -1254,9 +1254,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - PSR2.Methods.MethodDeclaration - Squiz.Scope.MethodScope - Squiz.Scope.StaticThisUsage - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.CodeAnalysis.UnusedFunctionParameter now only skips functions with empty bodies when the class implements an interface - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.CodeAnalysis.UnusedFunctionParameter now has additional error codes to indicate where unused params were found - The new error code prefixes are: - FoundInExtendedClass: when the class extends another @@ -1276,133 +1276,133 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - FoundInImplementedInterfaceBeforeLastUsed - FoundInImplementedInterfaceAfterLastUsed - These errors code make it easier for specific cases to be ignored or promoted using a ruleset.xml file - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - Generic.Classes.DuplicateClassName now inspects traits for duplicate names as well as classes and interfaces - - Thanks to Chris Wilkinson for the patch + - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - Generic.Files.InlineHTML now ignores a BOM at the start of the file - - Thanks to Chris Wilkinson for the patch + - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - Generic.PHP.CharacterBeforePHPOpeningTag now ignores a BOM at the start of the file - - Thanks to Chris Wilkinson for the patch + - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - Generic.Formatting.SpaceAfterCast now has a setting to specify how many spaces are required after a type cast - Default remains 1 - Override the "spacing" setting in a ruleset.xml file to change - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Formatting.SpaceAfterCast now has a setting to ignore newline characters after a type cast - Default remains FALSE, so newlines are not allowed - Override the "ignoreNewlines" setting in a ruleset.xml file to change - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Formatting.SpaceAfterNot now has a setting to specify how many spaces are required after a NOT operator - Default remains 1 - Override the "spacing" setting in a ruleset.xml file to change - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Formatting.SpaceAfterNot now has a setting to ignore newline characters after the NOT operator - Default remains FALSE, so newlines are not allowed - Override the "ignoreNewlines" setting in a ruleset.xml file to change - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PEAR.Functions.FunctionDeclaration now checks spacing before the opening parenthesis of functions with no body - - Thanks to Chris Wilkinson for the patch + - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - PEAR.Functions.FunctionDeclaration now enforces no space before the semicolon in functions with no body - - Thanks to Chris Wilkinson for the patch + - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - PSR2.Classes.PropertyDeclaration now checks the order of property modifier keywords - This is a rule that is documented in PSR-2 but was not enforced by the included PSR2 standard until now - This sniff is also able to fix the order of the modifier keywords if they are incorrect - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PSR2.Methods.MethodDeclaration now checks method declarations inside traits - - Thanks to Chris Wilkinson for the patch + - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - Squiz.Commenting.InlineComment now has better detection of comment block boundaries - Squiz.Classes.ClassFileName now checks that a trait name matches the filename - - Thanks to Chris Wilkinson for the patch + - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - Squiz.Classes.SelfMemberReference now supports scoped declarations and anonymous classes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Classes.SelfMemberReference now fixes multiple errors at once, increasing fixer performance - - Thanks to Gabriel Ostrolucký for the patch + - Thanks to [Gabriel Ostrolucký][@ostrolucky] for the patch - Squiz.Functions.LowercaseFunctionKeywords now checks abstract and final prefixes, and auto-fixes errors - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Objects.ObjectMemberComma.Missing has been renamed to Squiz.Objects.ObjectMemberComma.Found - The error is thrown when the comma is found but not required, so the error code was incorrect - If you are referencing the old error code in a ruleset XML file, please use the new code instead - If you wish to maintain backwards compatibility, you can provide rules for both the old and new codes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.ObjectOperatorSpacing is now more tolerant of parse errors - Squiz.WhiteSpace.ObjectOperatorSpacing now fixes errors more efficiently - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed - Fixed bug #2109 : Generic.Functions.CallTimePassByReference false positive for bitwise and used in function argument - Fixed bug #2165 : Conflict between Squiz.Arrays.ArrayDeclaration and ScopeIndent sniffs when heredoc used in array - Fixed bug #2167 : Generic.WhiteSpace.ScopeIndent shows invalid error when scope opener indented inside inline HTML - Fixed bug #2178 : Generic.NamingConventions.ConstructorName matches methods in anon classes with same name as containing class - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2190 : PEAR.Functions.FunctionCallSignature incorrect error when encountering trailing PHPCS annotation - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2194 : Generic.Whitespace.LanguageConstructSpacing should not be checking namespace operators - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2202 : Squiz.WhiteSpace.OperatorSpacing throws error for negative index when using curly braces for string access - Same issue fixed in Squiz.Formatting.OperatorBracket - - Thanks to Andreas Buchenrieder for the patch + - Thanks to [Andreas Buchenrieder][@anbuc] for the patch - Fixed bug #2210 : Generic.NamingConventions.CamelCapsFunctionName not ignoring SoapClient __getCookies() method - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2211 : PSR2.Methods.MethodDeclaration gets confused over comments between modifier keywords - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2212 : FUNCTION and CONST in use groups being tokenised as T_FUNCTION and T_CONST - - Thanks to Chris Wilkinson for the patch + - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - Fixed bug #2214 : File::getMemberProperties() is recognizing method params as properties - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2236 : Memory info measurement unit is Mb but probably should be MB - Fixed bug #2246 : CSS tokenizer does not tokenize class names correctly when they contain the string NEW - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2278 : Squiz.Operators.ComparisonOperatorUsage false positive when inline IF contained in parentheses - - Thanks to Arnout Boks for the patch + - Thanks to [Arnout Boks][@aboks] for the patch - Fixed bug #2284 : Squiz.Functions.FunctionDeclarationArgumentSpacing removing type hint during fixing - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Fixed bug #2297 : Anonymous class not tokenized correctly when used as argument to another anon class - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch ## [2.9.2] - 2018-11-08 ### Changed - PHPCS should now run under PHP 7.3 without deprecation warnings - - Thanks to Nick Wilde for the patch + - Thanks to [Nick Wilde][@NickDickinsonWilde] for the patch ### Fixed - Fixed bug #1496 : Squiz.Strings.DoubleQuoteUsage not unescaping dollar sign when fixing - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Fixed bug #1549 : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1890 : Incorrect Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose error between catch and finally statements ## [3.3.2] - 2018-09-24 ### Changed - Fixed a problem where the report cache was not being cleared when the sniffs inside a standard were updated - The info report (--report=info) now has improved formatting for metrics that span multiple lines - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The unit test runner now skips .bak files when looking for test cases - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The Squiz standard now ensures underscores are not used to indicate visibility of private members vars and methods - Previously, this standard enforced the use of underscores - Generic.PHP.NoSilencedErrors error messages now contain a code snippet to show the context of the error - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Arrays.ArrayDeclaration no longer reports errors for a comma on a line new after a here/nowdoc - Also stops a parse error being generated when auto-fixing - The SpaceBeforeComma error message has been changed to only have one data value instead of two - Squiz.Commenting.FunctionComment no longer errors when trying to fix indents of multi-line param comments - Squiz.Formatting.OperatorBracket now correctly fixes statements that contain strings - Squiz.PHP.CommentedOutCode now ignores more @-style annotations and includes better comment block detection - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed - Fixed a problem where referencing a relative file path in a ruleset XML file could add unnecessary sniff exclusions - This didn't actually exclude anything, but caused verbose output to list strange exclusion rules - Fixed bug #2110 : Squiz.WhiteSpace.FunctionSpacing is removing indents from the start of functions when fixing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2115 : Squiz.Commenting.VariableComment not checking var types when the @var line contains a comment - Fixed bug #2120 : Tokenizer fails to match T_INLINE_ELSE when used after function call containing closure - Fixed bug #2121 : Squiz.PHP.DisallowMultipleAssignments false positive in while loop conditions - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2127 : File::findExtendedClassName() doesn't support nested classes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2138 : Tokenizer detects wrong token for php ::class feature with spaces - Fixed bug #2143 : PSR2.Namespaces.UseDeclaration does not properly fix "use function" and "use const" statements - - Thanks to Chris Wilkinson for the patch + - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - Fixed bug #2144 : Squiz.Arrays.ArrayDeclaration does incorrect align calculation in array with cyrillic keys - Fixed bug #2146 : Zend.Files.ClosingTag removes closing tag from end of file without inserting a semicolon - Fixed bug #2151 : XML schema not updated with the new array property syntax @@ -1410,30 +1410,30 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ## [3.3.1] - 2018-07-27 ### Removed - Support for HHVM has been dropped due to recent unfixed bugs and HHVM refocus on Hack only - - Thanks to Walt Sorensen and Juliette Reinders Folmer for helping to remove all HHVM exceptions from the core + - Thanks to [Walt Sorensen][@photodude] and [Juliette Reinders Folmer][@jrfnl] for helping to remove all HHVM exceptions from the core ### Changed - The full report (the default report) now has improved word wrapping for multi-line messages and sniff codes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The summary report now sorts files based on their directory location instead of just a basic string sort - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The source report now orders error codes by name when they have the same number of errors - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The junit report no longer generates validation errors with the Jenkins xUnit plugin - - Thanks to Nikolay Geo for the patch + - Thanks to [Nikolay Geo][@nicholascus] for the patch - Generic.Commenting.DocComment no longer generates the SpacingBeforeTags error if tags are the first content in the docblock - The sniff will still generate a MissingShort error if there is no short comment - This allows the MissingShort error to be suppressed in a ruleset to make short descriptions optional - Generic.Functions.FunctionCallArgumentSpacing now properly fixes multi-line function calls with leading commas - Previously, newlines between function arguments would be removed - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.PHP.Syntax will now use PHP_BINARY instead of trying to discover the executable path - This ensures that the sniff will always syntax check files using the PHP version that PHPCS is running under - Setting the php_path config var will still override this value as normal - - Thanks to Willem Stuursma-Ruwen for the patch + - Thanks to [Willem Stuursma-Ruwen][@willemstuursma] for the patch - PSR2.Namespaces.UseDeclaration now supports commas at the end of group use declarations - Also improves checking and fixing for use statements containing parse errors - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Arrays.ArrayDeclaration no longer removes the array opening brace while fixing - This could occur when the opening brace was on a new line and the first array key directly followed - This change also stops the KeyNotAligned error message being incorrectly reported in these cases @@ -1444,24 +1444,24 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The Squiz.Classes.ValidClassName.NotCamelCaps message now references PascalCase instead of CamelCase - The "CamelCase class name" metric produced by the sniff has been changed to "PascalCase class name" - This reflects the fact that the class name check is actually a Pascal Case check and not really Camel Case - - Thanks to Tom H Anderson for the patch + - Thanks to [Tom H Anderson][@TomHAnderson] for the patch - Squiz.Commenting.InlineComment no longer enforces spacing rules when an inline comment is followed by a docblock - Fixes a conflict between this sniff and the Squiz.WhiteSpace.FunctionSpacing sniff - Squiz.WhiteSpace.OperatorSpacing no longer tries to fix operator spacing if the next content is a comment on a new line - Fixes a conflict between this sniff and the Squiz.Commenting.PostStatementComment sniff - Also stops PHPCS annotations from being moved to a different line, potentially changing their meaning - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.FunctionSpacing no longer checks spacing of functions at the top of an embedded PHP block - Fixes a conflict between this sniff and the Squiz.PHP.EmbeddedPHP sniff - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.MemberVarSpacing no longer checks spacing before member vars that come directly after methods - Fixes a conflict between this sniff and the Squiz.WhiteSpace.FunctionSpacing sniff - Squiz.WhiteSpace.SuperfluousWhitespace now recognizes unicode whitespace at the start and end of a file - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed - Fixed bug #2029 : Squiz.Scope.MemberVarScope throws fatal error when a property is found in an interface - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2047 : PSR12.Classes.ClassInstantiation false positive when instantiating class from array index - Fixed bug #2048 : GenericFormatting.MultipleStatementAlignment false positive when assigning values inside an array - Fixed bug #2053 : PSR12.Classes.ClassInstantiation incorrectly fix when using member vars and some variable formats @@ -1477,12 +1477,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - As soon as possible, replace all instances of the old sniff code with the new sniff code in your ruleset.xml files - The existing Squiz sniff will continue to work until version 4 has been released - The new Generic sniff now also checks many more language constructs to enforce additional spacing rules - - Thanks to Mponos George for the contribution + - Thanks to [Mponos George][@gmponos] for the contribution - The current method for setting array properties in ruleset files has been deprecated and will be removed in version 4 - Currently, setting an array value uses the string syntax "print=>echo,create_function=>null" - Now, individual array elements are specified using a new "element" tag with "key" and "value" attributes - For example, element key="print" value="echo" - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - The T_ARRAY_HINT token has been deprecated and will be removed in version 4 - The token was used to ensure array type hints were not tokenized as T_ARRAY, but no other type hints were given a special token - Array type hints now use the standard T_STRING token instead @@ -1516,7 +1516,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Or, you can disable a specific sniff and have it re-enable when you re-enable the category or standard - The value of array sniff properties can now be set using phpcs:set annotations - e.g., phpcs:set Standard.Category.SniffName property[] key=>value,key2=>value2 - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - PHPCS annotations now remain as T_PHPCS_* tokens instead of reverting to comment tokens when --ignore-annotations is used - This stops sniffs (especially commenting sniffs) from generating a large number of false errors when ignoring - Any custom sniffs that are using the T_PHPCS_* tokens to detect annotations may need to be changed to ignore them @@ -1524,12 +1524,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - You can now use fully or partially qualified class names for custom reports instead of absolute file paths - To support this, you must specify an autoload file in your ruleset.xml file and use it to register an autoloader - Your autoloader will need to load your custom report class when requested - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The JSON report format now does escaping in error source codes as well as error messages - - Thanks to Martin Vasel for the patch + - Thanks to [Martin Vasel][@marvasDE] for the patch - Invalid installed_paths values are now ignored instead of causing a fatal error - Improved testability of custom rulesets by allowing the installed standards to be overridden - - Thanks to Timo Schinkel for the patch + - Thanks to [Timo Schinkel][@timoschinkel] for the patch - The key used for caching PHPCS runs now includes all set config values - This fixes a problem where changing config values (e.g., via --runtime-set) used an incorrect cache file - The "Function opening brace placement" metric has been separated into function and closure metrics in the info report @@ -1544,7 +1544,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The File::getMethodProperties() method now includes a return_type_token array index in the return value - Provides the position in the token stack of the first token in the return type - The File::getTokensAsString() method can now optionally return original (non tab-replaced) content - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Removed Squiz.PHP.DisallowObEndFlush from the Squiz standard - If you use this sniff and want to continue banning ob_end_flush(), use Generic.PHP.ForbiddenFunctions instead - You will need to set the forbiddenFunctions property in your ruleset.xml file @@ -1555,13 +1555,13 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Now, Generic.PHP.ForbiddenFunctions.Found and Generic.PHP.ForbiddenFunctions.FoundWithAlternative - Added new Generic.PHP.LowerCaseType sniff - Ensures PHP types used for type hints, return types, and type casting are lowercase - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - Added new Generic.WhiteSpace.ArbitraryParenthesesSpacing sniff - Generates an error for whitespace inside parenthesis that don't belong to a function call/declaration or control structure - Generates a warning for any empty parenthesis found - Allows the required spacing to be set using the spacing sniff property (default is 0) - Allows newlines to be used by setting the ignoreNewlines sniff property (default is false) - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - Added new PSR12.Classes.ClassInstantiation sniff - Ensures parenthesis are used when instantiating a new class - Added new PSR12.Keywords.ShortFormTypeKeywords sniff @@ -1573,19 +1573,19 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Ensures operators are preceded and followed by at least 1 space - Improved core support for grouped property declarations - Also improves support in Squiz.WhiteSpace.ScopeKeywordSpacing and Squiz.WhiteSpace.MemberVarSpacing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Commenting.DocComment now produces a NonParamGroup error when tags are mixed in with the @param tag group - It would previously throw either a NonParamGroup or ParamGroup error depending on the order of tags - This change allows the NonParamGroup error to be suppressed in a ruleset to allow the @param group to contain other tags - - Thanks to Phil Davis for the patch + - Thanks to [Phil Davis][@phil-davis] for the patch - Generic.Commenting.DocComment now continues checks param tags even if the doc comment short description is missing - This change allows the MissingShort error to be suppressed in a ruleset without all other errors being suppressed as well - - Thanks to Phil Davis for the patch + - Thanks to [Phil Davis][@phil-davis] for the patch - Generic.CodeAnalysis.AssignmentInCondition now reports a different error code for assignments found in WHILE conditions - The return value of a function call is often assigned in a WHILE condition, so this change makes it easier to exclude these cases - The new code for this error message is Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition - The error code for all other cases remains as Generic.CodeAnalysis.AssignmentInCondition.Found - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Functions.OpeningFunctionBraceBsdAllman now longer leaves trailing whitespace when moving the opening brace during fixing - Also applies to fixes made by PEAR.Functions.FunctionDeclaration and Squiz.Functions.MultiLineFunctionDeclaration - Generic.WhiteSpace.ScopeIndent now does a better job of fixing the indent of multi-line comments @@ -1601,15 +1601,15 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz.Arrays.ArrayDeclaration now continues checking array formatting even if the key indent is not correct - Allows for using different array indent rules while still checking/fixing double arrow and value alignment - Squiz.Commenting.BlockComment has improved support for tab-indented comments - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.BlockComment auto fixing no longer breaks when two block comments follow each other - Also stopped single-line block comments from being auto fixed when they are embedded in other code - Also fixed as issue found when PHPCS annotations were used inside a block comment - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.BlockComment.LastLineIndent is now able to be fixed with phpcbf - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.BlockComment now aligns star-prefixed lines under the opening tag while fixing, instead of indenting them - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.FunctionComment.IncorrectTypeHint message no longer contains cut-off suggested type hints - Squiz.Commenting.InlineComment now uses a new error code for inline comments at the end of a function - Previously, all inline comments followed by a blank line threw a Squiz.Commenting.InlineComment.SpacingAfter error @@ -1617,19 +1617,19 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - If you previously excluded SpacingAfter, add an exclusion for SpacingAfterAtFunctionEnd to your ruleset as well - If you previously only included SpacingAfter, consider including SpacingAfterAtFunctionEnd as well - The Squiz standard now excludes SpacingAfterAtFunctionEnd as the blank line is checked elsewhere - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.ControlStructures.ControlSignature now errors when a comment follows the closing brace of an earlier body - Applies to catch, finally, else, elseif, and do/while structures - The included PSR2 standard now enforces this rule - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Formatting.OperatorBracket.MissingBrackets message has been changed to remove the word "arithmetic" - The sniff checks more than just arithmetic operators, so the message is now clearer - Sniffs.Operators.ComparisonOperatorUsage now detects more cases of implicit true comparisons - It could previously be confused by comparisons used as function arguments - Squiz.PHP.CommentedOutCode now ignores simple @-style annotation comments so they are not flagged as commented out code - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.PHP.CommentedOutCode now ignores a greater number of short comments so they are not flagged as commented out code - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.PHP.DisallowComparisonAssignment no longer errors when using the null coalescing operator - Given this operator is used almost exclusively to assign values, it didn't make sense to generate an error - Squiz.WhiteSpacing.FunctionSpacing now has a property to specify how many blank lines should be before the first class method @@ -1649,20 +1649,20 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #1882 : Conditional with missing braces confused by indirect variables - Fixed bug #1915 : JS tokenizer fails to tokenize regular expression proceeded by boolean not operator - Fixed bug #1920 : Directory exclude pattern improperly excludes files with names that start the same - - Thanks to Jeff Puckett for the patch + - Thanks to [Jeff Puckett][@jpuck] for the patch - Fixed bug #1922 : Equal sign alignment check broken when list syntax used before assignment operator - Fixed bug #1925 : Generic.Formatting.MultipleStatementAlignment skipping assignments within closures - Fixed bug #1931 : Generic opening brace placement sniffs do not correctly support function return types - Fixed bug #1932 : Generic.ControlStructures.InlineControlStructure fixer moves new PHPCS annotations - Fixed bug #1938 : Generic opening brace placement sniffs incorrectly move PHPCS annotations - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1939 : phpcs:set annotations do not cause the line they are on to be ignored - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1949 : Squiz.PHP.DisallowMultipleAssignments false positive when using namespaces with static assignments - Fixed bug #1959 : SquizMultiLineFunctionDeclaration error when param has trailing comment - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1963 : Squiz.Scope.MemberVarScope does not work for multiline member declaration - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1971 : Short array list syntax not correctly tokenized if short array is the first content in a file - Fixed bug #1979 : Tokenizer does not change heredoc to nowdoc token if the start tag contains spaces - Fixed bug #1982 : Squiz.Arrays.ArrayDeclaration fixer sometimes puts a comma in front of the last array value @@ -1675,9 +1675,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - These used to contain 3 pieces of data, but now only contain 2 - If you have customised the error messages of this sniff, please review your ruleset after upgrading - Fixed bug #2018 : Generic.Formatting.MultipleStatementAlignment does see PHP close tag as end of statement block - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #2027 : PEAR.NamingConventions.ValidFunctionName error when function name includes double underscore - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.2.3] - 2018-02-21 ### Changed @@ -1687,33 +1687,33 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - This ensures that only cache files generated by the current PHP version are selected - This change fixes caching issues when using sniffs that produce errors based on the current PHP version - A new Tokens::$phpcsCommentTokens array is now available for sniff developers to detect phpcs: comment syntax - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The PEAR.Commenting.FunctionComment.Missing error message now includes the name of the function - - Thanks to Yorman Arias for the patch + - Thanks to [Yorman Arias][@cixtor] for the patch - The PEAR.Commenting.ClassComment.Missing and Squiz.Commenting.ClassComment.Missing error messages now include the name of the class - - Thanks to Yorman Arias for the patch + - Thanks to [Yorman Arias][@cixtor] for the patch - PEAR.Functions.FunctionCallSignature now only forces alignment at a specific tab stop while fixing - It was enforcing this during checking, but this meant invalid errors if the OpeningIndent message was being muted - This fixes incorrect errors when using the PSR2 standard with some code blocks - Generic.Files.LineLength now ignores lines that only contain phpcs: annotation comments - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Formatting.MultipleStatementAlignment now skips over arrays containing comments - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.PHP.Syntax now forces display_errors to ON when linting - - Thanks to Raúl Arellano for the patch + - Thanks to [Raúl Arellano][@raul338] for the patch - PSR2.Namespaces.UseDeclaration has improved syntax error handling and closure detection - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.PHP.CommentedOutCode now has improved comment block detection for improved accuracy - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.PHP.NonExecutableCode could fatal error while fixing file with syntax error - Squiz.PHP.NonExecutableCode now detects unreachable code after a goto statement - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.LanguageConstructSpacing has improved syntax error handling while fixing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Improved phpcs: annotation syntax handling for a number of sniffs - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Improved auto-fixing of files with incomplete comment blocks for various commenting sniffs - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed - Fixed test suite compatibility with PHPUnit 7 @@ -1721,17 +1721,17 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #1803 : Squiz.WhiteSpace.ScopeKeywordSpacing removes member var name while fixing if no space after scope keyword - Fixed bug #1817 : Blank line not enforced after control structure if comment on same line as closing brace - Fixed bug #1827 : A phpcs:enable comment is not tokenized correctly if it is outside a phpcs:disable block - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1828 : Squiz.WhiteSpace.SuperfluousWhiteSpace ignoreBlankLines property ignores whitespace after single line comments - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1840 : When a comment has too many asterisks, phpcbf gives FAILED TO FIX error - Fixed bug #1867 : Cant use phpcs:ignore where the next line is HTML - Fixed bug #1870 : Invalid warning in multiple assignments alignment with closure or anon class - Fixed bug #1890 : Incorrect Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose error between catch and finally statements - Fixed bug #1891 : Comment on last USE statement causes false positive for PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse - - Thanks to Matt Coleman, Daniel Hensby, and Juliette Reinders Folmer for the patch + - Thanks to [Matt Coleman][@iammattcoleman], [Daniel Hensby][@dhensby], and [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1901 : Fixed PHPCS annotations in multi-line tab-indented comments + not ignoring whole line for phpcs:set - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.2.2] - 2017-12-20 ### Changed @@ -1743,7 +1743,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Empty diffs are no longer followed by a newline character (request #1781) - Generic.Functions.OpeningFunctionBraceKernighanRitchie no longer complains when the open brace is followed by a close tag - This makes the sniff more useful when used in templates - - Thanks to Joseph Zidell for the patch + - Thanks to [Joseph Zidell][@josephzidell] for the patch ### Fixed - Fixed problems with some scripts and plugins waiting for STDIN @@ -1787,27 +1787,27 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The sniff does not support phpcs:ignore; you must wrap code structures with disable/enable comments - Previously, there was no way to have this sniff ignore parts of a file - Fixed a problem where PHPCS would sometimes hang waiting for STDIN, or read incomplete versions of large files - - Thanks to Arne Jørgensen for the patch + - Thanks to [Arne Jørgensen][@arnested] for the patch - Array properties specified in ruleset files now have their keys and values trimmed - This saves having to do this in individual sniffs and stops errors introduced by whitespace in rulesets - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added phpcs.xsd to allow validation of ruleset XML files - - Thanks to Renaat De Muynck for the contribution + - Thanks to [Renaat De Muynck][@renaatdemuynck] for the contribution - File paths specified using --stdin-path can now point to fake file locations (request #1488) - Previously, STDIN files using fake file paths were excluded from checking - Setting an empty basepath (--basepath=) on the CLI will now clear a basepath set directly in a ruleset - - Thanks to Xaver Loppenstedt for the patch + - Thanks to [Xaver Loppenstedt][@xalopp] for the patch - Ignore patterns are now checked on symlink target paths instead of symlink source paths - Restores previous behaviour of this feature - Metrics were being double counted when multiple sniffs were recording the same metric - Added support for bash process substitution - - Thanks to Scott Dutton for the contribution + - Thanks to [Scott Dutton][@exussum12] for the contribution - Files included in the cache file code hash are now sorted to aid in cache file reuse across servers - Windows BAT files can now be used outside a PEAR install - You must have the path to PHP set in your PATH environment variable - - Thanks to Joris Debonnet for the patch + - Thanks to [Joris Debonnet][@JorisDebonnet] for the patch - The JS unsigned right shift assignment operator is now properly classified as an assignment operator - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The AbstractVariableSniff abstract sniff now supports anonymous classes and nested functions - Also fixes an issue with Squiz.Scope.MemberVarScope where member vars of anonymous classes were not being checked - Added AbstractArraySniff to make it easier to create sniffs that check array formatting @@ -1817,33 +1817,33 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Also ensures the close brace is on a new line and indented to the same level as the original statement - Allows for the indent size to be set using an "indent" property of the sniff - Added Generic.PHP.DiscourageGoto to warn about the use of the GOTO language construct - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - Generic.Debug.ClosureLinter was not running the gjslint command - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Generic.WhiteSpace.DisallowSpaceIndent now fixes space indents in multi-line block comments - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.WhiteSpace.DisallowSpaceIndent now fixes mixed space/tab indents more accurately - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.WhiteSpace.DisallowTabIndent now fixes tab indents in multi-line block comments - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PEAR.Functions.FunctionDeclaration no longer errors when a function declaration is the first content in a JS file - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PEAR.Functions.FunctionCallSignature now requires the function name to be indented to an exact tab stop - If the function name is not the start of the statement, the opening statement must be indented correctly instead - Added a new fixable error code PEAR.Functions.FunctionCallSignature.OpeningIndent for this error - Squiz.Functions.FunctionDeclarationArgumentSpacing is no longer confused about comments in function declarations - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.PHP.NonExecutableCode error messages now indicate which line the code block ending is on - Makes it easier to identify where the code block exited or returned - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.FunctionComment now supports nullable type hints - Squiz.Commenting.FunctionCommentThrowTag no longer assigns throw tags inside anon classes to the enclosing function - Squiz.WhiteSpace.SemicolonSpacing now ignores semicolons used for empty statements inside FOR conditions - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.ControlStructures.ControlSignature now allows configuring the number of spaces before the colon in alternative syntax - Override the 'requiredSpacesBeforeColon' setting in a ruleset.xml file to change - Default remains at 1 - - Thanks to Nikola Kovacs for the patch + - Thanks to [Nikola Kovacs][@nkovacs] for the patch - The Squiz standard now ensures array keys are indented 4 spaces from the main statement - Previously, this standard aligned keys 1 space from the start of the array keyword - The Squiz standard now ensures array end braces are aligned with the main statement @@ -1851,12 +1851,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The standard for PHP_CodeSniffer itself now enforces short array syntax - The standard for PHP_CodeSniffer itself now uses the Generic.Arrays/ArrayIndent sniff rules - Improved fixer conflicts and syntax error handling for a number of sniffs - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed - Fixed bug #1462 : Error processing cyrillic strings in Tokenizer - Fixed bug #1573 : Squiz.WhiteSpace.LanguageConstructSpacing does not properly check for tabs and newlines - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Fixed bug #1590 : InlineControlStructure CBF issue while adding braces to an if thats returning a nested function - Fixed bug #1718 : Unclosed strings at EOF sometimes tokenized as T_WHITESPACE by the JS tokenizer - Fixed bug #1731 : Directory exclusions do not work as expected when a single file name is passed to phpcs @@ -1867,7 +1867,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #1758 : PHPCS gets stuck creating file list when processing circular symlinks - Fixed bug #1761 : Generic.WhiteSpace.ScopeIndent error on multi-line function call with static closure argument - Fixed bug #1762 : Generic.WhiteSpace.Disallow[Space/Tab]Indent not inspecting content before open tag - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1769 : Custom "define" function triggers a warning about declaring new symbols - Fixed bug #1776 : Squiz.Scope.StaticThisUsage incorrectly looking inside anon classes - Fixed bug #1777 : Generic.WhiteSpace.ScopeIndent incorrect indent errors when self called function proceeded by comment @@ -1876,28 +1876,28 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Changed - Restored preference of non-dist files over dist files for phpcs.xml and phpcs.xml.dist - The order that the files are searched is now: .phpcs.xml, phpcs.xml, .phpcs.xml.dist, phpcs.xml.dist - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Progress output now correctly shows skipped files - Progress output now shows 100% when the file list has finished processing (request #1697) - Stopped some IDEs complaining about testing class aliases - - Thanks to Vytautas Stankus for the patch + - Thanks to [Vytautas Stankus][@svycka] for the patch - Squiz.Commenting.InlineComment incorrectly identified comment blocks in some cases, muting some errors - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed - Fixed bug #1512 : PEAR.Functions.FunctionCallSignature enforces spaces when no arguments if required spaces is not 0 - Fixed bug #1522 : Squiz Arrays.ArrayDeclaration and Strings.ConcatenationSpacing fixers causing parse errors with here/ nowdocs - Fixed bug #1570 : Squiz.Arrays.ArrayDeclaration fixer removes comments between array keyword and open parentheses - Fixed bug #1604 : File::isReference has problems with some bitwise operators and class property references - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1645 : Squiz.Commenting.InlineComment will fail to fix comments at the end of the file - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1656 : Using the --sniffs argument has a problem with case sensitivity - Fixed bug #1657 : Uninitialized string offset: 0 when sniffing CSS - Fixed bug #1669 : Temporary expression proceeded by curly brace is detected as function call - Fixed bug #1681 : Huge arrays are super slow to scan with Squiz.Arrays.ArrayDeclaration sniff - Fixed bug #1694 : Squiz.Arrays.ArrayBracketSpacing is removing some comments during fixing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1702 : Generic.WhiteSpaceDisallowSpaceIndent fixer bug when line only contains superfluous whitespace ## [3.1.0] - 2017-09-20 @@ -1909,9 +1909,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - specify the PHP_CodeSniffer bootstrap file on the command line: phpunit --bootstrap=/path/to/phpcs/tests/bootstrap.php - require the PHP_CodeSniffer bootstrap file from your own bootstrap file - If you don't run PHP_CodeSniffer unit tests, this change will not affect you - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - A phpcs.xml or phpcs.xml.dist file now takes precedence over the default_standard config setting - - Thanks to Björn Fischer for the patch + - Thanks to [Björn Fischer][@Fischer-Bjoern] for the patch - Both phpcs.xml and phpcs.xml.dist files can now be prefixed with a dot (request #1566) - The order that the files are searched is: .phpcs.xml, .phpcs.xml.dist, phpcs.xml, phpcs.xml.dist - The autoloader will now search for files during unit tests runs from the same locations as during normal phpcs runs @@ -1926,21 +1926,21 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - PHPCS now cleanly exits if its config file is not readable - Previously, a combination of PHP notices and PHPCS errors would be generated - Comment tokens that start with /** are now always tokenized as docblocks - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - The PHP-supplied T_YIELD and T_YIELD_FROM token have been replicated for older PHP versions - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Added new Generic.CodeAnalysis.AssignmentInCondition sniff to warn about variable assignments inside conditions - - Thanks to Juliette Reinders Folmer for the contribution + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the contribution - Added Generic.Files.OneObjectStructurePerFile sniff to ensure there is a single class/interface/trait per file - - Thanks to Mponos George for the contribution + - Thanks to [Mponos George][@gmponos] for the contribution - Function call sniffs now check variable function names and self/static object creation - Specific sniffs are Generic.Functions.FunctionCallArgumentSpacing, PEAR.Functions.FunctionCallSignature, and PSR2.Methods.FunctionCallSignature - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Generic.Files.LineLength can now be configured to ignore all comment lines, no matter their length - Set the ignoreComments property to TRUE (default is FALSE) in your ruleset.xml file to enable this - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.PHP.LowerCaseKeyword now checks self, parent, yield, yield from, and closure (function) keywords - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - PEAR.Functions.FunctionDeclaration now removes a blank line if it creates one by moving the curly brace during fixing - Squiz.Commenting.FunctionCommentThrowTag now supports PHP 7.1 multi catch exceptions - Squiz.Formatting.OperatorBracket no longer throws errors for PHP 7.1 multi catch exceptions @@ -1948,19 +1948,19 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz.Formatting.OperatorBracket now correctly fixes pipe separated flags - Squiz.Formatting.OperatorBracket now correctly fixes statements containing short array syntax - Squiz.PHP.EmbeddedPhp now properly fixes cases where the only content in an embedded PHP block is a comment - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.ControlStructureSpacing now ignores comments when checking blank lines at the top of control structures - Squiz.WhiteSpace.ObjectOperatorSpacing now detects and fixes spaces around double colons - - Thanks to Julius Å mataviÄius for the patch + - Thanks to [Julius Å mataviÄius][@bondas83] for the patch - Squiz.WhiteSpace.MemberVarSpacing can now be configured to check any number of blank lines between member vars - Set the spacing property (default is 1) in your ruleset.xml file to set the spacing - Squiz.WhiteSpace.MemberVarSpacing can now be configured to check a different number of blank lines before the first member var - Set the spacingBeforeFirst property (default is 1) in your ruleset.xml file to set the spacing - Added a new PHP_CodeSniffer\Util\Tokens::$ooScopeTokens static member var for quickly checking object scope - Includes T_CLASS, T_ANON_CLASS, T_INTERFACE, and T_TRAIT - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PHP_CodeSniffer\Files\File::findExtendedClassName() now supports extended interfaces - - Thanks to Martin Hujer for the patch + - Thanks to [Martin Hujer][@mhujer] for the patch ### Fixed - Fixed bug #1550 : Squiz.Commenting.FunctionComment false positive when function contains closure @@ -1968,12 +1968,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #1581 : Sniffs not loaded when one-standard directories are being registered in installed_paths - Fixed bug #1591 : Autoloader failing to load arbitrary files when installed_paths only set via a custom ruleset - Fixed bug #1605 : Squiz.WhiteSpace.OperatorSpacing false positive on unary minus after comment - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1615 : Uncaught RuntimeException when phpcbf fails to fix files - Fixed bug #1637 : Generic.WhiteSpaceScopeIndent closure argument indenting incorrect with multi-line strings - Fixed bug #1638 : Squiz.WhiteSpace.ScopeClosingBrace closure argument indenting incorrect with multi-line strings - Fixed bug #1640 : Squiz.Strings.DoubleQuoteUsage replaces tabs with spaces when fixing - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.0.2] - 2017-07-18 ### Changed @@ -1984,9 +1984,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - If not, catch the new DeepExitException to get the error message ($e->getMessage()) and exit code ($e->getCode()); - NOWDOC tokens are now considered conditions, just as HEREDOC tokens are - This makes it easier to find the start and end of a NOWDOC from any token within it - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Custom autoloaders are now only included once in case multiple standards are using the same one - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Improved tokenizing of fallthrough CASE and DEFAULT statements that share a closing statement and use curly braces - Improved the error message when Squiz.ControlStructures.ControlSignature detects a newline after the closing parenthesis @@ -1996,16 +1996,16 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #1465 : Generic.WhiteSpace.ScopeIndent reports incorrect errors when indenting double arrows in short arrays - Fixed bug #1478 : Indentation in fallthrough CASE that contains a closure - Fixed bug #1497 : Fatal error if composer prepend-autoloader is set to false - - Thanks to Kunal Mehta for the patch + - Thanks to [Kunal Mehta][@legoktm] for the patch - Fixed bug #1503 : Alternative control structure syntax not always recognized as scoped - Fixed bug #1523 : Fatal error when using the --suffix argument - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1526 : Use of basepath setting can stop PHPCBF being able to write fixed files - Fixed bug #1530 : Generic.WhiteSpace.ScopeIndent can increase indent too much for lines within code blocks - Fixed bug #1547 : Wrong token type for backslash in use function - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Fixed bug #1549 : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1560 : Squiz.Commenting.FunctionComment fatal error when fixing additional param comment lines that have no indent ## [3.0.1] - 2017-06-14 @@ -2018,7 +2018,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - e.g., you allow external tool paths to be set by user-defined values - If you are unable to upgrade but you check 3rd-party code, ensure you are not using the Git modified filter - This advisory does not affect PHP_CodeSniffer version 2. - - Thanks to Sergei Morozov for the report and patch + - Thanks to [Sergei Morozov][@morozov] for the report and patch ### Changed - Arguments on the command line now override or merge with those specified in a ruleset.xml file in all cases @@ -2050,15 +2050,15 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #1447 : Running the unit tests with a phpunit config file breaks the test suite - Unknown arguments were not being handled correctly, but are now stored in $config->unknown - Fixed bug #1449 : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1450 : Coding standard located under an installed_path with the same directory name throws an error - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1451 : Sniff exclusions/restrictions dont work with custom sniffs unless they use the PHP_CodeSniffer NS - Fixed bug #1454 : Squiz.WhiteSpace.OperatorSpacing is not checking spacing on either side of a short ternary operator - - Thanks to Mponos George for the patch + - Thanks to [Mponos George][@gmponos] for the patch - Fixed bug #1495 : Setting an invalid installed path breaks all commands - Fixed bug #1496 : Squiz.Strings.DoubleQuoteUsage not unescaping dollar sign when fixing - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Fixed bug #1501 : Interactive mode is broken - Fixed bug #1504 : PSR2.Namespaces.UseDeclaration hangs fixing use statement with no trailing code @@ -2066,7 +2066,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed bug #1442 : T_NULLABLE detection not working for nullable parameters and return type hints in some cases - Fixed bug #1448 : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ## [3.0.0] - 2017-05-04 ### Changed @@ -2089,7 +2089,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed bug #834 : PSR2.ControlStructures.SwitchDeclaration does not handle if branches with returns - - Thanks to Fabian Wiget for the patch + - Thanks to [Fabian Wiget][@fabacino] for the patch ## [3.0.0RC4] - 2017-03-02 ### Security @@ -2110,7 +2110,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The Squiz.Debug.JSLint sniff - The Squiz.Debug.JavaScriptLint sniff - The Zend.Debug.CodeAnalyzer sniff - - Thanks to Klaus Purer for the report + - Thanks to [Klaus Purer][@klausi] for the report ### Changed - The indent property of PEAR.Classes.ClassDeclaration has been removed @@ -2211,7 +2211,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Use --filter=gitmodified to check these files - You still need to give PHPCS a list of files or directories in which to check - Added automatic discovery of executable paths (request #571) - - Thanks to Sergey Morozov for the patch + - Thanks to [Sergei Morozov][@morozov] for the patch - You must now pass "-" on the command line to have PHPCS wait for STDIN - E.g., phpcs --standard=PSR2 - - You can still pipe content via STDIN as normal as PHPCS will see this and process it @@ -2261,33 +2261,33 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Changed - Added Generic.Debug.ESLint sniff to run ESLint over JS files and report errors - Set eslint path using: phpcs --config-set eslint_path /path/to/eslint - - Thanks to Ryan McCue for the contribution + - Thanks to [Ryan McCue][@rmccue] for the contribution - T_POW is now properly considered an arithmetic operator, and will be checked as such - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - T_SPACESHIP and T_COALESCE are now properly considered comparison operators, and will be checked as such - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.PHP.DisallowShortOpenTag now warns about possible short open tags even when short_open_tag is set to OFF - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.WhiteSpace.DisallowTabIndent now finds and fixes improper use of spaces anywhere inside the line indent - Previously, only the first part of the indent was used to determine the indent type - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PEAR.Commenting.ClassComment now supports checking of traits as well as classes and interfaces - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.FunctionCommentThrowTag now supports re-throwing exceptions (request #946) - - Thanks to Samuel Levy for the patch + - Thanks to [Samuel Levy][@samlev] for the patch - Squiz.PHP.DisallowMultipleAssignments now ignores PHP4-style member var assignments - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.FunctionSpacing now ignores spacing above functions when they are preceded by inline comments - Stops conflicts between this sniff and comment spacing sniffs - Squiz.WhiteSpace.OperatorSpacing no longer checks the equal sign in declare statements - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added missing error codes for a couple of sniffs so they can now be customised as normal ### Fixed - Fixed bug #1266 : PEAR.WhiteSpace.ScopeClosingBrace can throw an error while fixing mixed PHP/HTML - Fixed bug #1364 : Yield From values are not recognised as returned values in Squiz FunctionComment sniff - Fixed bug #1373 : Error in tab expansion results in white-space of incorrect size - - Thanks to Mark Clements for the patch + - Thanks to [Mark Clements][@MarkMaldaba] for the patch - Fixed bug #1381 : Tokenizer: dereferencing incorrectly identified as short array - Fixed bug #1387 : Squiz.ControlStructures.ControlSignature does not handle alt syntax when checking space after closing brace - Fixed bug #1392 : Scope indent calculated incorrectly when using array destructuring @@ -2296,7 +2296,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #1405 : Squiz.WhiteSpace.ScopeClosingBrace fails to fix closing brace within indented PHP tags - Fixed bug #1421 : Ternaries used in constant scalar expression for param default misidentified by tokenizer - Fixed bug #1431 : PHPCBF can't fix short open tags when they are not followed by a space - - Thanks to Gonçalo Queirós for the patch + - Thanks to [Gonçalo Queirós][@ghunti] for the patch - Fixed bug #1432 : PHPCBF can make invalid fixes to inline JS control structures that make use of JS objects ## [2.8.1] - 2017-03-02 @@ -2318,7 +2318,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The Squiz.Debug.JSLint sniff - The Squiz.Debug.JavaScriptLint sniff - The Zend.Debug.CodeAnalyzer sniff - - Thanks to Klaus Purer for the report + - Thanks to [Klaus Purer][@klausi] for the report ### Changed - The PHP-supplied T_COALESCE_EQUAL token has been replicated for PHP versions before 7.2 @@ -2329,19 +2329,19 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz.Commenting.FunctionComment now corrects multi-line param comment padding more accurately - Squiz.Commenting.FunctionComment now properly fixes pipe-separated param types - Squiz.Commenting.FunctionComment now works correctly when function return types also contain a comment - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.ControlStructures.InlineIfDeclaration now supports the elvis operator - As this is not a real PHP operator, it enforces no spaces between ? and : when the THEN statement is empty - Squiz.ControlStructures.InlineIfDeclaration is now able to fix the spacing errors it reports ### Fixed - Fixed bug #1340 : STDIN file contents not being populated in some cases - - Thanks to David Biňovec for the patch + - Thanks to [David Biňovec][@david-binda] for the patch - Fixed bug #1344 : PEAR.Functions.FunctionCallSignatureSniff throws error for blank comment lines - Fixed bug #1347 : PSR2.Methods.FunctionCallSignature strips some comments during fixing - - Thanks to Algirdas Gurevicius for the patch + - Thanks to [Algirdas Gurevicius][@uniquexor] for the patch - Fixed bug #1349 : Squiz.Strings.DoubleQuoteUsage.NotRequired message is badly formatted when string contains a CR newline char - - Thanks to Algirdas Gurevicius for the patch + - Thanks to [Algirdas Gurevicius][@uniquexor] for the patch - Fixed bug #1350 : Invalid Squiz.Formatting.OperatorBracket error when using namespaces - Fixed bug #1369 : Empty line in multi-line function declaration cause infinite loop @@ -2350,57 +2350,57 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The Internal.NoCodeFound error is no longer generated for content sourced from STDIN - This should stop some Git hooks generating errors because PHPCS is trying to process the refs passed on STDIN - Squiz.Commenting.DocCommentAlignment now checks comments on class properties defined using the VAR keyword - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - The getMethodParameters() method now recognises "self" as a valid type hint - The return array now contains a new "content" index containing the raw content of the param definition - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The getMethodParameters() method now supports nullable types - The return array now contains a new "nullable_type" index set to true or false for each method param - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The getMethodParameters() method now supports closures - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added more guard code for JS files with syntax errors (request #1271 and request #1272) - Added more guard code for CSS files with syntax errors (request #1304) - PEAR.Commenting.FunctionComment fixers now correctly handle multi-line param comments - AbstractVariableSniff now supports anonymous classes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.NamingConventions.ConstructorName and PEAR.NamingConventions.ValidVariable now support anonymous classes - Generic.NamingConventions.CamelCapsFunctionName and PEAR.NamingConventions.ValidFunctionName now support anonymous classes - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.CodeAnalysis.UnusedFunctionParameter and PEAR.Functions.ValidDefaultValue now support closures - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PEAR.NamingConventions.ValidClassName and Squiz.Classes.ValidClassName now support traits - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Functions.FunctionCallArgumentSpacing now supports closures other PHP-provided functions - - Thanks to Algirdas Gurevicius for the patch + - Thanks to [Algirdas Gurevicius][@uniquexor] for the patch - Fixed an error where a nullable type character was detected as an inline then token - A new T_NULLABLE token has been added to represent the ? nullable type character - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Squiz.WhiteSpace.SemicolonSpacing no longer removes comments while fixing the placement of semicolons - - Thanks to Algirdas Gurevicius for the patch + - Thanks to [Algirdas Gurevicius][@uniquexor] for the patch ### Fixed - Fixed bug #1230 : JS tokeniser incorrectly tokenises bitwise shifts as comparison - - Thanks to Ryan McCue for the patch + - Thanks to [Ryan McCue][@rmccue] for the patch - Fixed bug #1237 : Uninitialized string offset in PHP Tokenizer on PHP 5.2 - Fixed bug #1239 : Warning when static method name is 'default' - Fixed bug #1240 : False positive for function names starting with triple underscore - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1245 : SELF is not recognised as T_SELF token in: return new self - Fixed bug #1246 : A mix of USE statements with and without braces can cause the tokenizer to mismatch brace tokens - - Thanks to MichaÅ‚ Bundyra for the patch + - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch - Fixed bug #1249 : GitBlame report requires a .git directory - Fixed bug #1252 : Squiz.Strings.ConcatenationSpacing fix creates syntax error when joining a number to a string - Fixed bug #1253 : Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch - Fixed bug #1255 : Inconsistent indentation check results when ELSE on new line - Fixed bug #1257 : Double dash in CSS class name can lead to "Named colours are forbidden" false positives - Fixed bug #1260 : Syntax errors not being shown when error_prepend_string is set - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug #1264 : Array return type hint is sometimes detected as T_ARRAY_HINT instead of T_RETURN_TYPE - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Fixed bug #1265 : ES6 arrow function raises unexpected operator spacing errors - Fixed bug #1267 : Fixer incorrectly handles filepaths with repeated dir names - - Thanks to Sergey Ovchinnikov for the patch + - Thanks to [Sergey Ovchinnikov][@orx0r] for the patch - Fixed bug #1276 : Commenting.FunctionComment.InvalidReturnVoid conditional issue with anonymous classes - Fixed bug #1277 : Squiz.PHP.DisallowMultipleAssignments.Found error when var assignment is on the same line as an open tag - Fixed bug #1284 : Squiz.Arrays.ArrayBracketSpacing.SpaceBeforeBracket false positive match for short list syntax @@ -2413,12 +2413,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed a problem where the content of T_DOC_COMMENT_CLOSE_TAG tokens could sometimes be (boolean) false - Developers of custom standards with custom test runners can now have their standards ignored by the built-in test runner - Set the value of an environment variable called PHPCS_IGNORE_TESTS with a comma separated list of your standard names - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The unit test runner now loads the test sniff outside of the standard's ruleset so that exclude rules do not get applied - This may have caused problems when testing custom sniffs inside custom standards - Also makes the unit tests runs a little faster - The SVN pre-commit hook now works correctly when installed via composer - - Thanks to Sergey for the patch + - Thanks to [Sergey][@sserbin] for the patch ### Fixed - Fixed bug #1135 : PEAR.ControlStructures.MultiLineCondition.CloseBracketNewLine not detected if preceded by multiline function call @@ -2426,12 +2426,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #1141 : Sniffs that check EOF newlines don't detect newlines properly when the last token is a doc block - Fixed bug #1150 : Squiz.Strings.EchoedStrings does not properly fix bracketed statements - Fixed bug #1156 : Generic.Formatting.DisallowMultipleStatements errors when multiple short echo tags are used on the same line - - Thanks to Nikola Kovacs for the patch + - Thanks to [Nikola Kovacs][@nkovacs] for the patch - Fixed bug #1161 : Absolute report path is treated like a relative path if it also exists within the current directory - Fixed bug #1170 : Javascript regular expression literal not recognized after comparison operator - Fixed bug #1180 : Class constant named FUNCTION is incorrectly tokenized - Fixed bug #1181 : Squiz.Operators.IncrementDecrementUsage.NoBrackets false positive when incrementing properties - - Thanks to Jürgen Henge-Ernst for the patch + - Thanks to [Jürgen Henge-Ernst][@hernst42] for the patch - Fixed bug #1188 : Generic.WhiteSpace.ScopeIndent issues with inline HTML and multi-line function signatures - Fixed bug #1190 : phpcbf on if/else with trailing comment generates erroneous code - Fixed bug #1191 : Javascript sniffer fails with function called "Function" @@ -2446,7 +2446,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Useful is you have a generated list of files to check that would be too long for the command line - File and directory paths are listed one per line - Usage is: phpcs --file-list=/path/to/file-list ... - - Thanks to Blotzu for the patch + - Thanks to [Blotzu][@andrei-propertyguru] for the patch - Values set using @codingStandardsChangeSetting comments can now contain spaces - Sniff unit tests can now specify a list of test files instead of letting the runner pick them (request #1078) - Useful if a sniff needs to exclude files based on the environment, or is checking filenames @@ -2458,49 +2458,49 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz.Commenting.LongConditionClosingComment now allows for the length of a code block to be configured - Set the lineLimit property (default is 20) in your ruleset.xml file to set the code block length - When the code block length is reached, the sniff will enforce a closing comment after the closing brace - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Commenting.LongConditionClosingComment now allows for the end comment format to be configured - Set the commentFormat property (default is "//end %s") in your ruleset.xml file to set the format - The placeholder %s will be replaced with the type of condition opener, e.g., "//end foreach" - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.PHPForbiddenFunctions now allows forbidden functions to have mixed case - Previously, it would only do a strtolower comparison - Error message now shows what case was found in the code and what the correct case should be - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added Generic.Classes.OpeningBraceSameLine to ensure opening brace of class/interface/trait is on the same line as the declaration - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added Generic.PHP.BacktickOperator to ban the use of the backtick operator for running shell commands - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added Generic.PHP.DisallowAlternativePHPTags to ban the use of alternate PHP tags - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.WhiteSpace.LanguageConstructSpacing no longer checks for spaces if parenthesis are being used (request #1062) - Makes this sniff more compatible with those that check parenthesis spacing of function calls - Squiz.WhiteSpace.ObjectOperatorSpacing now has a setting to ignore newline characters around object operators - Default remains FALSE, so newlines are not allowed - Override the "ignoreNewlines" setting in a ruleset.xml file to change - - Thanks to Alex Howansky for the patch + - Thanks to [Alex Howansky][@AlexHowansky] for the patch - Squiz.Scope.MethodScope now sniffs traits as well as classes and interfaces - - Thanks to Jesse Donat for the patch + - Thanks to [Jesse Donat][@donatj] for the patch - PHPCBF is now able to fix Squiz.SelfMemberReference.IncorrectCase errors - - Thanks to Nikola Kovacs for the patch + - Thanks to [Nikola Kovacs][@nkovacs] for the patch - PHPCBF is now able to fix Squiz.Commenting.VariableComment.IncorrectVarType - - Thanks to Walt Sorensen for the patch + - Thanks to [Walt Sorensen][@photodude] for the patch - PHPCBF is now able to fix Generic.PHP.DisallowShortOpenTag - - Thanks to Juliette Reinders Folmer for the patch + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Improved the formatting of the end brace when auto fixing InlineControlStructure errors (request #1121) - Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine fix no longer leaves blank line after brace (request #1085) - Generic UpperCaseConstantNameSniff now allows lowercase namespaces in constant definitions - - Thanks to Daniel Schniepp for the patch + - Thanks to [Daniel Schniepp][@dschniepp] for the patch - Squiz DoubleQuoteUsageSniff is now more tolerant of syntax errors caused by mismatched string tokens - A few sniffs that produce errors based on the current PHP version can now be told to run using a specific PHP version - Set the php_version config var using --config-set, --runtime-set, or in a ruleset to specify a specific PHP version - The format of the PHP version is the same as the PHP_VERSION_ID constant (e.g., 50403 for version 5.4.3) - Supported sniffs are Generic.PHP.DisallowAlternativePHPTags, PSR1.Classes.ClassDeclaration, Squiz.Commenting.FunctionComment - - Thanks to Finlay Beaton for the patch + - Thanks to [Finlay Beaton][@ofbeaton] for the patch ### Fixed - Fixed bug #985 : Duplicate class definition detection generates false-positives in media queries - - Thanks to Raphael Horber for the patch + - Thanks to [Raphael Horber][@rhorber] for the patch - Fixed bug #1014 : Squiz VariableCommentSniff doesn't always detect a missing comment - Fixed bug #1066 : Undefined index: quiet in CLI.php during unit test run with -v command line arg - Fixed bug #1072 : Squiz.SelfMemberReference.NotUsed not detected if leading namespace separator is used @@ -2510,14 +2510,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #1095 : Generic LineEndings sniff replaces tabs with spaces with --tab-width is set - Fixed bug #1096 : Squiz FunctionDeclarationArgumentSpacing gives incorrect error/fix when variadic operator is followed by a space - Fixed bug #1099 : Group use declarations are incorrectly fixed by the PSR2 standard - - Thanks to Jason McCreary for the patch + - Thanks to [Jason McCreary][@jasonmccreary] for the patch - Fixed bug #1101 : Incorrect indent errors when breaking out of PHP inside an IF statement - Fixed bug #1102 : Squiz.Formatting.OperatorBracket.MissingBrackets faulty bracketing fix - Fixed bug #1109 : Wrong scope indent reported in anonymous class - Fixed bug #1112 : File docblock not recognized when require_once follows it - Fixed bug #1120 : InlineControlStructureSniff does not handle auto-fixing for control structures that make function calls - Fixed bug #1124 : Squiz.Operators.ComparisonOperatorUsage does not detect bracketed conditions for inline IF statements - - Thanks to Raphael Horber for the patch + - Thanks to [Raphael Horber][@rhorber] for the patch ## [2.6.2] - 2016-07-14 ### Changed @@ -2530,7 +2530,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - A typical case is a comment that contains a very long URL - The comment is ignored if putting the URL on a indented new comment line would be longer than the allowed length - Settings extensions in a ruleset no longer causes PHP notices during unit testing - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Version control reports now show which errors are fixable if you are showing sources - Added a new sniff to enforce a single space after a NOT operator (request #1051) - Include in a ruleset using the code Generic.Formatting.SpaceAfterNot @@ -2542,7 +2542,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #945 : Incorrect indent behavior using deep-nested function and arrays - Fixed bug #961 : Two anonymous functions passed as function/method arguments cause indentation false positive - Fixed bug #1005 : Using global composer vendor autoload breaks PHP lowercase built-in function sniff - - Thanks to Michael Butler for the patch + - Thanks to [Michael Butler][@michaelbutler] for the patch - Fixed bug #1007 : Squiz Unreachable code detection is not working properly with a closure inside a case - Fixed bug #1023 : PSR2.Classes.ClassDeclaration fails if class extends base class and "implements" is on trailing line - Fixed bug #1026 : Arrays in comma delimited class properties cause ScopeIndent to increase indent @@ -2556,9 +2556,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Changed - The PHP-supplied T_COALESCE token has been replicated for PHP versions before 7.0 - Function return types of self, parent and callable are now tokenized as T_RETURN_TYPE - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - The default_standard config setting now allows multiple standards to be listed, like on the command line - - Thanks to Michael Mayer for the patch + - Thanks to [Michael Mayer][@schnittstabil] for the patch - Installations done via composer now only include the composer autoloader for PHP 5.3.2+ (request #942) - Added a rollbackChangeset() method to the Fixer class to purposely rollback the active changeset @@ -2568,19 +2568,19 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #944 : PHP warning when running the latest phar - Fixed bug #951 : InlineIfDeclaration: invalid error produced with UTF-8 string - Fixed bug #957 : Operator spacing sniff errors when plus is used as part of a number - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Fixed bug #959 : Call-time pass-by-reference false positive if there is a square bracket before the ampersand - - Thanks to Konstantin Leboev for the patch + - Thanks to [Konstantin Leboev][@realmfoo] for the patch - Fixed bug #962 : Null coalescing operator (??) not detected as a token - - Thanks to Joel Posti for the patch + - Thanks to [Joel Posti][@joelposti] for the patch - Fixed bug #973 : Anonymous class declaration and PSR1.Files.SideEffects.FoundWithSymbols - Fixed bug #974 : Error when file ends with "function" - Fixed bug #979 : Anonymous function with return type hint is not refactored as expected - Fixed bug #983 : Squiz.WhiteSpace.MemberVarSpacing.AfterComment fails to fix error when comment is not a docblock - Fixed bug #1010 : Squiz NonExecutableCode sniff does not detect boolean OR - - Thanks to Derek Henderson for the patch + - Thanks to [Derek Henderson][@2shediac] for the patch - Fixed bug #1015 : The Squiz.Commenting.FunctionComment sniff doesn't allow description in @return tag - - Thanks to Alexander Obuhovich for the patch + - Thanks to [Alexander Obuhovich][@aik099] for the patch - Fixed bug #1022 : Duplicate spaces after opening bracket error with PSR2 standard - Fixed bug #1025 : Syntax error in JS file can cause undefined index for parenthesis_closer @@ -2600,11 +2600,11 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - See the included JS and CSS tokenizers for an example - Config vars set in ruleset.xml files are now processed earlier, allowing them to be used during sniff registration - Among other things, this allows the installed_paths config var to be set in ruleset.xml files - - Thanks to Pieter Frenssen for the patch + - Thanks to [Pieter Frenssen][@pfrenssen] for the patch - Improved detection of regular expressions in the JS tokenizer - Generic PHP Syntax sniff now uses PHP_BINARY (if available) to determine the path to PHP if no other path is available - You can still manually set php_path to use a specific binary for testing - - Thanks to Andrew Berry for the patch + - Thanks to [Andrew Berry][@deviantintegral] for the patch - The PHP-supplied T_POW_EQUAL token has been replicated for PHP versions before 5.6 - Added support for PHP7 use group declarations (request #878) - New tokens T_OPEN_USE_GROUP and T_CLOSE_USE_GROUP are assigned to the open and close curly braces @@ -2614,7 +2614,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The PSR2 and Squiz standards now allow multi-line default values in function declarations (request #542) - Previously, these would automatically make the function a multi-line declaration - Squiz InlineCommentSniff now allows docblocks on require(_once) and include(_once) statements - - Thanks to Gary Jones for the patch + - Thanks to [Gary Jones][@GaryJones] for the patch - Squiz and PEAR Class and File sniffs no longer assume the first comment in a file is always a file comment - phpDocumentor assigns the comment to the file only if it is not followed by a structural element - These sniffs now follow this same rule @@ -2646,24 +2646,24 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #915 : JS Tokenizer generates errors when processing some decimals - Fixed bug #928 : Endless loop when sniffing a PHP file with a git merge conflict inside a function - Fixed bug #937 : Shebang can cause PSR1 SideEffects warning - - Thanks to Clay Loveless for the patch + - Thanks to [Clay Loveless][@claylo] for the patch - Fixed bug #938 : CallTimePassByReferenceSniff ignores functions with return value ## [2.5.1] - 2016-01-20 ### Changed - The PHP-supplied T_SPACESHIP token has been replicated for PHP versions before 7.0 - T_SPACESHIP is now correctly identified as an operator - - Thanks to Alexander Obuhovich for the patch + - Thanks to [Alexander Obuhovich][@aik099] for the patch - Generic LowerCaseKeyword now ensures array type hints are lowercase as well - - Thanks to Mathieu Rochette for the patch + - Thanks to [Mathieu Rochette][@mathroc] for the patch - Squiz ComparisonOperatorUsageSniff no longer hangs on JS FOR loops that don't use semicolons - PHP_CodesSniffer now includes the composer autoload.php file, if there is one - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Added error Squiz.Commenting.FunctionComment.ScalarTypeHintMissing for PHP7 only (request #858) - These errors were previously reported as Squiz.Commenting.FunctionComment.TypeHintMissing on PHP7 - Disable this error message in a ruleset.xml file if your code needs to run on both PHP5 and PHP7 - The PHP 5.6 __debugInfo magic method no longer produces naming convention errors - - Thanks to Michael Nowack for the patch + - Thanks to [Michael Nowack][@syranez] for the patch - PEAR and Squiz FunctionComment sniffs now support variadic functions (request #841) ### Fixed @@ -2677,21 +2677,21 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #829 : Short array argument not fixed correctly when multiple function arguments are on the same line - Fixed bug #831 : PHPCS freezes in an infinite loop under Windows if no standard is passed - Fixed bug #832 : Tokenizer does not support context sensitive parsing - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Fixed bug #835 : PEAR.Functions.FunctionCallSignature broken when closure uses return types - Fixed bug #838 : CSS indentation fixer changes color codes - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Fixed bug #839 : "__()" method is marked as not camel caps - - Thanks to Tim Bezhashvyly for the patch + - Thanks to [Tim Bezhashvyly][@tim-bezhashvyly] for the patch - Fixed bug #852 : Generic.Commenting.DocComment not finding errors when long description is omitted - Fixed bug #854 : Return typehints in interfaces are not reported as T_RETURN_TYPE - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Fixed bug #855 : Capital letter detection for multibyte strings doesn't work correctly - Fixed bug #857 : PSR2.ControlStructure.SwitchDeclaration shouldn't check indent of curly brace closers - Fixed bug #859 : Switch statement indention issue when returning function call with closure - Fixed bug #861 : Single-line arrays and function calls can generate incorrect indentation errors - Fixed bug #867 : Squiz.Strings.DoubleQuoteUsage broken for some escape codes - - Thanks to Jack Blower for the help with the fix + - Thanks to [Jack Blower][@ElvenSpellmaker] for the help with the fix - Fixed bug #21005 : Incorrect indent detection when multiple properties are initialized to arrays - Fixed bug #21010 : Incorrect missing colon detection in CSS when first style is not on new line - Fixed bug #21011 : Incorrect error message text when newline found after opening brace @@ -2708,10 +2708,10 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Added support for one or more bootstrap files to be run before processing begins - Use the --bootstrap=file,file,file command line argument to include bootstrap files - Useful if you want to override some of the high-level settings of PHPCS or PHPCBF - - Thanks to John Maguire for the patch + - Thanks to [John Maguire][@johnmaguire] for the patch - Added additional verbose output for CSS tokenizing - Squiz ComparisonOperatorUsageSniff now checks FOR, WHILE and DO-WHILE statements - - Thanks to Arnout Boks for the patch + - Thanks to [Arnout Boks][@aboks] for the patch ### Fixed - Fixed bug #660 : Syntax checks can fail on Windows with PHP5.6 @@ -2739,22 +2739,22 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - PEAR FunctionCallSignatureSniff now properly detects indents in more mixed HTML/PHP code blocks - Full report now properly indents lines when newlines are found inside error messages - Generating documentation without specifying a standard now uses the default standard instead - - Thanks to Ken Guest for the patch + - Thanks to [Ken Guest][@kenguest] for the patch - Generic InlineControlStructureSniff now supports braceless do/while loops in JS - - Thanks to Pieter Frenssen for the patch + - Thanks to [Pieter Frenssen][@pfrenssen] for the patch - Added more guard code for function declarations with syntax errors - Thanks to Yun Young-jin for the patch - Added more guard code for foreach declarations with syntax errors - - Thanks to Johan de Ruijter for the patch + - Thanks to [Johan de Ruijter][@johanderuijter] for the patch - Added more guard code for class declarations with syntax errors - Squiz ArrayDeclarationSniff now has guard code for arrays with syntax errors - Generic InlineControlStructureSniff now correctly fixes ELSEIF statements ### Fixed - Fixed bug #601 : Expected type hint int[]; found array in Squiz FunctionCommentSniff - - Thanks to Scato Eggen for the patch + - Thanks to [Scato Eggen][@scato] for the patch - Fixed bug #625 : Consider working around T_HASHBANG in HHVM 3.5.x and 3.6.x - - Thanks to Kunal Mehta for the patch + - Thanks to [Kunal Mehta][@legoktm] for the patch - Fixed bug #692 : Comment tokenizer can break when using mbstring function overloading - Fixed bug #694 : Long sniff codes can cause PHP warnings in source report when showing error codes - Fixed bug #698 : PSR2.Methods.FunctionCallSignature.Indent forces exact indent of ternary operator parameters @@ -2763,19 +2763,19 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #709 : Squiz.Sniffs.Whitespace.ScopeClosingBraceSniff marking indented endif in mixed inline HTML blocks - Fixed bug #711 : Sniffing from STDIN shows Generic.Files.LowercasedFilename.NotFound error - Fixed bug #714 : Fixes suppression of errors using docblocks - - Thanks to Andrzej Karmazyn for the patch + - Thanks to [Andrzej Karmazyn][@akarmazyn] for the patch - Fixed bug #716 : JSON report is invalid when messages contain newlines or tabs - - Thanks to Pieter Frenssen for the patch + - Thanks to [Pieter Frenssen][@pfrenssen] for the patch - Fixed bug #723 : ScopeIndent can fail when multiple array closers are on the same line - Fixed bug #730 : ScopeIndent can fail when a short array opening square bracket is on a line by itself - Fixed bug #732 : PHP Notice if @package name is made up of all invalid characters - Adds new error code PEAR.Commenting.FileComment.InvalidPackageValue - Fixed bug #748 : Auto fix for Squiz.Commenting.BlockComment.WrongEnd is incorrect - - Thanks to J.D. Grimes for the patch + - Thanks to [J.D. Grimes][@JDGrimes] for the patch - Fixed bug #753 : PSR2 standard shouldn't require space after USE block when next code is a closing tag - Fixed bug #768 : PEAR FunctionCallSignature sniff forbids comments after opening parenthesis of a multiline call - Fixed bug #769 : Incorrect detection of variable reference operator when used with short array syntax - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Fixed bug #772 : Syntax error when using PHPCBF on alternative style foreach loops - Fixed bug #773 : Syntax error when stripping trailing PHP close tag and previous statement has no semicolon - Fixed bug #778 : PHPCBF creates invalid PHP for inline FOREACH containing multiple control structures @@ -2789,13 +2789,13 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - JSON report format now includes the fixable status for each error message and the total number of fixable errors - Added more guard code for function declarations with syntax errors - Added tokenizer support for the PHP declare construct - - Thanks to Andy Blyler for the patch + - Thanks to [Andy Blyler][@ablyler] for the patch - Generic UnnecessaryStringConcatSniff can now allow strings concatenated over multiple lines - Set the allowMultiline property to TRUE (default is FALSE) in your ruleset.xml file to enable this - By default, concat used only for getting around line length limits still generates an error - - Thanks to Stefan Lenselink for the contribution + - Thanks to [Stefan Lenselink][@stefanlenselink] for the contribution - Invalid byte sequences no longer throw iconv_strlen() errors (request #639) - - Thanks to Willem Stuursma for the patch + - Thanks to [Willem Stuursma][@willemstuursma] for the patch - Generic TodoSniff and FixmeSniff are now better at processing strings with invalid characters - PEAR FunctionCallSignatureSniff now ignores indentation of inline HTML content - Squiz ControlSignatureSniff now supports control structures with only inline HTML content @@ -2804,17 +2804,17 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #636 : Some class names cause CSS tokenizer to hang - Fixed bug #638 : VCS blame reports output error content from the blame commands for files not under VC - Fixed bug #642 : Method params incorrectly detected when default value uses short array syntax - - Thanks to Josh Davis for the patch + - Thanks to [Josh Davis][@joshdavis11] for the patch - Fixed bug #644 : PEAR ScopeClosingBrace sniff does not work with mixed HTML/PHP - Fixed bug #645 : FunctionSignature and ScopeIndent sniffs don't detect indents correctly when PHP open tag is not on a line by itself - Fixed bug #648 : Namespace not tokenized correctly when followed by multiple use statements - Fixed bug #654 : Comments affect indent check for BSDAllman brace style - Fixed bug #658 : Squiz.Functions.FunctionDeclarationSpacing error for multi-line declarations with required spaces greater than zero - - Thanks to J.D. Grimes for the patch + - Thanks to [J.D. Grimes][@JDGrimes] for the patch - Fixed bug #663 : No space after class name generates: Class name "" is not in camel caps format - Fixed bug #667 : Scope indent check can go into infinite loop due to some parse errors - Fixed bug #670 : Endless loop in PSR1 SideEffects sniffer if no semicolon after last statement - - Thanks to Thomas Jarosch for the patch + - Thanks to [Thomas Jarosch][@thomasjfox] for the patch - Fixed bug #672 : Call-time pass-by-reference false positive - Fixed bug #683 : Comments are incorrectly reported by PSR2.ControlStructures.SwitchDeclaration sniff - Fixed bug #687 : ScopeIndent does not check indent correctly for method prefixes like public and abstract @@ -2823,12 +2823,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ## [2.3.3] - 2015-06-24 ### Changed - Improved the performance of the CSS tokenizer, especially on very large CSS files (thousands of lines) - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Defined tokens for lower PHP versions are now phpcs-specific strings instead of ints - Stops conflict with other projects, like PHP_CodeCoverage - Added more guard code for syntax errors to various sniffs - Improved support for older HHVM versions - - Thanks to Kunal Mehta for the patch + - Thanks to [Kunal Mehta][@legoktm] for the patch - Squiz ValidLogicalOperatorsSniff now ignores XOR as type casting is different when using the ^ operator (request #567) - Squiz CommentedOutCodeSniff is now better at ignoring URLs inside comments - Squiz ControlSignatureSniff is now better at checking embedded PHP code @@ -2840,7 +2840,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #592 : USE statement tokenising can sometimes result in mismatched scopes - Fixed bug #594 : Tokenizer issue on closure that returns by reference - Fixed bug #595 : Colons in CSS selectors within media queries throw false positives - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Fixed bug #598 : PHPCBF can break function/use closure brace placement - Fixed bug #603 : Squiz ControlSignatureSniff hard-codes opener type while fixing - Fixed bug #605 : Auto report-width specified in ruleset.xml ignored @@ -2858,7 +2858,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed bug #545 : Long list of CASE statements can cause tokenizer to reach a depth limit - Fixed bug #565 : Squiz.WhiteSpace.OperatorSpacing reports negative number in short array - - Thanks to VaÅ¡ek Purchart for the patch + - Thanks to [VaÅ¡ek Purchart][@VasekPurchart] for the patch - Same fix also applied to Squiz.Formatting.OperatorBracket - Fixed bug #569 : Generic ScopeIndentSniff throws PHP notices in JS files - Fixed bug #570 : Phar class fatals in PHP less than 5.3 @@ -2869,9 +2869,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Set the ignore_errors_on_exit config variable to 1 to set this behaviour - Use with the ignore_warnings_on_exit config variable to never return a non-zero exit code - Added Generic DisallowLongArraySyntaxSniff to enforce the use of the PHP short array syntax (request #483) - - Thanks to Xaver Loppenstedt for helping with tests + - Thanks to [Xaver Loppenstedt][@xalopp] for helping with tests - Added Generic DisallowShortArraySyntaxSniff to ban the use of the PHP short array syntax (request #483) - - Thanks to Xaver Loppenstedt for helping with tests + - Thanks to [Xaver Loppenstedt][@xalopp] for helping with tests - Generic ScopeIndentSniff no longer does exact checking for content inside parenthesis (request #528) - Only applies to custom coding standards that set the "exact" flag to TRUE - Squiz ConcatenationSpacingSniff now has a setting to ignore newline characters around operators (request #511) @@ -2898,12 +2898,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Changed - The existence of the main config file is now cached to reduce is_file() calls when it doesn't exist (request #486) - Abstract classes inside the Sniffs directory are now ignored even if they are named [Name]Sniff.php (request #476) - - Thanks to David Vernet for the patch + - Thanks to [David Vernet][@Decave] for the patch - PEAR and Squiz FileComment sniffs no longer have @ in their error codes - e.g., PEAR.Commenting.FileComment.Duplicate@categoryTag becomes PEAR.Commenting.FileComment.DuplicateCategoryTag - e.g., Squiz.Commenting.FileComment.Missing@categoryTag becomes Squiz.Commenting.FileComment.MissingCategoryTag - PEAR MultiLineConditionSniff now allows comment lines inside multi-line IF statement conditions - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Generic ForbiddenFunctionsSniff now supports setting null replacements in ruleset files (request #263) - Generic opening function brace sniffs now support checking of closures - Set the checkClosures property to TRUE (default is FALSE) in your ruleset.xml file to enable this @@ -2931,10 +2931,10 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #473 : Writing a report for an empty folder to existing file includes the existing contents - Fixed bug #485 : PHP notice in Squiz.Commenting.FunctionComment when checking malformed @throws comment - Fixed bug #491 : Generic InlineControlStructureSniff can correct with missing semicolon - - Thanks to Jesse Donat for the patch + - Thanks to [Jesse Donat][@donatj] for the patch - Fixed bug #492 : Use statements don't increase the scope indent - Fixed bug #493 : PSR1_Sniffs_Methods_CamelCapsMethodNameSniff false positives for some magic method detection - - Thanks to Andreas Möller for the patch + - Thanks to [Andreas Möller][@localheinz] for the patch - Fixed bug #496 : Closures in PSR2 are not checked for a space after the function keyword - Fixed bug #497 : Generic InlineControlStructureSniff does not support alternative SWITCH syntax - Fixed bug #500 : Functions not supported as values in Squiz ArrayDeclaration sniff @@ -2978,7 +2978,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - PEAR ObjectOperatorIndentSniff now only checks object operators at the start of a line - PEAR FileComment and ClassComment sniffs no longer have @ in their error codes - E.g., PEAR.Commenting.FileComment.Missing@categoryTag becomes PEAR.Commenting.FileComment.MissingCategoryTag - - Thanks to Grzegorz Rygielski for the patch + - Thanks to [Grzegorz Rygielski][@grzr] for the patch - Squiz ControlStructureSpacingSniff no longer enforces a blank line before CATCH statements - Squiz FunctionCommentSniff now fixes the return type in the @return tag (request #392) - Squiz BlockCommentSniff now only disallows lowercase letters at the start of the comment @@ -2988,7 +2988,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Override the "ignoreNewlines" setting in a ruleset.xml file to change - PSR2 ControlStructureSpacingSniff now checks for, and fixes, newlines after the opening parenthesis - Added a markdown document generator (--generator=markdown to use) - - Thanks to Stefano Kowalke for the contribution + - Thanks to [Stefano Kowalke][@Konafets] for the contribution ### Fixed - Fixed bug #379 : Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast incorrectly detects comments @@ -3036,7 +3036,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz standard now includes Generic EmptyStatementSniff and turns off the empty CATCH error - Squiz ControlSignatureSniff fixes now retain comments between the closing parenthesis and open brace - Squiz SuperfluousWhitespaceSniff now checks for extra blank lines inside closures - - Thanks to Sertan Danis for the patch + - Thanks to [Sertan Danis][@sertand] for the patch - Squiz ArrayDeclarationSniff now skips function calls while checking multi-line arrays ### Fixed @@ -3068,7 +3068,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Improved regular expression detection in the JS tokenizer - You can now get PHP_CodeSniffer to ignore a single line by putting @codingStandardsIgnoreLine in a comment - When the comment is found, the comment line and the following line will be ignored - - Thanks to Andy Bulford for the contribution + - Thanks to [Andy Bulford][@abulford] for the contribution - PHPCBF now prints output when it is changing into directories - Improved conflict detection during auto fixing - The -vvv command line argument will now output the current file content for each loop during fixing @@ -3094,15 +3094,15 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Changed - JS tokenizer now detects xor statements correctly - The --config-show command now pretty-prints the config values - - Thanks to Ken Guest for the patch + - Thanks to [Ken Guest][@kenguest] for the patch - Setting and removing config values now catches exceptions if the config file is not writable - - Thanks to Ken Guest for the patch + - Thanks to [Ken Guest][@kenguest] for the patch - Setting and removing config values now prints a message to confirm the action and show old values - You can now get PHP_CodeSniffer to ignore a single line by putting @codingStandardsIgnoreLine in a comment - When the comment is found, the comment line and the following line will be ignored - - Thanks to Andy Bulford for the contribution + - Thanks to [Andy Bulford][@abulford] for the contribution - Generic ConstructorNameSniff no longer errors for PHP4 style constructors when __construct() is present - - Thanks to Thibaud Fabre for the patch + - Thanks to [Thibaud Fabre][@fabre-thibaud] for the patch ### Fixed - Fixed bug #280 : The --config-show option generates error when there is no config file @@ -3128,7 +3128,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - File-wide sniff properties can now be set using T_INLINE_HTML content during unit test runs - Sniffs that start checking at the open tag can only, normally, have properties set using a ruleset - Generic ConstructorNameSniff no longer errors for PHP4 style constructors when __construct() is present - - Thanks to Thibaud Fabre for the patch + - Thanks to [Thibaud Fabre][@fabre-thibaud] for the patch - Generic DocCommentSniff now checks that the end comment tag is on a new line - Generic MultipleStatementAlignmentSniff no longer skips assignments for closures - Squiz DocCommentAlignment sniff now has better checking for single line doc block @@ -3151,9 +3151,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - See Generic ScopeIndentUnitTest.inc and ScopeIndentUnitTest.inc.fixed for an example - Fixer token replacement methods now return TRUE if the change was accepted and FALSE if rejected - The --config-show command now pretty-prints the config values - - Thanks to Ken Guest for the patch + - Thanks to [Ken Guest][@kenguest] for the patch - Setting and removing config values now catches exceptions if the config file is not writable - - Thanks to Ken Guest for the patch + - Thanks to [Ken Guest][@kenguest] for the patch - Setting and removing config values now prints a message to confirm the action and show old values - Generic ScopeIndentSniff has been completely rewritten to improve fixing and embedded PHP detection - Generic DisallowTabIndent and DisallowSpaceIndent sniffs now detect indents at the start of block comments @@ -3193,14 +3193,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Added conflict detection to the file fixer - If 2 sniffs look to be conflicting, one change will be ignored to allow a fix to occur - Generic CamelCapsFunctionNameSniff now ignores a single leading underscore - - Thanks to Alex Slobodiskiy for the patch + - Thanks to [Alex Slobodiskiy][@xt99] for the patch - Standards can now be located within hidden directories (further fix for bug #20323) - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Sniff ignore patterns now replace Win dir separators like file ignore patterns already did - Exclude patterns now use backtick delimiters, allowing all special characters to work correctly again - - Thanks to Jeremy Edgell for the patch + - Thanks to [Jeremy Edgell][@jedgell] for the patch - Errors converted to warnings in a ruleset (and vice versa) now retain their fixable status - - Thanks to Alexander Obuhovich for the patch + - Thanks to [Alexander Obuhovich][@aik099] for the patch - Squiz ConcatenationSpacingSniff now has a setting to specify how many spaces there should around concat operators - Default remains at 0 - Override the "spacing" setting in a ruleset.xml file to change @@ -3209,9 +3209,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz OperatorBracketSniff now correctly fixes operations that include arrays - Zend ClosingTagSniff fix now correctly leaves closing tags when followed by HTML - Added Generic SyntaxSniff to check for syntax errors in PHP files - - Thanks to Blaine Schmeisser for the contribution + - Thanks to [Blaine Schmeisser][@bayleedev] for the contribution - Added Generic OneTraitPerFileSniff to check that only one trait is defined in each file - - Thanks to Alexander Obuhovich for the contribution + - Thanks to [Alexander Obuhovich][@aik099] for the contribution - Squiz DiscouragedFunctionsSniff now warns about var_dump() - PEAR ValidFunctionNameSniff no longer throws an error for _() - Squiz and PEAR FunctionCommentSniffs now support _() @@ -3226,7 +3226,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #20377 : Error when trying to execute phpcs with report=json - Fixed bug #20378 : Report appended to existing file if no errors found in run - Fixed bug #20381 : Invalid "Comment closer must be on a new line" - - Thanks to Brad Kent for the patch + - Thanks to [Brad Kent][@bkdotcom] for the patch - Fixed bug #20402 : SVN pre-commit hook fails due to unknown argument error ## [1.5.5] - 2014-09-25 @@ -3236,11 +3236,11 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Improved closure support in Generic ScopeIndentSniff - Improved indented PHP tag support in Generic ScopeIndentSniff - Generic CamelCapsFunctionNameSniff now ignores a single leading underscore - - Thanks to Alex Slobodiskiy for the patch + - Thanks to [Alex Slobodiskiy][@xt99] for the patch - Standards can now be located within hidden directories (further fix for bug #20323) - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Added Generic SyntaxSniff to check for syntax errors in PHP files - - Thanks to Blaine Schmeisser for the contribution + - Thanks to [Blaine Schmeisser][@bayleedev] for the contribution - Squiz DiscouragedFunctionsSniff now warns about var_dump() - PEAR ValidFunctionNameSniff no longer throws an error for _() - Squiz and PEAR FunctionCommentSnif now support _() @@ -3252,7 +3252,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #20373 : Inline comment sniff tab handling way - Fixed bug #20378 : Report appended to existing file if no errors found in run - Fixed bug #20381 : Invalid "Comment closer must be on a new line" - - Thanks to Brad Kent for the patch + - Thanks to [Brad Kent][@bkdotcom] for the patch - Fixed bug #20386 : Squiz.Commenting.ClassComment.SpacingBefore thrown if first block comment ## [2.0.0RC1] - 2014-08-06 @@ -3262,12 +3262,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Added phpcbf.bat file for Windows - Verbose option no longer errors when using a phar file with a space in the path - Fixed a reporting error when using HHVM - - Thanks to Martins Sipenko for the patch + - Thanks to [Martins Sipenko][@martinssipenko] for the patch - addFixableError() and addFixableWarning() now only return true if the fixer is enabled - Saves checking ($phpcsFile->fixer->enabled === true) before every fix - Added addErrorOnLine() and addWarningOnLine() to add a non-fixable violation to a line at column 1 - Useful if you are generating errors using an external tool or parser and only know line numbers - - Thanks to OndÅ™ej Mirtes for the patch + - Thanks to [OndÅ™ej Mirtes][@ondrejmirtes] for the patch - CSS tokenizer now identifies embedded PHP code using the new T_EMBEDDED_PHP token type - The entire string of PHP is contained in a single token - PHP tokenizer contains better detection of short array syntax @@ -3289,26 +3289,26 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The rewrite allows this sniff to fix all control structure formatting issues it finds - The installed_paths config var now accepts relative paths - The paths are relative to the PHP_CodeSniffer install directory - - Thanks to Weston Ruter for the patch + - Thanks to [Weston Ruter][@westonruter] for the patch - Generic ScopeIndentSniff now accounts for different open tag indents - PEAR FunctionDeclarationSniff now ignores short arrays when checking indent - - Thanks to Daniel Tschinder for the patch + - Thanks to [Daniel Tschinder][@danez] for the patch - PSR2 FunctionCallSignatureSniff now treats multi-line strings as a single-line argument, like arrays and closures - - Thanks to Dawid Nowak for the patch + - Thanks to [Dawid Nowak][@MacDada] for the patch - PSR2 UseDeclarationSniff now checks for a single space after the USE keyword - Generic ForbiddenFunctionsSniff now detects calls to functions in the global namespace - - Thanks to Ole Martin Handeland for the patch + - Thanks to [Ole Martin Handeland][@olemartinorg] for the patch - Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore namespaces beginning with TRUE/FALSE/NULL - - Thanks to Renan Gonçalves for the patch + - Thanks to [Renan Gonçalves][@renan] for the patch - Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request #20299) - Squiz SelfMemberReferenceSniff now works correctly with namespaces - Squiz FunctionCommentSniff is now more relaxed when checking namespaced type hints - Tab characters are now encoded in abstract pattern errors messages - - Thanks to Blaine Schmeisser for the patch + - Thanks to [Blaine Schmeisser][@bayleedev] for the patch - Invalid sniff codes passed to --sniffs now show a friendly error message (request #20313) - Generic LineLengthSniff now shows a warning if the iconv module is disabled (request #20314) - Source report no longer shows errors if category or sniff names ends in an uppercase error - - Thanks to Jonathan Marcil for the patch + - Thanks to [Jonathan Marcil][@jmarcil] for the patch ### Fixed - Fixed bug #20261 : phpcbf has an endless fixing loop @@ -3329,24 +3329,24 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Removed use of sys_get_temp_dir() as this is not supported by the min PHP version - The installed_paths config var now accepts relative paths - The paths are relative to the PHP_CodeSniffer install directory - - Thanks to Weston Ruter for the patch + - Thanks to [Weston Ruter][@westonruter] for the patch - Generic ScopeIndentSniff now accounts for different open tag indents - PEAR FunctionDeclarationSniff now ignores short arrays when checking indent - - Thanks to Daniel Tschinder for the patch + - Thanks to [Daniel Tschinder][@danez] for the patch - PSR2 FunctionCallSignatureSniff now treats multi-line strings as a single-line argument, like arrays and closures - - Thanks to Dawid Nowak for the patch + - Thanks to [Dawid Nowak][@MacDada] for the patch - Generic ForbiddenFunctionsSniff now detects calls to functions in the global namespace - - Thanks to Ole Martin Handeland for the patch + - Thanks to [Ole Martin Handeland][@olemartinorg] for the patch - Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore namespaces beginning with TRUE/FALSE/NULL - - Thanks to Renan Gonçalves for the patch + - Thanks to [Renan Gonçalves][@renan] for the patch - Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request #20299) - Squiz SelfMemberReferenceSniff now works correctly with namespaces - Tab characters are now encoded in abstract pattern errors messages - - Thanks to Blaine Schmeisser for the patch + - Thanks to [Blaine Schmeisser][@bayleedev] for the patch - Invalid sniff codes passed to --sniffs now show a friendly error message (request #20313) - Generic LineLengthSniff now shows a warning if the iconv module is disabled (request #20314) - Source report no longer shows errors if category or sniff names ends in an uppercase error - - Thanks to Jonathan Marcil for the patch + - Thanks to [Jonathan Marcil][@jmarcil] for the patch ### Fixed - Fixed bug #20268 : Incorrect documentation titles in PEAR documentation @@ -3380,16 +3380,16 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz DoubleQuoteUsageSniff now properly replaces escaped double quotes when fixing a doubled quoted string - Improved detection of nested IF statements that use the alternate IF/ENDIF syntax - PSR1 CamelCapsMethodNameSniff now ignores magic methods - - Thanks to Eser Ozvataf for the patch + - Thanks to [Eser Ozvataf][@eser] for the patch - PSR1 SideEffectsSniff now ignores methods named define() - PSR1 and PEAR ClassDeclarationSniffs now support traits (request #20208) - PSR2 ControlStructureSpacingSniff now allows newlines before/after parentheses - - Thanks to Maurus Cuelenaere for the patch + - Thanks to [Maurus Cuelenaere][@mcuelenaere] for the patch - PSR2 ControlStructureSpacingSniff now checks TRY and CATCH statements - Squiz SuperfluousWhitespaceSniff now detects whitespace at the end of block comment lines - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Squiz LowercasePHPFunctionsSniff no longer reports errors for namespaced functions - - Thanks to Max Galbusera for the patch + - Thanks to [Max Galbusera][@maxgalbu] for the patch - Squiz SwitchDeclarationSniff now allows exit() as a breaking statement for case/default - Squiz ValidVariableNameSniff and Zend ValidVariableNameSniff now ignore additional PHP reserved vars - Thanks to Mikuláš DítÄ› and Adrian Crepaz for the patch @@ -3404,7 +3404,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #20234 : phpcbf patch command absolute paths - Fixed bug #20240 : Squiz block comment sniff fails when newline present - Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while - - Thanks to Alexander Obuhovich for the patch + - Thanks to [Alexander Obuhovich][@aik099] for the patch - Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope - Fixed bug #20252 : Unitialized string offset when package name starts with underscore @@ -3413,13 +3413,13 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Improved detection of nested IF statements that use the alternate IF/ENDIF syntax - PHP tokenizer now supports DEFAULT statements opened with a T_SEMICOLON - PSR1 CamelCapsMethodNameSniff now ignores magic methods - - Thanks to Eser Ozvataf for the patch + - Thanks to [Eser Ozvataf][@eser] for the patch - PSR1 SideEffectsSniff now ignores methods named define() - PSR1 and PEAR ClassDeclarationSniffs now support traits (request #20208) - PSR2 ControlStructureSpacingSniff now allows newlines before/after parentheses - - Thanks to Maurus Cuelenaere for the patch + - Thanks to [Maurus Cuelenaere][@mcuelenaere] for the patch - Squiz LowercasePHPFunctionsSniff no longer reports errors for namespaced functions - - Thanks to Max Galbusera for the patch + - Thanks to [Max Galbusera][@maxgalbu] for the patch - Squiz SwitchDeclarationSniff now allows exit() as a breaking statement for case/default - Squiz ValidVariableNameSniff and Zend ValidVariableNameSniff now ignore additional PHP reserved vars - Thanks to Mikuláš DítÄ› and Adrian Crepaz for the patch @@ -3433,7 +3433,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting - Fixed bug #20240 : Squiz block comment sniff fails when newline present - Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while - - Thanks to Alexander Obuhovich for the patch + - Thanks to [Alexander Obuhovich][@aik099] for the patch - Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope - Fixed bug #20252 : Uninitialized string offset when package name starts with underscore @@ -3477,7 +3477,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Added error Squiz.Commenting.ClassComment.SpacingAfter to ensure there are no blank lines after a class comment - Added error Squiz.WhiteSpace.MemberVarSpacing.AfterComment to ensure there are no blank lines after a member var comment - Fixes have also been corrected to not strip the member var comment or indent under some circumstances - - Thanks to Mark Scherer for help with this fix + - Thanks to [Mark Scherer][@dereuromark] for help with this fix - Added error Squiz.Commenting.FunctionCommentThrowTag.Missing to ensure a throw is documented - Removed error Squiz.Commenting.FunctionCommentThrowTag.WrongType - Content passed via STDIN can now specify the filename to use so that sniffs can run the correct filename checks @@ -3493,31 +3493,31 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Improved support for the PHP 5.5. classname::class syntax - PSR2 SwitchDeclarationSniff no longer throws errors when this syntax is used in CASE conditions - Improved support for negative checks of instanceOf in Squiz ComparisonOperatorUsageSniff - - Thanks to Martin Winkel for the patch + - Thanks to [Martin Winkel][@storeman] for the patch - Generic FunctionCallArgumentSpacingSniff now longer complains about space before comma when using here/nowdocs - - Thanks to Richard van Velzen for the patch + - Thanks to [Richard van Velzen][@rvanvelzen] for the patch - Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore class constants - - Thanks to Kristopher Wilson for the patch + - Thanks to [Kristopher Wilson][@mrkrstphr] for the patch - PEAR FunctionCallSignatureSniff now has settings to specify how many spaces should appear before/after parentheses - Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change - Default remains at 0 for both - - Thanks to Astinus Eberhard for the patch + - Thanks to [Astinus Eberhard][@Astinus-Eberhard] for the patch - PSR2 ControlStructureSpacingSniff now has settings to specify how many spaces should appear before/after parentheses - Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change - Default remains at 0 for both - - Thanks to Astinus Eberhard for the patch + - Thanks to [Astinus Eberhard][@Astinus-Eberhard] for the patch - Squiz ForEachLoopDeclarationSniff now has settings to specify how many spaces should appear before/after parentheses - Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change - Default remains at 0 for both - - Thanks to Astinus Eberhard for the patch + - Thanks to [Astinus Eberhard][@Astinus-Eberhard] for the patch - Squiz ForLoopDeclarationSniff now has settings to specify how many spaces should appear before/after parentheses - Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change - Default remains at 0 for both - - Thanks to Astinus Eberhard for the patch + - Thanks to [Astinus Eberhard][@Astinus-Eberhard] for the patch - Squiz FunctionDeclarationArgumentSpacingSniff now has settings to specify how many spaces should appear before/after parentheses - Override the 'requiredSpacesAfterOpen' and 'requiredSpacesBeforeClose' settings in a ruleset.xml file to change - Default remains at 0 for both - - Thanks to Astinus Eberhard for the patch + - Thanks to [Astinus Eberhard][@Astinus-Eberhard] for the patch - Removed UnusedFunctionParameter, CyclomaticComplexity and NestingLevel from the Squiz standard - Generic FixmeSniff and TodoSniff now work correctly with accented characters @@ -3531,11 +3531,11 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Changed - Config values can now be set at runtime using the command line argument [--runtime-set key value] - Runtime values are the same as config values, but are not written to the main config file - - Thanks to Wim Godden for the patch + - Thanks to [Wim Godden][@wimg] for the patch - Config values can now be set in ruleset files - e.g., config name="zend_ca_path" value="/path/to/ZendCodeAnalyzer" - Can not be used to set config values that override command line values, such as show_warnings - - Thanks to Jonathan Marcil for helping with the patch + - Thanks to [Jonathan Marcil][@jmarcil] for helping with the patch - Added a new installed_paths config value to allow for the setting of directories that contain standards - By default, standards have to be installed into the CodeSniffer/Standards directory to be considered installed - New config value allows a list of paths to be set in addition to this internal path @@ -3549,7 +3549,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed bug #20136 : Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff and Traits - Fixed bug #20138 : Protected property underscore and camel caps issue (in trait with Zend) - - Thanks to Gaetan Rousseau for the patch + - Thanks to [Gaetan Rousseau][@Naelyth] for the patch - Fixed bug #20139 : No report file generated on success ## [1.5.0] - 2013-11-28 @@ -3565,14 +3565,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Individual messages can now be excluded in ruleset.xml files using the exclude tag (request #20091) - Setting message severity to 0 continues to be supported - Squiz OperatorSpacingSniff no longer throws errors for the ?: short ternary operator - - Thanks to Antoine Musso for the patch + - Thanks to [Antoine Musso][@hashar] for the patch - Comment parser now supports non-English characters when splitting comment lines into words - - Thanks to Nik Sun for the patch + - Thanks to [Nik Sun][@CandySunPlus] for the patch - Exit statements are now recognised as valid closers for CASE and DEFAULT blocks - - Thanks to Maksim Kochkin for the patch + - Thanks to [Maksim Kochkin][@ksimka] for the patch - PHP_CodeSniffer_CLI::process() can now be passed an incomplete array of CLI values - Missing values will be set to the CLI defaults - - Thanks to Maksim Kochkin for the patch + - Thanks to [Maksim Kochkin][@ksimka] for the patch ### Fixed - Fixed bug #20093 : Bug with ternary operator token @@ -3590,14 +3590,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT" - PSR2 standard now ignores comments when checking indentation rules - Squiz OperatorSpacingSniff no longer throws errors for the ?: short ternary operator - - Thanks to Antoine Musso for the patch + - Thanks to [Antoine Musso][@hashar] for the patch - Comment parser now supports non-English characters when splitting comment lines into words - - Thanks to Nik Sun for the patch + - Thanks to [Nik Sun][@CandySunPlus] for the patch - Exit statements are now recognised as valid closers for CASE and DEFAULT blocks - - Thanks to Maksim Kochkin for the patch + - Thanks to [Maksim Kochkin][@ksimka] for the patch - PHP_CodeSniffer_CLI::process() can now be passed an incomplete array of CLI values - Missing values will be set to the CLI defaults - - Thanks to Maksim Kochkin for the patch + - Thanks to [Maksim Kochkin][@ksimka] for the patch ### Fixed - Fixed bug #20097 : CLI.php throws error in php 5.2 @@ -3617,31 +3617,31 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Doc generation is now working again - Progress information now shows the percentage complete at the end of each line - Added report type --report=junit to show the error list in a JUnit compatible format - - Thanks to Oleg Lobach for the contribution + - Thanks to [Oleg Lobach][@bladeofsteel] for the contribution - Added support for the PHP 5.4 callable type hint - Fixed problem where some file content could be ignored when checking STDIN - Version information is now printed when installed via composer or run from a Git clone (request #20050) - Added Squiz DisallowBooleanStatementSniff to ban boolean operators outside of control structure conditions - The CSS tokenizer is now more reliable when encountering 'list' and 'break' strings - Coding standard ignore comments can now appear instead doc blocks as well as inline comments - - Thanks to Stuart Langley for the patch + - Thanks to [Stuart Langley][@sjlangley] for the patch - Generic LineLengthSniff now ignores SVN URL and Head URL comments - - Thanks to Karl DeBisschop for the patch + - Thanks to [Karl DeBisschop][@kdebisschop] for the patch - PEAR MultiLineConditionSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - - Thanks to Szabolcs Sulik for the patch + - Thanks to [Szabolcs Sulik][@blerou] for the patch - PEAR MultiLineAssignmentSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - - Thanks to Szabolcs Sulik for the patch + - Thanks to [Szabolcs Sulik][@blerou] for the patch - PEAR FunctionDeclarationSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - - Thanks to Szabolcs Sulik for the patch + - Thanks to [Szabolcs Sulik][@blerou] for the patch - Squiz SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - - Thanks to Szabolcs Sulik for the patch + - Thanks to [Szabolcs Sulik][@blerou] for the patch - Squiz CSS IndentationSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - - Thanks to Hugo Fonseca for the patch + - Thanks to [Hugo Fonseca][@fonsecas72] for the patch - Squiz and MySource File and Function comment sniffs now allow all tags and don't require a particular licence - Squiz standard now allows lines to be 120 characters long before warning; up from 85 - Squiz LowercaseStyleDefinitionSniff no longer throws errors for class names in nested style definitions @@ -3650,7 +3650,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz CSS IndentationSniff no longer sees comments as blank lines - Squiz LogicalOperatorSpacingSniff now ignores whitespace at the end of a line - Squiz.Scope.MethodScope.Missing error message now mentions 'visibility' instead of 'scope modifier' - - Thanks to Renat Akhmedyanov for the patch + - Thanks to [Renat Akhmedyanov][@r3nat] for the patch - Added support for the PSR2 multi-line arguments errata - The PSR2 standard no longer throws errors for additional spacing after a type hint - PSR UseDeclarationSniff no longer throws errors for USE statements inside TRAITs @@ -3664,35 +3664,35 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #20044 : PSR1 camelCase check does not ignore leading underscores - Fixed bug #20045 : Errors about indentation for closures with multi-line 'use' in functions - Fixed bug #20051 : Undefined index: scope_opener / scope_closer - - Thanks to Anthon Pang for the patch + - Thanks to [Anthon Pang][@robocoder] for the patch ## [1.4.7] - 2013-09-26 ### Changed - Added report type --report=junit to show the error list in a JUnit compatible format - - Thanks to Oleg Lobach for the contribution + - Thanks to [Oleg Lobach][@bladeofsteel] for the contribution - Added support for the PHP 5.4 callable type hint - Fixed problem where some file content could be ignored when checking STDIN - Version information is now printed when installed via composer or run from a Git clone (request #20050) - The CSS tokenizer is now more reliable when encountering 'list' and 'break' strings - Coding standard ignore comments can now appear instead doc blocks as well as inline comments - - Thanks to Stuart Langley for the patch + - Thanks to [Stuart Langley][@sjlangley] for the patch - Generic LineLengthSniff now ignores SVN URL and Head URL comments - - Thanks to Karl DeBisschop for the patch + - Thanks to [Karl DeBisschop][@kdebisschop] for the patch - PEAR MultiLineConditionSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - - Thanks to Szabolcs Sulik for the patch + - Thanks to [Szabolcs Sulik][@blerou] for the patch - PEAR MultiLineAssignmentSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - - Thanks to Szabolcs Sulik for the patch + - Thanks to [Szabolcs Sulik][@blerou] for the patch - PEAR FunctionDeclarationSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - - Thanks to Szabolcs Sulik for the patch + - Thanks to [Szabolcs Sulik][@blerou] for the patch - Squiz SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - - Thanks to Szabolcs Sulik for the patch + - Thanks to [Szabolcs Sulik][@blerou] for the patch - Squiz CSS IndentationSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the 'indent' setting in a ruleset.xml file to change - - Thanks to Hugo Fonseca for the patch + - Thanks to [Hugo Fonseca][@fonsecas72] for the patch - Squiz and MySource File and Function comment sniffs now allow all tags and don't require a particular licence - Squiz LowercaseStyleDefinitionSniff no longer throws errors for class names in nested style definitions - Squiz ClassFileNameSniff no longer throws errors when checking STDIN @@ -3700,7 +3700,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz CSS IndentationSniff no longer sees comments as blank lines - Squiz LogicalOperatorSpacingSniff now ignores whitespace at the end of a line - Squiz.Scope.MethodScope.Missing error message now mentions 'visibility' instead of 'scope modifier' - - Thanks to Renat Akhmedyanov for the patch + - Thanks to [Renat Akhmedyanov][@r3nat] for the patch - Added support for the PSR2 multi-line arguments errata - The PSR2 standard no longer throws errors for additional spacing after a type hint - PSR UseDeclarationSniff no longer throws errors for USE statements inside TRAITs @@ -3716,7 +3716,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ## [1.5.0RC3] - 2013-07-25 ### Changed - Added report type --report=json to show the error list and total counts for all checked files - - Thanks to Jeffrey Fisher for the contribution + - Thanks to [Jeffrey Fisher][@jeffslofish] for the contribution - PHP_CodeSniffer::isCamelCaps now allows for acronyms at the start of a string if the strict flag is FALSE - acronyms are defined as at least 2 uppercase characters in a row - e.g., the following is now valid camel caps with strict set to FALSE: XMLParser @@ -3724,14 +3724,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The JS tokenizer now has support for the T_THROW token - Symlinked directories inside CodeSniffer/Standards and in ruleset.xml files are now supported - Only available since PHP 5.2.11 and 5.3.1 - - Thanks to Maik Penz for the patch + - Thanks to [Maik Penz][@goatherd] for the patch - The JS tokenizer now correctly identifies T_INLINE_ELSE tokens instead of leaving them as T_COLON - - Thanks to Arnout Boks for the patch + - Thanks to [Arnout Boks][@aboks] for the patch - Explaining a standard (phpcs -e) that uses namespaces now works correctly - Restricting a check to specific sniffs (phpcs --sniffs=...) now works correctly with namespaced sniffs - - Thanks to Maik Penz for the patch + - Thanks to [Maik Penz][@goatherd] for the patch - Docs added for the entire Generic standard, and many sniffs from other standards are now documented as well - - Thanks to Spencer Rinehart for the contribution + - Thanks to [Spencer Rinehart][@nubs] for the contribution - Clearer error message for when the sniff class name does not match the directory structure - Generated HTML docs now correctly show the open PHP tag in code comparison blocks - Added Generic InlineHTMLSniff to ensure a file only contains PHP code @@ -3743,9 +3743,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - PSR2 SwitchDeclarationSniff no longer reports errors for empty lines between CASE statements - PEAR ObjectOperatorIndentSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the indent setting in a ruleset.xml file to change - - Thanks to Andrey Mindubaev for the patch + - Thanks to [Andrey Mindubaev][@covex-nn] for the patch - Squiz FileExtensionSniff now supports traits - - Thanks to Lucas Green for the patch + - Thanks to [Lucas Green][@mythril] for the patch - Squiz ArrayDeclarationSniff no longer reports errors for no comma at the end of a line that contains a function call - Squiz SwitchDeclarationSniff now supports T_CONTINUE and T_THROW as valid case/default breaking statements - Squiz CommentedOutCodeSniff is now better at ignoring commented out HTML, XML and regular expressions @@ -3753,23 +3753,23 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz ColourDefinitionSniff no longer throws errors for some CSS class names - Squiz ControlStructureSpacingSniff now supports all types of CASE/DEFAULT breaking statements - Generic CallTimePassByReferenceSniff now reports errors for functions called using a variable - - Thanks to Maik Penz for the patch + - Thanks to [Maik Penz][@goatherd] for the patch - Generic ConstructorNameSniff no longer throws a notice for abstract constructors inside abstract classes - - Thanks to Spencer Rinehart for the patch + - Thanks to [Spencer Rinehart][@nubs] for the patch - Squiz ComparisonOperatorUsageSniff now checks inside elseif statements - - Thanks to Arnout Boks for the patch + - Thanks to [Arnout Boks][@aboks] for the patch - Squiz OperatorSpacingSniff now reports errors for no spacing around inline then and else tokens - - Thanks to Arnout Boks for the patch + - Thanks to [Arnout Boks][@aboks] for the patch ### Fixed - Fixed bug #19811 : Comments not ignored in all cases in AbstractPatternSniff - - Thanks to Erik Wiffin for the patch + - Thanks to [Erik Wiffin][@erikwiffin] for the patch - Fixed bug #19892 : ELSE with no braces causes incorrect SWITCH break statement indentation error - Fixed bug #19897 : Indenting warnings in templates not consistent - Fixed bug #19908 : PEAR MultiLineCondition Does Not Apply elseif - Fixed bug #19930 : option --report-file generate an empty file - Fixed bug #19935 : notify-send reports do not vanish in gnome-shell - - Thanks to Christian Weiske for the patch + - Thanks to [Christian Weiske][@cweiske] for the patch - Fixed bug #19944 : docblock squiz sniff "return void" trips over return in lambda function - Fixed bug #19953 : PSR2 - Spaces before interface name for abstract class - Fixed bug #19956 : phpcs warns for Type Hint missing Resource @@ -3781,18 +3781,18 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ## [1.4.6] - 2013-07-25 ### Changed - Added report type --report=json to show the error list and total counts for all checked files - - Thanks to Jeffrey Fisher for the contribution + - Thanks to [Jeffrey Fisher][@jeffslofish] for the contribution - The JS tokenizer now has support for the T_THROW token - Symlinked directories inside CodeSniffer/Standards and in ruleset.xml files are now supported - Only available since PHP 5.2.11 and 5.3.1 - - Thanks to Maik Penz for the patch + - Thanks to [Maik Penz][@goatherd] for the patch - The JS tokenizer now correctly identifies T_INLINE_ELSE tokens instead of leaving them as T_COLON - - Thanks to Arnout Boks for the patch + - Thanks to [Arnout Boks][@aboks] for the patch - Explaining a standard (phpcs -e) that uses namespaces now works correctly - Restricting a check to specific sniffs (phpcs --sniffs=...) now works correctly with namespaced sniffs - - Thanks to Maik Penz for the patch + - Thanks to [Maik Penz][@goatherd] for the patch - Docs added for the entire Generic standard, and many sniffs from other standards are now documented as well - - Thanks to Spencer Rinehart for the contribution + - Thanks to [Spencer Rinehart][@nubs] for the contribution - Clearer error message for when the sniff class name does not match the directory structure - Generated HTML docs now correctly show the open PHP tag in code comparison blocks - Added Generic InlineHTMLSniff to ensure a file only contains PHP code @@ -3804,9 +3804,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - PSR2 SwitchDeclarationSniff no longer reports errors for empty lines between CASE statements - PEAR ObjectOperatorIndentSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the indent setting in a ruleset.xml file to change - - Thanks to Andrey Mindubaev for the patch + - Thanks to [Andrey Mindubaev][@covex-nn] for the patch - Squiz FileExtensionSniff now supports traits - - Thanks to Lucas Green for the patch + - Thanks to [Lucas Green][@mythril] for the patch - Squiz ArrayDeclarationSniff no longer reports errors for no comma at the end of a line that contains a function call - Squiz SwitchDeclarationSniff now supports T_CONTINUE and T_THROW as valid case/default breaking statements - Squiz CommentedOutCodeSniff is now better at ignoring commented out HTML, XML and regular expressions @@ -3814,24 +3814,24 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz ColourDefinitionSniff no longer throws errors for some CSS class names - Squiz ControlStructureSpacingSniff now supports all types of CASE/DEFAULT breaking statements - Generic CallTimePassByReferenceSniff now reports errors for functions called using a variable - - Thanks to Maik Penz for the patch + - Thanks to [Maik Penz][@goatherd] for the patch - Generic ConstructorNameSniff no longer throws a notice for abstract constructors inside abstract classes - - Thanks to Spencer Rinehart for the patch + - Thanks to [Spencer Rinehart][@nubs] for the patch - Squiz ComparisonOperatorUsageSniff now checks inside elseif statements - - Thanks to Arnout Boks for the patch + - Thanks to [Arnout Boks][@aboks] for the patch - Squiz OperatorSpacingSniff now reports errors for no spacing around inline then and else tokens - - Thanks to Arnout Boks for the patch + - Thanks to [Arnout Boks][@aboks] for the patch ### Fixed - Fixed bug #19811 : Comments not ignored in all cases in AbstractPatternSniff - - Thanks to Erik Wiffin for the patch + - Thanks to [Erik Wiffin][@erikwiffin] for the patch - Fixed bug #19892 : ELSE with no braces causes incorrect SWITCH break statement indentation error - Fixed bug #19897 : Indenting warnings in templates not consistent - Fixed bug #19908 : PEAR MultiLineCondition Does Not Apply elseif - Fixed bug #19913 : Running phpcs in interactive mode causes warnings - - Thanks to Harald Franndorfer for the patch + - Thanks to [Harald Franndorfer][pear-gemineye] for the patch - Fixed bug #19935 : notify-send reports do not vanish in gnome-shell - - Thanks to Christian Weiske for the patch + - Thanks to [Christian Weiske][@cweiske] for the patch - Fixed bug #19944 : docblock squiz sniff "return void" trips over return in lambda function - Fixed bug #19953 : PSR2 - Spaces before interface name for abstract class - Fixed bug #19956 : phpcs warns for Type Hint missing Resource @@ -3864,16 +3864,16 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Generic EndFileNoNewlineSniff now supports checking of CSS and JS files - PSR2 SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the indent setting in a ruleset.xml file to change - - Thanks to Asher Snyder for the patch + - Thanks to [Asher Snyder][@asnyder] for the patch - Generic ScopeIndentSniff now has a setting to specify a list of tokens that should be ignored - The first token on the line is checked and the whole line is ignored if the token is in the array - - Thanks to Eloy Lafuente for the patch + - Thanks to [Eloy Lafuente][@stronk7] for the patch - Squiz LowercaseClassKeywordsSniff now checks for the TRAIT keyword - - Thanks to Anthon Pang for the patch + - Thanks to [Anthon Pang][@robocoder] for the patch - If you create your own PHP_CodeSniffer object, PHPCS will no longer exit when an unknown argument is found - This allows you to create wrapper scripts for PHPCS more easily - PSR2 MethodDeclarationSniff no longer generates a notice for methods named "_" - - Thanks to Bart S for the patch + - Thanks to [Bart S][@zBart] for the patch - Squiz BlockCommentSniff no longer reports that a blank line between a scope closer and block comment is invalid - Generic DuplicateClassNameSniff no longer reports an invalid error if multiple PHP open tags exist in a file - Generic DuplicateClassNameSniff no longer reports duplicate errors if multiple PHP open tags exist in a file @@ -3899,16 +3899,16 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Generic EndFileNoNewlineSniff now supports checking of CSS and JS files - PSR2 SwitchDeclarationSniff now has a setting to specify how many spaces code should be indented - Default remains at 4; override the indent setting in a ruleset.xml file to change - - Thanks to Asher Snyder for the patch + - Thanks to [Asher Snyder][@asnyder] for the patch - Generic ScopeIndentSniff now has a setting to specify a list of tokens that should be ignored - The first token on the line is checked and the whole line is ignored if the token is in the array - - Thanks to Eloy Lafuente for the patch + - Thanks to [Eloy Lafuente][@stronk7] for the patch - Squiz LowercaseClassKeywordsSniff now checks for the TRAIT keyword - - Thanks to Anthon Pang for the patch + - Thanks to [Anthon Pang][@robocoder] for the patch - If you create your own PHP_CodeSniffer object, PHPCS will no longer exit when an unknown argument is found - This allows you to create wrapper scripts for PHPCS more easily - PSR2 MethodDeclarationSniff no longer generates a notice for methods named "_" - - Thanks to Bart S for the patch + - Thanks to [Bart S][@zBart] for the patch - Squiz BlockCommentSniff no longer reports that a blank line between a scope closer and block comment is invalid - Generic DuplicateClassNameSniff no longer reports an invalid error if multiple PHP open tags exist in a file - Generic DuplicateClassNameSniff no longer reports duplicate errors if multiple PHP open tags exist in a file @@ -3932,23 +3932,23 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ## [1.4.4] - 2013-02-07 ### Changed - Ignored lines no longer cause the summary report to show incorrect error and warning counts - - Thanks to Bert Van Hauwaert for the patch + - Thanks to [Bert Van Hauwaert][@becoded] for the patch - Added Generic CSSLintSniff to run CSSLint over a CSS file and report warnings - Set full command to run CSSLint using phpcs --config-set csslint_path /path/to/csslint - - Thanks to Roman Levishchenko for the contribution + - Thanks to [Roman Levishchenko][@index0h] for the contribution - Added PSR2 ControlStructureSpacingSniff to ensure there are no spaces before and after parenthesis in control structures - Fixes bug #19732 : PSR2: some control structures errors not reported - Squiz commenting sniffs now support non-English characters when checking for capital letters - - Thanks to Roman Levishchenko for the patch + - Thanks to [Roman Levishchenko][@index0h] for the patch - Generic EndFileNewlineSniff now supports JS and CSS files - - Thanks to Denis Ryabkov for the patch + - Thanks to [Denis Ryabkov][@dryabkov] for the patch - PSR1 SideEffectsSniff no longer reports constant declarations as side effects - Notifysend report now supports notify-send versions before 0.7.3 - - Thanks to Ken Guest for the patch + - Thanks to [Ken Guest][@kenguest] for the patch - PEAR and Squiz FunctionCommentSniffs no longer report errors for misaligned argument comments when they are blank - - Thanks to Thomas Peterson for the patch + - Thanks to [Thomas Peterson][@boonkerz] for the patch - Squiz FunctionDeclarationArgumentSpacingSniff now works correctly for equalsSpacing values greater than 0 - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Squiz SuperfluousWhitespaceSniff no longer throws errors for CSS files with no newline at the end - Squiz SuperfluousWhitespaceSniff now allows a single newline at the end of JS and CSS files @@ -3969,14 +3969,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Added empty CodeSniffer.conf to enable config settings for Composer installs - Added Generic EndFileNoNewlineSniff to ensure there is no newline at the end of a file - Autoloader can now load PSR-0 compliant classes - - Thanks to Maik Penz for the patch + - Thanks to [Maik Penz][@goatherd] for the patch - Squiz NonExecutableCodeSniff no longer throws error for multi-line RETURNs inside CASE statements - - Thanks to Marc Ypes for the patch + - Thanks to [Marc Ypes][@ceeram] for the patch - Squiz OperatorSpacingSniff no longer reports errors for negative numbers inside inline THEN statements - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Squiz OperatorSpacingSniff no longer reports errors for the assignment of operations involving negative numbers - Squiz SelfMemberReferenceSniff can no longer get into an infinite loop when checking a static call with a namespace - - Thanks to Andy Grunwald for the patch + - Thanks to [Andy Grunwald][@andygrunwald] for the patch ### Fixed - Fixed bug #19699 : Generic.Files.LineLength giving false positives when tab-width is used @@ -3987,10 +3987,10 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Changed - PHP_CodeSniffer can now be installed using Composer - Require squizlabs/php_codesniffer in your composer.json file - - Thanks to Rob Bast, Stephen Rees-Carter, Stefano Kowalke and Ivan Habunek for help with this + - Thanks to [Rob Bast][@alcohol], [Stephen Rees-Carter][@valorin], [Stefano Kowalke][@Konafets] and [Ivan Habunek][@ihabunek] for help with this - Squiz BlockCommentSniff and InlineCommentSniff no longer report errors for trait block comments - Squiz SelfMemberReferenceSniff now supports namespaces - - Thanks to Andy Grunwald for the patch + - Thanks to [Andy Grunwald][@andygrunwald] for the patch - Squiz FileCommentSniff now uses tag names inside the error codes for many messages - This allows you to exclude specific missing, out of order etc., tags - Squiz SuperfluousWhitespaceSniff now has an option to ignore blank lines @@ -4000,10 +4000,10 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed gitblame report not working on Windows - - Thanks to Rogerio Prado de Jesus + - Thanks to [Rogerio Prado de Jesus][@rogeriopradoj] - Fixed an incorrect error in Squiz OperatorSpacingSniff for default values inside a closure definition - Fixed bug #19691 : SubversionPropertiesSniff fails to find missing properties - - Thanks to Kevin Winahradsky for the patch + - Thanks to [Kevin Winahradsky][pear-kwinahradsky] for the patch - Fixed bug #19692 : DisallowMultipleAssignments is triggered by a closure - Fixed bug #19693 : exclude-patterns no longer work on specific messages - Fixed bug #19694 : Squiz.PHP.LowercasePHPFunctions incorrectly matches return by ref functions @@ -4020,28 +4020,28 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - As you would with "message" and "severity", specify a "type" tag under a "rule" tag and set the value to "error" or "warning" - PHP_CodeSniffer will now generate a warning on files that it detects have mixed line endings - This warning has the code Internal.LineEndings.Mixed and can be overridden in a ruleset.xml file - - Thanks to Vit Brunner for help with this + - Thanks to [Vit Brunner][@tasuki] for help with this - Sniffs inside PHP 5.3 namespaces are now supported, along with the existing underscore-style emulated namespaces - For example: namespace MyStandard\Sniffs\Arrays; class ArrayDeclarationSniff implements \PHP_CodeSniffer_Sniff { ... - - Thanks to Till Klampaeckel for the patch + - Thanks to [Till Klampaeckel][@till] for the patch - Generic DuplicateClassNameSniff is no longer a multi-file sniff, so it won't max out your memory - Multi-file sniff support should be considered deprecated as standard sniffs can now do the same thing - Added Generic DisallowSpaceIndent to check that files are indented using tabs - Added Generic OneClassPerFileSniff to check that only one class is defined in each file - - Thanks to Andy Grunwald for the contribution + - Thanks to [Andy Grunwald][@andygrunwald] for the contribution - Added Generic OneInterfacePerFileSniff to check that only one interface is defined in each file - - Thanks to Andy Grunwald for the contribution + - Thanks to [Andy Grunwald][@andygrunwald] for the contribution - Added Generic LowercasedFilenameSniff to check that filenames are lowercase - - Thanks to Andy Grunwald for the contribution + - Thanks to [Andy Grunwald][@andygrunwald] for the contribution - Added Generic ClosingPHPTagSniff to check that each open PHP tag has a corresponding close tag - - Thanks to Andy Grunwald for the contribution + - Thanks to [Andy Grunwald][@andygrunwald] for the contribution - Added Generic CharacterBeforePHPOpeningTagSniff to check that the open PHP tag is the first content in a file - - Thanks to Andy Grunwald for the contribution + - Thanks to [Andy Grunwald][@andygrunwald] for the contribution - Fixed incorrect errors in Squiz OperatorBracketSniff and OperatorSpacingSniff for negative numbers in CASE statements - - Thanks to Arnout Boks for the patch + - Thanks to [Arnout Boks][@aboks] for the patch - Generic CamelCapsFunctionNameSniff no longer enforces exact case matching for PHP magic methods - Generic CamelCapsFunctionNameSniff no longer throws errors for overridden SOAPClient methods prefixed with double underscores - - Thanks to Dorian Villet for the patch + - Thanks to [Dorian Villet][@gnutix] for the patch - PEAR ValidFunctionNameSniff now supports traits - PSR1 ClassDeclarationSniff no longer throws an error for non-namespaced code if PHP version is less than 5.3.0 @@ -4063,10 +4063,10 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The sniff list includes all imported and native sniffs - Explain a standard by using the -e and --standard=[standard] command line arguments - E.g., phpcs -e --standard=Squiz - - Thanks to Ben Selby for the idea + - Thanks to [Ben Selby][@benmatselby] for the idea - Added report to show results using notify-send - Use --report=notifysend to generate the report - - Thanks to Christian Weiske for the contribution + - Thanks to [Christian Weiske][@cweiske] for the contribution - The JS tokenizer now recognises RETURN as a valid closer for CASE and DEFAULT inside switch statements - AbstractPatternSniff now sets the ignoreComments option using a public var rather than through the constructor - This allows the setting to be overwritten in ruleset.xml files @@ -4079,7 +4079,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed a PHP notice generated when loading custom array settings from a ruleset.xml file - Fixed bug #17908 : CodeSniffer does not recognise optional @params - - Thanks to Pete Walker for the patch + - Thanks to [Pete Walker][pear-pete] for the patch - Fixed bug #19538 : Function indentation code sniffer checks inside short arrays - Fixed bug #19565 : Non-Executable Code Sniff Broken for Case Statements with both return and break - Fixed bug #19612 : Invalid @package suggestion @@ -4093,7 +4093,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Significantly improved the performance of Squiz NonExecutableCodeSniff - Ignore patterns now check the relative path of a file based on the dir being checked - Allows ignore patterns to become more generic as the path to the code is no longer included when checking - - Thanks to Kristof Coomans for the patch + - Thanks to [Kristof Coomans][@kristofser] for the patch - Sniff settings can now be changed by specifying a special comment format inside a file - e.g., // @codingStandardsChangeSetting PEAR.Functions.FunctionCallSignature allowMultipleArguments false - If you change a setting, don't forget to change it back @@ -4103,9 +4103,9 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz standard now enforces one argument per line in multi-line function calls - Squiz FunctionDeclarationArgumentSpacingSniff now supports closures - Squiz OperatorSpacingSniff no longer throws an error for negative values inside an inline THEN statement - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Squiz FunctionCommentSniff now throws an error for not closing a comment with */ - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Summary report no longer shows two lines of PHP_Timer output when showing sources ### Fixed @@ -4130,7 +4130,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - PEAR FunctionDeclarationSniff now supports closures - Squiz MultiLineFunctionDeclarationSniff now supports closures - Exclude rules written for Unix systems will now work correctly on Windows - - Thanks to Walter Tamboer for the patch + - Thanks to [Walter Tamboer][@waltertamboer] for the patch - The PHP tokenizer now recognises T_RETURN as a valid closer for T_CASE and T_DEFAULT inside switch statements ### Fixed @@ -4139,44 +4139,44 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #19416 : Shorthand arrays cause bracket spacing errors - Fixed bug #19421 : phpcs doesn't recognize ${x} as equivalent to $x - Fixed bug #19428 : PHPCS Report "hgblame" doesn't support windows paths - - Thanks to Justin Rovang for the patch + - Thanks to [Justin Rovang][@rovangju] for the patch - Fixed bug #19448 : Problem with detecting remote standards - Fixed bug #19463 : Anonymous functions incorrectly being flagged by NonExecutableCodeSniff - Fixed bug #19469 : PHP_CodeSniffer_File::getMemberProperties() sets wrong scope - Fixed bug #19471 : phpcs on Windows, when using Zend standard, doesn't catch problems - - Thanks to Ivan Habunek for the patch + - Thanks to [Ivan Habunek][@ihabunek] for the patch - Fixed bug #19478 : Incorrect indent detection in PEAR standard - - Thanks to Shane Auckland for the patch + - Thanks to [Shane Auckland][@shanethehat] for the patch - Fixed bug #19483 : Blame Reports fail with space in directory name ## [1.3.4] - 2012-05-17 ### Changed - Added missing package.xml entries for new Generic FixmeSniff - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Expected indents for PEAR ScopeClosingBraceSniff and FunctionCallSignatureSniff can now be set in ruleset files - Both sniffs use a variable called "indent" - - Thanks to Thomas Despoix for the patch + - Thanks to [Thomas Despoix][pear-tomdesp] for the patch - Standards designed to be installed in the PHPCS Standards dir will now work outside this dir as well - In particular, allows the Drupal CS to work without needing to symlink it into the PHPCS install - - Thanks to Peter Philipp for the patch + - Thanks to [Peter Philipp][@das-peter] for the patch - Rule references for standards, directories and specific sniffs can now be relative in ruleset.xml files - For example: ref="../MyStandard/Sniffs/Commenting/DisallowHashCommentsSniff.php" - Symlinked standards now work correctly, allowing aliasing of installed standards (request #19417) - - Thanks to Tom Klingenberg for the patch + - Thanks to [Tom Klingenberg][@ktomk] for the patch - Squiz ObjectInstantiationSniff now allows objects to be returned without assigning them to a variable - Added Squiz.Commenting.FileComment.MissingShort error message for file comments that only contains tags - Also stops undefined index errors being generated for these comments - Debug option -vv now shows tokenizer status for CSS files - Added support for new gjslint error formats - - Thanks to Meck for the patch + - Thanks to [Meck][@yesmeck] for the patch - Generic ScopeIndentSniff now allows comment indents to not be exact even if the exact flag is set - The start of the comment is still checked for exact indentation as normal - Fixed an issue in AbstractPatternSniff where comments were not being ignored in some cases - Fixed an issue in Zend ClosingTagSniff where the closing tag was not always being detected correctly - - Thanks to Jonathan Robson for the patch + - Thanks to [Jonathan Robson][@jnrbsn] for the patch - Fixed an issue in Generic FunctionCallArgumentSpacingSniff where closures could cause incorrect errors - Fixed an issue in Generic UpperCaseConstantNameSniff where errors were incorrectly reported on goto statements - - Thanks to Tom Klingenberg for the patch + - Thanks to [Tom Klingenberg][@ktomk] for the patch - PEAR FileCommentSniff and ClassCommentSniff now support author emails with a single character in the local part - E.g., a@me.com - Thanks to Denis Shapkin for the patch @@ -4190,7 +4190,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #19381 : traits and indentations in traits are not handled properly - Fixed bug #19394 : Notice in NonExecutableCodeSniff - Fixed bug #19402 : Syntax error when executing phpcs on Windows with parens in PHP path - - Thanks to Tom Klingenberg for the patch + - Thanks to [Tom Klingenberg][@ktomk] for the patch - Fixed bug #19411 : magic method error on __construct() - The fix required a rewrite of AbstractScopeSniff, so please test any sniffs that extend this class - Fixed bug #19412 : Incorrect error about assigning objects to variables when inside inline IF @@ -4200,12 +4200,12 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ## [1.3.3] - 2012-02-07 ### Changed - Added new Generic FixmeSniff that shows error messages for all FIXME comments left in your code - - Thanks to Sam Graham for the contribution + - Thanks to [Sam Graham][@illusori] for the contribution - The maxPercentage setting in the Squiz CommentedOutCodeSniff can now be overridden in a ruleset.xml file - - Thanks to Volker Dusch for the patch + - Thanks to [Volker Dusch][@edorian] for the patch - The Checkstyle and XML reports now use XMLWriter - Only change in output is that empty file tags are no longer produced for files with no violations - - Thanks to Sebastian Bergmann for the patch + - Thanks to [Sebastian Bergmann][@sebastianbergmann] for the patch - Added PHP_CodeSniffer_Tokens::$bracketTokens to give sniff writers fast access to open and close bracket tokens - Fixed an issue in AbstractPatternSniff where EOL tokens were not being correctly checked in some cases - PHP_CodeSniffer_File::getTokensAsString() now detects incorrect length value (request #19313) @@ -4213,18 +4213,18 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed bug #19114 : CodeSniffer checks extension even for single file - Fixed bug #19171 : Show sniff codes option is ignored by some report types - - Thanks to Dominic Scheirlinck for the patch + - Thanks to [Dominic Scheirlinck][@dominics] for the patch - Fixed bug #19188 : Lots of PHP Notices when analyzing the Symfony framework - First issue was list-style.. lines in CSS files not properly adjusting open/close bracket positions - Second issue was notices caused by bug #19137 - Fixed bug #19208 : UpperCaseConstantName reports class members - Was also a problem with LowerCaseConstantName as well - Fixed bug #19256 : T_DOC_COMMENT in CSS files breaks ClassDefinitionNameSpacingSniff - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch - Fixed bug #19264 : Squiz.PHP.NonExecutableCode does not handle RETURN in CASE without BREAK - Fixed bug #19270 : DuplicateClassName does not handle namespaces correctly - Fixed bug #19283 : CSS @media rules cause false positives - - Thanks to Klaus Purer for the patch + - Thanks to [Klaus Purer][@klausi] for the patch ## [1.3.2] - 2011-12-01 ### Changed @@ -4234,17 +4234,17 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Thanks to Alexander Weiß for the contribution - Nowdocs are now tokenized using PHP_CodeSniffer specific T_NOWDOC tokens for easier identification - Generic UpperCaseConstantNameSniff no longer throws errors for namespaces - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Squiz NonExecutableCodeSniff now detects code after thrown exceptions - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Squiz OperatorSpacingSniff now ignores references - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Squiz FunctionCommentSniff now reports a missing function comment if it finds a standard code comment instead - Squiz FunctionCommentThrownTagSniff no longer reports errors if it can't find a function comment ### Fixed - Fixed unit tests not running under Windows - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Fixed bug #18964 : "$stackPtr must be of type T_VARIABLE" on heredocs and nowdocs - Fixed bug #18973 : phpcs is looking for variables in a nowdoc - Fixed bug #18974 : Blank line causes "Multi-line function call not indented correctly" @@ -4257,14 +4257,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The extensions command line argument now supports multi-part file extensions (request #17227) - Added report type --report=hgblame to show number of errors/warnings committed by authors in a Mercurial repository - Has the same functionality as the svnblame report - - Thanks to Ben Selby for the patch + - Thanks to [Ben Selby][@benmatselby] for the patch - Added T_BACKTICK token type to make detection of backticks easier (request #18799) - Added pattern matching support to Generic ForbiddenFunctionsSniff - If you are extending it and overriding register() or addError() you will need to review your sniff - Namespaces are now recognised as scope openers, although they do not require braces (request #18043) - Added new ByteOrderMarkSniff to Generic standard (request #18194) - Throws an error if a byte order mark is found in any PHP file - - Thanks to Piotr Karas for the contribution + - Thanks to [Piotr Karas][pear-ryba] for the contribution - PHP_Timer output is no longer included in reports when being written to a file (request #18252) - Also now shown for all report types if nothing is being printed to the screen - Generic DeprecatedFunctionSniff now reports functions as deprecated and not simply forbidden (request #18288) @@ -4277,7 +4277,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - PEAR FileCommentSniff now allows GIT IDs in the version tag (request #14874) - AbstractVariableSniff now supports heredocs - Also includes some variable detection fixes - - Thanks to Sam Graham for the patch + - Thanks to [Sam Graham][@illusori] for the patch - Squiz FileCommentSniff now enforces rule that package names cannot start with the word Squiz - MySource AssignThisSniff now allows "this" to be assigned to the private var _self - PEAR ClassDeclaration sniff now supports indentation checks when using the alternate namespace syntax @@ -4295,27 +4295,27 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Also corrects conversion of T_FUNCTION tokens to T_CLOSURE, which was not fixing token condition arrays - Fixed bug #18543 : CSS Tokenizer deletes too many # - Fixed bug #18624 : @throws namespace problem - - Thanks to Gavin Davies for the patch + - Thanks to [Gavin Davies][pear-boxgav] for the patch - Fixed bug #18628 : Generic.Files.LineLength gives incorrect results with Windows line-endings - Fixed bug #18633 : CSS Tokenizer doesn't replace T_LIST tokens inside some styles - Fixed bug #18657 : anonymous functions wrongly indented - Fixed bug #18670 : UpperCaseConstantNameSniff fails on dynamic retrieval of class constant - Fixed bug #18709 : Code sniffer sniffs file if even if it's in --ignore - - Thanks to Artem Lopata for the patch + - Thanks to [Artem Lopata][@biozshock] for the patch - Fixed bug #18762 : Incorrect handling of define and constant in UpperCaseConstantNameSniff - - Thanks to Thomas Baker for the patch + - Thanks to [Thomas Baker][pear-bakert] for the patch - Fixed bug #18769 : CSS Tokenizer doesn't replace T_BREAK tokens inside some styles - Fixed bug #18835 : Unreachable errors of inline returns of closure functions - - Thanks to Patrick Schmidt for the patch + - Thanks to [Patrick Schmidt][pear-woellchen] for the patch - Fixed bug #18839 : Fix miscount of warnings in AbstractSniffUnitTest.php - - Thanks to Sam Graham for the patch + - Thanks to [Sam Graham][@illusori] for the patch - Fixed bug #18844 : Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff with empty body - - Thanks to Dmitri Medvedev for the patch + - Thanks to [Dmitri Medvedev][pear-dvino] for the patch - Fixed bug #18847 : Running Squiz_Sniffs_Classes_ClassDeclarationSniff results in PHP notice - Fixed bug #18868 : jslint+rhino: errors/warnings not detected - - Thanks to Christian Weiske for the patch + - Thanks to [Christian Weiske][@cweiske] for the patch - Fixed bug #18879 : phpcs-svn-pre-commit requires escapeshellarg - - Thanks to Bjorn Katuin for the patch + - Thanks to [Bjorn Katuin][pear-bjorn] for the patch - Fixed bug #18951 : weird behaviour with closures and multi-line use () params ## 1.3.0 - 2011-03-17 @@ -4335,7 +4335,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #18250 : --standard with relative path skips Standards' "implicit" sniffs - Fixed bug #18274 : Multi-line IF and function call indent rules conflict - Fixed bug #18282 : Squiz doesn't handle final keyword before function comments - - Thanks to Dave Perrett for the patch + - Thanks to [Dave Perrett][pear-recurser] for the patch - Fixed bug #18336 : Function isUnderscoreName gives php notices ## 1.3.0RC2 - 2011-01-14 @@ -4347,7 +4347,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The standard --report and --report-file command line arguments are unchanged - Added -d command line argument to set php.ini settings while running (request #17244) - Usage is: phpcs -d memory_limit=32M -d ... - - Thanks to Ben Selby for the patch + - Thanks to [Ben Selby][@benmatselby] for the patch - Added -p command line argument to show progress during a run - Dot means pass, E means errors found, W means only warnings found and S means skipped file - Particularly good for runs where you are checking more than 100 files @@ -4387,21 +4387,21 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed bug #17693 : issue with pre-commit hook script with filenames that start with v - Fixed bug #17860 : isReference function fails with references in array - - Thanks to Lincoln Maskey for the patch + - Thanks to [Lincoln Maskey][pear-ljmaskey] for the patch - Fixed bug #17902 : Cannot run tests when tests are symlinked into tests dir - - Thanks to Matt Button for the patch + - Thanks to [Matt Button][@BRMatt] for the patch - Fixed bug #17928 : Improve error message for Generic_Sniffs_PHP_UpperCaseConstantSniff - - Thanks to Stefano Kowalke for the patch + - Thanks to [Stefano Kowalke][@Konafets] for the patch - Fixed bug #18039 : JS Tokenizer crash when ] is last character in file - Fixed bug #18047 : Incorrect handling of namespace aliases as constants - - Thanks to Dmitri Medvedev for the patch + - Thanks to [Dmitri Medvedev][pear-dvino] for the patch - Fixed bug #18072 : Impossible to exclude path from processing when symlinked - Fixed bug #18073 : Squiz.PHP.NonExecutableCode fault - Fixed bug #18117 : PEAR coding standard: Method constructor not sniffed as a function - Fixed bug #18135 : Generic FunctionCallArgumentSpacingSniff reports function declaration errors - Fixed bug #18140 : Generic scope indent in exact mode: strange expected/found values for switch - Fixed bug #18145 : Sniffs are not loaded for custom ruleset file - - Thanks to Scott McCammon for the patch + - Thanks to [Scott McCammon][pear-mccammos] for the patch - Fixed bug #18152 : While and do-while with AbstractPatternSniff - Fixed bug #18191 : Squiz.PHP.LowercasePHPFunctions does not work with new Date() - Fixed bug #18193 : CodeSniffer doesn't reconize CR (\r) line endings @@ -4418,7 +4418,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - The report is no longer printed to screen when using the --report-file command line option (request #17467) - If you want to print it to screen as well, use the -v command line argument - The SVN and GIT blame reports now also show percentage of reported errors per author (request #17606) - - Thanks to Ben Selby for the patch + - Thanks to [Ben Selby][@benmatselby] for the patch - Updated the SVN pre-commit hook to work with the new severity levels feature - Generic SubversionPropertiesSniff now allows properties to have NULL values (request #17682) - A null value indicates that the property should exist but the value should not be checked @@ -4431,7 +4431,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #17092 : Problems with utf8_encode and htmlspecialchars with non-ascii chars - Use the new --encoding=utf-8 command line argument if your files are utf-8 encoded - Fixed bug #17629 : PHP_CodeSniffer_Tokens::$booleanOperators missing T_LOGICAL_XOR - - Thanks to Matthew Turland for the patch + - Thanks to [Matthew Turland][@elazar] for the patch - Fixed bug #17699 : Fatal error generating code coverage with PHPUnit 5.3.0RC1 - Fixed bug #17718 : Namespace 'use' statement: used global class name is recognized as constant - Fixed bug #17734 : Generic SubversionPropertiesSniff complains on non SVN files @@ -4446,20 +4446,20 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - e.g., phpcs --standard=/path/to/my/ruleset.xml - Added a new report type --report=gitblame to show how many errors and warnings were committed by each author - Has the same functionality as the svnblame report - - Thanks to Ben Selby for the patch + - Thanks to [Ben Selby][@benmatselby] for the patch - A new token type T_DOLLAR has been added to allow you to sniff for variable variables (feature request #17095) - - Thanks to Ian Young for the patch + - Thanks to [Ian Young][pear-youngian] for the patch - JS tokenizer now supports T_POWER (^) and T_MOD_EQUAL (%=) tokens (feature request #17441) - If you have PHP_Timer installed, you'll now get a time/memory summary at the end of a script run - Only happens when printing reports that are designed to be read on the command line - Added Generic DeprecatedFunctionsSniff to warn about the use of deprecated functions (feature request #16694) - - Thanks to Sebastian Bergmann for the patch + - Thanks to [Sebastian Bergmann][@sebastianbergmann] for the patch - Added Squiz LogicalOperatorSniff to ensure that logical operators are surrounded by single spaces - Added MySource ChannelExceptionSniff to ensure action files only throw ChannelException - Added new method getClassProperties() for sniffs to use to determine if a class is abstract and/or final - - Thanks to Christian Kaps for the patch + - Thanks to [Christian Kaps][@akkie] for the patch - Generic UpperCaseConstantSniff no longer throws errors about namespaces - - Thanks to Christian Kaps for the patch + - Thanks to [Christian Kaps][@akkie] for the patch - Squiz OperatorBracketSniff now correctly checks value assignments in arrays - Squiz LongConditionClosingCommentSniff now requires a comment for long CASE statements that use curly braces - Squiz LongConditionClosingCommentSniff now requires an exact comment match on the brace @@ -4486,7 +4486,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ## 1.2.2 - 2010-01-27 ### Changed - The core PHP_CodeSniffer_File methods now understand the concept of closures (feature request #16866) - - Thanks to Christian Kaps for the sample code + - Thanks to [Christian Kaps][@akkie] for the sample code - Sniffs can now specify violation codes for each error and warning they add - Future versions will allow you to override messages and severities using these codes - Specifying a code is optional, but will be required if you wish to support overriding @@ -4540,14 +4540,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #16794 : ValidLogicalOperatorsSniff doesn't report operators not in lowercase - Fixed bug #16804 : Report filename is shortened too much - Fixed bug #16821 : Bug in Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Fixed bug #16836 : Notice raised when using semicolon to open case - Fixed bug #16855 : Generic standard sniffs incorrectly for define() method - Fixed bug #16865 : Two bugs in Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Fixed bug #16902 : Inline If Declaration bug - Fixed bug #16960 : False positive for late static binding in Squiz/ScopeKeywordSpacingSniff - - Thanks to Jakub Tománek for the patch + - Thanks to [Jakub Tománek][pear-thezero] for the patch - Fixed bug #16976 : The phpcs attempts to process symbolic links that don't resolve to files - Fixed bug #17017 : Including one file in the files sniffed alters errors reported for another file @@ -4591,19 +4591,19 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #16530 : ScopeIndentSniff reports false positive - Fixed bug #16533 : Duplicate errors and warnings - Fixed bug #16563 : Check file extensions problem in phpcs-svn-pre-commit - - Thanks to Kaijung Chen for the patch + - Thanks to [Kaijung Chen][pear-et3w503] for the patch - Fixed bug #16592 : Object operator indentation incorrect when first operator is on a new line - Fixed bug #16641 : Notice output - Fixed bug #16682 : Squiz_Sniffs_Strings_DoubleQuoteUsageSniff reports string "\0" as invalid - Fixed bug #16683 : Typing error in PHP_CodeSniffer_CommentParser_AbstractParser - Fixed bug #16684 : Bug in Squiz_Sniffs_PHP_NonExecutableCodeSniff - Fixed bug #16692 : Spaces in paths in Squiz_Sniffs_Debug_JavaScriptLintSniff - - Thanks to Jaroslav Hanslík for the patch + - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Fixed bug #16696 : Spelling error in MultiLineConditionSniff - Fixed bug #16697 : MultiLineConditionSniff incorrect result with inline IF - Fixed bug #16698 : Notice in JavaScript Tokenizer - Fixed bug #16736 : Multi-files sniffs aren't processed when FILE is a single directory - - Thanks to Alexey Shein for the patch + - Thanks to [Alexey Shein][pear-conf] for the patch - Fixed bug #16792 : Bug in Generic_Sniffs_PHP_ForbiddenFunctionsSniff ## 1.2.0 - 2009-08-17 @@ -4635,7 +4635,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed bug #15980 : PHP_CodeSniffer change php current directory - - Thanks to Dolly Aswin Harahap for the patch + - Thanks to [Dolly Aswin Harahap][pear-dollyaswin] for the patch - Fixed bug #16001 : Notice triggered - Fixed bug #16054 : phpcs-svn-pre-commit not showing any errors - Fixed bug #16071 : Fatal error: Uncaught PHP_CodeSniffer_Exception @@ -4649,7 +4649,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Added Generic SubversionPropertiesSniff to check that specific svn props are set for files - Thanks to Jack Bates for the contribution - The PHP version check can now be overridden in classes that extend PEAR FileCommentSniff - - Thanks to Helgi Þormar Þorbjörnsson for the suggestion + - Thanks to [Helgi Þormar Þorbjörnsson][@helgi] for the suggestion - Added Generic ConstructorNameSniff to check for PHP4 constructor name usage - Thanks to Leif Wickland for the contribution - Squiz standard now supports multi-line function and condition sniffs from PEAR standard @@ -4696,7 +4696,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Added MySource DebugCodeSniff to ban the use of Debug::method() calls - Added MySource CreateWidgetTypeCallback sniff to check callback usage in widget type create methods - Added Squiz DisallowObjectStringIndexSniff that forces object dot notation in JavaScript files - - Thanks to Sertan Danis for the contribution + - Thanks to [Sertan Danis][@sertand] for the contribution - Added Squiz DiscouragedFunctionsSniff to warn when using debug functions - Added Squiz PropertyLabelSniff to check whitespace around colons in JS property and label declarations - Added Squiz DuplicatePropertySniff to check for duplicate property names in JS classes @@ -4766,13 +4766,13 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #14409 : Output of warnings to log file - Fixed bug #14520 : Notice: Undefined offset: 1 in /usr/share/php/PHP/CodeSniffer/File.php on line - Fixed bug #14637 : Call to processUnknownArguments() misses second parameter $pos - - Thanks to Peter Buri for the patch + - Thanks to [Peter Buri][pear-burci] for the patch - Fixed bug #14889 : Lack of clarity: licence or license - Fixed bug #15008 : Nested Parentheses in Control Structure Sniffs - Fixed bug #15091 : pre-commit hook attempts to sniff folders - - Thanks to Bruce Weirdan for the patch + - Thanks to [Bruce Weirdan][pear-weirdan] for the patch - Fixed bug #15124 : AbstractParser.php uses deprecated split() function - - Thanks to Sebastian Bergmann for the patch + - Thanks to [Sebastian Bergmann][@sebastianbergmann] for the patch - Fixed bug #15188 : PHPCS vs HEREDOC strings - Fixed bug #15231 : Notice: Uninitialized string offset: 0 in FileCommentSniff.php on line 555 - Fixed bug #15336 : Notice: Undefined offset: 2 in /usr/share/php/PHP/CodeSniffer/File.php on line @@ -4835,7 +4835,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed error in phpcs error message when a supplied file does not exist - Fixed a cosmetic error in AbstractPatternSniff where the "found" string was missing some content - Added sniffs that implement part of the PMD rule catalog to the Generic standard - - Thanks to Manuel Pichler for the contribution of all these sniffs. + - Thanks to [Manuel Pichler][@manuelpichler] for the contribution of all these sniffs. - Squiz FunctionCommentThrowTagSniff no longer throws errors for function that only throw variables - Generic ScopeIndentSniff now has private member to enforce exact indent matching - Replaced Squiz DisallowCountInLoopsSniff with Squiz DisallowSizeFunctionsInLoopsSniff @@ -4877,7 +4877,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed error in Squiz OperatorBracketSniff where negative numbers were ignored during comparisons - Fixed error in Squiz FunctionSpacingSniff where functions after member vars reported incorrect spacing - Fixed bug #13062 : Interface comments aren't handled in PEAR standard - - Thanks to Manuel Pichler for the path + - Thanks to [Manuel Pichler][@manuelpichler] for the path - Fixed bug #13119 : php minimum requirement need to be fix - Fixed bug #13156 : Bug in Squiz_Sniffs_PHP_NonExecutableCodeSniff - Fixed bug #13158 : Strange behaviour in AbstractPatternSniff @@ -4885,7 +4885,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #13178 : Catch exception in File.php - Fixed bug #13254 : Notices output in checkstyle report causes XML issues - Fixed bug #13446 : crash with src of phpMyAdmin - - Thanks to Manuel Pichler for the path + - Thanks to [Manuel Pichler][@manuelpichler] for the path ## 1.0.1a1 - 2008-04-21 ### Changed @@ -4925,13 +4925,13 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed a problem that caused the parentheses map to sometimes contain incorrect values - Fixed bug #12767 : Cant run phpcs from dir with PEAR subdir - Fixed bug #12773 : Reserved variables are not detected in strings - - Thanks to Wilfried Loche for the patch + - Thanks to [Wilfried Loche][pear-wloche] for the patch - Fixed bug #12832 : Tab to space conversion does not work - Fixed bug #12888 : extra space indentation = Notice: Uninitialized string offset... - Fixed bug #12909 : Default generateDocs function does not work under linux - - Thanks to Paul Smith for the patch + - Thanks to [Paul Smith][pear-thing2b] for the patch - Fixed bug #12957 : PHP 5.3 magic method __callStatic - - Thanks to Manuel Pichler for the patch + - Thanks to [Manuel Pichler][@manuelpichler] for the patch ## 1.0.0 - 2007-12-21 ### Changed @@ -4944,7 +4944,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Those tokens that must have an opener (like T_CLASS) now keep looking until EOF - Other tokens (like T_FUNCTION) still stop after 3 lines for performance - You can now escape commas in ignore patterns so they can be matched in file names - - Thanks to Carsten Wiedmann for the patch + - Thanks to [Carsten Wiedmann][pear-cwiedmann] for the patch - Config data is now cached in a global var so the file system is not hit so often - You can also set config data temporarily for the script if you are using your own external script - Pass TRUE as the third argument to PHP_CodeSniffer::setConfigData() @@ -4953,14 +4953,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Squiz ClassDeclarationSniff now throws errors for a missing end PHP tag after the end class tag - Squiz IncrementDecrementUsageSniff no longer throws errors when -= and += are being used with vars - Squiz SwitchDeclarationSniff now throws errors for switch statements that do not contain a case statement - - Thanks to Sertan Danis for the patch + - Thanks to [Sertan Danis][@sertand] for the patch - MySource IncludeSystemSniff no longer throws errors for the Util package ### Fixed - Fixed bug #12621 : "space after AS" check is wrong - - Thanks to Satoshi Oikawa for the patch + - Thanks to [Satoshi Oikawa][pear-renoiv] for the patch - Fixed bug #12645 : error message is wrong - - Thanks to Renoiv for the patch + - Thanks to [Satoshi Oikawa][pear-renoiv] for the patch - Fixed bug #12651 : Increment/Decrement Operators Usage at -1 ## 1.0.0RC3 - 2007-11-30 @@ -4988,25 +4988,25 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed bug #12471 : Checkstyle report is broken - Fixed bug #12476 : PHP4 destructors are reported as error - Fixed bug #12513 : Checkstyle XML messages need to be utf8_encode()d - - Thanks to Sebastian Bergmann for the patch. + - Thanks to [Sebastian Bergmann][@sebastianbergmann] for the patch. - Fixed bug #12517 : getNewlineAfter() and dos files ## 1.0.0RC2 - 2007-11-14 ### Changed - Added a new Checkstyle report format - Like the current XML format but modified to look like Checkstyle output - - Thanks to Manuel Pichler for helping get the format correct + - Thanks to [Manuel Pichler][@manuelpichler] for helping get the format correct - You can now hide warnings by default - Run: phpcs --config-set show_warnings 0 - If warnings are hidden by default, use the new -w command line argument to override - Added new command line argument --config-delete to delete a config value and revert to the default - Improved overall performance by optimising tokenising and next/prev methods (feature request #12421) - - Thanks to Christian Weiske for the patch + - Thanks to [Christian Weiske][@cweiske] for the patch - Added FunctionCallSignatureSniff to Squiz standard - Added @subpackage support to file and class comment sniffs in PEAR standard (feature request #12382) - - Thanks to Carsten Wiedmann for the patch + - Thanks to [Carsten Wiedmann][pear-cwiedmann] for the patch - An error is now displayed if you use a PHP version less than 5.1.0 (feature request #12380) - - Thanks to Carsten Wiedmann for the patch + - Thanks to [Carsten Wiedmann][pear-cwiedmann] for the patch - phpcs now exits with status 2 if it receives invalid input (feature request #12380) - This is distinct from status 1, which indicates errors or warnings were found - Added new Squiz LanguageConstructSpacingSniff to throw errors for additional whitespace after echo etc. @@ -5019,7 +5019,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed incorrect errors for list() in Squiz DisallowMultipleAssignmentsSniff - Errors no longer thrown if control structure is followed by a CASE's BREAK in Squiz ControlStructureSpacingSniff - Fixed bug #12368 : Autoloader cannot be found due to include_path override - - Thanks to Richard Quadling for the patch + - Thanks to [Richard Quadling][pear-rquadling] for the patch - Fixed bug #12378 : equal sign alignments problem with while() ## 1.0.0RC1 - 2007-11-01 @@ -5085,7 +5085,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ## 0.8.0 - 2007-08-08 ### Changed - Added new XML report format; --report=xml (feature request #11535) - - Thanks to Brett Bieber for the patch + - Thanks to [Brett Bieber][@saltybeagle] for the patch - Added new command line argument --ignore to specify a list of files to skip (feature request #11556) - Added PHPCS and MySource coding standards into the core install - Scope map no longer gets confused by curly braces that act as string offsets @@ -5121,7 +5121,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Coding standard classes can now specify a list of sniffs to exclude as well as include (feature request #11056) - Two uppercase characters can now be placed side-by-side in class names in Squiz ValidClassNameSniff - SVN tags now allowed in PEAR file doc blocks (feature request #11038) - - Thanks to Torsten Roehr for the patch + - Thanks to [Torsten Roehr][pear-troehr] for the patch - Private methods in commenting sniffs and comment parser are now protected (feature request #11087) - Added Generic LineEndingsSniff to check the EOL character of a file - PEAR standard now only throws one error per file for incorrect line endings (eg. /r/n) @@ -5151,14 +5151,14 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Fixed - Fixed bug #11105 : getIncludedSniffs() not working anymore - - Thanks to Blair Robertson for the patch + - Thanks to [Blair Robertson][pear-adviva] for the patch - Fixed bug #11120 : Uninitialized string offset in AbstractParser.php on line 200 ## 0.6.0 - 2007-05-15 ### Changed - The number of errors and warnings found is now shown for each file while checking the file if verbosity is enabled - Now using PHP_EOL instead of hard-coded \n so output looks good on Windows (feature request #10761) - - Thanks to Carsten Wiedmann for the patch. + - Thanks to [Carsten Wiedmann][pear-cwiedmann] for the patch. - phpcs now exits with status 0 (no errors) or 1 (errors found) (feature request #10348) - Added new -l command line argument to stop recursion into directories (feature request #10979) @@ -5166,7 +5166,7 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c - Fixed variable name error causing incorrect error message in Squiz ValidVariableNameSniff - Fixed bug #10757 : Error in ControlSignatureSniff - Fixed bugs #10751, #10777 : Sniffer class paths handled incorrectly in Windows - - Thanks to Carsten Wiedmann for the patch. + - Thanks to [Carsten Wiedmann][pear-cwiedmann] for the patch. - Fixed bug #10961 : Error "Last parameter comment requires a blank newline after it" thrown - Fixed bug #10983 : phpcs outputs notices when checking invalid PHP - Fixed bug #10980 : Incorrect warnings for equals sign @@ -5341,6 +5341,10 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c ### Added - Initial preview release + + [Unreleased]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/master...HEAD [3.8.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.2...3.8.0 [3.7.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.1...3.7.2 @@ -5430,3 +5434,234 @@ Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo c [1.3.4]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.3.3...1.3.4 [1.3.3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.3.2...1.3.3 [1.3.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/1.3.1...1.3.2 + + + +[@2shediac]: https://github.com/2shediac +[@ablyler]: https://github.com/ablyler +[@aboks]: https://github.com/aboks +[@abulford]: https://github.com/abulford +[@afilina]: https://github.com/afilina +[@aik099]: https://github.com/aik099 +[@akarmazyn]: https://github.com/akarmazyn +[@akkie]: https://github.com/akkie +[@alcohol]: https://github.com/alcohol +[@alekitto]: https://github.com/alekitto +[@AlexHowansky]: https://github.com/AlexHowansky +[@anbuc]: https://github.com/anbuc +[@andrei-propertyguru]: https://github.com/andrei-propertyguru +[@AndrewDawes]: https://github.com/AndrewDawes +[@andygrunwald]: https://github.com/andygrunwald +[@annechko]: https://github.com/annechko +[@arnested]: https://github.com/arnested +[@asnyder]: https://github.com/asnyder +[@Astinus-Eberhard]: https://github.com/Astinus-Eberhard +[@axlon]: https://github.com/axlon +[@bayleedev]: https://github.com/bayleedev +[@becoded]: https://github.com/becoded +[@Benjamin-Loison]: https://github.com/Benjamin-Loison +[@benmatselby]: https://github.com/benmatselby +[@Billz95]: https://github.com/Billz95 +[@biozshock]: https://github.com/biozshock +[@bkdotcom]: https://github.com/bkdotcom +[@bladeofsteel]: https://github.com/bladeofsteel +[@blerou]: https://github.com/blerou +[@blue32a]: https://github.com/blue32a +[@bondas83]: https://github.com/bondas83 +[@boonkerz]: https://github.com/boonkerz +[@BRMatt]: https://github.com/BRMatt +[@CandySunPlus]: https://github.com/CandySunPlus +[@ceeram]: https://github.com/ceeram +[@cixtor]: https://github.com/cixtor +[@claylo]: https://github.com/claylo +[@codebymikey]: https://github.com/codebymikey +[@covex-nn]: https://github.com/covex-nn +[@cweiske]: https://github.com/cweiske +[@Daimona]: https://github.com/Daimona +[@danez]: https://github.com/danez +[@DannyvdSluijs]: https://github.com/DannyvdSluijs +[@das-peter]: https://github.com/das-peter +[@datengraben]: https://github.com/datengraben +[@david-binda]: https://github.com/david-binda +[@Decave]: https://github.com/Decave +[@dereuromark]: https://github.com/dereuromark +[@derrabus]: https://github.com/derrabus +[@deviantintegral]: https://github.com/deviantintegral +[@dhensby]: https://github.com/dhensby +[@dominics]: https://github.com/dominics +[@donatj]: https://github.com/donatj +[@dryabkov]: https://github.com/dryabkov +[@dschniepp]: https://github.com/dschniepp +[@duncan3dc]: https://github.com/duncan3dc +[@edorian]: https://github.com/edorian +[@elazar]: https://github.com/elazar +[@ElvenSpellmaker]: https://github.com/ElvenSpellmaker +[@emil-nasso]: https://github.com/emil-nasso +[@enl]: https://github.com/enl +[@erikwiffin]: https://github.com/erikwiffin +[@eser]: https://github.com/eser +[@exussum12]: https://github.com/exussum12 +[@fabacino]: https://github.com/fabacino +[@fabre-thibaud]: https://github.com/fabre-thibaud +[@filips123]: https://github.com/filips123 +[@Fischer-Bjoern]: https://github.com/Fischer-Bjoern +[@fonsecas72]: https://github.com/fonsecas72 +[@fredden]: https://github.com/fredden +[@GaryJones]: https://github.com/GaryJones +[@ghostal]: https://github.com/ghostal +[@ghunti]: https://github.com/ghunti +[@gmponos]: https://github.com/gmponos +[@gnutix]: https://github.com/gnutix +[@goatherd]: https://github.com/goatherd +[@grongor]: https://github.com/grongor +[@grzr]: https://github.com/grzr +[@gwharton]: https://github.com/gwharton +[@hashar]: https://github.com/hashar +[@helgi]: https://github.com/helgi +[@hernst42]: https://github.com/hernst42 +[@iammattcoleman]: https://github.com/iammattcoleman +[@ihabunek]: https://github.com/ihabunek +[@illusori]: https://github.com/illusori +[@index0h]: https://github.com/index0h +[@ivuorinen]: https://github.com/ivuorinen +[@jasonmccreary]: https://github.com/jasonmccreary +[@javer]: https://github.com/javer +[@JDGrimes]: https://github.com/JDGrimes +[@jedgell]: https://github.com/jedgell +[@jeffslofish]: https://github.com/jeffslofish +[@jmarcil]: https://github.com/jmarcil +[@jnrbsn]: https://github.com/jnrbsn +[@joelposti]: https://github.com/joelposti +[@johanderuijter]: https://github.com/johanderuijter +[@johnmaguire]: https://github.com/johnmaguire +[@johnpbloch]: https://github.com/johnpbloch +[@JorisDebonnet]: https://github.com/JorisDebonnet +[@josephzidell]: https://github.com/josephzidell +[@joshdavis11]: https://github.com/joshdavis11 +[@jpuck]: https://github.com/jpuck +[@jrfnl]: https://github.com/jrfnl +[@kdebisschop]: https://github.com/kdebisschop +[@kenguest]: https://github.com/kenguest +[@klausi]: https://github.com/klausi +[@Konafets]: https://github.com/Konafets +[@kristofser]: https://github.com/kristofser +[@ksimka]: https://github.com/ksimka +[@ktomk]: https://github.com/ktomk +[@kukulich]: https://github.com/kukulich +[@legoktm]: https://github.com/legoktm +[@lmanzke]: https://github.com/lmanzke +[@localheinz]: https://github.com/localheinz +[@MacDada]: https://github.com/MacDada +[@Majkl578]: https://github.com/Majkl578 +[@manuelpichler]: https://github.com/manuelpichler +[@marcospassos]: https://github.com/marcospassos +[@MarkBaker]: https://github.com/MarkBaker +[@MarkMaldaba]: https://github.com/MarkMaldaba +[@martinssipenko]: https://github.com/martinssipenko +[@marvasDE]: https://github.com/marvasDE +[@MasterOdin]: https://github.com/MasterOdin +[@mathroc]: https://github.com/mathroc +[@maxgalbu]: https://github.com/maxgalbu +[@mcuelenaere]: https://github.com/mcuelenaere +[@mhujer]: https://github.com/mhujer +[@michaelbutler]: https://github.com/michaelbutler +[@michalbundyra]: https://github.com/michalbundyra +[@Morerice]: https://github.com/Morerice +[@morozov]: https://github.com/morozov +[@mrkrstphr]: https://github.com/mrkrstphr +[@mythril]: https://github.com/mythril +[@Naelyth]: https://github.com/Naelyth +[@ndm2]: https://github.com/ndm2 +[@nicholascus]: https://github.com/nicholascus +[@NickDickinsonWilde]: https://github.com/NickDickinsonWilde +[@nkovacs]: https://github.com/nkovacs +[@nubs]: https://github.com/nubs +[@o5]: https://github.com/o5 +[@ofbeaton]: https://github.com/ofbeaton +[@olemartinorg]: https://github.com/olemartinorg +[@ondrejmirtes]: https://github.com/ondrejmirtes +[@orx0r]: https://github.com/orx0r +[@ostrolucky]: https://github.com/ostrolucky +[@pfrenssen]: https://github.com/pfrenssen +[@phil-davis]: https://github.com/phil-davis +[@photodude]: https://github.com/photodude +[@r3nat]: https://github.com/r3nat +[@raul338]: https://github.com/raul338 +[@realmfoo]: https://github.com/realmfoo +[@renaatdemuynck]: https://github.com/renaatdemuynck +[@renan]: https://github.com/renan +[@rhorber]: https://github.com/rhorber +[@rmccue]: https://github.com/rmccue +[@robocoder]: https://github.com/robocoder +[@rogeriopradoj]: https://github.com/rogeriopradoj +[@rovangju]: https://github.com/rovangju +[@rvanvelzen]: https://github.com/rvanvelzen +[@saltybeagle]: https://github.com/saltybeagle +[@samlev]: https://github.com/samlev +[@scato]: https://github.com/scato +[@schlessera]: https://github.com/schlessera +[@schnittstabil]: https://github.com/schnittstabil +[@sebastianbergmann]: https://github.com/sebastianbergmann +[@sertand]: https://github.com/sertand +[@shanethehat]: https://github.com/shanethehat +[@simonsan]: https://github.com/simonsan +[@sjlangley]: https://github.com/sjlangley +[@sserbin]: https://github.com/sserbin +[@stefanlenselink]: https://github.com/stefanlenselink +[@SteveTalbot]: https://github.com/SteveTalbot +[@storeman]: https://github.com/storeman +[@stronk7]: https://github.com/stronk7 +[@svycka]: https://github.com/svycka +[@syranez]: https://github.com/syranez +[@tasuki]: https://github.com/tasuki +[@tim-bezhashvyly]: https://github.com/tim-bezhashvyly +[@TomHAnderson]: https://github.com/TomHAnderson +[@thewilkybarkid]: https://github.com/thewilkybarkid +[@thiemowmde]: https://github.com/thiemowmde +[@thomasjfox]: https://github.com/thomasjfox +[@till]: https://github.com/till +[@timoschinkel]: https://github.com/timoschinkel +[@uniquexor]: https://github.com/uniquexor +[@valorin]: https://github.com/valorin +[@VasekPurchart]: https://github.com/VasekPurchart +[@VincentLanglet]: https://github.com/VincentLanglet +[@waltertamboer]: https://github.com/waltertamboer +[@westonruter]: https://github.com/westonruter +[@willemstuursma]: https://github.com/willemstuursma +[@wimg]: https://github.com/wimg +[@wvega]: https://github.com/wvega +[@xalopp]: https://github.com/xalopp +[@xjm]: https://github.com/xjm +[@xt99]: https://github.com/xt99 +[@yesmeck]: https://github.com/yesmeck +[@zBart]: https://github.com/zBart +[pear-adviva]: https://pear.php.net/user/adviva +[pear-bakert]: https://pear.php.net/user/bakert +[pear-bjorn]: https://pear.php.net/user/bjorn +[pear-boxgav]: https://pear.php.net/user/boxgav +[pear-burci]: https://pear.php.net/user/burci +[pear-conf]: https://pear.php.net/user/conf +[pear-cwiedmann]: https://pear.php.net/user/cwiedmann +[pear-dollyaswin]: https://pear.php.net/user/dollyaswin +[pear-dvino]: https://pear.php.net/user/dvino +[pear-et3w503]: https://pear.php.net/user/et3w503 +[pear-gemineye]: https://pear.php.net/user/gemineye +[pear-kwinahradsky]: https://pear.php.net/user/kwinahradsky +[pear-ljmaskey]: https://pear.php.net/user/ljmaskey +[pear-mccammos]: https://pear.php.net/user/mccammos +[pear-pete]: https://pear.php.net/user/pete +[pear-recurser]: https://pear.php.net/user/recurser +[pear-renoiv]: https://pear.php.net/user/renoiv +[pear-rquadling]: https://pear.php.net/user/rquadling +[pear-ryba]: https://pear.php.net/user/ryba +[pear-thezero]: https://pear.php.net/user/thezero +[pear-thing2b]: https://pear.php.net/user/thing2b +[pear-tomdesp]: https://pear.php.net/user/tomdesp +[pear-troehr]: https://pear.php.net/user/troehr +[pear-weirdan]: https://pear.php.net/user/weirdan +[pear-wloche]: https://pear.php.net/user/wloche +[pear-woellchen]: https://pear.php.net/user/woellchen +[pear-youngian]: https://pear.php.net/user/youngian + From 7725dec0a4cf6c269384d9034face0f894e5c5a6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Dec 2023 17:17:32 +0100 Subject: [PATCH 240/874] PHP 8.2 | Squiz/VariableComment: allow for stand-alone null/true/false types Since PHP 8.2, stand-alone use of `true`, `false` and `null` is allowed. However, if these were used as the type for a property, the docblock would not be found. Fixed now. Includes unit tests. --- .../Sniffs/Commenting/VariableCommentSniff.php | 3 +++ .../Commenting/VariableCommentUnitTest.inc | 18 ++++++++++++++++++ .../VariableCommentUnitTest.inc.fixed | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php index f7599c779b..370e720875 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php @@ -42,6 +42,9 @@ public function processMemberVar(File $phpcsFile, $stackPtr) T_NULLABLE => T_NULLABLE, T_TYPE_UNION => T_TYPE_UNION, T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, + T_NULL => T_NULL, + T_TRUE => T_TRUE, + T_FALSE => T_FALSE, ]; for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) { diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc index 928022498a..60d83525cb 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc @@ -418,3 +418,21 @@ class IntersectionTypes */ private \Iterator&\Countable $variableName; } + +class StandaloneNullTrueFalseTypes +{ + /** + * @var null + */ + public null $variableName = null; + + /** + * @var true + */ + protected true $variableName = true; + + /** + * @var false + */ + private false $variableName = false; +} diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed index 2666c7c553..8bea190fd5 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed @@ -418,3 +418,21 @@ class IntersectionTypes */ private \Iterator&\Countable $variableName; } + +class StandaloneNullTrueFalseTypes +{ + /** + * @var null + */ + public null $variableName = null; + + /** + * @var true + */ + protected true $variableName = true; + + /** + * @var false + */ + private false $variableName = false; +} From b04f0a690ed6812e6eb4524248e2a7a8c4ea04a6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Dec 2023 17:19:55 +0100 Subject: [PATCH 241/874] Squiz/VariableComment: allow for various other missing types There were some more allowed types missing from the list of tokens to skip over to find a docblock. Fixed now. Includes unit tests. --- .../Sniffs/Commenting/VariableCommentSniff.php | 3 +++ .../Commenting/VariableCommentUnitTest.inc | 18 ++++++++++++++++++ .../VariableCommentUnitTest.inc.fixed | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php index 370e720875..76fbc6dca6 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php @@ -39,12 +39,15 @@ public function processMemberVar(File $phpcsFile, $stackPtr) T_WHITESPACE => T_WHITESPACE, T_STRING => T_STRING, T_NS_SEPARATOR => T_NS_SEPARATOR, + T_NAMESPACE => T_NAMESPACE, T_NULLABLE => T_NULLABLE, T_TYPE_UNION => T_TYPE_UNION, T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, T_NULL => T_NULL, T_TRUE => T_TRUE, T_FALSE => T_FALSE, + T_SELF => T_SELF, + T_PARENT => T_PARENT, ]; for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) { diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc index 60d83525cb..54ef5d2d3b 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc @@ -436,3 +436,21 @@ class StandaloneNullTrueFalseTypes */ private false $variableName = false; } + +class MoreMissingButSupportedTypes +{ + /** + * @var parent + */ + public parent $variableName; + + /** + * @var self + */ + protected self $variableName; + + /** + * @var SomeClass + */ + private namespace\SomeClass $variableName; +} diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed index 8bea190fd5..a292b6de15 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed @@ -436,3 +436,21 @@ class StandaloneNullTrueFalseTypes */ private false $variableName = false; } + +class MoreMissingButSupportedTypes +{ + /** + * @var parent + */ + public parent $variableName; + + /** + * @var self + */ + protected self $variableName; + + /** + * @var SomeClass + */ + private namespace\SomeClass $variableName; +} From 7341d76b11a347545d07937cfdb08821deff3bd4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 10 Jan 2024 02:21:58 +0100 Subject: [PATCH 242/874] GH Actions: warm PHPUnit cache on PHPUnit 9.3+ As of PHPUnit 9.3, PHPUnit started using PHP-Parser as a basis to calculate code coverage. PHP Parser also polyfills tokens and that can interfere with the sniffs, but only in code coverage runs. In PHPUnit 9.3.4 a new feature was added to warm the code cache ahead of running tests recording code coverage. Using that feature should prevent the token interference. So far, I've not seen problems with this for this codebase, but better safe than sorry, so I'm going to enable cache warming now anyway. Notes regarding cache-warming: * The `--coverage-cache` and `--warm-coverage-cache` options are available since PHPUnit 9.3.4 and if these are used on older PHPUnit versions, PHPUnit will error out with an "unrecognized CLI argument" error. * In other words: these options can only be used with PHPUnit 9.3+, which is why the PHPUnit version is checked and remembered and subsequently used in the conditions. * Also: running PHPUnit with the `--warm-coverage-cache` option _does not run the tests_. It literally only warms the cache, which is why this is implemented as a separate step in the workflow. * The cache directory can be configured in the `phpunit.xml[.dist]` file, but only when using the PHPUnit 9.3+ `coverage` XML tag. As the PHPUnit config used needs to stay cross-version compatible with older PHPUnit versions, the CLI option is used for now. Refs: * https://github.com/sebastianbergmann/php-code-coverage/issues/798#issuecomment-678922065 * https://github.com/sebastianbergmann/phpunit/compare/9.3.3...9.3.4 Also note that PHP-Parser 5.0 was released a couple of days ago and when used for code coverage runs on PHP 8.0 (as used for the 4.0 branch), this causes problems. When I merge this commit up to 4.0, I will adjust the GH Actions script for the 4.0 branch to use PHP 8.1 instead of PHP 8.0 to avoid this issue. The issue has been reported upstream: https://github.com/sebastianbergmann/php-code-coverage/issues/1025 --- .github/workflows/test.yml | 23 ++++++++++++++++++++++- composer.json | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2527c4b8bb..80bb99fde4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -234,12 +234,33 @@ jobs: # Bust the cache at least once a month - output format: YYYY-MM. custom-cache-suffix: $(date -u "+%Y-%m") + - name: Grab PHPUnit version + id: phpunit_version + # yamllint disable-line rule:line-length + run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT + + - name: "DEBUG: Show grabbed version" + run: echo ${{ steps.phpunit_version.outputs.VERSION }} + - name: 'PHPCS: set the path to PHP' run: php bin/phpcs --config-set php_path php - - name: 'PHPUnit: run the tests with code coverage' + # PHPUnit 9.3 started using PHP-Parser for code coverage, which can cause issues due to Parser + # also polyfilling PHP tokens. + # As of PHPUnit 9.3.4, a cache warming option is available. + # Using that option prevents issues with PHP-Parser backfilling PHP tokens during our test runs. + - name: "Warm the PHPUnit cache (PHPUnit 9.3+)" + if: ${{ steps.phpunit_version.outputs.VERSION >= '9.3' }} + run: vendor/bin/phpunit --coverage-cache ./build/phpunit-cache --warm-coverage-cache + + - name: "Run the unit tests with code coverage (PHPUnit < 9.3)" + if: ${{ steps.phpunit_version.outputs.VERSION < '9.3' }} run: vendor/bin/phpunit tests/AllTests.php + - name: "Run the unit tests with code coverage (PHPUnit 9.3+)" + if: ${{ steps.phpunit_version.outputs.VERSION >= '9.3' }} + run: vendor/bin/phpunit tests/AllTests.php --coverage-cache ./build/phpunit-cache + - name: Upload coverage results to Coveralls if: ${{ success() }} uses: coverallsapp/github-action@v2 diff --git a/composer.json b/composer.json index c0d0e4e082..ae7c7604aa 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "ext-xmlwriter": "*" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ "bin/phpcbf", From 63ab52ce8944b0d33c93166d044c43b4a9b6a6ce Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 22 Mar 2019 02:38:38 +0100 Subject: [PATCH 243/874] Util/Common: add tests for the suggestType() method The `Common::suggestType()` method did not have dedicated unit tests. The tests now added are based upon work previously done for squizlabs/PHP_CodeSniffer 2189 / squizlabs/PHP_CodeSniffer 2456 --- tests/Core/Util/SuggestTypeTest.php | 224 ++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 tests/Core/Util/SuggestTypeTest.php diff --git a/tests/Core/Util/SuggestTypeTest.php b/tests/Core/Util/SuggestTypeTest.php new file mode 100644 index 0000000000..b143e6bc16 --- /dev/null +++ b/tests/Core/Util/SuggestTypeTest.php @@ -0,0 +1,224 @@ + + * @copyright 2019 Juliette Reinders Folmer. All rights reserved. + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Util; + +use PHP_CodeSniffer\Util\Common; +use PHPUnit\Framework\TestCase; + +/** + * Tests for the \PHP_CodeSniffer\Util\Sniffs\Comments::suggestType() method. + * + * @covers \PHP_CodeSniffer\Util\Common::suggestType + */ +class SuggestTypeTest extends TestCase +{ + + + /** + * Test passing an empty type to the suggestType() method. + * + * @return void + */ + public function testSuggestTypeEmpty() + { + $this->assertSame('', Common::suggestType('')); + + }//end testSuggestTypeEmpty() + + + /** + * Test passing one of the allowed types to the suggestType() method. + * + * @param string $varType The type. + * + * @dataProvider dataSuggestTypeAllowedType + * + * @return void + */ + public function testSuggestTypeAllowedType($varType) + { + $result = Common::suggestType($varType); + $this->assertSame($varType, $result); + + }//end testSuggestTypeAllowedType() + + + /** + * Data provider. + * + * @see testSuggestTypeAllowedType() + * + * @return array> + */ + public function dataSuggestTypeAllowedType() + { + $data = []; + foreach (Common::$allowedTypes as $type) { + $data['Type: '.$type] = [$type]; + } + + return $data; + + }//end dataSuggestTypeAllowedType() + + + /** + * Test passing one of the allowed types in the wrong case to the suggestType() method. + * + * @param string $varType The type found. + * @param string $expected Expected suggested type. + * + * @dataProvider dataSuggestTypeAllowedTypeWrongCase + * + * @return void + */ + public function testSuggestTypeAllowedTypeWrongCase($varType, $expected) + { + $result = Common::suggestType($varType); + $this->assertSame($expected, $result); + + }//end testSuggestTypeAllowedTypeWrongCase() + + + /** + * Data provider. + * + * @see testSuggestTypeAllowedTypeWrongCase() + * + * @return array> + */ + public function dataSuggestTypeAllowedTypeWrongCase() + { + $data = []; + foreach (Common::$allowedTypes as $type) { + $data['Mixed case: '.$type] = [ + 'varType' => ucfirst($type), + 'expected' => $type, + ]; + $data['Uppercase: '.$type] = [ + 'varType' => strtoupper($type), + 'expected' => $type, + ]; + } + + return $data; + + }//end dataSuggestTypeAllowedTypeWrongCase() + + + /** + * Test the suggestType() method for all other cases. + * + * @param string $varType The type found. + * @param string $expected Expected suggested type. + * + * @dataProvider dataSuggestTypeOther + * + * @return void + */ + public function testSuggestTypeOther($varType, $expected) + { + $result = Common::suggestType($varType); + $this->assertSame($expected, $result); + + }//end testSuggestTypeOther() + + + /** + * Data provider. + * + * @see testSuggestTypeOther() + * + * @return array> + */ + public function dataSuggestTypeOther() + { + return [ + // Short forms. + 'Short form type: bool, lowercase' => [ + 'varType' => 'bool', + 'expected' => 'boolean', + ], + 'Short form type: bool, uppercase' => [ + 'varType' => 'BOOL', + 'expected' => 'boolean', + ], + 'Short form type: double, lowercase' => [ + 'varType' => 'double', + 'expected' => 'float', + ], + 'Short form type: real, mixed case' => [ + 'varType' => 'Real', + 'expected' => 'float', + ], + 'Short form type: double, mixed case' => [ + 'varType' => 'DoUbLe', + 'expected' => 'float', + ], + 'Short form type: int, lowercase' => [ + 'varType' => 'int', + 'expected' => 'integer', + ], + 'Short form type: int, uppercase' => [ + 'varType' => 'INT', + 'expected' => 'integer', + ], + + // Array types. + 'Array type: mixed case keyword, empty parentheses' => [ + 'varType' => 'Array()', + 'expected' => 'array', + ], + 'Array type: short form type as value within the parentheses' => [ + 'varType' => 'array(real)', + 'expected' => 'array(float)', + ], + 'Array type: short form type as key within the parentheses' => [ + 'varType' => 'array(int => object)', + 'expected' => 'array(integer => object)', + ], + 'Array type: valid specification' => [ + 'varType' => 'array(integer => array(string => resource))', + 'expected' => 'array(integer => array(string => resource))', + ], + 'Array type: short form + uppercase types within the parentheses' => [ + 'varType' => 'ARRAY(BOOL => DOUBLE)', + 'expected' => 'array(boolean => float)', + ], + 'Array type: no space around the arrow within the parentheses' => [ + 'varType' => 'array(string=>resource)', + 'expected' => 'array(string => resource)', + ], + + // Incomplete array type. + 'Array type: incomplete specification' => [ + 'varType' => 'array(int =>', + 'expected' => 'array', + ], + + // Custom types are returned unchanged. + 'Unknown type: " => "' => [ + 'varType' => ' => ', + 'expected' => ' => ', + ], + 'Unknown type: "string[]"' => [ + 'varType' => 'string[]', + 'expected' => 'string[]', + ], + 'Unknown type: "\DateTime"' => [ + 'varType' => '\DateTime', + 'expected' => '\DateTime', + ], + ]; + + }//end dataSuggestTypeOther() + + +}//end class From 65270ebdc120c911dc2100aa1a3d6e23823864a5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Jan 2024 21:38:46 +0100 Subject: [PATCH 244/874] Tests/SuggestTypeTest: minor docblock fix --- tests/Core/Util/SuggestTypeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Core/Util/SuggestTypeTest.php b/tests/Core/Util/SuggestTypeTest.php index b143e6bc16..a5a862f43c 100644 --- a/tests/Core/Util/SuggestTypeTest.php +++ b/tests/Core/Util/SuggestTypeTest.php @@ -4,7 +4,7 @@ * * @author Juliette Reinders Folmer * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ namespace PHP_CodeSniffer\Tests\Core\Util; From 8f5f986afb5b30e47b12ce563f833d154ff98d32 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 11 Dec 2023 18:46:58 +0100 Subject: [PATCH 245/874] Changelog for the 3.8.1 release --- CHANGELOG.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cde2c338c1..2da2e81067 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,53 @@ The file documents changes to the PHP_CodeSniffer project. _Nothing yet._ +## [3.8.1] - 2024-01-11 + +### 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 release assets (PHARS + asc files) (same as it previously was in the squizlabs repo). See [#205] for context. + - Thanks to [Shivam Mathur][@shivammathur] for opening a discussion about this +- Various housekeeping, includes improvements to the tests and documentation + - Thanks to [Dan Wallis][@fredden], [Lucas Hoffmann][@lucc], [Rodrigo Primo][@rodrigoprimo] and [Juliette Reinders Folmer][@jrfnl] for their contributions + +### 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 + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch + +[#124]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/124 +[#150]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/150 +[#154]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/154 +[#178]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/178 +[#205]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/205 +[#211]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/211 +[#226]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/226 + + ## [3.8.0] - 2023-12-08 [Squizlabs/PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is dead. Long live [PHPCSStandards/PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer)! @@ -699,9 +746,9 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - The cache is no longer used if the list of loaded PHP extensions changes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - `Generic.NamingConventions.CamelCapsFunctionName` no longer reports `__serialize` and `__unserialize` as invalid names - - Thanks to [Filip Å][@filips123]  for the patch + - Thanks to [Filip Å ][@filips123] for the patch - `PEAR.NamingConventions.ValidFunctionName` no longer reports `__serialize` and `__unserialize` as invalid names - - Thanks to [Filip Å][@filips123]  for the patch + - Thanks to [Filip Å ][@filips123] for the patch - `Squiz.Scope.StaticThisUsage` now detects usage of `$this` inside closures and arrow functions - Thanks to [MichaÅ‚ Bundyra][@michalbundyra] for the patch @@ -5346,6 +5393,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo --> [Unreleased]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/master...HEAD +[3.8.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.8.0...3.8.1 [3.8.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.2...3.8.0 [3.7.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.1...3.7.2 [3.7.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.0...3.7.1 @@ -5455,6 +5503,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@AndrewDawes]: https://github.com/AndrewDawes [@andygrunwald]: https://github.com/andygrunwald [@annechko]: https://github.com/annechko +[@anomiex]: https://github.com/anomiex [@arnested]: https://github.com/arnested [@asnyder]: https://github.com/asnyder [@Astinus-Eberhard]: https://github.com/Astinus-Eberhard @@ -5490,6 +5539,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@derrabus]: https://github.com/derrabus [@deviantintegral]: https://github.com/deviantintegral [@dhensby]: https://github.com/dhensby +[@dingo-d]: https://github.com/dingo-d [@dominics]: https://github.com/dominics [@donatj]: https://github.com/donatj [@dryabkov]: https://github.com/dryabkov @@ -5505,6 +5555,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@exussum12]: https://github.com/exussum12 [@fabacino]: https://github.com/fabacino [@fabre-thibaud]: https://github.com/fabre-thibaud +[@fcool]: https://github.com/fcool [@filips123]: https://github.com/filips123 [@Fischer-Bjoern]: https://github.com/Fischer-Bjoern [@fonsecas72]: https://github.com/fonsecas72 @@ -5553,6 +5604,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@legoktm]: https://github.com/legoktm [@lmanzke]: https://github.com/lmanzke [@localheinz]: https://github.com/localheinz +[@lucc]: https://github.com/lucc [@MacDada]: https://github.com/MacDada [@Majkl578]: https://github.com/Majkl578 [@manuelpichler]: https://github.com/manuelpichler @@ -5595,6 +5647,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@rhorber]: https://github.com/rhorber [@rmccue]: https://github.com/rmccue [@robocoder]: https://github.com/robocoder +[@rodrigoprimo]: https://github.com/rodrigoprimo [@rogeriopradoj]: https://github.com/rogeriopradoj [@rovangju]: https://github.com/rovangju [@rvanvelzen]: https://github.com/rvanvelzen @@ -5606,6 +5659,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@sebastianbergmann]: https://github.com/sebastianbergmann [@sertand]: https://github.com/sertand [@shanethehat]: https://github.com/shanethehat +[@shivammathur]: https://github.com/shivammathur [@simonsan]: https://github.com/simonsan [@sjlangley]: https://github.com/sjlangley [@sserbin]: https://github.com/sserbin From 811773cf1307e953b9f41c205b50ef9b77df50c8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Jan 2024 22:22:23 +0100 Subject: [PATCH 246/874] Config: update version nr to next --- src/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index d92483988b..f2ce8157b6 100644 --- a/src/Config.php +++ b/src/Config.php @@ -81,7 +81,7 @@ class Config * * @var string */ - const VERSION = '3.8.1'; + const VERSION = '3.8.2'; /** * Package stability; either stable, beta or alpha. From 8fd83add5531d51fb8bd776d06b5ee075eafb98f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Jan 2024 22:56:25 +0100 Subject: [PATCH 247/874] GH Actions/test: always run the workflow for tags .. to ensure the PHAR files for the tag are generated. --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 80bb99fde4..970be4bf63 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,8 @@ on: push: branches: - master + tags: + - '**' paths-ignore: - '**.md' pull_request: From 4985221b28a56b4a0ed8e1855fe5781c50a3411a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Jan 2024 23:32:59 +0100 Subject: [PATCH 248/874] Tests: all test classes should be either `final` or `abstract` Classes belonging to the test _framework_ have been exempted at this time. This may be revisited at a later point in time when addressing issue 25. --- src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php | 2 +- .../Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php | 2 +- .../Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php | 2 +- .../Generic/Tests/Classes/DuplicateClassNameUnitTest.php | 2 +- .../Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php | 2 +- .../Tests/CodeAnalysis/AssignmentInConditionUnitTest.php | 2 +- .../Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php | 2 +- .../Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php | 2 +- .../Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php | 2 +- .../Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php | 2 +- .../Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php | 2 +- .../Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php | 2 +- .../Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php | 2 +- .../Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php | 2 +- .../Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php | 2 +- src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php | 2 +- src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php | 2 +- src/Standards/Generic/Tests/Commenting/TodoUnitTest.php | 2 +- .../Tests/ControlStructures/DisallowYodaConditionsUnitTest.php | 2 +- .../Tests/ControlStructures/InlineControlStructureUnitTest.php | 2 +- src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php | 2 +- src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php | 2 +- src/Standards/Generic/Tests/Debug/ESLintUnitTest.php | 2 +- src/Standards/Generic/Tests/Debug/JSHintUnitTest.php | 2 +- src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php | 2 +- src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php | 2 +- src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php | 2 +- src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php | 2 +- src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php | 2 +- src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php | 2 +- src/Standards/Generic/Tests/Files/LineLengthUnitTest.php | 2 +- .../Generic/Tests/Files/LowercasedFilenameUnitTest.php | 2 +- src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php | 2 +- .../Generic/Tests/Files/OneInterfacePerFileUnitTest.php | 2 +- .../Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php | 2 +- src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php | 2 +- .../Tests/Formatting/DisallowMultipleStatementsUnitTest.php | 2 +- .../Tests/Formatting/MultipleStatementAlignmentUnitTest.php | 2 +- .../Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php | 2 +- .../Generic/Tests/Formatting/SpaceAfterCastUnitTest.php | 2 +- .../Generic/Tests/Formatting/SpaceAfterNotUnitTest.php | 2 +- .../Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php | 2 +- .../Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php | 2 +- .../Tests/Functions/FunctionCallArgumentSpacingUnitTest.php | 2 +- .../Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php | 2 +- .../Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php | 2 +- .../Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php | 2 +- src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php | 2 +- .../Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php | 2 +- .../Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php | 2 +- .../Generic/Tests/NamingConventions/ConstructorNameUnitTest.php | 2 +- .../Tests/NamingConventions/InterfaceNameSuffixUnitTest.php | 2 +- .../Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php | 2 +- .../Tests/NamingConventions/UpperCaseConstantNameUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php | 2 +- .../Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php | 2 +- .../Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php | 2 +- .../Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php | 2 +- .../Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php | 2 +- src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php | 2 +- .../Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php | 2 +- .../Generic/Tests/VersionControl/GitMergeConflictUnitTest.php | 2 +- .../Tests/VersionControl/SubversionPropertiesUnitTest.php | 2 +- .../Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php | 2 +- .../Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php | 2 +- .../Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php | 2 +- .../Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php | 2 +- .../Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php | 2 +- src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php | 2 +- .../Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php | 2 +- .../MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php | 2 +- .../MySource/Tests/Channels/DisallowSelfActionsUnitTest.php | 2 +- src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php | 2 +- src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php | 2 +- .../MySource/Tests/Commenting/FunctionCommentUnitTest.php | 2 +- src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php | 2 +- src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php | 2 +- src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php | 2 +- .../MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php | 2 +- .../MySource/Tests/Objects/DisallowNewWidgetUnitTest.php | 2 +- src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php | 2 +- src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php | 2 +- src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php | 2 +- .../MySource/Tests/PHP/ReturnFunctionValueUnitTest.php | 2 +- src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php | 2 +- src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php | 2 +- src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php | 2 +- src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php | 2 +- src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php | 2 +- src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php | 2 +- .../PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php | 2 +- .../PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php | 2 +- src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php | 2 +- .../PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php | 2 +- .../PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php | 2 +- .../PEAR/Tests/Functions/FunctionDeclarationUnitTest.php | 2 +- .../PEAR/Tests/Functions/ValidDefaultValueUnitTest.php | 2 +- .../PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php | 2 +- .../PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php | 2 +- .../PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php | 2 +- .../PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php | 2 +- .../PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php | 2 +- src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php | 2 +- src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php | 2 +- src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php | 2 +- .../PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php | 2 +- .../PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php | 2 +- .../PSR12/Tests/Classes/ClassInstantiationUnitTest.php | 2 +- src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php | 2 +- src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php | 2 +- .../ControlStructures/BooleanOperatorPlacementUnitTest.php | 2 +- .../Tests/ControlStructures/ControlStructureSpacingUnitTest.php | 2 +- src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php | 2 +- src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php | 2 +- src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php | 2 +- src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php | 2 +- .../PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php | 2 +- .../PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php | 2 +- .../PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php | 2 +- .../PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php | 2 +- src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php | 2 +- .../PSR12/Tests/Properties/ConstantVisibilityUnitTest.php | 2 +- src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php | 2 +- src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php | 2 +- .../PSR2/Tests/Classes/PropertyDeclarationUnitTest.php | 2 +- .../Tests/ControlStructures/ControlStructureSpacingUnitTest.php | 2 +- .../PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php | 2 +- .../PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php | 2 +- src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php | 2 +- src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php | 2 +- .../PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php | 2 +- .../PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php | 2 +- src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php | 2 +- .../PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php | 2 +- src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php | 2 +- .../Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php | 2 +- src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php | 2 +- .../Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php | 2 +- .../Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php | 2 +- .../Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php | 2 +- .../Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php | 2 +- .../Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php | 2 +- .../Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php | 2 +- .../Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php | 2 +- src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php | 2 +- src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php | 2 +- src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php | 2 +- src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php | 2 +- .../Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php | 2 +- .../Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php | 2 +- src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php | 2 +- src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php | 2 +- src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php | 2 +- .../Tests/Commenting/ClosingDeclarationCommentUnitTest.php | 2 +- .../Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php | 2 +- .../Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php | 2 +- src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php | 2 +- .../Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php | 2 +- .../Squiz/Tests/Commenting/FunctionCommentUnitTest.php | 2 +- src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php | 2 +- .../Tests/Commenting/LongConditionClosingCommentUnitTest.php | 2 +- .../Squiz/Tests/Commenting/PostStatementCommentUnitTest.php | 2 +- .../Squiz/Tests/Commenting/VariableCommentUnitTest.php | 2 +- .../Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php | 2 +- .../Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php | 2 +- .../Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php | 2 +- .../Tests/ControlStructures/ForLoopDeclarationUnitTest.php | 2 +- .../Tests/ControlStructures/InlineIfDeclarationUnitTest.php | 2 +- .../Tests/ControlStructures/LowercaseDeclarationUnitTest.php | 2 +- .../Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php | 2 +- src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php | 2 +- src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php | 2 +- src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php | 2 +- .../Squiz/Tests/Formatting/OperatorBracketUnitTest.php | 2 +- .../Functions/FunctionDeclarationArgumentSpacingUnitTest.php | 2 +- .../Squiz/Tests/Functions/FunctionDeclarationUnitTest.php | 2 +- .../Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php | 2 +- src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php | 2 +- .../Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php | 2 +- .../Tests/Functions/MultiLineFunctionDeclarationUnitTest.php | 2 +- .../Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php | 2 +- .../Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php | 2 +- .../Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php | 2 +- .../Squiz/Tests/Objects/ObjectInstantiationUnitTest.php | 2 +- src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php | 2 +- .../Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php | 2 +- .../Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php | 2 +- .../Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php | 2 +- .../Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php | 2 +- .../Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php | 2 +- .../Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php | 2 +- .../Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/EvalUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php | 2 +- src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php | 2 +- src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php | 2 +- src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php | 2 +- src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php | 2 +- .../Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php | 2 +- src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php | 2 +- src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php | 2 +- src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php | 2 +- .../Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php | 2 +- .../Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php | 2 +- .../Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php | 2 +- src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php | 2 +- src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php | 2 +- .../Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php | 2 +- tests/Core/Autoloader/DetermineLoadedClassTest.php | 2 +- tests/Core/Config/ReportWidthTest.php | 2 +- tests/Core/ErrorSuppressionTest.php | 2 +- tests/Core/File/FindEndOfStatementTest.php | 2 +- tests/Core/File/FindExtendedClassNameTest.php | 2 +- tests/Core/File/FindImplementedInterfaceNamesTest.php | 2 +- tests/Core/File/FindStartOfStatementTest.php | 2 +- tests/Core/File/GetClassPropertiesTest.php | 2 +- tests/Core/File/GetConditionTest.php | 2 +- tests/Core/File/GetDeclarationNameJSTest.php | 2 +- tests/Core/File/GetDeclarationNameTest.php | 2 +- tests/Core/File/GetMemberPropertiesTest.php | 2 +- tests/Core/File/GetMethodParametersParseError1Test.php | 2 +- tests/Core/File/GetMethodParametersParseError2Test.php | 2 +- tests/Core/File/GetMethodParametersTest.php | 2 +- tests/Core/File/GetMethodPropertiesTest.php | 2 +- tests/Core/File/GetTokensAsStringTest.php | 2 +- tests/Core/File/IsReferenceTest.php | 2 +- tests/Core/Filters/Filter/AcceptTest.php | 2 +- tests/Core/Filters/GitModifiedTest.php | 2 +- tests/Core/Filters/GitStagedTest.php | 2 +- tests/Core/Ruleset/ExplainTest.php | 2 +- tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php | 2 +- tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php | 2 +- tests/Core/Ruleset/RuleInclusionTest.php | 2 +- tests/Core/Ruleset/SetSniffPropertyTest.php | 2 +- tests/Core/Sniffs/AbstractArraySniffTest.php | 2 +- tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php | 2 +- tests/Core/Tokenizer/ArrayKeywordTest.php | 2 +- tests/Core/Tokenizer/AttributesTest.php | 2 +- tests/Core/Tokenizer/BackfillEnumTest.php | 2 +- tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php | 2 +- tests/Core/Tokenizer/BackfillFnTokenTest.php | 2 +- tests/Core/Tokenizer/BackfillMatchTokenTest.php | 2 +- tests/Core/Tokenizer/BackfillNumericSeparatorTest.php | 2 +- tests/Core/Tokenizer/BackfillReadonlyTest.php | 2 +- tests/Core/Tokenizer/BitwiseOrTest.php | 2 +- tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php | 2 +- tests/Core/Tokenizer/DefaultKeywordTest.php | 2 +- tests/Core/Tokenizer/DoubleArrowTest.php | 2 +- tests/Core/Tokenizer/DoubleQuotedStringTest.php | 2 +- tests/Core/Tokenizer/EnumCaseTest.php | 2 +- tests/Core/Tokenizer/FinallyTest.php | 2 +- tests/Core/Tokenizer/GotoLabelTest.php | 2 +- tests/Core/Tokenizer/HeredocNowdocCloserTest.php | 2 +- tests/Core/Tokenizer/HeredocStringTest.php | 2 +- tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php | 2 +- tests/Core/Tokenizer/NullsafeObjectOperatorTest.php | 2 +- tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php | 2 +- tests/Core/Tokenizer/ShortArrayTest.php | 2 +- tests/Core/Tokenizer/StableCommentWhitespaceTest.php | 2 +- tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php | 2 +- tests/Core/Tokenizer/TypeIntersectionTest.php | 2 +- tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php | 2 +- tests/Core/Util/IsCamelCapsTest.php | 2 +- tests/Core/Util/SuggestTypeTest.php | 2 +- 303 files changed, 303 insertions(+), 303 deletions(-) diff --git a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php index 24b36e6b3e..2c0f68de77 100644 --- a/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff */ -class ArrayIndentUnitTest extends AbstractSniffUnitTest +final class ArrayIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php b/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php index 1f67229a4d..7d818ebeeb 100644 --- a/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff */ -class DisallowLongArraySyntaxUnitTest extends AbstractSniffUnitTest +final class DisallowLongArraySyntaxUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php b/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php index 5e88348748..af361f8b2c 100644 --- a/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowShortArraySyntaxSniff */ -class DisallowShortArraySyntaxUnitTest extends AbstractSniffUnitTest +final class DisallowShortArraySyntaxUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php b/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php index ba7b70eca6..48ebdb8e9e 100644 --- a/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php +++ b/src/Standards/Generic/Tests/Classes/DuplicateClassNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Classes\DuplicateClassNameSniff */ -class DuplicateClassNameUnitTest extends AbstractSniffUnitTest +final class DuplicateClassNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php index a2df57736f..451af9b243 100644 --- a/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php +++ b/src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Classes\OpeningBraceSameLineSniff */ -class OpeningBraceSameLineUnitTest extends AbstractSniffUnitTest +final class OpeningBraceSameLineUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php index 5dd5adc6c1..c7f23b5247 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff */ -class AssignmentInConditionUnitTest extends AbstractSniffUnitTest +final class AssignmentInConditionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php index 2c9c5bffe6..1b31b5f288 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyPHPStatementSniff */ -class EmptyPHPStatementUnitTest extends AbstractSniffUnitTest +final class EmptyPHPStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php index 2189d1d7c2..8122aa2a5c 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyStatementUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff */ -class EmptyStatementUnitTest extends AbstractSniffUnitTest +final class EmptyStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php index 8937ea6281..c118e3c7a9 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopShouldBeWhileLoopUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\ForLoopShouldBeWhileLoopSniff */ -class ForLoopShouldBeWhileLoopUnitTest extends AbstractSniffUnitTest +final class ForLoopShouldBeWhileLoopUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php index 29b3b0fa86..a82dcfeb27 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\ForLoopWithTestFunctionCallSniff */ -class ForLoopWithTestFunctionCallUnitTest extends AbstractSniffUnitTest +final class ForLoopWithTestFunctionCallUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php index db5b1e2a4e..b3f65f1564 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\JumbledIncrementerSniff */ -class JumbledIncrementerUnitTest extends AbstractSniffUnitTest +final class JumbledIncrementerUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php index 48815d6868..b6e242d31f 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnconditionalIfStatementUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnconditionalIfStatementSniff */ -class UnconditionalIfStatementUnitTest extends AbstractSniffUnitTest +final class UnconditionalIfStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php index 60acbc9a8e..c35634258c 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnnecessaryFinalModifierSniff */ -class UnnecessaryFinalModifierUnitTest extends AbstractSniffUnitTest +final class UnnecessaryFinalModifierUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php index 298395c5dc..980dad8dac 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnusedFunctionParameterSniff */ -class UnusedFunctionParameterUnitTest extends AbstractSniffUnitTest +final class UnusedFunctionParameterUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php index bd8a99d8fa..ffc0f0674f 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UselessOverridingMethodSniff */ -class UselessOverridingMethodUnitTest extends AbstractSniffUnitTest +final class UselessOverridingMethodUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php index cacef6bc17..fc3b37accc 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\DocCommentSniff */ -class DocCommentUnitTest extends AbstractSniffUnitTest +final class DocCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php index 90ee54c499..3b6cff5312 100644 --- a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\FixmeSniff */ -class FixmeUnitTest extends AbstractSniffUnitTest +final class FixmeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php index d3300fb15c..e617aff922 100644 --- a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\TodoSniff */ -class TodoUnitTest extends AbstractSniffUnitTest +final class TodoUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php index da347410e3..52fc370a68 100644 --- a/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\DisallowYodaConditionsSniff */ -class DisallowYodaConditionsUnitTest extends AbstractSniffUnitTest +final class DisallowYodaConditionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index af4d43ea50..44f1d74716 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\InlineControlStructureSniff */ -class InlineControlStructureUnitTest extends AbstractSniffUnitTest +final class InlineControlStructureUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php b/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php index 4c17ff25e6..83f875cb0f 100644 --- a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\CSSLintSniff */ -class CSSLintUnitTest extends AbstractSniffUnitTest +final class CSSLintUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php b/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php index ca51f1340e..6577f69dfb 100644 --- a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\ClosureLinterSniff */ -class ClosureLinterUnitTest extends AbstractSniffUnitTest +final class ClosureLinterUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php index 584d29c2fa..824beae4ad 100644 --- a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\ESLintSniff */ -class ESLintUnitTest extends AbstractSniffUnitTest +final class ESLintUnitTest extends AbstractSniffUnitTest { /** diff --git a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php b/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php index ce980e2334..19c0473a87 100644 --- a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php +++ b/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\JSHintSniff */ -class JSHintUnitTest extends AbstractSniffUnitTest +final class JSHintUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php index b663e2aa00..3d80c618f6 100644 --- a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ByteOrderMarkSniff */ -class ByteOrderMarkUnitTest extends AbstractSniffUnitTest +final class ByteOrderMarkUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php index f32100b833..2db35a195a 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\EndFileNewlineSniff */ -class EndFileNewlineUnitTest extends AbstractSniffUnitTest +final class EndFileNewlineUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php index e0b94a05f7..e41aa51bc9 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\EndFileNoNewlineSniff */ -class EndFileNoNewlineUnitTest extends AbstractSniffUnitTest +final class EndFileNoNewlineUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php index c42308e235..86767a73b1 100644 --- a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ExecutableFileSniff */ -class ExecutableFileUnitTest extends AbstractSniffUnitTest +final class ExecutableFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php index 570c68822c..3e716061d3 100644 --- a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php +++ b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\InlineHTMLSniff */ -class InlineHTMLUnitTest extends AbstractSniffUnitTest +final class InlineHTMLUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php index bf6289dbe2..ca20a78486 100644 --- a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineEndingsSniff */ -class LineEndingsUnitTest extends AbstractSniffUnitTest +final class LineEndingsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php index bac731eb45..4b86d46017 100644 --- a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff */ -class LineLengthUnitTest extends AbstractSniffUnitTest +final class LineLengthUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php index 0dd18292f6..894a86dfed 100644 --- a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LowercasedFilenameSniff */ -class LowercasedFilenameUnitTest extends AbstractSniffUnitTest +final class LowercasedFilenameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php index 5ad4dc932e..eb3cf49750 100644 --- a/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneClassPerFileUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneClassPerFileSniff */ -class OneClassPerFileUnitTest extends AbstractSniffUnitTest +final class OneClassPerFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php index 35d5139008..b6a62b18c3 100644 --- a/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneInterfacePerFileUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneInterfacePerFileSniff */ -class OneInterfacePerFileUnitTest extends AbstractSniffUnitTest +final class OneInterfacePerFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php index 083c8a62ee..d0e618a822 100644 --- a/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneObjectStructurePerFileUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneObjectStructurePerFileSniff */ -class OneObjectStructurePerFileUnitTest extends AbstractSniffUnitTest +final class OneObjectStructurePerFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php b/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php index 26c4a5a763..38f50a47c8 100644 --- a/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\OneTraitPerFileSniff */ -class OneTraitPerFileUnitTest extends AbstractSniffUnitTest +final class OneTraitPerFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php b/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php index cc919d2ec7..d9c32f83af 100644 --- a/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/DisallowMultipleStatementsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\DisallowMultipleStatementsSniff */ -class DisallowMultipleStatementsUnitTest extends AbstractSniffUnitTest +final class DisallowMultipleStatementsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php index b27a7b0306..e2b5e0c5df 100644 --- a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\MultipleStatementAlignmentSniff */ -class MultipleStatementAlignmentUnitTest extends AbstractSniffUnitTest +final class MultipleStatementAlignmentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php index 535cf18801..e449811eb2 100644 --- a/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/NoSpaceAfterCastUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\NoSpaceAfterCastSniff */ -class NoSpaceAfterCastUnitTest extends AbstractSniffUnitTest +final class NoSpaceAfterCastUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php index 287f4bb5d8..36e444b647 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff */ -class SpaceAfterCastUnitTest extends AbstractSniffUnitTest +final class SpaceAfterCastUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php index cf62c9294c..f79cc7b987 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterNotSniff */ -class SpaceAfterNotUnitTest extends AbstractSniffUnitTest +final class SpaceAfterNotUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php index 3bf5944e0a..5165409d56 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceBeforeCastUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceBeforeCastSniff */ -class SpaceBeforeCastUnitTest extends AbstractSniffUnitTest +final class SpaceBeforeCastUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php b/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php index faa37c31ae..4f9198b3d4 100644 --- a/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\CallTimePassByReferenceSniff */ -class CallTimePassByReferenceUnitTest extends AbstractSniffUnitTest +final class CallTimePassByReferenceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php index e325f7f1fb..f630965f37 100644 --- a/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\FunctionCallArgumentSpacingSniff */ -class FunctionCallArgumentSpacingUnitTest extends AbstractSniffUnitTest +final class FunctionCallArgumentSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php index 160adb22fb..0c6c4af1ec 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\OpeningFunctionBraceBsdAllmanSniff */ -class OpeningFunctionBraceBsdAllmanUnitTest extends AbstractSniffUnitTest +final class OpeningFunctionBraceBsdAllmanUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php index 53ef2a358e..f98430768f 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\OpeningFunctionBraceKernighanRitchieSniff */ -class OpeningFunctionBraceKernighanRitchieUnitTest extends AbstractSniffUnitTest +final class OpeningFunctionBraceKernighanRitchieUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php index 733f9258aa..950ba3eec3 100644 --- a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff */ -class CyclomaticComplexityUnitTest extends AbstractSniffUnitTest +final class CyclomaticComplexityUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php index 036d1bab8f..fda8d461c7 100644 --- a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff */ -class NestingLevelUnitTest extends AbstractSniffUnitTest +final class NestingLevelUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php index 90350bdfd4..0f7ef0939a 100644 --- a/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.php @@ -15,7 +15,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\AbstractClassNamePrefixSniff */ -class AbstractClassNamePrefixUnitTest extends AbstractSniffUnitTest +final class AbstractClassNamePrefixUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php index 716a423813..777d81c711 100644 --- a/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff */ -class CamelCapsFunctionNameUnitTest extends AbstractSniffUnitTest +final class CamelCapsFunctionNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php index 54c3213e27..616f651347 100644 --- a/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\ConstructorNameSniff */ -class ConstructorNameUnitTest extends AbstractSniffUnitTest +final class ConstructorNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php index 8411c7246b..e5a4c3c597 100644 --- a/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/InterfaceNameSuffixUnitTest.php @@ -15,7 +15,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\InterfaceNameSuffixSniff */ -class InterfaceNameSuffixUnitTest extends AbstractSniffUnitTest +final class InterfaceNameSuffixUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php index 351714862b..efef8df6e6 100644 --- a/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/TraitNameSuffixUnitTest.php @@ -15,7 +15,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\TraitNameSuffixSniff */ -class TraitNameSuffixUnitTest extends AbstractSniffUnitTest +final class TraitNameSuffixUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php index de352ce227..907d8bb5be 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\UpperCaseConstantNameSniff */ -class UpperCaseConstantNameUnitTest extends AbstractSniffUnitTest +final class UpperCaseConstantNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php b/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php index fdbb55f3af..b2d3c8239d 100644 --- a/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/BacktickOperatorUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\BacktickOperatorSniff */ -class BacktickOperatorUnitTest extends AbstractSniffUnitTest +final class BacktickOperatorUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php b/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php index 69b8437e53..8fce995ab9 100644 --- a/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\CharacterBeforePHPOpeningTagSniff */ -class CharacterBeforePHPOpeningTagUnitTest extends AbstractSniffUnitTest +final class CharacterBeforePHPOpeningTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php b/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php index 2e7c779c9d..35df704b60 100644 --- a/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ClosingPHPTagSniff */ -class ClosingPHPTagUnitTest extends AbstractSniffUnitTest +final class ClosingPHPTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php b/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php index 1b82da5f10..4b6f6ef540 100644 --- a/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DeprecatedFunctionsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DeprecatedFunctionsSniff */ -class DeprecatedFunctionsUnitTest extends AbstractSniffUnitTest +final class DeprecatedFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php index 212f08a09b..8dd6deb97b 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowAlternativePHPTagsSniff */ -class DisallowAlternativePHPTagsUnitTest extends AbstractSniffUnitTest +final class DisallowAlternativePHPTagsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php index b54405ee2f..15510a6915 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowRequestSuperglobalUnitTest.php @@ -15,7 +15,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowRequestSuperglobalSniff */ -class DisallowRequestSuperglobalUnitTest extends AbstractSniffUnitTest +final class DisallowRequestSuperglobalUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php index 7d11b0b1fd..a8955d6991 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowShortOpenTagSniff */ -class DisallowShortOpenTagUnitTest extends AbstractSniffUnitTest +final class DisallowShortOpenTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php b/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php index 315c236158..36db20dbc3 100644 --- a/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DiscourageGotoUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DiscourageGotoSniff */ -class DiscourageGotoUnitTest extends AbstractSniffUnitTest +final class DiscourageGotoUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php b/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php index 06be9d758f..cb09313125 100644 --- a/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff */ -class ForbiddenFunctionsUnitTest extends AbstractSniffUnitTest +final class ForbiddenFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php index fac155c459..0d1ea8b2ab 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseConstantSniff */ -class LowerCaseConstantUnitTest extends AbstractSniffUnitTest +final class LowerCaseConstantUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php index a7b708e36b..17f0e25d3e 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseKeywordSniff */ -class LowerCaseKeywordUnitTest extends AbstractSniffUnitTest +final class LowerCaseKeywordUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php index 4e6ccc3bed..0eaf7f5319 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseTypeSniff */ -class LowerCaseTypeUnitTest extends AbstractSniffUnitTest +final class LowerCaseTypeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php index 43f762812b..b4e383c360 100644 --- a/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/NoSilencedErrorsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\NoSilencedErrorsSniff */ -class NoSilencedErrorsUnitTest extends AbstractSniffUnitTest +final class NoSilencedErrorsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php index c311266d3f..9ef6ad8c4e 100644 --- a/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\RequireStrictTypesSniff */ -class RequireStrictTypesUnitTest extends AbstractSniffUnitTest +final class RequireStrictTypesUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php b/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php index 9835b061ec..9ee274b6f1 100644 --- a/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SAPIUsageSniff */ -class SAPIUsageUnitTest extends AbstractSniffUnitTest +final class SAPIUsageUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php b/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php index 0069cf5756..58433eb1d1 100644 --- a/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SyntaxSniff */ -class SyntaxUnitTest extends AbstractSniffUnitTest +final class SyntaxUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php index dcfe801429..481c4ab1c7 100644 --- a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\UpperCaseConstantSniff */ -class UpperCaseConstantUnitTest extends AbstractSniffUnitTest +final class UpperCaseConstantUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php index ce08934bdf..c08918d15c 100644 --- a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php +++ b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Strings\UnnecessaryStringConcatSniff */ -class UnnecessaryStringConcatUnitTest extends AbstractSniffUnitTest +final class UnnecessaryStringConcatUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php index f67518258d..bc96638499 100644 --- a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php +++ b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\GitMergeConflictSniff */ -class GitMergeConflictUnitTest extends AbstractSniffUnitTest +final class GitMergeConflictUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php b/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php index 32c7fc9d16..7be9cc0ed5 100644 --- a/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php +++ b/src/Standards/Generic/Tests/VersionControl/SubversionPropertiesUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\SubversionPropertiesSniff */ -class SubversionPropertiesUnitTest extends AbstractSniffUnitTest +final class SubversionPropertiesUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php index 488754337d..64ca21a938 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ArbitraryParenthesesSpacingSniff */ -class ArbitraryParenthesesSpacingUnitTest extends AbstractSniffUnitTest +final class ArbitraryParenthesesSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php index 799568a1f7..2f21d2eef9 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\DisallowSpaceIndentSniff */ -class DisallowSpaceIndentUnitTest extends AbstractSniffUnitTest +final class DisallowSpaceIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php index de688e0867..94b833d657 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\DisallowTabIndentSniff */ -class DisallowTabIndentUnitTest extends AbstractSniffUnitTest +final class DisallowTabIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php index ce6e114da6..e6fee9b962 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\IncrementDecrementSpacingSniff */ -class IncrementDecrementSpacingUnitTest extends AbstractSniffUnitTest +final class IncrementDecrementSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php index 0ac7e6d815..adac2c843f 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\LanguageConstructSpacingSniff */ -class LanguageConstructSpacingUnitTest extends AbstractSniffUnitTest +final class LanguageConstructSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index feb4fd67c0..2533b434c0 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff */ -class ScopeIndentUnitTest extends AbstractSniffUnitTest +final class ScopeIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php index 7192f668bf..90842320e2 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\SpreadOperatorSpacingAfterSniff */ -class SpreadOperatorSpacingAfterUnitTest extends AbstractSniffUnitTest +final class SpreadOperatorSpacingAfterUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php b/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php index 30049591dd..7f10457c4b 100644 --- a/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php +++ b/src/Standards/MySource/Tests/CSS/BrowserSpecificStylesUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\CSS\BrowserSpecificStylesSniff */ -class BrowserSpecificStylesUnitTest extends AbstractSniffUnitTest +final class BrowserSpecificStylesUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php b/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php index 9233a2f5b0..30a62d1363 100644 --- a/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/DisallowSelfActionsUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Channels\DisallowSelfActionsSniff */ -class DisallowSelfActionsUnitTest extends AbstractSniffUnitTest +final class DisallowSelfActionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php b/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php index 407535655e..635054d3f4 100644 --- a/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/IncludeSystemUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Channels\IncludeSystemSniff */ -class IncludeSystemUnitTest extends AbstractSniffUnitTest +final class IncludeSystemUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php b/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php index b3455ac3fd..05359a4825 100644 --- a/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php +++ b/src/Standards/MySource/Tests/Channels/UnusedSystemUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Channels\UnusedSystemSniff */ -class UnusedSystemUnitTest extends AbstractSniffUnitTest +final class UnusedSystemUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php index 8a3d706615..07c62a9564 100644 --- a/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/MySource/Tests/Commenting/FunctionCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Commenting\FunctionCommentSniff */ -class FunctionCommentUnitTest extends AbstractSniffUnitTest +final class FunctionCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php b/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php index d8f80118ed..1f85b23e5e 100644 --- a/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php +++ b/src/Standards/MySource/Tests/Debug/DebugCodeUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Debug\DebugCodeSniff */ -class DebugCodeUnitTest extends AbstractSniffUnitTest +final class DebugCodeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php b/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php index 3a88a0ecdf..8b9d60435a 100644 --- a/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php +++ b/src/Standards/MySource/Tests/Debug/FirebugConsoleUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Debug\FirebugConsoleSniff */ -class FirebugConsoleUnitTest extends AbstractSniffUnitTest +final class FirebugConsoleUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php b/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php index 4b056a7faa..7e44a85788 100644 --- a/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/AssignThisUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Objects\AssignThisSniff */ -class AssignThisUnitTest extends AbstractSniffUnitTest +final class AssignThisUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php b/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php index 55b93375a9..5c9ca8e51d 100644 --- a/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Objects\CreateWidgetTypeCallbackSniff */ -class CreateWidgetTypeCallbackUnitTest extends AbstractSniffUnitTest +final class CreateWidgetTypeCallbackUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php b/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php index 3fa2453228..049356048a 100644 --- a/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php +++ b/src/Standards/MySource/Tests/Objects/DisallowNewWidgetUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Objects\DisallowNewWidgetSniff */ -class DisallowNewWidgetUnitTest extends AbstractSniffUnitTest +final class DisallowNewWidgetUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php b/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php index 606b9f40cb..fa39de07ed 100644 --- a/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\PHP\AjaxNullComparisonSniff */ -class AjaxNullComparisonUnitTest extends AbstractSniffUnitTest +final class AjaxNullComparisonUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php b/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php index 85a8c3c0a8..e98ee2857f 100644 --- a/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/EvalObjectFactoryUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\PHP\EvalObjectFactorySniff */ -class EvalObjectFactoryUnitTest extends AbstractSniffUnitTest +final class EvalObjectFactoryUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php b/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php index 747fae12a4..f079325b05 100644 --- a/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/GetRequestDataUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\PHP\GetRequestDataSniff */ -class GetRequestDataUnitTest extends AbstractSniffUnitTest +final class GetRequestDataUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php b/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php index 3859a03b6b..ce86046109 100644 --- a/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php +++ b/src/Standards/MySource/Tests/PHP/ReturnFunctionValueUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\PHP\ReturnFunctionValueSniff */ -class ReturnFunctionValueUnitTest extends AbstractSniffUnitTest +final class ReturnFunctionValueUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php b/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php index a2c43dce03..b33922330c 100644 --- a/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php +++ b/src/Standards/MySource/Tests/Strings/JoinStringsUnitTest.php @@ -16,7 +16,7 @@ * * @covers PHP_CodeSniffer\Standards\MySource\Sniffs\Strings\JoinStringsSniff */ -class JoinStringsUnitTest extends AbstractSniffUnitTest +final class JoinStringsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php index b751fd8d25..12648cc0a2 100644 --- a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Classes\ClassDeclarationSniff */ -class ClassDeclarationUnitTest extends AbstractSniffUnitTest +final class ClassDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php index 724217662e..d60c0fe83a 100644 --- a/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/ClassCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\ClassCommentSniff */ -class ClassCommentUnitTest extends AbstractSniffUnitTest +final class ClassCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php index 52bcd5872e..661885d29f 100644 --- a/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\FileCommentSniff */ -class FileCommentUnitTest extends AbstractSniffUnitTest +final class FileCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php index bf379c6584..62863be625 100644 --- a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\FunctionCommentSniff */ -class FunctionCommentUnitTest extends AbstractSniffUnitTest +final class FunctionCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php b/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php index ca2ac643d1..457b5d896d 100644 --- a/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php +++ b/src/Standards/PEAR/Tests/Commenting/InlineCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\InlineCommentSniff */ -class InlineCommentUnitTest extends AbstractSniffUnitTest +final class InlineCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php index ef8b946897..b387a93e14 100644 --- a/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\ControlStructures\ControlSignatureSniff */ -class ControlSignatureUnitTest extends AbstractSniffUnitTest +final class ControlSignatureUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php index aadaea9490..263906d189 100644 --- a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php +++ b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\ControlStructures\MultiLineConditionSniff */ -class MultiLineConditionUnitTest extends AbstractSniffUnitTest +final class MultiLineConditionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php b/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php index 5b7aecfdbd..70d63ec428 100644 --- a/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php +++ b/src/Standards/PEAR/Tests/Files/IncludingFileUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Files\IncludingFileSniff */ -class IncludingFileUnitTest extends AbstractSniffUnitTest +final class IncludingFileUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php b/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php index d817996a6f..1be3296c58 100644 --- a/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php +++ b/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Formatting\MultiLineAssignmentSniff */ -class MultiLineAssignmentUnitTest extends AbstractSniffUnitTest +final class MultiLineAssignmentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php index f6d456ac04..5884bd8f7a 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\FunctionCallSignatureSniff */ -class FunctionCallSignatureUnitTest extends AbstractSniffUnitTest +final class FunctionCallSignatureUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php index 43cffff080..04f846bc70 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\FunctionDeclarationSniff */ -class FunctionDeclarationUnitTest extends AbstractSniffUnitTest +final class FunctionDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php b/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php index 5c2450b968..c91e2dc697 100644 --- a/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\ValidDefaultValueSniff */ -class ValidDefaultValueUnitTest extends AbstractSniffUnitTest +final class ValidDefaultValueUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php index 1b38fde7ee..504e8d666c 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidClassNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidClassNameSniff */ -class ValidClassNameUnitTest extends AbstractSniffUnitTest +final class ValidClassNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php index 6d92123827..80a40d4840 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff */ -class ValidFunctionNameUnitTest extends AbstractSniffUnitTest +final class ValidFunctionNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php index 5b3e58f087..c98af3bc51 100644 --- a/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidVariableNameSniff */ -class ValidVariableNameUnitTest extends AbstractSniffUnitTest +final class ValidVariableNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php index fa34ed4899..9beb77feab 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ObjectOperatorIndentSniff */ -class ObjectOperatorIndentUnitTest extends AbstractSniffUnitTest +final class ObjectOperatorIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php index 2683d6b1c1..4568943300 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ScopeClosingBraceSniff */ -class ScopeClosingBraceUnitTest extends AbstractSniffUnitTest +final class ScopeClosingBraceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php index cb350e70d1..3c6fd4a5e5 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ScopeIndentSniff */ -class ScopeIndentUnitTest extends AbstractSniffUnitTest +final class ScopeIndentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php index 46c3a39ed9..b8c2b6cc32 100644 --- a/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR1\Sniffs\Classes\ClassDeclarationSniff */ -class ClassDeclarationUnitTest extends AbstractSniffUnitTest +final class ClassDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php index 73c3c79424..c7408ad2ea 100644 --- a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php +++ b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR1\Sniffs\Files\SideEffectsSniff */ -class SideEffectsUnitTest extends AbstractSniffUnitTest +final class SideEffectsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php b/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php index 3b1efeb2b4..ffbbb36b8c 100644 --- a/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php +++ b/src/Standards/PSR1/Tests/Methods/CamelCapsMethodNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff */ -class CamelCapsMethodNameUnitTest extends AbstractSniffUnitTest +final class CamelCapsMethodNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php index 736d28cfbf..06104444ae 100644 --- a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\AnonClassDeclarationSniff */ -class AnonClassDeclarationUnitTest extends AbstractSniffUnitTest +final class AnonClassDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php b/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php index 1eb233a34a..103569211d 100644 --- a/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClassInstantiationSniff */ -class ClassInstantiationUnitTest extends AbstractSniffUnitTest +final class ClassInstantiationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php b/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php index ba4be7aaa7..196de8f5fb 100644 --- a/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/ClosingBraceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClosingBraceSniff */ -class ClosingBraceUnitTest extends AbstractSniffUnitTest +final class ClosingBraceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php b/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php index 212861e63b..c4315fb5cc 100644 --- a/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/OpeningBraceSpaceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\OpeningBraceSpaceSniff */ -class OpeningBraceSpaceUnitTest extends AbstractSniffUnitTest +final class OpeningBraceSpaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php b/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php index f7adc003d4..957ea546df 100644 --- a/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php +++ b/src/Standards/PSR12/Tests/ControlStructures/BooleanOperatorPlacementUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures\BooleanOperatorPlacementSniff */ -class BooleanOperatorPlacementUnitTest extends AbstractSniffUnitTest +final class BooleanOperatorPlacementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php b/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php index a3ada241da..69ef8b7c36 100644 --- a/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php +++ b/src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures\ControlStructureSpacingSniff */ -class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest +final class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php index 2218b8e918..3fbf8760f0 100644 --- a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\DeclareStatementSniff */ -class DeclareStatementUnitTest extends AbstractSniffUnitTest +final class DeclareStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php b/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php index 58f1ec918f..01122342a3 100644 --- a/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/FileHeaderUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\FileHeaderSniff */ -class FileHeaderUnitTest extends AbstractSniffUnitTest +final class FileHeaderUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php b/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php index 3774a433cd..86bca2d0c4 100644 --- a/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/ImportStatementUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\ImportStatementSniff */ -class ImportStatementUnitTest extends AbstractSniffUnitTest +final class ImportStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php b/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php index 815a4c23d5..898334e443 100644 --- a/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/OpenTagUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Files\OpenTagSniff */ -class OpenTagUnitTest extends AbstractSniffUnitTest +final class OpenTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php index ff3e105aa1..828ec4d8c7 100644 --- a/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Functions\NullableTypeDeclarationSniff */ -class NullableTypeDeclarationUnitTest extends AbstractSniffUnitTest +final class NullableTypeDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php index ce059e024e..d2962e8d13 100644 --- a/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Functions/ReturnTypeDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Functions\ReturnTypeDeclarationSniff */ -class ReturnTypeDeclarationUnitTest extends AbstractSniffUnitTest +final class ReturnTypeDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php b/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php index 5713520f77..e0fc38f475 100644 --- a/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php +++ b/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Keywords\ShortFormTypeKeywordsSniff */ -class ShortFormTypeKeywordsUnitTest extends AbstractSniffUnitTest +final class ShortFormTypeKeywordsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php b/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php index 367f8aa6d3..4ad77882e6 100644 --- a/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php +++ b/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Namespaces\CompoundNamespaceDepthSniff */ -class CompoundNamespaceDepthUnitTest extends AbstractSniffUnitTest +final class CompoundNamespaceDepthUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php b/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php index 5b17f76616..abcce946cd 100644 --- a/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php +++ b/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators\OperatorSpacingSniff */ -class OperatorSpacingUnitTest extends AbstractSniffUnitTest +final class OperatorSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php b/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php index 98038db6ba..6c39e7cc6b 100644 --- a/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php +++ b/src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Properties\ConstantVisibilitySniff */ -class ConstantVisibilityUnitTest extends AbstractSniffUnitTest +final class ConstantVisibilityUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php index 7689388356..383d59c816 100644 --- a/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Traits/UseDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR12\Sniffs\Traits\UseDeclarationSniff */ -class UseDeclarationUnitTest extends AbstractSniffUnitTest +final class UseDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php index df574cb35c..26e2c8c98e 100644 --- a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\ClassDeclarationSniff */ -class ClassDeclarationUnitTest extends AbstractSniffUnitTest +final class ClassDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php index 377b664fb6..bf7dc29a31 100644 --- a/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\PropertyDeclarationSniff */ -class PropertyDeclarationUnitTest extends AbstractSniffUnitTest +final class PropertyDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php index 0ddd9a4464..a8ab73e1ab 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/ControlStructureSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ControlStructureSpacingSniff */ -class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest +final class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php index d646689637..79d46542f7 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/ElseIfDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ElseIfDeclarationSniff */ -class ElseIfDeclarationUnitTest extends AbstractSniffUnitTest +final class ElseIfDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php index cd4c19f109..a292503dcc 100644 --- a/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff */ -class SwitchDeclarationUnitTest extends AbstractSniffUnitTest +final class SwitchDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php b/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php index b840ec0e17..85ba6e34bb 100644 --- a/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php +++ b/src/Standards/PSR2/Tests/Files/ClosingTagUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\ClosingTagSniff */ -class ClosingTagUnitTest extends AbstractSniffUnitTest +final class ClosingTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php index f50cbf6dbe..9a983e8001 100644 --- a/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\EndFileNewlineSniff */ -class EndFileNewlineUnitTest extends AbstractSniffUnitTest +final class EndFileNewlineUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php b/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php index 6abee067b2..52cda17467 100644 --- a/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/FunctionCallSignatureUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionCallSignatureSniff */ -class FunctionCallSignatureUnitTest extends AbstractSniffUnitTest +final class FunctionCallSignatureUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php b/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php index f3def5279a..d6886ac958 100644 --- a/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/FunctionClosingBraceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionClosingBraceSniff */ -class FunctionClosingBraceUnitTest extends AbstractSniffUnitTest +final class FunctionClosingBraceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php index e3603c68ca..3654a0f647 100644 --- a/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff */ -class MethodDeclarationUnitTest extends AbstractSniffUnitTest +final class MethodDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php index 999b5b49e9..e42822622d 100644 --- a/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Namespaces\NamespaceDeclarationSniff */ -class NamespaceDeclarationUnitTest extends AbstractSniffUnitTest +final class NamespaceDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php index 75aeaab929..9282994809 100644 --- a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Namespaces\UseDeclarationSniff */ -class UseDeclarationUnitTest extends AbstractSniffUnitTest +final class UseDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php b/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php index 14d13a8135..0e687b800f 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Arrays/ArrayBracketSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayBracketSpacingSniff */ -class ArrayBracketSpacingUnitTest extends AbstractSniffUnitTest +final class ArrayBracketSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php index 03a4044f7d..6ec80af373 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayDeclarationSniff */ -class ArrayDeclarationUnitTest extends AbstractSniffUnitTest +final class ArrayDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php index af2f8db0a1..c9770cc161 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ClassDefinitionClosingBraceSpaceSniff */ -class ClassDefinitionClosingBraceSpaceUnitTest extends AbstractSniffUnitTest +final class ClassDefinitionClosingBraceSpaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php index 89c21f3cda..5320047c08 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ClassDefinitionNameSpacingSniff */ -class ClassDefinitionNameSpacingUnitTest extends AbstractSniffUnitTest +final class ClassDefinitionNameSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php index 6e9faebca0..3d5f37bb60 100644 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ClassDefinitionOpeningBraceSpaceSniff */ -class ClassDefinitionOpeningBraceSpaceUnitTest extends AbstractSniffUnitTest +final class ClassDefinitionOpeningBraceSpaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php index 8c79d0c624..222bbe4e18 100644 --- a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ColonSpacingSniff */ -class ColonSpacingUnitTest extends AbstractSniffUnitTest +final class ColonSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php index 100386a73b..44a2d64f7c 100644 --- a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ColourDefinitionSniff */ -class ColourDefinitionUnitTest extends AbstractSniffUnitTest +final class ColourDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php index b9efc5dd59..18abf1a5cd 100644 --- a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\DisallowMultipleStyleDefinitionsSniff */ -class DisallowMultipleStyleDefinitionsUnitTest extends AbstractSniffUnitTest +final class DisallowMultipleStyleDefinitionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php index e6d31f31e3..70bc5b1059 100644 --- a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\DuplicateClassDefinitionSniff */ -class DuplicateClassDefinitionUnitTest extends AbstractSniffUnitTest +final class DuplicateClassDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php index 2b6e04f85c..f7e9e95f09 100644 --- a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\DuplicateStyleDefinitionSniff */ -class DuplicateStyleDefinitionUnitTest extends AbstractSniffUnitTest +final class DuplicateStyleDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php index 767265dd20..b75873002f 100644 --- a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\EmptyClassDefinitionSniff */ -class EmptyClassDefinitionUnitTest extends AbstractSniffUnitTest +final class EmptyClassDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php index cd591e89a1..55ec5331ec 100644 --- a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\EmptyStyleDefinitionSniff */ -class EmptyStyleDefinitionUnitTest extends AbstractSniffUnitTest +final class EmptyStyleDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php index b212aec7fe..f5cdae4367 100644 --- a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ForbiddenStylesSniff */ -class ForbiddenStylesUnitTest extends AbstractSniffUnitTest +final class ForbiddenStylesUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php index 0f4fb5de3b..fe79ffb3e0 100644 --- a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\IndentationSniff */ -class IndentationUnitTest extends AbstractSniffUnitTest +final class IndentationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php index ed2ac53e8b..c47455a143 100644 --- a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\LowercaseStyleDefinitionSniff */ -class LowercaseStyleDefinitionUnitTest extends AbstractSniffUnitTest +final class LowercaseStyleDefinitionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php b/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php index c0ef173881..29e39848b2 100644 --- a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\MissingColonSniff */ -class MissingColonUnitTest extends AbstractSniffUnitTest +final class MissingColonUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php b/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php index 9a2e25fe53..90744d3581 100644 --- a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\NamedColoursSniff */ -class NamedColoursUnitTest extends AbstractSniffUnitTest +final class NamedColoursUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php index c0454a831a..d323477b2d 100644 --- a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\OpacitySniff */ -class OpacityUnitTest extends AbstractSniffUnitTest +final class OpacityUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php index 334fc7b695..ab2c839beb 100644 --- a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\SemicolonSpacingSniff */ -class SemicolonSpacingUnitTest extends AbstractSniffUnitTest +final class SemicolonSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php index 9f5a3bb3db..91ba7fb092 100644 --- a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ShorthandSizeSniff */ -class ShorthandSizeUnitTest extends AbstractSniffUnitTest +final class ShorthandSizeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php index df35d2b2b2..635fd5d10a 100644 --- a/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ClassDeclarationSniff */ -class ClassDeclarationUnitTest extends AbstractSniffUnitTest +final class ClassDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php index 1d64fc5e11..7a01e9c09f 100644 --- a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ClassFileNameSniff */ -class ClassFileNameUnitTest extends AbstractSniffUnitTest +final class ClassFileNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php b/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php index a1cfd5b093..567a89cc29 100644 --- a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\DuplicatePropertySniff */ -class DuplicatePropertyUnitTest extends AbstractSniffUnitTest +final class DuplicatePropertyUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php index ed6517aacf..9bbc66fb1d 100644 --- a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\LowercaseClassKeywordsSniff */ -class LowercaseClassKeywordsUnitTest extends AbstractSniffUnitTest +final class LowercaseClassKeywordsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php b/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php index 703dff3868..72760a5e96 100644 --- a/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/SelfMemberReferenceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\SelfMemberReferenceSniff */ -class SelfMemberReferenceUnitTest extends AbstractSniffUnitTest +final class SelfMemberReferenceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php b/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php index e67ca84bb1..8e505a4188 100644 --- a/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff */ -class ValidClassNameUnitTest extends AbstractSniffUnitTest +final class ValidClassNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php index 982e3f8686..3027d6b195 100644 --- a/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\BlockCommentSniff */ -class BlockCommentUnitTest extends AbstractSniffUnitTest +final class BlockCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php index c64983cee4..05f9e8a0f7 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/ClassCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\ClassCommentSniff */ -class ClassCommentUnitTest extends AbstractSniffUnitTest +final class ClassCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php index db38e74df5..6179d79ef9 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\ClosingDeclarationCommentSniff */ -class ClosingDeclarationCommentUnitTest extends AbstractSniffUnitTest +final class ClosingDeclarationCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php index 6eab274482..a1ab9c3278 100644 --- a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\DocCommentAlignmentSniff */ -class DocCommentAlignmentUnitTest extends AbstractSniffUnitTest +final class DocCommentAlignmentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php index 6e795a2c47..06c308e016 100644 --- a/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/EmptyCatchCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\EmptyCatchCommentSniff */ -class EmptyCatchCommentUnitTest extends AbstractSniffUnitTest +final class EmptyCatchCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php index b7b686d73b..d5816bff47 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FileCommentSniff */ -class FileCommentUnitTest extends AbstractSniffUnitTest +final class FileCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php index 3854846445..178b85a267 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentThrowTagSniff */ -class FunctionCommentThrowTagUnitTest extends AbstractSniffUnitTest +final class FunctionCommentThrowTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php index 6433dbe356..0d89db9e5d 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff */ -class FunctionCommentUnitTest extends AbstractSniffUnitTest +final class FunctionCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php index dbaccb2cbe..c559c5ae6b 100644 --- a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\InlineCommentSniff */ -class InlineCommentUnitTest extends AbstractSniffUnitTest +final class InlineCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php index a24a68a266..e2a0f7b00c 100644 --- a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\LongConditionClosingCommentSniff */ -class LongConditionClosingCommentUnitTest extends AbstractSniffUnitTest +final class LongConditionClosingCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php index 7d7f270ab1..b9751f6147 100644 --- a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\PostStatementCommentSniff */ -class PostStatementCommentUnitTest extends AbstractSniffUnitTest +final class PostStatementCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php index 0cb3e1964d..965e3c0310 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\VariableCommentSniff */ -class VariableCommentUnitTest extends AbstractSniffUnitTest +final class VariableCommentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php index 3187047c7c..f20666d976 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ControlSignatureSniff */ -class ControlSignatureUnitTest extends AbstractSniffUnitTest +final class ControlSignatureUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php index e8432b6391..469a942eb5 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ElseIfDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ElseIfDeclarationSniff */ -class ElseIfDeclarationUnitTest extends AbstractSniffUnitTest +final class ElseIfDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php index da7f144470..5e70703ed2 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForEachLoopDeclarationSniff */ -class ForEachLoopDeclarationUnitTest extends AbstractSniffUnitTest +final class ForEachLoopDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php index 5ceba29ed6..af9fd66ee2 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ForLoopDeclarationSniff */ -class ForLoopDeclarationUnitTest extends AbstractSniffUnitTest +final class ForLoopDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php index 0fa7b26b2c..dc4738e0ad 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/InlineIfDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\InlineIfDeclarationSniff */ -class InlineIfDeclarationUnitTest extends AbstractSniffUnitTest +final class InlineIfDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php index 2307f9a7dc..1b30f4fbdc 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/LowercaseDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\LowercaseDeclarationSniff */ -class LowercaseDeclarationUnitTest extends AbstractSniffUnitTest +final class LowercaseDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php index 32f9ce35a5..a7f0e3afad 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\SwitchDeclarationSniff */ -class SwitchDeclarationUnitTest extends AbstractSniffUnitTest +final class SwitchDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php index 5c7b8390fc..c4b14dc2e3 100644 --- a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php +++ b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug\JSLintSniff */ -class JSLintUnitTest extends AbstractSniffUnitTest +final class JSLintUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php index e7221ed77e..96a68d7c8f 100644 --- a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php +++ b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug\JavaScriptLintSniff */ -class JavaScriptLintUnitTest extends AbstractSniffUnitTest +final class JavaScriptLintUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php b/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php index fe6388ab8e..065922547b 100644 --- a/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php +++ b/src/Standards/Squiz/Tests/Files/FileExtensionUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Files\FileExtensionSniff */ -class FileExtensionUnitTest extends AbstractSniffUnitTest +final class FileExtensionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php index ee5af1b9d0..0da136242b 100644 --- a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php +++ b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Formatting\OperatorBracketSniff */ -class OperatorBracketUnitTest extends AbstractSniffUnitTest +final class OperatorBracketUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php index 2981af59fe..62ccfef2ec 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDeclarationArgumentSpacingSniff */ -class FunctionDeclarationArgumentSpacingUnitTest extends AbstractSniffUnitTest +final class FunctionDeclarationArgumentSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php index ffb82011f4..021ebe71dc 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDeclarationSniff */ -class FunctionDeclarationUnitTest extends AbstractSniffUnitTest +final class FunctionDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php index 68ee6be691..f29f809006 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDuplicateArgumentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\FunctionDuplicateArgumentSniff */ -class FunctionDuplicateArgumentUnitTest extends AbstractSniffUnitTest +final class FunctionDuplicateArgumentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php b/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php index 03af0b0fa2..1a07791567 100644 --- a/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/GlobalFunctionUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\GlobalFunctionSniff */ -class GlobalFunctionUnitTest extends AbstractSniffUnitTest +final class GlobalFunctionUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php b/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php index 11b21ba425..c91c3008c9 100644 --- a/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/LowercaseFunctionKeywordsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\LowercaseFunctionKeywordsSniff */ -class LowercaseFunctionKeywordsUnitTest extends AbstractSniffUnitTest +final class LowercaseFunctionKeywordsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php index 1dd5cca225..30490345d4 100644 --- a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions\MultiLineFunctionDeclarationSniff */ -class MultiLineFunctionDeclarationUnitTest extends AbstractSniffUnitTest +final class MultiLineFunctionDeclarationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php index c3dce6cfe5..7b9692e7a8 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidFunctionNameSniff */ -class ValidFunctionNameUnitTest extends AbstractSniffUnitTest +final class ValidFunctionNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php index 0638d9df4b..d8d8695c6e 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidVariableNameSniff */ -class ValidVariableNameUnitTest extends AbstractSniffUnitTest +final class ValidVariableNameUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php index f3a71f754d..36880a9a58 100644 --- a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects\DisallowObjectStringIndexSniff */ -class DisallowObjectStringIndexUnitTest extends AbstractSniffUnitTest +final class DisallowObjectStringIndexUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php b/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php index 231dd606f4..bfd4bef29c 100644 --- a/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects\ObjectInstantiationSniff */ -class ObjectInstantiationUnitTest extends AbstractSniffUnitTest +final class ObjectInstantiationUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php index 347c69a623..0ac826f3ad 100644 --- a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php +++ b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects\ObjectMemberCommaSniff */ -class ObjectMemberCommaUnitTest extends AbstractSniffUnitTest +final class ObjectMemberCommaUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php index ffaf905d90..1189725bcf 100644 --- a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators\ComparisonOperatorUsageSniff */ -class ComparisonOperatorUsageUnitTest extends AbstractSniffUnitTest +final class ComparisonOperatorUsageUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php index 0393bafe8d..037fee96c2 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators\IncrementDecrementUsageSniff */ -class IncrementDecrementUsageUnitTest extends AbstractSniffUnitTest +final class IncrementDecrementUsageUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php b/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php index e91f951443..d7ce889e3c 100644 --- a/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/ValidLogicalOperatorsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators\ValidLogicalOperatorsSniff */ -class ValidLogicalOperatorsUnitTest extends AbstractSniffUnitTest +final class ValidLogicalOperatorsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php index 148d13882f..99d8f01ace 100644 --- a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\CommentedOutCodeSniff */ -class CommentedOutCodeUnitTest extends AbstractSniffUnitTest +final class CommentedOutCodeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php index d2122d420a..8c3afa4de6 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowBooleanStatementUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowBooleanStatementSniff */ -class DisallowBooleanStatementUnitTest extends AbstractSniffUnitTest +final class DisallowBooleanStatementUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php index e26f7d09f6..9c0f7e3365 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowComparisonAssignmentSniff */ -class DisallowComparisonAssignmentUnitTest extends AbstractSniffUnitTest +final class DisallowComparisonAssignmentUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php index 7e78e97395..14f79c87e2 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowInlineIfSniff */ -class DisallowInlineIfUnitTest extends AbstractSniffUnitTest +final class DisallowInlineIfUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php index c89656d2f5..6da39a5bce 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowMultipleAssignmentsSniff */ -class DisallowMultipleAssignmentsUnitTest extends AbstractSniffUnitTest +final class DisallowMultipleAssignmentsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php index 8ec0b73c89..3f923ad6b0 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DisallowSizeFunctionsInLoopsSniff */ -class DisallowSizeFunctionsInLoopsUnitTest extends AbstractSniffUnitTest +final class DisallowSizeFunctionsInLoopsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php index 7712e438ff..7351b2b45c 100644 --- a/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DiscouragedFunctionsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\DiscouragedFunctionsSniff */ -class DiscouragedFunctionsUnitTest extends AbstractSniffUnitTest +final class DiscouragedFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php index dd13cb1753..8944fc2aee 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\EmbeddedPhpSniff */ -class EmbeddedPhpUnitTest extends AbstractSniffUnitTest +final class EmbeddedPhpUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php b/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php index 277cef9ebe..db0af7f041 100644 --- a/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EvalUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\EvalSniff */ -class EvalUnitTest extends AbstractSniffUnitTest +final class EvalUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php b/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php index 0f602d841f..c0c79baa65 100644 --- a/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/GlobalKeywordUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\GlobalKeywordSniff */ -class GlobalKeywordUnitTest extends AbstractSniffUnitTest +final class GlobalKeywordUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php index de2d71e48e..5d78d89380 100644 --- a/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\HeredocSniff */ -class HeredocUnitTest extends AbstractSniffUnitTest +final class HeredocUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php index 3a5309f60d..fff8871e69 100644 --- a/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/InnerFunctionsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\InnerFunctionsSniff */ -class InnerFunctionsUnitTest extends AbstractSniffUnitTest +final class InnerFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php b/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php index 223496d9a7..5feb363f6b 100644 --- a/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\LowercasePHPFunctionsSniff */ -class LowercasePHPFunctionsUnitTest extends AbstractSniffUnitTest +final class LowercasePHPFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php index 275a6c6d64..4b8e0f074f 100644 --- a/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\NonExecutableCodeSniff */ -class NonExecutableCodeUnitTest extends AbstractSniffUnitTest +final class NonExecutableCodeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php b/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php index b269e739e9..e17f9ae7b9 100644 --- a/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MemberVarScopeSniff */ -class MemberVarScopeUnitTest extends AbstractSniffUnitTest +final class MemberVarScopeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php b/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php index 7325bac295..d57ce9d9b8 100644 --- a/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MethodScopeSniff */ -class MethodScopeUnitTest extends AbstractSniffUnitTest +final class MethodScopeUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php b/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php index 9eee8c3cdc..543b569736 100644 --- a/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\StaticThisUsageSniff */ -class StaticThisUsageUnitTest extends AbstractSniffUnitTest +final class StaticThisUsageUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php b/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php index 6d0181fe53..e59da3c6e3 100644 --- a/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/ConcatenationSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Strings\ConcatenationSpacingSniff */ -class ConcatenationSpacingUnitTest extends AbstractSniffUnitTest +final class ConcatenationSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php index e48dada95a..df50beee1a 100644 --- a/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Strings\DoubleQuoteUsageSniff */ -class DoubleQuoteUsageUnitTest extends AbstractSniffUnitTest +final class DoubleQuoteUsageUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php b/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php index 272275250e..dd8ead06a3 100644 --- a/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php +++ b/src/Standards/Squiz/Tests/Strings/EchoedStringsUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Strings\EchoedStringsSniff */ -class EchoedStringsUnitTest extends AbstractSniffUnitTest +final class EchoedStringsUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php index 25465ca477..38dba6d424 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/CastSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\CastSpacingSniff */ -class CastSpacingUnitTest extends AbstractSniffUnitTest +final class CastSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php index f3820bba8e..c5567cb723 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ControlStructureSpacingSniff */ -class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest +final class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php index 90fd2ae2b3..cb5cf061dc 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionClosingBraceSpaceSniff */ -class FunctionClosingBraceSpaceUnitTest extends AbstractSniffUnitTest +final class FunctionClosingBraceSpaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php index c5525abba7..dcfb3dd17b 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionOpeningBraceSpaceSniff */ -class FunctionOpeningBraceSpaceUnitTest extends AbstractSniffUnitTest +final class FunctionOpeningBraceSpaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php index d58eb8c6f2..cc6d96d256 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionSpacingSniff */ -class FunctionSpacingUnitTest extends AbstractSniffUnitTest +final class FunctionSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php index 196beaceb9..f5d6c61f7a 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LanguageConstructSpacingSniff */ -class LanguageConstructSpacingUnitTest extends AbstractSniffUnitTest +final class LanguageConstructSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php index 1c985ef8cd..31158fd270 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LogicalOperatorSpacingSniff */ -class LogicalOperatorSpacingUnitTest extends AbstractSniffUnitTest +final class LogicalOperatorSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php index fd3f77d055..548ee3baa8 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\MemberVarSpacingSniff */ -class MemberVarSpacingUnitTest extends AbstractSniffUnitTest +final class MemberVarSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php index 31f6a3ffec..c1ef24a42e 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ObjectOperatorSpacingSniff */ -class ObjectOperatorSpacingUnitTest extends AbstractSniffUnitTest +final class ObjectOperatorSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php index 66b780a74e..e9a50c7e7d 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\OperatorSpacingSniff */ -class OperatorSpacingUnitTest extends AbstractSniffUnitTest +final class OperatorSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php index 32561da9c6..5c20b00104 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\PropertyLabelSpacingSniff */ -class PropertyLabelSpacingUnitTest extends AbstractSniffUnitTest +final class PropertyLabelSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php index 5a845086e5..0729624c94 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ScopeClosingBraceSniff */ -class ScopeClosingBraceUnitTest extends AbstractSniffUnitTest +final class ScopeClosingBraceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php index 35e14e4d11..52bd129ace 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ScopeKeywordSpacingSniff */ -class ScopeKeywordSpacingUnitTest extends AbstractSniffUnitTest +final class ScopeKeywordSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php index 2f31ffb8bc..218666dc09 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SemicolonSpacingSniff */ -class SemicolonSpacingUnitTest extends AbstractSniffUnitTest +final class SemicolonSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php index 7064de21df..4f7c7cdbcf 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff */ -class SuperfluousWhitespaceUnitTest extends AbstractSniffUnitTest +final class SuperfluousWhitespaceUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php b/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php index ec0e849424..82781a7d60 100644 --- a/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php +++ b/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Standards\Zend\Sniffs\Debug\CodeAnalyzerSniff */ -class CodeAnalyzerUnitTest extends AbstractSniffUnitTest +final class CodeAnalyzerUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php b/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php index f20aef4092..0a031486bf 100644 --- a/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php +++ b/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Zend\Sniffs\Files\ClosingTagSniff */ -class ClosingTagUnitTest extends AbstractSniffUnitTest +final class ClosingTagUnitTest extends AbstractSniffUnitTest { diff --git a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php index 1df307ef69..94316dad18 100644 --- a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Standards\Zend\Sniffs\NamingConventions\ValidVariableNameSniff */ -class ValidVariableNameUnitTest extends AbstractSniffUnitTest +final class ValidVariableNameUnitTest extends AbstractSniffUnitTest { diff --git a/tests/Core/Autoloader/DetermineLoadedClassTest.php b/tests/Core/Autoloader/DetermineLoadedClassTest.php index 44a4cef079..ea40a5402d 100644 --- a/tests/Core/Autoloader/DetermineLoadedClassTest.php +++ b/tests/Core/Autoloader/DetermineLoadedClassTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Autoload::determineLoadedClass */ -class DetermineLoadedClassTest extends TestCase +final class DetermineLoadedClassTest extends TestCase { diff --git a/tests/Core/Config/ReportWidthTest.php b/tests/Core/Config/ReportWidthTest.php index c46dc22e6b..c89bf85b2e 100644 --- a/tests/Core/Config/ReportWidthTest.php +++ b/tests/Core/Config/ReportWidthTest.php @@ -18,7 +18,7 @@ * * @covers \PHP_CodeSniffer\Config::__get */ -class ReportWidthTest extends TestCase +final class ReportWidthTest extends TestCase { diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index 7fc28d0e2e..e18271a3ef 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -19,7 +19,7 @@ * * @coversNothing */ -class ErrorSuppressionTest extends TestCase +final class ErrorSuppressionTest extends TestCase { diff --git a/tests/Core/File/FindEndOfStatementTest.php b/tests/Core/File/FindEndOfStatementTest.php index 6296db6756..ba04cd591a 100644 --- a/tests/Core/File/FindEndOfStatementTest.php +++ b/tests/Core/File/FindEndOfStatementTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::findEndOfStatement */ -class FindEndOfStatementTest extends AbstractMethodUnitTest +final class FindEndOfStatementTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/FindExtendedClassNameTest.php b/tests/Core/File/FindExtendedClassNameTest.php index be13208908..f26b616790 100644 --- a/tests/Core/File/FindExtendedClassNameTest.php +++ b/tests/Core/File/FindExtendedClassNameTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::findExtendedClassName */ -class FindExtendedClassNameTest extends AbstractMethodUnitTest +final class FindExtendedClassNameTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.php b/tests/Core/File/FindImplementedInterfaceNamesTest.php index 5b0ed7bc8c..e96b6f956d 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.php +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::findImplementedInterfaceNames */ -class FindImplementedInterfaceNamesTest extends AbstractMethodUnitTest +final class FindImplementedInterfaceNamesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/FindStartOfStatementTest.php b/tests/Core/File/FindStartOfStatementTest.php index 334d05b2b3..c674a602d1 100644 --- a/tests/Core/File/FindStartOfStatementTest.php +++ b/tests/Core/File/FindStartOfStatementTest.php @@ -18,7 +18,7 @@ * * @covers \PHP_CodeSniffer\Files\File::findStartOfStatement */ -class FindStartOfStatementTest extends AbstractMethodUnitTest +final class FindStartOfStatementTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetClassPropertiesTest.php b/tests/Core/File/GetClassPropertiesTest.php index 1cb963c4b1..5d182807b1 100644 --- a/tests/Core/File/GetClassPropertiesTest.php +++ b/tests/Core/File/GetClassPropertiesTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::getClassProperties */ -class GetClassPropertiesTest extends AbstractMethodUnitTest +final class GetClassPropertiesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetConditionTest.php b/tests/Core/File/GetConditionTest.php index e6b01192c5..5df0f5a276 100644 --- a/tests/Core/File/GetConditionTest.php +++ b/tests/Core/File/GetConditionTest.php @@ -18,7 +18,7 @@ * @covers \PHP_CodeSniffer\Files\File::getCondition * @covers \PHP_CodeSniffer\Files\File::hasCondition */ -class GetConditionTest extends AbstractMethodUnitTest +final class GetConditionTest extends AbstractMethodUnitTest { /** diff --git a/tests/Core/File/GetDeclarationNameJSTest.php b/tests/Core/File/GetDeclarationNameJSTest.php index a2b8968583..af3fe56d2d 100644 --- a/tests/Core/File/GetDeclarationNameJSTest.php +++ b/tests/Core/File/GetDeclarationNameJSTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::getDeclarationName */ -class GetDeclarationNameJSTest extends AbstractMethodUnitTest +final class GetDeclarationNameJSTest extends AbstractMethodUnitTest { /** diff --git a/tests/Core/File/GetDeclarationNameTest.php b/tests/Core/File/GetDeclarationNameTest.php index 03736ba7ab..19c798f50e 100644 --- a/tests/Core/File/GetDeclarationNameTest.php +++ b/tests/Core/File/GetDeclarationNameTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::getDeclarationName */ -class GetDeclarationNameTest extends AbstractMethodUnitTest +final class GetDeclarationNameTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index 24a170ae92..df4973ceeb 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::getMemberProperties */ -class GetMemberPropertiesTest extends AbstractMethodUnitTest +final class GetMemberPropertiesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMethodParametersParseError1Test.php b/tests/Core/File/GetMethodParametersParseError1Test.php index 393fe9ba76..528d548733 100644 --- a/tests/Core/File/GetMethodParametersParseError1Test.php +++ b/tests/Core/File/GetMethodParametersParseError1Test.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::getMethodParameters */ -class GetMethodParametersParseError1Test extends AbstractMethodUnitTest +final class GetMethodParametersParseError1Test extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMethodParametersParseError2Test.php b/tests/Core/File/GetMethodParametersParseError2Test.php index 0f6e12e654..49cd940592 100644 --- a/tests/Core/File/GetMethodParametersParseError2Test.php +++ b/tests/Core/File/GetMethodParametersParseError2Test.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::getMethodParameters */ -class GetMethodParametersParseError2Test extends AbstractMethodUnitTest +final class GetMethodParametersParseError2Test extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMethodParametersTest.php b/tests/Core/File/GetMethodParametersTest.php index d0b75a94b6..9b920dc703 100644 --- a/tests/Core/File/GetMethodParametersTest.php +++ b/tests/Core/File/GetMethodParametersTest.php @@ -18,7 +18,7 @@ * * @covers \PHP_CodeSniffer\Files\File::getMethodParameters */ -class GetMethodParametersTest extends AbstractMethodUnitTest +final class GetMethodParametersTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMethodPropertiesTest.php b/tests/Core/File/GetMethodPropertiesTest.php index b7c8bc928c..bb861010a3 100644 --- a/tests/Core/File/GetMethodPropertiesTest.php +++ b/tests/Core/File/GetMethodPropertiesTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::getMethodProperties */ -class GetMethodPropertiesTest extends AbstractMethodUnitTest +final class GetMethodPropertiesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetTokensAsStringTest.php b/tests/Core/File/GetTokensAsStringTest.php index 5728c481ed..7db977aaf0 100644 --- a/tests/Core/File/GetTokensAsStringTest.php +++ b/tests/Core/File/GetTokensAsStringTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::getTokensAsString */ -class GetTokensAsStringTest extends AbstractMethodUnitTest +final class GetTokensAsStringTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/IsReferenceTest.php b/tests/Core/File/IsReferenceTest.php index 929779d43b..0fd5516a7b 100644 --- a/tests/Core/File/IsReferenceTest.php +++ b/tests/Core/File/IsReferenceTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Files\File::isReference */ -class IsReferenceTest extends AbstractMethodUnitTest +final class IsReferenceTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index fa3c834f77..3fda81e51e 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -21,7 +21,7 @@ * * @covers \PHP_CodeSniffer\Filters\Filter */ -class AcceptTest extends AbstractFilterTestCase +final class AcceptTest extends AbstractFilterTestCase { diff --git a/tests/Core/Filters/GitModifiedTest.php b/tests/Core/Filters/GitModifiedTest.php index b3d11b631f..626fb65312 100644 --- a/tests/Core/Filters/GitModifiedTest.php +++ b/tests/Core/Filters/GitModifiedTest.php @@ -19,7 +19,7 @@ * * @covers \PHP_CodeSniffer\Filters\GitModified */ -class GitModifiedTest extends AbstractFilterTestCase +final class GitModifiedTest extends AbstractFilterTestCase { diff --git a/tests/Core/Filters/GitStagedTest.php b/tests/Core/Filters/GitStagedTest.php index ebf761c4fe..0009aefa7a 100644 --- a/tests/Core/Filters/GitStagedTest.php +++ b/tests/Core/Filters/GitStagedTest.php @@ -19,7 +19,7 @@ * * @covers \PHP_CodeSniffer\Filters\GitStaged */ -class GitStagedTest extends AbstractFilterTestCase +final class GitStagedTest extends AbstractFilterTestCase { diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index 065a73cfba..df145a2f9d 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -18,7 +18,7 @@ * * @covers \PHP_CodeSniffer\Ruleset::explain */ -class ExplainTest extends TestCase +final class ExplainTest extends TestCase { diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php index 786cbe745a..04099f3876 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php @@ -18,7 +18,7 @@ * * @covers \PHP_CodeSniffer\Ruleset */ -class RuleInclusionAbsoluteLinuxTest extends TestCase +final class RuleInclusionAbsoluteLinuxTest extends TestCase { /** diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php index 629668c9af..da3723831b 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php @@ -18,7 +18,7 @@ * * @covers \PHP_CodeSniffer\Ruleset */ -class RuleInclusionAbsoluteWindowsTest extends TestCase +final class RuleInclusionAbsoluteWindowsTest extends TestCase { /** diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index df4a022636..04ab4a6041 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -19,7 +19,7 @@ * * @covers \PHP_CodeSniffer\Ruleset */ -class RuleInclusionTest extends TestCase +final class RuleInclusionTest extends TestCase { /** diff --git a/tests/Core/Ruleset/SetSniffPropertyTest.php b/tests/Core/Ruleset/SetSniffPropertyTest.php index 1b3d955cc3..e23f2688ec 100644 --- a/tests/Core/Ruleset/SetSniffPropertyTest.php +++ b/tests/Core/Ruleset/SetSniffPropertyTest.php @@ -19,7 +19,7 @@ * * @covers \PHP_CodeSniffer\Ruleset::setSniffProperty */ -class SetSniffPropertyTest extends TestCase +final class SetSniffPropertyTest extends TestCase { diff --git a/tests/Core/Sniffs/AbstractArraySniffTest.php b/tests/Core/Sniffs/AbstractArraySniffTest.php index cf8a231bc0..f074d9500f 100644 --- a/tests/Core/Sniffs/AbstractArraySniffTest.php +++ b/tests/Core/Sniffs/AbstractArraySniffTest.php @@ -16,7 +16,7 @@ * * @covers \PHP_CodeSniffer\Sniffs\AbstractArraySniff */ -class AbstractArraySniffTest extends AbstractMethodUnitTest +final class AbstractArraySniffTest extends AbstractMethodUnitTest { /** diff --git a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php index 9a5470971a..e3683381d7 100644 --- a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php +++ b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class AnonClassParenthesisOwnerTest extends AbstractMethodUnitTest +final class AnonClassParenthesisOwnerTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/ArrayKeywordTest.php b/tests/Core/Tokenizer/ArrayKeywordTest.php index b831ed74af..208b9f639d 100644 --- a/tests/Core/Tokenizer/ArrayKeywordTest.php +++ b/tests/Core/Tokenizer/ArrayKeywordTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class ArrayKeywordTest extends AbstractMethodUnitTest +final class ArrayKeywordTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/AttributesTest.php b/tests/Core/Tokenizer/AttributesTest.php index 1593f0f44f..424fb9e586 100644 --- a/tests/Core/Tokenizer/AttributesTest.php +++ b/tests/Core/Tokenizer/AttributesTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class AttributesTest extends AbstractMethodUnitTest +final class AttributesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/BackfillEnumTest.php b/tests/Core/Tokenizer/BackfillEnumTest.php index 7c72672137..544c9c53e3 100644 --- a/tests/Core/Tokenizer/BackfillEnumTest.php +++ b/tests/Core/Tokenizer/BackfillEnumTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class BackfillEnumTest extends AbstractMethodUnitTest +final class BackfillEnumTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php b/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php index a01754a5ae..cbaf85bffb 100644 --- a/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php +++ b/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class BackfillExplicitOctalNotationTest extends AbstractMethodUnitTest +final class BackfillExplicitOctalNotationTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/BackfillFnTokenTest.php b/tests/Core/Tokenizer/BackfillFnTokenTest.php index e6935331b3..128d5a0f96 100644 --- a/tests/Core/Tokenizer/BackfillFnTokenTest.php +++ b/tests/Core/Tokenizer/BackfillFnTokenTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class BackfillFnTokenTest extends AbstractMethodUnitTest +final class BackfillFnTokenTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/BackfillMatchTokenTest.php b/tests/Core/Tokenizer/BackfillMatchTokenTest.php index 72ca61e6da..0b4f58132d 100644 --- a/tests/Core/Tokenizer/BackfillMatchTokenTest.php +++ b/tests/Core/Tokenizer/BackfillMatchTokenTest.php @@ -13,7 +13,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -class BackfillMatchTokenTest extends AbstractMethodUnitTest +final class BackfillMatchTokenTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php index 4b96801b5f..7f5151d2e8 100644 --- a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php +++ b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class BackfillNumericSeparatorTest extends AbstractMethodUnitTest +final class BackfillNumericSeparatorTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index 024220d3bf..703f4903e9 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class BackfillReadonlyTest extends AbstractMethodUnitTest +final class BackfillReadonlyTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/BitwiseOrTest.php b/tests/Core/Tokenizer/BitwiseOrTest.php index 81e10e01a9..5360a3015d 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.php +++ b/tests/Core/Tokenizer/BitwiseOrTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class BitwiseOrTest extends AbstractMethodUnitTest +final class BitwiseOrTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php index 21233511d1..2605aa1707 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php @@ -12,7 +12,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -class ContextSensitiveKeywordsTest extends AbstractMethodUnitTest +final class ContextSensitiveKeywordsTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/DefaultKeywordTest.php b/tests/Core/Tokenizer/DefaultKeywordTest.php index c4d216dda0..7b04c45bff 100644 --- a/tests/Core/Tokenizer/DefaultKeywordTest.php +++ b/tests/Core/Tokenizer/DefaultKeywordTest.php @@ -12,7 +12,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class DefaultKeywordTest extends AbstractMethodUnitTest +final class DefaultKeywordTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/DoubleArrowTest.php b/tests/Core/Tokenizer/DoubleArrowTest.php index e1a0174d7b..f472a7548c 100644 --- a/tests/Core/Tokenizer/DoubleArrowTest.php +++ b/tests/Core/Tokenizer/DoubleArrowTest.php @@ -13,7 +13,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class DoubleArrowTest extends AbstractMethodUnitTest +final class DoubleArrowTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/DoubleQuotedStringTest.php b/tests/Core/Tokenizer/DoubleQuotedStringTest.php index 4e837babac..55faae5380 100644 --- a/tests/Core/Tokenizer/DoubleQuotedStringTest.php +++ b/tests/Core/Tokenizer/DoubleQuotedStringTest.php @@ -12,7 +12,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class DoubleQuotedStringTest extends AbstractMethodUnitTest +final class DoubleQuotedStringTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/EnumCaseTest.php b/tests/Core/Tokenizer/EnumCaseTest.php index d4b6fe7c07..c4989ae098 100644 --- a/tests/Core/Tokenizer/EnumCaseTest.php +++ b/tests/Core/Tokenizer/EnumCaseTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class EnumCaseTest extends AbstractMethodUnitTest +final class EnumCaseTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/FinallyTest.php b/tests/Core/Tokenizer/FinallyTest.php index d5e089a05b..587ebc69fe 100644 --- a/tests/Core/Tokenizer/FinallyTest.php +++ b/tests/Core/Tokenizer/FinallyTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class FinallyTest extends AbstractMethodUnitTest +final class FinallyTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/GotoLabelTest.php b/tests/Core/Tokenizer/GotoLabelTest.php index b4d1e8a4eb..3825a3d1c9 100644 --- a/tests/Core/Tokenizer/GotoLabelTest.php +++ b/tests/Core/Tokenizer/GotoLabelTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class GotoLabelTest extends AbstractMethodUnitTest +final class GotoLabelTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php index 9d34c5e1a4..bce3b9c834 100644 --- a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php +++ b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php @@ -19,7 +19,7 @@ * * @requires PHP 7.3 */ -class HeredocNowdocCloserTest extends AbstractMethodUnitTest +final class HeredocNowdocCloserTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/HeredocStringTest.php b/tests/Core/Tokenizer/HeredocStringTest.php index 993fd98c97..35e39db099 100644 --- a/tests/Core/Tokenizer/HeredocStringTest.php +++ b/tests/Core/Tokenizer/HeredocStringTest.php @@ -12,7 +12,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class HeredocStringTest extends AbstractMethodUnitTest +final class HeredocStringTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php index 8819a202b1..90df5fefa3 100644 --- a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php +++ b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php @@ -12,7 +12,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -class NamedFunctionCallArgumentsTest extends AbstractMethodUnitTest +final class NamedFunctionCallArgumentsTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php b/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php index 83b48e67f1..f29c7a8a55 100644 --- a/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php +++ b/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php @@ -12,7 +12,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -class NullsafeObjectOperatorTest extends AbstractMethodUnitTest +final class NullsafeObjectOperatorTest extends AbstractMethodUnitTest { /** diff --git a/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php b/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php index 143179547f..b2ecd8a522 100644 --- a/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php +++ b/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class ScopeSettingWithNamespaceOperatorTest extends AbstractMethodUnitTest +final class ScopeSettingWithNamespaceOperatorTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/ShortArrayTest.php b/tests/Core/Tokenizer/ShortArrayTest.php index 3cf9cd14e6..9e73f61b3e 100644 --- a/tests/Core/Tokenizer/ShortArrayTest.php +++ b/tests/Core/Tokenizer/ShortArrayTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class ShortArrayTest extends AbstractMethodUnitTest +final class ShortArrayTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php index 781fc1b7e3..9e57542dbc 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php @@ -18,7 +18,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -class StableCommentWhitespaceTest extends AbstractMethodUnitTest +final class StableCommentWhitespaceTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php index 3fef5e421e..f78aa4769a 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php @@ -15,7 +15,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -class StableCommentWhitespaceWinTest extends AbstractMethodUnitTest +final class StableCommentWhitespaceWinTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.php b/tests/Core/Tokenizer/TypeIntersectionTest.php index fcfd191acf..fa888f7c36 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.php +++ b/tests/Core/Tokenizer/TypeIntersectionTest.php @@ -12,7 +12,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class TypeIntersectionTest extends AbstractMethodUnitTest +final class TypeIntersectionTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php index 72ee773f0f..a3c8fd6081 100644 --- a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php +++ b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php @@ -21,7 +21,7 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; -class UndoNamespacedNameSingleTokenTest extends AbstractMethodUnitTest +final class UndoNamespacedNameSingleTokenTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Util/IsCamelCapsTest.php b/tests/Core/Util/IsCamelCapsTest.php index 2a1729b2a3..4d15a41fe4 100644 --- a/tests/Core/Util/IsCamelCapsTest.php +++ b/tests/Core/Util/IsCamelCapsTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Util\Common::isCamelCaps */ -class IsCamelCapsTest extends TestCase +final class IsCamelCapsTest extends TestCase { diff --git a/tests/Core/Util/SuggestTypeTest.php b/tests/Core/Util/SuggestTypeTest.php index a5a862f43c..1b24a5a788 100644 --- a/tests/Core/Util/SuggestTypeTest.php +++ b/tests/Core/Util/SuggestTypeTest.php @@ -17,7 +17,7 @@ * * @covers \PHP_CodeSniffer\Util\Common::suggestType */ -class SuggestTypeTest extends TestCase +final class SuggestTypeTest extends TestCase { From 72a2ee038e3d0832eb82387737f38119d0be06ff Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 12 Jan 2024 00:03:37 +0100 Subject: [PATCH 249/874] Tests: make dataproviders `static` As of PHPUnit 10, data providers are (again) expected to be `static` methods. While the test suite does not (yet) support PHPUnit 10, it's still not a bad idea to already start complying with this. --- tests/Core/Config/ReportWidthTest.php | 2 +- tests/Core/ErrorSuppressionTest.php | 22 +++++++++---------- tests/Core/File/FindExtendedClassNameTest.php | 2 +- .../FindImplementedInterfaceNamesTest.php | 2 +- tests/Core/File/GetClassPropertiesTest.php | 4 ++-- tests/Core/File/GetMemberPropertiesTest.php | 4 ++-- tests/Core/File/IsReferenceTest.php | 2 +- tests/Core/Ruleset/RuleInclusionTest.php | 6 ++--- tests/Core/Ruleset/SetSniffPropertyTest.php | 4 ++-- .../AnonClassParenthesisOwnerTest.php | 4 ++-- tests/Core/Tokenizer/ArrayKeywordTest.php | 6 ++--- tests/Core/Tokenizer/AttributesTest.php | 6 ++--- tests/Core/Tokenizer/BackfillEnumTest.php | 4 ++-- .../BackfillExplicitOctalNotationTest.php | 2 +- tests/Core/Tokenizer/BackfillFnTokenTest.php | 4 ++-- .../Core/Tokenizer/BackfillMatchTokenTest.php | 8 +++---- .../BackfillNumericSeparatorTest.php | 4 ++-- tests/Core/Tokenizer/BackfillReadonlyTest.php | 4 ++-- tests/Core/Tokenizer/BitwiseOrTest.php | 4 ++-- .../ContextSensitiveKeywordsTest.php | 4 ++-- tests/Core/Tokenizer/DefaultKeywordTest.php | 6 ++--- tests/Core/Tokenizer/DoubleArrowTest.php | 6 ++--- .../Core/Tokenizer/DoubleQuotedStringTest.php | 2 +- tests/Core/Tokenizer/EnumCaseTest.php | 6 ++--- tests/Core/Tokenizer/FinallyTest.php | 4 ++-- tests/Core/Tokenizer/GotoLabelTest.php | 6 ++--- .../Tokenizer/HeredocNowdocCloserTest.php | 2 +- tests/Core/Tokenizer/HeredocStringTest.php | 2 +- .../NamedFunctionCallArgumentsTest.php | 6 ++--- .../Tokenizer/NullsafeObjectOperatorTest.php | 4 ++-- .../ScopeSettingWithNamespaceOperatorTest.php | 2 +- tests/Core/Tokenizer/ShortArrayTest.php | 4 ++-- .../Tokenizer/StableCommentWhitespaceTest.php | 2 +- .../StableCommentWhitespaceWinTest.php | 2 +- tests/Core/Tokenizer/TypeIntersectionTest.php | 4 ++-- .../UndoNamespacedNameSingleTokenTest.php | 2 +- tests/Core/Util/SuggestTypeTest.php | 6 ++--- 37 files changed, 82 insertions(+), 82 deletions(-) diff --git a/tests/Core/Config/ReportWidthTest.php b/tests/Core/Config/ReportWidthTest.php index c89bf85b2e..3b3881ce01 100644 --- a/tests/Core/Config/ReportWidthTest.php +++ b/tests/Core/Config/ReportWidthTest.php @@ -267,7 +267,7 @@ public function testReportWidthInputHandling($input, $expected) * * @return array */ - public function dataReportWidthInputHandling() + public static function dataReportWidthInputHandling() { return [ 'No value (empty string)' => [ diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index e18271a3ef..212cef425a 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -65,7 +65,7 @@ public function testSuppressError($before, $after, $expectedErrors=0) * * @return array */ - public function dataSuppressError() + public static function dataSuppressError() { return [ 'no suppression' => [ @@ -204,7 +204,7 @@ public function testSuppressSomeErrors($before, $between, $expectedErrors=1) * * @return array */ - public function dataSuppressSomeErrors() + public static function dataSuppressSomeErrors() { return [ 'no suppression' => [ @@ -296,7 +296,7 @@ public function testSuppressWarning($before, $after, $expectedWarnings=0) * * @return array */ - public function dataSuppressWarning() + public static function dataSuppressWarning() { return [ 'no suppression' => [ @@ -381,7 +381,7 @@ public function testSuppressLine($before, $after='', $expectedErrors=1) * * @return array */ - public function dataSuppressLine() + public static function dataSuppressLine() { return [ 'no suppression' => [ @@ -532,7 +532,7 @@ public function testNestedSuppressLine($before, $after) * * @return array */ - public function dataNestedSuppressLine() + public static function dataNestedSuppressLine() { return [ // Process with disable/enable suppression and no single line suppression. @@ -627,7 +627,7 @@ function myFunction() { * * @return array */ - public function dataSuppressScope() + public static function dataSuppressScope() { return [ 'no suppression' => [ @@ -722,7 +722,7 @@ class MyClass {} * * @return array */ - public function dataSuppressFile() + public static function dataSuppressFile() { return [ 'no suppression' => [ @@ -821,7 +821,7 @@ public function testDisableSelected($before, $expectedErrors=0, $expectedWarning * * @return array */ - public function dataDisableSelected() + public static function dataDisableSelected() { return [ // Single sniff. @@ -928,7 +928,7 @@ public function testEnableSelected($code, $expectedErrors, $expectedWarnings) * * @return array */ - public function dataEnableSelected() + public static function dataEnableSelected() { return [ 'disable/enable: a single sniff' => [ @@ -1108,7 +1108,7 @@ public function testIgnoreSelected($before, $expectedErrors, $expectedWarnings) * * @return array */ - public function dataIgnoreSelected() + public static function dataIgnoreSelected() { return [ 'no suppression' => [ @@ -1195,7 +1195,7 @@ public function testCommenting($code, $expectedErrors, $expectedWarnings) * * @return array */ - public function dataCommenting() + public static function dataCommenting() { return [ 'ignore: single sniff' => [ diff --git a/tests/Core/File/FindExtendedClassNameTest.php b/tests/Core/File/FindExtendedClassNameTest.php index f26b616790..bb69f25680 100644 --- a/tests/Core/File/FindExtendedClassNameTest.php +++ b/tests/Core/File/FindExtendedClassNameTest.php @@ -74,7 +74,7 @@ public function testFindExtendedClassName($identifier, $expected) * * @return array> */ - public function dataExtendedClass() + public static function dataExtendedClass() { return [ 'class does not extend' => [ diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.php b/tests/Core/File/FindImplementedInterfaceNamesTest.php index e96b6f956d..bcf2cade27 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.php +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.php @@ -73,7 +73,7 @@ public function testFindImplementedInterfaceNames($identifier, $expected) * * @return array>> */ - public function dataImplementedInterface() + public static function dataImplementedInterface() { return [ 'interface declaration, no implements' => [ diff --git a/tests/Core/File/GetClassPropertiesTest.php b/tests/Core/File/GetClassPropertiesTest.php index 5d182807b1..1bebc5893f 100644 --- a/tests/Core/File/GetClassPropertiesTest.php +++ b/tests/Core/File/GetClassPropertiesTest.php @@ -47,7 +47,7 @@ public function testNotAClassException($testMarker, $tokenType) * * @return array> */ - public function dataNotAClassException() + public static function dataNotAClassException() { return [ 'interface' => [ @@ -93,7 +93,7 @@ public function testGetClassProperties($testMarker, $expected) * * @return array>> */ - public function dataGetClassProperties() + public static function dataGetClassProperties() { return [ 'no-properties' => [ diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index df4973ceeb..5f2c4cdf95 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -60,7 +60,7 @@ public function testGetMemberProperties($identifier, $expected) * * @return array>> */ - public function dataGetMemberProperties() + public static function dataGetMemberProperties() { return [ 'var-modifier' => [ @@ -1106,7 +1106,7 @@ public function testNotClassPropertyException($identifier) * * @return array> */ - public function dataNotClassProperty() + public static function dataNotClassProperty() { return [ 'method parameter' => ['/* testMethodParam */'], diff --git a/tests/Core/File/IsReferenceTest.php b/tests/Core/File/IsReferenceTest.php index 0fd5516a7b..bbe31baef2 100644 --- a/tests/Core/File/IsReferenceTest.php +++ b/tests/Core/File/IsReferenceTest.php @@ -59,7 +59,7 @@ public function testIsReference($identifier, $expected) * * @return array> */ - public function dataIsReference() + public static function dataIsReference() { return [ 'issue-1971-list-first-in-file' => [ diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index 04ab4a6041..5659f7fb03 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -131,7 +131,7 @@ public function testRegisteredSniffCodes($key, $value) * * @return array */ - public function dataRegisteredSniffCodes() + public static function dataRegisteredSniffCodes() { return [ [ @@ -364,7 +364,7 @@ public function testSettingProperties($sniffClass, $propertyName, $expectedValue * * @return array */ - public function dataSettingProperties() + public static function dataSettingProperties() { return [ 'Set property for complete standard: PSR2 ClassDeclaration' => [ @@ -455,7 +455,7 @@ public function testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFail * * @return array */ - public function dataSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails() + public static function dataSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails() { return [ 'Set property for complete standard: PSR2 ClassDeclaration' => [ diff --git a/tests/Core/Ruleset/SetSniffPropertyTest.php b/tests/Core/Ruleset/SetSniffPropertyTest.php index e23f2688ec..824ac73e38 100644 --- a/tests/Core/Ruleset/SetSniffPropertyTest.php +++ b/tests/Core/Ruleset/SetSniffPropertyTest.php @@ -74,7 +74,7 @@ public function testSniffPropertiesGetSetWhenAllowed($name) * * @return array */ - public function dataSniffPropertiesGetSetWhenAllowed() + public static function dataSniffPropertiesGetSetWhenAllowed() { return [ 'Property allowed as explicitly declared' => ['SetPropertyAllowedAsDeclared'], @@ -315,7 +315,7 @@ public function testDirectCallWithOldArrayFormatSetsProperty($propertyValue) * * @return array */ - public function dataDirectCallWithOldArrayFormatSetsProperty() + public static function dataDirectCallWithOldArrayFormatSetsProperty() { return [ 'Property value is not an array (boolean)' => [false], diff --git a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php index e3683381d7..83652d9469 100644 --- a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php +++ b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php @@ -72,7 +72,7 @@ public function testAnonClassNoParenthesesNextOpenClose($testMarker) * * @return array */ - public function dataAnonClassNoParentheses() + public static function dataAnonClassNoParentheses() { return [ ['/* testNoParentheses */'], @@ -131,7 +131,7 @@ public function testAnonClassWithParentheses($testMarker) * * @return array */ - public function dataAnonClassWithParentheses() + public static function dataAnonClassWithParentheses() { return [ ['/* testWithParentheses */'], diff --git a/tests/Core/Tokenizer/ArrayKeywordTest.php b/tests/Core/Tokenizer/ArrayKeywordTest.php index 208b9f639d..56a02d4dde 100644 --- a/tests/Core/Tokenizer/ArrayKeywordTest.php +++ b/tests/Core/Tokenizer/ArrayKeywordTest.php @@ -51,7 +51,7 @@ public function testArrayKeyword($testMarker, $testContent='array') * * @return array */ - public function dataArrayKeyword() + public static function dataArrayKeyword() { return [ 'empty array' => ['/* testEmptyArray */'], @@ -103,7 +103,7 @@ public function testArrayType($testMarker, $testContent='array') * * @return array */ - public function dataArrayType() + public static function dataArrayType() { return [ 'closure return type' => [ @@ -154,7 +154,7 @@ public function testNotArrayKeyword($testMarker, $testContent='array') * * @return array */ - public function dataNotArrayKeyword() + public static function dataNotArrayKeyword() { return [ 'class-constant-name' => [ diff --git a/tests/Core/Tokenizer/AttributesTest.php b/tests/Core/Tokenizer/AttributesTest.php index 424fb9e586..ec0893f6dc 100644 --- a/tests/Core/Tokenizer/AttributesTest.php +++ b/tests/Core/Tokenizer/AttributesTest.php @@ -66,7 +66,7 @@ function ($token) use ($attribute, $length) { * * @return array */ - public function dataAttribute() + public static function dataAttribute() { return [ [ @@ -345,7 +345,7 @@ function ($token) use ($attribute, $length) { * * @return array */ - public function dataAttributeOnParameters() + public static function dataAttributeOnParameters() { return [ [ @@ -451,7 +451,7 @@ public function testAttributeContainingTextLookingLikeCloseTag($testMarker, $len * * @return array */ - public function dataAttributeOnTextLookingLikeCloseTag() + public static function dataAttributeOnTextLookingLikeCloseTag() { return [ [ diff --git a/tests/Core/Tokenizer/BackfillEnumTest.php b/tests/Core/Tokenizer/BackfillEnumTest.php index 544c9c53e3..c033cba41e 100644 --- a/tests/Core/Tokenizer/BackfillEnumTest.php +++ b/tests/Core/Tokenizer/BackfillEnumTest.php @@ -75,7 +75,7 @@ public function testEnums($testMarker, $testContent, $openerOffset, $closerOffse * * @return array */ - public function dataEnums() + public static function dataEnums() { return [ [ @@ -154,7 +154,7 @@ public function testNotEnums($testMarker, $testContent) * * @return array */ - public function dataNotEnums() + public static function dataNotEnums() { return [ [ diff --git a/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php b/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php index cbaf85bffb..4f67e567c9 100644 --- a/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php +++ b/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php @@ -49,7 +49,7 @@ public function testExplicitOctalNotation($marker, $value, $nextToken, $nextCont * * @return array */ - public function dataExplicitOctalNotation() + public static function dataExplicitOctalNotation() { return [ [ diff --git a/tests/Core/Tokenizer/BackfillFnTokenTest.php b/tests/Core/Tokenizer/BackfillFnTokenTest.php index 128d5a0f96..5058a85dc4 100644 --- a/tests/Core/Tokenizer/BackfillFnTokenTest.php +++ b/tests/Core/Tokenizer/BackfillFnTokenTest.php @@ -581,7 +581,7 @@ public function testInMatchValue($testMarker, $openerOffset, $closerOffset, $exp * * @return array */ - public function dataInMatchValue() + public static function dataInMatchValue() { return [ 'not_last_value' => [ @@ -671,7 +671,7 @@ public function testNotAnArrowFunction($testMarker, $testContent='fn') * * @return array */ - public function dataNotAnArrowFunction() + public static function dataNotAnArrowFunction() { return [ ['/* testFunctionName */'], diff --git a/tests/Core/Tokenizer/BackfillMatchTokenTest.php b/tests/Core/Tokenizer/BackfillMatchTokenTest.php index 0b4f58132d..99655b0f85 100644 --- a/tests/Core/Tokenizer/BackfillMatchTokenTest.php +++ b/tests/Core/Tokenizer/BackfillMatchTokenTest.php @@ -53,7 +53,7 @@ public function testMatchExpression($testMarker, $openerOffset, $closerOffset, $ * * @return array */ - public function dataMatchExpression() + public static function dataMatchExpression() { return [ 'simple_match' => [ @@ -243,7 +243,7 @@ public function testNotAMatchStructure($testMarker, $testContent='match') * * @return array */ - public function dataNotAMatchStructure() + public static function dataNotAMatchStructure() { return [ 'static_method_call' => ['/* testNoMatchStaticMethodCall */'], @@ -346,7 +346,7 @@ public function testSwitchExpression($testMarker, $openerOffset, $closerOffset) * * @return array */ - public function dataSwitchExpression() + public static function dataSwitchExpression() { return [ 'switch_containing_match' => [ @@ -399,7 +399,7 @@ public function testSwitchCaseVersusMatch($testMarker, $openerOffset, $closerOff * * @return array */ - public function dataSwitchCaseVersusMatch() + public static function dataSwitchCaseVersusMatch() { return [ 'switch_with_nested_match_case_1' => [ diff --git a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php index 7f5151d2e8..1052d63e08 100644 --- a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php +++ b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php @@ -44,7 +44,7 @@ public function testBackfill($testData) * * @return array */ - public function dataTestBackfill() + public static function dataTestBackfill() { $testHexType = 'T_LNUMBER'; if (PHP_INT_MAX < 0xCAFEF00D) { @@ -191,7 +191,7 @@ public function testNoBackfill($testMarker, $expectedTokens) * * @return array */ - public function dataNoBackfill() + public static function dataNoBackfill() { return [ [ diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index 703f4903e9..b0f7a9ca7a 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -44,7 +44,7 @@ public function testReadonly($testMarker, $testContent) * * @return array */ - public function dataReadonly() + public static function dataReadonly() { return [ [ @@ -221,7 +221,7 @@ public function testNotReadonly($testMarker, $testContent) * * @return array */ - public function dataNotReadonly() + public static function dataNotReadonly() { return [ [ diff --git a/tests/Core/Tokenizer/BitwiseOrTest.php b/tests/Core/Tokenizer/BitwiseOrTest.php index 5360a3015d..c5b937d69a 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.php +++ b/tests/Core/Tokenizer/BitwiseOrTest.php @@ -43,7 +43,7 @@ public function testBitwiseOr($testMarker) * * @return array */ - public function dataBitwiseOr() + public static function dataBitwiseOr() { return [ ['/* testBitwiseOr1 */'], @@ -94,7 +94,7 @@ public function testTypeUnion($testMarker) * * @return array */ - public function dataTypeUnion() + public static function dataTypeUnion() { return [ ['/* testTypeUnionPropertySimple */'], diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php index 2605aa1707..9326c57a96 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php @@ -45,7 +45,7 @@ public function testStrings($testMarker) * * @return array */ - public function dataStrings() + public static function dataStrings() { return [ ['/* testAbstract */'], @@ -187,7 +187,7 @@ public function testKeywords($testMarker, $expectedTokenType) * * @return array */ - public function dataKeywords() + public static function dataKeywords() { return [ [ diff --git a/tests/Core/Tokenizer/DefaultKeywordTest.php b/tests/Core/Tokenizer/DefaultKeywordTest.php index 7b04c45bff..b281fdd425 100644 --- a/tests/Core/Tokenizer/DefaultKeywordTest.php +++ b/tests/Core/Tokenizer/DefaultKeywordTest.php @@ -55,7 +55,7 @@ public function testMatchDefault($testMarker, $testContent='default') * * @return array */ - public function dataMatchDefault() + public static function dataMatchDefault() { return [ 'simple_match_default' => ['/* testSimpleMatchDefault */'], @@ -171,7 +171,7 @@ public function testSwitchDefault($testMarker, $openerOffset, $closerOffset, $co * * @return array */ - public function dataSwitchDefault() + public static function dataSwitchDefault() { return [ 'simple_switch_default' => [ @@ -246,7 +246,7 @@ public function testNotDefaultKeyword($testMarker, $testContent='DEFAULT') * * @return array */ - public function dataNotDefaultKeyword() + public static function dataNotDefaultKeyword() { return [ 'class-constant-as-short-array-key' => ['/* testClassConstantAsShortArrayKey */'], diff --git a/tests/Core/Tokenizer/DoubleArrowTest.php b/tests/Core/Tokenizer/DoubleArrowTest.php index f472a7548c..6fe3a5eee8 100644 --- a/tests/Core/Tokenizer/DoubleArrowTest.php +++ b/tests/Core/Tokenizer/DoubleArrowTest.php @@ -47,7 +47,7 @@ public function testDoubleArrow($testMarker) * * @return array */ - public function dataDoubleArrow() + public static function dataDoubleArrow() { return [ 'simple_long_array' => ['/* testLongArrayArrowSimple */'], @@ -132,7 +132,7 @@ public function testMatchArrow($testMarker) * * @return array */ - public function dataMatchArrow() + public static function dataMatchArrow() { return [ 'single_case' => ['/* testMatchArrowSimpleSingleCase */'], @@ -219,7 +219,7 @@ public function testFnArrow($testMarker) * * @return array */ - public function dataFnArrow() + public static function dataFnArrow() { return [ 'simple_fn' => ['/* testFnArrowSimple */'], diff --git a/tests/Core/Tokenizer/DoubleQuotedStringTest.php b/tests/Core/Tokenizer/DoubleQuotedStringTest.php index 55faae5380..c5c86972a8 100644 --- a/tests/Core/Tokenizer/DoubleQuotedStringTest.php +++ b/tests/Core/Tokenizer/DoubleQuotedStringTest.php @@ -44,7 +44,7 @@ public function testDoubleQuotedString($testMarker, $expectedContent) * * @return array */ - public function dataDoubleQuotedString() + public static function dataDoubleQuotedString() { return [ [ diff --git a/tests/Core/Tokenizer/EnumCaseTest.php b/tests/Core/Tokenizer/EnumCaseTest.php index c4989ae098..4b41312675 100644 --- a/tests/Core/Tokenizer/EnumCaseTest.php +++ b/tests/Core/Tokenizer/EnumCaseTest.php @@ -49,7 +49,7 @@ public function testEnumCases($testMarker) * * @return array */ - public function dataEnumCases() + public static function dataEnumCases() { return [ ['/* testPureEnumCase */'], @@ -98,7 +98,7 @@ public function testNotEnumCases($testMarker) * * @return array */ - public function dataNotEnumCases() + public static function dataNotEnumCases() { return [ ['/* testCaseWithSemicolonIsNotEnumCase */'], @@ -142,7 +142,7 @@ public function testKeywordAsEnumCaseNameShouldBeString($testMarker) * * @return array */ - public function dataKeywordAsEnumCaseNameShouldBeString() + public static function dataKeywordAsEnumCaseNameShouldBeString() { return [ ['/* testKeywordAsEnumCaseNameShouldBeString1 */'], diff --git a/tests/Core/Tokenizer/FinallyTest.php b/tests/Core/Tokenizer/FinallyTest.php index 587ebc69fe..571bf0ae75 100644 --- a/tests/Core/Tokenizer/FinallyTest.php +++ b/tests/Core/Tokenizer/FinallyTest.php @@ -43,7 +43,7 @@ public function testFinallyKeyword($testMarker) * * @return array */ - public function dataFinallyKeyword() + public static function dataFinallyKeyword() { return [ ['/* testTryCatchFinally */'], @@ -82,7 +82,7 @@ public function testFinallyNonKeyword($testMarker) * * @return array */ - public function dataFinallyNonKeyword() + public static function dataFinallyNonKeyword() { return [ ['/* testFinallyUsedAsClassConstantName */'], diff --git a/tests/Core/Tokenizer/GotoLabelTest.php b/tests/Core/Tokenizer/GotoLabelTest.php index 3825a3d1c9..cf52a77758 100644 --- a/tests/Core/Tokenizer/GotoLabelTest.php +++ b/tests/Core/Tokenizer/GotoLabelTest.php @@ -45,7 +45,7 @@ public function testGotoStatement($testMarker, $testContent) * * @return array */ - public function dataGotoStatement() + public static function dataGotoStatement() { return [ [ @@ -91,7 +91,7 @@ public function testGotoDeclaration($testMarker, $testContent) * * @return array */ - public function dataGotoDeclaration() + public static function dataGotoDeclaration() { return [ [ @@ -136,7 +136,7 @@ public function testNotAGotoDeclaration($testMarker, $testContent) * * @return array */ - public function dataNotAGotoDeclaration() + public static function dataNotAGotoDeclaration() { return [ [ diff --git a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php index bce3b9c834..2902556a2e 100644 --- a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php +++ b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php @@ -93,7 +93,7 @@ public function testHeredocNowdocCloserTabReplacement($testMarker, $expected) * * @return array */ - public function dataHeredocNowdocCloserTabReplacement() + public static function dataHeredocNowdocCloserTabReplacement() { return [ [ diff --git a/tests/Core/Tokenizer/HeredocStringTest.php b/tests/Core/Tokenizer/HeredocStringTest.php index 35e39db099..2aa04a1bdc 100644 --- a/tests/Core/Tokenizer/HeredocStringTest.php +++ b/tests/Core/Tokenizer/HeredocStringTest.php @@ -66,7 +66,7 @@ public function testHeredocStringWrapped($testMarker, $expectedContent) * * @return array */ - public function dataHeredocString() + public static function dataHeredocString() { return [ [ diff --git a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php index 90df5fefa3..f0ca635357 100644 --- a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php +++ b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php @@ -76,7 +76,7 @@ public function testNamedFunctionCallArguments($testMarker, $parameters) * * @return array */ - public function dataNamedFunctionCallArguments() + public static function dataNamedFunctionCallArguments() { return [ [ @@ -296,7 +296,7 @@ public function testOtherTstringInFunctionCall($testMarker, $content) * * @return array */ - public function dataOtherTstringInFunctionCall() + public static function dataOtherTstringInFunctionCall() { return [ [ @@ -746,7 +746,7 @@ public function testReservedKeywordsAsName($testMarker, $tokenTypes, $tokenConte * * @return array */ - public function dataReservedKeywordsAsName() + public static function dataReservedKeywordsAsName() { $reservedKeywords = [ // '__halt_compiler', NOT TESTABLE diff --git a/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php b/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php index f29c7a8a55..8c4f5ab97d 100644 --- a/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php +++ b/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php @@ -73,7 +73,7 @@ public function testNullsafeObjectOperator($testMarker) * * @return array */ - public function dataNullsafeObjectOperator() + public static function dataNullsafeObjectOperator() { return [ ['/* testNullsafeObjectOperator */'], @@ -119,7 +119,7 @@ public function testTernaryThen($testMarker, $testObjectOperator=false) * * @return array */ - public function dataTernaryThen() + public static function dataTernaryThen() { return [ ['/* testTernaryThen */'], diff --git a/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php b/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php index b2ecd8a522..872979f7fe 100644 --- a/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php +++ b/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php @@ -61,7 +61,7 @@ public function testScopeSetting($testMarker, $tokenTypes, $open=T_OPEN_CURLY_BR * * @return array */ - public function dataScopeSetting() + public static function dataScopeSetting() { return [ [ diff --git a/tests/Core/Tokenizer/ShortArrayTest.php b/tests/Core/Tokenizer/ShortArrayTest.php index 9e73f61b3e..a4273adc90 100644 --- a/tests/Core/Tokenizer/ShortArrayTest.php +++ b/tests/Core/Tokenizer/ShortArrayTest.php @@ -49,7 +49,7 @@ public function testSquareBrackets($testMarker) * * @return array */ - public function dataSquareBrackets() + public static function dataSquareBrackets() { return [ 'array access 1' => ['/* testArrayAccess1 */'], @@ -114,7 +114,7 @@ public function testShortArrays($testMarker) * * @return array */ - public function dataShortArrays() + public static function dataShortArrays() { return [ 'short array empty' => ['/* testShortArrayDeclarationEmpty */'], diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php index 9e57542dbc..3b5ffeb963 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php @@ -56,7 +56,7 @@ public function testCommentTokenization($testMarker, $expectedTokens) * * @return array */ - public function dataCommentTokenization() + public static function dataCommentTokenization() { return [ [ diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php index f78aa4769a..a85ba73cb9 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php @@ -53,7 +53,7 @@ public function testCommentTokenization($testMarker, $expectedTokens) * * @return array */ - public function dataCommentTokenization() + public static function dataCommentTokenization() { return [ [ diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.php b/tests/Core/Tokenizer/TypeIntersectionTest.php index fa888f7c36..7c27e07050 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.php +++ b/tests/Core/Tokenizer/TypeIntersectionTest.php @@ -44,7 +44,7 @@ public function testBitwiseAnd($testMarker) * * @return array */ - public function dataBitwiseAnd() + public static function dataBitwiseAnd() { return [ ['/* testBitwiseAnd1 */'], @@ -97,7 +97,7 @@ public function testTypeIntersection($testMarker) * * @return array */ - public function dataTypeIntersection() + public static function dataTypeIntersection() { return [ ['/* testTypeIntersectionPropertySimple */'], diff --git a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php index a3c8fd6081..2fa8d0e714 100644 --- a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php +++ b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php @@ -59,7 +59,7 @@ public function testIdentifierTokenization($testMarker, $expectedTokens) * * @return array */ - public function dataIdentifierTokenization() + public static function dataIdentifierTokenization() { return [ [ diff --git a/tests/Core/Util/SuggestTypeTest.php b/tests/Core/Util/SuggestTypeTest.php index 1b24a5a788..48790a888c 100644 --- a/tests/Core/Util/SuggestTypeTest.php +++ b/tests/Core/Util/SuggestTypeTest.php @@ -57,7 +57,7 @@ public function testSuggestTypeAllowedType($varType) * * @return array> */ - public function dataSuggestTypeAllowedType() + public static function dataSuggestTypeAllowedType() { $data = []; foreach (Common::$allowedTypes as $type) { @@ -94,7 +94,7 @@ public function testSuggestTypeAllowedTypeWrongCase($varType, $expected) * * @return array> */ - public function dataSuggestTypeAllowedTypeWrongCase() + public static function dataSuggestTypeAllowedTypeWrongCase() { $data = []; foreach (Common::$allowedTypes as $type) { @@ -138,7 +138,7 @@ public function testSuggestTypeOther($varType, $expected) * * @return array> */ - public function dataSuggestTypeOther() + public static function dataSuggestTypeOther() { return [ // Short forms. From da43b73afc13ee15fb7d9da37b03f00f292e2df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C5=BDoljom?= Date: Mon, 8 Jan 2024 09:21:46 +0100 Subject: [PATCH 250/874] Add the documentation for the PSR12 Return Type Declaration sniff --- .../ReturnTypeDeclarationStandard.xml | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Standards/PSR12/Docs/Functions/ReturnTypeDeclarationStandard.xml diff --git a/src/Standards/PSR12/Docs/Functions/ReturnTypeDeclarationStandard.xml b/src/Standards/PSR12/Docs/Functions/ReturnTypeDeclarationStandard.xml new file mode 100644 index 0000000000..000459c33a --- /dev/null +++ b/src/Standards/PSR12/Docs/Functions/ReturnTypeDeclarationStandard.xml @@ -0,0 +1,41 @@ + + + + + + + string { + // Closure body. +}; + ]]> + + + string { + // Closure body. +}; + ]]> + + + + + : string { + // Function body. +}; + ]]> + + + : string { + // Function body. +}; + ]]> + + + From e8897308b31bd62c1654bb042db5d1f169c7069f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 12 Jan 2024 08:25:58 +0100 Subject: [PATCH 251/874] Tests/Filters: skip tests requiring git repository --- tests/Core/Filters/GitModifiedTest.php | 4 ++++ tests/Core/Filters/GitStagedTest.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tests/Core/Filters/GitModifiedTest.php b/tests/Core/Filters/GitModifiedTest.php index 626fb65312..46959072f4 100644 --- a/tests/Core/Filters/GitModifiedTest.php +++ b/tests/Core/Filters/GitModifiedTest.php @@ -211,6 +211,10 @@ public static function dataAcceptOnlyGitModified() */ public function testExecAlwaysReturnsArray($cmd, $expected) { + if (is_dir(__DIR__.'/../../../.git') === false) { + $this->markTestSkipped('Not a git repository'); + } + $fakeDI = new RecursiveArrayIterator(self::getFakeFileList()); $filter = new GitModified($fakeDI, '/', self::$config, self::$ruleset); diff --git a/tests/Core/Filters/GitStagedTest.php b/tests/Core/Filters/GitStagedTest.php index 0009aefa7a..31b7345bb7 100644 --- a/tests/Core/Filters/GitStagedTest.php +++ b/tests/Core/Filters/GitStagedTest.php @@ -211,6 +211,10 @@ public static function dataAcceptOnlyGitStaged() */ public function testExecAlwaysReturnsArray($cmd, $expected) { + if (is_dir(__DIR__.'/../../../.git') === false) { + $this->markTestSkipped('Not a git repository'); + } + $fakeDI = new RecursiveArrayIterator(self::getFakeFileList()); $filter = new GitStaged($fakeDI, '/', self::$config, self::$ruleset); From 4287c8c5ca7f1071882651d44b72f1c9248b9f56 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 9 Jan 2024 11:05:50 -0300 Subject: [PATCH 252/874] Generic/UnnecessaryFinalModifier: rename test case file Doing this to be able to create a test with a syntax error on a separate file. --- ...=> UnnecessaryFinalModifierUnitTest.1.inc} | 0 .../UnnecessaryFinalModifierUnitTest.php | 25 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) rename src/Standards/Generic/Tests/CodeAnalysis/{UnnecessaryFinalModifierUnitTest.inc => UnnecessaryFinalModifierUnitTest.1.inc} (100%) diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc rename to src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php index c35634258c..8ee5f3b3c0 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php @@ -41,18 +41,25 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the test file being tested. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return [ - 11 => 1, - 12 => 1, - 15 => 1, - 18 => 1, - 32 => 1, - 33 => 1, - ]; + switch ($testFile) { + case 'UnnecessaryFinalModifierUnitTest.1.inc': + return [ + 11 => 1, + 12 => 1, + 15 => 1, + 18 => 1, + 32 => 1, + 33 => 1, + ]; + default: + return []; + } }//end getWarningList() From 4b699bada97bd74d343e2860a46709e7468d09c0 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 9 Jan 2024 11:43:13 -0300 Subject: [PATCH 253/874] Generic/UnnecessaryFinalModifier: improve code coverage This commit add one more test case file to exercise defensive code that makes the sniff bail early if the class has no body. --- .../CodeAnalysis/UnnecessaryFinalModifierUnitTest.2.inc | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.2.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.2.inc b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.2.inc new file mode 100644 index 0000000000..d3636f4800 --- /dev/null +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.2.inc @@ -0,0 +1,5 @@ + Date: Fri, 12 Jan 2024 09:55:40 -0300 Subject: [PATCH 254/874] Generic/UnnecessaryFinalModifier: add tests for final class constants --- .../UnnecessaryFinalModifierUnitTest.1.inc | 22 +++++++++++++++++++ .../UnnecessaryFinalModifierUnitTest.php | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.1.inc b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.1.inc index 026cf48424..d217d07367 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.1.inc +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.1.inc @@ -32,3 +32,25 @@ final readonly class Foo_Bar { public final function fooBar() {} final protected function fool() {} } + +final class Final_Class_Final_Constants { + final public const FINAL_PUBLIC_CONST = 23; + protected final const FINAL_PROTECTED_CONST = 'foo'; +} + +final class Final_Class_Regular_Constants { + public const PUBLIC_CONST = 23; + protected const PROTECTED_CONST = 'foo'; + private const PRIVATE_CONST = true; +} + +class Regular_Class_Final_Constants { + public final const FINAL_PUBLIC_CONST = 23; + final protected const FINAL_PROTECTED_CONST = 'foo'; +} + +class Regular_Class_Regular_Constants { + public const PUBLIC_CONST = 23; + protected const PROTECTED_CONST = 'foo'; + private const PRIVATE_CONST = true; +} diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php index 8ee5f3b3c0..6557db4348 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php @@ -56,6 +56,8 @@ public function getWarningList($testFile='') 18 => 1, 32 => 1, 33 => 1, + 37 => 1, + 38 => 1, ]; default: return []; From 89535fbd7fea456086eb53e9e13b0317b7cb8fd8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 12 Jan 2024 19:46:00 +0100 Subject: [PATCH 255/874] Filter/ExactMatch: rename a private property Follow up on PR 202. There has been some discussion in ticket 198 about the future names of the methods which are associated with the properties and as one of the methods will get a rename, this commit anticipates on that by renaming the property which will capture the return value of the method to be in line with that change. As the property is `private`, this is a change which doesn't affect the API and is therefore non-breaking. The method renames will be handled in separate PRs as those are in the public API. See 198, 199 and 203. --- src/Filters/ExactMatch.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Filters/ExactMatch.php b/src/Filters/ExactMatch.php index ce04e02bcd..d41fccd255 100644 --- a/src/Filters/ExactMatch.php +++ b/src/Filters/ExactMatch.php @@ -2,7 +2,7 @@ /** * An abstract filter class for checking files and folders against exact matches. * - * Supports both allowed files and blocked files. + * Supports both allowed files and disallowed files. * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -21,12 +21,12 @@ abstract class ExactMatch extends Filter * * @var array */ - private $blockedFiles = null; + private $disallowedFiles = null; /** * A list of files to include. * - * If the allowed files list is empty, only files in the blocked files list will be excluded. + * If the allowed files list is empty, only files in the disallowed files list will be excluded. * * @var array */ @@ -36,7 +36,7 @@ abstract class ExactMatch extends Filter /** * Check whether the current element of the iterator is acceptable. * - * If a file is both blocked and allowed, it will be deemed unacceptable. + * If a file is both disallowed and allowed, it will be deemed unacceptable. * * @return bool */ @@ -46,8 +46,8 @@ public function accept() return false; } - if ($this->blockedFiles === null) { - $this->blockedFiles = $this->getblacklist(); + if ($this->disallowedFiles === null) { + $this->disallowedFiles = $this->getblacklist(); } if ($this->allowedFiles === null) { @@ -56,13 +56,13 @@ public function accept() $filePath = Util\Common::realpath($this->current()); - // If file is both blocked and allowed, the blocked files list takes precedence. - if (isset($this->blockedFiles[$filePath]) === true) { + // If file is both disallowed and allowed, the disallowed files list takes precedence. + if (isset($this->disallowedFiles[$filePath]) === true) { return false; } - if (empty($this->allowedFiles) === true && empty($this->blockedFiles) === false) { - // We are only checking a blocked files list, so everything else should be allowed. + if (empty($this->allowedFiles) === true && empty($this->disallowedFiles) === false) { + // We are only checking a disallowed files list, so everything else should be allowed. return true; } @@ -74,7 +74,7 @@ public function accept() /** * Returns an iterator for the current entry. * - * Ensures that the blocked files list and the allowed files list are preserved so they don't have + * Ensures that the disallowed files list and the allowed files list are preserved so they don't have * to be generated each time. * * @return \RecursiveIterator @@ -82,8 +82,8 @@ public function accept() public function getChildren() { $children = parent::getChildren(); - $children->blockedFiles = $this->blockedFiles; - $children->allowedFiles = $this->allowedFiles; + $children->disallowedFiles = $this->disallowedFiles; + $children->allowedFiles = $this->allowedFiles; return $children; }//end getChildren() From f0ead3215f29edb775bb03dcb90f4a75ebde97bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C5=BDoljom?= Date: Sat, 13 Jan 2024 04:47:10 +0100 Subject: [PATCH 256/874] [Documentation] PSR12 - Import Statement (#232) * Add the documentation for the PSR12 Import Statement sniff --- .../Docs/Files/ImportStatementStandard.xml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/Standards/PSR12/Docs/Files/ImportStatementStandard.xml diff --git a/src/Standards/PSR12/Docs/Files/ImportStatementStandard.xml b/src/Standards/PSR12/Docs/Files/ImportStatementStandard.xml new file mode 100644 index 0000000000..66b58de0c5 --- /dev/null +++ b/src/Standards/PSR12/Docs/Files/ImportStatementStandard.xml @@ -0,0 +1,33 @@ + + + + + + + + + + \Vendor\Package\ClassA as A; + +class FooBar extends A +{ + // Class content. +} + ]]> + + + From 8ffe4035898c506ecab8109f24f2f26e9b1292ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C5=BDoljom?= Date: Sat, 13 Jan 2024 06:43:50 +0100 Subject: [PATCH 257/874] [Documentation] PSR12 - Constant Visiblity (#238) * Add the documentation for the PSR12 Constant Visiblity sniff --- .../Properties/ConstantVisibilityStandard.xml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Standards/PSR12/Docs/Properties/ConstantVisibilityStandard.xml diff --git a/src/Standards/PSR12/Docs/Properties/ConstantVisibilityStandard.xml b/src/Standards/PSR12/Docs/Properties/ConstantVisibilityStandard.xml new file mode 100644 index 0000000000..da9b60a404 --- /dev/null +++ b/src/Standards/PSR12/Docs/Properties/ConstantVisibilityStandard.xml @@ -0,0 +1,27 @@ + + + + + + + private const BAR = 'bar'; +} + ]]> + + + const BAR = 'bar'; +} + ]]> + + + From e6f43f6d86b09bead124a871ecaf7c2119bf361b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 5 Jan 2024 09:19:58 +0100 Subject: [PATCH 258/874] Tests/ExplainTest: expand the tests These additional tests test different aspects of the explain command functionality, as well as document the behaviour of the command. --- .../Core/Ruleset/ExplainCustomRulesetTest.xml | 10 ++ tests/Core/Ruleset/ExplainSingleSniffTest.xml | 6 + tests/Core/Ruleset/ExplainTest.php | 158 +++++++++++++++++- 3 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 tests/Core/Ruleset/ExplainCustomRulesetTest.xml create mode 100644 tests/Core/Ruleset/ExplainSingleSniffTest.xml diff --git a/tests/Core/Ruleset/ExplainCustomRulesetTest.xml b/tests/Core/Ruleset/ExplainCustomRulesetTest.xml new file mode 100644 index 0000000000..cbca4fd512 --- /dev/null +++ b/tests/Core/Ruleset/ExplainCustomRulesetTest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/Core/Ruleset/ExplainSingleSniffTest.xml b/tests/Core/Ruleset/ExplainSingleSniffTest.xml new file mode 100644 index 0000000000..159b7efa85 --- /dev/null +++ b/tests/Core/Ruleset/ExplainSingleSniffTest.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index df145a2f9d..d2226c4352 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -11,6 +11,7 @@ use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Runner; use PHPUnit\Framework\TestCase; /** @@ -30,7 +31,7 @@ final class ExplainTest extends TestCase public function testExplain() { // Set up the ruleset. - $config = new Config(['--standard=PSR1', '-e']); + $config = new Config(['--standard=PSR1', '-e', '--report-width=80']); $ruleset = new Ruleset($config); $expected = PHP_EOL; @@ -57,4 +58,159 @@ public function testExplain() }//end testExplain() + /** + * Test the output of the "explain" command is not influenced by a user set report width. + * + * @return void + */ + public function testExplainAlwaysDisplaysCompleteSniffName() + { + // Set up the ruleset. + $config = new Config(['--standard=PSR1', '-e', '--report-width=30']); + $ruleset = new Ruleset($config); + + $expected = PHP_EOL; + $expected .= 'The PSR1 standard contains 8 sniffs'.PHP_EOL.PHP_EOL; + $expected .= 'Generic (4 sniffs)'.PHP_EOL; + $expected .= '------------------'.PHP_EOL; + $expected .= ' Generic.Files.ByteOrderMark'.PHP_EOL; + $expected .= ' Generic.NamingConventions.UpperCaseConstantName'.PHP_EOL; + $expected .= ' Generic.PHP.DisallowAlternativePHPTags'.PHP_EOL; + $expected .= ' Generic.PHP.DisallowShortOpenTag'.PHP_EOL.PHP_EOL; + $expected .= 'PSR1 (3 sniffs)'.PHP_EOL; + $expected .= '---------------'.PHP_EOL; + $expected .= ' PSR1.Classes.ClassDeclaration'.PHP_EOL; + $expected .= ' PSR1.Files.SideEffects'.PHP_EOL; + $expected .= ' PSR1.Methods.CamelCapsMethodName'.PHP_EOL.PHP_EOL; + $expected .= 'Squiz (1 sniff)'.PHP_EOL; + $expected .= '---------------'.PHP_EOL; + $expected .= ' Squiz.Classes.ValidClassName'.PHP_EOL; + + $this->expectOutputString($expected); + + $ruleset->explain(); + + }//end testExplainAlwaysDisplaysCompleteSniffName() + + + /** + * Test the output of the "explain" command when a ruleset only contains a single sniff. + * + * This is mostly about making sure that the summary line uses the correct grammar. + * + * @return void + */ + public function testExplainSingleSniff() + { + // Set up the ruleset. + $standard = __DIR__.'/ExplainSingleSniffTest.xml'; + $config = new Config(["--standard=$standard", '-e', '--report-width=80']); + $ruleset = new Ruleset($config); + + $expected = PHP_EOL; + $expected .= 'The ExplainSingleSniffTest standard contains 1 sniff'.PHP_EOL.PHP_EOL; + $expected .= 'Squiz (1 sniff)'.PHP_EOL; + $expected .= '---------------'.PHP_EOL; + $expected .= ' Squiz.Scope.MethodScope'.PHP_EOL; + + $this->expectOutputString($expected); + + $ruleset->explain(); + + }//end testExplainSingleSniff() + + + /** + * Test that "explain" works correctly with custom rulesets. + * + * Verifies that: + * - The "standard" name is taken from the custom ruleset. + * - Any and all sniff additions and exclusions in the ruleset are taken into account correctly. + * - That the displayed list will have both the standards as well as the sniff names + * ordered alphabetically. + * + * @return void + */ + public function testExplainCustomRuleset() + { + // Set up the ruleset. + $standard = __DIR__.'/ExplainCustomRulesetTest.xml'; + $config = new Config(["--standard=$standard", '-e', '--report-width=80']); + $ruleset = new Ruleset($config); + + $expected = PHP_EOL; + $expected .= 'The ExplainCustomRulesetTest standard contains 10 sniffs'.PHP_EOL.PHP_EOL; + $expected .= 'Generic (4 sniffs)'.PHP_EOL; + $expected .= '------------------'.PHP_EOL; + $expected .= ' Generic.Files.ByteOrderMark'.PHP_EOL; + $expected .= ' Generic.NamingConventions.UpperCaseConstantName'.PHP_EOL; + $expected .= ' Generic.PHP.DisallowAlternativePHPTags'.PHP_EOL; + $expected .= ' Generic.PHP.DisallowShortOpenTag'.PHP_EOL.PHP_EOL; + $expected .= 'PSR1 (2 sniffs)'.PHP_EOL; + $expected .= '---------------'.PHP_EOL; + $expected .= ' PSR1.Classes.ClassDeclaration'.PHP_EOL; + $expected .= ' PSR1.Methods.CamelCapsMethodName'.PHP_EOL.PHP_EOL; + $expected .= 'PSR12 (2 sniffs)'.PHP_EOL; + $expected .= '----------------'.PHP_EOL; + $expected .= ' PSR12.ControlStructures.BooleanOperatorPlacement'.PHP_EOL; + $expected .= ' PSR12.ControlStructures.ControlStructureSpacing'.PHP_EOL.PHP_EOL; + $expected .= 'Squiz (2 sniffs)'.PHP_EOL; + $expected .= '----------------'.PHP_EOL; + $expected .= ' Squiz.Classes.ValidClassName'.PHP_EOL; + $expected .= ' Squiz.Scope.MethodScope'.PHP_EOL; + + $this->expectOutputString($expected); + + $ruleset->explain(); + + }//end testExplainCustomRuleset() + + + /** + * Test that each standard passed on the command-line is explained separately. + * + * @covers \PHP_CodeSniffer\Runner::runPHPCS + * + * @return void + */ + public function testExplainWillExplainEachStandardSeparately() + { + $standard = __DIR__.'/ExplainSingleSniffTest.xml'; + $_SERVER['argv'] = [ + 'phpcs', + '-e', + "--standard=PSR1,$standard", + '--report-width=80', + ]; + + $expected = PHP_EOL; + $expected .= 'The PSR1 standard contains 8 sniffs'.PHP_EOL.PHP_EOL; + $expected .= 'Generic (4 sniffs)'.PHP_EOL; + $expected .= '------------------'.PHP_EOL; + $expected .= ' Generic.Files.ByteOrderMark'.PHP_EOL; + $expected .= ' Generic.NamingConventions.UpperCaseConstantName'.PHP_EOL; + $expected .= ' Generic.PHP.DisallowAlternativePHPTags'.PHP_EOL; + $expected .= ' Generic.PHP.DisallowShortOpenTag'.PHP_EOL.PHP_EOL; + $expected .= 'PSR1 (3 sniffs)'.PHP_EOL; + $expected .= '---------------'.PHP_EOL; + $expected .= ' PSR1.Classes.ClassDeclaration'.PHP_EOL; + $expected .= ' PSR1.Files.SideEffects'.PHP_EOL; + $expected .= ' PSR1.Methods.CamelCapsMethodName'.PHP_EOL.PHP_EOL; + $expected .= 'Squiz (1 sniff)'.PHP_EOL; + $expected .= '---------------'.PHP_EOL; + $expected .= ' Squiz.Classes.ValidClassName'.PHP_EOL.PHP_EOL; + + $expected .= 'The ExplainSingleSniffTest standard contains 1 sniff'.PHP_EOL.PHP_EOL; + $expected .= 'Squiz (1 sniff)'.PHP_EOL; + $expected .= '---------------'.PHP_EOL; + $expected .= ' Squiz.Scope.MethodScope'.PHP_EOL; + + $this->expectOutputString($expected); + + $runner = new Runner(); + $exitCode = $runner->runPHPCS(); + + }//end testExplainWillExplainEachStandardSeparately() + + }//end class From f66c3231df468118a60be80f33b277810d61f68a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 05:50:55 +0100 Subject: [PATCH 259/874] Tests/ErrorSuppressionTest: normalize data provider arrays ... to improve scannability of the test cases covered. See 225 --- tests/Core/ErrorSuppressionTest.php | 80 +++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index 212cef425a..3b0de34436 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -391,12 +391,24 @@ public static function dataSuppressLine() ], // With suppression on line before. - 'ignore: line before, slash comment' => ['before' => '// phpcs:ignore'], - 'ignore: line before, slash comment, with @' => ['before' => '// @phpcs:ignore'], - 'ignore: line before, hash comment' => ['before' => '# phpcs:ignore'], - 'ignore: line before, hash comment, with @' => ['before' => '# @phpcs:ignore'], - 'ignore: line before, star comment' => ['before' => '/* phpcs:ignore */'], - 'ignore: line before, star comment, with @' => ['before' => '/* @phpcs:ignore */'], + 'ignore: line before, slash comment' => [ + 'before' => '// phpcs:ignore', + ], + 'ignore: line before, slash comment, with @' => [ + 'before' => '// @phpcs:ignore', + ], + 'ignore: line before, hash comment' => [ + 'before' => '# phpcs:ignore', + ], + 'ignore: line before, hash comment, with @' => [ + 'before' => '# @phpcs:ignore', + ], + 'ignore: line before, star comment' => [ + 'before' => '/* phpcs:ignore */', + ], + 'ignore: line before, star comment, with @' => [ + 'before' => '/* @phpcs:ignore */', + ], // With suppression as trailing comment on code line. 'ignore: end of line, slash comment' => [ @@ -417,7 +429,9 @@ public static function dataSuppressLine() ], // Deprecated syntax. - 'old style: line before, slash comment' => ['before' => '// @codingStandardsIgnoreLine'], + 'old style: line before, slash comment' => [ + 'before' => '// @codingStandardsIgnoreLine', + ], 'old style: end of line, slash comment' => [ 'before' => '', 'after' => ' // @codingStandardsIgnoreLine', @@ -732,16 +746,30 @@ public static function dataSuppressFile() ], // Process with suppression. - 'ignoreFile: start of file, slash comment' => ['before' => '// phpcs:ignoreFile'], - 'ignoreFile: start of file, slash comment, with @' => ['before' => '// @phpcs:ignoreFile'], - 'ignoreFile: start of file, slash comment, mixed case' => ['before' => '// PHPCS:Ignorefile'], - 'ignoreFile: start of file, hash comment' => ['before' => '# phpcs:ignoreFile'], - 'ignoreFile: start of file, hash comment, with @' => ['before' => '# @phpcs:ignoreFile'], - 'ignoreFile: start of file, single-line star comment' => ['before' => '/* phpcs:ignoreFile */'], + 'ignoreFile: start of file, slash comment' => [ + 'before' => '// phpcs:ignoreFile', + ], + 'ignoreFile: start of file, slash comment, with @' => [ + 'before' => '// @phpcs:ignoreFile', + ], + 'ignoreFile: start of file, slash comment, mixed case' => [ + 'before' => '// PHPCS:Ignorefile', + ], + 'ignoreFile: start of file, hash comment' => [ + 'before' => '# phpcs:ignoreFile', + ], + 'ignoreFile: start of file, hash comment, with @' => [ + 'before' => '# @phpcs:ignoreFile', + ], + 'ignoreFile: start of file, single-line star comment' => [ + 'before' => '/* phpcs:ignoreFile */', + ], 'ignoreFile: start of file, multi-line star comment' => [ 'before' => '/*'.PHP_EOL.' phpcs:ignoreFile'.PHP_EOL.' */', ], - 'ignoreFile: start of file, single-line docblock comment' => ['before' => '/** phpcs:ignoreFile */'], + 'ignoreFile: start of file, single-line docblock comment' => [ + 'before' => '/** phpcs:ignoreFile */', + ], // Process late comment. 'ignoreFile: late comment, slash comment' => [ @@ -750,12 +778,18 @@ public static function dataSuppressFile() ], // Deprecated syntax. - 'old style: start of file, slash comment' => ['before' => '// @codingStandardsIgnoreFile'], - 'old style: start of file, single-line star comment' => ['before' => '/* @codingStandardsIgnoreFile */'], + 'old style: start of file, slash comment' => [ + 'before' => '// @codingStandardsIgnoreFile', + ], + 'old style: start of file, single-line star comment' => [ + 'before' => '/* @codingStandardsIgnoreFile */', + ], 'old style: start of file, multi-line star comment' => [ 'before' => '/*'.PHP_EOL.' @codingStandardsIgnoreFile'.PHP_EOL.' */', ], - 'old style: start of file, single-line docblock comment' => ['before' => '/** @codingStandardsIgnoreFile */'], + 'old style: start of file, single-line docblock comment' => [ + 'before' => '/** @codingStandardsIgnoreFile */', + ], // Deprecated syntax, late comment. 'old style: late comment, slash comment' => [ @@ -843,7 +877,9 @@ public static function dataDisableSelected() ], // Multiple sniffs. - 'disable: multiple sniffs in one comment' => ['before' => '// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant'], + 'disable: multiple sniffs in one comment' => [ + 'before' => '// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant', + ], 'disable: multiple sniff in multiple comments' => [ 'before' => '// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'// phpcs:disable Generic.PHP.LowerCaseConstant', ], @@ -853,12 +889,16 @@ public static function dataDisableSelected() 'before' => '// phpcs:disable Generic.Commenting', 'expectedErrors' => 1, ], - 'disable: whole standard' => ['before' => '// phpcs:disable Generic'], + 'disable: whole standard' => [ + 'before' => '// phpcs:disable Generic', + ], 'disable: single errorcode' => [ 'before' => '# @phpcs:disable Generic.Commenting.Todo.TaskFound', 'expectedErrors' => 1, ], - 'disable: single errorcode and a category' => ['before' => '// phpcs:disable Generic.PHP.LowerCaseConstant.Found,Generic.Commenting'], + 'disable: single errorcode and a category' => [ + 'before' => '// phpcs:disable Generic.PHP.LowerCaseConstant.Found,Generic.Commenting', + ], // Wrong category/sniff/code. 'disable: wrong error code and category' => [ From dc5a0f42401aa6274c0cc0722a3e6ad28b057650 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 06:05:15 +0100 Subject: [PATCH 260/874] Tests/ErrorSuppressionTest: improve doc type specificity --- tests/Core/ErrorSuppressionTest.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index 3b0de34436..28165be5b5 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -63,7 +63,7 @@ public function testSuppressError($before, $after, $expectedErrors=0) * * @see testSuppressError() * - * @return array + * @return array> */ public static function dataSuppressError() { @@ -202,7 +202,7 @@ public function testSuppressSomeErrors($before, $between, $expectedErrors=1) * * @see testSuppressSomeErrors() * - * @return array + * @return array> */ public static function dataSuppressSomeErrors() { @@ -294,7 +294,7 @@ public function testSuppressWarning($before, $after, $expectedWarnings=0) * * @see testSuppressWarning() * - * @return array + * @return array> */ public static function dataSuppressWarning() { @@ -379,7 +379,7 @@ public function testSuppressLine($before, $after='', $expectedErrors=1) * * @see testSuppressLine() * - * @return array + * @return array> */ public static function dataSuppressLine() { @@ -544,7 +544,7 @@ public function testNestedSuppressLine($before, $after) * * @see testNestedSuppressLine() * - * @return array + * @return array> */ public static function dataNestedSuppressLine() { @@ -639,7 +639,7 @@ function myFunction() { * * @see testSuppressScope() * - * @return array + * @return array> */ public static function dataSuppressScope() { @@ -734,7 +734,7 @@ class MyClass {} * * @see testSuppressFile() * - * @return array + * @return array> */ public static function dataSuppressFile() { @@ -853,7 +853,7 @@ public function testDisableSelected($before, $expectedErrors=0, $expectedWarning * * @see testDisableSelected() * - * @return array + * @return array> */ public static function dataDisableSelected() { @@ -966,7 +966,7 @@ public function testEnableSelected($code, $expectedErrors, $expectedWarnings) * * @see testEnableSelected() * - * @return array + * @return array> */ public static function dataEnableSelected() { @@ -1146,7 +1146,7 @@ public function testIgnoreSelected($before, $expectedErrors, $expectedWarnings) * * @see testIgnoreSelected() * - * @return array + * @return array> */ public static function dataIgnoreSelected() { @@ -1233,7 +1233,7 @@ public function testCommenting($code, $expectedErrors, $expectedWarnings) * * @see testCommenting() * - * @return array + * @return array> */ public static function dataCommenting() { From 27225219a498c5072662d78bd9b916a91d13ec2a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 06:33:34 +0100 Subject: [PATCH 261/874] Tests/ErrorSuppressionTest: improve `@covers` tag --- tests/Core/ErrorSuppressionTest.php | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index 28165be5b5..65fc961fda 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -17,7 +17,8 @@ /** * Tests for PHP_CodeSniffer error suppression tags. * - * @coversNothing + * @covers PHP_CodeSniffer\Files\File::addMessage + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap */ final class ErrorSuppressionTest extends TestCase { @@ -32,7 +33,6 @@ final class ErrorSuppressionTest extends TestCase * Defaults to 0. * * @dataProvider dataSuppressError - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ @@ -165,7 +165,6 @@ public static function dataSuppressError() * Defaults to 1. * * @dataProvider dataSuppressSomeErrors - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ @@ -258,7 +257,6 @@ public static function dataSuppressSomeErrors() * Defaults to 0. * * @dataProvider dataSuppressWarning - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ @@ -343,7 +341,6 @@ public static function dataSuppressWarning() * Defaults to 1. * * @dataProvider dataSuppressLine - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ @@ -444,8 +441,6 @@ public static function dataSuppressLine() /** * Test suppressing a single error using a single line ignore in the middle of a line. * - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap - * * @return void */ public function testSuppressLineMidLine() @@ -469,8 +464,6 @@ public function testSuppressLineMidLine() /** * Test suppressing a single error using a single line ignore within a docblock. * - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap - * * @return void */ public function testSuppressLineWithinDocblock() @@ -507,7 +500,6 @@ public function testSuppressLineWithinDocblock() * @param string $after Annotation to place after the code. * * @dataProvider dataNestedSuppressLine - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ @@ -598,7 +590,6 @@ public static function dataNestedSuppressLine() * Defaults to 0. * * @dataProvider dataSuppressScope - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ @@ -696,7 +687,6 @@ public static function dataSuppressScope() * Defaults to 0. * * @dataProvider dataSuppressFile - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ @@ -811,7 +801,6 @@ public static function dataSuppressFile() * Defaults to 0. * * @dataProvider dataDisableSelected - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ @@ -929,7 +918,6 @@ public static function dataDisableSelected() * @param int $expectedWarnings Number of warnings expected. * * @dataProvider dataEnableSelected - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ @@ -1104,7 +1092,6 @@ public static function dataEnableSelected() * @param int $expectedWarnings Number of warnings expected. * * @dataProvider dataIgnoreSelected - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ @@ -1196,7 +1183,6 @@ public static function dataIgnoreSelected() * @param int $expectedWarnings Number of warnings expected. * * @dataProvider dataCommenting - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap * * @return void */ From ecbdc37089778ee67da28ea652ba8739fc0e8bcb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 5 Jan 2024 09:40:48 +0100 Subject: [PATCH 262/874] Tests/SetSniffPropertyTest: rename fixtures With an eye on adding additional tests for the Ruleset class, which would require additional test fixtures, this commit renames the `Category` subdirectory to `SetProperty` to directly link the fixtures in that folder to the `SetSniffPropertyTest`. It also removes the `SetProperty` prefix from the dummy sniffs in that folder as it is not necessary anymore what with the folder being renamed. Includes making the necessary updates to the dummy sniffs and the tests to allow for the rename. --- .../AllowedAsDeclaredSniff.php} | 4 +- .../AllowedViaMagicMethodSniff.php} | 4 +- .../AllowedViaStdClassSniff.php} | 4 +- .../NotAllowedViaAttributeSniff.php} | 4 +- .../SetPropertyAllowedAsDeclaredTest.xml | 2 +- .../SetPropertyAllowedViaMagicMethodTest.xml | 2 +- .../SetPropertyAllowedViaStdClassTest.xml | 2 +- .../SetPropertyNotAllowedViaAttributeTest.xml | 2 +- tests/Core/Ruleset/SetSniffPropertyTest.php | 38 +++++++++---------- 9 files changed, 31 insertions(+), 31 deletions(-) rename tests/Core/Ruleset/Fixtures/Sniffs/{Category/SetPropertyAllowedAsDeclaredSniff.php => SetProperty/AllowedAsDeclaredSniff.php} (81%) rename tests/Core/Ruleset/Fixtures/Sniffs/{Category/SetPropertyAllowedViaMagicMethodSniff.php => SetProperty/AllowedViaMagicMethodSniff.php} (86%) rename tests/Core/Ruleset/Fixtures/Sniffs/{Category/SetPropertyAllowedViaStdClassSniff.php => SetProperty/AllowedViaStdClassSniff.php} (76%) rename tests/Core/Ruleset/Fixtures/Sniffs/{Category/SetPropertyNotAllowedViaAttributeSniff.php => SetProperty/NotAllowedViaAttributeSniff.php} (80%) diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyAllowedAsDeclaredSniff.php b/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedAsDeclaredSniff.php similarity index 81% rename from tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyAllowedAsDeclaredSniff.php rename to tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedAsDeclaredSniff.php index 7eeed212f3..c26160b279 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyAllowedAsDeclaredSniff.php +++ b/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedAsDeclaredSniff.php @@ -5,12 +5,12 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest */ -namespace Fixtures\Sniffs\Category; +namespace Fixtures\Sniffs\SetProperty; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; -class SetPropertyAllowedAsDeclaredSniff implements Sniff +class AllowedAsDeclaredSniff implements Sniff { public $arbitrarystring; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyAllowedViaMagicMethodSniff.php b/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php similarity index 86% rename from tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyAllowedViaMagicMethodSniff.php rename to tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php index 8421ce6c6d..04097bb91a 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyAllowedViaMagicMethodSniff.php +++ b/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php @@ -5,12 +5,12 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest */ -namespace Fixtures\Sniffs\Category; +namespace Fixtures\Sniffs\SetProperty; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; -class SetPropertyAllowedViaMagicMethodSniff implements Sniff +class AllowedViaMagicMethodSniff implements Sniff { private $magic = []; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyAllowedViaStdClassSniff.php b/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaStdClassSniff.php similarity index 76% rename from tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyAllowedViaStdClassSniff.php rename to tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaStdClassSniff.php index 6ffffad3e2..30418729dc 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyAllowedViaStdClassSniff.php +++ b/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaStdClassSniff.php @@ -5,13 +5,13 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest */ -namespace Fixtures\Sniffs\Category; +namespace Fixtures\Sniffs\SetProperty; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use stdClass; -class SetPropertyAllowedViaStdClassSniff extends stdClass implements Sniff +class AllowedViaStdClassSniff extends stdClass implements Sniff { public function register() diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyNotAllowedViaAttributeSniff.php b/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php similarity index 80% rename from tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyNotAllowedViaAttributeSniff.php rename to tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php index 2700b96558..e895a87a8b 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/Category/SetPropertyNotAllowedViaAttributeSniff.php +++ b/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php @@ -5,14 +5,14 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest */ -namespace Fixtures\Sniffs\Category; +namespace Fixtures\Sniffs\SetProperty; use AllowDynamicProperties; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; #[AllowDynamicProperties] -class SetPropertyNotAllowedViaAttributeSniff implements Sniff +class NotAllowedViaAttributeSniff implements Sniff { public function register() diff --git a/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml b/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml index 70859bac8c..5840d0c362 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml @@ -1,7 +1,7 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml b/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml index 65e22555f3..7ff2178247 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml @@ -1,7 +1,7 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml b/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml index ba094db24a..387f419e8d 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml @@ -1,7 +1,7 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml b/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml index e411520c19..7caae3d393 100644 --- a/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml +++ b/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml @@ -1,7 +1,7 @@ - + diff --git a/tests/Core/Ruleset/SetSniffPropertyTest.php b/tests/Core/Ruleset/SetSniffPropertyTest.php index 824ac73e38..2bd6e5c176 100644 --- a/tests/Core/Ruleset/SetSniffPropertyTest.php +++ b/tests/Core/Ruleset/SetSniffPropertyTest.php @@ -34,8 +34,8 @@ final class SetSniffPropertyTest extends TestCase */ public function testSniffPropertiesGetSetWhenAllowed($name) { - $sniffCode = "Fixtures.Category.{$name}"; - $sniffClass = 'Fixtures\Sniffs\Category\\'.$name.'Sniff'; + $sniffCode = "Fixtures.SetProperty.{$name}"; + $sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff'; $properties = [ 'arbitrarystring' => 'arbitraryvalue', 'arbitraryarray' => [ @@ -45,7 +45,7 @@ public function testSniffPropertiesGetSetWhenAllowed($name) ]; // Set up the ruleset. - $standard = __DIR__."/{$name}Test.xml"; + $standard = __DIR__."/SetProperty{$name}Test.xml"; $config = new Config(["--standard=$standard"]); $ruleset = new Ruleset($config); @@ -77,9 +77,9 @@ public function testSniffPropertiesGetSetWhenAllowed($name) public static function dataSniffPropertiesGetSetWhenAllowed() { return [ - 'Property allowed as explicitly declared' => ['SetPropertyAllowedAsDeclared'], - 'Property allowed as sniff extends stdClass' => ['SetPropertyAllowedViaStdClass'], - 'Property allowed as sniff has magic __set() method' => ['SetPropertyAllowedViaMagicMethod'], + 'Property allowed as explicitly declared' => ['AllowedAsDeclared'], + 'Property allowed as sniff extends stdClass' => ['AllowedViaStdClass'], + 'Property allowed as sniff has magic __set() method' => ['AllowedViaMagicMethod'], ]; }//end dataSniffPropertiesGetSetWhenAllowed() @@ -163,7 +163,7 @@ public function testSetPropertyThrowsErrorOnInvalidProperty() public function testSetPropertyThrowsErrorWhenPropertyOnlyAllowedViaAttribute() { $exceptionClass = 'PHP_CodeSniffer\Exceptions\RuntimeException'; - $exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff Fixtures.Category.SetPropertyNotAllowedViaAttribute'; + $exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff Fixtures.SetProperty.NotAllowedViaAttribute'; if (method_exists($this, 'expectException') === true) { $this->expectException($exceptionClass); $this->expectExceptionMessage($exceptionMsg); @@ -224,12 +224,12 @@ public function testSetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCateg */ public function testDirectCallWithNewArrayFormatSetsProperty() { - $name = 'SetPropertyAllowedAsDeclared'; - $sniffCode = "Fixtures.Category.{$name}"; - $sniffClass = 'Fixtures\Sniffs\Category\\'.$name.'Sniff'; + $name = 'AllowedAsDeclared'; + $sniffCode = "Fixtures.SetProperty.{$name}"; + $sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff'; // Set up the ruleset. - $standard = __DIR__."/{$name}Test.xml"; + $standard = __DIR__."/SetProperty{$name}Test.xml"; $config = new Config(["--standard=$standard"]); $ruleset = new Ruleset($config); @@ -275,12 +275,12 @@ public function testDirectCallWithNewArrayFormatSetsProperty() */ public function testDirectCallWithOldArrayFormatSetsProperty($propertyValue) { - $name = 'SetPropertyAllowedAsDeclared'; - $sniffCode = "Fixtures.Category.{$name}"; - $sniffClass = 'Fixtures\Sniffs\Category\\'.$name.'Sniff'; + $name = 'AllowedAsDeclared'; + $sniffCode = "Fixtures.SetProperty.{$name}"; + $sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff'; // Set up the ruleset. - $standard = __DIR__."/{$name}Test.xml"; + $standard = __DIR__."/SetProperty{$name}Test.xml"; $config = new Config(["--standard=$standard"]); $ruleset = new Ruleset($config); @@ -376,12 +376,12 @@ public function testDirectCallWithOldArrayFormatThrowsDeprecationNotice() $this->setExpectedException($exceptionClass, $exceptionMsg); } - $name = 'SetPropertyAllowedAsDeclared'; - $sniffCode = "Fixtures.Category.{$name}"; - $sniffClass = 'Fixtures\Sniffs\Category\\'.$name.'Sniff'; + $name = 'AllowedAsDeclared'; + $sniffCode = "Fixtures.SetProperty.{$name}"; + $sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff'; // Set up the ruleset. - $standard = __DIR__."/{$name}Test.xml"; + $standard = __DIR__."/SetProperty{$name}Test.xml"; $config = new Config(["--standard=$standard"]); $ruleset = new Ruleset($config); From 08a4b8bc99ad41fb06c22d3e05f64b11eab1b368 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 07:21:10 +0100 Subject: [PATCH 263/874] Tests/SetSniffPropertyTest: use named data within data sets This commit adds the parameter name for each item in the data set in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes minor array normalization. Includes making the data type in the docblock more specific. --- tests/Core/Ruleset/SetSniffPropertyTest.php | 24 +++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/Core/Ruleset/SetSniffPropertyTest.php b/tests/Core/Ruleset/SetSniffPropertyTest.php index 2bd6e5c176..1415dbf72d 100644 --- a/tests/Core/Ruleset/SetSniffPropertyTest.php +++ b/tests/Core/Ruleset/SetSniffPropertyTest.php @@ -72,7 +72,7 @@ public function testSniffPropertiesGetSetWhenAllowed($name) * * @see self::testSniffPropertiesGetSetWhenAllowed() * - * @return array + * @return array> */ public static function dataSniffPropertiesGetSetWhenAllowed() { @@ -313,34 +313,40 @@ public function testDirectCallWithOldArrayFormatSetsProperty($propertyValue) * * @see self::testDirectCallWithOldArrayFormatSetsProperty() * - * @return array + * @return array> */ public static function dataDirectCallWithOldArrayFormatSetsProperty() { return [ - 'Property value is not an array (boolean)' => [false], - 'Property value is not an array (string)' => ['a string'], - 'Property value is an empty array' => [[]], + 'Property value is not an array (boolean)' => [ + 'propertyValue' => false, + ], + 'Property value is not an array (string)' => [ + 'propertyValue' => 'a string', + ], + 'Property value is an empty array' => [ + 'propertyValue' => [], + ], 'Property value is an array without keys' => [ - [ + 'propertyValue' => [ 'value', false, ], ], 'Property value is an array without the "scope" or "value" keys' => [ - [ + 'propertyValue' => [ 'key1' => 'value', 'key2' => false, ], ], 'Property value is an array without the "scope" key' => [ - [ + 'propertyValue' => [ 'key1' => 'value', 'value' => true, ], ], 'Property value is an array without the "value" key' => [ - [ + 'propertyValue' => [ 'scope' => 'value', 'key2' => 1234, ], From 0e92765ecd565b75aceac0058073988e943d9ff6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 8 Jan 2024 00:36:43 +0100 Subject: [PATCH 264/874] Tests/BackfillReadonlyTest: fix typo in test case name --- tests/Core/Tokenizer/BackfillReadonlyTest.inc | 2 +- tests/Core/Tokenizer/BackfillReadonlyTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.inc b/tests/Core/Tokenizer/BackfillReadonlyTest.inc index 1e66d4643b..cbc91f13a3 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.inc +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.inc @@ -130,7 +130,7 @@ class ReadonlyWithDisjunctiveNormalForm public function __construct( /* testReadonlyConstructorPropertyPromotionWithDNF */ private readonly (B&C)|A $b1, - /* testReadonlyConstructorPropertyPromotionWithDNFAndRefence */ + /* testReadonlyConstructorPropertyPromotionWithDNFAndReference */ readonly (B&C)|A &$b2, ) {} diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index b0f7a9ca7a..e4268b58a7 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -180,7 +180,7 @@ public static function dataReadonly() 'readonly', ], [ - '/* testReadonlyConstructorPropertyPromotionWithDNFAndRefence */', + '/* testReadonlyConstructorPropertyPromotionWithDNFAndReference */', 'readonly', ], [ From a08b80d35dd6188dbd62602d922b401589f85be1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 08:40:22 +0100 Subject: [PATCH 265/874] Tests/BackfillReadonlyTest: simplify data providers The token content for the "target token" of these tests is the same in most cases, but was explicitly provided in all cases. This simplifies the data provider arrays by making the `$testContent` test parameters optional with a `'readonly'` default value, allowing for removing a significant number of the `$testContent` parameter values from the data providers. --- tests/Core/Tokenizer/BackfillReadonlyTest.php | 54 +++---------------- 1 file changed, 6 insertions(+), 48 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index e4268b58a7..0460eb4666 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -19,14 +19,15 @@ final class BackfillReadonlyTest extends AbstractMethodUnitTest * Test that the "readonly" keyword is tokenized as such. * * @param string $testMarker The comment which prefaces the target token in the test file. - * @param string $testContent The token content to look for. + * @param string $testContent Optional. The token content to look for. + * Defaults to lowercase "readonly". * * @dataProvider dataReadonly * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional * * @return void */ - public function testReadonly($testMarker, $testContent) + public function testReadonly($testMarker, $testContent='readonly') { $tokens = self::$phpcsFile->getTokens(); @@ -49,87 +50,66 @@ public static function dataReadonly() return [ [ '/* testReadonlyProperty */', - 'readonly', ], [ '/* testVarReadonlyProperty */', - 'readonly', ], [ '/* testReadonlyVarProperty */', - 'readonly', ], [ '/* testStaticReadonlyProperty */', - 'readonly', ], [ '/* testReadonlyStaticProperty */', - 'readonly', ], [ '/* testConstReadonlyProperty */', - 'readonly', ], [ '/* testReadonlyPropertyWithoutType */', - 'readonly', ], [ '/* testPublicReadonlyProperty */', - 'readonly', ], [ '/* testProtectedReadonlyProperty */', - 'readonly', ], [ '/* testPrivateReadonlyProperty */', - 'readonly', ], [ '/* testPublicReadonlyPropertyWithReadonlyFirst */', - 'readonly', ], [ '/* testProtectedReadonlyPropertyWithReadonlyFirst */', - 'readonly', ], [ '/* testPrivateReadonlyPropertyWithReadonlyFirst */', - 'readonly', ], [ '/* testReadonlyWithCommentsInDeclaration */', - 'readonly', ], [ '/* testReadonlyWithNullableProperty */', - 'readonly', ], [ '/* testReadonlyNullablePropertyWithUnionTypeHintAndNullFirst */', - 'readonly', ], [ '/* testReadonlyNullablePropertyWithUnionTypeHintAndNullLast */', - 'readonly', ], [ '/* testReadonlyPropertyWithArrayTypeHint */', - 'readonly', ], [ '/* testReadonlyPropertyWithSelfTypeHint */', - 'readonly', ], [ '/* testReadonlyPropertyWithParentTypeHint */', - 'readonly', ], [ '/* testReadonlyPropertyWithFullyQualifiedTypeHint */', - 'readonly', ], [ '/* testReadonlyIsCaseInsensitive */', @@ -137,7 +117,6 @@ public static function dataReadonly() ], [ '/* testReadonlyConstructorPropertyPromotion */', - 'readonly', ], [ '/* testReadonlyConstructorPropertyPromotionWithReference */', @@ -145,47 +124,36 @@ public static function dataReadonly() ], [ '/* testReadonlyPropertyInAnonymousClass */', - 'readonly', ], [ '/* testReadonlyPropertyDNFTypeUnqualified */', - 'readonly', ], [ '/* testReadonlyPropertyDNFTypeFullyQualified */', - 'readonly', ], [ '/* testReadonlyPropertyDNFTypePartiallyQualified */', - 'readonly', ], [ '/* testReadonlyPropertyDNFTypeRelativeName */', - 'readonly', ], [ '/* testReadonlyPropertyDNFTypeMultipleSets */', - 'readonly', ], [ '/* testReadonlyPropertyDNFTypeWithArray */', - 'readonly', ], [ '/* testReadonlyPropertyDNFTypeWithSpacesAndComments */', - 'readonly', ], [ '/* testReadonlyConstructorPropertyPromotionWithDNF */', - 'readonly', ], [ '/* testReadonlyConstructorPropertyPromotionWithDNFAndReference */', - 'readonly', ], [ '/* testParseErrorLiveCoding */', - 'readonly', ], ]; @@ -196,14 +164,15 @@ public static function dataReadonly() * Test that "readonly" when not used as the keyword is still tokenized as `T_STRING`. * * @param string $testMarker The comment which prefaces the target token in the test file. - * @param string $testContent The token content to look for. + * @param string $testContent Optional. The token content to look for. + * Defaults to lowercase "readonly". * * @dataProvider dataNotReadonly * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional * * @return void */ - public function testNotReadonly($testMarker, $testContent) + public function testNotReadonly($testMarker, $testContent='readonly') { $tokens = self::$phpcsFile->getTokens(); @@ -230,23 +199,18 @@ public static function dataNotReadonly() ], [ '/* testReadonlyUsedAsMethodName */', - 'readonly', ], [ '/* testReadonlyUsedAsPropertyName */', - 'readonly', ], [ '/* testReadonlyPropertyInTernaryOperator */', - 'readonly', ], [ '/* testReadonlyUsedAsFunctionName */', - 'readonly', ], [ '/* testReadonlyUsedAsFunctionNameWithReturnByRef */', - 'readonly', ], [ '/* testReadonlyUsedAsNamespaceName */', @@ -258,11 +222,9 @@ public static function dataNotReadonly() ], [ '/* testReadonlyAsFunctionCall */', - 'readonly', ], [ '/* testReadonlyAsNamespacedFunctionCall */', - 'readonly', ], [ '/* testReadonlyAsNamespaceRelativeFunctionCall */', @@ -270,7 +232,6 @@ public static function dataNotReadonly() ], [ '/* testReadonlyAsMethodCall */', - 'readonly', ], [ '/* testReadonlyAsNullsafeMethodCall */', @@ -278,7 +239,6 @@ public static function dataNotReadonly() ], [ '/* testReadonlyAsStaticMethodCallWithSpace */', - 'readonly', ], [ '/* testClassConstantFetchWithReadonlyAsConstantName */', @@ -286,11 +246,9 @@ public static function dataNotReadonly() ], [ '/* testReadonlyUsedAsFunctionCallWithSpaceBetweenKeywordAndParens */', - 'readonly', ], [ '/* testReadonlyUsedAsMethodNameWithDNFParam */', - 'readonly', ], ]; From 7a017f3ab04a8e5ae09f117657e743d6bd44a662 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 08:43:12 +0100 Subject: [PATCH 266/874] Tests/BackfillReadonlyTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes making the data types in the docblocks more specific. --- tests/Core/Tokenizer/BackfillReadonlyTest.php | 228 +++++++++--------- 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index 0460eb4666..f044e924a6 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -43,117 +43,117 @@ public function testReadonly($testMarker, $testContent='readonly') * * @see testReadonly() * - * @return array + * @return array> */ public static function dataReadonly() { return [ - [ - '/* testReadonlyProperty */', + 'property declaration, no visibility' => [ + 'testMarker' => '/* testReadonlyProperty */', ], - [ - '/* testVarReadonlyProperty */', + 'property declaration, var keyword before' => [ + 'testMarker' => '/* testVarReadonlyProperty */', ], - [ - '/* testReadonlyVarProperty */', + 'property declaration, var keyword after' => [ + 'testMarker' => '/* testReadonlyVarProperty */', ], - [ - '/* testStaticReadonlyProperty */', + 'property declaration, static before' => [ + 'testMarker' => '/* testStaticReadonlyProperty */', ], - [ - '/* testReadonlyStaticProperty */', + 'property declaration, static after' => [ + 'testMarker' => '/* testReadonlyStaticProperty */', ], - [ - '/* testConstReadonlyProperty */', + 'constant declaration, with visibility' => [ + 'testMarker' => '/* testConstReadonlyProperty */', ], - [ - '/* testReadonlyPropertyWithoutType */', + 'property declaration, missing type' => [ + 'testMarker' => '/* testReadonlyPropertyWithoutType */', ], - [ - '/* testPublicReadonlyProperty */', + 'property declaration, public before' => [ + 'testMarker' => '/* testPublicReadonlyProperty */', ], - [ - '/* testProtectedReadonlyProperty */', + 'property declaration, protected before' => [ + 'testMarker' => '/* testProtectedReadonlyProperty */', ], - [ - '/* testPrivateReadonlyProperty */', + 'property declaration, private before' => [ + 'testMarker' => '/* testPrivateReadonlyProperty */', ], - [ - '/* testPublicReadonlyPropertyWithReadonlyFirst */', + 'property declaration, public after' => [ + 'testMarker' => '/* testPublicReadonlyPropertyWithReadonlyFirst */', ], - [ - '/* testProtectedReadonlyPropertyWithReadonlyFirst */', + 'property declaration, protected after' => [ + 'testMarker' => '/* testProtectedReadonlyPropertyWithReadonlyFirst */', ], - [ - '/* testPrivateReadonlyPropertyWithReadonlyFirst */', + 'property declaration, private after' => [ + 'testMarker' => '/* testPrivateReadonlyPropertyWithReadonlyFirst */', ], - [ - '/* testReadonlyWithCommentsInDeclaration */', + 'property declaration, private before, comments in declaration' => [ + 'testMarker' => '/* testReadonlyWithCommentsInDeclaration */', ], - [ - '/* testReadonlyWithNullableProperty */', + 'property declaration, private before, nullable type' => [ + 'testMarker' => '/* testReadonlyWithNullableProperty */', ], - [ - '/* testReadonlyNullablePropertyWithUnionTypeHintAndNullFirst */', + 'property declaration, private before, union type, null first' => [ + 'testMarker' => '/* testReadonlyNullablePropertyWithUnionTypeHintAndNullFirst */', ], - [ - '/* testReadonlyNullablePropertyWithUnionTypeHintAndNullLast */', + 'property declaration, private before, union type, null last' => [ + 'testMarker' => '/* testReadonlyNullablePropertyWithUnionTypeHintAndNullLast */', ], - [ - '/* testReadonlyPropertyWithArrayTypeHint */', + 'property declaration, private before, array type' => [ + 'testMarker' => '/* testReadonlyPropertyWithArrayTypeHint */', ], - [ - '/* testReadonlyPropertyWithSelfTypeHint */', + 'property declaration, private before, self type' => [ + 'testMarker' => '/* testReadonlyPropertyWithSelfTypeHint */', ], - [ - '/* testReadonlyPropertyWithParentTypeHint */', + 'property declaration, private before, parent type' => [ + 'testMarker' => '/* testReadonlyPropertyWithParentTypeHint */', ], - [ - '/* testReadonlyPropertyWithFullyQualifiedTypeHint */', + 'property declaration, private before, FQN type' => [ + 'testMarker' => '/* testReadonlyPropertyWithFullyQualifiedTypeHint */', ], - [ - '/* testReadonlyIsCaseInsensitive */', - 'ReAdOnLy', + 'property declaration, public before, mixed case' => [ + 'testMarker' => '/* testReadonlyIsCaseInsensitive */', + 'testContent' => 'ReAdOnLy', ], - [ - '/* testReadonlyConstructorPropertyPromotion */', + 'property declaration, constructor property promotion' => [ + 'testMarker' => '/* testReadonlyConstructorPropertyPromotion */', ], - [ - '/* testReadonlyConstructorPropertyPromotionWithReference */', - 'ReadOnly', + 'property declaration, constructor property promotion with reference, mixed case' => [ + 'testMarker' => '/* testReadonlyConstructorPropertyPromotionWithReference */', + 'testContent' => 'ReadOnly', ], - [ - '/* testReadonlyPropertyInAnonymousClass */', + 'property declaration, in anonymous class' => [ + 'testMarker' => '/* testReadonlyPropertyInAnonymousClass */', ], - [ - '/* testReadonlyPropertyDNFTypeUnqualified */', + 'property declaration, no visibility, DNF type, unqualified' => [ + 'testMarker' => '/* testReadonlyPropertyDNFTypeUnqualified */', ], - [ - '/* testReadonlyPropertyDNFTypeFullyQualified */', + 'property declaration, public before, DNF type, fully qualified' => [ + 'testMarker' => '/* testReadonlyPropertyDNFTypeFullyQualified */', ], - [ - '/* testReadonlyPropertyDNFTypePartiallyQualified */', + 'property declaration, protected before, DNF type, partially qualified' => [ + 'testMarker' => '/* testReadonlyPropertyDNFTypePartiallyQualified */', ], - [ - '/* testReadonlyPropertyDNFTypeRelativeName */', + 'property declaration, private before, DNF type, namespace relative name' => [ + 'testMarker' => '/* testReadonlyPropertyDNFTypeRelativeName */', ], - [ - '/* testReadonlyPropertyDNFTypeMultipleSets */', + 'property declaration, private before, DNF type, multiple sets' => [ + 'testMarker' => '/* testReadonlyPropertyDNFTypeMultipleSets */', ], - [ - '/* testReadonlyPropertyDNFTypeWithArray */', + 'property declaration, private before, DNF type, union with array' => [ + 'testMarker' => '/* testReadonlyPropertyDNFTypeWithArray */', ], - [ - '/* testReadonlyPropertyDNFTypeWithSpacesAndComments */', + 'property declaration, private before, DNF type, with spaces and comment' => [ + 'testMarker' => '/* testReadonlyPropertyDNFTypeWithSpacesAndComments */', ], - [ - '/* testReadonlyConstructorPropertyPromotionWithDNF */', + 'property declaration, constructor property promotion, DNF type' => [ + 'testMarker' => '/* testReadonlyConstructorPropertyPromotionWithDNF */', ], - [ - '/* testReadonlyConstructorPropertyPromotionWithDNFAndReference */', + 'property declaration, constructor property promotion, DNF type and reference' => [ + 'testMarker' => '/* testReadonlyConstructorPropertyPromotionWithDNFAndReference */', ], - [ - '/* testParseErrorLiveCoding */', + 'live coding / parse error' => [ + 'testMarker' => '/* testParseErrorLiveCoding */', ], ]; @@ -188,67 +188,67 @@ public function testNotReadonly($testMarker, $testContent='readonly') * * @see testNotReadonly() * - * @return array + * @return array> */ public static function dataNotReadonly() { return [ - [ - '/* testReadonlyUsedAsClassConstantName */', - 'READONLY', + 'name of a constant, context: declaration using "const" keyword, uppercase' => [ + 'testMarker' => '/* testReadonlyUsedAsClassConstantName */', + 'testContent' => 'READONLY', ], - [ - '/* testReadonlyUsedAsMethodName */', + 'name of a method, context: declaration' => [ + 'testMarker' => '/* testReadonlyUsedAsMethodName */', ], - [ - '/* testReadonlyUsedAsPropertyName */', + 'name of a property, context: property access' => [ + 'testMarker' => '/* testReadonlyUsedAsPropertyName */', ], - [ - '/* testReadonlyPropertyInTernaryOperator */', + 'name of a property, context: property access in ternary' => [ + 'testMarker' => '/* testReadonlyPropertyInTernaryOperator */', ], - [ - '/* testReadonlyUsedAsFunctionName */', + 'name of a function, context: declaration' => [ + 'testMarker' => '/* testReadonlyUsedAsFunctionName */', ], - [ - '/* testReadonlyUsedAsFunctionNameWithReturnByRef */', + 'name of a function, context: declaration with return by ref' => [ + 'testMarker' => '/* testReadonlyUsedAsFunctionNameWithReturnByRef */', ], - [ - '/* testReadonlyUsedAsNamespaceName */', - 'Readonly', + 'name of namespace, context: declaration, mixed case' => [ + 'testMarker' => '/* testReadonlyUsedAsNamespaceName */', + 'testContent' => 'Readonly', ], - [ - '/* testReadonlyUsedAsPartOfNamespaceName */', - 'Readonly', + 'partial name of namespace, context: declaration, mixed case' => [ + 'testMarker' => '/* testReadonlyUsedAsPartOfNamespaceName */', + 'testContent' => 'Readonly', ], - [ - '/* testReadonlyAsFunctionCall */', + 'name of a function, context: call' => [ + 'testMarker' => '/* testReadonlyAsFunctionCall */', ], - [ - '/* testReadonlyAsNamespacedFunctionCall */', + 'name of a namespaced function, context: partially qualified call' => [ + 'testMarker' => '/* testReadonlyAsNamespacedFunctionCall */', ], - [ - '/* testReadonlyAsNamespaceRelativeFunctionCall */', - 'ReadOnly', + 'name of a function, context: namespace relative call, mixed case' => [ + 'testMarker' => '/* testReadonlyAsNamespaceRelativeFunctionCall */', + 'testContent' => 'ReadOnly', ], - [ - '/* testReadonlyAsMethodCall */', + 'name of a method, context: method call on object' => [ + 'testMarker' => '/* testReadonlyAsMethodCall */', ], - [ - '/* testReadonlyAsNullsafeMethodCall */', - 'readOnly', + 'name of a method, context: nullsafe method call on object' => [ + 'testMarker' => '/* testReadonlyAsNullsafeMethodCall */', + 'testContent' => 'readOnly', ], - [ - '/* testReadonlyAsStaticMethodCallWithSpace */', + 'name of a method, context: static method call with space after' => [ + 'testMarker' => '/* testReadonlyAsStaticMethodCallWithSpace */', ], - [ - '/* testClassConstantFetchWithReadonlyAsConstantName */', - 'READONLY', + 'name of a constant, context: constant access - uppercase' => [ + 'testMarker' => '/* testClassConstantFetchWithReadonlyAsConstantName */', + 'testContent' => 'READONLY', ], - [ - '/* testReadonlyUsedAsFunctionCallWithSpaceBetweenKeywordAndParens */', + 'name of a function, context: call with space and comment between keyword and parens' => [ + 'testMarker' => '/* testReadonlyUsedAsFunctionCallWithSpaceBetweenKeywordAndParens */', ], - [ - '/* testReadonlyUsedAsMethodNameWithDNFParam */', + 'name of a method, context: declaration with DNF parameter' => [ + 'testMarker' => '/* testReadonlyUsedAsMethodNameWithDNFParam */', ], ]; From e1157df197286ff5bf2484267a961b3c9a8557fc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 8 Jan 2024 01:03:00 +0100 Subject: [PATCH 267/874] Tests/AttributesTest: normalize data provider arrays ... to improve scannability of the test cases covered. See 225 --- tests/Core/Tokenizer/AttributesTest.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/Core/Tokenizer/AttributesTest.php b/tests/Core/Tokenizer/AttributesTest.php index ec0893f6dc..bdfe126257 100644 --- a/tests/Core/Tokenizer/AttributesTest.php +++ b/tests/Core/Tokenizer/AttributesTest.php @@ -72,7 +72,9 @@ public static function dataAttribute() [ '/* testAttribute */', 2, - [ T_STRING ], + [ + T_STRING, + ], ], [ '/* testAttributeWithParams */', @@ -104,7 +106,9 @@ public static function dataAttribute() [ '/* testAttributeOnFunction */', 2, - [ T_STRING ], + [ + T_STRING, + ], ], [ '/* testAttributeOnFunctionWithParams */', @@ -352,7 +356,9 @@ public static function dataAttributeOnParameters() '/* testSingleAttributeOnParameter */', 4, 2, - [T_STRING], + [ + T_STRING, + ], ], [ '/* testMultipleAttributesOnParameter */', From a1d13663b43c33844dba626026c2ef414fa80650 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 8 Jan 2024 00:54:36 +0100 Subject: [PATCH 268/874] Tests/AttributesTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes making the data types in the docblocks more specific. --- tests/Core/Tokenizer/AttributesTest.php | 156 ++++++++++++------------ 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/tests/Core/Tokenizer/AttributesTest.php b/tests/Core/Tokenizer/AttributesTest.php index bdfe126257..efac8a041e 100644 --- a/tests/Core/Tokenizer/AttributesTest.php +++ b/tests/Core/Tokenizer/AttributesTest.php @@ -18,9 +18,9 @@ final class AttributesTest extends AbstractMethodUnitTest /** * Test that attributes are parsed correctly. * - * @param string $testMarker The comment which prefaces the target token in the test file. - * @param int $length The number of tokens between opener and closer. - * @param array $tokenCodes The codes of tokens inside the attributes. + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int $length The number of tokens between opener and closer. + * @param array $tokenCodes The codes of tokens inside the attributes. * * @dataProvider dataAttribute * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize @@ -64,22 +64,22 @@ function ($token) use ($attribute, $length) { * * @see testAttribute() * - * @return array + * @return array>> */ public static function dataAttribute() { return [ - [ - '/* testAttribute */', - 2, - [ - T_STRING, + 'class attribute' => [ + 'testMarker' => '/* testAttribute */', + 'length' => 2, + 'tokenCodes' => [ + T_STRING ], ], - [ - '/* testAttributeWithParams */', - 7, - [ + 'class attribute with param' => [ + 'testMarker' => '/* testAttributeWithParams */', + 'length' => 7, + 'tokenCodes' => [ T_STRING, T_OPEN_PARENTHESIS, T_STRING, @@ -88,10 +88,10 @@ public static function dataAttribute() T_CLOSE_PARENTHESIS, ], ], - [ - '/* testAttributeWithNamedParam */', - 10, - [ + 'class attribute with named param' => [ + 'testMarker' => '/* testAttributeWithNamedParam */', + 'length' => 10, + 'tokenCodes' => [ T_STRING, T_OPEN_PARENTHESIS, T_PARAM_NAME, @@ -103,17 +103,17 @@ public static function dataAttribute() T_CLOSE_PARENTHESIS, ], ], - [ - '/* testAttributeOnFunction */', - 2, - [ - T_STRING, + 'function attribute' => [ + 'testMarker' => '/* testAttributeOnFunction */', + 'length' => 2, + 'tokenCodes' => [ + T_STRING ], ], - [ - '/* testAttributeOnFunctionWithParams */', - 17, - [ + 'function attribute with params' => [ + 'testMarker' => '/* testAttributeOnFunctionWithParams */', + 'length' => 17, + 'tokenCodes' => [ T_STRING, T_OPEN_PARENTHESIS, T_CONSTANT_ENCAPSED_STRING, @@ -132,10 +132,10 @@ public static function dataAttribute() T_CLOSE_PARENTHESIS, ], ], - [ - '/* testAttributeWithShortClosureParameter */', - 17, - [ + 'function attribute with arrow function as param' => [ + 'testMarker' => '/* testAttributeWithShortClosureParameter */', + 'length' => 17, + 'tokenCodes' => [ T_STRING, T_OPEN_PARENTHESIS, T_STATIC, @@ -154,10 +154,10 @@ public static function dataAttribute() T_CLOSE_PARENTHESIS, ], ], - [ - '/* testAttributeGrouping */', - 26, - [ + 'function attribute; multiple comma separated classes' => [ + 'testMarker' => '/* testAttributeGrouping */', + 'length' => 26, + 'tokenCodes' => [ T_STRING, T_COMMA, T_WHITESPACE, @@ -185,10 +185,10 @@ public static function dataAttribute() T_CLOSE_PARENTHESIS, ], ], - [ - '/* testAttributeMultiline */', - 31, - [ + 'function attribute; multiple comma separated classes, one per line' => [ + 'testMarker' => '/* testAttributeMultiline */', + 'length' => 31, + 'tokenCodes' => [ T_WHITESPACE, T_WHITESPACE, T_STRING, @@ -221,10 +221,10 @@ public static function dataAttribute() T_WHITESPACE, ], ], - [ - '/* testFqcnAttribute */', - 13, - [ + 'function attribute; using partially qualified and fully qualified class names' => [ + 'testMarker' => '/* testFqcnAttribute */', + 'length' => 13, + 'tokenCodes' => [ T_STRING, T_NS_SEPARATOR, T_STRING, @@ -294,10 +294,10 @@ public function testAttributeAndLineComment() /** * Test that attributes on function declaration parameters are parsed correctly. * - * @param string $testMarker The comment which prefaces the target token in the test file. - * @param int $position The token position (starting from T_FUNCTION) of T_ATTRIBUTE token. - * @param int $length The number of tokens between opener and closer. - * @param array $tokenCodes The codes of tokens inside the attributes. + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int $position The token position (starting from T_FUNCTION) of T_ATTRIBUTE token. + * @param int $length The number of tokens between opener and closer. + * @param array $tokenCodes The codes of tokens inside the attributes. * * @dataProvider dataAttributeOnParameters * @@ -347,24 +347,24 @@ function ($token) use ($attribute, $length) { * * @see testAttributeOnParameters() * - * @return array + * @return array>> */ public static function dataAttributeOnParameters() { return [ - [ - '/* testSingleAttributeOnParameter */', - 4, - 2, - [ - T_STRING, + 'parameter attribute; single, inline' => [ + 'testMarker' => '/* testSingleAttributeOnParameter */', + 'position' => 4, + 'length' => 2, + 'tokenCodes' => [ + T_STRING ], ], - [ - '/* testMultipleAttributesOnParameter */', - 4, - 10, - [ + 'parameter attribute; multiple comma separated, inline' => [ + 'testMarker' => '/* testMultipleAttributesOnParameter */', + 'position' => 4, + 'length' => 10, + 'tokenCodes' => [ T_STRING, T_COMMA, T_WHITESPACE, @@ -376,11 +376,11 @@ public static function dataAttributeOnParameters() T_CLOSE_PARENTHESIS, ], ], - [ - '/* testMultilineAttributesOnParameter */', - 4, - 13, - [ + 'parameter attribute; single, multiline' => [ + 'testMarker' => '/* testMultilineAttributesOnParameter */', + 'position' => 4, + 'length' => 13, + 'tokenCodes' => [ T_WHITESPACE, T_WHITESPACE, T_STRING, @@ -403,10 +403,10 @@ public static function dataAttributeOnParameters() /** * Test that an attribute containing text which looks like a PHP close tag is tokenized correctly. * - * @param string $testMarker The comment which prefaces the target token in the test file. - * @param int $length The number of tokens between opener and closer. - * @param array $expectedTokensAttribute The codes of tokens inside the attributes. - * @param array $expectedTokensAfter The codes of tokens after the attributes. + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int $length The number of tokens between opener and closer. + * @param array> $expectedTokensAttribute The codes of tokens inside the attributes. + * @param array $expectedTokensAfter The codes of tokens after the attributes. * * @covers PHP_CodeSniffer\Tokenizers\PHP::parsePhpAttribute * @@ -455,15 +455,15 @@ public function testAttributeContainingTextLookingLikeCloseTag($testMarker, $len * * @see dataAttributeOnTextLookingLikeCloseTag() * - * @return array + * @return array>|array>> */ public static function dataAttributeOnTextLookingLikeCloseTag() { return [ - [ - '/* testAttributeContainingTextLookingLikeCloseTag */', - 5, - [ + 'function attribute; string param with "?>"' => [ + 'testMarker' => '/* testAttributeContainingTextLookingLikeCloseTag */', + 'length' => 5, + 'expectedTokensAttribute' => [ [ 'T_STRING', 'DeprecationReason', @@ -485,7 +485,7 @@ public static function dataAttributeOnTextLookingLikeCloseTag() ']', ], ], - [ + 'expectedTokensAfter' => [ T_WHITESPACE, T_FUNCTION, T_WHITESPACE, @@ -497,10 +497,10 @@ public static function dataAttributeOnTextLookingLikeCloseTag() T_CLOSE_CURLY_BRACKET, ], ], - [ - '/* testAttributeContainingMultilineTextLookingLikeCloseTag */', - 8, - [ + 'function attribute; string param with "?>"; multiline' => [ + 'testMarker' => '/* testAttributeContainingMultilineTextLookingLikeCloseTag */', + 'length' => 8, + 'expectedTokensAttribute' => [ [ 'T_STRING', 'DeprecationReason', @@ -534,7 +534,7 @@ public static function dataAttributeOnTextLookingLikeCloseTag() ']', ], ], - [ + 'expectedTokensAfter' => [ T_WHITESPACE, T_FUNCTION, T_WHITESPACE, From 4920451f44f6b1d5c4d500fa9e1bcecdd64987d2 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 12 Jan 2024 04:25:45 +0100 Subject: [PATCH 269/874] Tests/AttributesTest: activate a test This test case already existed in the test case file, but was not being tested so far. Fixed now. --- tests/Core/Tokenizer/AttributesTest.php | 57 +++++++++++++++++++++---- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/tests/Core/Tokenizer/AttributesTest.php b/tests/Core/Tokenizer/AttributesTest.php index efac8a041e..86c0fa5ea0 100644 --- a/tests/Core/Tokenizer/AttributesTest.php +++ b/tests/Core/Tokenizer/AttributesTest.php @@ -69,14 +69,14 @@ function ($token) use ($attribute, $length) { public static function dataAttribute() { return [ - 'class attribute' => [ + 'class attribute' => [ 'testMarker' => '/* testAttribute */', 'length' => 2, 'tokenCodes' => [ T_STRING ], ], - 'class attribute with param' => [ + 'class attribute with param' => [ 'testMarker' => '/* testAttributeWithParams */', 'length' => 7, 'tokenCodes' => [ @@ -88,7 +88,7 @@ public static function dataAttribute() T_CLOSE_PARENTHESIS, ], ], - 'class attribute with named param' => [ + 'class attribute with named param' => [ 'testMarker' => '/* testAttributeWithNamedParam */', 'length' => 10, 'tokenCodes' => [ @@ -103,14 +103,14 @@ public static function dataAttribute() T_CLOSE_PARENTHESIS, ], ], - 'function attribute' => [ + 'function attribute' => [ 'testMarker' => '/* testAttributeOnFunction */', 'length' => 2, 'tokenCodes' => [ T_STRING ], ], - 'function attribute with params' => [ + 'function attribute with params' => [ 'testMarker' => '/* testAttributeOnFunctionWithParams */', 'length' => 17, 'tokenCodes' => [ @@ -132,7 +132,7 @@ public static function dataAttribute() T_CLOSE_PARENTHESIS, ], ], - 'function attribute with arrow function as param' => [ + 'function attribute with arrow function as param' => [ 'testMarker' => '/* testAttributeWithShortClosureParameter */', 'length' => 17, 'tokenCodes' => [ @@ -154,7 +154,7 @@ public static function dataAttribute() T_CLOSE_PARENTHESIS, ], ], - 'function attribute; multiple comma separated classes' => [ + 'function attribute; multiple comma separated classes' => [ 'testMarker' => '/* testAttributeGrouping */', 'length' => 26, 'tokenCodes' => [ @@ -185,7 +185,7 @@ public static function dataAttribute() T_CLOSE_PARENTHESIS, ], ], - 'function attribute; multiple comma separated classes, one per line' => [ + 'function attribute; multiple comma separated classes, one per line' => [ 'testMarker' => '/* testAttributeMultiline */', 'length' => 31, 'tokenCodes' => [ @@ -221,7 +221,46 @@ public static function dataAttribute() T_WHITESPACE, ], ], - 'function attribute; using partially qualified and fully qualified class names' => [ + 'function attribute; multiple comma separated classes, one per line, with comments' => [ + 'testMarker' => '/* testAttributeMultilineWithComment */', + 'length' => 34, + 'tokenCodes' => [ + T_WHITESPACE, + T_WHITESPACE, + T_STRING, + T_COMMA, + T_WHITESPACE, + T_COMMENT, + T_WHITESPACE, + T_STRING, + T_OPEN_PARENTHESIS, + T_COMMENT, + T_WHITESPACE, + T_CONSTANT_ENCAPSED_STRING, + T_CLOSE_PARENTHESIS, + T_COMMA, + T_WHITESPACE, + T_WHITESPACE, + T_STRING, + T_OPEN_PARENTHESIS, + T_CONSTANT_ENCAPSED_STRING, + T_COMMA, + T_WHITESPACE, + T_PARAM_NAME, + T_COLON, + T_WHITESPACE, + T_OPEN_SHORT_ARRAY, + T_CONSTANT_ENCAPSED_STRING, + T_WHITESPACE, + T_DOUBLE_ARROW, + T_WHITESPACE, + T_CONSTANT_ENCAPSED_STRING, + T_CLOSE_SHORT_ARRAY, + T_CLOSE_PARENTHESIS, + T_WHITESPACE, + ], + ], + 'function attribute; using partially qualified and fully qualified class names' => [ 'testMarker' => '/* testFqcnAttribute */', 'length' => 13, 'tokenCodes' => [ From 61aa313fa23de1249634642e1fe959adf8157878 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 08:00:14 +0100 Subject: [PATCH 270/874] Tests/BackfillNumericSeparatorTest::dataTestBackfill(): simplify data sets The data for each set was previously passed as an array instead of as values, even though the number of array items was known and stable. Fixed now. --- .../BackfillNumericSeparatorTest.php | 118 +++++++----------- 1 file changed, 47 insertions(+), 71 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php index 1052d63e08..253cb425e2 100644 --- a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php +++ b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php @@ -18,21 +18,23 @@ final class BackfillNumericSeparatorTest extends AbstractMethodUnitTest /** * Test that numbers using numeric separators are tokenized correctly. * - * @param array $testData The data required for the specific test case. + * @param string $marker The comment which prefaces the target token in the test file. + * @param string $type The expected token type. + * @param string $value The expected token content. * * @dataProvider dataTestBackfill * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize * * @return void */ - public function testBackfill($testData) + public function testBackfill($marker, $type, $value) { $tokens = self::$phpcsFile->getTokens(); - $number = $this->getTargetToken($testData['marker'], [T_LNUMBER, T_DNUMBER]); + $number = $this->getTargetToken($marker, [T_LNUMBER, T_DNUMBER]); - $this->assertSame(constant($testData['type']), $tokens[$number]['code']); - $this->assertSame($testData['type'], $tokens[$number]['type']); - $this->assertSame($testData['value'], $tokens[$number]['content']); + $this->assertSame(constant($type), $tokens[$number]['code']); + $this->assertSame($type, $tokens[$number]['type']); + $this->assertSame($value, $tokens[$number]['content']); }//end testBackfill() @@ -63,95 +65,69 @@ public static function dataTestBackfill() return [ [ - [ - 'marker' => '/* testSimpleLNumber */', - 'type' => 'T_LNUMBER', - 'value' => '1_000_000_000', - ], + 'marker' => '/* testSimpleLNumber */', + 'type' => 'T_LNUMBER', + 'value' => '1_000_000_000', ], [ - [ - 'marker' => '/* testSimpleDNumber */', - 'type' => 'T_DNUMBER', - 'value' => '107_925_284.88', - ], + 'marker' => '/* testSimpleDNumber */', + 'type' => 'T_DNUMBER', + 'value' => '107_925_284.88', ], [ - [ - 'marker' => '/* testFloat */', - 'type' => 'T_DNUMBER', - 'value' => '6.674_083e-11', - ], + 'marker' => '/* testFloat */', + 'type' => 'T_DNUMBER', + 'value' => '6.674_083e-11', ], [ - [ - 'marker' => '/* testFloat2 */', - 'type' => 'T_DNUMBER', - 'value' => '6.674_083e+11', - ], + 'marker' => '/* testFloat2 */', + 'type' => 'T_DNUMBER', + 'value' => '6.674_083e+11', ], [ - [ - 'marker' => '/* testFloat3 */', - 'type' => 'T_DNUMBER', - 'value' => '1_2.3_4e1_23', - ], + 'marker' => '/* testFloat3 */', + 'type' => 'T_DNUMBER', + 'value' => '1_2.3_4e1_23', ], [ - [ - 'marker' => '/* testHex */', - 'type' => $testHexType, - 'value' => '0xCAFE_F00D', - ], + 'marker' => '/* testHex */', + 'type' => $testHexType, + 'value' => '0xCAFE_F00D', ], [ - [ - 'marker' => '/* testHexMultiple */', - 'type' => $testHexMultipleType, - 'value' => '0x42_72_6F_77_6E', - ], + 'marker' => '/* testHexMultiple */', + 'type' => $testHexMultipleType, + 'value' => '0x42_72_6F_77_6E', ], [ - [ - 'marker' => '/* testHexInt */', - 'type' => 'T_LNUMBER', - 'value' => '0x42_72_6F', - ], + 'marker' => '/* testHexInt */', + 'type' => 'T_LNUMBER', + 'value' => '0x42_72_6F', ], [ - [ - 'marker' => '/* testBinary */', - 'type' => 'T_LNUMBER', - 'value' => '0b0101_1111', - ], + 'marker' => '/* testBinary */', + 'type' => 'T_LNUMBER', + 'value' => '0b0101_1111', ], [ - [ - 'marker' => '/* testOctal */', - 'type' => 'T_LNUMBER', - 'value' => '0137_041', - ], + 'marker' => '/* testOctal */', + 'type' => 'T_LNUMBER', + 'value' => '0137_041', ], [ - [ - 'marker' => '/* testExplicitOctal */', - 'type' => 'T_LNUMBER', - 'value' => '0o137_041', - ], + 'marker' => '/* testExplicitOctal */', + 'type' => 'T_LNUMBER', + 'value' => '0o137_041', ], [ - [ - 'marker' => '/* testExplicitOctalCapitalised */', - 'type' => 'T_LNUMBER', - 'value' => '0O137_041', - ], + 'marker' => '/* testExplicitOctalCapitalised */', + 'type' => 'T_LNUMBER', + 'value' => '0O137_041', ], [ - [ - 'marker' => '/* testIntMoreThanMax */', - 'type' => $testIntMoreThanMaxType, - 'value' => '10_223_372_036_854_775_807', - ], + 'marker' => '/* testIntMoreThanMax */', + 'type' => $testIntMoreThanMaxType, + 'value' => '10_223_372_036_854_775_807', ], ]; From 0fb1c2f3a635b9c907536fe7e4b9b7d0f50e6090 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 08:18:31 +0100 Subject: [PATCH 271/874] Tests/BackfillNumericSeparatorTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes: * Making the data type in the docblock more specific. --- .../BackfillNumericSeparatorTest.php | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php index 253cb425e2..b953a3ac93 100644 --- a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php +++ b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php @@ -44,7 +44,7 @@ public function testBackfill($marker, $type, $value) * * @see testBackfill() * - * @return array + * @return array> */ public static function dataTestBackfill() { @@ -64,67 +64,67 @@ public static function dataTestBackfill() } return [ - [ + 'decimal integer' => [ 'marker' => '/* testSimpleLNumber */', 'type' => 'T_LNUMBER', 'value' => '1_000_000_000', ], - [ + 'float' => [ 'marker' => '/* testSimpleDNumber */', 'type' => 'T_DNUMBER', 'value' => '107_925_284.88', ], - [ + 'float, scientific notation, negative exponent with sigh' => [ 'marker' => '/* testFloat */', 'type' => 'T_DNUMBER', 'value' => '6.674_083e-11', ], - [ + 'float, scientific notation, positive exponent with sign' => [ 'marker' => '/* testFloat2 */', 'type' => 'T_DNUMBER', 'value' => '6.674_083e+11', ], - [ + 'float, scientific notation, positive exponent without sign' => [ 'marker' => '/* testFloat3 */', 'type' => 'T_DNUMBER', 'value' => '1_2.3_4e1_23', ], - [ + 'hexidecimal integer/float' => [ 'marker' => '/* testHex */', 'type' => $testHexType, 'value' => '0xCAFE_F00D', ], - [ + 'hexidecimal integer/float with multiple underscores' => [ 'marker' => '/* testHexMultiple */', 'type' => $testHexMultipleType, 'value' => '0x42_72_6F_77_6E', ], - [ + 'hexidecimal integer' => [ 'marker' => '/* testHexInt */', 'type' => 'T_LNUMBER', 'value' => '0x42_72_6F', ], - [ + 'binary integer' => [ 'marker' => '/* testBinary */', 'type' => 'T_LNUMBER', 'value' => '0b0101_1111', ], - [ + 'octal integer' => [ 'marker' => '/* testOctal */', 'type' => 'T_LNUMBER', 'value' => '0137_041', ], - [ + 'octal integer using explicit octal notation' => [ 'marker' => '/* testExplicitOctal */', 'type' => 'T_LNUMBER', 'value' => '0o137_041', ], - [ + 'octal integer using explicit octal notation with capital O' => [ 'marker' => '/* testExplicitOctalCapitalised */', 'type' => 'T_LNUMBER', 'value' => '0O137_041', ], - [ + 'integer more than PHP_INT_MAX becomes a float' => [ 'marker' => '/* testIntMoreThanMax */', 'type' => $testIntMoreThanMaxType, 'value' => '10_223_372_036_854_775_807', @@ -138,8 +138,8 @@ public static function dataTestBackfill() * Test that numbers using numeric separators which are considered parse errors and/or * which aren't relevant to the backfill, do not incorrectly trigger the backfill anyway. * - * @param string $testMarker The comment which prefaces the target token in the test file. - * @param array $expectedTokens The token type and content of the expected token sequence. + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param array> $expectedTokens The token type and content of the expected token sequence. * * @dataProvider dataNoBackfill * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize @@ -165,14 +165,14 @@ public function testNoBackfill($testMarker, $expectedTokens) * * @see testBackfill() * - * @return array + * @return array>>> */ public static function dataNoBackfill() { return [ - [ - '/* testInvalid1 */', - [ + 'invalid: trailing underscore' => [ + 'testMarker' => '/* testInvalid1 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '100', @@ -183,9 +183,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid2 */', - [ + 'invalid: two consecutive underscores' => [ + 'testMarker' => '/* testInvalid2 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '1', @@ -196,9 +196,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid3 */', - [ + 'invalid: underscore directly before decimal point' => [ + 'testMarker' => '/* testInvalid3 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '1', @@ -213,9 +213,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid4 */', - [ + 'invalid: underscore directly after decimal point' => [ + 'testMarker' => '/* testInvalid4 */', + 'expectedTokens' => [ [ 'code' => T_DNUMBER, 'content' => '1.', @@ -226,9 +226,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid5 */', - [ + 'invalid: hex int - underscore directly after x' => [ + 'testMarker' => '/* testInvalid5 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '0', @@ -239,9 +239,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid6 */', - [ + 'invalid: binary int - underscore directly after b' => [ + 'testMarker' => '/* testInvalid6 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '0', @@ -252,9 +252,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid7 */', - [ + 'invalid: scientific float - underscore directly before e' => [ + 'testMarker' => '/* testInvalid7 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '1', @@ -265,9 +265,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid8 */', - [ + 'invalid: scientific float - underscore directly after e' => [ + 'testMarker' => '/* testInvalid8 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '1', @@ -278,9 +278,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid9 */', - [ + 'invalid: space between parts of the number' => [ + 'testMarker' => '/* testInvalid9 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '107_925_284', @@ -295,9 +295,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid10 */', - [ + 'invalid: comment within the number' => [ + 'testMarker' => '/* testInvalid10 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '107_925_284', @@ -312,9 +312,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid11 */', - [ + 'invalid: explicit octal int - underscore directly after o' => [ + 'testMarker' => '/* testInvalid11 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '0', @@ -325,9 +325,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testInvalid12 */', - [ + 'invalid: explicit octal int - underscore directly after capital O' => [ + 'testMarker' => '/* testInvalid12 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '0', @@ -338,9 +338,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* testCalc1 */', - [ + 'calculations should be untouched - int - int' => [ + 'testMarker' => '/* testCalc1 */', + 'expectedTokens' => [ [ 'code' => T_LNUMBER, 'content' => '667_083', @@ -363,9 +363,9 @@ public static function dataNoBackfill() ], ], ], - [ - '/* test Calc2 */', - [ + 'calculations should be untouched - scientific float + int' => [ + 'testMarker' => '/* test Calc2 */', + 'expectedTokens' => [ [ 'code' => T_DNUMBER, 'content' => '6.674_08e3', From c8d68d67ebc506a514917777a7cef22d389ad185 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 10:07:00 +0100 Subject: [PATCH 272/874] Tests/HeredocNowdocCloserTest: remove overloaded "setUpBeforeClass" method Follow up on 220 / commit 5aa4362eb589e1290c1e23f54e9393a2b26390c5 . As the `tabWidth` setting is now available via the `AbstractMethodUnitTest`, the `initializeFile()` method no longer needs to be overloaded for this test. --- .../Tokenizer/HeredocNowdocCloserTest.php | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php index 2902556a2e..987972ceb3 100644 --- a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php +++ b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php @@ -9,9 +9,6 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Ruleset; -use PHP_CodeSniffer\Files\DummyFile; use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; /** @@ -23,39 +20,6 @@ final class HeredocNowdocCloserTest extends AbstractMethodUnitTest { - /** - * Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file. - * - * {@internal This is a near duplicate of the original method. Only difference is that - * tab replacement is enabled for this test.} - * - * @beforeClass - * - * @return void - */ - public static function initializeFile() - { - $config = new Config(); - $config->standards = ['PSR1']; - $config->tabWidth = 4; - - $ruleset = new Ruleset($config); - - // Default to a file with the same name as the test class. Extension is property based. - $relativeCN = str_replace(__NAMESPACE__, '', get_called_class()); - $relativePath = str_replace('\\', DIRECTORY_SEPARATOR, $relativeCN); - $pathToTestFile = realpath(__DIR__).$relativePath.'.'.static::$fileExtension; - - // Make sure the file gets parsed correctly based on the file type. - $contents = 'phpcs_input_file: '.$pathToTestFile.PHP_EOL; - $contents .= file_get_contents($pathToTestFile); - - self::$phpcsFile = new DummyFile($contents, $ruleset, $config); - self::$phpcsFile->process(); - - }//end initializeFile() - - /** * Verify that leading (indent) whitespace in a heredoc/nowdoc closer token get the tab replacement treatment. * From b030aa09c7b82c8c4ce8b1d8388d8091949ad851 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 10:00:18 +0100 Subject: [PATCH 273/874] Tests/HeredocNowdocCloserTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblock more specific. Includes fixing up the docblock description for the file. --- .../Tokenizer/HeredocNowdocCloserTest.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php index 987972ceb3..9973f4ec61 100644 --- a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php +++ b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php @@ -1,6 +1,6 @@ * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) @@ -23,8 +23,8 @@ final class HeredocNowdocCloserTest extends AbstractMethodUnitTest /** * Verify that leading (indent) whitespace in a heredoc/nowdoc closer token get the tab replacement treatment. * - * @param string $testMarker The comment prefacing the target token. - * @param array $expected Expectations for the token array. + * @param string $testMarker The comment prefacing the target token. + * @param array $expected Expectations for the token array. * * @dataProvider dataHeredocNowdocCloserTabReplacement * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap @@ -55,12 +55,12 @@ public function testHeredocNowdocCloserTabReplacement($testMarker, $expected) * * @see testHeredocNowdocCloserTabReplacement() * - * @return array + * @return array>> */ public static function dataHeredocNowdocCloserTabReplacement() { return [ - [ + 'Heredoc closer without indent' => [ 'testMarker' => '/* testHeredocCloserNoIndent */', 'expected' => [ 'length' => 3, @@ -68,7 +68,7 @@ public static function dataHeredocNowdocCloserTabReplacement() 'orig_content' => null, ], ], - [ + 'Nowdoc closer without indent' => [ 'testMarker' => '/* testNowdocCloserNoIndent */', 'expected' => [ 'length' => 3, @@ -76,7 +76,7 @@ public static function dataHeredocNowdocCloserTabReplacement() 'orig_content' => null, ], ], - [ + 'Heredoc closer with indent, spaces' => [ 'testMarker' => '/* testHeredocCloserSpaceIndent */', 'expected' => [ 'length' => 7, @@ -84,7 +84,7 @@ public static function dataHeredocNowdocCloserTabReplacement() 'orig_content' => null, ], ], - [ + 'Nowdoc closer with indent, spaces' => [ 'testMarker' => '/* testNowdocCloserSpaceIndent */', 'expected' => [ 'length' => 8, @@ -92,7 +92,7 @@ public static function dataHeredocNowdocCloserTabReplacement() 'orig_content' => null, ], ], - [ + 'Heredoc closer with indent, tabs' => [ 'testMarker' => '/* testHeredocCloserTabIndent */', 'expected' => [ 'length' => 8, @@ -100,7 +100,7 @@ public static function dataHeredocNowdocCloserTabReplacement() 'orig_content' => ' END', ], ], - [ + 'Nowdoc closer with indent, tabs' => [ 'testMarker' => '/* testNowdocCloserTabIndent */', 'expected' => [ 'length' => 7, From 9772b4293208b4f1fd6519cf9dd2e95a2fa97ce4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 13 Jan 2024 19:10:07 +0100 Subject: [PATCH 274/874] Tests/NamedFunctionCallArgumentsTest: improve test markers Make the test marker names more descriptive. --- tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.inc | 6 +++--- tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.inc b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.inc index b9c0df24d4..2f1d20bf08 100644 --- a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.inc +++ b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.inc @@ -32,13 +32,13 @@ array_fill( value: 50 ); -/* testNamespaceOperatorFunction */ +/* testNamespaceRelativeFunction */ namespace\function_name(label:$string, more: false); -/* testNamespaceRelativeFunction */ +/* testPartiallyQualifiedFunction */ Partially\Qualified\function_name(label:$string, more: false); -/* testNamespacedFQNFunction */ +/* testFullyQualifiedFunction */ \Fully\Qualified\function_name(label: $string, more:false); /* testVariableFunction */ diff --git a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php index f0ca635357..5dba79eea9 100644 --- a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php +++ b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php @@ -124,21 +124,21 @@ public static function dataNamedFunctionCallArguments() ['array_or_countable'], ], [ - '/* testNamespaceOperatorFunction */', + '/* testNamespaceRelativeFunction */', [ 'label', 'more', ], ], [ - '/* testNamespaceRelativeFunction */', + '/* testPartiallyQualifiedFunction */', [ 'label', 'more', ], ], [ - '/* testNamespacedFQNFunction */', + '/* testFullyQualifiedFunction */', [ 'label', 'more', From b4df61e8f92c75bbfe9390a48369b6bf56989f17 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 8 Jan 2024 00:59:40 +0100 Subject: [PATCH 275/874] Tests/NamedFunctionCallArgumentsTest: normalize data provider arrays ... to improve scannability of the test cases covered. See 225 --- .../NamedFunctionCallArgumentsTest.php | 48 ++++++++++++++----- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php index 5dba79eea9..030b708ee8 100644 --- a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php +++ b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php @@ -105,7 +105,9 @@ public static function dataNamedFunctionCallArguments() ], [ '/* testMixedPositionalAndNamedArgs */', - ['double_encode'], + [ + 'double_encode', + ], ], [ '/* testNestedFunctionCallOuter */', @@ -117,11 +119,15 @@ public static function dataNamedFunctionCallArguments() ], [ '/* testNestedFunctionCallInner1 */', - ['skip'], + [ + 'skip', + ], ], [ '/* testNestedFunctionCallInner2 */', - ['array_or_countable'], + [ + 'array_or_countable', + ], ], [ '/* testNamespaceRelativeFunction */', @@ -212,23 +218,33 @@ public static function dataNamedFunctionCallArguments() // Coding errors which should still be handled. [ '/* testCompileErrorNamedBeforePositional */', - ['param'], + [ + 'param', + ], ], [ '/* testDuplicateName1 */', - ['param'], + [ + 'param', + ], ], [ '/* testDuplicateName2 */', - ['param'], + [ + 'param', + ], ], [ '/* testIncorrectOrderWithVariadic */', - ['start_index'], + [ + 'start_index', + ], ], [ '/* testCompileErrorIncorrectOrderWithVariadic */', - ['param'], + [ + 'param', + ], ], [ '/* testParseErrorNoValue */', @@ -239,19 +255,27 @@ public static function dataNamedFunctionCallArguments() ], [ '/* testParseErrorExit */', - ['status'], + [ + 'status', + ], ], [ '/* testParseErrorEmpty */', - ['variable'], + [ + 'variable', + ], ], [ '/* testParseErrorEval */', - ['code'], + [ + 'code', + ], ], [ '/* testParseErrorArbitraryParentheses */', - ['something'], + [ + 'something', + ], ], ]; From fc1b8c6e2e7fc13dce17cc1bfc3a4e71c963d1e9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 10:00:34 +0100 Subject: [PATCH 276/874] Tests/NamedFunctionCallArgumentsTest: fix test description --- tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php index 030b708ee8..070723d28e 100644 --- a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php +++ b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php @@ -1,6 +1,6 @@ * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) From 34bdfaadb6715b0b3ffa924551bcf55507e8fb59 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 13 Jan 2024 19:45:04 +0100 Subject: [PATCH 277/874] Tests/NamedFunctionCallArgumentsTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Include making the data type in the docblock more specific. --- .../NamedFunctionCallArgumentsTest.php | 214 +++++++++--------- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php index 070723d28e..9004b384f5 100644 --- a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php +++ b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php @@ -20,8 +20,8 @@ final class NamedFunctionCallArgumentsTest extends AbstractMethodUnitTest * Verify that parameter labels are tokenized as T_PARAM_NAME and that * the colon after it is tokenized as a T_COLON. * - * @param string $testMarker The comment prefacing the target token. - * @param array $parameters The token content for each parameter label to look for. + * @param string $testMarker The comment prefacing the target token. + * @param array $parameters The token content for each parameter label to look for. * * @dataProvider dataNamedFunctionCallArguments * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize @@ -74,141 +74,141 @@ public function testNamedFunctionCallArguments($testMarker, $parameters) * * @see testNamedFunctionCallArguments() * - * @return array + * @return array>> */ public static function dataNamedFunctionCallArguments() { return [ - [ - '/* testNamedArgs */', - [ + 'function call, single line, all named args' => [ + 'testMarker' => '/* testNamedArgs */', + 'parameters' => [ 'start_index', 'count', 'value', ], ], - [ - '/* testNamedArgsMultiline */', - [ + 'function call, multi-line, all named args' => [ + 'testMarker' => '/* testNamedArgsMultiline */', + 'parameters' => [ 'start_index', 'count', 'value', ], ], - [ - '/* testNamedArgsWithWhitespaceAndComments */', - [ + 'function call, single line, all named args; comments and whitespace' => [ + 'testMarker' => '/* testNamedArgsWithWhitespaceAndComments */', + 'parameters' => [ 'start_index', 'count', 'value', ], ], - [ - '/* testMixedPositionalAndNamedArgs */', - [ + 'function call, single line, mixed positional and named args' => [ + 'testMarker' => '/* testMixedPositionalAndNamedArgs */', + 'parameters' => [ 'double_encode', ], ], - [ - '/* testNestedFunctionCallOuter */', - [ + 'function call containing nested function call values' => [ + 'testMarker' => '/* testNestedFunctionCallOuter */', + 'parameters' => [ 'start_index', 'count', 'value', ], ], - [ - '/* testNestedFunctionCallInner1 */', - [ + 'function call nested in named arg [1]' => [ + 'testMarker' => '/* testNestedFunctionCallInner1 */', + 'parameters' => [ 'skip', ], ], - [ - '/* testNestedFunctionCallInner2 */', - [ + 'function call nested in named arg [2]' => [ + 'testMarker' => '/* testNestedFunctionCallInner2 */', + 'parameters' => [ 'array_or_countable', ], ], - [ - '/* testNamespaceRelativeFunction */', - [ + 'namespace relative function call' => [ + 'testMarker' => '/* testNamespaceRelativeFunction */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testPartiallyQualifiedFunction */', - [ + 'partially qualified function call' => [ + 'testMarker' => '/* testPartiallyQualifiedFunction */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testFullyQualifiedFunction */', - [ + 'fully qualified function call' => [ + 'testMarker' => '/* testFullyQualifiedFunction */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testVariableFunction */', - [ + 'variable function call' => [ + 'testMarker' => '/* testVariableFunction */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testVariableVariableFunction */', - [ + 'variable variable function call' => [ + 'testMarker' => '/* testVariableVariableFunction */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testMethodCall */', - [ + 'method call' => [ + 'testMarker' => '/* testMethodCall */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testVariableMethodCall */', - [ + 'variable method call' => [ + 'testMarker' => '/* testVariableMethodCall */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testClassInstantiation */', - [ + 'class instantiation' => [ + 'testMarker' => '/* testClassInstantiation */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testClassInstantiationSelf */', - [ + 'class instantiation with "self"' => [ + 'testMarker' => '/* testClassInstantiationSelf */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testClassInstantiationStatic */', - [ + 'class instantiation with "static"' => [ + 'testMarker' => '/* testClassInstantiationStatic */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testAnonClass */', - [ + 'anonymous class instantiation' => [ + 'testMarker' => '/* testAnonClass */', + 'parameters' => [ 'label', 'more', ], ], - [ - '/* testNonAsciiNames */', - [ + 'function call with non-ascii characters in the variable name labels' => [ + 'testMarker' => '/* testNonAsciiNames */', + 'parameters' => [ '💩💩💩', 'ПаÑха', '_valid', @@ -216,64 +216,64 @@ public static function dataNamedFunctionCallArguments() ], // Coding errors which should still be handled. - [ - '/* testCompileErrorNamedBeforePositional */', - [ + 'invalid: named arg before positional (compile error)' => [ + 'testMarker' => '/* testCompileErrorNamedBeforePositional */', + 'parameters' => [ 'param', ], ], - [ - '/* testDuplicateName1 */', - [ + 'invalid: duplicate parameter name [1]' => [ + 'testMarker' => '/* testDuplicateName1 */', + 'parameters' => [ 'param', ], ], - [ - '/* testDuplicateName2 */', - [ + 'invalid: duplicate parameter name [2]' => [ + 'testMarker' => '/* testDuplicateName2 */', + 'parameters' => [ 'param', ], ], - [ - '/* testIncorrectOrderWithVariadic */', - [ + 'invalid: named arg before variadic (error exception)' => [ + 'testMarker' => '/* testIncorrectOrderWithVariadic */', + 'parameters' => [ 'start_index', ], ], - [ - '/* testCompileErrorIncorrectOrderWithVariadic */', - [ + 'invalid: named arg after variadic (compile error)' => [ + 'testMarker' => '/* testCompileErrorIncorrectOrderWithVariadic */', + 'parameters' => [ 'param', ], ], - [ - '/* testParseErrorNoValue */', - [ + 'invalid: named arg without value (parse error)' => [ + 'testMarker' => '/* testParseErrorNoValue */', + 'parameters' => [ 'param1', 'param2', ], ], - [ - '/* testParseErrorExit */', - [ + 'invalid: named arg in exit() (parse error)' => [ + 'testMarker' => '/* testParseErrorExit */', + 'parameters' => [ 'status', ], ], - [ - '/* testParseErrorEmpty */', - [ + 'invalid: named arg in empty() (parse error)' => [ + 'testMarker' => '/* testParseErrorEmpty */', + 'parameters' => [ 'variable', ], ], - [ - '/* testParseErrorEval */', - [ + 'invalid: named arg in eval() (parse error)' => [ + 'testMarker' => '/* testParseErrorEval */', + 'parameters' => [ 'code', ], ], - [ - '/* testParseErrorArbitraryParentheses */', - [ + 'invalid: named arg in arbitrary parentheses (parse error)' => [ + 'testMarker' => '/* testParseErrorArbitraryParentheses */', + 'parameters' => [ 'something', ], ], @@ -318,26 +318,26 @@ public function testOtherTstringInFunctionCall($testMarker, $content) * * @see testOtherTstringInFunctionCall() * - * @return array + * @return array> */ public static function dataOtherTstringInFunctionCall() { return [ - [ - '/* testPositionalArgs */', - 'START_INDEX', + 'not arg name - global constant' => [ + 'testMarker' => '/* testPositionalArgs */', + 'content' => 'START_INDEX', ], - [ - '/* testPositionalArgs */', - 'COUNT', + 'not arg name - fully qualified constant' => [ + 'testMarker' => '/* testPositionalArgs */', + 'content' => 'COUNT', ], - [ - '/* testPositionalArgs */', - 'VALUE', + 'not arg name - namespace relative constant' => [ + 'testMarker' => '/* testPositionalArgs */', + 'content' => 'VALUE', ], - [ - '/* testNestedFunctionCallInner2 */', - 'count', + 'not arg name - unqualified function call' => [ + 'testMarker' => '/* testNestedFunctionCallInner2 */', + 'content' => 'count', ], ]; @@ -716,9 +716,9 @@ public function testParseErrorVariableLabel() * Verify that reserved keywords used as a parameter label are tokenized as T_PARAM_NAME * and that the colon after it is tokenized as a T_COLON. * - * @param string $testMarker The comment prefacing the target token. - * @param array $tokenTypes The token codes to look for. - * @param string $tokenContent The token content to look for. + * @param string $testMarker The comment prefacing the target token. + * @param array $tokenTypes The token codes to look for. + * @param string $tokenContent The token content to look for. * * @dataProvider dataReservedKeywordsAsName * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize @@ -768,7 +768,7 @@ public function testReservedKeywordsAsName($testMarker, $tokenTypes, $tokenConte * * @see testReservedKeywordsAsName() * - * @return array + * @return array>> */ public static function dataReservedKeywordsAsName() { From 292f3c5bce4bbc942bb1da594e65db4485d2bd96 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 13 Jan 2024 19:36:10 +0100 Subject: [PATCH 278/874] Tests/NamedFunctionCallArgumentsTest: activate two test cases These test cases already existed in the test case file, but were not being run as tests. Fixed now. --- .../NamedFunctionCallArgumentsTest.php | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php index 9004b384f5..52df789115 100644 --- a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php +++ b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php @@ -712,6 +712,71 @@ public function testParseErrorVariableLabel() }//end testParseErrorVariableLabel() + /** + * Verify whether the colons are tokenized correctly when a return type is used for an inline + * closure/arrow function declaration in a ternary. + * + * @param string $testMarker The comment prefacing the target token. + * + * @dataProvider dataOtherColonsInTernary + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * + * @return void + */ + public function testOtherColonsInTernary($testMarker) + { + $tokens = self::$phpcsFile->getTokens(); + + $startOfStatement = $this->getTargetToken($testMarker, T_VARIABLE); + + // Walk the statement and check the tokenization. + // There should be no T_PARAM_NAME tokens. + // First colon should be T_COLON for the return type. + // Second colon should be T_INLINE_ELSE for the ternary. + // Third colon should be T_COLON for the return type. + $colonCount = 0; + for ($i = ($startOfStatement + 1); $tokens[$i]['line'] === $tokens[$startOfStatement]['line']; $i++) { + $this->assertNotEquals(T_PARAM_NAME, $tokens[$i]['code'], "Token $i is tokenized as parameter label"); + + if ($tokens[$i]['content'] === ':') { + ++$colonCount; + + if ($colonCount === 1) { + $this->assertSame(T_COLON, $tokens[$i]['code'], 'First colon is not tokenized as T_COLON'); + } else if ($colonCount === 2) { + $this->assertSame(T_INLINE_ELSE, $tokens[$i]['code'], 'Second colon is not tokenized as T_INLINE_ELSE'); + } else if ($colonCount === 3) { + $this->assertSame(T_COLON, $tokens[$i]['code'], 'Third colon is not tokenized as T_COLON'); + } else { + $this->fail('Unexpected colon encountered in statement'); + } + } + } + + }//end testOtherColonsInTernary() + + + /** + * Data provider. + * + * @see testOtherColonsInTernary() + * + * @return array> + */ + public static function dataOtherColonsInTernary() + { + return [ + 'closures with return types in ternary' => [ + 'testMarker' => '/* testTernaryWithClosuresAndReturnTypes */', + ], + 'arrow functions with return types in ternary' => [ + 'testMarker' => '/* testTernaryWithArrowFunctionsAndReturnTypes */', + ], + ]; + + }//end dataOtherColonsInTernary() + + /** * Verify that reserved keywords used as a parameter label are tokenized as T_PARAM_NAME * and that the colon after it is tokenized as a T_COLON. From 7e13933360453f1714b6070153f6cb0344f68d83 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 14:30:36 +0100 Subject: [PATCH 279/874] Tests/EnumCaseTest: activate three test cases These test cases already existed in the test case file, but were not being run as tests. Fixed now. --- tests/Core/Tokenizer/EnumCaseTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/Core/Tokenizer/EnumCaseTest.php b/tests/Core/Tokenizer/EnumCaseTest.php index 4b41312675..ef43c8a5c6 100644 --- a/tests/Core/Tokenizer/EnumCaseTest.php +++ b/tests/Core/Tokenizer/EnumCaseTest.php @@ -149,6 +149,9 @@ public static function dataKeywordAsEnumCaseNameShouldBeString() ['/* testKeywordAsEnumCaseNameShouldBeString2 */'], ['/* testKeywordAsEnumCaseNameShouldBeString3 */'], ['/* testKeywordAsEnumCaseNameShouldBeString4 */'], + ['/* testKeywordAsEnumCaseNameShouldBeString5 */'], + ['/* testKeywordAsEnumCaseNameShouldBeString6 */'], + ['/* testKeywordAsEnumCaseNameShouldBeString7 */'], ]; }//end dataKeywordAsEnumCaseNameShouldBeString() From 986050460885517166834dbf8d734af350d3c485 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 14:29:13 +0100 Subject: [PATCH 280/874] Tests/EnumCaseTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblock more specific. --- tests/Core/Tokenizer/EnumCaseTest.php | 48 +++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/Core/Tokenizer/EnumCaseTest.php b/tests/Core/Tokenizer/EnumCaseTest.php index ef43c8a5c6..26a8699daf 100644 --- a/tests/Core/Tokenizer/EnumCaseTest.php +++ b/tests/Core/Tokenizer/EnumCaseTest.php @@ -47,18 +47,18 @@ public function testEnumCases($testMarker) * * @see testEnumCases() * - * @return array + * @return array> */ public static function dataEnumCases() { return [ - ['/* testPureEnumCase */'], - ['/* testBackingIntegerEnumCase */'], - ['/* testBackingStringEnumCase */'], - ['/* testEnumCaseInComplexEnum */'], - ['/* testEnumCaseIsCaseInsensitive */'], - ['/* testEnumCaseAfterSwitch */'], - ['/* testEnumCaseAfterSwitchWithEndSwitch */'], + 'enum case, no value' => ['/* testPureEnumCase */'], + 'enum case, integer value' => ['/* testBackingIntegerEnumCase */'], + 'enum case, string value' => ['/* testBackingStringEnumCase */'], + 'enum case, integer value in more complex enum' => ['/* testEnumCaseInComplexEnum */'], + 'enum case, keyword in mixed case' => ['/* testEnumCaseIsCaseInsensitive */'], + 'enum case, after switch statement' => ['/* testEnumCaseAfterSwitch */'], + 'enum case, after switch statement using alternative syntax' => ['/* testEnumCaseAfterSwitchWithEndSwitch */'], ]; }//end dataEnumCases() @@ -96,18 +96,18 @@ public function testNotEnumCases($testMarker) * * @see testNotEnumCases() * - * @return array + * @return array> */ public static function dataNotEnumCases() { return [ - ['/* testCaseWithSemicolonIsNotEnumCase */'], - ['/* testCaseWithConstantIsNotEnumCase */'], - ['/* testCaseWithConstantAndIdenticalIsNotEnumCase */'], - ['/* testCaseWithAssigmentToConstantIsNotEnumCase */'], - ['/* testIsNotEnumCaseIsCaseInsensitive */'], - ['/* testCaseInSwitchWhenCreatingEnumInSwitch1 */'], - ['/* testCaseInSwitchWhenCreatingEnumInSwitch2 */'], + 'switch case with constant, semicolon condition end' => ['/* testCaseWithSemicolonIsNotEnumCase */'], + 'switch case with constant, colon condition end' => ['/* testCaseWithConstantIsNotEnumCase */'], + 'switch case with constant, comparison' => ['/* testCaseWithConstantAndIdenticalIsNotEnumCase */'], + 'switch case with constant, assignment' => ['/* testCaseWithAssigmentToConstantIsNotEnumCase */'], + 'switch case with constant, keyword in mixed case' => ['/* testIsNotEnumCaseIsCaseInsensitive */'], + 'switch case, body in curlies declares enum' => ['/* testCaseInSwitchWhenCreatingEnumInSwitch1 */'], + 'switch case, body after semicolon declares enum' => ['/* testCaseInSwitchWhenCreatingEnumInSwitch2 */'], ]; }//end dataNotEnumCases() @@ -140,18 +140,18 @@ public function testKeywordAsEnumCaseNameShouldBeString($testMarker) * * @see testKeywordAsEnumCaseNameShouldBeString() * - * @return array + * @return array> */ public static function dataKeywordAsEnumCaseNameShouldBeString() { return [ - ['/* testKeywordAsEnumCaseNameShouldBeString1 */'], - ['/* testKeywordAsEnumCaseNameShouldBeString2 */'], - ['/* testKeywordAsEnumCaseNameShouldBeString3 */'], - ['/* testKeywordAsEnumCaseNameShouldBeString4 */'], - ['/* testKeywordAsEnumCaseNameShouldBeString5 */'], - ['/* testKeywordAsEnumCaseNameShouldBeString6 */'], - ['/* testKeywordAsEnumCaseNameShouldBeString7 */'], + '"interface" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString1 */'], + '"trait" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString2 */'], + '"enum" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString3 */'], + '"function" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString4 */'], + '"false" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString5 */'], + '"default" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString6 */'], + '"array" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString7 */'], ]; }//end dataKeywordAsEnumCaseNameShouldBeString() From 960e8b46eade2f889bcab3169093b404669401d6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 7 Jan 2024 17:38:43 +0100 Subject: [PATCH 281/874] Tests/BitwiseOrTest: fix order of tests The data set order did not match the order of the tests in the test case file. Also the test order in the test case file was at times confusing (by the looks of it caused by incorrect merge conflict resolution, which hasn't kept tests which were grouped together, together). Fixed now. --- tests/Core/Tokenizer/BitwiseOrTest.inc | 12 ++++++------ tests/Core/Tokenizer/BitwiseOrTest.php | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Core/Tokenizer/BitwiseOrTest.inc b/tests/Core/Tokenizer/BitwiseOrTest.inc index b758aba019..4667ad025b 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.inc +++ b/tests/Core/Tokenizer/BitwiseOrTest.inc @@ -71,12 +71,12 @@ class TypeUnion \Fully\Qualified\NameA|\Fully\Qualified\NameB $paramC, ) {} - /* testTypeUnionReturnType */ - public function returnType() : int|false {} - /* testTypeUnionConstructorPropertyPromotion */ public function __construct( public bool|null $property) {} + /* testTypeUnionReturnType */ + public function returnType() : int|false {} + /* testTypeUnionAbstractMethodReturnType1 */ abstract public function abstractMethod(): object|array /* testTypeUnionAbstractMethodReturnType2 */ |false; @@ -90,9 +90,6 @@ class TypeUnion public function identifierNamesReturnFQ() : \Fully\Qualified\NameA|\Fully\Qualified\NameB {} } -/* testTypeUnionClosureParamIllegalNullable */ -$closureWithParamType = function (?string|null $string) {}; - function globalFunctionWithSpreadAndReference( /* testTypeUnionWithReference */ float|null &$paramA, @@ -100,6 +97,9 @@ function globalFunctionWithSpreadAndReference( string|int ...$paramB ) {} +/* testTypeUnionClosureParamIllegalNullable */ +$closureWithParamType = function (?string|null $string) {}; + /* testBitwiseOrClosureParamDefault */ $closureWithReturnType = function ($string = NONSENSE | FAKE)/* testTypeUnionClosureReturn */ : \Package\MyA|PackageB {}; diff --git a/tests/Core/Tokenizer/BitwiseOrTest.php b/tests/Core/Tokenizer/BitwiseOrTest.php index c5b937d69a..182ed6dcd6 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.php +++ b/tests/Core/Tokenizer/BitwiseOrTest.php @@ -106,9 +106,9 @@ public static function dataTypeUnion() ['/* testTypeUnionPropertyPartiallyQualified */'], ['/* testTypeUnionPropertyFullyQualified */'], ['/* testTypeUnionPropertyWithReadOnlyKeyword */'], - ['/* testTypeUnionPropertyWithReadOnlyKeywordFirst */'], ['/* testTypeUnionPropertyWithStaticAndReadOnlyKeywords */'], ['/* testTypeUnionPropertyWithVarAndReadOnlyKeywords */'], + ['/* testTypeUnionPropertyWithReadOnlyKeywordFirst */'], ['/* testTypeUnionPropertyWithOnlyReadOnlyKeyword */'], ['/* testTypeUnionPropertyWithOnlyStaticKeyword */'], ['/* testTypeUnionParam1 */'], @@ -117,16 +117,16 @@ public static function dataTypeUnion() ['/* testTypeUnionParamNamespaceRelative */'], ['/* testTypeUnionParamPartiallyQualified */'], ['/* testTypeUnionParamFullyQualified */'], - ['/* testTypeUnionReturnType */'], ['/* testTypeUnionConstructorPropertyPromotion */'], + ['/* testTypeUnionReturnType */'], ['/* testTypeUnionAbstractMethodReturnType1 */'], ['/* testTypeUnionAbstractMethodReturnType2 */'], ['/* testTypeUnionReturnTypeNamespaceRelative */'], ['/* testTypeUnionReturnPartiallyQualified */'], ['/* testTypeUnionReturnFullyQualified */'], - ['/* testTypeUnionClosureParamIllegalNullable */'], ['/* testTypeUnionWithReference */'], ['/* testTypeUnionWithSpreadOperator */'], + ['/* testTypeUnionClosureParamIllegalNullable */'], ['/* testTypeUnionClosureReturn */'], ['/* testTypeUnionArrowParam */'], ['/* testTypeUnionArrowReturnType */'], From c7d920afede1afd825f4323260016a295e846c67 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 7 Jan 2024 12:32:08 +0100 Subject: [PATCH 282/874] Tests/BitwiseOrTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblock more specific. --- tests/Core/Tokenizer/BitwiseOrTest.php | 108 ++++++++++++------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/tests/Core/Tokenizer/BitwiseOrTest.php b/tests/Core/Tokenizer/BitwiseOrTest.php index 182ed6dcd6..a21f6f174a 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.php +++ b/tests/Core/Tokenizer/BitwiseOrTest.php @@ -41,26 +41,26 @@ public function testBitwiseOr($testMarker) * * @see testBitwiseOr() * - * @return array + * @return array> */ public static function dataBitwiseOr() { return [ - ['/* testBitwiseOr1 */'], - ['/* testBitwiseOr2 */'], - ['/* testBitwiseOrPropertyDefaultValue */'], - ['/* testBitwiseOrParamDefaultValue */'], - ['/* testBitwiseOr3 */'], - ['/* testBitwiseOrClosureParamDefault */'], - ['/* testBitwiseOrArrowParamDefault */'], - ['/* testBitwiseOrArrowExpression */'], - ['/* testBitwiseOrInArrayKey */'], - ['/* testBitwiseOrInArrayValue */'], - ['/* testBitwiseOrInShortArrayKey */'], - ['/* testBitwiseOrInShortArrayValue */'], - ['/* testBitwiseOrTryCatch */'], - ['/* testBitwiseOrNonArrowFnFunctionCall */'], - ['/* testLiveCoding */'], + 'in simple assignment 1' => ['/* testBitwiseOr1 */'], + 'in simple assignment 2' => ['/* testBitwiseOr2 */'], + 'in property default value' => ['/* testBitwiseOrPropertyDefaultValue */'], + 'in method parameter default value' => ['/* testBitwiseOrParamDefaultValue */'], + 'in return statement' => ['/* testBitwiseOr3 */'], + 'in closure parameter default value' => ['/* testBitwiseOrClosureParamDefault */'], + 'in arrow function parameter default value' => ['/* testBitwiseOrArrowParamDefault */'], + 'in arrow function return expression' => ['/* testBitwiseOrArrowExpression */'], + 'in long array key' => ['/* testBitwiseOrInArrayKey */'], + 'in long array value' => ['/* testBitwiseOrInArrayValue */'], + 'in short array key' => ['/* testBitwiseOrInShortArrayKey */'], + 'in short array value' => ['/* testBitwiseOrInShortArrayValue */'], + 'in catch condition' => ['/* testBitwiseOrTryCatch */'], + 'in parameter in function call' => ['/* testBitwiseOrNonArrowFnFunctionCall */'], + 'live coding / undetermined' => ['/* testLiveCoding */'], ]; }//end dataBitwiseOr() @@ -92,48 +92,48 @@ public function testTypeUnion($testMarker) * * @see testTypeUnion() * - * @return array + * @return array> */ public static function dataTypeUnion() { return [ - ['/* testTypeUnionPropertySimple */'], - ['/* testTypeUnionPropertyReverseModifierOrder */'], - ['/* testTypeUnionPropertyMulti1 */'], - ['/* testTypeUnionPropertyMulti2 */'], - ['/* testTypeUnionPropertyMulti3 */'], - ['/* testTypeUnionPropertyNamespaceRelative */'], - ['/* testTypeUnionPropertyPartiallyQualified */'], - ['/* testTypeUnionPropertyFullyQualified */'], - ['/* testTypeUnionPropertyWithReadOnlyKeyword */'], - ['/* testTypeUnionPropertyWithStaticAndReadOnlyKeywords */'], - ['/* testTypeUnionPropertyWithVarAndReadOnlyKeywords */'], - ['/* testTypeUnionPropertyWithReadOnlyKeywordFirst */'], - ['/* testTypeUnionPropertyWithOnlyReadOnlyKeyword */'], - ['/* testTypeUnionPropertyWithOnlyStaticKeyword */'], - ['/* testTypeUnionParam1 */'], - ['/* testTypeUnionParam2 */'], - ['/* testTypeUnionParam3 */'], - ['/* testTypeUnionParamNamespaceRelative */'], - ['/* testTypeUnionParamPartiallyQualified */'], - ['/* testTypeUnionParamFullyQualified */'], - ['/* testTypeUnionConstructorPropertyPromotion */'], - ['/* testTypeUnionReturnType */'], - ['/* testTypeUnionAbstractMethodReturnType1 */'], - ['/* testTypeUnionAbstractMethodReturnType2 */'], - ['/* testTypeUnionReturnTypeNamespaceRelative */'], - ['/* testTypeUnionReturnPartiallyQualified */'], - ['/* testTypeUnionReturnFullyQualified */'], - ['/* testTypeUnionWithReference */'], - ['/* testTypeUnionWithSpreadOperator */'], - ['/* testTypeUnionClosureParamIllegalNullable */'], - ['/* testTypeUnionClosureReturn */'], - ['/* testTypeUnionArrowParam */'], - ['/* testTypeUnionArrowReturnType */'], - ['/* testTypeUnionNonArrowFunctionDeclaration */'], - ['/* testTypeUnionPHP82TrueFirst */'], - ['/* testTypeUnionPHP82TrueMiddle */'], - ['/* testTypeUnionPHP82TrueLast */'], + 'type for static property' => ['/* testTypeUnionPropertySimple */'], + 'type for static property, reversed modifier order' => ['/* testTypeUnionPropertyReverseModifierOrder */'], + 'type for property, first of multi-union' => ['/* testTypeUnionPropertyMulti1 */'], + 'type for property, middle of multi-union, also comments' => ['/* testTypeUnionPropertyMulti2 */'], + 'type for property, last of multi-union' => ['/* testTypeUnionPropertyMulti3 */'], + 'type for property using namespace relative names' => ['/* testTypeUnionPropertyNamespaceRelative */'], + 'type for property using partially qualified names' => ['/* testTypeUnionPropertyPartiallyQualified */'], + 'type for property using fully qualified names' => ['/* testTypeUnionPropertyFullyQualified */'], + 'type for readonly property' => ['/* testTypeUnionPropertyWithReadOnlyKeyword */'], + 'type for static readonly property' => ['/* testTypeUnionPropertyWithStaticAndReadOnlyKeywords */'], + 'type for readonly property using var keyword' => ['/* testTypeUnionPropertyWithVarAndReadOnlyKeywords */'], + 'type for readonly property, reversed modifier order' => ['/* testTypeUnionPropertyWithReadOnlyKeywordFirst */'], + 'type for readonly property, no visibility' => ['/* testTypeUnionPropertyWithOnlyReadOnlyKeyword */'], + 'type for static property, no visibility' => ['/* testTypeUnionPropertyWithOnlyStaticKeyword */'], + 'type for method parameter' => ['/* testTypeUnionParam1 */'], + 'type for method parameter, first in multi-union' => ['/* testTypeUnionParam2 */'], + 'type for method parameter, last in multi-union' => ['/* testTypeUnionParam3 */'], + 'type for method parameter with namespace relative names' => ['/* testTypeUnionParamNamespaceRelative */'], + 'type for method parameter with partially qualified names' => ['/* testTypeUnionParamPartiallyQualified */'], + 'type for method parameter with fully qualified names' => ['/* testTypeUnionParamFullyQualified */'], + 'type for property in constructor property promotion' => ['/* testTypeUnionConstructorPropertyPromotion */'], + 'return type for method' => ['/* testTypeUnionReturnType */'], + 'return type for method, first of multi-union' => ['/* testTypeUnionAbstractMethodReturnType1 */'], + 'return type for method, last of multi-union' => ['/* testTypeUnionAbstractMethodReturnType2 */'], + 'return type for method with namespace relative names' => ['/* testTypeUnionReturnTypeNamespaceRelative */'], + 'return type for method with partially qualified names' => ['/* testTypeUnionReturnPartiallyQualified */'], + 'return type for method with fully qualified names' => ['/* testTypeUnionReturnFullyQualified */'], + 'type for function parameter with reference' => ['/* testTypeUnionWithReference */'], + 'type for function parameter with spread operator' => ['/* testTypeUnionWithSpreadOperator */'], + 'type for closure parameter with illegal nullable' => ['/* testTypeUnionClosureParamIllegalNullable */'], + 'return type for closure' => ['/* testTypeUnionClosureReturn */'], + 'type for arrow function parameter' => ['/* testTypeUnionArrowParam */'], + 'return type for arrow function' => ['/* testTypeUnionArrowReturnType */'], + 'type for function parameter, return by ref' => ['/* testTypeUnionNonArrowFunctionDeclaration */'], + 'type for function param with true type first' => ['/* testTypeUnionPHP82TrueFirst */'], + 'type for function param with true type middle' => ['/* testTypeUnionPHP82TrueMiddle */'], + 'type for function param with true type last' => ['/* testTypeUnionPHP82TrueLast */'], ]; }//end dataTypeUnion() From 140ce8fd8dc838fc799856b7b2ed7ec25892ec8d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 7 Jan 2024 18:05:49 +0100 Subject: [PATCH 283/874] Tests/TypeIntersectionTest: fix order of tests The test order in the test case file was at times confusing (by the looks of it caused by incorrect merge conflict resolution, which hasn't kept tests which were grouped together, together). Fixed now. --- tests/Core/Tokenizer/TypeIntersectionTest.inc | 12 ++++++------ tests/Core/Tokenizer/TypeIntersectionTest.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.inc b/tests/Core/Tokenizer/TypeIntersectionTest.inc index ad421cba5a..10cd56b2db 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.inc +++ b/tests/Core/Tokenizer/TypeIntersectionTest.inc @@ -59,12 +59,12 @@ class TypeIntersection \Fully\Qualified\NameA&\Fully\Qualified\NameB $paramC, ) {} - /* testTypeIntersectionReturnType */ - public function returnType() : Foo&Bar {} - /* testTypeIntersectionConstructorPropertyPromotion */ public function __construct( public Foo&Bar $property) {} + /* testTypeIntersectionReturnType */ + public function returnType() : Foo&Bar {} + /* testTypeIntersectionAbstractMethodReturnType1 */ abstract public function abstractMethod(): Foo&Bar /* testTypeIntersectionAbstractMethodReturnType2 */ &Baz; @@ -78,9 +78,6 @@ class TypeIntersection public function identifierNamesReturnFQ() : \Fully\Qualified\NameA&\Fully\Qualified\NameB {} } -/* testTypeIntersectionClosureParamIllegalNullable */ -$closureWithParamType = function (?Foo&Bar $string) {}; - function globalFunctionWithSpreadAndReference( /* testTypeIntersectionWithReference */ Foo&Bar /* testBitwiseAnd5 */ &$paramA, @@ -88,6 +85,9 @@ function globalFunctionWithSpreadAndReference( Foo&Bar ...$paramB ) {} +/* testTypeIntersectionClosureParamIllegalNullable */ +$closureWithParamType = function (?Foo&Bar $string) {}; + /* testBitwiseAndClosureParamDefault */ $closureWithReturnType = function ($string = NONSENSE & FAKE)/* testTypeIntersectionClosureReturn */ : \Package\MyA&PackageB {}; diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.php b/tests/Core/Tokenizer/TypeIntersectionTest.php index 7c27e07050..cea1e5798e 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.php +++ b/tests/Core/Tokenizer/TypeIntersectionTest.php @@ -116,16 +116,16 @@ public static function dataTypeIntersection() ['/* testTypeIntersectionParamNamespaceRelative */'], ['/* testTypeIntersectionParamPartiallyQualified */'], ['/* testTypeIntersectionParamFullyQualified */'], - ['/* testTypeIntersectionReturnType */'], ['/* testTypeIntersectionConstructorPropertyPromotion */'], + ['/* testTypeIntersectionReturnType */'], ['/* testTypeIntersectionAbstractMethodReturnType1 */'], ['/* testTypeIntersectionAbstractMethodReturnType2 */'], ['/* testTypeIntersectionReturnTypeNamespaceRelative */'], ['/* testTypeIntersectionReturnPartiallyQualified */'], ['/* testTypeIntersectionReturnFullyQualified */'], - ['/* testTypeIntersectionClosureParamIllegalNullable */'], ['/* testTypeIntersectionWithReference */'], ['/* testTypeIntersectionWithSpreadOperator */'], + ['/* testTypeIntersectionClosureParamIllegalNullable */'], ['/* testTypeIntersectionClosureReturn */'], ['/* testTypeIntersectionArrowParam */'], ['/* testTypeIntersectionArrowReturnType */'], From 477b13f1dacaef83f3e2978ab31c7a94b7337afa Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 7 Jan 2024 18:21:39 +0100 Subject: [PATCH 284/874] Tests/TypeIntersectionTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblock more specific. --- tests/Core/Tokenizer/TypeIntersectionTest.php | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.php b/tests/Core/Tokenizer/TypeIntersectionTest.php index cea1e5798e..5ac025240b 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.php +++ b/tests/Core/Tokenizer/TypeIntersectionTest.php @@ -42,28 +42,28 @@ public function testBitwiseAnd($testMarker) * * @see testBitwiseAnd() * - * @return array + * @return array> */ public static function dataBitwiseAnd() { return [ - ['/* testBitwiseAnd1 */'], - ['/* testBitwiseAnd2 */'], - ['/* testBitwiseAndPropertyDefaultValue */'], - ['/* testBitwiseAndParamDefaultValue */'], - ['/* testBitwiseAnd3 */'], - ['/* testBitwiseAnd4 */'], - ['/* testBitwiseAnd5 */'], - ['/* testBitwiseAndClosureParamDefault */'], - ['/* testBitwiseAndArrowParamDefault */'], - ['/* testBitwiseAndArrowExpression */'], - ['/* testBitwiseAndInArrayKey */'], - ['/* testBitwiseAndInArrayValue */'], - ['/* testBitwiseAndInShortArrayKey */'], - ['/* testBitwiseAndInShortArrayValue */'], - ['/* testBitwiseAndNonArrowFnFunctionCall */'], - ['/* testBitwiseAnd6 */'], - ['/* testLiveCoding */'], + 'in simple assignment 1' => ['/* testBitwiseAnd1 */'], + 'in simple assignment 2' => ['/* testBitwiseAnd2 */'], + 'in property default value' => ['/* testBitwiseAndPropertyDefaultValue */'], + 'in method parameter default value' => ['/* testBitwiseAndParamDefaultValue */'], + 'reference for method parameter' => ['/* testBitwiseAnd3 */'], + 'in return statement' => ['/* testBitwiseAnd4 */'], + 'reference for function parameter' => ['/* testBitwiseAnd5 */'], + 'in closure parameter default value' => ['/* testBitwiseAndClosureParamDefault */'], + 'in arrow function parameter default value' => ['/* testBitwiseAndArrowParamDefault */'], + 'in arrow function return expression' => ['/* testBitwiseAndArrowExpression */'], + 'in long array key' => ['/* testBitwiseAndInArrayKey */'], + 'in long array value' => ['/* testBitwiseAndInArrayValue */'], + 'in short array key' => ['/* testBitwiseAndInShortArrayKey */'], + 'in short array value' => ['/* testBitwiseAndInShortArrayValue */'], + 'in parameter in function call' => ['/* testBitwiseAndNonArrowFnFunctionCall */'], + 'function return by reference' => ['/* testBitwiseAnd6 */'], + 'live coding / undetermined' => ['/* testLiveCoding */'], ]; }//end dataBitwiseAnd() @@ -95,42 +95,42 @@ public function testTypeIntersection($testMarker) * * @see testTypeIntersection() * - * @return array + * @return array> */ public static function dataTypeIntersection() { return [ - ['/* testTypeIntersectionPropertySimple */'], - ['/* testTypeIntersectionPropertyReverseModifierOrder */'], - ['/* testTypeIntersectionPropertyMulti1 */'], - ['/* testTypeIntersectionPropertyMulti2 */'], - ['/* testTypeIntersectionPropertyMulti3 */'], - ['/* testTypeIntersectionPropertyNamespaceRelative */'], - ['/* testTypeIntersectionPropertyPartiallyQualified */'], - ['/* testTypeIntersectionPropertyFullyQualified */'], - ['/* testTypeIntersectionPropertyWithReadOnlyKeyword */'], - ['/* testTypeIntersectionPropertyWithStaticKeyword */'], - ['/* testTypeIntersectionParam1 */'], - ['/* testTypeIntersectionParam2 */'], - ['/* testTypeIntersectionParam3 */'], - ['/* testTypeIntersectionParamNamespaceRelative */'], - ['/* testTypeIntersectionParamPartiallyQualified */'], - ['/* testTypeIntersectionParamFullyQualified */'], - ['/* testTypeIntersectionConstructorPropertyPromotion */'], - ['/* testTypeIntersectionReturnType */'], - ['/* testTypeIntersectionAbstractMethodReturnType1 */'], - ['/* testTypeIntersectionAbstractMethodReturnType2 */'], - ['/* testTypeIntersectionReturnTypeNamespaceRelative */'], - ['/* testTypeIntersectionReturnPartiallyQualified */'], - ['/* testTypeIntersectionReturnFullyQualified */'], - ['/* testTypeIntersectionWithReference */'], - ['/* testTypeIntersectionWithSpreadOperator */'], - ['/* testTypeIntersectionClosureParamIllegalNullable */'], - ['/* testTypeIntersectionClosureReturn */'], - ['/* testTypeIntersectionArrowParam */'], - ['/* testTypeIntersectionArrowReturnType */'], - ['/* testTypeIntersectionNonArrowFunctionDeclaration */'], - ['/* testTypeIntersectionWithInvalidTypes */'], + 'type for static property' => ['/* testTypeIntersectionPropertySimple */'], + 'type for static property, reversed modifier order' => ['/* testTypeIntersectionPropertyReverseModifierOrder */'], + 'type for property, first of multi-intersect' => ['/* testTypeIntersectionPropertyMulti1 */'], + 'type for property, middle of multi-intersect, also comments' => ['/* testTypeIntersectionPropertyMulti2 */'], + 'type for property, last of multi-intersect' => ['/* testTypeIntersectionPropertyMulti3 */'], + 'type for property using namespace relative names' => ['/* testTypeIntersectionPropertyNamespaceRelative */'], + 'type for property using partially qualified names' => ['/* testTypeIntersectionPropertyPartiallyQualified */'], + 'type for property using fully qualified names' => ['/* testTypeIntersectionPropertyFullyQualified */'], + 'type for readonly property' => ['/* testTypeIntersectionPropertyWithReadOnlyKeyword */'], + 'type for static readonly property' => ['/* testTypeIntersectionPropertyWithStaticKeyword */'], + 'type for method parameter' => ['/* testTypeIntersectionParam1 */'], + 'type for method parameter, first in multi-intersect' => ['/* testTypeIntersectionParam2 */'], + 'type for method parameter, last in multi-intersect' => ['/* testTypeIntersectionParam3 */'], + 'type for method parameter with namespace relative names' => ['/* testTypeIntersectionParamNamespaceRelative */'], + 'type for method parameter with partially qualified names' => ['/* testTypeIntersectionParamPartiallyQualified */'], + 'type for method parameter with fully qualified names' => ['/* testTypeIntersectionParamFullyQualified */'], + 'type for property in constructor property promotion' => ['/* testTypeIntersectionConstructorPropertyPromotion */'], + 'return type for method' => ['/* testTypeIntersectionReturnType */'], + 'return type for method, first of multi-intersect' => ['/* testTypeIntersectionAbstractMethodReturnType1 */'], + 'return type for method, last of multi-intersect' => ['/* testTypeIntersectionAbstractMethodReturnType2 */'], + 'return type for method with namespace relative names' => ['/* testTypeIntersectionReturnTypeNamespaceRelative */'], + 'return type for method with partially qualified names' => ['/* testTypeIntersectionReturnPartiallyQualified */'], + 'return type for method with fully qualified names' => ['/* testTypeIntersectionReturnFullyQualified */'], + 'type for function parameter with reference' => ['/* testTypeIntersectionWithReference */'], + 'type for function parameter with spread operator' => ['/* testTypeIntersectionWithSpreadOperator */'], + 'type for closure parameter with illegal nullable' => ['/* testTypeIntersectionClosureParamIllegalNullable */'], + 'return type for closure' => ['/* testTypeIntersectionClosureReturn */'], + 'type for arrow function parameter' => ['/* testTypeIntersectionArrowParam */'], + 'return type for arrow function' => ['/* testTypeIntersectionArrowReturnType */'], + 'type for function parameter, return by ref' => ['/* testTypeIntersectionNonArrowFunctionDeclaration */'], + 'type for function parameter with invalid types' => ['/* testTypeIntersectionWithInvalidTypes */'], ]; }//end dataTypeIntersection() From 11e56f2647a149b946e1af4eab520ccda1463b9e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 06:39:11 +0100 Subject: [PATCH 285/874] Tests/FindImplementedInterfaceNamesTest: normalize data provider arrays ... to improve scannability of the test cases covered. See 225 --- .../FindImplementedInterfaceNamesTest.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.php b/tests/Core/File/FindImplementedInterfaceNamesTest.php index bcf2cade27..ffb59300a7 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.php +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.php @@ -86,7 +86,9 @@ public static function dataImplementedInterface() ], 'class implements single interface, unqualified' => [ 'identifier' => '/* testClassImplementsSingle */', - 'expected' => ['testFIINInterface'], + 'expected' => [ + 'testFIINInterface', + ], ], 'class implements multiple interfaces' => [ 'identifier' => '/* testClassImplementsMultiple */', @@ -97,11 +99,15 @@ public static function dataImplementedInterface() ], 'class implements single interface, fully qualified' => [ 'identifier' => '/* testImplementsFullyQualified */', - 'expected' => ['\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'], + 'expected' => [ + '\PHP_CodeSniffer\Tests\Core\File\testFIINInterface', + ], ], 'class implements single interface, partially qualified' => [ 'identifier' => '/* testImplementsPartiallyQualified */', - 'expected' => ['Core\File\RelativeInterface'], + 'expected' => [ + 'Core\File\RelativeInterface', + ], ], 'class extends and implements' => [ 'identifier' => '/* testClassThatExtendsAndImplements */', @@ -123,7 +129,9 @@ public static function dataImplementedInterface() ], 'enum implements single interface, unqualified' => [ 'identifier' => '/* testEnumImplementsSingle */', - 'expected' => ['Colorful'], + 'expected' => [ + 'Colorful', + ], ], 'enum implements multiple interfaces, unqualified + fully qualified' => [ 'identifier' => '/* testBackedEnumImplementsMulti */', @@ -134,7 +142,9 @@ public static function dataImplementedInterface() ], 'anon class implements single interface, unqualified' => [ 'identifier' => '/* testAnonClassImplementsSingle */', - 'expected' => ['testFIINInterface'], + 'expected' => [ + 'testFIINInterface', + ], ], 'parse error - implements keyword, but no interface name' => [ 'identifier' => '/* testMissingImplementsName */', From 1fad27d2a9f92d55477445bbf97ff38ae5ef363b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 06:43:04 +0100 Subject: [PATCH 286/874] Tests/GetMethodParametersTest: normalize data provider arrays ... to improve scannability of the test cases covered. See 225 --- tests/Core/File/GetMethodParametersTest.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/Core/File/GetMethodParametersTest.php b/tests/Core/File/GetMethodParametersTest.php index 9b920dc703..83419ddeaa 100644 --- a/tests/Core/File/GetMethodParametersTest.php +++ b/tests/Core/File/GetMethodParametersTest.php @@ -143,11 +143,15 @@ public function testNoParams($commentString, $targetTokenType=[T_FUNCTION, T_CLO public static function dataNoParams() { return [ - 'FunctionNoParams' => ['/* testFunctionNoParams */'], - 'ClosureNoParams' => ['/* testClosureNoParams */'], + 'FunctionNoParams' => [ + 'commentString' => '/* testFunctionNoParams */', + ], + 'ClosureNoParams' => [ + 'commentString' => '/* testClosureNoParams */', + ], 'ClosureUseNoParams' => [ - '/* testClosureUseNoParams */', - T_USE, + 'commentString' => '/* testClosureUseNoParams */', + 'targetTokenType' => T_USE, ], ]; From c821e2411d396c016a22c64ee6b7e2563be5b07f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 06:45:20 +0100 Subject: [PATCH 287/874] Tests/GitModifiedTest: normalize data provider arrays ... to improve scannability of the test cases covered. See 225 --- tests/Core/Filters/GitModifiedTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Core/Filters/GitModifiedTest.php b/tests/Core/Filters/GitModifiedTest.php index 46959072f4..1b2189f900 100644 --- a/tests/Core/Filters/GitModifiedTest.php +++ b/tests/Core/Filters/GitModifiedTest.php @@ -112,14 +112,18 @@ public static function dataAcceptOnlyGitModified() 'single file marked as git modified - file in root dir' => [ 'inputPaths' => $fakeFileList, - 'outputGitModified' => ['autoload.php'], + 'outputGitModified' => [ + 'autoload.php', + ], 'expectedOutput' => [ $basedir.'/autoload.php', ], ], 'single file marked as git modified - file in sub dir' => [ 'inputPaths' => $fakeFileList, - 'outputGitModified' => ['src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php'], + 'outputGitModified' => [ + 'src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php', + ], 'expectedOutput' => [ $basedir.'/src', $basedir.'/src/Standards', From 2621fc0e754b3247650d6be0c8a578d960ca7391 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 06:46:27 +0100 Subject: [PATCH 288/874] Tests/GitStagedTest: normalize data provider arrays ... to improve scannability of the test cases covered. See 225 --- tests/Core/Filters/GitStagedTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Core/Filters/GitStagedTest.php b/tests/Core/Filters/GitStagedTest.php index 31b7345bb7..545f5839fa 100644 --- a/tests/Core/Filters/GitStagedTest.php +++ b/tests/Core/Filters/GitStagedTest.php @@ -112,14 +112,18 @@ public static function dataAcceptOnlyGitStaged() 'single file marked as git modified - file in root dir' => [ 'inputPaths' => $fakeFileList, - 'outputGitStaged' => ['autoload.php'], + 'outputGitStaged' => [ + 'autoload.php', + ], 'expectedOutput' => [ $basedir.'/autoload.php', ], ], 'single file marked as git modified - file in sub dir' => [ 'inputPaths' => $fakeFileList, - 'outputGitStaged' => ['src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php'], + 'outputGitStaged' => [ + 'src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php', + ], 'expectedOutput' => [ $basedir.'/src', $basedir.'/src/Standards', From 74501b959fc418d2e1d62bddc9362fbb569f210c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 14 Jan 2024 06:53:37 +0100 Subject: [PATCH 289/874] Tests/UndoNamespacedNameSingleTokenTest: improve test markers Make the test marker names more descriptive. --- tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.inc | 2 +- tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.inc b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.inc index 540f72c9dc..65c551a84f 100644 --- a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.inc +++ b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.inc @@ -79,7 +79,7 @@ class MyClass /* testFunctionCallUnqualified */ echo function_name(); - /* testFunctionPartiallyQualified */ + /* testFunctionCallPartiallyQualified */ echo Level\function_name(); /* testCatchRelative */ diff --git a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php index 2fa8d0e714..04f31d67e4 100644 --- a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php +++ b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php @@ -831,7 +831,7 @@ public static function dataIdentifierTokenization() ], ], [ - '/* testFunctionPartiallyQualified */', + '/* testFunctionCallPartiallyQualified */', [ [ 'type' => 'T_STRING', From 9e0b3ec6c511a5f9e31705d279bb2cb642854e76 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 10:23:25 +0100 Subject: [PATCH 290/874] Tests/UndoNamespacedNameSingleTokenTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes making the data types in the docblocks more specific. --- .../UndoNamespacedNameSingleTokenTest.php | 276 +++++++++--------- 1 file changed, 138 insertions(+), 138 deletions(-) diff --git a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php index 04f31d67e4..6db1156652 100644 --- a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php +++ b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php @@ -28,8 +28,8 @@ final class UndoNamespacedNameSingleTokenTest extends AbstractMethodUnitTest /** * Test that identifier names are tokenized the same across PHP versions, based on the PHP 5/7 tokenization. * - * @param string $testMarker The comment prefacing the test. - * @param array $expectedTokens The tokenization expected. + * @param string $testMarker The comment prefacing the test. + * @param array> $expectedTokens The tokenization expected. * * @dataProvider dataIdentifierTokenization * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize @@ -57,14 +57,14 @@ public function testIdentifierTokenization($testMarker, $expectedTokens) * * @see testIdentifierTokenization() * - * @return array + * @return array>>> */ public static function dataIdentifierTokenization() { return [ - [ - '/* testNamespaceDeclaration */', - [ + 'namespace declaration' => [ + 'testMarker' => '/* testNamespaceDeclaration */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Package', @@ -75,9 +75,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testNamespaceDeclarationWithLevels */', - [ + 'namespace declaration, multi-level' => [ + 'testMarker' => '/* testNamespaceDeclarationWithLevels */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Vendor', @@ -104,9 +104,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testUseStatement */', - [ + 'import use statement, class' => [ + 'testMarker' => '/* testUseStatement */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'ClassName', @@ -117,9 +117,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testUseStatementWithLevels */', - [ + 'import use statement, class, multi-level' => [ + 'testMarker' => '/* testUseStatementWithLevels */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Vendor', @@ -146,9 +146,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionUseStatement */', - [ + 'import use statement, function' => [ + 'testMarker' => '/* testFunctionUseStatement */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'function', @@ -167,9 +167,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionUseStatementWithLevels */', - [ + 'import use statement, function, multi-level' => [ + 'testMarker' => '/* testFunctionUseStatementWithLevels */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'function', @@ -204,9 +204,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testConstantUseStatement */', - [ + 'import use statement, constant' => [ + 'testMarker' => '/* testConstantUseStatement */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'const', @@ -225,9 +225,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testConstantUseStatementWithLevels */', - [ + 'import use statement, constant, multi-level' => [ + 'testMarker' => '/* testConstantUseStatementWithLevels */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'const', @@ -262,9 +262,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testMultiUseUnqualified */', - [ + 'import use statement, multi-statement, unqualified class' => [ + 'testMarker' => '/* testMultiUseUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'UnqualifiedClassName', @@ -275,9 +275,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testMultiUsePartiallyQualified */', - [ + 'import use statement, multi-statement, partially qualified class' => [ + 'testMarker' => '/* testMultiUsePartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Sublevel', @@ -296,9 +296,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testGroupUseStatement */', - [ + 'group use statement, multi-level prefix, mix inside group' => [ + 'testMarker' => '/* testGroupUseStatement */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Vendor', @@ -492,9 +492,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testClassName */', - [ + 'class declaration' => [ + 'testMarker' => '/* testClassName */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'MyClass', @@ -506,9 +506,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testExtendedFQN */', - [ + 'class declaration, extends fully qualified name' => [ + 'testMarker' => '/* testExtendedFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -540,9 +540,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testImplementsRelative */', - [ + 'class declaration, implements namespace relative name' => [ + 'testMarker' => '/* testImplementsRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -561,9 +561,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testImplementsFQN */', - [ + 'class declaration, implements fully qualified name' => [ + 'testMarker' => '/* testImplementsFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -586,9 +586,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testImplementsUnqualified */', - [ + 'class declaration, implements unqualified name' => [ + 'testMarker' => '/* testImplementsUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Unqualified', @@ -599,9 +599,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testImplementsPartiallyQualified */', - [ + 'class declaration, implements partially qualified name' => [ + 'testMarker' => '/* testImplementsPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Sub', @@ -629,9 +629,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionName */', - [ + 'method declaration' => [ + 'testMarker' => '/* testFunctionName */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'function_name', @@ -642,9 +642,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testTypeDeclarationRelative */', - [ + 'param type declaration, namespace relative name' => [ + 'testMarker' => '/* testTypeDeclarationRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -667,9 +667,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testTypeDeclarationFQN */', - [ + 'param type declaration, fully qualified name' => [ + 'testMarker' => '/* testTypeDeclarationFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -700,9 +700,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testTypeDeclarationUnqualified */', - [ + 'param type declaration, unqualified name' => [ + 'testMarker' => '/* testTypeDeclarationUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Unqualified', @@ -717,9 +717,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testTypeDeclarationPartiallyQualified */', - [ + 'param type declaration, partially qualified name' => [ + 'testMarker' => '/* testTypeDeclarationPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_NULLABLE', 'content' => '?', @@ -742,9 +742,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testReturnTypeFQN */', - [ + 'return type declaration, fully qualified name' => [ + 'testMarker' => '/* testReturnTypeFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NULLABLE', 'content' => '?', @@ -763,9 +763,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionCallRelative */', - [ + 'function call, namespace relative name' => [ + 'testMarker' => '/* testFunctionCallRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'NameSpace', @@ -784,9 +784,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionCallFQN */', - [ + 'function call, fully qualified name' => [ + 'testMarker' => '/* testFunctionCallFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -817,9 +817,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionCallUnqualified */', - [ + 'function call, unqualified name' => [ + 'testMarker' => '/* testFunctionCallUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'function_name', @@ -830,9 +830,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testFunctionCallPartiallyQualified */', - [ + 'function call, partially qualified name' => [ + 'testMarker' => '/* testFunctionCallPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Level', @@ -851,9 +851,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testCatchRelative */', - [ + 'catch, namespace relative name' => [ + 'testMarker' => '/* testCatchRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -880,9 +880,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testCatchFQN */', - [ + 'catch, fully qualified name' => [ + 'testMarker' => '/* testCatchFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -897,9 +897,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testCatchUnqualified */', - [ + 'catch, unqualified name' => [ + 'testMarker' => '/* testCatchUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Exception', @@ -910,9 +910,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testCatchPartiallyQualified */', - [ + 'catch, partially qualified name' => [ + 'testMarker' => '/* testCatchPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Level', @@ -931,9 +931,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testNewRelative */', - [ + 'class instantiation, namespace relative name' => [ + 'testMarker' => '/* testNewRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -952,9 +952,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testNewFQN */', - [ + 'class instantiation, fully qualified name' => [ + 'testMarker' => '/* testNewFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -977,9 +977,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testNewUnqualified */', - [ + 'class instantiation, unqualified name' => [ + 'testMarker' => '/* testNewUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'ClassName', @@ -990,9 +990,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testNewPartiallyQualified */', - [ + 'class instantiation, partially qualified name' => [ + 'testMarker' => '/* testNewPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Level', @@ -1011,9 +1011,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testDoubleColonRelative */', - [ + 'double colon class access, namespace relative name' => [ + 'testMarker' => '/* testDoubleColonRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -1032,9 +1032,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testDoubleColonFQN */', - [ + 'double colon class access, fully qualified name' => [ + 'testMarker' => '/* testDoubleColonFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -1049,9 +1049,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testDoubleColonUnqualified */', - [ + 'double colon class access, unqualified name' => [ + 'testMarker' => '/* testDoubleColonUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'ClassName', @@ -1062,9 +1062,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testDoubleColonPartiallyQualified */', - [ + 'double colon class access, partially qualified name' => [ + 'testMarker' => '/* testDoubleColonPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Level', @@ -1083,9 +1083,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInstanceOfRelative */', - [ + 'instanceof, namespace relative name' => [ + 'testMarker' => '/* testInstanceOfRelative */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -1104,9 +1104,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInstanceOfFQN */', - [ + 'instanceof, fully qualified name' => [ + 'testMarker' => '/* testInstanceOfFQN */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', @@ -1129,9 +1129,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInstanceOfUnqualified */', - [ + 'instanceof, unqualified name' => [ + 'testMarker' => '/* testInstanceOfUnqualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'ClassName', @@ -1142,9 +1142,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInstanceOfPartiallyQualified */', - [ + 'instanceof, partially qualified name' => [ + 'testMarker' => '/* testInstanceOfPartiallyQualified */', + 'expectedTokens' => [ [ 'type' => 'T_STRING', 'content' => 'Partially', @@ -1163,9 +1163,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInvalidInPHP8Whitespace */', - [ + 'function call, namespace relative, with whitespace (invalid in PHP 8)' => [ + 'testMarker' => '/* testInvalidInPHP8Whitespace */', + 'expectedTokens' => [ [ 'type' => 'T_NAMESPACE', 'content' => 'namespace', @@ -1213,9 +1213,9 @@ public static function dataIdentifierTokenization() ], ], ], - [ - '/* testInvalidInPHP8Comments */', - [ + 'double colon class access, fully qualified, with whitespace and comments (invalid in PHP 8)' => [ + 'testMarker' => '/* testInvalidInPHP8Comments */', + 'expectedTokens' => [ [ 'type' => 'T_NS_SEPARATOR', 'content' => '\\', From 68c060e62978727fd58310affba223e847377182 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 07:20:30 +0100 Subject: [PATCH 291/874] Tests/RuleInclusionTest: use named data within data sets This commit adds the parameter name for each item in the data set in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes making the data type in the docblock more specific. --- tests/Core/Ruleset/RuleInclusionTest.php | 84 ++++++++++++------------ 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index 5659f7fb03..946a89482d 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -129,7 +129,7 @@ public function testRegisteredSniffCodes($key, $value) * * @see self::testRegisteredSniffCodes() * - * @return array + * @return array> */ public static function dataRegisteredSniffCodes() { @@ -335,9 +335,9 @@ public static function dataRegisteredSniffCodes() * Test that setting properties for standards, categories, sniffs works for all supported rule * inclusion methods. * - * @param string $sniffClass The name of the sniff class. - * @param string $propertyName The name of the changed property. - * @param mixed $expectedValue The value expected for the property. + * @param string $sniffClass The name of the sniff class. + * @param string $propertyName The name of the changed property. + * @param string|int|bool $expectedValue The value expected for the property. * * @dataProvider dataSettingProperties * @@ -362,62 +362,62 @@ public function testSettingProperties($sniffClass, $propertyName, $expectedValue * * @see self::testSettingProperties() * - * @return array + * @return array> */ public static function dataSettingProperties() { return [ 'Set property for complete standard: PSR2 ClassDeclaration' => [ - 'PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\ClassDeclarationSniff', - 'indent', - '20', + 'sniffClass' => 'PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\ClassDeclarationSniff', + 'propertyName' => 'indent', + 'expectedValue' => '20', ], 'Set property for complete standard: PSR2 SwitchDeclaration' => [ - 'PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff', - 'indent', - '20', + 'sniffClass' => 'PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff', + 'propertyName' => 'indent', + 'expectedValue' => '20', ], 'Set property for complete standard: PSR2 FunctionCallSignature' => [ - 'PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionCallSignatureSniff', - 'indent', - '20', + 'sniffClass' => 'PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionCallSignatureSniff', + 'propertyName' => 'indent', + 'expectedValue' => '20', ], 'Set property for complete category: PSR12 OperatorSpacing' => [ - 'PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators\OperatorSpacingSniff', - 'ignoreSpacingBeforeAssignments', - false, + 'sniffClass' => 'PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators\OperatorSpacingSniff', + 'propertyName' => 'ignoreSpacingBeforeAssignments', + 'expectedValue' => false, ], 'Set property for individual sniff: Generic ArrayIndent' => [ - 'PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff', - 'indent', - '2', + 'sniffClass' => 'PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff', + 'propertyName' => 'indent', + 'expectedValue' => '2', ], 'Set property for individual sniff using sniff file inclusion: Generic LineLength' => [ - 'PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff', - 'lineLimit', - '10', + 'sniffClass' => 'PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff', + 'propertyName' => 'lineLimit', + 'expectedValue' => '10', ], 'Set property for individual sniff using sniff file inclusion: CamelCapsFunctionName' => [ - 'PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff', - 'strict', - false, + 'sniffClass' => 'PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff', + 'propertyName' => 'strict', + 'expectedValue' => false, ], 'Set property for individual sniff via included ruleset: NestingLevel - nestingLevel' => [ - 'PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff', - 'nestingLevel', - '2', + 'sniffClass' => 'PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff', + 'propertyName' => 'nestingLevel', + 'expectedValue' => '2', ], 'Set property for all sniffs in an included ruleset: NestingLevel - absoluteNestingLevel' => [ - 'PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff', - 'absoluteNestingLevel', - true, + 'sniffClass' => 'PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff', + 'propertyName' => 'absoluteNestingLevel', + 'expectedValue' => true, ], // Testing that setting a property at error code level does *not* work. 'Set property for error code will not change the sniff property value: CyclomaticComplexity' => [ - 'PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff', - 'complexity', - 10, + 'sniffClass' => 'PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff', + 'propertyName' => 'complexity', + 'expectedValue' => 10, ], ]; @@ -453,22 +453,22 @@ public function testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFail * * @see self::testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails() * - * @return array + * @return arraystring, string>> */ public static function dataSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails() { return [ 'Set property for complete standard: PSR2 ClassDeclaration' => [ - 'PHP_CodeSniffer\Standards\PSR1\Sniffs\Classes\ClassDeclarationSniff', - 'setforallsniffs', + 'sniffClass' => 'PHP_CodeSniffer\Standards\PSR1\Sniffs\Classes\ClassDeclarationSniff', + 'propertyName' => 'setforallsniffs', ], 'Set property for complete standard: PSR2 FunctionCallSignature' => [ - 'PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionCallSignatureSniff', - 'setforallsniffs', + 'sniffClass' => 'PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionCallSignatureSniff', + 'propertyName' => 'setforallsniffs', ], 'Set property for complete category: PSR12 OperatorSpacing' => [ - 'PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators\OperatorSpacingSniff', - 'setforallincategory', + 'sniffClass' => 'PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators\OperatorSpacingSniff', + 'propertyName' => 'setforallincategory', ], ]; From a902981f97deeddb20ebda1ccf891835e29e8849 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 10:29:23 +0100 Subject: [PATCH 292/874] Tests/AnonClassParenthesisOwnerTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes minor data set array normalization. Includes making the data types in the docblocks more specific. --- .../AnonClassParenthesisOwnerTest.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php index 83652d9469..c923371ce0 100644 --- a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php +++ b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php @@ -70,13 +70,17 @@ public function testAnonClassNoParenthesesNextOpenClose($testMarker) * @see testAnonClassNoParentheses() * @see testAnonClassNoParenthesesNextOpenClose() * - * @return array + * @return array> */ public static function dataAnonClassNoParentheses() { return [ - ['/* testNoParentheses */'], - ['/* testNoParenthesesAndEmptyTokens */'], + 'plain' => [ + 'testMarker' => '/* testNoParentheses */', + ], + 'declaration contains comments and extra whitespace' => [ + 'testMarker' => '/* testNoParenthesesAndEmptyTokens */', + ], ]; }//end dataAnonClassNoParentheses() @@ -129,13 +133,17 @@ public function testAnonClassWithParentheses($testMarker) * * @see testAnonClassWithParentheses() * - * @return array + * @return array> */ public static function dataAnonClassWithParentheses() { return [ - ['/* testWithParentheses */'], - ['/* testWithParenthesesAndEmptyTokens */'], + 'plain' => [ + 'testMarker' => '/* testWithParentheses */', + ], + 'declaration contains comments and extra whitespace' => [ + 'testMarker' => '/* testWithParenthesesAndEmptyTokens */', + ], ]; }//end dataAnonClassWithParentheses() From 29290f90c83cccd0368d7f440c628d2610fac316 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 07:26:41 +0100 Subject: [PATCH 293/874] Tests/ArrayKeywordTest: use named data within data sets This commit adds the parameter name for each item in the data set in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes minor array normalization. Includes making the data type in the docblock more specific. --- tests/Core/Tokenizer/ArrayKeywordTest.php | 46 +++++++++++++++-------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/tests/Core/Tokenizer/ArrayKeywordTest.php b/tests/Core/Tokenizer/ArrayKeywordTest.php index 56a02d4dde..653b6a18b2 100644 --- a/tests/Core/Tokenizer/ArrayKeywordTest.php +++ b/tests/Core/Tokenizer/ArrayKeywordTest.php @@ -49,19 +49,27 @@ public function testArrayKeyword($testMarker, $testContent='array') * * @see testArrayKeyword() * - * @return array + * @return array> */ public static function dataArrayKeyword() { return [ - 'empty array' => ['/* testEmptyArray */'], - 'array with space before parenthesis' => ['/* testArrayWithSpace */'], + 'empty array' => [ + 'testMarker' => '/* testEmptyArray */', + ], + 'array with space before parenthesis' => [ + 'testMarker' => '/* testArrayWithSpace */', + ], 'array with comment before parenthesis' => [ - '/* testArrayWithComment */', - 'Array', + 'testMarker' => '/* testArrayWithComment */', + 'testContent' => 'Array', + ], + 'nested: outer array' => [ + 'testMarker' => '/* testNestingArray */', + ], + 'nested: inner array' => [ + 'testMarker' => '/* testNestedArray */', ], - 'nested: outer array' => ['/* testNestingArray */'], - 'nested: inner array' => ['/* testNestedArray */'], ]; }//end dataArrayKeyword() @@ -101,17 +109,21 @@ public function testArrayType($testMarker, $testContent='array') * * @see testArrayType() * - * @return array + * @return array> */ public static function dataArrayType() { return [ 'closure return type' => [ - '/* testClosureReturnType */', - 'Array', + 'testMarker' => '/* testClosureReturnType */', + 'testContent' => 'Array', + ], + 'function param type' => [ + 'testMarker' => '/* testFunctionDeclarationParamType */', + ], + 'function union return type' => [ + 'testMarker' => '/* testFunctionDeclarationReturnType */', ], - 'function param type' => ['/* testFunctionDeclarationParamType */'], - 'function union return type' => ['/* testFunctionDeclarationReturnType */'], ]; }//end dataArrayType() @@ -152,16 +164,18 @@ public function testNotArrayKeyword($testMarker, $testContent='array') * * @see testNotArrayKeyword() * - * @return array + * @return array> */ public static function dataNotArrayKeyword() { return [ 'class-constant-name' => [ - '/* testClassConst */', - 'ARRAY', + 'testMarker' => '/* testClassConst */', + 'testContent' => 'ARRAY', + ], + 'class-method-name' => [ + 'testMarker' => '/* testClassMethod */', ], - 'class-method-name' => ['/* testClassMethod */'], ]; }//end dataNotArrayKeyword() From c5f32cdb10357476f5a1f81bf7b659d51684f983 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 10:37:56 +0100 Subject: [PATCH 294/874] Tests/BackfillFnTokenTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes minor data set array normalization. Includes making the data types in the docblocks more specific. --- tests/Core/Tokenizer/BackfillFnTokenTest.php | 118 +++++++++++-------- 1 file changed, 67 insertions(+), 51 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillFnTokenTest.php b/tests/Core/Tokenizer/BackfillFnTokenTest.php index 5058a85dc4..1f4cd05011 100644 --- a/tests/Core/Tokenizer/BackfillFnTokenTest.php +++ b/tests/Core/Tokenizer/BackfillFnTokenTest.php @@ -579,38 +579,38 @@ public function testInMatchValue($testMarker, $openerOffset, $closerOffset, $exp * * @see testInMatchValue() * - * @return array + * @return array> */ public static function dataInMatchValue() { return [ 'not_last_value' => [ - '/* testInMatchNotLastValue */', - 5, - 11, - 'T_COMMA', - 'comma', + 'testMarker' => '/* testInMatchNotLastValue */', + 'openerOffset' => 5, + 'closerOffset' => 11, + 'expectedCloserType' => 'T_COMMA', + 'expectedCloserFriendlyName' => 'comma', ], 'last_value_with_trailing_comma' => [ - '/* testInMatchLastValueWithTrailingComma */', - 5, - 11, - 'T_COMMA', - 'comma', + 'testMarker' => '/* testInMatchLastValueWithTrailingComma */', + 'openerOffset' => 5, + 'closerOffset' => 11, + 'expectedCloserType' => 'T_COMMA', + 'expectedCloserFriendlyName' => 'comma', ], 'last_value_without_trailing_comma_1' => [ - '/* testInMatchLastValueNoTrailingComma1 */', - 5, - 10, - 'T_CLOSE_PARENTHESIS', - 'close parenthesis', + 'testMarker' => '/* testInMatchLastValueNoTrailingComma1 */', + 'openerOffset' => 5, + 'closerOffset' => 10, + 'expectedCloserType' => 'T_CLOSE_PARENTHESIS', + 'expectedCloserFriendlyName' => 'close parenthesis', ], 'last_value_without_trailing_comma_2' => [ - '/* testInMatchLastValueNoTrailingComma2 */', - 5, - 11, - 'T_VARIABLE', - '$y variable', + 'testMarker' => '/* testInMatchLastValueNoTrailingComma2 */', + 'openerOffset' => 5, + 'closerOffset' => 11, + 'expectedCloserType' => 'T_VARIABLE', + 'expectedCloserFriendlyName' => '$y variable', ], ]; @@ -669,47 +669,63 @@ public function testNotAnArrowFunction($testMarker, $testContent='fn') * * @see testNotAnArrowFunction() * - * @return array + * @return array> */ public static function dataNotAnArrowFunction() { return [ - ['/* testFunctionName */'], - [ - '/* testConstantDeclaration */', - 'FN', + 'name of a function, context: declaration' => [ + 'testMarker' => '/* testFunctionName */', ], - [ - '/* testConstantDeclarationLower */', - 'fn', + 'name of a constant, context: declaration using "const" keyword - uppercase' => [ + 'testMarker' => '/* testConstantDeclaration */', + 'testContent' => 'FN', ], - ['/* testStaticMethodName */'], - ['/* testPropertyAssignment */'], - [ - '/* testAnonClassMethodName */', - 'fN', + 'name of a constant, context: declaration using "const" keyword - lowercase' => [ + 'testMarker' => '/* testConstantDeclarationLower */', + 'testContent' => 'fn', ], - ['/* testNonArrowStaticMethodCall */'], - [ - '/* testNonArrowConstantAccess */', - 'FN', + 'name of a (static) method, context: declaration' => [ + 'testMarker' => '/* testStaticMethodName */', ], - [ - '/* testNonArrowConstantAccessMixed */', - 'Fn', + 'name of a property, context: property access' => [ + 'testMarker' => '/* testPropertyAssignment */', ], - ['/* testNonArrowObjectMethodCall */'], - [ - '/* testNonArrowObjectMethodCallUpper */', - 'FN', + 'name of a method, context: declaration in an anon class - mixed case' => [ + 'testMarker' => '/* testAnonClassMethodName */', + 'testContent' => 'fN', ], - [ - '/* testNonArrowNamespacedFunctionCall */', - 'Fn', + 'name of a method, context: static method call' => [ + 'testMarker' => '/* testNonArrowStaticMethodCall */', + ], + 'name of a constant, context: constant access - uppercase' => [ + 'testMarker' => '/* testNonArrowConstantAccess */', + 'testContent' => 'FN', + ], + 'name of a constant, context: constant access - mixed case' => [ + 'testMarker' => '/* testNonArrowConstantAccessMixed */', + 'testContent' => 'Fn', + ], + 'name of a method, context: method call on object - lowercase' => [ + 'testMarker' => '/* testNonArrowObjectMethodCall */', + ], + 'name of a method, context: method call on object - uppercase' => [ + 'testMarker' => '/* testNonArrowObjectMethodCallUpper */', + 'testContent' => 'FN', + ], + 'name of a (namespaced) function, context: partially qualified function call' => [ + 'testMarker' => '/* testNonArrowNamespacedFunctionCall */', + 'testContent' => 'Fn', + ], + 'name of a (namespaced) function, context: namespace relative function call' => [ + 'testMarker' => '/* testNonArrowNamespaceOperatorFunctionCall */', + ], + 'name of a function, context: declaration with union types for param and return' => [ + 'testMarker' => '/* testNonArrowFunctionNameWithUnionTypes */', + ], + 'unknown - live coding/parse error' => [ + 'testMarker' => '/* testLiveCoding */', ], - ['/* testNonArrowNamespaceOperatorFunctionCall */'], - ['/* testNonArrowFunctionNameWithUnionTypes */'], - ['/* testLiveCoding */'], ]; }//end dataNotAnArrowFunction() From 118aa7fda95fb66364c37481c834469b3df2c2c9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 23:38:48 +0100 Subject: [PATCH 295/874] Tests/BackfillEnumTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes: * Making the data type in the docblock more specific. * Removing a duplicate test. --- tests/Core/Tokenizer/BackfillEnumTest.inc | 4 - tests/Core/Tokenizer/BackfillEnumTest.php | 180 +++++++++++----------- 2 files changed, 88 insertions(+), 96 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillEnumTest.inc b/tests/Core/Tokenizer/BackfillEnumTest.inc index 82bfe24fd5..16624eccea 100644 --- a/tests/Core/Tokenizer/BackfillEnumTest.inc +++ b/tests/Core/Tokenizer/BackfillEnumTest.inc @@ -66,10 +66,6 @@ enum /* comment */ Name case SOME_CASE; } -enum /* testEnumUsedAsEnumName */ Enum -{ -} - /* testEnumUsedAsNamespaceName */ namespace Enum; /* testEnumUsedAsPartOfNamespaceName */ diff --git a/tests/Core/Tokenizer/BackfillEnumTest.php b/tests/Core/Tokenizer/BackfillEnumTest.php index c033cba41e..6027c181dd 100644 --- a/tests/Core/Tokenizer/BackfillEnumTest.php +++ b/tests/Core/Tokenizer/BackfillEnumTest.php @@ -73,52 +73,52 @@ public function testEnums($testMarker, $testContent, $openerOffset, $closerOffse * * @see testEnums() * - * @return array + * @return array> */ public static function dataEnums() { return [ - [ - '/* testPureEnum */', - 'enum', - 4, - 12, - ], - [ - '/* testBackedIntEnum */', - 'enum', - 7, - 29, - ], - [ - '/* testBackedStringEnum */', - 'enum', - 8, - 30, - ], - [ - '/* testComplexEnum */', - 'enum', - 11, - 72, - ], - [ - '/* testEnumWithEnumAsClassName */', - 'enum', - 6, - 7, - ], - [ - '/* testEnumIsCaseInsensitive */', - 'EnUm', - 4, - 5, - ], - [ - '/* testDeclarationContainingComment */', - 'enum', - 6, - 14, + 'enum - pure' => [ + 'testMarker' => '/* testPureEnum */', + 'testContent' => 'enum', + 'openerOffset' => 4, + 'closerOffset' => 12, + ], + 'enum - backed int' => [ + 'testMarker' => '/* testBackedIntEnum */', + 'testContent' => 'enum', + 'openerOffset' => 7, + 'closerOffset' => 29, + ], + 'enum - backed string' => [ + 'testMarker' => '/* testBackedStringEnum */', + 'testContent' => 'enum', + 'openerOffset' => 8, + 'closerOffset' => 30, + ], + 'enum - backed int + implements' => [ + 'testMarker' => '/* testComplexEnum */', + 'testContent' => 'enum', + 'openerOffset' => 11, + 'closerOffset' => 72, + ], + 'enum keyword when "enum" is the name for the construct (yes, this is allowed)' => [ + 'testMarker' => '/* testEnumWithEnumAsClassName */', + 'testContent' => 'enum', + 'openerOffset' => 6, + 'closerOffset' => 7, + ], + 'enum - keyword is case insensitive' => [ + 'testMarker' => '/* testEnumIsCaseInsensitive */', + 'testContent' => 'EnUm', + 'openerOffset' => 4, + 'closerOffset' => 5, + ], + 'enum - declaration containing comment' => [ + 'testMarker' => '/* testDeclarationContainingComment */', + 'testContent' => 'enum', + 'openerOffset' => 6, + 'closerOffset' => 14, ], ]; @@ -152,74 +152,70 @@ public function testNotEnums($testMarker, $testContent) * * @see testNotEnums() * - * @return array + * @return array> */ public static function dataNotEnums() { return [ - [ - '/* testEnumAsClassNameAfterEnumKeyword */', - 'Enum', + 'not enum - construct named enum' => [ + 'testMarker' => '/* testEnumAsClassNameAfterEnumKeyword */', + 'testContent' => 'Enum', ], - [ - '/* testEnumUsedAsClassName */', - 'Enum', + 'not enum - class named enum' => [ + 'testMarker' => '/* testEnumUsedAsClassName */', + 'testContent' => 'Enum', ], - [ - '/* testEnumUsedAsClassConstantName */', - 'ENUM', + 'not enum - class constant named enum' => [ + 'testMarker' => '/* testEnumUsedAsClassConstantName */', + 'testContent' => 'ENUM', ], - [ - '/* testEnumUsedAsMethodName */', - 'enum', + 'not enum - method named enum' => [ + 'testMarker' => '/* testEnumUsedAsMethodName */', + 'testContent' => 'enum', ], - [ - '/* testEnumUsedAsPropertyName */', - 'enum', + 'not enum - class property named enum' => [ + 'testMarker' => '/* testEnumUsedAsPropertyName */', + 'testContent' => 'enum', ], - [ - '/* testEnumUsedAsFunctionName */', - 'enum', + 'not enum - global function named enum' => [ + 'testMarker' => '/* testEnumUsedAsFunctionName */', + 'testContent' => 'enum', ], - [ - '/* testEnumUsedAsEnumName */', - 'Enum', + 'not enum - namespace named enum' => [ + 'testMarker' => '/* testEnumUsedAsNamespaceName */', + 'testContent' => 'Enum', ], - [ - '/* testEnumUsedAsNamespaceName */', - 'Enum', + 'not enum - part of namespace named enum' => [ + 'testMarker' => '/* testEnumUsedAsPartOfNamespaceName */', + 'testContent' => 'Enum', ], - [ - '/* testEnumUsedAsPartOfNamespaceName */', - 'Enum', + 'not enum - class instantiation for class enum' => [ + 'testMarker' => '/* testEnumUsedInObjectInitialization */', + 'testContent' => 'Enum', ], - [ - '/* testEnumUsedInObjectInitialization */', - 'Enum', + 'not enum - function call' => [ + 'testMarker' => '/* testEnumAsFunctionCall */', + 'testContent' => 'enum', ], - [ - '/* testEnumAsFunctionCall */', - 'enum', + 'not enum - namespace relative function call' => [ + 'testMarker' => '/* testEnumAsFunctionCallWithNamespace */', + 'testContent' => 'enum', ], - [ - '/* testEnumAsFunctionCallWithNamespace */', - 'enum', + 'not enum - class constant fetch with enum as class name' => [ + 'testMarker' => '/* testClassConstantFetchWithEnumAsClassName */', + 'testContent' => 'Enum', ], - [ - '/* testClassConstantFetchWithEnumAsClassName */', - 'Enum', + 'not enum - class constant fetch with enum as constant name' => [ + 'testMarker' => '/* testClassConstantFetchWithEnumAsConstantName */', + 'testContent' => 'ENUM', ], - [ - '/* testClassConstantFetchWithEnumAsConstantName */', - 'ENUM', + 'parse error, not enum - enum declaration without name' => [ + 'testMarker' => '/* testParseErrorMissingName */', + 'testContent' => 'enum', ], - [ - '/* testParseErrorMissingName */', - 'enum', - ], - [ - '/* testParseErrorLiveCoding */', - 'enum', + 'parse error, not enum - enum declaration with curlies' => [ + 'testMarker' => '/* testParseErrorLiveCoding */', + 'testContent' => 'enum', ], ]; From 145b8ca9a2411c61811e885caae1d059c3e2acd9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 29 Dec 2023 23:51:37 +0100 Subject: [PATCH 296/874] Tests/BackfillExplicitOctalNotationTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblock more specific. --- .../BackfillExplicitOctalNotationTest.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php b/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php index 4f67e567c9..7d98541dc4 100644 --- a/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php +++ b/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php @@ -47,66 +47,66 @@ public function testExplicitOctalNotation($marker, $value, $nextToken, $nextCont * * @see testExplicitOctalNotation() * - * @return array + * @return array> */ public static function dataExplicitOctalNotation() { return [ - [ + 'Explicit octal' => [ 'marker' => '/* testExplicitOctal */', 'value' => '0o137041', 'nextToken' => T_SEMICOLON, 'nextContent' => ';', ], - [ + 'Explicit octal - capitalized O' => [ 'marker' => '/* testExplicitOctalCapitalised */', 'value' => '0O137041', 'nextToken' => T_SEMICOLON, 'nextContent' => ';', ], - [ + 'Explicit octal - with numeric literal separator' => [ 'marker' => '/* testExplicitOctalWithNumericSeparator */', 'value' => '0o137_041', 'nextToken' => T_SEMICOLON, 'nextContent' => ';', ], - [ + 'Invalid explicit octal - numeric literal separator directly after "0o"' => [ 'marker' => '/* testInvalid1 */', 'value' => '0', 'nextToken' => T_STRING, 'nextContent' => 'o_137', ], - [ + 'Invalid explicit octal - numeric literal separator directly after "0O" (capitalized O)' => [ 'marker' => '/* testInvalid2 */', 'value' => '0', 'nextToken' => T_STRING, 'nextContent' => 'O_41', ], - [ + 'Invalid explicit octal - number out of octal range' => [ 'marker' => '/* testInvalid3 */', 'value' => '0', 'nextToken' => T_STRING, 'nextContent' => 'o91', ], - [ + 'Invalid explicit octal - part of the number out of octal range' => [ 'marker' => '/* testInvalid4 */', 'value' => '0O2', 'nextToken' => T_LNUMBER, 'nextContent' => '82', ], - [ + 'Invalid explicit octal - part of the number out of octal range with numeric literal separator after' => [ 'marker' => '/* testInvalid5 */', 'value' => '0o2', 'nextToken' => T_LNUMBER, 'nextContent' => '8_2', ], - [ + 'Invalid explicit octal - part of the number out of octal range with numeric literal separator before' => [ 'marker' => '/* testInvalid6 */', 'value' => '0o2', 'nextToken' => T_STRING, 'nextContent' => '_82', ], - [ + 'Invalid explicit octal - explicit notation without number' => [ 'marker' => '/* testInvalid7 */', 'value' => '0', 'nextToken' => T_STRING, From dadb35a1fb90a13a159740d364964dc291b08ec5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 07:52:00 +0100 Subject: [PATCH 297/874] Tests/BackfillMatchTokenTest: use named data within data sets This commit adds the parameter name for each item in the data set in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes minor array normalization. Includes making the data type in the docblock more specific. --- .../Core/Tokenizer/BackfillMatchTokenTest.php | 328 ++++++++++-------- 1 file changed, 177 insertions(+), 151 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillMatchTokenTest.php b/tests/Core/Tokenizer/BackfillMatchTokenTest.php index 99655b0f85..02e8fb748c 100644 --- a/tests/Core/Tokenizer/BackfillMatchTokenTest.php +++ b/tests/Core/Tokenizer/BackfillMatchTokenTest.php @@ -51,147 +51,147 @@ public function testMatchExpression($testMarker, $openerOffset, $closerOffset, $ * * @see testMatchExpression() * - * @return array + * @return array> */ public static function dataMatchExpression() { return [ 'simple_match' => [ - '/* testMatchSimple */', - 6, - 33, + 'testMarker' => '/* testMatchSimple */', + 'openerOffset' => 6, + 'closerOffset' => 33, ], 'no_trailing_comma' => [ - '/* testMatchNoTrailingComma */', - 6, - 24, + 'testMarker' => '/* testMatchNoTrailingComma */', + 'openerOffset' => 6, + 'closerOffset' => 24, ], 'with_default_case' => [ - '/* testMatchWithDefault */', - 6, - 33, + 'testMarker' => '/* testMatchWithDefault */', + 'openerOffset' => 6, + 'closerOffset' => 33, ], 'expression_in_condition' => [ - '/* testMatchExpressionInCondition */', - 6, - 77, + 'testMarker' => '/* testMatchExpressionInCondition */', + 'openerOffset' => 6, + 'closerOffset' => 77, ], 'multicase' => [ - '/* testMatchMultiCase */', - 6, - 40, + 'testMarker' => '/* testMatchMultiCase */', + 'openerOffset' => 6, + 'closerOffset' => 40, ], 'multicase_trailing_comma_in_case' => [ - '/* testMatchMultiCaseTrailingCommaInCase */', - 6, - 47, + 'testMarker' => '/* testMatchMultiCaseTrailingCommaInCase */', + 'openerOffset' => 6, + 'closerOffset' => 47, ], 'in_closure_not_lowercase' => [ - '/* testMatchInClosureNotLowercase */', - 6, - 36, - 'Match', + 'testMarker' => '/* testMatchInClosureNotLowercase */', + 'openerOffset' => 6, + 'closerOffset' => 36, + 'testContent' => 'Match', ], 'in_arrow_function' => [ - '/* testMatchInArrowFunction */', - 5, - 36, + 'testMarker' => '/* testMatchInArrowFunction */', + 'openerOffset' => 5, + 'closerOffset' => 36, ], 'arrow_function_in_match_no_trailing_comma' => [ - '/* testArrowFunctionInMatchNoTrailingComma */', - 6, - 44, + 'testMarker' => '/* testArrowFunctionInMatchNoTrailingComma */', + 'openerOffset' => 6, + 'closerOffset' => 44, ], 'in_function_call_param_not_lowercase' => [ - '/* testMatchInFunctionCallParamNotLowercase */', - 8, - 32, - 'MATCH', + 'testMarker' => '/* testMatchInFunctionCallParamNotLowercase */', + 'openerOffset' => 8, + 'closerOffset' => 32, + 'testContent' => 'MATCH', ], 'in_method_call_param' => [ - '/* testMatchInMethodCallParam */', - 5, - 13, + 'testMarker' => '/* testMatchInMethodCallParam */', + 'openerOffset' => 5, + 'closerOffset' => 13, ], 'discard_result' => [ - '/* testMatchDiscardResult */', - 6, - 18, + 'testMarker' => '/* testMatchDiscardResult */', + 'openerOffset' => 6, + 'closerOffset' => 18, ], 'duplicate_conditions_and_comments' => [ - '/* testMatchWithDuplicateConditionsWithComments */', - 12, - 59, + 'testMarker' => '/* testMatchWithDuplicateConditionsWithComments */', + 'openerOffset' => 12, + 'closerOffset' => 59, ], 'nested_match_outer' => [ - '/* testNestedMatchOuter */', - 6, - 33, + 'testMarker' => '/* testNestedMatchOuter */', + 'openerOffset' => 6, + 'closerOffset' => 33, ], 'nested_match_inner' => [ - '/* testNestedMatchInner */', - 6, - 14, + 'testMarker' => '/* testNestedMatchInner */', + 'openerOffset' => 6, + 'closerOffset' => 14, ], 'ternary_condition' => [ - '/* testMatchInTernaryCondition */', - 6, - 21, + 'testMarker' => '/* testMatchInTernaryCondition */', + 'openerOffset' => 6, + 'closerOffset' => 21, ], 'ternary_then' => [ - '/* testMatchInTernaryThen */', - 6, - 21, + 'testMarker' => '/* testMatchInTernaryThen */', + 'openerOffset' => 6, + 'closerOffset' => 21, ], 'ternary_else' => [ - '/* testMatchInTernaryElse */', - 6, - 21, + 'testMarker' => '/* testMatchInTernaryElse */', + 'openerOffset' => 6, + 'closerOffset' => 21, ], 'array_value' => [ - '/* testMatchInArrayValue */', - 6, - 21, + 'testMarker' => '/* testMatchInArrayValue */', + 'openerOffset' => 6, + 'closerOffset' => 21, ], 'array_key' => [ - '/* testMatchInArrayKey */', - 6, - 21, + 'testMarker' => '/* testMatchInArrayKey */', + 'openerOffset' => 6, + 'closerOffset' => 21, ], 'returning_array' => [ - '/* testMatchreturningArray */', - 6, - 125, + 'testMarker' => '/* testMatchreturningArray */', + 'openerOffset' => 6, + 'closerOffset' => 125, ], 'nested_in_switch_case_1' => [ - '/* testMatchWithDefaultNestedInSwitchCase1 */', - 6, - 25, + 'testMarker' => '/* testMatchWithDefaultNestedInSwitchCase1 */', + 'openerOffset' => 6, + 'closerOffset' => 25, ], 'nested_in_switch_case_2' => [ - '/* testMatchWithDefaultNestedInSwitchCase2 */', - 6, - 25, + 'testMarker' => '/* testMatchWithDefaultNestedInSwitchCase2 */', + 'openerOffset' => 6, + 'closerOffset' => 25, ], 'nested_in_switch_default' => [ - '/* testMatchWithDefaultNestedInSwitchDefault */', - 6, - 25, + 'testMarker' => '/* testMatchWithDefaultNestedInSwitchDefault */', + 'openerOffset' => 6, + 'closerOffset' => 25, ], 'match_with_nested_switch' => [ - '/* testMatchContainingSwitch */', - 6, - 180, + 'testMarker' => '/* testMatchContainingSwitch */', + 'openerOffset' => 6, + 'closerOffset' => 180, ], 'no_cases' => [ - '/* testMatchNoCases */', - 6, - 7, + 'testMarker' => '/* testMatchNoCases */', + 'openerOffset' => 6, + 'closerOffset' => 7, ], 'multi_default' => [ - '/* testMatchMultiDefault */', - 6, - 40, + 'testMarker' => '/* testMatchMultiDefault */', + 'openerOffset' => 6, + 'closerOffset' => 40, ], ]; @@ -241,76 +241,102 @@ public function testNotAMatchStructure($testMarker, $testContent='match') * * @see testNotAMatchStructure() * - * @return array + * @return array> */ public static function dataNotAMatchStructure() { return [ - 'static_method_call' => ['/* testNoMatchStaticMethodCall */'], + 'static_method_call' => [ + 'testMarker' => '/* testNoMatchStaticMethodCall */', + ], 'class_constant_access' => [ - '/* testNoMatchClassConstantAccess */', - 'MATCH', + 'testMarker' => '/* testNoMatchClassConstantAccess */', + 'testContent' => 'MATCH', ], 'class_constant_array_access' => [ - '/* testNoMatchClassConstantArrayAccessMixedCase */', - 'Match', + 'testMarker' => '/* testNoMatchClassConstantArrayAccessMixedCase */', + 'testContent' => 'Match', + ], + 'method_call' => [ + 'testMarker' => '/* testNoMatchMethodCall */', ], - 'method_call' => ['/* testNoMatchMethodCall */'], 'method_call_uppercase' => [ - '/* testNoMatchMethodCallUpper */', - 'MATCH', - ], - 'property_access' => ['/* testNoMatchPropertyAccess */'], - 'namespaced_function_call' => ['/* testNoMatchNamespacedFunctionCall */'], - 'namespace_operator_function_call' => ['/* testNoMatchNamespaceOperatorFunctionCall */'], - 'interface_method_declaration' => ['/* testNoMatchInterfaceMethodDeclaration */'], - 'class_constant_declaration' => ['/* testNoMatchClassConstantDeclarationLower */'], - 'class_method_declaration' => ['/* testNoMatchClassMethodDeclaration */'], - 'property_assigment' => ['/* testNoMatchPropertyAssignment */'], + 'testMarker' => '/* testNoMatchMethodCallUpper */', + 'testContent' => 'MATCH', + ], + 'property_access' => [ + 'testMarker' => '/* testNoMatchPropertyAccess */', + ], + 'namespaced_function_call' => [ + 'testMarker' => '/* testNoMatchNamespacedFunctionCall */', + ], + 'namespace_operator_function_call' => [ + 'testMarker' => '/* testNoMatchNamespaceOperatorFunctionCall */', + ], + 'interface_method_declaration' => [ + 'testMarker' => '/* testNoMatchInterfaceMethodDeclaration */', + ], + 'class_constant_declaration' => [ + 'testMarker' => '/* testNoMatchClassConstantDeclarationLower */', + ], + 'class_method_declaration' => [ + 'testMarker' => '/* testNoMatchClassMethodDeclaration */', + ], + 'property_assigment' => [ + 'testMarker' => '/* testNoMatchPropertyAssignment */', + ], 'class_instantiation' => [ - '/* testNoMatchClassInstantiation */', - 'Match', + 'testMarker' => '/* testNoMatchClassInstantiation */', + 'testContent' => 'Match', ], 'anon_class_method_declaration' => [ - '/* testNoMatchAnonClassMethodDeclaration */', - 'maTCH', + 'testMarker' => '/* testNoMatchAnonClassMethodDeclaration */', + 'testContent' => 'maTCH', ], 'class_declaration' => [ - '/* testNoMatchClassDeclaration */', - 'Match', + 'testMarker' => '/* testNoMatchClassDeclaration */', + 'testContent' => 'Match', ], 'interface_declaration' => [ - '/* testNoMatchInterfaceDeclaration */', - 'Match', + 'testMarker' => '/* testNoMatchInterfaceDeclaration */', + 'testContent' => 'Match', ], 'trait_declaration' => [ - '/* testNoMatchTraitDeclaration */', - 'Match', + 'testMarker' => '/* testNoMatchTraitDeclaration */', + 'testContent' => 'Match', ], 'constant_declaration' => [ - '/* testNoMatchConstantDeclaration */', - 'MATCH', + 'testMarker' => '/* testNoMatchConstantDeclaration */', + 'testContent' => 'MATCH', + ], + 'function_declaration' => [ + 'testMarker' => '/* testNoMatchFunctionDeclaration */', ], - 'function_declaration' => ['/* testNoMatchFunctionDeclaration */'], 'namespace_declaration' => [ - '/* testNoMatchNamespaceDeclaration */', - 'Match', + 'testMarker' => '/* testNoMatchNamespaceDeclaration */', + 'testContent' => 'Match', ], 'class_extends_declaration' => [ - '/* testNoMatchExtendedClassDeclaration */', - 'Match', + 'testMarker' => '/* testNoMatchExtendedClassDeclaration */', + 'testContent' => 'Match', ], 'class_implements_declaration' => [ - '/* testNoMatchImplementedClassDeclaration */', - 'Match', + 'testMarker' => '/* testNoMatchImplementedClassDeclaration */', + 'testContent' => 'Match', ], 'use_statement' => [ - '/* testNoMatchInUseStatement */', - 'Match', + 'testMarker' => '/* testNoMatchInUseStatement */', + 'testContent' => 'Match', + ], + 'unsupported_inline_control_structure' => [ + 'testMarker' => '/* testNoMatchMissingCurlies */', + ], + 'unsupported_alternative_syntax' => [ + 'testMarker' => '/* testNoMatchAlternativeSyntax */', + ], + 'live_coding' => [ + 'testMarker' => '/* testLiveCoding */', ], - 'unsupported_inline_control_structure' => ['/* testNoMatchMissingCurlies */'], - 'unsupported_alternative_syntax' => ['/* testNoMatchAlternativeSyntax */'], - 'live_coding' => ['/* testLiveCoding */'], ]; }//end dataNotAMatchStructure() @@ -344,25 +370,25 @@ public function testSwitchExpression($testMarker, $openerOffset, $closerOffset) * * @see testSwitchExpression() * - * @return array + * @return array> */ public static function dataSwitchExpression() { return [ 'switch_containing_match' => [ - '/* testSwitchContainingMatch */', - 6, - 174, + 'testMarker' => '/* testSwitchContainingMatch */', + 'openerOffset' => 6, + 'closerOffset' => 174, ], 'match_containing_switch_1' => [ - '/* testSwitchNestedInMatch1 */', - 5, - 63, + 'testMarker' => '/* testSwitchNestedInMatch1 */', + 'openerOffset' => 5, + 'closerOffset' => 63, ], 'match_containing_switch_2' => [ - '/* testSwitchNestedInMatch2 */', - 5, - 63, + 'testMarker' => '/* testSwitchNestedInMatch2 */', + 'openerOffset' => 5, + 'closerOffset' => 63, ], ]; @@ -397,35 +423,35 @@ public function testSwitchCaseVersusMatch($testMarker, $openerOffset, $closerOff * * @see testSwitchCaseVersusMatch() * - * @return array + * @return array> */ public static function dataSwitchCaseVersusMatch() { return [ 'switch_with_nested_match_case_1' => [ - '/* testMatchWithDefaultNestedInSwitchCase1 */', - 3, - 55, + 'testMarker' => '/* testMatchWithDefaultNestedInSwitchCase1 */', + 'openerOffset' => 3, + 'closerOffset' => 55, ], 'switch_with_nested_match_case_2' => [ - '/* testMatchWithDefaultNestedInSwitchCase2 */', - 4, - 21, + 'testMarker' => '/* testMatchWithDefaultNestedInSwitchCase2 */', + 'openerOffset' => 4, + 'closerOffset' => 21, ], 'switch_with_nested_match_default_case' => [ - '/* testMatchWithDefaultNestedInSwitchDefault */', - 1, - 38, + 'testMarker' => '/* testMatchWithDefaultNestedInSwitchDefault */', + 'openerOffset' => 1, + 'closerOffset' => 38, ], 'match_with_nested_switch_case' => [ - '/* testSwitchDefaultNestedInMatchCase */', - 1, - 18, + 'testMarker' => '/* testSwitchDefaultNestedInMatchCase */', + 'openerOffset' => 1, + 'closerOffset' => 18, ], 'match_with_nested_switch_default_case' => [ - '/* testSwitchDefaultNestedInMatchDefault */', - 1, - 20, + 'testMarker' => '/* testSwitchDefaultNestedInMatchDefault */', + 'openerOffset' => 1, + 'closerOffset' => 20, ], ]; From c504beaf1a9856d2cfa12395951879f64abd80a9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 8 Jan 2024 00:55:46 +0100 Subject: [PATCH 298/874] Tests/ContextSensitiveKeywordsTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in a data set when the data set contains multiple parameters, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes making the data types in the docblocks more specific. --- .../ContextSensitiveKeywordsTest.php | 762 +++++++++--------- 1 file changed, 381 insertions(+), 381 deletions(-) diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php index 9326c57a96..e30a86fa8f 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php @@ -43,112 +43,112 @@ public function testStrings($testMarker) * * @see testStrings() * - * @return array + * @return array> */ public static function dataStrings() { return [ - ['/* testAbstract */'], - ['/* testArray */'], - ['/* testAs */'], - ['/* testBreak */'], - ['/* testCallable */'], - ['/* testCase */'], - ['/* testCatch */'], - ['/* testClass */'], - ['/* testClone */'], - ['/* testConst */'], - ['/* testContinue */'], - ['/* testDeclare */'], - ['/* testDefault */'], - ['/* testDo */'], - ['/* testEcho */'], - ['/* testElse */'], - ['/* testElseIf */'], - ['/* testEmpty */'], - ['/* testEndDeclare */'], - ['/* testEndFor */'], - ['/* testEndForeach */'], - ['/* testEndIf */'], - ['/* testEndSwitch */'], - ['/* testEndWhile */'], - ['/* testEnum */'], - ['/* testEval */'], - ['/* testExit */'], - ['/* testExtends */'], - ['/* testFinal */'], - ['/* testFinally */'], - ['/* testFn */'], - ['/* testFor */'], - ['/* testForeach */'], - ['/* testFunction */'], - ['/* testGlobal */'], - ['/* testGoto */'], - ['/* testIf */'], - ['/* testImplements */'], - ['/* testInclude */'], - ['/* testIncludeOnce */'], - ['/* testInstanceOf */'], - ['/* testInsteadOf */'], - ['/* testInterface */'], - ['/* testIsset */'], - ['/* testList */'], - ['/* testMatch */'], - ['/* testNamespace */'], - ['/* testNew */'], - ['/* testParent */'], - ['/* testPrint */'], - ['/* testPrivate */'], - ['/* testProtected */'], - ['/* testPublic */'], - ['/* testReadonly */'], - ['/* testRequire */'], - ['/* testRequireOnce */'], - ['/* testReturn */'], - ['/* testSelf */'], - ['/* testStatic */'], - ['/* testSwitch */'], - ['/* testThrows */'], - ['/* testTrait */'], - ['/* testTry */'], - ['/* testUnset */'], - ['/* testUse */'], - ['/* testVar */'], - ['/* testWhile */'], - ['/* testYield */'], - ['/* testYieldFrom */'], - ['/* testAnd */'], - ['/* testOr */'], - ['/* testXor */'], - ['/* testFalse */'], - ['/* testTrue */'], - ['/* testNull */'], - - ['/* testKeywordAfterNamespaceShouldBeString */'], - ['/* testNamespaceNameIsString1 */'], - ['/* testNamespaceNameIsString2 */'], - ['/* testNamespaceNameIsString3 */'], - - ['/* testKeywordAfterFunctionShouldBeString */'], - ['/* testKeywordAfterFunctionByRefShouldBeString */'], - ['/* testKeywordSelfAfterFunctionByRefShouldBeString */'], - ['/* testKeywordStaticAfterFunctionByRefShouldBeString */'], - ['/* testKeywordParentAfterFunctionByRefShouldBeString */'], - ['/* testKeywordFalseAfterFunctionByRefShouldBeString */'], - ['/* testKeywordTrueAfterFunctionByRefShouldBeString */'], - ['/* testKeywordNullAfterFunctionByRefShouldBeString */'], - - ['/* testKeywordAsFunctionCallNameShouldBeStringSelf */'], - ['/* testKeywordAsFunctionCallNameShouldBeStringStatic */'], - ['/* testKeywordAsMethodCallNameShouldBeStringStatic */'], - ['/* testKeywordAsFunctionCallNameShouldBeStringParent */'], - ['/* testKeywordAsFunctionCallNameShouldBeStringFalse */'], - ['/* testKeywordAsFunctionCallNameShouldBeStringTrue */'], - ['/* testKeywordAsFunctionCallNameShouldBeStringNull */'], - - ['/* testClassInstantiationFalseIsString */'], - ['/* testClassInstantiationTrueIsString */'], - ['/* testClassInstantiationNullIsString */'], + 'constant declaration: abstract' => ['/* testAbstract */'], + 'constant declaration: array' => ['/* testArray */'], + 'constant declaration: as' => ['/* testAs */'], + 'constant declaration: break' => ['/* testBreak */'], + 'constant declaration: callable' => ['/* testCallable */'], + 'constant declaration: case' => ['/* testCase */'], + 'constant declaration: catch' => ['/* testCatch */'], + 'constant declaration: class' => ['/* testClass */'], + 'constant declaration: clone' => ['/* testClone */'], + 'constant declaration: const' => ['/* testConst */'], + 'constant declaration: continue' => ['/* testContinue */'], + 'constant declaration: declare' => ['/* testDeclare */'], + 'constant declaration: default' => ['/* testDefault */'], + 'constant declaration: do' => ['/* testDo */'], + 'constant declaration: echo' => ['/* testEcho */'], + 'constant declaration: else' => ['/* testElse */'], + 'constant declaration: elseif' => ['/* testElseIf */'], + 'constant declaration: empty' => ['/* testEmpty */'], + 'constant declaration: enddeclare' => ['/* testEndDeclare */'], + 'constant declaration: endfor' => ['/* testEndFor */'], + 'constant declaration: endforeach' => ['/* testEndForeach */'], + 'constant declaration: endif' => ['/* testEndIf */'], + 'constant declaration: endswitch' => ['/* testEndSwitch */'], + 'constant declaration: endwhile' => ['/* testEndWhile */'], + 'constant declaration: enum' => ['/* testEnum */'], + 'constant declaration: eval' => ['/* testEval */'], + 'constant declaration: exit' => ['/* testExit */'], + 'constant declaration: extends' => ['/* testExtends */'], + 'constant declaration: final' => ['/* testFinal */'], + 'constant declaration: finally' => ['/* testFinally */'], + 'constant declaration: fn' => ['/* testFn */'], + 'constant declaration: for' => ['/* testFor */'], + 'constant declaration: foreach' => ['/* testForeach */'], + 'constant declaration: function' => ['/* testFunction */'], + 'constant declaration: global' => ['/* testGlobal */'], + 'constant declaration: goto' => ['/* testGoto */'], + 'constant declaration: if' => ['/* testIf */'], + 'constant declaration: implements' => ['/* testImplements */'], + 'constant declaration: include' => ['/* testInclude */'], + 'constant declaration: include_once' => ['/* testIncludeOnce */'], + 'constant declaration: instanceof' => ['/* testInstanceOf */'], + 'constant declaration: insteadof' => ['/* testInsteadOf */'], + 'constant declaration: interface' => ['/* testInterface */'], + 'constant declaration: isset' => ['/* testIsset */'], + 'constant declaration: list' => ['/* testList */'], + 'constant declaration: match' => ['/* testMatch */'], + 'constant declaration: namespace' => ['/* testNamespace */'], + 'constant declaration: new' => ['/* testNew */'], + 'constant declaration: parent' => ['/* testParent */'], + 'constant declaration: print' => ['/* testPrint */'], + 'constant declaration: private' => ['/* testPrivate */'], + 'constant declaration: protected' => ['/* testProtected */'], + 'constant declaration: public' => ['/* testPublic */'], + 'constant declaration: readonly' => ['/* testReadonly */'], + 'constant declaration: require' => ['/* testRequire */'], + 'constant declaration: require_once' => ['/* testRequireOnce */'], + 'constant declaration: return' => ['/* testReturn */'], + 'constant declaration: self' => ['/* testSelf */'], + 'constant declaration: static' => ['/* testStatic */'], + 'constant declaration: switch' => ['/* testSwitch */'], + 'constant declaration: throws' => ['/* testThrows */'], + 'constant declaration: trait' => ['/* testTrait */'], + 'constant declaration: try' => ['/* testTry */'], + 'constant declaration: unset' => ['/* testUnset */'], + 'constant declaration: use' => ['/* testUse */'], + 'constant declaration: var' => ['/* testVar */'], + 'constant declaration: while' => ['/* testWhile */'], + 'constant declaration: yield' => ['/* testYield */'], + 'constant declaration: yield_from' => ['/* testYieldFrom */'], + 'constant declaration: and' => ['/* testAnd */'], + 'constant declaration: or' => ['/* testOr */'], + 'constant declaration: xor' => ['/* testXor */'], + 'constant declaration: false' => ['/* testFalse */'], + 'constant declaration: true' => ['/* testTrue */'], + 'constant declaration: null' => ['/* testNull */'], + + 'namespace declaration: class' => ['/* testKeywordAfterNamespaceShouldBeString */'], + 'namespace declaration (partial): my' => ['/* testNamespaceNameIsString1 */'], + 'namespace declaration (partial): class' => ['/* testNamespaceNameIsString2 */'], + 'namespace declaration (partial): foreach' => ['/* testNamespaceNameIsString3 */'], + + 'function declaration: eval' => ['/* testKeywordAfterFunctionShouldBeString */'], + 'function declaration with return by ref: switch' => ['/* testKeywordAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: self' => ['/* testKeywordSelfAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: static' => ['/* testKeywordStaticAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: parent' => ['/* testKeywordParentAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: false' => ['/* testKeywordFalseAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: true' => ['/* testKeywordTrueAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: null' => ['/* testKeywordNullAfterFunctionByRefShouldBeString */'], + + 'function call: self' => ['/* testKeywordAsFunctionCallNameShouldBeStringSelf */'], + 'function call: static' => ['/* testKeywordAsFunctionCallNameShouldBeStringStatic */'], + 'method call: static' => ['/* testKeywordAsMethodCallNameShouldBeStringStatic */'], + 'function call: parent' => ['/* testKeywordAsFunctionCallNameShouldBeStringParent */'], + 'function call: false' => ['/* testKeywordAsFunctionCallNameShouldBeStringFalse */'], + 'function call: true' => ['/* testKeywordAsFunctionCallNameShouldBeStringTrue */'], + 'function call: null; with comment between keyword and parentheses' => ['/* testKeywordAsFunctionCallNameShouldBeStringNull */'], + + 'class instantiation: false' => ['/* testClassInstantiationFalseIsString */'], + 'class instantiation: true' => ['/* testClassInstantiationTrueIsString */'], + 'class instantiation: null' => ['/* testClassInstantiationNullIsString */'], ]; }//end dataStrings() @@ -190,394 +190,394 @@ public function testKeywords($testMarker, $expectedTokenType) public static function dataKeywords() { return [ - [ - '/* testNamespaceIsKeyword */', - 'T_NAMESPACE', + 'namespace: declaration' => [ + 'testMarker' => '/* testNamespaceIsKeyword */', + 'expectedTokenType' => 'T_NAMESPACE', ], - [ - '/* testAbstractIsKeyword */', - 'T_ABSTRACT', + 'abstract: class declaration' => [ + 'testMarker' => '/* testAbstractIsKeyword */', + 'expectedTokenType' => 'T_ABSTRACT', ], - [ - '/* testClassIsKeyword */', - 'T_CLASS', + 'class: declaration' => [ + 'testMarker' => '/* testClassIsKeyword */', + 'expectedTokenType' => 'T_CLASS', ], - [ - '/* testExtendsIsKeyword */', - 'T_EXTENDS', + 'extends: in class declaration' => [ + 'testMarker' => '/* testExtendsIsKeyword */', + 'expectedTokenType' => 'T_EXTENDS', ], - [ - '/* testImplementsIsKeyword */', - 'T_IMPLEMENTS', + 'implements: in class declaration' => [ + 'testMarker' => '/* testImplementsIsKeyword */', + 'expectedTokenType' => 'T_IMPLEMENTS', ], - [ - '/* testUseIsKeyword */', - 'T_USE', + 'use: in trait import' => [ + 'testMarker' => '/* testUseIsKeyword */', + 'expectedTokenType' => 'T_USE', ], - [ - '/* testInsteadOfIsKeyword */', - 'T_INSTEADOF', + 'insteadof: in trait import' => [ + 'testMarker' => '/* testInsteadOfIsKeyword */', + 'expectedTokenType' => 'T_INSTEADOF', ], - [ - '/* testAsIsKeyword */', - 'T_AS', + 'as: in trait import' => [ + 'testMarker' => '/* testAsIsKeyword */', + 'expectedTokenType' => 'T_AS', ], - [ - '/* testConstIsKeyword */', - 'T_CONST', + 'const: declaration' => [ + 'testMarker' => '/* testConstIsKeyword */', + 'expectedTokenType' => 'T_CONST', ], - [ - '/* testPrivateIsKeyword */', - 'T_PRIVATE', + 'private: property declaration' => [ + 'testMarker' => '/* testPrivateIsKeyword */', + 'expectedTokenType' => 'T_PRIVATE', ], - [ - '/* testProtectedIsKeyword */', - 'T_PROTECTED', + 'protected: property declaration' => [ + 'testMarker' => '/* testProtectedIsKeyword */', + 'expectedTokenType' => 'T_PROTECTED', ], - [ - '/* testPublicIsKeyword */', - 'T_PUBLIC', + 'public: property declaration' => [ + 'testMarker' => '/* testPublicIsKeyword */', + 'expectedTokenType' => 'T_PUBLIC', ], - [ - '/* testVarIsKeyword */', - 'T_VAR', + 'var: property declaration' => [ + 'testMarker' => '/* testVarIsKeyword */', + 'expectedTokenType' => 'T_VAR', ], - [ - '/* testStaticIsKeyword */', - 'T_STATIC', + 'static: property declaration' => [ + 'testMarker' => '/* testStaticIsKeyword */', + 'expectedTokenType' => 'T_STATIC', ], - [ - '/* testReadonlyIsKeyword */', - 'T_READONLY', + 'readonly: property declaration' => [ + 'testMarker' => '/* testReadonlyIsKeyword */', + 'expectedTokenType' => 'T_READONLY', ], - [ - '/* testFinalIsKeyword */', - 'T_FINAL', + 'final: function declaration' => [ + 'testMarker' => '/* testFinalIsKeyword */', + 'expectedTokenType' => 'T_FINAL', ], - [ - '/* testFunctionIsKeyword */', - 'T_FUNCTION', + 'function: declaration' => [ + 'testMarker' => '/* testFunctionIsKeyword */', + 'expectedTokenType' => 'T_FUNCTION', ], - [ - '/* testCallableIsKeyword */', - 'T_CALLABLE', + 'callable: param type declaration' => [ + 'testMarker' => '/* testCallableIsKeyword */', + 'expectedTokenType' => 'T_CALLABLE', ], - [ - '/* testSelfIsKeyword */', - 'T_SELF', + 'self: param type declaration' => [ + 'testMarker' => '/* testSelfIsKeyword */', + 'expectedTokenType' => 'T_SELF', ], - [ - '/* testParentIsKeyword */', - 'T_PARENT', + 'parent: param type declaration' => [ + 'testMarker' => '/* testParentIsKeyword */', + 'expectedTokenType' => 'T_PARENT', ], - [ - '/* testReturnIsKeyword */', - 'T_RETURN', + 'return: statement' => [ + 'testMarker' => '/* testReturnIsKeyword */', + 'expectedTokenType' => 'T_RETURN', ], - [ - '/* testInterfaceIsKeyword */', - 'T_INTERFACE', + 'interface: declaration' => [ + 'testMarker' => '/* testInterfaceIsKeyword */', + 'expectedTokenType' => 'T_INTERFACE', ], - [ - '/* testTraitIsKeyword */', - 'T_TRAIT', + 'trait: declaration' => [ + 'testMarker' => '/* testTraitIsKeyword */', + 'expectedTokenType' => 'T_TRAIT', ], - [ - '/* testEnumIsKeyword */', - 'T_ENUM', + 'enum: declaration' => [ + 'testMarker' => '/* testEnumIsKeyword */', + 'expectedTokenType' => 'T_ENUM', ], - [ - '/* testNewIsKeyword */', - 'T_NEW', + 'new: named instantiation' => [ + 'testMarker' => '/* testNewIsKeyword */', + 'expectedTokenType' => 'T_NEW', ], - [ - '/* testInstanceOfIsKeyword */', - 'T_INSTANCEOF', + 'instanceof: comparison' => [ + 'testMarker' => '/* testInstanceOfIsKeyword */', + 'expectedTokenType' => 'T_INSTANCEOF', ], - [ - '/* testCloneIsKeyword */', - 'T_CLONE', + 'clone' => [ + 'testMarker' => '/* testCloneIsKeyword */', + 'expectedTokenType' => 'T_CLONE', ], - [ - '/* testIfIsKeyword */', - 'T_IF', + 'if' => [ + 'testMarker' => '/* testIfIsKeyword */', + 'expectedTokenType' => 'T_IF', ], - [ - '/* testEmptyIsKeyword */', - 'T_EMPTY', + 'empty' => [ + 'testMarker' => '/* testEmptyIsKeyword */', + 'expectedTokenType' => 'T_EMPTY', ], - [ - '/* testElseIfIsKeyword */', - 'T_ELSEIF', + 'elseif' => [ + 'testMarker' => '/* testElseIfIsKeyword */', + 'expectedTokenType' => 'T_ELSEIF', ], - [ - '/* testElseIsKeyword */', - 'T_ELSE', + 'else' => [ + 'testMarker' => '/* testElseIsKeyword */', + 'expectedTokenType' => 'T_ELSE', ], - [ - '/* testEndIfIsKeyword */', - 'T_ENDIF', + 'endif' => [ + 'testMarker' => '/* testEndIfIsKeyword */', + 'expectedTokenType' => 'T_ENDIF', ], - [ - '/* testForIsKeyword */', - 'T_FOR', + 'for' => [ + 'testMarker' => '/* testForIsKeyword */', + 'expectedTokenType' => 'T_FOR', ], - [ - '/* testEndForIsKeyword */', - 'T_ENDFOR', + 'endfor' => [ + 'testMarker' => '/* testEndForIsKeyword */', + 'expectedTokenType' => 'T_ENDFOR', ], - [ - '/* testForeachIsKeyword */', - 'T_FOREACH', + 'foreach' => [ + 'testMarker' => '/* testForeachIsKeyword */', + 'expectedTokenType' => 'T_FOREACH', ], - [ - '/* testEndForeachIsKeyword */', - 'T_ENDFOREACH', + 'endforeach' => [ + 'testMarker' => '/* testEndForeachIsKeyword */', + 'expectedTokenType' => 'T_ENDFOREACH', ], - [ - '/* testSwitchIsKeyword */', - 'T_SWITCH', + 'switch' => [ + 'testMarker' => '/* testSwitchIsKeyword */', + 'expectedTokenType' => 'T_SWITCH', ], - [ - '/* testCaseIsKeyword */', - 'T_CASE', + 'case: in switch' => [ + 'testMarker' => '/* testCaseIsKeyword */', + 'expectedTokenType' => 'T_CASE', ], - [ - '/* testDefaultIsKeyword */', - 'T_DEFAULT', + 'default: in switch' => [ + 'testMarker' => '/* testDefaultIsKeyword */', + 'expectedTokenType' => 'T_DEFAULT', ], - [ - '/* testEndSwitchIsKeyword */', - 'T_ENDSWITCH', + 'endswitch' => [ + 'testMarker' => '/* testEndSwitchIsKeyword */', + 'expectedTokenType' => 'T_ENDSWITCH', ], - [ - '/* testBreakIsKeyword */', - 'T_BREAK', + 'break: in switch' => [ + 'testMarker' => '/* testBreakIsKeyword */', + 'expectedTokenType' => 'T_BREAK', ], - [ - '/* testContinueIsKeyword */', - 'T_CONTINUE', + 'continue: in switch' => [ + 'testMarker' => '/* testContinueIsKeyword */', + 'expectedTokenType' => 'T_CONTINUE', ], - [ - '/* testDoIsKeyword */', - 'T_DO', + 'do' => [ + 'testMarker' => '/* testDoIsKeyword */', + 'expectedTokenType' => 'T_DO', ], - [ - '/* testWhileIsKeyword */', - 'T_WHILE', + 'while' => [ + 'testMarker' => '/* testWhileIsKeyword */', + 'expectedTokenType' => 'T_WHILE', ], - [ - '/* testEndWhileIsKeyword */', - 'T_ENDWHILE', + 'endwhile' => [ + 'testMarker' => '/* testEndWhileIsKeyword */', + 'expectedTokenType' => 'T_ENDWHILE', ], - [ - '/* testTryIsKeyword */', - 'T_TRY', + 'try' => [ + 'testMarker' => '/* testTryIsKeyword */', + 'expectedTokenType' => 'T_TRY', ], - [ - '/* testThrowIsKeyword */', - 'T_THROW', + 'throw: statement' => [ + 'testMarker' => '/* testThrowIsKeyword */', + 'expectedTokenType' => 'T_THROW', ], - [ - '/* testCatchIsKeyword */', - 'T_CATCH', + 'catch' => [ + 'testMarker' => '/* testCatchIsKeyword */', + 'expectedTokenType' => 'T_CATCH', ], - [ - '/* testFinallyIsKeyword */', - 'T_FINALLY', + 'finally' => [ + 'testMarker' => '/* testFinallyIsKeyword */', + 'expectedTokenType' => 'T_FINALLY', ], - [ - '/* testGlobalIsKeyword */', - 'T_GLOBAL', + 'global' => [ + 'testMarker' => '/* testGlobalIsKeyword */', + 'expectedTokenType' => 'T_GLOBAL', ], - [ - '/* testEchoIsKeyword */', - 'T_ECHO', + 'echo' => [ + 'testMarker' => '/* testEchoIsKeyword */', + 'expectedTokenType' => 'T_ECHO', ], - [ - '/* testPrintIsKeyword */', - 'T_PRINT', + 'print: statement' => [ + 'testMarker' => '/* testPrintIsKeyword */', + 'expectedTokenType' => 'T_PRINT', ], - [ - '/* testDieIsKeyword */', - 'T_EXIT', + 'die: statement' => [ + 'testMarker' => '/* testDieIsKeyword */', + 'expectedTokenType' => 'T_EXIT', ], - [ - '/* testEvalIsKeyword */', - 'T_EVAL', + 'eval' => [ + 'testMarker' => '/* testEvalIsKeyword */', + 'expectedTokenType' => 'T_EVAL', ], - [ - '/* testExitIsKeyword */', - 'T_EXIT', + 'exit: statement' => [ + 'testMarker' => '/* testExitIsKeyword */', + 'expectedTokenType' => 'T_EXIT', ], - [ - '/* testIssetIsKeyword */', - 'T_ISSET', + 'isset' => [ + 'testMarker' => '/* testIssetIsKeyword */', + 'expectedTokenType' => 'T_ISSET', ], - [ - '/* testUnsetIsKeyword */', - 'T_UNSET', + 'unset' => [ + 'testMarker' => '/* testUnsetIsKeyword */', + 'expectedTokenType' => 'T_UNSET', ], - [ - '/* testIncludeIsKeyword */', - 'T_INCLUDE', + 'include' => [ + 'testMarker' => '/* testIncludeIsKeyword */', + 'expectedTokenType' => 'T_INCLUDE', ], - [ - '/* testIncludeOnceIsKeyword */', - 'T_INCLUDE_ONCE', + 'include_once' => [ + 'testMarker' => '/* testIncludeOnceIsKeyword */', + 'expectedTokenType' => 'T_INCLUDE_ONCE', ], - [ - '/* testRequireIsKeyword */', - 'T_REQUIRE', + 'require' => [ + 'testMarker' => '/* testRequireIsKeyword */', + 'expectedTokenType' => 'T_REQUIRE', ], - [ - '/* testRequireOnceIsKeyword */', - 'T_REQUIRE_ONCE', + 'require_once' => [ + 'testMarker' => '/* testRequireOnceIsKeyword */', + 'expectedTokenType' => 'T_REQUIRE_ONCE', ], - [ - '/* testListIsKeyword */', - 'T_LIST', + 'list' => [ + 'testMarker' => '/* testListIsKeyword */', + 'expectedTokenType' => 'T_LIST', ], - [ - '/* testGotoIsKeyword */', - 'T_GOTO', + 'goto' => [ + 'testMarker' => '/* testGotoIsKeyword */', + 'expectedTokenType' => 'T_GOTO', ], - [ - '/* testMatchIsKeyword */', - 'T_MATCH', + 'match' => [ + 'testMarker' => '/* testMatchIsKeyword */', + 'expectedTokenType' => 'T_MATCH', ], - [ - '/* testMatchDefaultIsKeyword */', - 'T_MATCH_DEFAULT', + 'default: in match expression' => [ + 'testMarker' => '/* testMatchDefaultIsKeyword */', + 'expectedTokenType' => 'T_MATCH_DEFAULT', ], - [ - '/* testFnIsKeyword */', - 'T_FN', + 'fn' => [ + 'testMarker' => '/* testFnIsKeyword */', + 'expectedTokenType' => 'T_FN', ], - [ - '/* testYieldIsKeyword */', - 'T_YIELD', + 'yield' => [ + 'testMarker' => '/* testYieldIsKeyword */', + 'expectedTokenType' => 'T_YIELD', ], - [ - '/* testYieldFromIsKeyword */', - 'T_YIELD_FROM', + 'yield from' => [ + 'testMarker' => '/* testYieldFromIsKeyword */', + 'expectedTokenType' => 'T_YIELD_FROM', ], - [ - '/* testDeclareIsKeyword */', - 'T_DECLARE', + 'declare' => [ + 'testMarker' => '/* testDeclareIsKeyword */', + 'expectedTokenType' => 'T_DECLARE', ], - [ - '/* testEndDeclareIsKeyword */', - 'T_ENDDECLARE', + 'enddeclare' => [ + 'testMarker' => '/* testEndDeclareIsKeyword */', + 'expectedTokenType' => 'T_ENDDECLARE', ], - [ - '/* testAndIsKeyword */', - 'T_LOGICAL_AND', + 'and: in if' => [ + 'testMarker' => '/* testAndIsKeyword */', + 'expectedTokenType' => 'T_LOGICAL_AND', ], - [ - '/* testOrIsKeyword */', - 'T_LOGICAL_OR', + 'or: in if' => [ + 'testMarker' => '/* testOrIsKeyword */', + 'expectedTokenType' => 'T_LOGICAL_OR', ], - [ - '/* testXorIsKeyword */', - 'T_LOGICAL_XOR', + 'xor: in if' => [ + 'testMarker' => '/* testXorIsKeyword */', + 'expectedTokenType' => 'T_LOGICAL_XOR', ], - [ - '/* testAnonymousClassIsKeyword */', - 'T_ANON_CLASS', + 'class: anon class declaration' => [ + 'testMarker' => '/* testAnonymousClassIsKeyword */', + 'expectedTokenType' => 'T_ANON_CLASS', ], - [ - '/* testExtendsInAnonymousClassIsKeyword */', - 'T_EXTENDS', + 'extends: anon class declaration' => [ + 'testMarker' => '/* testExtendsInAnonymousClassIsKeyword */', + 'expectedTokenType' => 'T_EXTENDS', ], - [ - '/* testImplementsInAnonymousClassIsKeyword */', - 'T_IMPLEMENTS', + 'implements: anon class declaration' => [ + 'testMarker' => '/* testImplementsInAnonymousClassIsKeyword */', + 'expectedTokenType' => 'T_IMPLEMENTS', ], - [ - '/* testClassInstantiationParentIsKeyword */', - 'T_PARENT', + 'parent: class instantiation' => [ + 'testMarker' => '/* testClassInstantiationParentIsKeyword */', + 'expectedTokenType' => 'T_PARENT', ], - [ - '/* testClassInstantiationSelfIsKeyword */', - 'T_SELF', + 'self: class instantiation' => [ + 'testMarker' => '/* testClassInstantiationSelfIsKeyword */', + 'expectedTokenType' => 'T_SELF', ], - [ - '/* testClassInstantiationStaticIsKeyword */', - 'T_STATIC', + 'static: class instantiation' => [ + 'testMarker' => '/* testClassInstantiationStaticIsKeyword */', + 'expectedTokenType' => 'T_STATIC', ], - [ - '/* testNamespaceInNameIsKeyword */', - 'T_NAMESPACE', + 'namespace: operator' => [ + 'testMarker' => '/* testNamespaceInNameIsKeyword */', + 'expectedTokenType' => 'T_NAMESPACE', ], - [ - '/* testStaticIsKeywordBeforeClosure */', - 'T_STATIC', + 'static: closure declaration' => [ + 'testMarker' => '/* testStaticIsKeywordBeforeClosure */', + 'expectedTokenType' => 'T_STATIC', ], - [ - '/* testStaticIsKeywordWhenParamType */', - 'T_STATIC', + 'static: parameter type (illegal)' => [ + 'testMarker' => '/* testStaticIsKeywordWhenParamType */', + 'expectedTokenType' => 'T_STATIC', ], - [ - '/* testStaticIsKeywordBeforeArrow */', - 'T_STATIC', + 'static: arrow function declaration' => [ + 'testMarker' => '/* testStaticIsKeywordBeforeArrow */', + 'expectedTokenType' => 'T_STATIC', ], - [ - '/* testStaticIsKeywordWhenReturnType */', - 'T_STATIC', + 'static: return type for arrow function' => [ + 'testMarker' => '/* testStaticIsKeywordWhenReturnType */', + 'expectedTokenType' => 'T_STATIC', ], - [ - '/* testFalseIsKeywordAsParamType */', - 'T_FALSE', + 'false: param type declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsParamType */', + 'expectedTokenType' => 'T_FALSE', ], - [ - '/* testTrueIsKeywordAsParamType */', - 'T_TRUE', + 'true: param type declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsParamType */', + 'expectedTokenType' => 'T_TRUE', ], - [ - '/* testNullIsKeywordAsParamType */', - 'T_NULL', + 'null: param type declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsParamType */', + 'expectedTokenType' => 'T_NULL', ], - [ - '/* testFalseIsKeywordAsReturnType */', - 'T_FALSE', + 'false: return type declaration in union' => [ + 'testMarker' => '/* testFalseIsKeywordAsReturnType */', + 'expectedTokenType' => 'T_FALSE', ], - [ - '/* testTrueIsKeywordAsReturnType */', - 'T_TRUE', + 'true: return type declaration in union' => [ + 'testMarker' => '/* testTrueIsKeywordAsReturnType */', + 'expectedTokenType' => 'T_TRUE', ], - [ - '/* testNullIsKeywordAsReturnType */', - 'T_NULL', + 'null: return type declaration in union' => [ + 'testMarker' => '/* testNullIsKeywordAsReturnType */', + 'expectedTokenType' => 'T_NULL', ], - [ - '/* testFalseIsKeywordInComparison */', - 'T_FALSE', + 'false: in comparison' => [ + 'testMarker' => '/* testFalseIsKeywordInComparison */', + 'expectedTokenType' => 'T_FALSE', ], - [ - '/* testTrueIsKeywordInComparison */', - 'T_TRUE', + 'true: in comparison' => [ + 'testMarker' => '/* testTrueIsKeywordInComparison */', + 'expectedTokenType' => 'T_TRUE', ], - [ - '/* testNullIsKeywordInComparison */', - 'T_NULL', + 'null: in comparison' => [ + 'testMarker' => '/* testNullIsKeywordInComparison */', + 'expectedTokenType' => 'T_NULL', ], ]; From c7218d510ce77df7f453edbe9cbbbd6541cc603c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 08:55:01 +0100 Subject: [PATCH 299/874] Tests/DefaultKeywordTest: use named data within data sets This commit adds the parameter name for each item in the data set in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes array normalization. Includes making the data type in the docblocks more specific. --- tests/Core/Tokenizer/DefaultKeywordTest.php | 160 +++++++++++++------- 1 file changed, 102 insertions(+), 58 deletions(-) diff --git a/tests/Core/Tokenizer/DefaultKeywordTest.php b/tests/Core/Tokenizer/DefaultKeywordTest.php index b281fdd425..efbce192f8 100644 --- a/tests/Core/Tokenizer/DefaultKeywordTest.php +++ b/tests/Core/Tokenizer/DefaultKeywordTest.php @@ -53,40 +53,50 @@ public function testMatchDefault($testMarker, $testContent='default') * * @see testMatchDefault() * - * @return array + * @return array> */ public static function dataMatchDefault() { return [ - 'simple_match_default' => ['/* testSimpleMatchDefault */'], - 'match_default_in_switch_case_1' => ['/* testMatchDefaultNestedInSwitchCase1 */'], - 'match_default_in_switch_case_2' => ['/* testMatchDefaultNestedInSwitchCase2 */'], - 'match_default_in_switch_default' => ['/* testMatchDefaultNestedInSwitchDefault */'], - 'match_default_containing_switch' => ['/* testMatchDefault */'], + 'simple_match_default' => [ + 'testMarker' => '/* testSimpleMatchDefault */', + ], + 'match_default_in_switch_case_1' => [ + 'testMarker' => '/* testMatchDefaultNestedInSwitchCase1 */', + ], + 'match_default_in_switch_case_2' => [ + 'testMarker' => '/* testMatchDefaultNestedInSwitchCase2 */', + ], + 'match_default_in_switch_default' => [ + 'testMarker' => '/* testMatchDefaultNestedInSwitchDefault */', + ], + 'match_default_containing_switch' => [ + 'testMarker' => '/* testMatchDefault */', + ], 'match_default_with_nested_long_array_and_default_key' => [ - '/* testMatchDefaultWithNestedLongArrayWithClassConstantKey */', - 'DEFAULT', + 'testMarker' => '/* testMatchDefaultWithNestedLongArrayWithClassConstantKey */', + 'testContent' => 'DEFAULT', ], 'match_default_with_nested_long_array_and_default_key_2' => [ - '/* testMatchDefaultWithNestedLongArrayWithClassConstantKeyLevelDown */', - 'DEFAULT', + 'testMarker' => '/* testMatchDefaultWithNestedLongArrayWithClassConstantKeyLevelDown */', + 'testContent' => 'DEFAULT', ], 'match_default_with_nested_short_array_and_default_key' => [ - '/* testMatchDefaultWithNestedShortArrayWithClassConstantKey */', - 'DEFAULT', + 'testMarker' => '/* testMatchDefaultWithNestedShortArrayWithClassConstantKey */', + 'testContent' => 'DEFAULT', ], 'match_default_with_nested_short_array_and_default_key_2' => [ - '/* testMatchDefaultWithNestedShortArrayWithClassConstantKeyLevelDown */', - 'DEFAULT', + 'testMarker' => '/* testMatchDefaultWithNestedShortArrayWithClassConstantKeyLevelDown */', + 'testContent' => 'DEFAULT', ], 'match_default_in_long_array' => [ - '/* testMatchDefaultNestedInLongArray */', - 'DEFAULT', + 'testMarker' => '/* testMatchDefaultNestedInLongArray */', + 'testContent' => 'DEFAULT', ], 'match_default_in_short_array' => [ - '/* testMatchDefaultNestedInShortArray */', - 'DEFAULT', + 'testMarker' => '/* testMatchDefaultNestedInShortArray */', + 'testContent' => 'DEFAULT', ], ]; @@ -169,40 +179,40 @@ public function testSwitchDefault($testMarker, $openerOffset, $closerOffset, $co * * @see testSwitchDefault() * - * @return array + * @return array> */ public static function dataSwitchDefault() { return [ 'simple_switch_default' => [ - '/* testSimpleSwitchDefault */', - 1, - 4, + 'testMarker' => '/* testSimpleSwitchDefault */', + 'openerOffset' => 1, + 'closerOffset' => 4, ], 'simple_switch_default_with_curlies' => [ // For a default structure with curly braces, the scope opener // will be the open curly and the closer the close curly. // However, scope conditions will not be set for open to close, // but only for the open token up to the "break/return/continue" etc. - '/* testSimpleSwitchDefaultWithCurlies */', - 3, - 12, - 6, + 'testMarker' => '/* testSimpleSwitchDefaultWithCurlies */', + 'openerOffset' => 3, + 'closerOffset' => 12, + 'conditionStop' => 6, ], 'switch_default_toplevel' => [ - '/* testSwitchDefault */', - 1, - 43, + 'testMarker' => '/* testSwitchDefault */', + 'openerOffset' => 1, + 'closerOffset' => 43, ], 'switch_default_nested_in_match_case' => [ - '/* testSwitchDefaultNestedInMatchCase */', - 1, - 20, + 'testMarker' => '/* testSwitchDefaultNestedInMatchCase */', + 'openerOffset' => 1, + 'closerOffset' => 20, ], 'switch_default_nested_in_match_default' => [ - '/* testSwitchDefaultNestedInMatchDefault */', - 1, - 18, + 'testMarker' => '/* testSwitchDefaultNestedInMatchDefault */', + 'openerOffset' => 1, + 'closerOffset' => 18, ], ]; @@ -244,34 +254,68 @@ public function testNotDefaultKeyword($testMarker, $testContent='DEFAULT') * * @see testNotDefaultKeyword() * - * @return array + * @return array> */ public static function dataNotDefaultKeyword() { return [ - 'class-constant-as-short-array-key' => ['/* testClassConstantAsShortArrayKey */'], - 'class-property-as-short-array-key' => ['/* testClassPropertyAsShortArrayKey */'], - 'namespaced-constant-as-short-array-key' => ['/* testNamespacedConstantAsShortArrayKey */'], - 'fqn-global-constant-as-short-array-key' => ['/* testFQNGlobalConstantAsShortArrayKey */'], - 'class-constant-as-long-array-key' => ['/* testClassConstantAsLongArrayKey */'], - 'class-constant-as-yield-key' => ['/* testClassConstantAsYieldKey */'], - - 'class-constant-as-long-array-key-nested-in-match' => ['/* testClassConstantAsLongArrayKeyNestedInMatch */'], - 'class-constant-as-long-array-key-nested-in-match-2' => ['/* testClassConstantAsLongArrayKeyNestedInMatchLevelDown */'], - 'class-constant-as-short-array-key-nested-in-match' => ['/* testClassConstantAsShortArrayKeyNestedInMatch */'], - 'class-constant-as-short-array-key-nested-in-match-2' => ['/* testClassConstantAsShortArrayKeyNestedInMatchLevelDown */'], - 'class-constant-as-long-array-key-with-nested-match' => ['/* testClassConstantAsLongArrayKeyWithNestedMatch */'], - 'class-constant-as-short-array-key-with-nested-match' => ['/* testClassConstantAsShortArrayKeyWithNestedMatch */'], - - 'class-constant-in-switch-case' => ['/* testClassConstantInSwitchCase */'], - 'class-property-in-switch-case' => ['/* testClassPropertyInSwitchCase */'], - 'namespaced-constant-in-switch-case' => ['/* testNamespacedConstantInSwitchCase */'], - 'namespace-relative-constant-in-switch-case' => ['/* testNamespaceRelativeConstantInSwitchCase */'], - - 'class-constant-declaration' => ['/* testClassConstant */'], + 'class-constant-as-short-array-key' => [ + 'testMarker' => '/* testClassConstantAsShortArrayKey */', + ], + 'class-property-as-short-array-key' => [ + 'testMarker' => '/* testClassPropertyAsShortArrayKey */', + ], + 'namespaced-constant-as-short-array-key' => [ + 'testMarker' => '/* testNamespacedConstantAsShortArrayKey */', + ], + 'fqn-global-constant-as-short-array-key' => [ + 'testMarker' => '/* testFQNGlobalConstantAsShortArrayKey */', + ], + 'class-constant-as-long-array-key' => [ + 'testMarker' => '/* testClassConstantAsLongArrayKey */', + ], + 'class-constant-as-yield-key' => [ + 'testMarker' => '/* testClassConstantAsYieldKey */', + ], + + 'class-constant-as-long-array-key-nested-in-match' => [ + 'testMarker' => '/* testClassConstantAsLongArrayKeyNestedInMatch */', + ], + 'class-constant-as-long-array-key-nested-in-match-2' => [ + 'testMarker' => '/* testClassConstantAsLongArrayKeyNestedInMatchLevelDown */', + ], + 'class-constant-as-short-array-key-nested-in-match' => [ + 'testMarker' => '/* testClassConstantAsShortArrayKeyNestedInMatch */', + ], + 'class-constant-as-short-array-key-nested-in-match-2' => [ + 'testMarker' => '/* testClassConstantAsShortArrayKeyNestedInMatchLevelDown */', + ], + 'class-constant-as-long-array-key-with-nested-match' => [ + 'testMarker' => '/* testClassConstantAsLongArrayKeyWithNestedMatch */', + ], + 'class-constant-as-short-array-key-with-nested-match' => [ + 'testMarker' => '/* testClassConstantAsShortArrayKeyWithNestedMatch */', + ], + + 'class-constant-in-switch-case' => [ + 'testMarker' => '/* testClassConstantInSwitchCase */', + ], + 'class-property-in-switch-case' => [ + 'testMarker' => '/* testClassPropertyInSwitchCase */', + ], + 'namespaced-constant-in-switch-case' => [ + 'testMarker' => '/* testNamespacedConstantInSwitchCase */', + ], + 'namespace-relative-constant-in-switch-case' => [ + 'testMarker' => '/* testNamespaceRelativeConstantInSwitchCase */', + ], + + 'class-constant-declaration' => [ + 'testMarker' => '/* testClassConstant */', + ], 'class-method-declaration' => [ - '/* testMethodDeclaration */', - 'default', + 'testMarker' => '/* testMethodDeclaration */', + 'testContent' => 'default', ], ]; From 075ab2c4ca045fada620a25c4278fff23e29e88f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 11:31:50 +0100 Subject: [PATCH 300/874] Tests/DoubleQuotedStringTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblock more specific. --- .../Core/Tokenizer/DoubleQuotedStringTest.php | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/tests/Core/Tokenizer/DoubleQuotedStringTest.php b/tests/Core/Tokenizer/DoubleQuotedStringTest.php index c5c86972a8..6d9526e008 100644 --- a/tests/Core/Tokenizer/DoubleQuotedStringTest.php +++ b/tests/Core/Tokenizer/DoubleQuotedStringTest.php @@ -40,90 +40,98 @@ public function testDoubleQuotedString($testMarker, $expectedContent) /** * Data provider. * + * Type reference: + * 1. Directly embedded variables. + * 2. Braces outside the variable. + * 3. Braces after the dollar sign. + * 4. Variable variables and expressions. + * + * @link https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation + * * @see testDoubleQuotedString() * - * @return array + * @return array> */ public static function dataDoubleQuotedString() { return [ - [ + 'Type 1: simple variable' => [ 'testMarker' => '/* testSimple1 */', 'expectedContent' => '"$foo"', ], - [ + 'Type 2: simple variable' => [ 'testMarker' => '/* testSimple2 */', 'expectedContent' => '"{$foo}"', ], - [ + 'Type 3: simple variable' => [ 'testMarker' => '/* testSimple3 */', 'expectedContent' => '"${foo}"', ], - [ + 'Type 1: array offset' => [ 'testMarker' => '/* testDIM1 */', 'expectedContent' => '"$foo[bar]"', ], - [ + 'Type 2: array offset' => [ 'testMarker' => '/* testDIM2 */', 'expectedContent' => '"{$foo[\'bar\']}"', ], - [ + 'Type 3: array offset' => [ 'testMarker' => '/* testDIM3 */', 'expectedContent' => '"${foo[\'bar\']}"', ], - [ + 'Type 1: object property' => [ 'testMarker' => '/* testProperty1 */', 'expectedContent' => '"$foo->bar"', ], - [ + 'Type 2: object property' => [ 'testMarker' => '/* testProperty2 */', 'expectedContent' => '"{$foo->bar}"', ], - [ + 'Type 2: object method call' => [ 'testMarker' => '/* testMethod1 */', 'expectedContent' => '"{$foo->bar()}"', ], - [ + 'Type 2: closure function call' => [ 'testMarker' => '/* testClosure1 */', 'expectedContent' => '"{$foo()}"', ], - [ + 'Type 2: chaining various syntaxes' => [ 'testMarker' => '/* testChain1 */', 'expectedContent' => '"{$foo[\'bar\']->baz()()}"', ], - [ + 'Type 4: variable variables' => [ 'testMarker' => '/* testVariableVar1 */', 'expectedContent' => '"${$bar}"', ], - [ + 'Type 4: variable constants' => [ 'testMarker' => '/* testVariableVar2 */', 'expectedContent' => '"${(foo)}"', ], - [ + 'Type 4: object property' => [ 'testMarker' => '/* testVariableVar3 */', 'expectedContent' => '"${foo->bar}"', ], - [ + 'Type 4: variable variable nested in array offset' => [ 'testMarker' => '/* testNested1 */', 'expectedContent' => '"${foo["${bar}"]}"', ], - [ + 'Type 4: variable array offset nested in array offset' => [ 'testMarker' => '/* testNested2 */', 'expectedContent' => '"${foo["${bar[\'baz\']}"]}"', ], - [ + 'Type 4: variable object property' => [ 'testMarker' => '/* testNested3 */', 'expectedContent' => '"${foo->{$baz}}"', ], - [ + 'Type 4: variable object property - complex with single quotes' => [ 'testMarker' => '/* testNested4 */', 'expectedContent' => '"${foo->{${\'a\'}}}"', ], - [ + 'Type 4: variable object property - complex with single and double quotes' => [ 'testMarker' => '/* testNested5 */', 'expectedContent' => '"${foo->{"${\'a\'}"}}"', ], - [ + 'Type 4: live coding/parse error' => [ 'testMarker' => '/* testParseError */', 'expectedContent' => '"${foo["${bar ', From 0e094e7a506707616db0123075d516192cc6e5af Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Dec 2023 00:39:45 +0100 Subject: [PATCH 301/874] Tests/FinallyTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblock more specific. --- tests/Core/Tokenizer/FinallyTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Core/Tokenizer/FinallyTest.php b/tests/Core/Tokenizer/FinallyTest.php index 571bf0ae75..428fb356ff 100644 --- a/tests/Core/Tokenizer/FinallyTest.php +++ b/tests/Core/Tokenizer/FinallyTest.php @@ -41,14 +41,14 @@ public function testFinallyKeyword($testMarker) * * @see testFinallyKeyword() * - * @return array + * @return array> */ public static function dataFinallyKeyword() { return [ - ['/* testTryCatchFinally */'], - ['/* testTryFinallyCatch */'], - ['/* testTryFinally */'], + 'finally after try and catch' => ['/* testTryCatchFinally */'], + 'finally between try and catch' => ['/* testTryFinallyCatch */'], + 'finally after try, no catch' => ['/* testTryFinally */'], ]; }//end dataFinallyKeyword() @@ -80,14 +80,14 @@ public function testFinallyNonKeyword($testMarker) * * @see testFinallyNonKeyword() * - * @return array + * @return array> */ public static function dataFinallyNonKeyword() { return [ - ['/* testFinallyUsedAsClassConstantName */'], - ['/* testFinallyUsedAsMethodName */'], - ['/* testFinallyUsedAsPropertyName */'], + 'finally used as class constant name' => ['/* testFinallyUsedAsClassConstantName */'], + 'finally used as method name' => ['/* testFinallyUsedAsMethodName */'], + 'finally used as property name' => ['/* testFinallyUsedAsPropertyName */'], ]; }//end dataFinallyNonKeyword() From 6e895dd33f60dc57f604d70a56bd3045845a2849 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Dec 2023 00:50:10 +0100 Subject: [PATCH 302/874] Tests/GotoLabelTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes making the data type in the docblock more specific. --- tests/Core/Tokenizer/GotoLabelTest.php | 72 +++++++++++++------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/Core/Tokenizer/GotoLabelTest.php b/tests/Core/Tokenizer/GotoLabelTest.php index cf52a77758..62a0a697ed 100644 --- a/tests/Core/Tokenizer/GotoLabelTest.php +++ b/tests/Core/Tokenizer/GotoLabelTest.php @@ -43,18 +43,18 @@ public function testGotoStatement($testMarker, $testContent) * * @see testGotoStatement() * - * @return array + * @return array> */ public static function dataGotoStatement() { return [ - [ - '/* testGotoStatement */', - 'marker', + 'label for goto statement' => [ + 'testMarker' => '/* testGotoStatement */', + 'testContent' => 'marker', ], - [ - '/* testGotoStatementInLoop */', - 'end', + 'label for goto statement in loop, keyword capitalized' => [ + 'testMarker' => '/* testGotoStatementInLoop */', + 'testContent' => 'end', ], ]; @@ -89,18 +89,18 @@ public function testGotoDeclaration($testMarker, $testContent) * * @see testGotoDeclaration() * - * @return array + * @return array> */ public static function dataGotoDeclaration() { return [ - [ - '/* testGotoDeclaration */', - 'marker:', + 'label in goto declaration - marker' => [ + 'testMarker' => '/* testGotoDeclaration */', + 'testContent' => 'marker:', ], - [ - '/* testGotoDeclarationOutsideLoop */', - 'end:', + 'label in goto declaration - end' => [ + 'testMarker' => '/* testGotoDeclarationOutsideLoop */', + 'testContent' => 'end:', ], ]; @@ -134,38 +134,38 @@ public function testNotAGotoDeclaration($testMarker, $testContent) * * @see testNotAGotoDeclaration() * - * @return array + * @return array> */ public static function dataNotAGotoDeclaration() { return [ - [ - '/* testNotGotoDeclarationGlobalConstant */', - 'CONSTANT', + 'not goto label - global constant followed by switch-case colon' => [ + 'testMarker' => '/* testNotGotoDeclarationGlobalConstant */', + 'testContent' => 'CONSTANT', ], - [ - '/* testNotGotoDeclarationNamespacedConstant */', - 'CONSTANT', + 'not goto label - namespaced constant followed by switch-case colon' => [ + 'testMarker' => '/* testNotGotoDeclarationNamespacedConstant */', + 'testContent' => 'CONSTANT', ], - [ - '/* testNotGotoDeclarationClassConstant */', - 'CONSTANT', + 'not goto label - class constant followed by switch-case colon' => [ + 'testMarker' => '/* testNotGotoDeclarationClassConstant */', + 'testContent' => 'CONSTANT', ], - [ - '/* testNotGotoDeclarationClassProperty */', - 'property', + 'not goto label - class property use followed by switch-case colon' => [ + 'testMarker' => '/* testNotGotoDeclarationClassProperty */', + 'testContent' => 'property', ], - [ - '/* testNotGotoDeclarationGlobalConstantInTernary */', - 'CONST_A', + 'not goto label - global constant followed by ternary else' => [ + 'testMarker' => '/* testNotGotoDeclarationGlobalConstantInTernary */', + 'testContent' => 'CONST_A', ], - [ - '/* testNotGotoDeclarationGlobalConstantInTernary */', - 'CONST_B', + 'not goto label - global constant after ternary else' => [ + 'testMarker' => '/* testNotGotoDeclarationGlobalConstantInTernary */', + 'testContent' => 'CONST_B', ], - [ - '/* testNotGotoDeclarationEnumWithType */', - 'Suit', + 'not goto label - name of backed enum' => [ + 'testMarker' => '/* testNotGotoDeclarationEnumWithType */', + 'testContent' => 'Suit', ], ]; From 4298671cfed5ba1f5642051f73de51f03f1ac88a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 11:57:12 +0100 Subject: [PATCH 303/874] Tests/HeredocStringTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblock more specific. --- tests/Core/Tokenizer/HeredocStringTest.php | 48 +++++++++++++--------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/tests/Core/Tokenizer/HeredocStringTest.php b/tests/Core/Tokenizer/HeredocStringTest.php index 2aa04a1bdc..16d06c118e 100644 --- a/tests/Core/Tokenizer/HeredocStringTest.php +++ b/tests/Core/Tokenizer/HeredocStringTest.php @@ -62,86 +62,94 @@ public function testHeredocStringWrapped($testMarker, $expectedContent) /** * Data provider. * + * Type reference: + * 1. Directly embedded variables. + * 2. Braces outside the variable. + * 3. Braces after the dollar sign. + * 4. Variable variables and expressions. + * + * @link https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation + * * @see testHeredocString() * - * @return array + * @return array> */ public static function dataHeredocString() { return [ - [ + 'Type 1: simple variable' => [ 'testMarker' => '/* testSimple1 */', 'expectedContent' => '$foo', ], - [ + 'Type 2: simple variable' => [ 'testMarker' => '/* testSimple2 */', 'expectedContent' => '{$foo}', ], - [ + 'Type 3: simple variable' => [ 'testMarker' => '/* testSimple3 */', 'expectedContent' => '${foo}', ], - [ + 'Type 1: array offset' => [ 'testMarker' => '/* testDIM1 */', 'expectedContent' => '$foo[bar]', ], - [ + 'Type 2: array offset' => [ 'testMarker' => '/* testDIM2 */', 'expectedContent' => '{$foo[\'bar\']}', ], - [ + 'Type 3: array offset' => [ 'testMarker' => '/* testDIM3 */', 'expectedContent' => '${foo[\'bar\']}', ], - [ + 'Type 1: object property' => [ 'testMarker' => '/* testProperty1 */', 'expectedContent' => '$foo->bar', ], - [ + 'Type 2: object property' => [ 'testMarker' => '/* testProperty2 */', 'expectedContent' => '{$foo->bar}', ], - [ + 'Type 2: object method call' => [ 'testMarker' => '/* testMethod1 */', 'expectedContent' => '{$foo->bar()}', ], - [ + 'Type 2: closure function call' => [ 'testMarker' => '/* testClosure1 */', 'expectedContent' => '{$foo()}', ], - [ + 'Type 2: chaining various syntaxes' => [ 'testMarker' => '/* testChain1 */', 'expectedContent' => '{$foo[\'bar\']->baz()()}', ], - [ + 'Type 4: variable variables' => [ 'testMarker' => '/* testVariableVar1 */', 'expectedContent' => '${$bar}', ], - [ + 'Type 4: variable constants' => [ 'testMarker' => '/* testVariableVar2 */', 'expectedContent' => '${(foo)}', ], - [ + 'Type 4: object property' => [ 'testMarker' => '/* testVariableVar3 */', 'expectedContent' => '${foo->bar}', ], - [ + 'Type 4: variable variable nested in array offset' => [ 'testMarker' => '/* testNested1 */', 'expectedContent' => '${foo["${bar}"]}', ], - [ + 'Type 4: variable array offset nested in array offset' => [ 'testMarker' => '/* testNested2 */', 'expectedContent' => '${foo["${bar[\'baz\']}"]}', ], - [ + 'Type 4: variable object property' => [ 'testMarker' => '/* testNested3 */', 'expectedContent' => '${foo->{$baz}}', ], - [ + 'Type 4: variable object property - complex with single quotes' => [ 'testMarker' => '/* testNested4 */', 'expectedContent' => '${foo->{${\'a\'}}}', ], - [ + 'Type 4: variable object property - complex with single and double quotes' => [ 'testMarker' => '/* testNested5 */', 'expectedContent' => '${foo->{"${\'a\'}"}}', ], From b2230273be694b71763e546f187e3b2bd1898019 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Dec 2023 01:40:34 +0100 Subject: [PATCH 304/874] Tests/NullsafeObjectOperatorTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes minor array normalization. Include making the data type in the docblock more specific. --- .../Tokenizer/NullsafeObjectOperatorTest.php | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php b/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php index 8c4f5ab97d..f4b424d964 100644 --- a/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php +++ b/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php @@ -18,7 +18,7 @@ final class NullsafeObjectOperatorTest extends AbstractMethodUnitTest /** * Tokens to search for. * - * @var array + * @var array */ protected $find = [ T_NULLSAFE_OBJECT_OPERATOR, @@ -71,13 +71,13 @@ public function testNullsafeObjectOperator($testMarker) * * @see testNullsafeObjectOperator() * - * @return array + * @return array> */ public static function dataNullsafeObjectOperator() { return [ - ['/* testNullsafeObjectOperator */'], - ['/* testNullsafeObjectOperatorWriteContext */'], + 'nullsafe operator' => ['/* testNullsafeObjectOperator */'], + 'illegal nullsafe operator (write context)' => ['/* testNullsafeObjectOperatorWriteContext */'], ]; }//end dataNullsafeObjectOperator() @@ -117,21 +117,25 @@ public function testTernaryThen($testMarker, $testObjectOperator=false) * * @see testTernaryThen() * - * @return array + * @return array> */ public static function dataTernaryThen() { return [ - ['/* testTernaryThen */'], - [ - '/* testParseErrorWhitespaceNotAllowed */', - true, + 'ternary then' => [ + 'testMarker' => '/* testTernaryThen */', ], - [ - '/* testParseErrorCommentNotAllowed */', - true, + 'whitespace between question mark and object operator' => [ + 'testMarker' => '/* testParseErrorWhitespaceNotAllowed */', + 'testObjectOperator' => true, + ], + 'comment between question mark and object operator' => [ + 'testMarker' => '/* testParseErrorCommentNotAllowed */', + 'testObjectOperator' => true, + ], + 'parse error/live coding' => [ + 'testMarker' => '/* testLiveCoding */', ], - ['/* testLiveCoding */'], ]; }//end dataTernaryThen() From 6b8e591efcac853e393c17dc8a0d0febc884ff8b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Dec 2023 01:31:58 +0100 Subject: [PATCH 305/874] Tests/ScopeSettingWithNamespaceOperatorTest: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Include making the data type in the docblock more specific. Includes fixing the test description in the file docblock. --- .../ScopeSettingWithNamespaceOperatorTest.php | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php b/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php index 872979f7fe..aa2a229ca9 100644 --- a/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php +++ b/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php @@ -1,6 +1,6 @@ * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) @@ -18,10 +18,10 @@ final class ScopeSettingWithNamespaceOperatorTest extends AbstractMethodUnitTest /** * Test that the scope opener/closers are set correctly when the namespace keyword is encountered as an operator. * - * @param string $testMarker The comment which prefaces the target tokens in the test file. - * @param int|string[] $tokenTypes The token type to search for. - * @param int|string[] $open Optional. The token type for the scope opener. - * @param int|string[] $close Optional. The token type for the scope closer. + * @param string $testMarker The comment which prefaces the target tokens in the test file. + * @param array $tokenTypes The token type to search for. + * @param array $open Optional. The token type for the scope opener. + * @param array $close Optional. The token type for the scope closer. * * @dataProvider dataScopeSetting * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap @@ -59,36 +59,36 @@ public function testScopeSetting($testMarker, $tokenTypes, $open=T_OPEN_CURLY_BR * * @see testScopeSetting() * - * @return array + * @return array>> */ public static function dataScopeSetting() { return [ - [ - '/* testClassExtends */', - [T_CLASS], + 'class which extends namespace relative name' => [ + 'testMarker' => '/* testClassExtends */', + 'tokenTypes' => [T_CLASS], ], - [ - '/* testClassImplements */', - [T_ANON_CLASS], + 'class which implements namespace relative name' => [ + 'testMarker' => '/* testClassImplements */', + 'tokenTypes' => [T_ANON_CLASS], ], - [ - '/* testInterfaceExtends */', - [T_INTERFACE], + 'interface which extend namespace relative name' => [ + 'testMarker' => '/* testInterfaceExtends */', + 'tokenTypes' => [T_INTERFACE], ], - [ - '/* testFunctionReturnType */', - [T_FUNCTION], + 'namespace relative name in function return type' => [ + 'testMarker' => '/* testFunctionReturnType */', + 'tokenTypes' => [T_FUNCTION], ], - [ - '/* testClosureReturnType */', - [T_CLOSURE], + 'namespace relative name in closure return type' => [ + 'testMarker' => '/* testClosureReturnType */', + 'tokenTypes' => [T_CLOSURE], ], - [ - '/* testArrowFunctionReturnType */', - [T_FN], - [T_FN_ARROW], - [T_SEMICOLON], + 'namespace relative name in arrow function return type' => [ + 'testMarker' => '/* testArrowFunctionReturnType */', + 'tokenTypes' => [T_FN], + 'open' => [T_FN_ARROW], + 'close' => [T_SEMICOLON], ], ]; From 2c32a6e3ade928e8f2284f60f86918376d6047e0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 10:18:12 +0100 Subject: [PATCH 306/874] Tests/StableCommentWhitespace[Win]Test: use named data sets With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Aside from adding the data set name, this commit also adds the parameter name for each item in the data set, this time in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes making the data types in the docblocks more specific. --- .../Tokenizer/StableCommentWhitespaceTest.php | 186 +++++++++--------- .../StableCommentWhitespaceWinTest.php | 96 ++++----- 2 files changed, 141 insertions(+), 141 deletions(-) diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php index 3b5ffeb963..466aecd1c9 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php @@ -25,8 +25,8 @@ final class StableCommentWhitespaceTest extends AbstractMethodUnitTest /** * Test that comment tokenization with new lines at the end of the comment is stable. * - * @param string $testMarker The comment prefacing the test. - * @param array $expectedTokens The tokenization expected. + * @param string $testMarker The comment prefacing the test. + * @param array> $expectedTokens The tokenization expected. * * @dataProvider dataCommentTokenization * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize @@ -54,14 +54,14 @@ public function testCommentTokenization($testMarker, $expectedTokens) * * @see testCommentTokenization() * - * @return array + * @return array>>> */ public static function dataCommentTokenization() { return [ - [ - '/* testSingleLineSlashComment */', - [ + 'slash comment, single line' => [ + 'testMarker' => '/* testSingleLineSlashComment */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment @@ -74,9 +74,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineSlashCommentTrailing */', - [ + 'slash comment, single line, trailing' => [ + 'testMarker' => '/* testSingleLineSlashCommentTrailing */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment @@ -89,9 +89,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineSlashAnnotation */', - [ + 'slash ignore annotation, single line' => [ + 'testMarker' => '/* testSingleLineSlashAnnotation */', + 'expectedTokens' => [ [ 'type' => 'T_PHPCS_DISABLE', 'content' => '// phpcs:disable Stnd.Cat @@ -104,9 +104,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineSlashComment */', - [ + 'slash comment, multi-line' => [ + 'testMarker' => '/* testMultiLineSlashComment */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment1 @@ -129,9 +129,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineSlashCommentWithIndent */', - [ + 'slash comment, multi-line, indented' => [ + 'testMarker' => '/* testMultiLineSlashCommentWithIndent */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment1 @@ -162,9 +162,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineSlashCommentWithAnnotationStart */', - [ + 'slash comment, multi-line, ignore annotation as first line' => [ + 'testMarker' => '/* testMultiLineSlashCommentWithAnnotationStart */', + 'expectedTokens' => [ [ 'type' => 'T_PHPCS_IGNORE', 'content' => '// phpcs:ignore Stnd.Cat @@ -187,9 +187,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineSlashCommentWithAnnotationMiddle */', - [ + 'slash comment, multi-line, ignore annotation as middle line' => [ + 'testMarker' => '/* testMultiLineSlashCommentWithAnnotationMiddle */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment1 @@ -212,9 +212,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineSlashCommentWithAnnotationEnd */', - [ + 'slash comment, multi-line, ignore annotation as last line' => [ + 'testMarker' => '/* testMultiLineSlashCommentWithAnnotationEnd */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment1 @@ -237,9 +237,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineStarComment */', - [ + 'star comment, single line' => [ + 'testMarker' => '/* testSingleLineStarComment */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '/* Single line star comment */', @@ -251,9 +251,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineStarCommentTrailing */', - [ + 'star comment, single line, trailing' => [ + 'testMarker' => '/* testSingleLineStarCommentTrailing */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '/* Comment */', @@ -265,9 +265,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineStarAnnotation */', - [ + 'star ignore annotation, single line' => [ + 'testMarker' => '/* testSingleLineStarAnnotation */', + 'expectedTokens' => [ [ 'type' => 'T_PHPCS_IGNORE', 'content' => '/* phpcs:ignore Stnd.Cat */', @@ -279,9 +279,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineStarComment */', - [ + 'star comment, multi-line' => [ + 'testMarker' => '/* testMultiLineStarComment */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '/* Comment1 @@ -303,9 +303,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineStarCommentWithIndent */', - [ + 'star comment, multi-line, indented' => [ + 'testMarker' => '/* testMultiLineStarCommentWithIndent */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '/* Comment1 @@ -327,9 +327,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineStarCommentWithAnnotationStart */', - [ + 'star comment, multi-line, ignore annotation as first line' => [ + 'testMarker' => '/* testMultiLineStarCommentWithAnnotationStart */', + 'expectedTokens' => [ [ 'type' => 'T_PHPCS_IGNORE', 'content' => '/* @phpcs:ignore Stnd.Cat @@ -351,9 +351,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineStarCommentWithAnnotationMiddle */', - [ + 'star comment, multi-line, ignore annotation as middle line' => [ + 'testMarker' => '/* testMultiLineStarCommentWithAnnotationMiddle */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '/* Comment1 @@ -375,9 +375,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineStarCommentWithAnnotationEnd */', - [ + 'star comment, multi-line, ignore annotation as last line' => [ + 'testMarker' => '/* testMultiLineStarCommentWithAnnotationEnd */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '/* Comment1 @@ -400,9 +400,9 @@ public static function dataCommentTokenization() ], ], - [ - '/* testSingleLineDocblockComment */', - [ + 'docblock comment, single line' => [ + 'testMarker' => '/* testSingleLineDocblockComment */', + 'expectedTokens' => [ [ 'type' => 'T_DOC_COMMENT_OPEN_TAG', 'content' => '/**', @@ -426,9 +426,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineDocblockCommentTrailing */', - [ + 'docblock comment, single line, trailing' => [ + 'testMarker' => '/* testSingleLineDocblockCommentTrailing */', + 'expectedTokens' => [ [ 'type' => 'T_DOC_COMMENT_OPEN_TAG', 'content' => '/**', @@ -452,9 +452,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineDocblockAnnotation */', - [ + 'docblock ignore annotation, single line' => [ + 'testMarker' => '/* testSingleLineDocblockAnnotation */', + 'expectedTokens' => [ [ 'type' => 'T_DOC_COMMENT_OPEN_TAG', 'content' => '/**', @@ -479,9 +479,9 @@ public static function dataCommentTokenization() ], ], - [ - '/* testMultiLineDocblockComment */', - [ + 'docblock comment, multi-line' => [ + 'testMarker' => '/* testMultiLineDocblockComment */', + 'expectedTokens' => [ [ 'type' => 'T_DOC_COMMENT_OPEN_TAG', 'content' => '/**', @@ -590,9 +590,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineDocblockCommentWithIndent */', - [ + 'docblock comment, multi-line, indented' => [ + 'testMarker' => '/* testMultiLineDocblockCommentWithIndent */', + 'expectedTokens' => [ [ 'type' => 'T_DOC_COMMENT_OPEN_TAG', 'content' => '/**', @@ -701,9 +701,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineDocblockCommentWithAnnotation */', - [ + 'docblock comment, multi-line, ignore annotation' => [ + 'testMarker' => '/* testMultiLineDocblockCommentWithAnnotation */', + 'expectedTokens' => [ [ 'type' => 'T_DOC_COMMENT_OPEN_TAG', 'content' => '/**', @@ -812,9 +812,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineDocblockCommentWithTagAnnotation */', - [ + 'docblock comment, multi-line, ignore annotation as tag' => [ + 'testMarker' => '/* testMultiLineDocblockCommentWithTagAnnotation */', + 'expectedTokens' => [ [ 'type' => 'T_DOC_COMMENT_OPEN_TAG', 'content' => '/**', @@ -923,9 +923,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineHashComment */', - [ + 'hash comment, single line' => [ + 'testMarker' => '/* testSingleLineHashComment */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '# Comment @@ -938,9 +938,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineHashCommentTrailing */', - [ + 'hash comment, single line, trailing' => [ + 'testMarker' => '/* testSingleLineHashCommentTrailing */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '# Comment @@ -953,9 +953,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineHashComment */', - [ + 'hash comment, multi-line' => [ + 'testMarker' => '/* testMultiLineHashComment */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '# Comment1 @@ -978,9 +978,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineHashCommentWithIndent */', - [ + 'hash comment, multi-line, indented' => [ + 'testMarker' => '/* testMultiLineHashCommentWithIndent */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '# Comment1 @@ -1011,9 +1011,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineSlashCommentNoNewLineAtEnd */', - [ + 'slash comment, single line, without new line at end' => [ + 'testMarker' => '/* testSingleLineSlashCommentNoNewLineAtEnd */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Slash ', @@ -1025,9 +1025,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineHashCommentNoNewLineAtEnd */', - [ + 'hash comment, single line, without new line at end' => [ + 'testMarker' => '/* testSingleLineHashCommentNoNewLineAtEnd */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '# Hash ', @@ -1039,9 +1039,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testCommentAtEndOfFile */', - [ + 'unclosed star comment at end of file' => [ + 'testMarker' => '/* testCommentAtEndOfFile */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '/* Comment', diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php index a85ba73cb9..d63159224d 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php @@ -22,8 +22,8 @@ final class StableCommentWhitespaceWinTest extends AbstractMethodUnitTest /** * Test that comment tokenization with new lines at the end of the comment is stable. * - * @param string $testMarker The comment prefacing the test. - * @param array $expectedTokens The tokenization expected. + * @param string $testMarker The comment prefacing the test. + * @param array> $expectedTokens The tokenization expected. * * @dataProvider dataCommentTokenization * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize @@ -51,14 +51,14 @@ public function testCommentTokenization($testMarker, $expectedTokens) * * @see testCommentTokenization() * - * @return array + * @return array>>> */ public static function dataCommentTokenization() { return [ - [ - '/* testSingleLineSlashComment */', - [ + 'slash comment, single line' => [ + 'testMarker' => '/* testSingleLineSlashComment */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment @@ -71,9 +71,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineSlashCommentTrailing */', - [ + 'slash comment, single line, trailing' => [ + 'testMarker' => '/* testSingleLineSlashCommentTrailing */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment @@ -86,9 +86,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineSlashAnnotation */', - [ + 'slash ignore annotation, single line' => [ + 'testMarker' => '/* testSingleLineSlashAnnotation */', + 'expectedTokens' => [ [ 'type' => 'T_PHPCS_DISABLE', 'content' => '// phpcs:disable Stnd.Cat @@ -101,9 +101,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineSlashComment */', - [ + 'slash comment, multi-line' => [ + 'testMarker' => '/* testMultiLineSlashComment */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment1 @@ -126,9 +126,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineSlashCommentWithIndent */', - [ + 'slash comment, multi-line, indented' => [ + 'testMarker' => '/* testMultiLineSlashCommentWithIndent */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment1 @@ -159,9 +159,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineSlashCommentWithAnnotationStart */', - [ + 'slash comment, multi-line, ignore annotation as first line' => [ + 'testMarker' => '/* testMultiLineSlashCommentWithAnnotationStart */', + 'expectedTokens' => [ [ 'type' => 'T_PHPCS_IGNORE', 'content' => '// phpcs:ignore Stnd.Cat @@ -184,9 +184,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineSlashCommentWithAnnotationMiddle */', - [ + 'slash comment, multi-line, ignore annotation as middle line' => [ + 'testMarker' => '/* testMultiLineSlashCommentWithAnnotationMiddle */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment1 @@ -209,9 +209,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineSlashCommentWithAnnotationEnd */', - [ + 'slash comment, multi-line, ignore annotation as last line' => [ + 'testMarker' => '/* testMultiLineSlashCommentWithAnnotationEnd */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Comment1 @@ -234,9 +234,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineSlashCommentNoNewLineAtEnd */', - [ + 'slash comment, single line, without new line at end' => [ + 'testMarker' => '/* testSingleLineSlashCommentNoNewLineAtEnd */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '// Slash ', @@ -248,9 +248,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineHashComment */', - [ + 'hash comment, single line' => [ + 'testMarker' => '/* testSingleLineHashComment */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '# Comment @@ -263,9 +263,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineHashCommentTrailing */', - [ + 'hash comment, single line, trailing' => [ + 'testMarker' => '/* testSingleLineHashCommentTrailing */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '# Comment @@ -278,9 +278,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineHashComment */', - [ + 'hash comment, multi-line' => [ + 'testMarker' => '/* testMultiLineHashComment */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '# Comment1 @@ -303,9 +303,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testMultiLineHashCommentWithIndent */', - [ + 'hash comment, multi-line, indented' => [ + 'testMarker' => '/* testMultiLineHashCommentWithIndent */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '# Comment1 @@ -336,9 +336,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testSingleLineHashCommentNoNewLineAtEnd */', - [ + 'hash comment, single line, without new line at end' => [ + 'testMarker' => '/* testSingleLineHashCommentNoNewLineAtEnd */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '# Hash ', @@ -350,9 +350,9 @@ public static function dataCommentTokenization() ], ], ], - [ - '/* testCommentAtEndOfFile */', - [ + 'unclosed star comment at end of file' => [ + 'testMarker' => '/* testCommentAtEndOfFile */', + 'expectedTokens' => [ [ 'type' => 'T_COMMENT', 'content' => '/* Comment', From 6e9d03b1bda5031dbf15f64ba2dac635e67c6278 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 15 Jan 2024 06:35:01 +0100 Subject: [PATCH 307/874] Tests: new `ConfigDouble` test helper class The PHP_CodeSniffer native `Config` class contains a number of static properties. As the value of these static properties will be retained between instantiations of the class, config values set in one test can influence the results for another test, which makes tests unstable. This commit introduces a test "double" of the `Config` class which prevents this from happening. In _most_ cases, tests should be using this class instead of the "normal" Config, with the exception of select tests for the Config class itself. --- tests/ConfigDouble.php | 196 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 tests/ConfigDouble.php diff --git a/tests/ConfigDouble.php b/tests/ConfigDouble.php new file mode 100644 index 0000000000..190f75ecef --- /dev/null +++ b/tests/ConfigDouble.php @@ -0,0 +1,196 @@ + + * @copyright 2024 Juliette Reinders Folmer. All rights reserved. + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests; + +use PHP_CodeSniffer\Config; +use ReflectionProperty; + +final class ConfigDouble extends Config +{ + + /** + * Whether or not the setting of a standard should be skipped. + * + * @var boolean + */ + private $skipSettingStandard = false; + + + /** + * Creates a clean Config object and populates it with command line values. + * + * @param array $cliArgs An array of values gathered from CLI args. + * @param bool $skipSettingStandard Whether to skip setting a standard to prevent + * the Config class trying to auto-discover a ruleset file. + * Should only be set to `true` for tests which actually test + * the ruleset auto-discovery. + * Note: there is no need to set this to `true` when a standard + * is being passed via the `$cliArgs`. Those settings will always + * respected. + * Defaults to `false`. Will result in the standard being set + * to "PSR1" if not provided via `$cliArgs`. + * @param bool $skipSettingReportWidth Whether to skip setting a report-width to prevent + * the Config class trying to auto-discover the screen width. + * Should only be set to `true` for tests which actually test + * the screen width auto-discovery. + * Note: there is no need to set this to `true` when a report-width + * is being passed via the `$cliArgs`. Those settings will always + * respected. + * Defaults to `false`. Will result in the reportWidth being set + * to "80" if not provided via `$cliArgs`. + * + * @return void + */ + public function __construct(array $cliArgs=[], $skipSettingStandard=false, $skipSettingReportWidth=false) + { + $this->skipSettingStandard = $skipSettingStandard; + + $this->resetSelectProperties(); + $this->preventReadingCodeSnifferConfFile(); + + parent::__construct($cliArgs); + + if ($skipSettingReportWidth !== true) { + $this->preventAutoDiscoveryScreenWidth(); + } + + }//end __construct() + + + /** + * Sets the command line values and optionally prevents a file system search for a custom ruleset. + * + * @param array $args An array of command line arguments to set. + * + * @return void + */ + public function setCommandLineValues($args) + { + parent::setCommandLineValues($args); + + if ($this->skipSettingStandard !== true) { + $this->preventSearchingForRuleset(); + } + + }//end setCommandLineValues() + + + /** + * Reset a few properties on the Config class to their default values. + * + * @return void + */ + private function resetSelectProperties() + { + $this->setStaticConfigProperty('overriddenDefaults', []); + $this->setStaticConfigProperty('executablePaths', []); + + }//end resetSelectProperties() + + + /** + * Prevent the values in a potentially available user-specific `CodeSniffer.conf` file + * from influencing the tests. + * + * This also prevents some file system calls which can influence the test runtime. + * + * @return void + */ + private function preventReadingCodeSnifferConfFile() + { + $this->setStaticConfigProperty('configData', []); + $this->setStaticConfigProperty('configDataFile', ''); + + }//end preventReadingCodeSnifferConfFile() + + + /** + * Prevent searching for a custom ruleset by setting a standard, but only if the test + * being run doesn't set a standard itself. + * + * This also prevents some file system calls which can influence the test runtime. + * + * The standard being set is the smallest one available so the ruleset initialization + * will be the fastest possible. + * + * @return void + */ + private function preventSearchingForRuleset() + { + $overriddenDefaults = $this->getStaticConfigProperty('overriddenDefaults'); + if (isset($overriddenDefaults['standards']) === false) { + $this->standards = ['PSR1']; + $overriddenDefaults['standards'] = true; + } + + self::setStaticConfigProperty('overriddenDefaults', $overriddenDefaults); + + }//end preventSearchingForRuleset() + + + /** + * Prevent a call to stty to figure out the screen width, but only if the test being run + * doesn't set a report width itself. + * + * @return void + */ + private function preventAutoDiscoveryScreenWidth() + { + $settings = $this->getSettings(); + if ($settings['reportWidth'] === 'auto') { + $this->reportWidth = self::DEFAULT_REPORT_WIDTH; + } + + }//end preventAutoDiscoveryScreenWidth() + + + /** + * Helper function to retrieve the value of a private static property on the Config class. + * + * @param string $name The name of the property to retrieve. + * + * @return mixed + */ + private function getStaticConfigProperty($name) + { + $property = new ReflectionProperty('PHP_CodeSniffer\Config', $name); + $property->setAccessible(true); + return $property->getValue(); + + }//end getStaticConfigProperty() + + + /** + * Helper function to set the value of a private static property on the Config class. + * + * @param string $name The name of the property to set. + * @param mixed $value The value to set the property to. + * + * @return void + */ + private function setStaticConfigProperty($name, $value) + { + $property = new ReflectionProperty('PHP_CodeSniffer\Config', $name); + $property->setAccessible(true); + $property->setValue(null, $value); + $property->setAccessible(false); + + }//end setStaticConfigProperty() + + +}//end class From 16ad55b6a9333ad735fade0fc786fec93961f9fc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 14 Jan 2024 22:59:37 +0100 Subject: [PATCH 308/874] Tests: implement use of the new `ConfigDouble` class Note: for the `AbstractSniffUnitTest` class, this change has little to no effect, other than protecting the sniff tests from changes made to the static properties in the `Config` class by the `Core` tests. This is due to the `Config` being cached to a global variable. Fixing that is outside the scope of this PR. Related issues: squizlabs/PHP_CodeSniffer 2899 and 25. --- tests/Core/AbstractMethodUnitTest.php | 57 +------------------ tests/Core/ErrorSuppressionTest.php | 28 ++++----- tests/Core/Filters/AbstractFilterTestCase.php | 4 +- tests/Core/Filters/Filter/AcceptTest.php | 3 +- tests/Core/Ruleset/ExplainTest.php | 10 ++-- .../RuleInclusionAbsoluteLinuxTest.php | 4 +- .../RuleInclusionAbsoluteWindowsTest.php | 4 +- tests/Core/Ruleset/RuleInclusionTest.php | 4 +- tests/Core/Ruleset/SetSniffPropertyTest.php | 20 +++---- tests/Standards/AbstractSniffUnitTest.php | 4 +- 10 files changed, 43 insertions(+), 95 deletions(-) diff --git a/tests/Core/AbstractMethodUnitTest.php b/tests/Core/AbstractMethodUnitTest.php index abab2d6ffe..9923d6d168 100644 --- a/tests/Core/AbstractMethodUnitTest.php +++ b/tests/Core/AbstractMethodUnitTest.php @@ -9,9 +9,9 @@ namespace PHP_CodeSniffer\Tests\Core; -use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; use ReflectionProperty; @@ -57,22 +57,7 @@ abstract class AbstractMethodUnitTest extends TestCase */ public static function initializeFile() { - /* - * Set the static properties in the Config class to specific values for performance - * and to clear out values from other tests. - */ - - self::setStaticConfigProperty('executablePaths', []); - - // Set to a usable value to circumvent Config trying to find a phpcs.xml config file. - self::setStaticConfigProperty('overriddenDefaults', ['standards' => ['PSR1']]); - - // Set to values which prevent the test-runner user's `CodeSniffer.conf` file - // from being read and influencing the tests. Also prevent an `exec()` call to stty. - self::setStaticConfigProperty('configData', ['report_width' => 80]); - self::setStaticConfigProperty('configDataFile', ''); - - $config = new Config(); + $config = new ConfigDouble(); // Also set a tab-width to enable testing tab-replaced vs `orig_content`. $config->tabWidth = static::$tabWidth; @@ -93,44 +78,6 @@ public static function initializeFile() }//end initializeFile() - /** - * Clean up after finished test. - * - * @afterClass - * - * @return void - */ - public static function resetFile() - { - self::$phpcsFile = null; - - // Reset the static properties in the Config class to their defaults to prevent tests influencing each other. - self::setStaticConfigProperty('overriddenDefaults', []); - self::setStaticConfigProperty('executablePaths', []); - self::setStaticConfigProperty('configData', null); - self::setStaticConfigProperty('configDataFile', null); - - }//end resetFile() - - - /** - * Helper function to set the value of a private static property on the Config class. - * - * @param string $name The name of the property to set. - * @param mixed $value The value to set the property to. - * - * @return void - */ - public static function setStaticConfigProperty($name, $value) - { - $property = new ReflectionProperty('PHP_CodeSniffer\Config', $name); - $property->setAccessible(true); - $property->setValue(null, $value); - $property->setAccessible(false); - - }//end setStaticConfigProperty() - - /** * Get the token pointer for a target token based on a specific comment found on the line before. * diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index 65fc961fda..4ae1e33ba2 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -9,9 +9,9 @@ namespace PHP_CodeSniffer\Tests\Core; -use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; /** @@ -41,7 +41,7 @@ public function testSuppressError($before, $after, $expectedErrors=0) static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = ['Generic.PHP.LowerCaseConstant']; @@ -173,7 +173,7 @@ public function testSuppressSomeErrors($before, $between, $expectedErrors=1) static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = ['Generic.PHP.LowerCaseConstant']; @@ -265,7 +265,7 @@ public function testSuppressWarning($before, $after, $expectedWarnings=0) static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = ['Generic.Commenting.Todo']; @@ -349,7 +349,7 @@ public function testSuppressLine($before, $after='', $expectedErrors=1) static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = ['Generic.PHP.LowerCaseConstant']; @@ -445,7 +445,7 @@ public static function dataSuppressLine() */ public function testSuppressLineMidLine() { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = ['Generic.PHP.LowerCaseConstant']; @@ -468,7 +468,7 @@ public function testSuppressLineMidLine() */ public function testSuppressLineWithinDocblock() { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = ['Generic.Files.LineLength']; @@ -508,7 +508,7 @@ public function testNestedSuppressLine($before, $after) static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = ['Generic.PHP.LowerCaseConstant']; @@ -598,7 +598,7 @@ public function testSuppressScope($before, $after, $expectedErrors=0) static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['PEAR']; $config->sniffs = ['PEAR.Functions.FunctionDeclaration']; @@ -695,7 +695,7 @@ public function testSuppressFile($before, $after='', $expectedWarnings=0) static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = ['Generic.Commenting.Todo']; @@ -809,7 +809,7 @@ public function testDisableSelected($before, $expectedErrors=0, $expectedWarning static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = [ 'Generic.PHP.LowerCaseConstant', @@ -926,7 +926,7 @@ public function testEnableSelected($code, $expectedErrors, $expectedWarnings) static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = [ 'Generic.PHP.LowerCaseConstant', @@ -1100,7 +1100,7 @@ public function testIgnoreSelected($before, $expectedErrors, $expectedWarnings) static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = [ 'Generic.PHP.LowerCaseConstant', @@ -1191,7 +1191,7 @@ public function testCommenting($code, $expectedErrors, $expectedWarnings) static $config, $ruleset; if (isset($config, $ruleset) === false) { - $config = new Config(); + $config = new ConfigDouble(); $config->standards = ['Generic']; $config->sniffs = [ 'Generic.PHP.LowerCaseConstant', diff --git a/tests/Core/Filters/AbstractFilterTestCase.php b/tests/Core/Filters/AbstractFilterTestCase.php index b867d7aaf8..9091d1998e 100644 --- a/tests/Core/Filters/AbstractFilterTestCase.php +++ b/tests/Core/Filters/AbstractFilterTestCase.php @@ -9,9 +9,9 @@ namespace PHP_CodeSniffer\Tests\Core\Filters; -use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Filters\Filter; use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; use RecursiveIteratorIterator; @@ -45,7 +45,7 @@ abstract class AbstractFilterTestCase extends TestCase */ public static function initializeConfigAndRuleset() { - self::$config = new Config(['--standard=PSR1', '--extensions=php,inc/php,js,css', '--report-width=80']); + self::$config = new ConfigDouble(['--extensions=php,inc/php,js,css']); self::$ruleset = new Ruleset(self::$config); }//end initializeConfigAndRuleset() diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index 3fda81e51e..64765f3af0 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -13,6 +13,7 @@ use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Filters\Filter; use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHP_CodeSniffer\Tests\Core\Filters\AbstractFilterTestCase; use RecursiveArrayIterator; @@ -35,7 +36,7 @@ final class AcceptTest extends AbstractFilterTestCase public static function initializeConfigAndRuleset() { $standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; - self::$config = new Config(["--standard=$standard", '--ignore=*/somethingelse/*', '--report-width=80']); + self::$config = new ConfigDouble(["--standard=$standard", '--ignore=*/somethingelse/*']); self::$ruleset = new Ruleset(self::$config); }//end initializeConfigAndRuleset() diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index d2226c4352..73943d3757 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -9,9 +9,9 @@ namespace PHP_CodeSniffer\Tests\Core\Ruleset; -use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Runner; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; /** @@ -31,7 +31,7 @@ final class ExplainTest extends TestCase public function testExplain() { // Set up the ruleset. - $config = new Config(['--standard=PSR1', '-e', '--report-width=80']); + $config = new ConfigDouble(['--standard=PSR1', '-e']); $ruleset = new Ruleset($config); $expected = PHP_EOL; @@ -66,7 +66,7 @@ public function testExplain() public function testExplainAlwaysDisplaysCompleteSniffName() { // Set up the ruleset. - $config = new Config(['--standard=PSR1', '-e', '--report-width=30']); + $config = new ConfigDouble(['--standard=PSR1', '-e', '--report-width=30']); $ruleset = new Ruleset($config); $expected = PHP_EOL; @@ -104,7 +104,7 @@ public function testExplainSingleSniff() { // Set up the ruleset. $standard = __DIR__.'/ExplainSingleSniffTest.xml'; - $config = new Config(["--standard=$standard", '-e', '--report-width=80']); + $config = new ConfigDouble(["--standard=$standard", '-e']); $ruleset = new Ruleset($config); $expected = PHP_EOL; @@ -135,7 +135,7 @@ public function testExplainCustomRuleset() { // Set up the ruleset. $standard = __DIR__.'/ExplainCustomRulesetTest.xml'; - $config = new Config(["--standard=$standard", '-e', '--report-width=80']); + $config = new ConfigDouble(["--standard=$standard", '-e']); $ruleset = new Ruleset($config); $expected = PHP_EOL; diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php index 04099f3876..1955ce2a43 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php @@ -9,8 +9,8 @@ namespace PHP_CodeSniffer\Tests\Core\Ruleset; -use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; /** @@ -71,7 +71,7 @@ public function initializeConfigAndRuleset() } // Initialize the config and ruleset objects for the test. - $config = new Config(["--standard={$this->standard}"]); + $config = new ConfigDouble(["--standard={$this->standard}"]); $this->ruleset = new Ruleset($config); }//end initializeConfigAndRuleset() diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php index da3723831b..cba45ee399 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php @@ -9,8 +9,8 @@ namespace PHP_CodeSniffer\Tests\Core\Ruleset; -use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; /** @@ -70,7 +70,7 @@ public function initializeConfigAndRuleset() } // Initialize the config and ruleset objects for the test. - $config = new Config(["--standard={$this->standard}"]); + $config = new ConfigDouble(["--standard={$this->standard}"]); $this->ruleset = new Ruleset($config); }//end initializeConfigAndRuleset() diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index 946a89482d..039c99748d 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -9,8 +9,8 @@ namespace PHP_CodeSniffer\Tests\Core\Ruleset; -use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; use ReflectionObject; @@ -74,7 +74,7 @@ public static function initializeConfigAndRuleset() self::markTestSkipped('On the fly ruleset adjustment failed'); } - $config = new Config(["--standard=$standard"]); + $config = new ConfigDouble(["--standard=$standard"]); self::$ruleset = new Ruleset($config); }//end initializeConfigAndRuleset() diff --git a/tests/Core/Ruleset/SetSniffPropertyTest.php b/tests/Core/Ruleset/SetSniffPropertyTest.php index 1415dbf72d..5b02278741 100644 --- a/tests/Core/Ruleset/SetSniffPropertyTest.php +++ b/tests/Core/Ruleset/SetSniffPropertyTest.php @@ -9,8 +9,8 @@ namespace PHP_CodeSniffer\Tests\Core\Ruleset; -use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; use ReflectionObject; @@ -46,7 +46,7 @@ public function testSniffPropertiesGetSetWhenAllowed($name) // Set up the ruleset. $standard = __DIR__."/SetProperty{$name}Test.xml"; - $config = new Config(["--standard=$standard"]); + $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); // Verify that the sniff has been registered. @@ -102,7 +102,7 @@ public function testSetPropertyAppliesPropertyToMultipleSniffsInCategory() // Set up the ruleset. $standard = __DIR__.'/SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml'; - $config = new Config(["--standard=$standard"]); + $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); // Test that the two sniffs which support the property have received the value. @@ -147,7 +147,7 @@ public function testSetPropertyThrowsErrorOnInvalidProperty() // Set up the ruleset. $standard = __DIR__.'/SetPropertyThrowsErrorOnInvalidPropertyTest.xml'; - $config = new Config(["--standard=$standard"]); + $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); }//end testSetPropertyThrowsErrorOnInvalidProperty() @@ -174,7 +174,7 @@ public function testSetPropertyThrowsErrorWhenPropertyOnlyAllowedViaAttribute() // Set up the ruleset. $standard = __DIR__.'/SetPropertyNotAllowedViaAttributeTest.xml'; - $config = new Config(["--standard=$standard"]); + $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); }//end testSetPropertyThrowsErrorWhenPropertyOnlyAllowedViaAttribute() @@ -192,7 +192,7 @@ public function testSetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStand { // Set up the ruleset. $standard = __DIR__.'/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml'; - $config = new Config(["--standard=$standard"]); + $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); }//end testSetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandard() @@ -210,7 +210,7 @@ public function testSetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCateg { // Set up the ruleset. $standard = __DIR__.'/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml'; - $config = new Config(["--standard=$standard"]); + $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); }//end testSetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategory() @@ -230,7 +230,7 @@ public function testDirectCallWithNewArrayFormatSetsProperty() // Set up the ruleset. $standard = __DIR__."/SetProperty{$name}Test.xml"; - $config = new Config(["--standard=$standard"]); + $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); $propertyName = 'arbitrarystring'; @@ -281,7 +281,7 @@ public function testDirectCallWithOldArrayFormatSetsProperty($propertyValue) // Set up the ruleset. $standard = __DIR__."/SetProperty{$name}Test.xml"; - $config = new Config(["--standard=$standard"]); + $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); $propertyName = 'arbitrarystring'; @@ -388,7 +388,7 @@ public function testDirectCallWithOldArrayFormatThrowsDeprecationNotice() // Set up the ruleset. $standard = __DIR__."/SetProperty{$name}Test.xml"; - $config = new Config(["--standard=$standard"]); + $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); $propertyName = 'arbitrarystring'; diff --git a/tests/Standards/AbstractSniffUnitTest.php b/tests/Standards/AbstractSniffUnitTest.php index 9bf61587b8..b57c2ac659 100644 --- a/tests/Standards/AbstractSniffUnitTest.php +++ b/tests/Standards/AbstractSniffUnitTest.php @@ -13,10 +13,10 @@ namespace PHP_CodeSniffer\Tests\Standards; -use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Exceptions\RuntimeException; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Files\LocalFile; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHP_CodeSniffer\Util\Common; use PHPUnit\Framework\TestCase; @@ -134,7 +134,7 @@ final public function testSniff() if (isset($GLOBALS['PHP_CODESNIFFER_CONFIG']) === true) { $config = $GLOBALS['PHP_CODESNIFFER_CONFIG']; } else { - $config = new Config(); + $config = new ConfigDouble(); $config->cache = false; $GLOBALS['PHP_CODESNIFFER_CONFIG'] = $config; } From e1e8bd8458dad62a49bfe9747c8aa4dbf603cbf5 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 16 Jan 2024 15:40:31 -0300 Subject: [PATCH 309/874] Add links to all issues in the 3.7.2 section of the changelog --- CHANGELOG.md | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2da2e81067..a265e9d2bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -320,27 +320,39 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz.Formatting.OperatorBracket no longer reports false positives in match() structures ### Fixed -- Fixed bug #3616 : Squiz.PHP.DisallowComparisonAssignment false positive for PHP 8 match expression +- 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() +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 + +[#3616]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3616 +[#3618]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3618 +[#3632]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3632 +[#3639]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3639 +[#3640]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3640 +[#3645]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3645 +[#3653]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3653 +[#3666]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3666 +[#3668]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3668 +[#3672]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3672 +[#3694]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3694 ## [3.7.1] - 2022-06-18 ### Fixed From 7ae6441eb9baac30e96cd9a5e6188ca0eb8d0bd0 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 11 Jan 2024 11:03:25 -0300 Subject: [PATCH 310/874] Generic/UnusedFunctionParameter: rename test case file To add more tests with syntax errors in separate files in subsequent commits. --- ... => UnusedFunctionParameterUnitTest.1.inc} | 0 .../UnusedFunctionParameterUnitTest.php | 44 +++++++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) rename src/Standards/Generic/Tests/CodeAnalysis/{UnusedFunctionParameterUnitTest.inc => UnusedFunctionParameterUnitTest.1.inc} (100%) diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc rename to src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php index 980dad8dac..a5c1a8e1c0 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php @@ -41,27 +41,35 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return [ - 3 => 1, - 7 => 1, - 78 => 1, - 94 => 1, - 100 => 1, - 106 => 1, - 117 => 1, - 121 => 2, - 125 => 2, - 163 => 1, - 172 => 1, - 228 => 2, - 232 => 2, - 244 => 2, - 248 => 2, - ]; + switch ($testFile) { + case 'UnusedFunctionParameterUnitTest.1.inc': + return [ + 3 => 1, + 7 => 1, + 78 => 1, + 94 => 1, + 100 => 1, + 106 => 1, + 117 => 1, + 121 => 2, + 125 => 2, + 163 => 1, + 172 => 1, + 228 => 2, + 232 => 2, + 244 => 2, + 248 => 2, + ]; + + default: + return []; + }//end switch }//end getWarningList() From 2573b67959f54819d5551397d2589ead40111c72 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 11 Jan 2024 11:13:12 -0300 Subject: [PATCH 311/874] Generic/UnusedFunctionParameter: remove unused variable I found this while working on improving code coverage for this sniff. The value of this variable is defined again on line 112 and then only used right below it on line 113 (https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/84acf4e56f110db8e75cb9a575c5727df637643c/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php#L112-L113) so it should be safe to remove it. --- .../Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php index 66fe781ac7..698ea3723a 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php @@ -94,7 +94,6 @@ public function process(File $phpcsFile, $stackPtr) $errorCode = 'Found'; $implements = false; - $extends = false; if ($token['code'] === T_FUNCTION) { $classPtr = $phpcsFile->getCondition($stackPtr, T_CLASS); From 0219a955373fc1d8d5eba2ae016f87c05ffdb1fc Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 11 Jan 2024 12:39:09 -0300 Subject: [PATCH 312/874] Generic/UnusedFunctionParameter: rename two variables This commit renames `$tmp` variables using more descriptive names to make it easier to understand the code. --- .../UnusedFunctionParameterSniff.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php index 698ea3723a..6b6e2c0a70 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php @@ -173,18 +173,27 @@ public function process(File $phpcsFile, $stackPtr) // A return statement as the first content indicates an interface method. if ($code === T_RETURN) { - $tmp = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true); - if ($tmp === false && $implements !== false) { + $firstNonEmptyTokenAfterReturn = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true); + if ($firstNonEmptyTokenAfterReturn === false && $implements !== false) { return; } // There is a return. - if ($tokens[$tmp]['code'] === T_SEMICOLON && $implements !== false) { + if ($tokens[$firstNonEmptyTokenAfterReturn]['code'] === T_SEMICOLON && $implements !== false) { return; } - $tmp = $phpcsFile->findNext(Tokens::$emptyTokens, ($tmp + 1), null, true); - if ($tmp !== false && $tokens[$tmp]['code'] === T_SEMICOLON && $implements !== false) { + $secondNonEmptyTokenAfterReturn = $phpcsFile->findNext( + Tokens::$emptyTokens, + ($firstNonEmptyTokenAfterReturn + 1), + null, + true + ); + + if ($secondNonEmptyTokenAfterReturn !== false + && $tokens[$secondNonEmptyTokenAfterReturn]['code'] === T_SEMICOLON + && $implements !== false + ) { // There is a return . return; } From f8dd4aa6b5946085a5c30a1aecd486bc77b5f389 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 11 Jan 2024 12:45:16 -0300 Subject: [PATCH 313/874] Generic/UnusedFunctionParameter: improve code coverage --- .../UnusedFunctionParameterUnitTest.1.inc | 23 +++++++++++++++++++ .../UnusedFunctionParameterUnitTest.2.inc | 5 ++++ .../UnusedFunctionParameterUnitTest.3.inc | 5 ++++ .../UnusedFunctionParameterUnitTest.php | 1 + 4 files changed, 34 insertions(+) create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.2.inc create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.3.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc index 154f03157b..f13253d301 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc @@ -249,3 +249,26 @@ class MagicMethodsWithParamsNotDictatedByPHPInChildClass extends SomeParent{ $this->foo = $foo; } } + +/** + * Methods that throw an exception or return on the first line and are part + * of a class that implements an interface should not trigger the sniff. + */ +class InterfaceMethodNotImplement implements SomeInterface { + public function notImplemented($param) { + throw new Exception('Not implemented.'); + } + + public function notImplemented2($param) { + return 'Not implemented.'; + } +} + +/** + * Should trigger the sniff as this method is not part of an interface. + */ +class MethodThrowsException { + public function throwsException($param) { + throw new Exception(); + } +} diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.2.inc b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.2.inc new file mode 100644 index 0000000000..d39eefe305 --- /dev/null +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.2.inc @@ -0,0 +1,5 @@ + 2, 244 => 2, 248 => 2, + 271 => 1, ]; default: From e8811932409837f9013744403495dd40f3a8e70f Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 11 Jan 2024 12:51:20 -0300 Subject: [PATCH 314/874] Generic/UnusedFunctionParameter: remove unreacheable if condition At this point in the code, there should always be a non-empty token after the return statement, even if only the scope closer, and thus the if condition will never be true. If there is a syntax error and there is nothing after the return, the code will never reach this point as in the beginning of the method the code checks if `$token['scope_opener']` is set and this only happens when there is also a scope_closer. --- .../Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php index 6b6e2c0a70..e076b83dce 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php @@ -174,11 +174,6 @@ public function process(File $phpcsFile, $stackPtr) // A return statement as the first content indicates an interface method. if ($code === T_RETURN) { $firstNonEmptyTokenAfterReturn = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true); - if ($firstNonEmptyTokenAfterReturn === false && $implements !== false) { - return; - } - - // There is a return. if ($tokens[$firstNonEmptyTokenAfterReturn]['code'] === T_SEMICOLON && $implements !== false) { return; } From e77350aa75ae46e0f82a377746c7865c04e1b9ab Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 16 Jan 2024 17:02:44 -0300 Subject: [PATCH 315/874] Add links to all issues in the 3.7.0 section of the changelog --- CHANGELOG.md | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a265e9d2bf..e0eef42bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -403,24 +403,35 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Jaroslav Hanslík][@kukulich] for the patch ### Fixed -- 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 -- Fixed bug #3505 : The nullsafe operator is not counted in Generic.Metrics.CyclomaticComplexity +- 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 +- Fixed bug [#3505] : The nullsafe operator is not counted in Generic.Metrics.CyclomaticComplexity - Thanks to [Mark Baker][@MarkBaker] for the patch -- Fixed bug #3526 : PSR12.Properties.ConstantVisibility false positive when using public final const syntax +- 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 +- 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 +- 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 +- 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 +- 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 ${ +- Fixed bug [#3604]: Tokenizer/PHP: bug fix for double quoted strings using ${ - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[#3502]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3502 +[#3503]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3503 +[#3505]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3505 +[#3526]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3526 +[#3530]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3530 +[#3534]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3534 +[#3546]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3546 +[#3550]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3550 +[#3575]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3575 +[#3604]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3604 + ## [3.6.2] - 2021-12-13 ### Changed - Processing large code bases that use tab indenting inside comments and strings will now be faster From 03c4f6c7741a8ed5054ea6e9a47b4d45c3889a40 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 16 Jan 2024 17:06:23 -0300 Subject: [PATCH 316/874] Add links to all issues in the 3.7.1 section of the changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0eef42bcc..a2d2a74c38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -356,9 +356,11 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ## [3.7.1] - 2022-06-18 ### Fixed -- Fixed bug #3609 : Methods/constants with name empty/isset/unset are always reported as error +- Fixed bug [#3609] : Methods/constants with name empty/isset/unset are always reported as error - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[#3609]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3609 + ## [3.7.0] - 2022-06-13 ### Added - Added support for PHP 8.1 explicit octal notation From e8b6e7a84b390a3616526991268333e75973c31d Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 16 Jan 2024 17:09:43 -0300 Subject: [PATCH 317/874] Fix typo in 3.7.0 changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2d2a74c38..d4850f785c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -373,7 +373,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 + - Tokenizing 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 From 841e11ae46d07dd516c3e8bc0ad8644869d68a64 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 17 Jan 2024 10:53:24 -0300 Subject: [PATCH 318/874] Fix some links in the 3.7.2 changelog This commit fixes some links that were using `issues` when they are actually PRs. The links were working due to a redirect, but it is preferable to use the canonical URLs. --- CHANGELOG.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4850f785c..ea99f261dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -344,15 +344,15 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [#3616]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3616 [#3618]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3618 -[#3632]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3632 -[#3639]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3639 -[#3640]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3640 -[#3645]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3645 -[#3653]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3653 +[#3632]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3632 +[#3639]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3639 +[#3640]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3640 +[#3645]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3645 +[#3653]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3653 [#3666]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3666 [#3668]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3668 [#3672]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3672 -[#3694]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3694 +[#3694]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3694 ## [3.7.1] - 2022-06-18 ### Fixed From 37ce21be2b3affab537ffd4e177fdc8a15852f88 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 17 Jan 2024 15:09:58 -0300 Subject: [PATCH 319/874] Generic/DocComment: sync JS and PHP test case files This commit copies two tests from the PHP test case file to the JS test case file. Now the files are synched and the same list of errors can continue to be used for both in DocCommentUnitTest.php. --- .../Generic/Tests/Commenting/DocCommentUnitTest.js | 12 ++++++++++++ .../Tests/Commenting/DocCommentUnitTest.js.fixed | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js index 3506fe0cf8..d1f2539cf7 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js @@ -248,3 +248,15 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ + +/** + * Do something. + * + * @codeCoverageIgnore + * + * @phpcs:disable Stnd.Cat.SniffName + * + * @return void + */ + +/** No docblock close tag. Must be last test without new line. \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed index f4ca127d66..2d9ab8b7e6 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed @@ -253,3 +253,15 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ + +/** + * Do something. + * + * @codeCoverageIgnore + * + * @phpcs:disable Stnd.Cat.SniffName + * + * @return void + */ + +/** No docblock close tag. Must be last test without new line. \ No newline at end of file From d55b222279d3b3f4fa56df32657b988111d7e6ce Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 9 Jan 2024 16:18:19 -0300 Subject: [PATCH 320/874] Generic/DocComment: rename test case files Doing this to be able to move a test that needs to be on the last line to a separate file. --- ...tUnitTest.inc => DocCommentUnitTest.1.inc} | 0 ...c.fixed => DocCommentUnitTest.1.inc.fixed} | 0 ...entUnitTest.js => DocCommentUnitTest.1.js} | 0 ...js.fixed => DocCommentUnitTest.1.js.fixed} | 0 .../Tests/Commenting/DocCommentUnitTest.php | 109 ++++++++++-------- 5 files changed, 59 insertions(+), 50 deletions(-) rename src/Standards/Generic/Tests/Commenting/{DocCommentUnitTest.inc => DocCommentUnitTest.1.inc} (100%) rename src/Standards/Generic/Tests/Commenting/{DocCommentUnitTest.inc.fixed => DocCommentUnitTest.1.inc.fixed} (100%) rename src/Standards/Generic/Tests/Commenting/{DocCommentUnitTest.js => DocCommentUnitTest.1.js} (100%) rename src/Standards/Generic/Tests/Commenting/{DocCommentUnitTest.js.fixed => DocCommentUnitTest.1.js.fixed} (100%) diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc rename to src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed similarity index 100% rename from src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc.fixed rename to src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js similarity index 100% rename from src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js rename to src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed similarity index 100% rename from src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js.fixed rename to src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php index fc3b37accc..a7c4f26573 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php @@ -41,59 +41,68 @@ public function setCliValues($testFile, $config) * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array(int => int) */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 14 => 1, - 16 => 1, - 18 => 1, - 23 => 1, - 26 => 1, - 30 => 1, - 32 => 1, - 38 => 2, - 40 => 1, - 41 => 1, - 51 => 1, - 54 => 1, - 58 => 1, - 60 => 2, - 67 => 1, - 69 => 2, - 80 => 1, - 81 => 2, - 88 => 1, - 91 => 1, - 95 => 1, - 156 => 1, - 158 => 1, - 170 => 3, - 171 => 3, - 179 => 1, - 183 => 1, - 184 => 2, - 185 => 1, - 186 => 1, - 187 => 2, - 193 => 1, - 196 => 1, - 199 => 1, - 203 => 1, - 206 => 1, - 211 => 1, - 214 => 4, - 218 => 1, - 220 => 2, - 222 => 1, - 224 => 3, - 243 => 1, - 244 => 1, - 246 => 1, - 248 => 1, - 249 => 1, - ]; + switch ($testFile) { + case 'DocCommentUnitTest.1.inc': + case 'DocCommentUnitTest.1.js': + return [ + 14 => 1, + 16 => 1, + 18 => 1, + 23 => 1, + 26 => 1, + 30 => 1, + 32 => 1, + 38 => 2, + 40 => 1, + 41 => 1, + 51 => 1, + 54 => 1, + 58 => 1, + 60 => 2, + 67 => 1, + 69 => 2, + 80 => 1, + 81 => 2, + 88 => 1, + 91 => 1, + 95 => 1, + 156 => 1, + 158 => 1, + 170 => 3, + 171 => 3, + 179 => 1, + 183 => 1, + 184 => 2, + 185 => 1, + 186 => 1, + 187 => 2, + 193 => 1, + 196 => 1, + 199 => 1, + 203 => 1, + 206 => 1, + 211 => 1, + 214 => 4, + 218 => 1, + 220 => 2, + 222 => 1, + 224 => 3, + 243 => 1, + 244 => 1, + 246 => 1, + 248 => 1, + 249 => 1, + ]; + + default: + return []; + }//end switch }//end getErrorList() From 69e5d9d31aec3f5feb48e3c3f578710e0ee310c5 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 9 Jan 2024 16:24:45 -0300 Subject: [PATCH 321/874] Generic/DocComment: move parse error test to its own file Moving a test that needs to be on the last line to its own file. I modified the comment message as, far as I could check, the sniff code to bail early if the doc comment is not properly closed works (as it should) even if there are new lines after it. --- .../Generic/Tests/Commenting/DocCommentUnitTest.1.inc | 2 -- .../Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed | 2 -- .../Generic/Tests/Commenting/DocCommentUnitTest.1.js | 2 -- .../Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed | 2 -- .../Generic/Tests/Commenting/DocCommentUnitTest.2.inc | 6 ++++++ .../Generic/Tests/Commenting/DocCommentUnitTest.2.js | 4 ++++ 6 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.2.inc create mode 100644 src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.2.js diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc index bcd8256d7b..04b9977af8 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc @@ -258,5 +258,3 @@ * * @return void */ - -/** No docblock close tag. Must be last test without new line. \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed index 7da1c8ae8e..7b0d8c82cf 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed @@ -263,5 +263,3 @@ * * @return void */ - -/** No docblock close tag. Must be last test without new line. \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js index d1f2539cf7..3391e1f783 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js @@ -258,5 +258,3 @@ * * @return void */ - -/** No docblock close tag. Must be last test without new line. \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed index 2d9ab8b7e6..65ddc733ac 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed @@ -263,5 +263,3 @@ * * @return void */ - -/** No docblock close tag. Must be last test without new line. \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.2.inc b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.2.inc new file mode 100644 index 0000000000..fc0698fa17 --- /dev/null +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.2.inc @@ -0,0 +1,6 @@ + Date: Tue, 9 Jan 2024 17:17:21 -0300 Subject: [PATCH 322/874] Generic/DocComment: improve code coverage Adds two tests to check that the sniffer triggers an error when it finds empty doc comments. --- .../Generic/Tests/Commenting/DocCommentUnitTest.1.inc | 10 ++++++++++ .../Tests/Commenting/DocCommentUnitTest.1.inc.fixed | 10 ++++++++++ .../Generic/Tests/Commenting/DocCommentUnitTest.1.js | 10 ++++++++++ .../Tests/Commenting/DocCommentUnitTest.1.js.fixed | 10 ++++++++++ .../Generic/Tests/Commenting/DocCommentUnitTest.php | 2 ++ 5 files changed, 42 insertions(+) diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc index 04b9977af8..543dd2d6db 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc @@ -258,3 +258,13 @@ * * @return void */ + +// Tests to check handling empty doc comments. +/** + */ + +/** + * + * + * + */ diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed index 7b0d8c82cf..6728780a0b 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.inc.fixed @@ -263,3 +263,13 @@ * * @return void */ + +// Tests to check handling empty doc comments. +/** + */ + +/** + * + * + * + */ diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js index 3391e1f783..bf914411ae 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js @@ -258,3 +258,13 @@ * * @return void */ + +// Tests to check handling empty doc comments. +/** + */ + +/** + * + * + * + */ diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed index 65ddc733ac..133b67d3f4 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed @@ -263,3 +263,13 @@ * * @return void */ + +// Tests to check handling empty doc comments. +/** + */ + +/** + * + * + * + */ diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php index a7c4f26573..78fdf44bc1 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php @@ -98,6 +98,8 @@ public function getErrorList($testFile='') 246 => 1, 248 => 1, 249 => 1, + 263 => 1, + 266 => 1, ]; default: From cc1b2f70cbf236e38d116238d5857b7cc0cdcb9f Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 17 Jan 2024 18:27:19 -0300 Subject: [PATCH 323/874] Add links to all issues in the 3.6.2 section of the changelog --- CHANGELOG.md | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea99f261dd..e72b421a81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -440,27 +440,38 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Thiemo Kreuz][@thiemowmde] for the patch ### Fixed -- Fixed bug #3388 : phpcs does not work when run from WSL drives +- 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 +- 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 +- 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 +- 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 +- Fixed bug [#3448] : PHP 8.1 deprecation notice while generating running time value - Thanks to [Juliette Reinders Folmer][@jrfnl] and Andy Postnikov for the patch -- Fixed bug #3456 : PSR12.Classes.ClassInstantiation.MissingParentheses false positive using attributes on anonymous class +- 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 +- 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 [#3468] : do/while loops are double-counted in Generic.Metrics.CyclomaticComplexity - Thanks to [Mark Baker][@MarkBaker] for the patch -- Fixed bug #3469 : Ternary Operator and Null Coalescing Operator are not counted in Generic.Metrics.CyclomaticComplexity +- Fixed bug [#3469] : Ternary Operator and Null Coalescing Operator are not counted in Generic.Metrics.CyclomaticComplexity - Thanks to [Mark Baker][@MarkBaker] for the patch -- Fixed bug #3472 : PHP 8 match() expression is not counted in Generic.Metrics.CyclomaticComplexity +- Fixed bug [#3472] : PHP 8 match() expression is not counted in Generic.Metrics.CyclomaticComplexity - Thanks to [Mark Baker][@MarkBaker] for the patch +[#3388]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3388 +[#3422]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3422 +[#3437]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3437 +[#3440]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3440 +[#3448]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3448 +[#3456]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3456 +[#3460]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3460 +[#3468]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3468 +[#3469]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3469 +[#3472]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3472 + ## [3.6.1] - 2021-10-11 ### Changed - PHPCS annotations can now be specified using hash-style comments From 2364ee2eedfae70e41b82a4360e94ddb8e0e32c5 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 17 Jan 2024 18:29:23 -0300 Subject: [PATCH 324/874] Add links to all issues in the 3.6.1 section of the changelog --- CHANGELOG.md | 67 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e72b421a81..80ef938b54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -510,45 +510,68 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz.Commenting.VariableComment - Squiz.WhiteSpace.MemberVarSpacing - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3294 : Bug in attribute tokenization when content contains PHP end token or attribute closer on new line +- Fixed bug [#3294] : Bug in attribute tokenization when content contains PHP end token or attribute closer on new line - Thanks to [Alessandro Chitolina][@alekitto] for the patch - Thanks to [Juliette Reinders Folmer][@jrfnl] for the tests -- Fixed bug #3296 : PSR2.ControlStructures.SwitchDeclaration takes phpcs:ignore as content of case body -- Fixed bug #3297 : PSR2.ControlStructures.SwitchDeclaration.TerminatingComment does not handle try/finally blocks +- Fixed bug [#3296] : PSR2.ControlStructures.SwitchDeclaration takes phpcs:ignore as content of case body +- Fixed bug [#3297] : PSR2.ControlStructures.SwitchDeclaration.TerminatingComment does not handle try/finally blocks - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3302 : PHP 8.0 | Tokenizer/PHP: bugfix for union types using namespace operator +- Fixed bug [#3302] : PHP 8.0 | Tokenizer/PHP: bugfix for union types using namespace operator - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3303 : findStartOfStatement() doesn't work with T_OPEN_TAG_WITH_ECHO -- Fixed bug #3316 : Arrow function not tokenized correctly when using null in union type -- Fixed bug #3317 : Problem with how phpcs handles ignored files when running in parallel +- Fixed bug [#3303] : findStartOfStatement() doesn't work with T_OPEN_TAG_WITH_ECHO +- Fixed bug [#3316] : Arrow function not tokenized correctly when using null in union type +- Fixed bug [#3317] : Problem with how phpcs handles ignored files when running in parallel - Thanks to [Emil Andersson][@emil-nasso] for the patch -- Fixed bug #3324 : PHPCS hangs processing some nested arrow functions inside a function call -- Fixed bug #3326 : Generic.Formatting.MultipleStatementAlignment error with const DEFAULT +- Fixed bug [#3324] : PHPCS hangs processing some nested arrow functions inside a function call +- Fixed bug [#3326] : Generic.Formatting.MultipleStatementAlignment error with const DEFAULT - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3333 : Squiz.Objects.ObjectInstantiation: null coalesce operators are not recognized as assignment +- Fixed bug [#3333] : Squiz.Objects.ObjectInstantiation: null coalesce operators are not recognized as assignment - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3340 : Ensure interface and trait names are always tokenized as T_STRING +- Fixed bug [#3340] : Ensure interface and trait names are always tokenized as T_STRING - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3342 : PSR12/Squiz/PEAR standards all error on promoted properties with docblocks +- Fixed bug [#3342] : PSR12/Squiz/PEAR standards all error on promoted properties with docblocks - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3345 : IF statement with no braces and double catch turned into syntax error by auto-fixer +- Fixed bug [#3345] : IF statement with no braces and double catch turned into syntax error by auto-fixer - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3352 : PSR2.ControlStructures.SwitchDeclaration can remove comments on the same line as the case statement while fixing +- Fixed bug [#3352] : PSR2.ControlStructures.SwitchDeclaration can remove comments on the same line as the case statement while fixing - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3357 : Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present +- Fixed bug [#3357] : Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3362 : Generic.WhiteSpace.ScopeIndent false positive for arrow functions inside arrays -- Fixed bug #3384 : Squiz.Commenting.FileComment.SpacingAfterComment false positive on empty file -- Fixed bug #3394 : Fix PHP 8.1 auto_detect_line_endings deprecation notice -- Fixed bug #3400 : PHP 8.1: prevent deprecation notices about missing return types +- Fixed bug [#3362] : Generic.WhiteSpace.ScopeIndent false positive for arrow functions inside arrays +- Fixed bug [#3384] : Squiz.Commenting.FileComment.SpacingAfterComment false positive on empty file +- Fixed bug [#3394] : Fix PHP 8.1 auto_detect_line_endings deprecation notice +- Fixed bug [#3400] : PHP 8.1: prevent deprecation notices about missing return types - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3424 : PHPCS fails when using PHP 8 Constructor property promotion with attributes +- Fixed bug [#3424] : PHPCS fails when using PHP 8 Constructor property promotion with attributes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3425 : PHP 8.1 | Runner::processChildProcs(): fix passing null to non-nullable bug +- Fixed bug [#3425] : PHP 8.1 | Runner::processChildProcs(): fix passing null to non-nullable bug - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3445 : Nullable parameter after attribute incorrectly tokenized as ternary operator +- Fixed bug [#3445] : Nullable parameter after attribute incorrectly tokenized as ternary operator - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[#3294]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3294 +[#3296]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3296 +[#3297]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3297 +[#3302]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3302 +[#3303]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3303 +[#3316]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3316 +[#3317]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3317 +[#3324]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3324 +[#3326]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3326 +[#3333]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3333 +[#3340]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3340 +[#3342]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3342 +[#3345]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3345 +[#3352]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3352 +[#3357]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3357 +[#3362]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3362 +[#3384]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3384 +[#3394]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3394 +[#3400]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3400 +[#3424]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3424 +[#3425]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3425 +[#3445]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3445 + ## [3.6.0] - 2021-04-09 ### Added - Added support for PHP 8.0 union types From 238d19a9414ba303c47375c37d72c64cc3bac9e4 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 17 Jan 2024 18:42:47 -0300 Subject: [PATCH 325/874] Fix typo in the 3.6.1 changelog entry --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80ef938b54..70c3a4949a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -477,8 +477,8 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - PHPCS annotations can now be specified using hash-style comments - Previously, only slash-style and block-style comments could be used to do things like disable errors - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- The new PHP 8.1 tokenisation for ampersands has been reverted to use the existing PHP_CodeSniffer method - - The PHP 8.1 tokens T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG and T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG are unsued +- The new PHP 8.1 tokenization for ampersands has been reverted to use the existing PHP_CodeSniffer method + - The PHP 8.1 tokens T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG and T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG are unused - Ampersands continue to be tokenized as T_BITWISE_AND for all PHP versions - Thanks to [Juliette Reinders Folmer][@jrfnl] and [Anna Filina][@afilina] for the patch - File::getMethodParameters() no longer incorrectly returns argument attributes in the type hint array index @@ -533,7 +533,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug [#3345] : IF statement with no braces and double catch turned into syntax error by auto-fixer - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3352] : PSR2.ControlStructures.SwitchDeclaration can remove comments on the same line as the case statement while fixing +- Fixed bug [#3352] : PSR2.ControlStructures.SwitchDeclaration can remove comments on the same line as the case statement while fixing - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug [#3357] : Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch From 73e959ca47892b4459bc3e93826ee43d3acc5166 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 4 Jan 2024 17:21:25 +0100 Subject: [PATCH 326/874] Add `community-cc-list.md` file This adds the initial cc list file. Fixes 227 --- .github/community-cc-list.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/community-cc-list.md diff --git a/.github/community-cc-list.md b/.github/community-cc-list.md new file mode 100644 index 0000000000..8724c4b8f3 --- /dev/null +++ b/.github/community-cc-list.md @@ -0,0 +1,16 @@ + + +/cc @asispts @dingo-d @fredden @GaryJones @greg0ire @kukulich @michalbundyra @Ocramius @sirbrillig @stronk7 @weierophinney @wimg From 282562d4d7d3be5ffc153c4770d7a755cbfd3778 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 19 Jan 2024 04:55:23 +0100 Subject: [PATCH 327/874] Config: update version nr As there are enough open PRs to warrant a new minor release and no pertinent issues were reported for the 3.8.1 release, the next release will be 3.9.0, not 3.8.2. --- src/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index f2ce8157b6..dd76cfc598 100644 --- a/src/Config.php +++ b/src/Config.php @@ -81,7 +81,7 @@ class Config * * @var string */ - const VERSION = '3.8.2'; + const VERSION = '3.9.0'; /** * Package stability; either stable, beta or alpha. From 4a3fcfa91a038c899023e00265a4536aafbb6f6c Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 4 Dec 2023 17:16:54 +0000 Subject: [PATCH 328/874] Squiz/FunctionComment: specify more specific error code for missing type --- .../Commenting/FunctionCommentSniff.php | 3 +++ .../Commenting/FunctionCommentUnitTest.inc | 24 +++++++++++++++++++ .../FunctionCommentUnitTest.inc.fixed | 24 +++++++++++++++++++ .../Commenting/FunctionCommentUnitTest.php | 9 +++++++ 4 files changed, 60 insertions(+) diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index 644fd50c7c..d7a292bdce 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -366,6 +366,9 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $phpcsFile->addError($error, $tag, 'MissingParamComment'); $commentLines[] = ['comment' => '']; }//end if + } else if ($tokens[($tag + 2)]['content'][0] === '$') { + $error = 'Missing parameter type'; + $phpcsFile->addError($error, $tag, 'MissingParamType'); } else { $error = 'Missing parameter name'; $phpcsFile->addError($error, $tag, 'MissingParamName'); diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc index a44f5e0e2e..4fcbb6dbe0 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc @@ -1134,3 +1134,27 @@ public function variableOrderMismatch($bar, $baz, $foo) { * @return never */ function foo() {} + +/** + * @param $noTypeNoComment + * @return void + */ +function paramVariation1($noTypeNoComment): void {} + +/** + * @param $noTypeWithComment This parameter has no type specified. + * @return void + */ +function paramVariation2($noTypeWithComment): void {} + +/** + * @param integer $hasTypeNoComment + * @return void + */ +function paramVariation3($hasTypeNoComment): void {} + +/** + * @param integer $hasTypehasComment This parameter has type. + * @return void + */ +function paramVariation4($hasTypehasComment): void {} diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed index 3d2e10fd6a..817630b5ba 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed @@ -1134,3 +1134,27 @@ public function variableOrderMismatch($bar, $baz, $foo) { * @return never */ function foo() {} + +/** + * @param $noTypeNoComment + * @return void + */ +function paramVariation1($noTypeNoComment): void {} + +/** + * @param $noTypeWithComment This parameter has no type specified. + * @return void + */ +function paramVariation2($noTypeWithComment): void {} + +/** + * @param integer $hasTypeNoComment + * @return void + */ +function paramVariation3($hasTypeNoComment): void {} + +/** + * @param integer $hasTypehasComment This parameter has type. + * @return void + */ +function paramVariation4($hasTypehasComment): void {} diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php index 0d89db9e5d..a4f4ae2c0b 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php @@ -137,6 +137,13 @@ public function getErrorList() 1123 => 1, 1124 => 1, 1125 => 1, + 1138 => 1, + 1139 => 1, + 1142 => 1, + 1144 => 1, + 1145 => 1, + 1148 => 1, + 1151 => 1, ]; // Scalar type hints only work from PHP 7 onwards. @@ -156,6 +163,8 @@ public function getErrorList() $errors[1089] = 3; $errors[1107] = 8; $errors[1129] = 3; + $errors[1154] = 1; + $errors[1160] = 1; } else { $errors[729] = 4; $errors[740] = 2; From bf88611028a56a91ed1c5ec62055150bc4e0d688 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 4 Dec 2023 17:20:24 +0000 Subject: [PATCH 329/874] Squiz/FunctionComment: no longer suggest incorrect type hint --- src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php | 2 +- .../Squiz/Tests/Commenting/FunctionCommentUnitTest.php | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index d7a292bdce..672818337c 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -463,7 +463,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) } } - if ($suggestedTypeHint !== '' && isset($realParams[$pos]) === true) { + if ($suggestedTypeHint !== '' && isset($realParams[$pos]) === true && $param['var'] !== '') { $typeHint = $realParams[$pos]['type_hint']; // Remove namespace prefixes when comparing. diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php index a4f4ae2c0b..036bdc622b 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php @@ -107,7 +107,6 @@ public function getErrorList() 792 => 1, 794 => 1, 797 => 1, - 801 => 1, 828 => 1, 840 => 1, 852 => 1, @@ -139,10 +138,8 @@ public function getErrorList() 1125 => 1, 1138 => 1, 1139 => 1, - 1142 => 1, 1144 => 1, 1145 => 1, - 1148 => 1, 1151 => 1, ]; From 61e20af23bd9ed6d76eb63f3aee04994c0904351 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 23 Dec 2023 05:05:49 +0100 Subject: [PATCH 330/874] Squiz/EmbeddedPhp: remove some redundant code The removed condition in the `validateInlineEmbeddedPhp()` method could never be `true` as this is already checked in the `process()` method before this method is ever called. As that means we will always already have determined the valid close tag, we may as well pass it to both underlying methods instead of determining it again. This should also yield a small performance improvement, especially when dealing with long files with only an open tag and no a closing tag, as it saves doing the token walking over the complete file for a second time. Includes moving a comment to a more appropriate place. --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 816c5a07bc..ce741987c4 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -46,9 +46,9 @@ public function process(File $phpcsFile, $stackPtr) // then we have an inline embedded PHP block. $closeTag = $phpcsFile->findNext(T_CLOSE_TAG, $stackPtr); if ($closeTag === false || $tokens[$stackPtr]['line'] !== $tokens[$closeTag]['line']) { - $this->validateMultilineEmbeddedPhp($phpcsFile, $stackPtr); + $this->validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag); } else { - $this->validateInlineEmbeddedPhp($phpcsFile, $stackPtr); + $this->validateInlineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag); } }//end process() @@ -57,13 +57,15 @@ public function process(File $phpcsFile, $stackPtr) /** * Validates embedded PHP that exists on multiple lines. * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. + * @param int|false $closingTag The position of the PHP close tag in the + * stack passed in $tokens. * * @return void */ - private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr) + private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag) { $tokens = $phpcsFile->getTokens(); @@ -74,7 +76,7 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr) } $firstContent = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - $closingTag = $phpcsFile->findNext(T_CLOSE_TAG, $stackPtr); + if ($closingTag !== false) { $nextContent = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), $phpcsFile->numTokens, true); if ($nextContent === false) { @@ -293,21 +295,15 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr) * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * @param int $stackPtr The position of the current token in the * stack passed in $tokens. + * @param int $closeTag The position of the PHP close tag in the + * stack passed in $tokens. * * @return void */ - private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr) + private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag) { $tokens = $phpcsFile->getTokens(); - // We only want one line PHP sections, so return if the closing tag is - // on the next line. - $closeTag = $phpcsFile->findNext(T_CLOSE_TAG, $stackPtr, null, false); - if ($tokens[$stackPtr]['line'] !== $tokens[$closeTag]['line']) { - return; - } - - // Check that there is one, and only one space at the start of the statement. $firstContent = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), $closeTag, true); if ($firstContent === false) { @@ -325,6 +321,7 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr) return; } + // Check that there is one, and only one space at the start of the statement. // The open tag token always contains a single space after it. $leadingSpace = 1; if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { From 6875b9e05d9470f7c6ef995bae5f6d49372686b1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 10:25:41 +0100 Subject: [PATCH 331/874] Squiz/EmbeddedPhp: rename two confusingly named variables --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index ce741987c4..b4d15f7e4f 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -78,8 +78,8 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag $firstContent = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); if ($closingTag !== false) { - $nextContent = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), $phpcsFile->numTokens, true); - if ($nextContent === false) { + $firstContentAfterBlock = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), $phpcsFile->numTokens, true); + if ($firstContentAfterBlock === false) { // Final closing tag. It will be handled elsewhere. return; } @@ -171,9 +171,9 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag }//end if }//end if - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$lastContent]['line'] === $tokens[$stackPtr]['line'] - && trim($tokens[$lastContent]['content']) !== '' + $lastContentBeforeBlock = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$lastContentBeforeBlock]['line'] === $tokens[$stackPtr]['line'] + && trim($tokens[$lastContentBeforeBlock]['content']) !== '' ) { $error = 'Opening PHP tag must be on a line by itself'; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'ContentBeforeOpen'); @@ -227,8 +227,8 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag return; } - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closingTag - 1), ($stackPtr + 1), true); - $nextContent = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), null, true); + $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closingTag - 1), ($stackPtr + 1), true); + $firstContentAfterBlock = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), null, true); if ($tokens[$lastContent]['line'] === $tokens[$closingTag]['line']) { $error = 'Closing PHP tag must be on a line by itself'; @@ -240,7 +240,7 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag $phpcsFile->fixer->addNewlineBefore($closingTag); $phpcsFile->fixer->endChangeset(); } - } else if ($tokens[$nextContent]['line'] === $tokens[$closingTag]['line']) { + } else if ($tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line']) { $error = 'Closing PHP tag must be on a line by itself'; $fix = $phpcsFile->addFixableError($error, $closingTag, 'ContentAfterEnd'); if ($fix === true) { From 2fc1ca99e716c96caa8f550a153f07b9ebde5913 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 23 Dec 2023 23:44:49 +0100 Subject: [PATCH 332/874] Squiz/EmbeddedPhp: make test cases more descriptive ... to allow for easier debugging. --- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc | 32 +++++++++---------- .../Tests/PHP/EmbeddedPhpUnitTest.inc.fixed | 32 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc index c61d5a391b..eaad0b0dfc 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc @@ -15,11 +15,11 @@ - - - - - + + + + + @@ -27,18 +27,18 @@ - + - - - + + + - - - + + + - + diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed index 5b43d8493d..fa4d934dc7 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed @@ -15,25 +15,25 @@ - - - - - + + + + + - - - + + + - - - + + + - + From 16f4a3a061e64ffc82a6c6f6334cb40561645722 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 23 Dec 2023 03:30:17 +0100 Subject: [PATCH 333/874] Squiz/EmbeddedPhp: add some extra tests with ignore annotations ... just as an extra safeguard. --- src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc | 2 ++ src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed | 2 ++ src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc index eaad0b0dfc..3a0359ff42 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc @@ -117,3 +117,5 @@ function foo() + + diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed index fa4d934dc7..a345161686 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed @@ -117,3 +117,5 @@ function foo() + + diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php index 8944fc2aee..b437828440 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php @@ -60,6 +60,8 @@ public function getErrorList() 113 => 1, 116 => 1, 117 => 1, + 120 => 1, + 121 => 1, ]; }//end getErrorList() From 38a90c1376f2be85dcc4668e766b3cb04d9bbeef Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 24 Dec 2023 06:37:57 +0100 Subject: [PATCH 334/874] Squiz/EmbeddedPhp: prevent tests being skipped The sniff contains a condition which prevents checks from being run on the last tag set when it is a non-single line tag set. Adding a final open tag will prevent the _last_ test in the file accidentally being skipped, independently of what type of tag set this is, making the test case file more stable. --- src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc | 5 +++++ src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc index 3a0359ff42..711d910ef6 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc @@ -119,3 +119,8 @@ function foo() + + + + Date: Sun, 24 Dec 2023 04:33:43 +0100 Subject: [PATCH 335/874] Squiz/EmbeddedPhp: empty tag set fixer should remove trailing spaces As things were, the "empty embed" fixers would in certain circumstances leave trailing spaces behind. For most codebases, this means the sniff would always need to be run in conjunction with a sniff which removes trailing spaces and that there is always a second fixer round needed: the first to fix the embedded PHP formatting, the second to allow the other sniff to remove the trailing spaces introduced by the fixes made by this sniff. Aside from that, it also makes updating the test case file fiddly. This commit fixes the "empty embed" fixers to remove trailing spaces, when applicable, and consolidates the code for this in a separate method. Note: _surrounding_ HTML whitespace, which is not trailing, will not be affected by this fix as the sniff should have no opinion on that. Covered by pre-existing tests + some additional newly added tests. --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 63 ++++++++++++------- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc | 25 ++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.inc.fixed | 21 ++++++- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 8 +++ 4 files changed, 94 insertions(+), 23 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index b4d15f7e4f..203be9d567 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -86,17 +86,7 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag // We have an opening and a closing tag, that lie within other content. if ($firstContent === $closingTag) { - $error = 'Empty embedded PHP tag found'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Empty'); - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); - for ($i = $stackPtr; $i <= $closingTag; $i++) { - $phpcsFile->fixer->replaceToken($i, ''); - } - - $phpcsFile->fixer->endChangeset(); - } - + $this->reportEmptyTagSet($phpcsFile, $stackPtr, $closingTag); return; } }//end if @@ -307,17 +297,7 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag) $firstContent = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), $closeTag, true); if ($firstContent === false) { - $error = 'Empty embedded PHP tag found'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Empty'); - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); - for ($i = $stackPtr; $i <= $closeTag; $i++) { - $phpcsFile->fixer->replaceToken($i, ''); - } - - $phpcsFile->fixer->endChangeset(); - } - + $this->reportEmptyTagSet($phpcsFile, $stackPtr, $closeTag); return; } @@ -396,4 +376,43 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag) }//end validateInlineEmbeddedPhp() + /** + * Report and fix an set of empty PHP tags. + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. + * @param int $closeTag The position of the PHP close tag in the + * stack passed in $tokens. + * + * @return void + */ + private function reportEmptyTagSet(File $phpcsFile, $stackPtr, $closeTag) + { + $tokens = $phpcsFile->getTokens(); + $error = 'Empty embedded PHP tag found'; + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Empty'); + if ($fix === true) { + $phpcsFile->fixer->beginChangeset(); + for ($i = $stackPtr; $i <= $closeTag; $i++) { + $phpcsFile->fixer->replaceToken($i, ''); + } + + // Prevent leaving indentation whitespace behind when the empty tag set is the only thing on the affected lines. + if (isset($tokens[($closeTag + 1)]) === true + && $tokens[($closeTag + 1)]['line'] !== $tokens[$closeTag]['line'] + && $tokens[($stackPtr - 1)]['code'] === T_INLINE_HTML + && $tokens[($stackPtr - 1)]['line'] === $tokens[$stackPtr]['line'] + && $tokens[($stackPtr - 1)]['column'] === 1 + && trim($tokens[($stackPtr - 1)]['content']) === '' + ) { + $phpcsFile->fixer->replaceToken(($stackPtr - 1), ''); + } + + $phpcsFile->fixer->endChangeset(); + } + + }//end reportEmptyTagSet() + + }//end class diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc index 711d910ef6..5ca71147fd 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc @@ -120,6 +120,31 @@ function foo() + +
+ + + + + + + +
+ + + + + + + - + @@ -120,6 +120,25 @@ function foo() + +
+ + + + + + +
+ + + + + + 1, 120 => 1, 121 => 1, + 128 => 1, + 129 => 1, + 132 => 1, + 134 => 1, + 136 => 1, + 138 => 1, + 142 => 1, + 145 => 1, ]; }//end getErrorList() From 77ebd281f308bff3217360d9061b826a3584d9f5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 24 Dec 2023 06:30:42 +0100 Subject: [PATCH 336/874] Squiz/EmbeddedPhp: opener on own line fixer should remove trailing spaces As things were, the "opener on own line / content after" fixer would always leave at least one trailing space behind. For most codebases, this means the sniff would always need to be run in conjunction with a sniff which removes trailing spaces and that there is always a second fixer round needed: the first to fix the embedded PHP formatting, the second to allow the other sniff to remove the trailing spaces introduced by the fixes made by this sniff. It also makes updating the test case file fiddly. Secondly, if the space between the open tag and the first content was larger than exactly one space, the sniff would also need an extra fixer round to fix the indent of the "first content", which was moved to the next line and given indent, but with the extra space having being moved as well, the indent would now be too large. This commit fixes the "opener on own line / content after" fixer to remove trailing spaces and prevent the potential extra fixer loop to fix the indent. Covered by pre-existing tests + an additional newly added test. --- src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 7 +++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc | 6 ++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed | 13 ++++++++++--- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 203be9d567..80a31d0ea6 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -97,9 +97,16 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag if ($fix === true) { $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true); $padding = (strlen($tokens[$first]['content']) - strlen(ltrim($tokens[$first]['content']))); + $phpcsFile->fixer->beginChangeset(); + $phpcsFile->fixer->replaceToken($stackPtr, rtrim($tokens[$stackPtr]['content'])); $phpcsFile->fixer->addNewline($stackPtr); $phpcsFile->fixer->addContent($stackPtr, str_repeat(' ', $padding)); + + if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { + $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); + } + $phpcsFile->fixer->endChangeset(); } } else { diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc index 5ca71147fd..04cc1a3e3b 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc @@ -145,6 +145,12 @@ or indentation if there is code _after_ the removed empty tag. + + + - @@ -51,12 +51,12 @@ function test() foreach ($root->section as $section) { ?> - - + + + 1, 142 => 1, 145 => 1, + 151 => 1, ]; }//end getErrorList() From 9fbbe04f4166496965347e6f184fedcc4d326f20 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 24 Dec 2023 07:24:08 +0100 Subject: [PATCH 337/874] Squiz/EmbeddedPhp: closer on own line fixers should remove trailing spaces As things were, the "closer on own line" fixers would, in most cases, leave trailing whitespace behind. For most codebases, this means the sniff would always need to be run in conjunction with a sniff which removes trailing spaces and that there is always a second fixer round needed: the first to fix the embedded PHP formatting, the second to allow the other sniff to remove the trailing spaces introduced by the fixes made by this sniff. It also makes updating the test case file fiddly. Additionally, when the next token is inline HTML, it could lead to weird/incorrect indents, which would not be fixable via a sniff (as determining intended indent for inline HTML is non-trivial). This commit fixes the "closer on own line" fixers to remove trailing spaces and prevents them from affecting the indent of inline HTML unnecessarily. Covered by pre-existing tests + additional newly added tests. --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 19 +++++++++++++++- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc | 17 ++++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.inc.fixed | 22 ++++++++++++++++++- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 3 +++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 80a31d0ea6..493895fe3f 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -233,6 +233,11 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag if ($fix === true) { $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $closingTag, true); $phpcsFile->fixer->beginChangeset(); + + if ($tokens[($closingTag - 1)]['code'] === T_WHITESPACE) { + $phpcsFile->fixer->replaceToken(($closingTag - 1), ''); + } + $phpcsFile->fixer->addContentBefore($closingTag, str_repeat(' ', ($tokens[$first]['column'] - 1))); $phpcsFile->fixer->addNewlineBefore($closingTag); $phpcsFile->fixer->endChangeset(); @@ -245,8 +250,20 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->addNewline($closingTag); $phpcsFile->fixer->addContent($closingTag, str_repeat(' ', ($tokens[$first]['column'] - 1))); + + if ($tokens[$firstContentAfterBlock]['code'] === T_INLINE_HTML) { + $trimmedHtmlContent = ltrim($tokens[$firstContentAfterBlock]['content']); + if ($trimmedHtmlContent === '') { + // HTML token contains only whitespace and the next token after is PHP, not HTML, so remove the whitespace. + $phpcsFile->fixer->replaceToken($firstContentAfterBlock, ''); + } else { + // The HTML token has content, so remove leading whitespace in favour of the indent. + $phpcsFile->fixer->replaceToken($firstContentAfterBlock, $trimmedHtmlContent); + } + } + $phpcsFile->fixer->endChangeset(); - } + }//end if }//end if $next = $phpcsFile->findNext(T_OPEN_TAG, ($closingTag + 1)); diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc index 04cc1a3e3b..aad1d839af 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc @@ -151,6 +151,23 @@ Make sure the "content after opener" fixer does not leave trailing space behind. + + + + + + + + + + + + + + + + + + 1, 145 => 1, 151 => 1, + 158 => 1, + 165 => 1, + 169 => 1, ]; }//end getErrorList() From bac3be55f13f274ee752b278f70671fb2c3515fc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 24 Dec 2023 22:21:12 +0100 Subject: [PATCH 338/874] Squiz/EmbeddedPhp: bug fix - fixer adds stray new line When the close tag of a previous multi-line embedded PHP snippet and the open tag of the next multi-line embedded PHP snippet are on the same line, the sniff would add a stray blank line with trailing whitespace between the two tokens due to the fixers both running in the same loop. This commit adds a small tweak preventing this stray blank line from being added. Includes unit tests proving the issue and safeguarding the fix. --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 7 +++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc | 13 +++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.inc.fixed | 16 ++++++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 6 ++++++ 4 files changed, 42 insertions(+) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 493895fe3f..2baa7f7652 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -262,6 +262,13 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag } } + if ($tokens[$firstContentAfterBlock]['code'] === T_OPEN_TAG) { + // Next token is a PHP open tag which will also have thrown an error. + // Prevent both fixers running in the same loop by making sure the token is "touched" during this loop. + // This prevents a stray new line being added between the close and open tags. + $phpcsFile->fixer->replaceToken($firstContentAfterBlock, $tokens[$firstContentAfterBlock]['content']); + } + $phpcsFile->fixer->endChangeset(); }//end if }//end if diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc index aad1d839af..ddd25d477b 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc @@ -168,6 +168,19 @@ Make sure the "content after closer" fixer does not leave trailing space behind. echo $closerNeedsOwnLine; ?> + + + + + + + + + 1, 165 => 1, 169 => 1, + 175 => 1, + 176 => 2, + 178 => 1, + 179 => 1, + 180 => 2, + 181 => 1, ]; }//end getErrorList() From b166d65aa63a94a58c64995298692f1e6dd0bb09 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 23 Dec 2023 03:26:53 +0100 Subject: [PATCH 339/874] Squiz/EmbeddedPhp: rename test case file ... to allow for additional test case files to be added. --- ...UnitTest.inc => EmbeddedPhpUnitTest.1.inc} | 0 ....fixed => EmbeddedPhpUnitTest.1.inc.fixed} | 0 .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 112 ++++++++++-------- 3 files changed, 60 insertions(+), 52 deletions(-) rename src/Standards/Squiz/Tests/PHP/{EmbeddedPhpUnitTest.inc => EmbeddedPhpUnitTest.1.inc} (100%) rename src/Standards/Squiz/Tests/PHP/{EmbeddedPhpUnitTest.inc.fixed => EmbeddedPhpUnitTest.1.inc.fixed} (100%) diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc similarity index 100% rename from src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc rename to src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed similarity index 100% rename from src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed rename to src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php index edeccd66b2..bd439188d1 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php @@ -26,61 +26,69 @@ final class EmbeddedPhpUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 7 => 1, - 12 => 1, - 18 => 1, - 19 => 2, - 20 => 1, - 21 => 1, - 22 => 3, - 24 => 1, - 26 => 1, - 29 => 1, - 30 => 1, - 31 => 1, - 34 => 1, - 36 => 1, - 40 => 1, - 41 => 1, - 44 => 1, - 45 => 1, - 49 => 1, - 59 => 1, - 63 => 1, - 93 => 1, - 94 => 2, - 100 => 1, - 102 => 1, - 112 => 1, - 113 => 1, - 116 => 1, - 117 => 1, - 120 => 1, - 121 => 1, - 128 => 1, - 129 => 1, - 132 => 1, - 134 => 1, - 136 => 1, - 138 => 1, - 142 => 1, - 145 => 1, - 151 => 1, - 158 => 1, - 165 => 1, - 169 => 1, - 175 => 1, - 176 => 2, - 178 => 1, - 179 => 1, - 180 => 2, - 181 => 1, - ]; + switch ($testFile) { + case 'EmbeddedPhpUnitTest.1.inc': + return [ + 7 => 1, + 12 => 1, + 18 => 1, + 19 => 2, + 20 => 1, + 21 => 1, + 22 => 3, + 24 => 1, + 26 => 1, + 29 => 1, + 30 => 1, + 31 => 1, + 34 => 1, + 36 => 1, + 40 => 1, + 41 => 1, + 44 => 1, + 45 => 1, + 49 => 1, + 59 => 1, + 63 => 1, + 93 => 1, + 94 => 2, + 100 => 1, + 102 => 1, + 112 => 1, + 113 => 1, + 116 => 1, + 117 => 1, + 120 => 1, + 121 => 1, + 128 => 1, + 129 => 1, + 132 => 1, + 134 => 1, + 136 => 1, + 138 => 1, + 142 => 1, + 145 => 1, + 151 => 1, + 158 => 1, + 165 => 1, + 169 => 1, + 175 => 1, + 176 => 2, + 178 => 1, + 179 => 1, + 180 => 2, + 181 => 1, + ]; + + default: + return []; + }//end switch }//end getErrorList() From 1e64373a9243810ee360eb2559eb4f1b9c5978a5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 26 Dec 2023 07:52:36 +0100 Subject: [PATCH 340/874] Squiz/EmbeddedPhp: add tests safeguarding that single line embedded PHP blocks are never ignored The exception conditions for the first/last tag set only apply to multi-line PHP blocks and PHP blocks without a closing tag. Single-line embedded PHP with a complete set of tags should not be affected. This is already handled correctly. This commit just adds tests to safeguard this. --- src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc | 7 +++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed | 7 +++++++ src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 7 +++++++ 3 files changed, 21 insertions(+) create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc new file mode 100644 index 0000000000..444ad04389 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc @@ -0,0 +1,7 @@ + + + + diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed new file mode 100644 index 0000000000..4e064fa2e6 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed @@ -0,0 +1,7 @@ + + + + diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php index bd439188d1..7fee9e5b81 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php @@ -86,6 +86,13 @@ public function getErrorList($testFile='') 181 => 1, ]; + case 'EmbeddedPhpUnitTest.2.inc': + return [ + 5 => 2, + 6 => 2, + 7 => 2, + ]; + default: return []; }//end switch From 3172a21337e2fc09fb701bb73b032152d27ba25c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 24 Dec 2023 17:51:31 +0100 Subject: [PATCH 341/874] Squiz/EmbeddedPhp: sniff for short open tags As things were, the `Squiz.PHP.EmbeddedPhp` sniff would only check the formatting for code embedded using long PHP open tags, while short PHP open tags are pretty common for embedded PHP. This commit adds support for examining short PHP open tags to the sniff. Notes: * The error codes used are the same for both type of open tags, with one exception: for single line embedded statements, it is checked that there is a semi-colon at the end of the statement. The "statement" in an embedded snippet using short open tags may just be a single variable and in _some_ lines of thinking it is acceptable to leave out the semi-colon in that case. To accommodate this, the error code for the missing semi-colon differentiates between whether the statement uses long open tags `NoSemicolon` (same as before) or short open tags `ShortOpenEchoNoSemicolon`. This will allows for selectively excluding the `ShortOpenEchoNoSemicolon` error code. * I've considered enforcing that short open tags always are always used as a single-line statement, or adding an option to enforce this, but have decided against this at this time. After all, this sniff is about _consistent_ formatting, single line stays single line and multi-line is made consistently/properly multi-line. It could be considered future scope to add a separate sniff to enforce short open echo tag sets to always be single line when they only contain a single statement. Fixes 27 --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 42 ++++-- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc | 2 +- .../Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed | 2 +- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc | 2 +- .../Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed | 2 +- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.3.inc | 123 ++++++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.3.inc.fixed | 132 ++++++++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.4.inc | 7 + .../Tests/PHP/EmbeddedPhpUnitTest.4.inc.fixed | 7 + .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.5.inc | 48 +++++++ .../Tests/PHP/EmbeddedPhpUnitTest.5.inc.fixed | 39 ++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 58 ++++++++ 12 files changed, 450 insertions(+), 14 deletions(-) create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.3.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.3.inc.fixed create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.4.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.4.inc.fixed create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.5.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.5.inc.fixed diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 2baa7f7652..bd33821de0 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -24,7 +24,10 @@ class EmbeddedPhpSniff implements Sniff */ public function register() { - return [T_OPEN_TAG]; + return [ + T_OPEN_TAG, + T_OPEN_TAG_WITH_ECHO, + ]; }//end register() @@ -69,7 +72,7 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag { $tokens = $phpcsFile->getTokens(); - $prevTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)); + $prevTag = $phpcsFile->findPrevious($this->register(), ($stackPtr - 1)); if ($prevTag === false) { // This is the first open tag. return; @@ -262,7 +265,9 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag } } - if ($tokens[$firstContentAfterBlock]['code'] === T_OPEN_TAG) { + if ($tokens[$firstContentAfterBlock]['code'] === T_OPEN_TAG + || $tokens[$firstContentAfterBlock]['code'] === T_OPEN_TAG_WITH_ECHO + ) { // Next token is a PHP open tag which will also have thrown an error. // Prevent both fixers running in the same loop by making sure the token is "touched" during this loop. // This prevents a stray new line being added between the close and open tags. @@ -273,7 +278,7 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag }//end if }//end if - $next = $phpcsFile->findNext(T_OPEN_TAG, ($closingTag + 1)); + $next = $phpcsFile->findNext($this->register(), ($closingTag + 1)); if ($next === false) { return; } @@ -333,10 +338,14 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag) } // Check that there is one, and only one space at the start of the statement. - // The open tag token always contains a single space after it. - $leadingSpace = 1; + $leadingSpace = 0; + if ($tokens[$stackPtr]['code'] === T_OPEN_TAG) { + // The long open tag token in a single line tag set always contains a single space after it. + $leadingSpace = 1; + } + if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { - $leadingSpace = ($tokens[($stackPtr + 1)]['length'] + 1); + $leadingSpace += $tokens[($stackPtr + 1)]['length']; } if ($leadingSpace !== 1) { @@ -344,7 +353,15 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag) $data = [$leadingSpace]; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterOpen', $data); if ($fix === true) { - $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); + if ($tokens[$stackPtr]['code'] === T_OPEN_TAG) { + $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); + } else if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { + // Short open tag with too much whitespace. + $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); + } else { + // Short open tag without whitespace. + $phpcsFile->fixer->addContent($stackPtr, ' '); + } } } @@ -357,7 +374,12 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag) && $tokens[$prev]['code'] !== T_SEMICOLON ) { $error = 'Inline PHP statement must end with a semicolon'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSemicolon'); + $code = 'NoSemicolon'; + if ($tokens[$stackPtr]['code'] === T_OPEN_TAG_WITH_ECHO) { + $code = 'ShortOpenEchoNoSemicolon'; + } + + $fix = $phpcsFile->addFixableError($error, $stackPtr, $code); if ($fix === true) { $phpcsFile->fixer->addContent($prev, ';'); } @@ -374,7 +396,7 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag) $data = [$statementCount]; $phpcsFile->addError($error, $stackPtr, 'MultipleStatements', $data); } - } + }//end if }//end if $trailingSpace = 0; diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc index ddd25d477b..c28a650b1e 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc @@ -1,6 +1,6 @@ diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed index e6dabf5ccd..4c0a5cd0e4 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed @@ -1,6 +1,6 @@ diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc index 444ad04389..755fd355b5 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc @@ -1,5 +1,5 @@ diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed index 4e064fa2e6..e9073da915 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed @@ -1,5 +1,5 @@ diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.3.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.3.inc new file mode 100644 index 0000000000..2d608490a8 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.3.inc @@ -0,0 +1,123 @@ + + + +<?= $title ?> + + + + + hello + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// Safeguard fixing when there is no whitespace between the close tag and the contents. + + + + + + + + + +<?= $title; ?> + + + + + hello + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// Safeguard fixing when there is no whitespace between the close tag and the contents. + + + + + + + + + + + + + diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.4.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.4.inc.fixed new file mode 100644 index 0000000000..b7985cc508 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.4.inc.fixed @@ -0,0 +1,7 @@ + + + + diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.5.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.5.inc new file mode 100644 index 0000000000..f4d8d8a0c0 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.5.inc @@ -0,0 +1,48 @@ + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + 2, 6 => 2, 7 => 2, ]; + case 'EmbeddedPhpUnitTest.3.inc': + return [ + 10 => 1, + 15 => 1, + 21 => 1, + 22 => 2, + 23 => 1, + 24 => 1, + 25 => 3, + 28 => 1, + 29 => 1, + 30 => 1, + 33 => 1, + 35 => 1, + 39 => 1, + 40 => 1, + 43 => 1, + 44 => 1, + 48 => 1, + 53 => 1, + 55 => 1, + 61 => 1, + 62 => 1, + 65 => 2, + 66 => 2, + 69 => 1, + 70 => 1, + 75 => 1, + 82 => 1, + 89 => 1, + 93 => 1, + 98 => 2, + 99 => 1, + 103 => 2, + 105 => 1, + 111 => 1, + 112 => 2, + 114 => 1, + 115 => 1, + 116 => 2, + 117 => 1, + ]; + + case 'EmbeddedPhpUnitTest.5.inc': + return [ + 16 => 1, + 18 => 1, + 25 => 1, + 26 => 1, + 29 => 1, + 31 => 1, + 33 => 1, + 35 => 1, + 39 => 1, + 42 => 1, + ]; + default: return []; }//end switch From 36e1a8cb795ad98436a6a273d3d423f9649d1e2c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 00:25:30 +0100 Subject: [PATCH 342/874] Squiz/EmbeddedPhp: add dedicated tests related to ignoring of first open tag --- src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.6.inc | 8 ++++++++ src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.7.inc | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.6.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.7.inc diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.6.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.6.inc new file mode 100644 index 0000000000..72862b2433 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.6.inc @@ -0,0 +1,8 @@ + + + + + Date: Wed, 27 Dec 2023 00:48:28 +0100 Subject: [PATCH 343/874] Squiz/EmbeddedPhp: efficiency fix - bow out early if there is nothing to do No need to go through the rest of the logic for the multi-line PHP block handling if there is nothing to do for the sniff. --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 4 ++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.10.inc | 16 ++++++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.11.inc | 14 ++++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.8.inc | 10 ++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.9.inc | 10 ++++++++++ 5 files changed, 54 insertions(+) create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.10.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.11.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.8.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.9.inc diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index bd33821de0..9d9eb598ea 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -79,6 +79,10 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag } $firstContent = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($firstContent === false) { + // Unclosed PHP open tag at the end of a file. Nothing to do. + return; + } if ($closingTag !== false) { $firstContentAfterBlock = $phpcsFile->findNext(T_WHITESPACE, ($closingTag + 1), $phpcsFile->numTokens, true); diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.10.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.10.inc new file mode 100644 index 0000000000..4a00156fae --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.10.inc @@ -0,0 +1,16 @@ + + + + + + + + + Date: Wed, 27 Dec 2023 01:24:23 +0100 Subject: [PATCH 344/874] Squiz/EmbeddedPhp: document behaviour for unclosed tag block with content at end of file --- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.12.inc | 12 ++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.12.inc.fixed | 10 ++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.13.inc | 12 ++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.13.inc.fixed | 10 ++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 7 +++++++ 5 files changed, 51 insertions(+) create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.12.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.12.inc.fixed create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.13.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.13.inc.fixed diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.12.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.12.inc new file mode 100644 index 0000000000..7631141347 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.12.inc @@ -0,0 +1,12 @@ + + + + + + + + + 1, ]; + case 'EmbeddedPhpUnitTest.12.inc': + case 'EmbeddedPhpUnitTest.13.inc': + return [ + 10 => 1, + 12 => 1, + ]; + default: return []; }//end switch From f2c3f47bec75bd239e67b956ff418e774a930252 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 01:16:20 +0100 Subject: [PATCH 345/874] Squiz/EmbeddedPhp: document the behaviour for closed tag block at end of file [1] As things are, the last tag block in a file, at the end of a file, will always be ignored if it contains a PHP close tag, even when it would otherwise trigger errors. These tests document this behaviour. --- src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.14.inc | 8 ++++++++ src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.15.inc | 9 +++++++++ src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.16.inc | 8 ++++++++ src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.17.inc | 8 ++++++++ 4 files changed, 33 insertions(+) create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.14.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.15.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.16.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.17.inc diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.14.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.14.inc new file mode 100644 index 0000000000..aa17e34950 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.14.inc @@ -0,0 +1,8 @@ + + + diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.15.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.15.inc new file mode 100644 index 0000000000..d8f0512773 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.15.inc @@ -0,0 +1,9 @@ + + + + diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.16.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.16.inc new file mode 100644 index 0000000000..754c241b8e --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.16.inc @@ -0,0 +1,8 @@ + + + diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.17.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.17.inc new file mode 100644 index 0000000000..71de17bfb4 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.17.inc @@ -0,0 +1,8 @@ + + + From 1016d402eb2e2dc69401831529b5c57dada75ba6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 01:55:32 +0100 Subject: [PATCH 346/874] Squiz/EmbeddedPhp: document the behaviour for closed tag block at end of file [2] The last tag block in a file will **not** be ignored if it is followed by non-empty inline HTML. These tests document this behaviour. --- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc | 15 +++++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.18.inc.fixed | 13 +++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc | 17 +++++++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.19.inc.fixed | 15 +++++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc | 15 +++++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.20.inc.fixed | 16 ++++++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc | 15 +++++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed | 16 ++++++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 10 ++++++++++ 9 files changed, 132 insertions(+) create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc.fixed create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc.fixed create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc.fixed create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc new file mode 100644 index 0000000000..3d61d4859d --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc @@ -0,0 +1,15 @@ + + +
+ + +
+

Some more content after the last PHP tag block.

diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc.fixed new file mode 100644 index 0000000000..8c906d40c7 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc.fixed @@ -0,0 +1,13 @@ + + +
+ +
+

Some more content after the last PHP tag block.

diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc new file mode 100644 index 0000000000..34db64d605 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc @@ -0,0 +1,17 @@ + + +
+ + +
+

Some more content after the last PHP tag block.

diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc.fixed new file mode 100644 index 0000000000..b1738db57f --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc.fixed @@ -0,0 +1,15 @@ + + +
+ +
+

Some more content after the last PHP tag block.

diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc new file mode 100644 index 0000000000..28cdbdaf7a --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc @@ -0,0 +1,15 @@ + + +
+ + +
+

Some more content after the last PHP tag block.

diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc.fixed new file mode 100644 index 0000000000..44942e31fc --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc.fixed @@ -0,0 +1,16 @@ + + +
+ + +
+

Some more content after the last PHP tag block.

diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc new file mode 100644 index 0000000000..1da67a2ea7 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc @@ -0,0 +1,15 @@ + + +
+ + +
+

Some more content after the last PHP tag block.

diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed new file mode 100644 index 0000000000..aa3951edc0 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed @@ -0,0 +1,16 @@ + + +
+ + +
+

Some more content after the last PHP tag block.

diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php index 37cf55a255..d732bdc135 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php @@ -158,6 +158,16 @@ public function getErrorList($testFile='') 12 => 1, ]; + case 'EmbeddedPhpUnitTest.18.inc': + return [11 => 1]; + + case 'EmbeddedPhpUnitTest.19.inc': + return [13 => 1]; + + case 'EmbeddedPhpUnitTest.20.inc': + case 'EmbeddedPhpUnitTest.21.inc': + return [12 => 2]; + default: return []; }//end switch From e9e2011cf8a63c8689d728ee7090649f3622e63f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 02:24:13 +0100 Subject: [PATCH 347/874] Squiz/EmbeddedPhp: bug fix - closer on own line indent is not calculated correctly When the PHP close tag is on the same line as the first PHP content in a multi-line embedded PHP block and the indent of the first PHP content in the block is incorrect, the indent for the close tag when it is moved to its own line will be based on the (incorrect) indent of the first PHP content line and not on the corrected indent for the first PHP content, which the indent fixer uses. This commit fixes this. Covered by pre-existing tests and adjusting the "fixed" expectations for those. Additionally, an extra test has been added for the case when `$indent` is not pre-calculated (= when the first content in the block is a scope closer). --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 18 +++++++++++++++--- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc | 7 +++++++ .../Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed | 8 ++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.20.inc.fixed | 2 +- .../Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed | 2 +- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 1 + 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 9d9eb598ea..d51ec9559d 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -238,17 +238,29 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag $error = 'Closing PHP tag must be on a line by itself'; $fix = $phpcsFile->addFixableError($error, $closingTag, 'ContentBeforeEnd'); if ($fix === true) { - $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $closingTag, true); + // Calculate the indent for the close tag. + // If the close tag is on the same line as the first content, re-use the indent + // calculated for the first content line to prevent the indent being based on an + // "old" indent, not the _new_ (fixed) indent. + if ($tokens[$firstContent]['line'] === $tokens[$lastContent]['line'] + && isset($indent) === true + ) { + $closerIndent = $indent; + } else { + $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $closingTag, true); + $closerIndent = ($tokens[$first]['column'] - 1); + } + $phpcsFile->fixer->beginChangeset(); if ($tokens[($closingTag - 1)]['code'] === T_WHITESPACE) { $phpcsFile->fixer->replaceToken(($closingTag - 1), ''); } - $phpcsFile->fixer->addContentBefore($closingTag, str_repeat(' ', ($tokens[$first]['column'] - 1))); + $phpcsFile->fixer->addContentBefore($closingTag, str_repeat(' ', $closerIndent)); $phpcsFile->fixer->addNewlineBefore($closingTag); $phpcsFile->fixer->endChangeset(); - } + }//end if } else if ($tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line']) { $error = 'Closing PHP tag must be on a line by itself'; $fix = $phpcsFile->addFixableError($error, $closingTag, 'ContentAfterEnd'); diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc index c28a650b1e..9603641908 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc @@ -181,6 +181,13 @@ Make sure the fixer does not add stray new lines when there are consecutive PHP echo 'embedded'; ?> + + + + + + + + +?>

Some more content after the last PHP tag block.

diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed index aa3951edc0..d7487b507d 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed @@ -10,7 +10,7 @@ as long as it is followed by non-empty inline HTML.
+?>

Some more content after the last PHP tag block.

diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php index d732bdc135..f51b6f7e59 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php @@ -84,6 +84,7 @@ public function getErrorList($testFile='') 179 => 1, 180 => 2, 181 => 1, + 189 => 1, ]; case 'EmbeddedPhpUnitTest.2.inc': From efb9e441d726bdf0c7a6981282b877bdd5911fd8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 03:46:45 +0100 Subject: [PATCH 348/874] Squiz/EmbeddedPhp: add test safeguarding handling of blank lines and scope closers --- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc | 11 +++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc index 9603641908..0938f70242 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc @@ -188,6 +188,17 @@ Safeguard closing tag indent calculation for when the last content on the close + + +
+ + + + + + + Date: Wed, 27 Dec 2023 04:55:59 +0100 Subject: [PATCH 349/874] Squiz/EmbeddedPhp: bug fix - content intended indent calculation The intended content indent calculation contained a pretty nasty bug, though it is unlikely to have been hit much in real code bases. What was happening: * The sniff would try to find the first whitespace token on the line containing the stack pointer. If found, the size of the whitespace was taken as the required indent. This part was working correctly. * If no whitespace token was found, the sniff would try and find the first inline HTML token. If an inline HTML token was found, the leading whitespace in the inline HTML token was taken as the indent. This, again, is correct. * However, now it gets iffy... what if no whitespace or inline HTML token was found on the line containing the open tag ? I.e. the situation where the open tag _is_ the first token on the line. This situation was not accounted for by the sniff. The `File::findFirstOnLine()` method would return `false` in that case, which means that the indent calculation would end up like this: ```php $indent = (strlen($tokens[false]['content']) - strlen(ltrim($tokens[false]['content']))); ``` Now, `false` is not a valid array key, so this would end up being juggled to `0`, meaning the length of the leading whitespace for the first token in the **file** was being used. Fixed now. Includes various additional unit tests safeguarding the fix and one (in a separate file) demonstrating the situation where the bug would have had a real life impact. --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 9 +++-- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc | 29 ++++++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed | 33 +++++++++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.22.inc | 20 +++++++++++ .../PHP/EmbeddedPhpUnitTest.22.inc.fixed | 20 +++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 11 +++++++ 6 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.22.inc create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.22.inc.fixed diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index d51ec9559d..c88864f360 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -147,10 +147,13 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag } }//end if - $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr); + $indent = 0; + $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr); if ($first === false) { - $first = $phpcsFile->findFirstOnLine(T_INLINE_HTML, $stackPtr); - $indent = (strlen($tokens[$first]['content']) - strlen(ltrim($tokens[$first]['content']))); + $first = $phpcsFile->findFirstOnLine(T_INLINE_HTML, $stackPtr); + if ($first !== false) { + $indent = (strlen($tokens[$first]['content']) - strlen(ltrim($tokens[$first]['content']))); + } } else { $indent = ($tokens[($first + 1)]['column'] - 1); } diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc index 0938f70242..ddf0c6c918 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc @@ -199,6 +199,35 @@ Safeguard that blank lines between a PHP tag and a scope closer are not touched } ?> + + + + +
+ + + + +
+ + + + + +
+ + + + + + +
+ + + Inline HTML with indent to demonstrate the bug in the indent calculation.
+ + + + + +Inline HTML with indent to demonstrate the bug in the indent calculation.
+ + + + + + 2, 181 => 1, 189 => 1, + 212 => 1, + 214 => 2, + 219 => 1, + 223 => 1, + 225 => 1, + 226 => 1, + 227 => 2, + 228 => 1, ]; case 'EmbeddedPhpUnitTest.2.inc': @@ -169,6 +177,9 @@ public function getErrorList($testFile='') case 'EmbeddedPhpUnitTest.21.inc': return [12 => 2]; + case 'EmbeddedPhpUnitTest.22.inc': + return [14 => 1]; + default: return []; }//end switch From d1c63af4ef181eb491a282d724c2698e5d270bfb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 05:29:20 +0100 Subject: [PATCH 350/874] Squiz/EmbeddedPhp: bug fix - open tag on own line intended indent calculation Basically, this is the same bug as fixed in a previous commit for the intended content indent calculation. The indentation of the first token in the file would be used to calculate the intended indentation, instead of the indentation for the first token on the line containing the PHP open tag. Fixed now, includes test. Note: The only reason the test doesn't actually show the bug is because of the earlier "fixer adds stray new line" bugfix in this PR, which means that the fixer for the previous close tag will prevent the buggy fixer from running. Without _that_ fix, this bug would be visible when running with `-vvv` (indent would get set to 32 and then corrected to 4 on the next fixer round via the `OpenTagIndent` fixer). --- src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 9 ++++++--- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.22.inc | 10 ++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.22.inc.fixed | 11 +++++++++++ src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 5 ++++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index c88864f360..99ff3968db 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -185,10 +185,13 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag $error = 'Opening PHP tag must be on a line by itself'; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'ContentBeforeOpen'); if ($fix === true) { - $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr); + $padding = 0; + $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr); if ($first === false) { - $first = $phpcsFile->findFirstOnLine(T_INLINE_HTML, $stackPtr); - $padding = (strlen($tokens[$first]['content']) - strlen(ltrim($tokens[$first]['content']))); + $first = $phpcsFile->findFirstOnLine(T_INLINE_HTML, $stackPtr); + if ($first !== false) { + $padding = (strlen($tokens[$first]['content']) - strlen(ltrim($tokens[$first]['content']))); + } } else { $padding = ($tokens[($first + 1)]['column'] - 1); } diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.22.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.22.inc index 8d08da0313..5196a3b45b 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.22.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.22.inc @@ -14,6 +14,16 @@ echo 'indent is correct - first on line for open tag is open tag'; echo 'indent is incorrect - first on line for open tag is inline HTML'; ?> + + + + + + + 2]; case 'EmbeddedPhpUnitTest.22.inc': - return [14 => 1]; + return [ + 14 => 1, + 22 => 2, + ]; default: return []; From b4c16825d2454ed5d832d8de22ce7c9c4b85bc0f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 07:57:56 +0100 Subject: [PATCH 351/874] Squiz/EmbeddedPhp: bug fix - close tag intended indent calculation Yet another indentation calculation bug. If the close tag is not on its own line, but is on a line containing a subsequent line of a star-slash style comment, the indentation would not be calculated correctly as the comment token will include the indentation. Fixed now, includes test. --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 11 ++++++++++- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc | 12 ++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed | 14 ++++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 2 ++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 99ff3968db..99e9e94e98 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -253,7 +253,16 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag ) { $closerIndent = $indent; } else { - $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $closingTag, true); + $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $closingTag, true); + + while ($tokens[$first]['code'] === T_COMMENT + && $tokens[$first]['content'] !== ltrim($tokens[$first]['content']) + ) { + // This is a subsequent line in a star-slash comment containing leading indent. + // We'll need the first line of the comment to correctly determine the indent. + $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, ($first - 1), true); + } + $closerIndent = ($tokens[$first]['column'] - 1); } diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc index ddf0c6c918..f2be4f7bce 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc @@ -228,6 +228,18 @@ echo 'indent is correct - first on line for open tag is open tag'; echo 'indent is incorrect - first on line for open tag is whitespace'; ?> + + + + + + + + + + 1, 227 => 2, 228 => 1, + 235 => 1, + 241 => 1, ]; case 'EmbeddedPhpUnitTest.2.inc': From 46f710263ddb7cd7e857be79b5216aa71fefb196 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 08:08:46 +0100 Subject: [PATCH 352/874] Squiz/EmbeddedPhp: bug fix - open tag intended indent calculation Basically, this is the same bug as fixed in a previous commit for the intended close tag indent calculation. If the first token on the line before the open tag would be a subsequent line for a star-slash comment, the indentation would not be calculated correctly, but would always be set to `0`, even when there was indentation. Fixed now, includes test. --- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 10 ++++++- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc | 25 ++++++++++++++++ .../Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed | 29 +++++++++++++++++++ .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 5 ++++ 4 files changed, 68 insertions(+), 1 deletion(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 99e9e94e98..be75265917 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -200,11 +200,19 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag } } else { // Find the first token on the first non-empty line we find. - for ($first = ($stackPtr - 1); $first > 0; $first--) { + for ($first = ($lastContentBeforeBlock - 1); $first > 0; $first--) { if ($tokens[$first]['line'] === $tokens[$stackPtr]['line']) { continue; } else if (trim($tokens[$first]['content']) !== '') { $first = $phpcsFile->findFirstOnLine([], $first, true); + if ($tokens[$first]['code'] === T_COMMENT + && $tokens[$first]['content'] !== ltrim($tokens[$first]['content']) + ) { + // This is a subsequent line in a star-slash comment containing leading indent. + // We'll need the first line of the comment to correctly determine the indent. + continue; + } + break; } } diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc index f2be4f7bce..f28c559894 100644 --- a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc @@ -240,6 +240,31 @@ Safeguard correct close tag indent calculation. This means the calculated indent would be 0 unless we walk to the first line in the comment. */ ?> + + + + + + + + + + + + + + 1, 235 => 1, 241 => 1, + 248 => 1, + 253 => 1, + 258 => 1, + 263 => 1, + 264 => 1, ]; case 'EmbeddedPhpUnitTest.2.inc': From ac5fd07fa2db2335fd739e19c34e39ad923bc758 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 10:54:43 +0100 Subject: [PATCH 353/874] Squiz/EmbeddedPhp: add some extra defensive coding `$firstContentAfterBlock` should not be able to be `false` at this point as it is already checked and handled at the top of the function, but better to be safe than sorry. --- src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index be75265917..0be6118e43 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -284,7 +284,9 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag $phpcsFile->fixer->addNewlineBefore($closingTag); $phpcsFile->fixer->endChangeset(); }//end if - } else if ($tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line']) { + } else if ($firstContentAfterBlock !== false + && $tokens[$firstContentAfterBlock]['line'] === $tokens[$closingTag]['line'] + ) { $error = 'Closing PHP tag must be on a line by itself'; $fix = $phpcsFile->addFixableError($error, $closingTag, 'ContentAfterEnd'); if ($fix === true) { From 50ae189f4bf6375e3fc5d67198d55d3b9639b464 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Dec 2023 11:20:21 +0100 Subject: [PATCH 354/874] Squiz/EmbeddedPhp: document the behaviour for closed tag block at end of file [3] While the last tag block in a file will **not** be ignored if it is followed by non-empty inline HTML, the "blank lines before the close tag" check _will_ be ignored if this is the last embedded PHP block. This test documents this behaviour. --- .../Tests/PHP/EmbeddedPhpUnitTest.23.inc | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.23.inc diff --git a/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.23.inc b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.23.inc new file mode 100644 index 0000000000..6642ef6b63 --- /dev/null +++ b/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.23.inc @@ -0,0 +1,23 @@ + + +
+ + +
+

Some more content after the last PHP tag block.

From 0f18ec6ac721543075be00dbe8809b56d3254e9e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 15 Jan 2024 11:26:40 +0100 Subject: [PATCH 355/874] Soft deprecate all sniffs which are to be removed in PHPCS 4.0 The deprecation of these sniffs was previously already announced in: * CSS/JS specific sniffs: https://github.com/squizlabs/PHP_CodeSniffer/issues/2448 * MySource standard: https://github.com/squizlabs/PHP_CodeSniffer/issues/2471 This commit _soft_ deprecates these sniffs with a `@deprecated` annotation. This will get a mention in the changelog. Hard deprecation will follow in a future 3.x minor as per 188. --- src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php | 2 ++ src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php | 2 ++ src/Standards/Generic/Sniffs/Debug/ESLintSniff.php | 2 ++ src/Standards/Generic/Sniffs/Debug/JSHintSniff.php | 2 ++ .../MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php | 2 ++ .../MySource/Sniffs/Channels/DisallowSelfActionsSniff.php | 2 ++ .../MySource/Sniffs/Channels/IncludeOwnSystemSniff.php | 2 ++ src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php | 2 ++ src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php | 2 ++ .../MySource/Sniffs/Commenting/FunctionCommentSniff.php | 2 ++ src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php | 2 ++ src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php | 2 ++ src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php | 2 ++ .../MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php | 2 ++ .../MySource/Sniffs/Objects/DisallowNewWidgetSniff.php | 2 ++ src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php | 2 ++ src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php | 2 ++ src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php | 2 ++ src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php | 2 ++ src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php | 2 ++ .../Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php | 2 ++ .../Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php | 2 ++ .../Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php | 2 ++ .../Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php | 2 ++ .../Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php | 2 ++ .../Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php | 2 ++ .../Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php | 2 ++ src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php | 2 ++ src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php | 2 ++ src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php | 2 ++ src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php | 2 ++ .../Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php | 2 ++ src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php | 2 ++ .../Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php | 2 ++ .../Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php | 2 ++ 45 files changed, 90 insertions(+) diff --git a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php index 24028e5cfc..2e4b251926 100644 --- a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php @@ -5,6 +5,8 @@ * @author Roman Levishchenko * @copyright 2013-2014 Roman Levishchenko * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; diff --git a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php index 8b4798388b..6a90533a98 100644 --- a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; diff --git a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php index 004054dee8..e62e6856cd 100644 --- a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php @@ -5,6 +5,8 @@ * @author Ryan McCue * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; diff --git a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php index 1461d57417..5af7f772a5 100644 --- a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php +++ b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php @@ -6,6 +6,8 @@ * @author Alexander Wei§ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; diff --git a/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php b/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php index 9d02672d16..904769e120 100644 --- a/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php +++ b/src/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\CSS; diff --git a/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php b/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php index 241104d098..91004a84d0 100644 --- a/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Channels; diff --git a/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php index 2ff91c974f..83bb5ff319 100644 --- a/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Channels; diff --git a/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php index 85d7f765a6..063dab4a86 100644 --- a/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Channels; diff --git a/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php b/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php index 7f96051097..0f20f70b9e 100644 --- a/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php +++ b/src/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Channels; diff --git a/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php index d5f09b6f74..da00c903f6 100644 --- a/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php @@ -7,6 +7,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Commenting; diff --git a/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php b/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php index 1ae6ba30e1..d40e064e8b 100644 --- a/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php +++ b/src/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Debug; diff --git a/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php b/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php index 77b86669ac..1f56a0e280 100644 --- a/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php +++ b/src/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Debug; diff --git a/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php b/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php index a126dce363..97732872c7 100644 --- a/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/AssignThisSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Objects; diff --git a/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php b/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php index 25e48dc7bd..5d8dc99687 100644 --- a/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Objects; diff --git a/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php b/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php index ecb57e5320..693a03714c 100644 --- a/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php +++ b/src/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Objects; diff --git a/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php b/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php index 71c31da3be..06c2512717 100644 --- a/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php @@ -8,6 +8,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\PHP; diff --git a/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php b/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php index 3b775aff7d..6684691f3c 100644 --- a/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php +++ b/src/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\PHP; diff --git a/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php b/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php index bdb3452775..a076779685 100644 --- a/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\PHP; diff --git a/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php b/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php index 1696837e26..697e91dc7e 100644 --- a/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php +++ b/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\PHP; diff --git a/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php b/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php index 968873e7b8..ee527b41be 100644 --- a/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php +++ b/src/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\MySource\Sniffs\Strings; diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php index fb147582fa..384a8f2b86 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php index 7ed872fea3..796bbbaa1a 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php index 0b84fa6262..7750fa1de5 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php index 07b6088679..6459e035c5 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php index 0f9131e7a2..5114a0cb03 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php b/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php index ddea31403d..72448a30b3 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php index b1c81bd613..82a974c8a0 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php index 97ad572ca2..e9221470ea 100644 --- a/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php index e641ed20d6..b7671d3e44 100644 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php index 816bb9b7cb..cc3007f2e4 100644 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php b/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php index b6955961f7..982f469705 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php b/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php index 427468ce19..56406ccb38 100644 --- a/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php index 509e9866b0..c8393c51c3 100644 --- a/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php b/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php index a9ca371ca2..83f2a6c822 100644 --- a/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php b/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php index 9322ef89ec..586b4730a5 100644 --- a/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php b/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php index e2a3e8dd9e..0c1c553a56 100644 --- a/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php index ef9d238c66..d51431bfc1 100644 --- a/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php b/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php index b59c27963d..76e7330c71 100644 --- a/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; diff --git a/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php b/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php index 0493b774eb..12d8a24561 100644 --- a/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes; diff --git a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php index 012a6a3c1f..30b3071d71 100644 --- a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php +++ b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug; diff --git a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php index e055cc1dd8..eb2b294559 100644 --- a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php +++ b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug; diff --git a/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php b/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php index 7bd14ebd1b..b619924e8c 100644 --- a/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php @@ -5,6 +5,8 @@ * @author Sertan Danis * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects; diff --git a/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php b/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php index 04bd5d1861..dbbc1b842a 100644 --- a/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php index b785f5431a..c4faf158b2 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.3.0 Use the Generic.WhiteSpace.LanguageConstructSpacing sniff instead. */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php index a41f787806..ec8218fef1 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php @@ -5,6 +5,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; From 829d3d9745bcc257ae4b2e7a37663e7984c839a6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 15 Jan 2024 11:37:17 +0100 Subject: [PATCH 356/874] Zend.Debug.CodeAnalyzer: soft deprecate the sniff See 58. This commit _soft_ deprecates the sniffs with a `@deprecated` annotation. This will get a mention in the changelog. Hard deprecation will follow in a future 3.x minor as per 188. --- src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php b/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php index ffbab028b4..7bf1f0ad0a 100644 --- a/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php +++ b/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php @@ -6,6 +6,8 @@ * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * + * @deprecated 3.9.0 */ namespace PHP_CodeSniffer\Standards\Zend\Sniffs\Debug; From b03d10fc5a68504e3ea28fc84651b92cb0252fd9 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Sun, 21 Jan 2024 23:36:17 -0300 Subject: [PATCH 357/874] Changelog: add links to all issues in the 3.6.0 section (#286) Includes fixing some typos in the 3.6.0 section of the changelog --- CHANGELOG.md | 67 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70c3a4949a..862cca4163 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -599,7 +599,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Added support for PHP 8.0 dereferencing of text strings with interpolated variables - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added support for PHP 8.0 match expressions - - Match expressions are now tokenised with parenthesis and scope openers and closers + - Match expressions are now tokenized with parenthesis and scope openers and closers - Sniffs can listen for the T_MATCH token to process match expressions - Note that the case and default statements inside match expressions do not have scopes set - A new T_MATCH_ARROW token is available to represent the arrows in match expressions @@ -674,7 +674,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - PSR2.ControlStructures.SwitchDeclaration now supports nested switch statements where every branch terminates - Previously, if a CASE only contained a SWITCH and no direct terminating statement, a fall-through error was displayed - - Now, the error is surpressed if every branch of the SWITCH has a terminating statement + - Now, the error is suppressed if every branch of the SWITCH has a terminating statement - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - The PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket error message is now reported on the closing parenthesis token - Previously, the error was being reported on the function keyword, leading to confusing line numbers in the error report @@ -698,33 +698,54 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Sniff no longer errors for assignments on first line of closure - Sniff no longer errors for assignments after a goto label - Thanks to [Jaroslav Hanslík][@kukulich] for the patch -- Fixed bug #2913 : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional -- Fixed bug #2992 : Enabling caching using a ruleset produces invalid cache files when using --sniffs and --exclude CLI args -- Fixed bug #3003 : Squiz.Formatting.OperatorBracket autofix incorrect when assignment used with null coalescing operator -- Fixed bug #3145 : Autoloading of sniff fails when multiple classes declared in same file -- Fixed bug #3157 : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented -- Fixed bug #3163 : Undefined index error with pre-commit hook using husky on PHP 7.4 +- Fixed bug [#2913] : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional +- Fixed bug [#2992] : Enabling caching using a ruleset produces invalid cache files when using --sniffs and --exclude CLI args +- Fixed bug [#3003] : Squiz.Formatting.OperatorBracket autofix incorrect when assignment used with null coalescing operator +- Fixed bug [#3145] : Autoloading of sniff fails when multiple classes declared in same file +- Fixed bug [#3157] : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented +- Fixed bug [#3163] : Undefined index error with pre-commit hook using husky on PHP 7.4 - Thanks to [Ismo Vuorinen][@ivuorinen] for the patch -- Fixed bug #3165 : Squiz.PHP.DisallowComparisonAssignment false positive when comparison inside closure -- Fixed bug #3167 : Generic.WhiteSpace.ScopeIndent false positive when using PHP 8.0 constructor property promotion -- Fixed bug #3170 : Squiz.WhiteSpace.OperatorSpacing false positive when using negation with string concat +- Fixed bug [#3165] : Squiz.PHP.DisallowComparisonAssignment false positive when comparison inside closure +- Fixed bug [#3167] : Generic.WhiteSpace.ScopeIndent false positive when using PHP 8.0 constructor property promotion +- Fixed bug [#3170] : Squiz.WhiteSpace.OperatorSpacing false positive when using negation with string concat - This also fixes the same issue in the PSR12.Operators.OperatorSpacing sniff -- Fixed bug #3177 : Incorrect tokenization of GOTO statements in mixed PHP/HTML files +- Fixed bug [#3177] : Incorrect tokenization of GOTO statements in mixed PHP/HTML files - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3184 : PSR2.Namespace.NamespaceDeclaration false positive on namespace operator +- Fixed bug [#3184] : PSR2.Namespace.NamespaceDeclaration false positive on namespace operator - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3188 : Squiz.WhiteSpace.ScopeKeywordSpacing false positive for static return type +- Fixed bug [#3188] : Squiz.WhiteSpace.ScopeKeywordSpacing false positive for static return type - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3192 : findStartOfStatement doesn't work correctly inside switch +- Fixed bug [#3192] : findStartOfStatement doesn't work correctly inside switch - Thanks to [Vincent Langlet][@VincentLanglet] for the patch -- Fixed bug #3195 : Generic.WhiteSpace.ScopeIndent confusing message when combination of tabs and spaces found -- Fixed bug #3197 : Squiz.NamingConventions.ValidVariableName does not use correct error code for all member vars -- Fixed bug #3219 : Generic.Formatting.MultipleStatementAlignment false positive for empty anonymous classes and closures -- Fixed bug #3258 : Squiz.Formatting.OperatorBracket duplicate error messages for unary minus - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3273 : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis -- Fixed bug #3277 : Nullable static return typehint causes whitespace error -- Fixed bug #3284 : Unused parameter false positive when using array index in arrow function +- Fixed bug [#3195] : Generic.WhiteSpace.ScopeIndent confusing message when combination of tabs and spaces found +- Fixed bug [#3197] : Squiz.NamingConventions.ValidVariableName does not use correct error code for all member vars +- Fixed bug [#3219] : Generic.Formatting.MultipleStatementAlignment false positive for empty anonymous classes and closures +- Fixed bug [#3258] : Squiz.Formatting.OperatorBracket duplicate error messages for unary minus + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#3273] : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis +- Fixed bug [#3277] : Nullable static return typehint causes whitespace error +- Fixed bug [#3284] : Unused parameter false positive when using array index in arrow function + +[#2913]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2913 +[#2992]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2992 +[#3003]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3003 +[#3145]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3145 +[#3157]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3157 +[#3163]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3163 +[#3165]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3165 +[#3167]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3167 +[#3170]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3170 +[#3177]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3177 +[#3184]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3184 +[#3188]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3188 +[#3192]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3192 +[#3195]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3195 +[#3197]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3197 +[#3219]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3219 +[#3258]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3258 +[#3273]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3273 +[#3277]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3277 +[#3284]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3284 ## [3.5.8] - 2020-10-23 ### Removed From a30addb3be25b09c60663a7822ceb4bf98127020 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 19 Jan 2024 10:42:35 -0300 Subject: [PATCH 358/874] Generic/IncrementDecrementSpacing: fix post-decrement error message This commit fixes the post-decrement error message when there is one or more newlines between the variable and the post-decrement operator. The wrong variable was being used to check whether the post-decrement and the variable were not on the same line, resulting in an incorrect error message. The error message should explicitly say that a newline was found. Before this commit the error message was: ``` Expected no spaces between $i and the decrement operator; 0 found ``` Now it is: ``` Expected no spaces between the decrement operator and $i; newline found ``` (`newline` instead of `0`) This commit also includes a test that exercises the modified line. --- .../Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php | 2 +- .../Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc | 3 +++ .../WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed | 2 ++ .../Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php index 60ea79ec53..25ba00153f 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php @@ -135,7 +135,7 @@ public function process(File $phpcsFile, $stackPtr) $fixable = false; $spaces = 'comment'; } else { - if ($tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']) { + if ($tokens[$stackPtr]['line'] !== $tokens[$prevNonEmpty]['line']) { $spaces = 'newline'; } else { $spaces = $tokens[($stackPtr - 1)]['length']; diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc index b674466b1d..79a046f5a1 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc @@ -35,3 +35,6 @@ $obj->prop['key'] ++; --ClassName::$prop; -- ClassName::$prop; + +getObject()->count +++; diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed index 1049e7e043..299d40ae03 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed @@ -34,3 +34,5 @@ $obj->prop['key']++; --ClassName::$prop; --ClassName::$prop; + +getObject()->count++; diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php index e6fee9b962..17dbbee0b9 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php @@ -53,6 +53,7 @@ public function getErrorList($testFile='') $errors[31] = 1; $errors[34] = 1; $errors[37] = 1; + $errors[40] = 1; return $errors; From 4607a26fc386cc15a6aa5cbc6b98791c72d20e3e Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 22 Jan 2024 09:50:33 -0300 Subject: [PATCH 359/874] Generic/IncrementDecrementSpacing: improve test coverage Adds tests using pre/post-incrementors with an object property accessed through a method call. --- .../Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc | 3 +++ .../WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed | 3 +++ .../Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php | 1 + 3 files changed, 7 insertions(+) diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc index 79a046f5a1..535053b0d0 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc @@ -38,3 +38,6 @@ $obj->prop['key'] ++; getObject()->count ++; +getObject()->count++; +++ getObject()->count; +++getObject()->count; diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed index 299d40ae03..c30332b25e 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.inc.fixed @@ -36,3 +36,6 @@ $obj->prop['key']++; --ClassName::$prop; getObject()->count++; +getObject()->count++; +++getObject()->count; +++getObject()->count; diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php index 17dbbee0b9..91e349338d 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php @@ -54,6 +54,7 @@ public function getErrorList($testFile='') $errors[34] = 1; $errors[37] = 1; $errors[40] = 1; + $errors[42] = 1; return $errors; From e3dcefeb8037ffe90e637c9fdddf32b4c4b917ac Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 4 Jan 2024 16:32:14 -0300 Subject: [PATCH 360/874] Generic/ForLoopWithTestFunctionCall: rename test case file Doing this to create more test case files in subsequent commits. --- ...> ForLoopWithTestFunctionCallUnitTest.1.inc} | 0 .../ForLoopWithTestFunctionCallUnitTest.php | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) rename src/Standards/Generic/Tests/CodeAnalysis/{ForLoopWithTestFunctionCallUnitTest.inc => ForLoopWithTestFunctionCallUnitTest.1.inc} (100%) diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc rename to src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php index a82dcfeb27..06c99c682f 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.php @@ -41,14 +41,21 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the test file being tested. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return [ - 4 => 1, - 13 => 1, - ]; + switch ($testFile) { + case 'ForLoopWithTestFunctionCallUnitTest.1.inc': + return [ + 4 => 1, + 13 => 1, + ]; + default: + return []; + } }//end getWarningList() From 6e61c8520f648dadbe901d658dcdd156b6a8e46e Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 4 Jan 2024 16:46:55 -0300 Subject: [PATCH 361/874] Generic/ForLoopWithTestFunctionCall: improve test coverage This commit adds more test cases related to the Generic/ForLoopWithTestFunctionCall sniff including test cases for the alternative for syntax, more types of function calls in the test part of the for loop and a test case to check defensive code when the for loop doesn't have a opening parenthesis. --- .../ForLoopWithTestFunctionCallUnitTest.1.inc | 82 ++++++++++++++++++- .../ForLoopWithTestFunctionCallUnitTest.2.inc | 5 ++ .../ForLoopWithTestFunctionCallUnitTest.php | 14 +++- 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.2.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.1.inc b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.1.inc index ef51b5a1ed..31f1a64199 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.1.inc +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.1.inc @@ -12,4 +12,84 @@ for ($i = 0, $c = sizeof($a); $i < $c; ++$i) { $it = new ArrayIterator($a); for ($it->rewind(); $it->valid(); $it->next()) { echo $it->current(); -} \ No newline at end of file +} + +for ($i = 0; MyClass::staticMethod($value); $i++) { + echo $i; +} + +for ($i = 0; $countFunction($value); $i++) { + echo $i; +} + +$a = array(1, 2, 3, 4); +for ($i = 0; $i < count($a); $i++): + $a[$i] *= $i; +endfor; + +for ($i = 0, $c = sizeof($a); $i < $c; ++$i): + $a[$i] *= $i; +endfor; + +$it = new ArrayIterator($a); +for ($it->rewind(); $it->valid(); $it->next()): + echo $it->current(); +endfor; + +for ($i = 0; MyClass::staticMethod($value); $i++) : + echo $i; +endfor; + +for ($i = 0; $countFunction($value); $i++): + echo $i; +endfor; + +for ($i = 0; (new MyClass)->method(); $i++) { +} + +for (; $i < 10; ++$i) {} + +for (; count($a); ++$i) {} + +for ($i = 0;; ++$i) {} + +for ($i = 0; $i < 10;) {} + +for ($i = 0; count($a);) {} + +for (;; $i++) {} + +for ($i = 0;;) {} + +for (;;) {} + +for ($i = 0; (new MyClass)->method(); $i++): +endfor; + +for (; $i < 10; ++$i) : +endfor; + +for (; count($a); ++$i) : +endfor; + +for ($i = 0;; ++$i) : +endfor; + +for ($i = 0; $i < 10;) : +endfor; + +for ($i = 0; count($a);) : +endfor; + +for (;; $i++) : +endfor; + +for ($i = 0;;) : +endfor; + +for (;;) : +endfor; + +for ($i = 0; $i < 10; $i = increment($i)) {} + +for ($i = initialValue(); $i < 10; $i = increment($i)) {} diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.2.inc b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.2.inc new file mode 100644 index 0000000000..54ef0a522b --- /dev/null +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.2.inc @@ -0,0 +1,5 @@ + 1, 13 => 1, + 17 => 1, + 21 => 1, + 26 => 1, + 35 => 1, + 39 => 1, + 43 => 1, + 47 => 1, + 52 => 1, + 58 => 1, + 66 => 1, + 72 => 1, + 81 => 1, ]; default: return []; - } + }//end switch }//end getWarningList() From 837e602af87641c2ba7685b7fea942bfad57bb80 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 5 Jan 2024 10:51:14 -0300 Subject: [PATCH 362/874] Generic/ForLoopWithTestFunctionCall: fix E_DEPRECATED error This commit fixes an issue in the sniff that could result in the following E_DEPRECATED error when running PHP 8.3: ``` Decrement on type null has no effect, this will change in the next major version of PHP src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCall.php:69 ``` This sniff relies on finding the position of the open and closing parentheses for a given `for` loop. However, the problem was that there was no defensive code for cases when the closing parenthesis is missing. The sniff would still work when running PHP >= 8.2, but on PHP 8.3 it would throw the deprecated message above. This would happen because since there is no closing parenthesis `$end` is set to null, and $next <= $end always evaluates to false (https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/84acf4e56f110db8e75cb9a575c5727df637643c/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php#L73). The issue was fixed by bailing early if the closing parenthesis is missing. A test with a `for` loop without the closing parenthesis was added. --- .../CodeAnalysis/ForLoopWithTestFunctionCallSniff.php | 2 +- .../CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.3.inc | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.3.inc diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php index 45b4f7306f..84ed101745 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php @@ -61,7 +61,7 @@ public function process(File $phpcsFile, $stackPtr) $token = $tokens[$stackPtr]; // Skip invalid statement. - if (isset($token['parenthesis_opener']) === false) { + if (isset($token['parenthesis_opener'], $token['parenthesis_closer']) === false) { return; } diff --git a/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.3.inc b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.3.inc new file mode 100644 index 0000000000..8bc6904e3d --- /dev/null +++ b/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.3.inc @@ -0,0 +1,6 @@ + Date: Wed, 17 Jan 2024 20:18:53 +0100 Subject: [PATCH 363/874] Generic/ForLoopWithTestFunctionCall: minor doc fix --- .../Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php index 84ed101745..0374a8f757 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php @@ -84,7 +84,7 @@ public function process(File $phpcsFile, $stackPtr) continue; } - // Find next non empty token, if it is a open curly brace we have a + // Find next non empty token, if it is a open parenthesis we have a // function call. $index = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true); From 0a83acee63e48c9cadaeb33da5c6ea593d70a960 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 23 Jan 2024 17:19:23 -0300 Subject: [PATCH 364/874] Add links to all issues in the 3.5.7 and 3.5.6 sections of the changelog This commit also fixes a few typos in the two changelogs. --- CHANGELOG.md | 91 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 862cca4163..049117693f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -755,9 +755,9 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ## [3.5.7] - 2020-10-23 ### Added - The PHP 8.0 T_NULLSAFE_OBJECT_OPERATOR token has been made available for older versions - - Existing sniffs that check for T_OBJECT_OPERATOR have been modified to apply the same rules for the nullsafe object operator + - Existing sniffs that check for T_OBJECT_OPERATOR have been modified to apply the same rules for the nullsafe object operator - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- The new method of PHP 8.0 tokenizing for namespaced names has been revert to thr pre 8.0 method +- The new method of PHP 8.0 tokenizing for namespaced names has been reverted to the pre 8.0 method - This maintains backwards compatible for existing sniffs on PHP 8.0 - This change will be removed in PHPCS 4.0 as the PHP 8.0 tokenizing method will be backported for pre 8.0 versions - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -778,37 +778,57 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed Squiz.Formatting.OperatorBracket false positive when exiting with a negative number - Fixed Squiz.PHP.DisallowComparisonAssignment false positive for methods called on an object -- Fixed bug #2882 : Generic.Arrays.ArrayIndent can request close brace indent to be less than the statement indent level -- Fixed bug #2883 : Generic.WhiteSpace.ScopeIndent.Incorrect issue after NOWDOC -- Fixed bug #2975 : Undefined offset in PSR12.Functions.ReturnTypeDeclaration when checking function return type inside ternary -- Fixed bug #2988 : Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding +- Fixed bug [#2882] : Generic.Arrays.ArrayIndent can request close brace indent to be less than the statement indent level +- Fixed bug [#2883] : Generic.WhiteSpace.ScopeIndent.Incorrect issue after NOWDOC +- Fixed bug [#2975] : Undefined offset in PSR12.Functions.ReturnTypeDeclaration when checking function return type inside ternary +- Fixed bug [#2988] : Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding - Thanks to [Thiemo Kreuz][@thiemowmde] for the patch -- Fixed bug #2989 : Incorrect auto-fixing in Generic.ControlStructures.InlineControlStructure during live coding +- Fixed bug [#2989] : Incorrect auto-fixing in Generic.ControlStructures.InlineControlStructure during live coding - Thanks to [Thiemo Kreuz][@thiemowmde] for the patch -- Fixed bug #3007 : Directory exclude pattern improperly excludes directories with names that start the same +- Fixed bug [#3007] : Directory exclude pattern improperly excludes directories with names that start the same - Thanks to [Steve Talbot][@SteveTalbot] for the patch -- Fixed bug #3043 : Squiz.WhiteSpace.OperatorSpacing false positive for negation in arrow function +- Fixed bug [#3043] : Squiz.WhiteSpace.OperatorSpacing false positive for negation in arrow function - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3049 : Incorrect error with arrow function and parameter passed as reference +- Fixed bug [#3049] : Incorrect error with arrow function and parameter passed as reference - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3053 : PSR2 incorrect fix when multiple use statements on same line do not have whitespace between them -- Fixed bug #3058 : Progress gets unaligned when 100% happens at the end of the available dots -- Fixed bug #3059 : Squiz.Arrays.ArrayDeclaration false positive when using type casting +- Fixed bug [#3053] : PSR2 incorrect fix when multiple use statements on same line do not have whitespace between them +- Fixed bug [#3058] : Progress gets unaligned when 100% happens at the end of the available dots +- Fixed bug [#3059] : Squiz.Arrays.ArrayDeclaration false positive when using type casting - Thanks to [Sergei Morozov][@morozov] for the patch -- Fixed bug #3060 : Squiz.Arrays.ArrayDeclaration false positive for static functions +- Fixed bug [#3060] : Squiz.Arrays.ArrayDeclaration false positive for static functions - Thanks to [Sergei Morozov][@morozov] for the patch -- Fixed bug #3065 : Should not fix Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma if comment between element and comma +- Fixed bug [#3065] : Should not fix Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma if comment between element and comma - Thanks to [Sergei Morozov][@morozov] for the patch -- Fixed bug #3066 : No support for namespace operator used in type declarations +- Fixed bug [#3066] : No support for namespace operator used in type declarations - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3075 : PSR12.ControlStructures.BooleanOperatorPlacement false positive when operator is the only content on line -- Fixed bug #3099 : Squiz.WhiteSpace.OperatorSpacing false positive when exiting with negative number +- Fixed bug [#3075] : PSR12.ControlStructures.BooleanOperatorPlacement false positive when operator is the only content on line +- Fixed bug [#3099] : Squiz.WhiteSpace.OperatorSpacing false positive when exiting with negative number - Thanks to [Sergei Morozov][@morozov] for the patch -- Fixed bug #3102 : PSR12.Squiz.OperatorSpacing false positive for default values of arrow functions - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3124 : PSR-12 not reporting error for empty lines with only whitespace -- Fixed bug #3135 : Ignore annotations are broken on PHP 8.0 - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#3102] : PSR12.Squiz.OperatorSpacing false positive for default values of arrow functions + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#3124] : PSR-12 not reporting error for empty lines with only whitespace +- Fixed bug [#3135] : Ignore annotations are broken on PHP 8.0 + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch + +[#2882]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2882 +[#2883]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2883 +[#2975]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2975 +[#2988]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2988 +[#2989]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2989 +[#3007]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3007 +[#3043]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3043 +[#3049]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3049 +[#3053]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3053 +[#3058]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3058 +[#3059]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3059 +[#3060]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3060 +[#3065]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3065 +[#3066]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3066 +[#3075]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3075 +[#3099]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3099 +[#3102]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3102 +[#3124]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3124 +[#3135]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3135 ## [3.5.6] - 2020-08-10 ### Added @@ -833,19 +853,28 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Michał Bundyra][@michalbundyra] for the patch ### Fixed -- Fixed bug #2877 : PEAR.Functions.FunctionCallSignature false positive for array of functions +- Fixed bug [#2877] : PEAR.Functions.FunctionCallSignature false positive for array of functions - Thanks to [Vincent Langlet][@VincentLanglet] for the patch -- Fixed bug #2888 : PSR12.Files.FileHeader blank line error with multiple namespaces in one file -- Fixed bug #2926 : phpcs hangs when using arrow functions that return heredoc -- Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed -- Fixed bug #2967 : Markdown generator does not output headings correctly +- Fixed bug [#2888] : PSR12.Files.FileHeader blank line error with multiple namespaces in one file +- Fixed bug [#2926] : phpcs hangs when using arrow functions that return heredoc +- Fixed bug [#2943] : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed +- Fixed bug [#2967] : Markdown generator does not output headings correctly - Thanks to [Petr Bugyík][@o5] for the patch -- Fixed bug #2977 : File::isReference() does not detect return by reference for closures +- Fixed bug [#2977] : File::isReference() does not detect return by reference for closures - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2994 : Generic.Formatting.DisallowMultipleStatements false positive for FOR loop with no body -- Fixed bug #3033 : Error generated during tokenizing of goto statements on PHP 8 +- Fixed bug [#2994] : Generic.Formatting.DisallowMultipleStatements false positive for FOR loop with no body +- Fixed bug [#3033] : Error generated during tokenizing of goto statements on PHP 8 - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[#2877]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2877 +[#2888]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2888 +[#2926]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2926 +[#2943]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2943 +[#2967]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2967 +[#2977]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2977 +[#2994]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2994 +[#3033]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3033 + ## [3.5.5] - 2020-04-17 ### Changed - The T_FN backfill now works more reliably so T_FN tokens only ever represent real arrow functions From c095f25cc6b13adde3faede0dc4cc216ed803a3b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 24 Jan 2024 02:19:01 +0100 Subject: [PATCH 365/874] Tests/Generic: make some tests a little more descriptive Follow up on squizlabs/PHP_CodeSniffer 2183 which added these test files. This commit makes it clear within the test case file what is being tested by each. --- src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.6.inc | 2 +- src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.7.inc | 2 +- .../Tests/PHP/CharacterBeforePHPOpeningTagUnitTest.3.inc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.6.inc b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.6.inc index db62c62310..16a044b806 100644 --- a/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.6.inc +++ b/src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.6.inc @@ -1,2 +1,2 @@  Date: Fri, 5 Jan 2024 09:20:06 +0100 Subject: [PATCH 366/874] PHPUnit config: make sure unexpected output fails the tests --- phpunit.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9fb6c304db..1402588f20 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,6 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.2/phpunit.xsd" backupGlobals="true" + beStrictAboutOutputDuringTests="true" beStrictAboutTestsThatDoNotTestAnything="false" bootstrap="tests/bootstrap.php" convertErrorsToExceptions="true" From 2507c78d6aa8fe714b19d5e62519cd75f0a3aceb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 16 Jan 2024 21:15:46 +0100 Subject: [PATCH 367/874] :sparkles: Native handling of sniff deprecations As per 164, this commit introduces a new feature to PHPCS: native handling of sniff deprecations. ### Background There are quite a few sniffs slated for removal in PHPCS 4.0 - 45 so far, to be exact - and save for two sniffs which have received a deprecation mention in the changelogs, this has only been announced in issues (squizlabs/PHP_CodeSniffer 2448 + squizlabs/PHP_CodeSniffer 2471) in the Squizlabs repo and should therefore only be considered "known" to a very small group of people. Increasing awareness of the upcoming sniff removals should allow for a smoother upgrade experience to PHPCS 4.0 for end-users. Aside from use by PHPCS itself, this feature can also be used by external standards to signal sniff deprecations to _their_ end-users. All in all, this feature should hopefully improve the end-user experience. ### Policy for use of this feature in PHP_CodeSniffer itself As per the notes in 188, the intention is for PHPCS itself to use this feature as follows: * Soft deprecate (changelog notice and `@deprecated` tag in sniff) sniffs during the lifetime of a major. * Hard deprecate sniffs, i.e. implement the `DeprecatedSniff` interface, in the last minor before the next major release. External standards are, of course, free to apply a different deprecation policy. ### Implementation details This commit introduces: #### A new `PHP_CodeSniffer\Sniffs\DeprecatedSniff` interface This interface enforces the implementation of three new methods: * `getDeprecationVersion(): string` - the return value should be a non-empty string with the version in which the sniff was deprecated. * `getRemovalVersion(): string` - the return value should be a non-empty string with the version in which the sniff will be removed. If the removal version is not yet known, it is recommended to set this to: "a future version". * `getDeprecationMessage(): string` - the return value allows for an arbitrary message to be added, such as a replacement recommendation. If no additional information needs to be conveyed to end-users, an empty string can be returned. Custom messages are allowed to contain new lines. #### Changes to the `Ruleset` class to allow for showing the deprecation notices The Ruleset class contains two new methods: * `hasSniffDeprecations(): bool` to allow for checking whether a loading ruleset includes deprecated sniffs. * `showSniffDeprecations(): void` to display the applicable deprecation notices. The implementation for showing the sniff deprecation notices is as follows: * No notices will be shown when PHPCS is running with the `-q` flag (quite mode). * No notices will be shown when PHPCS was giving the `-e` flag to "explain" a standard (list all sniffs). * No notices will be shown when PHPCS was asked to display documentation using the `--generator=...` CLI argument. * No notices will be shown when PHPCS is asked for information which doesn't involve loading a ruleset, such as running `phpcs` with the any of the following flags: `-i` (listing installed standards), `--version`, `--help`, `--config-show`, `--config-set`, `--config-delete`. * Only deprecation notices will be shown for _active_ sniffs. This means that when `--exclude=...` is used and deprecated sniffs are excluded, no notices will be shown for the excluded sniffs. It also means that when `--sniffs=...` is used, deprecation notices will only be shown for those sniffs selected (if deprecated). * The deprecation notices have no impact on the PHPCS (or PHPCBF) run itself. - Deprecated sniffs will still be loaded and run. - Properties can be set on deprecated sniffs. - The exit codes of runs are not affected by whether or not a ruleset contains deprecated sniffs. * As things are, deprecation notices will show both for `phpcs` as well as `phpcbf` runs. I did considered silencing them by default for `phpcbf`. For now, however, I've decided against this as the whole point of showing deprecation notices is to increase awareness of upcoming changes and as a subsection of the PHPCS users only run `phpcbf` and rarely `phpcs`, silencing the notices for `phpcbf` could be counter-productive. Additional implementation notes: * Any user set `--report-width` will be respected. This includes when the `report-width` is set to `auto`. * New lines in custom messages will be normalized to be suitable for the OS of the end-user. * The output will have select colourization if `--colors` is turned on. * The deprecation notices will not be included in generated reports saved to file using `--report-file=...` (and variants thereof). * If the interface is implemented incorrectly, a `PHP_CodeSniffer\Exceptions\RuntimeException` will be thrown. The intention is to add return type declarations to the interface in the future. The complete new feature is extensively covered by tests. Related issues: 188, 276 Fixes 164 --- src/Ruleset.php | 155 ++++++ src/Runner.php | 4 + src/Sniffs/DeprecatedSniff.php | 63 +++ .../Deprecated/WithLongReplacementSniff.php | 41 ++ ...eplacementContainingLinuxNewlinesSniff.php | 45 ++ ...WithReplacementContainingNewlinesSniff.php | 45 ++ .../Deprecated/WithReplacementSniff.php | 41 ++ .../Deprecated/WithoutReplacementSniff.php | 41 ++ .../EmptyDeprecationVersionSniff.php | 41 ++ .../EmptyRemovalVersionSniff.php | 41 ++ .../InvalidDeprecationMessageSniff.php | 42 ++ .../InvalidDeprecationVersionSniff.php | 41 ++ .../InvalidRemovalVersionSniff.php | 41 ++ tests/Core/Ruleset/Fixtures/ruleset.xml | 4 + ...eprecationsEmptyDeprecationVersionTest.xml | 8 + ...iffDeprecationsEmptyRemovalVersionTest.xml | 8 + ...recationsInvalidDeprecationMessageTest.xml | 8 + ...recationsInvalidDeprecationVersionTest.xml | 8 + ...fDeprecationsInvalidRemovalVersionTest.xml | 8 + .../ShowSniffDeprecationsOrderTest.xml | 10 + .../ShowSniffDeprecationsReportWidthTest.xml | 8 + .../Ruleset/ShowSniffDeprecationsTest.php | 510 ++++++++++++++++++ .../Ruleset/ShowSniffDeprecationsTest.xml | 10 + 23 files changed, 1223 insertions(+) create mode 100644 src/Sniffs/DeprecatedSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithLongReplacementSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithoutReplacementSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/ruleset.xml create mode 100644 tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml create mode 100644 tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml create mode 100644 tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml create mode 100644 tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml create mode 100644 tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml create mode 100644 tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml create mode 100644 tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml create mode 100644 tests/Core/Ruleset/ShowSniffDeprecationsTest.php create mode 100644 tests/Core/Ruleset/ShowSniffDeprecationsTest.xml diff --git a/src/Ruleset.php b/src/Ruleset.php index 2e2493037b..7c7b1a4b3c 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -12,6 +12,7 @@ namespace PHP_CodeSniffer; use PHP_CodeSniffer\Exceptions\RuntimeException; +use PHP_CodeSniffer\Sniffs\DeprecatedSniff; use PHP_CodeSniffer\Util; use stdClass; @@ -116,6 +117,16 @@ class Ruleset */ private $config = null; + /** + * An array of the names of sniffs which have been marked as deprecated. + * + * The key is the sniff code and the value + * is the fully qualified name of the sniff class. + * + * @var array + */ + private $deprecatedSniffs = []; + /** * Initialise the ruleset that the run will use. @@ -297,6 +308,146 @@ public function explain() }//end explain() + /** + * Checks whether any deprecated sniffs were registered via the ruleset. + * + * @return bool + */ + public function hasSniffDeprecations() + { + return (count($this->deprecatedSniffs) > 0); + + }//end hasSniffDeprecations() + + + /** + * Prints an information block about deprecated sniffs being used. + * + * @return void + * + * @throws \PHP_CodeSniffer\Exceptions\RuntimeException When the interface implementation is faulty. + */ + public function showSniffDeprecations() + { + if ($this->hasSniffDeprecations() === false) { + return; + } + + // Don't show deprecation notices in quiet mode, in explain mode + // or when the documentation is being shown. + // Documentation and explain will mark a sniff as deprecated natively + // and also call the Ruleset multiple times which would lead to duplicate + // display of the deprecation messages. + if ($this->config->quiet === true + || $this->config->explain === true + || $this->config->generator !== null + ) { + return; + } + + $reportWidth = $this->config->reportWidth; + // Message takes report width minus the leading dash + two spaces, minus a one space gutter at the end. + $maxMessageWidth = ($reportWidth - 4); + $maxActualWidth = 0; + + ksort($this->deprecatedSniffs, (SORT_NATURAL | SORT_FLAG_CASE)); + + $messages = []; + $messageTemplate = 'This sniff has been deprecated since %s and will be removed in %s. %s'; + $errorTemplate = 'The %s::%s() method must return a %sstring, received %s'; + + foreach ($this->deprecatedSniffs as $sniffCode => $className) { + if (isset($this->sniffs[$className]) === false) { + // Should only be possible in test situations, but some extra defensive coding is never a bad thing. + continue; + } + + // Verify the interface was implemented correctly. + // Unfortunately can't be safeguarded via type declarations yet. + $deprecatedSince = $this->sniffs[$className]->getDeprecationVersion(); + if (is_string($deprecatedSince) === false) { + throw new RuntimeException( + sprintf($errorTemplate, $className, 'getDeprecationVersion', 'non-empty ', gettype($deprecatedSince)) + ); + } + + if ($deprecatedSince === '') { + throw new RuntimeException( + sprintf($errorTemplate, $className, 'getDeprecationVersion', 'non-empty ', '""') + ); + } + + $removedIn = $this->sniffs[$className]->getRemovalVersion(); + if (is_string($removedIn) === false) { + throw new RuntimeException( + sprintf($errorTemplate, $className, 'getRemovalVersion', 'non-empty ', gettype($removedIn)) + ); + } + + if ($removedIn === '') { + throw new RuntimeException( + sprintf($errorTemplate, $className, 'getRemovalVersion', 'non-empty ', '""') + ); + } + + $customMessage = $this->sniffs[$className]->getDeprecationMessage(); + if (is_string($customMessage) === false) { + throw new RuntimeException( + sprintf($errorTemplate, $className, 'getDeprecationMessage', '', gettype($customMessage)) + ); + } + + // Truncate the error code if there is not enough report width. + if (strlen($sniffCode) > $maxMessageWidth) { + $sniffCode = substr($sniffCode, 0, ($maxMessageWidth - 3)).'...'; + } + + $message = '- '.$sniffCode.PHP_EOL; + if ($this->config->colors === true) { + $message = '- '."\033[36m".$sniffCode."\033[0m".PHP_EOL; + } + + $maxActualWidth = max($maxActualWidth, strlen($sniffCode)); + + // Normalize new line characters in custom message. + $customMessage = preg_replace('`\R`', PHP_EOL, $customMessage); + + $notice = trim(sprintf($messageTemplate, $deprecatedSince, $removedIn, $customMessage)); + $maxActualWidth = max($maxActualWidth, min(strlen($notice), $maxMessageWidth)); + $wrapped = wordwrap($notice, $maxMessageWidth, PHP_EOL); + $message .= ' '.implode(PHP_EOL.' ', explode(PHP_EOL, $wrapped)); + + $messages[] = $message; + }//end foreach + + if (count($messages) === 0) { + return; + } + + $summaryLine = "WARNING: The $this->name standard uses 1 deprecated sniff"; + $sniffCount = count($messages); + if ($sniffCount !== 1) { + $summaryLine = str_replace('1 deprecated sniff', "$sniffCount deprecated sniffs", $summaryLine); + } + + $maxActualWidth = max($maxActualWidth, min(strlen($summaryLine), $maxMessageWidth)); + + $summaryLine = wordwrap($summaryLine, $reportWidth, PHP_EOL); + if ($this->config->colors === true) { + echo "\033[33m".$summaryLine."\033[0m".PHP_EOL; + } else { + echo $summaryLine.PHP_EOL; + } + + echo str_repeat('-', min(($maxActualWidth + 4), $reportWidth)).PHP_EOL; + echo implode(PHP_EOL, $messages); + + $closer = wordwrap('Deprecated sniffs are still run, but will stop working at some point in the future.', $reportWidth, PHP_EOL); + echo PHP_EOL.PHP_EOL.$closer.PHP_EOL.PHP_EOL; + + }//end showSniffDeprecations() + + /** * Processes a single ruleset and returns a list of the sniffs it represents. * @@ -1225,6 +1376,10 @@ public function populateTokenListeners() $sniffCode = Util\Common::getSniffCode($sniffClass); $this->sniffCodes[$sniffCode] = $sniffClass; + if ($this->sniffs[$sniffClass] instanceof DeprecatedSniff) { + $this->deprecatedSniffs[$sniffCode] = $sniffClass; + } + // Set custom properties. if (isset($this->ruleset[$sniffCode]['properties']) === true) { foreach ($this->ruleset[$sniffCode]['properties'] as $name => $settings) { diff --git a/src/Runner.php b/src/Runner.php index 61013874c9..053c67cfaf 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -334,6 +334,10 @@ public function init() // should be checked and/or fixed. try { $this->ruleset = new Ruleset($this->config); + + if ($this->ruleset->hasSniffDeprecations() === true) { + $this->ruleset->showSniffDeprecations(); + } } catch (RuntimeException $e) { $error = 'ERROR: '.$e->getMessage().PHP_EOL.PHP_EOL; $error .= $this->config->printShortUsage(true); diff --git a/src/Sniffs/DeprecatedSniff.php b/src/Sniffs/DeprecatedSniff.php new file mode 100644 index 0000000000..4f4d9fc025 --- /dev/null +++ b/src/Sniffs/DeprecatedSniff.php @@ -0,0 +1,63 @@ + + * @copyright 2024 PHPCSStandards Contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Sniffs; + +interface DeprecatedSniff +{ + + + /** + * Provide the version number in which the sniff was deprecated. + * + * Recommended format for PHPCS native sniffs: "v3.3.0". + * Recommended format for external sniffs: "StandardName v3.3.0". + * + * @return string + */ + public function getDeprecationVersion(); + + + /** + * Provide the version number in which the sniff will be removed. + * + * Recommended format for PHPCS native sniffs: "v3.3.0". + * Recommended format for external sniffs: "StandardName v3.3.0". + * + * If the removal version is not yet known, it is recommended to set + * this to: "a future version". + * + * @return string + */ + public function getRemovalVersion(); + + + /** + * Optionally provide an arbitrary custom message to display with the deprecation. + * + * Typically intended to allow for displaying information about what to + * replace the deprecated sniff with. + * Example: "Use the Stnd.Cat.SniffName sniff instead." + * Multi-line messages (containing new line characters) are supported. + * + * An empty string can be returned if there is no replacement/no need + * for a custom message. + * + * @return string + */ + public function getDeprecationMessage(); + + +}//end interface diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithLongReplacementSniff.php b/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithLongReplacementSniff.php new file mode 100644 index 0000000000..40c23113d5 --- /dev/null +++ b/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithLongReplacementSniff.php @@ -0,0 +1,41 @@ + + + + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml new file mode 100644 index 0000000000..5e2480bf2f --- /dev/null +++ b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml new file mode 100644 index 0000000000..6e667375af --- /dev/null +++ b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml new file mode 100644 index 0000000000..d325167994 --- /dev/null +++ b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml new file mode 100644 index 0000000000..89d83ab528 --- /dev/null +++ b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml new file mode 100644 index 0000000000..c1eb062e1c --- /dev/null +++ b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml new file mode 100644 index 0000000000..3ce96ce89f --- /dev/null +++ b/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml new file mode 100644 index 0000000000..9f1cc85155 --- /dev/null +++ b/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php new file mode 100644 index 0000000000..8e81f96a25 --- /dev/null +++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php @@ -0,0 +1,510 @@ + + * @copyright 2024 Juliette Reinders Folmer. All rights reserved. + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHPUnit\Framework\TestCase; + +/** + * Tests PHPCS native handling of sniff deprecations. + * + * @covers \PHP_CodeSniffer\Ruleset::hasSniffDeprecations + * @covers \PHP_CodeSniffer\Ruleset::showSniffDeprecations + */ +final class ShowSniffDeprecationsTest extends TestCase +{ + + + /** + * Test the return value of the hasSniffDeprecations() method. + * + * @param string $standard The standard to use for the test. + * @param bool $expected The expected function return value. + * + * @dataProvider dataHasSniffDeprecations + * + * @return void + */ + public function testHasSniffDeprecations($standard, $expected) + { + $config = new ConfigDouble(['.', "--standard=$standard"]); + $ruleset = new Ruleset($config); + + $this->assertSame($expected, $ruleset->hasSniffDeprecations()); + + }//end testHasSniffDeprecations() + + + /** + * Data provider. + * + * @see testHasSniffDeprecations() + * + * @return array> + */ + public static function dataHasSniffDeprecations() + { + return [ + 'Standard not using deprecated sniffs: PSR1' => [ + 'standard' => 'PSR1', + 'expected' => false, + ], + 'Standard using deprecated sniffs: Test Fixture' => [ + 'standard' => __DIR__.'/ShowSniffDeprecationsTest.xml', + 'expected' => true, + ], + ]; + + }//end dataHasSniffDeprecations() + + + /** + * Test that the listing with deprecated sniffs will not show when specific command-line options are being used. + * + * @param string $standard The standard to use for the test. + * @param array $additionalArgs Optional. Additional arguments to pass. + * + * @dataProvider dataDeprecatedSniffsListDoesNotShow + * + * @return void + */ + public function testDeprecatedSniffsListDoesNotShow($standard, $additionalArgs=[]) + { + $args = $additionalArgs; + $args[] = '.'; + $args[] = "--standard=$standard"; + + $config = new ConfigDouble($args); + $ruleset = new Ruleset($config); + + $this->expectOutputString(''); + + $ruleset->showSniffDeprecations(); + + }//end testDeprecatedSniffsListDoesNotShow() + + + /** + * Data provider. + * + * @see testDeprecatedSniffsListDoesNotShow() + * + * @return array>> + */ + public static function dataDeprecatedSniffsListDoesNotShow() + { + return [ + 'Standard not using deprecated sniffs: PSR1' => [ + 'standard' => 'PSR1', + ], + 'Standard using deprecated sniffs; explain mode' => [ + 'standard' => __DIR__.'/ShowSniffDeprecationsTest.xml', + 'additionalArgs' => ['-e'], + ], + 'Standard using deprecated sniffs; quiet mode' => [ + 'standard' => __DIR__.'/ShowSniffDeprecationsTest.xml', + 'additionalArgs' => ['-q'], + ], + 'Standard using deprecated sniffs; documentation is requested' => [ + 'standard' => __DIR__.'/ShowSniffDeprecationsTest.xml', + 'additionalArgs' => ['--generator=text'], + ], + ]; + + }//end dataDeprecatedSniffsListDoesNotShow() + + + /** + * Test that the listing with deprecated sniffs will not show when using a standard containing deprecated sniffs, + * but only running select non-deprecated sniffs (using `--sniffs=...`). + * + * @return void + */ + public function testDeprecatedSniffsListDoesNotShowWhenSelectedSniffsAreNotDeprecated() + { + $standard = __DIR__.'/ShowSniffDeprecationsTest.xml'; + $config = new ConfigDouble(['.', "--standard=$standard"]); + $ruleset = new Ruleset($config); + + /* + * Apply sniff restrictions. + * For tests we need to manually trigger this if the standard is "installed", like with the fixtures these tests use. + */ + + $restrictions = []; + $sniffs = [ + 'Fixtures.SetProperty.AllowedAsDeclared', + 'Fixtures.SetProperty.AllowedViaStdClass', + ]; + foreach ($sniffs as $sniffCode) { + $parts = explode('.', strtolower($sniffCode)); + $sniffName = $parts[0].'\sniffs\\'.$parts[1].'\\'.$parts[2].'sniff'; + $restrictions[strtolower($sniffName)] = true; + } + + $sniffFiles = []; + $allSniffs = $ruleset->sniffCodes; + foreach ($allSniffs as $sniffName) { + $sniffFile = str_replace('\\', DIRECTORY_SEPARATOR, $sniffName); + $sniffFile = __DIR__.DIRECTORY_SEPARATOR.$sniffFile.'.php'; + $sniffFiles[] = $sniffFile; + } + + $ruleset->registerSniffs($allSniffs, $restrictions, []); + $ruleset->populateTokenListeners(); + + $this->expectOutputString(''); + + $ruleset->showSniffDeprecations(); + + }//end testDeprecatedSniffsListDoesNotShowWhenSelectedSniffsAreNotDeprecated() + + + /** + * Test that the listing with deprecated sniffs will not show when using a standard containing deprecated sniffs, + * but all deprecated sniffs have been excluded from the run (using `--exclude=...`). + * + * @return void + */ + public function testDeprecatedSniffsListDoesNotShowWhenAllDeprecatedSniffsAreExcluded() + { + $standard = __DIR__.'/ShowSniffDeprecationsTest.xml'; + $config = new ConfigDouble(['.', "--standard=$standard"]); + $ruleset = new Ruleset($config); + + /* + * Apply sniff restrictions. + * For tests we need to manually trigger this if the standard is "installed", like with the fixtures these tests use. + */ + + $exclusions = []; + $exclude = [ + 'Fixtures.Deprecated.WithLongReplacement', + 'Fixtures.Deprecated.WithoutReplacement', + 'Fixtures.Deprecated.WithReplacement', + 'Fixtures.Deprecated.WithReplacementContainingLinuxNewlines', + 'Fixtures.Deprecated.WithReplacementContainingNewlines', + ]; + foreach ($exclude as $sniffCode) { + $parts = explode('.', strtolower($sniffCode)); + $sniffName = $parts[0].'\sniffs\\'.$parts[1].'\\'.$parts[2].'sniff'; + $exclusions[strtolower($sniffName)] = true; + } + + $sniffFiles = []; + $allSniffs = $ruleset->sniffCodes; + foreach ($allSniffs as $sniffName) { + $sniffFile = str_replace('\\', DIRECTORY_SEPARATOR, $sniffName); + $sniffFile = __DIR__.DIRECTORY_SEPARATOR.$sniffFile.'.php'; + $sniffFiles[] = $sniffFile; + } + + $ruleset->registerSniffs($allSniffs, [], $exclusions); + $ruleset->populateTokenListeners(); + + $this->expectOutputString(''); + + $ruleset->showSniffDeprecations(); + + }//end testDeprecatedSniffsListDoesNotShowWhenAllDeprecatedSniffsAreExcluded() + + + /** + * Test deprecated sniffs are listed alphabetically in the deprecated sniffs warning. + * + * This tests a number of different aspects: + * 1. That the summary line uses the correct grammar when there is are multiple deprecated sniffs. + * 2. That there is no trailing whitespace when the sniff does not provide a custom message. + * 3. That custom messages containing new line characters (any type) are handled correctly and + * that those new line characters are converted to the OS supported new line char. + * + * @return void + */ + public function testDeprecatedSniffsWarning() + { + $standard = __DIR__.'/ShowSniffDeprecationsTest.xml'; + $config = new ConfigDouble(["--standard=$standard", '--no-colors']); + $ruleset = new Ruleset($config); + + $expected = 'WARNING: The SniffDeprecationTest standard uses 5 deprecated sniffs'.PHP_EOL; + $expected .= '--------------------------------------------------------------------------------'.PHP_EOL; + $expected .= '- Fixtures.Deprecated.WithLongReplacement'.PHP_EOL; + $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; + $expected .= ' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vel'.PHP_EOL; + $expected .= ' vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium sed.'.PHP_EOL; + $expected .= ' Fusce egestas congue massa semper cursus. Donec quis pretium tellus. In'.PHP_EOL; + $expected .= ' lacinia, augue ut ornare porttitor, diam nunc faucibus purus, et accumsan'.PHP_EOL; + $expected .= ' eros sapien at sem. Sed pulvinar aliquam malesuada. Aliquam erat volutpat.'.PHP_EOL; + $expected .= ' Mauris gravida rutrum lectus at egestas. Fusce tempus elit in tincidunt'.PHP_EOL; + $expected .= ' dictum. Suspendisse dictum egestas sapien, eget ullamcorper metus elementum'.PHP_EOL; + $expected .= ' semper. Vestibulum sem justo, consectetur ac tincidunt et, finibus eget'.PHP_EOL; + $expected .= ' libero.'.PHP_EOL; + $expected .= '- Fixtures.Deprecated.WithoutReplacement'.PHP_EOL; + $expected .= ' This sniff has been deprecated since v3.4.0 and will be removed in v4.0.0.'.PHP_EOL; + $expected .= '- Fixtures.Deprecated.WithReplacement'.PHP_EOL; + $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; + $expected .= ' Use the Stnd.Category.OtherSniff sniff instead.'.PHP_EOL; + $expected .= '- Fixtures.Deprecated.WithReplacementContainingLinuxNewlines'.PHP_EOL; + $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; + $expected .= ' Lorem ipsum dolor sit amet, consectetur adipiscing elit.'.PHP_EOL; + $expected .= ' Fusce vel vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium'.PHP_EOL; + $expected .= ' sed.'.PHP_EOL; + $expected .= ' Fusce egestas congue massa semper cursus. Donec quis pretium tellus.'.PHP_EOL; + $expected .= ' In lacinia, augue ut ornare porttitor, diam nunc faucibus purus, et accumsan'.PHP_EOL; + $expected .= ' eros sapien at sem.'.PHP_EOL; + $expected .= ' Sed pulvinar aliquam malesuada. Aliquam erat volutpat. Mauris gravida rutrum'.PHP_EOL; + $expected .= ' lectus at egestas.'.PHP_EOL; + $expected .= '- Fixtures.Deprecated.WithReplacementContainingNewlines'.PHP_EOL; + $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; + $expected .= ' Lorem ipsum dolor sit amet, consectetur adipiscing elit.'.PHP_EOL; + $expected .= ' Fusce vel vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium'.PHP_EOL; + $expected .= ' sed.'.PHP_EOL; + $expected .= ' Fusce egestas congue massa semper cursus. Donec quis pretium tellus.'.PHP_EOL; + $expected .= ' In lacinia, augue ut ornare porttitor, diam nunc faucibus purus, et accumsan'.PHP_EOL; + $expected .= ' eros sapien at sem.'.PHP_EOL; + $expected .= ' Sed pulvinar aliquam malesuada. Aliquam erat volutpat. Mauris gravida rutrum'.PHP_EOL; + $expected .= ' lectus at egestas'.PHP_EOL.PHP_EOL; + $expected .= 'Deprecated sniffs are still run, but will stop working at some point in the'.PHP_EOL; + $expected .= 'future.'.PHP_EOL.PHP_EOL; + + $this->expectOutputString($expected); + + $ruleset->showSniffDeprecations(); + + }//end testDeprecatedSniffsWarning() + + + /** + * Test deprecated sniffs are listed alphabetically in the deprecated sniffs warning. + * + * This tests the following aspects: + * 1. That the summary line uses the correct grammar when there is a single deprecated sniff. + * 2. That the separator line below the summary maximizes at the longest line length. + * 3. That the word wrapping respects the maximum report width. + * 4. That the sniff name is truncated if it is longer than the max report width. + * + * @param int $reportWidth Report width for the test. + * @param string $expectedOutput Expected output. + * + * @dataProvider dataReportWidthIsRespected + * + * @return void + */ + public function testReportWidthIsRespected($reportWidth, $expectedOutput) + { + // Set up the ruleset. + $standard = __DIR__.'/ShowSniffDeprecationsReportWidthTest.xml'; + $config = new ConfigDouble(['.', "--standard=$standard", "--report-width=$reportWidth", '--no-colors']); + $ruleset = new Ruleset($config); + + $this->expectOutputString($expectedOutput); + + $ruleset->showSniffDeprecations(); + + }//end testReportWidthIsRespected() + + + /** + * Data provider. + * + * @see testReportWidthIsRespected() + * + * @return array> + */ + public static function dataReportWidthIsRespected() + { + $summaryLine = 'WARNING: The SniffDeprecationTest standard uses 1 deprecated sniff'.PHP_EOL; + + // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- Test readability is more important. + return [ + 'Report width small: 40; with truncated sniff name and wrapped header and footer lines' => [ + 'reportWidth' => 40, + 'expectedOutput' => 'WARNING: The SniffDeprecationTest'.PHP_EOL + .'standard uses 1 deprecated sniff'.PHP_EOL + .'----------------------------------------'.PHP_EOL + .'- Fixtures.Deprecated.WithLongRepla...'.PHP_EOL + .' This sniff has been deprecated since'.PHP_EOL + .' v3.8.0 and will be removed in'.PHP_EOL + .' v4.0.0. Lorem ipsum dolor sit amet,'.PHP_EOL + .' consectetur adipiscing elit. Fusce'.PHP_EOL + .' vel vestibulum nunc. Sed luctus'.PHP_EOL + .' dolor tortor, eu euismod purus'.PHP_EOL + .' pretium sed. Fusce egestas congue'.PHP_EOL + .' massa semper cursus. Donec quis'.PHP_EOL + .' pretium tellus. In lacinia, augue ut'.PHP_EOL + .' ornare porttitor, diam nunc faucibus'.PHP_EOL + .' purus, et accumsan eros sapien at'.PHP_EOL + .' sem. Sed pulvinar aliquam malesuada.'.PHP_EOL + .' Aliquam erat volutpat. Mauris'.PHP_EOL + .' gravida rutrum lectus at egestas.'.PHP_EOL + .' Fusce tempus elit in tincidunt'.PHP_EOL + .' dictum. Suspendisse dictum egestas'.PHP_EOL + .' sapien, eget ullamcorper metus'.PHP_EOL + .' elementum semper. Vestibulum sem'.PHP_EOL + .' justo, consectetur ac tincidunt et,'.PHP_EOL + .' finibus eget libero.'.PHP_EOL.PHP_EOL + .'Deprecated sniffs are still run, but'.PHP_EOL + .'will stop working at some point in the'.PHP_EOL + .'future.'.PHP_EOL.PHP_EOL, + ], + 'Report width default: 80' => [ + 'reportWidth' => 80, + 'expectedOutput' => $summaryLine.str_repeat('-', 80).PHP_EOL + .'- Fixtures.Deprecated.WithLongReplacement'.PHP_EOL + .' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL + .' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vel'.PHP_EOL + .' vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium sed.'.PHP_EOL + .' Fusce egestas congue massa semper cursus. Donec quis pretium tellus. In'.PHP_EOL + .' lacinia, augue ut ornare porttitor, diam nunc faucibus purus, et accumsan'.PHP_EOL + .' eros sapien at sem. Sed pulvinar aliquam malesuada. Aliquam erat volutpat.'.PHP_EOL + .' Mauris gravida rutrum lectus at egestas. Fusce tempus elit in tincidunt'.PHP_EOL + .' dictum. Suspendisse dictum egestas sapien, eget ullamcorper metus elementum'.PHP_EOL + .' semper. Vestibulum sem justo, consectetur ac tincidunt et, finibus eget'.PHP_EOL + .' libero.'.PHP_EOL.PHP_EOL + .'Deprecated sniffs are still run, but will stop working at some point in the'.PHP_EOL + .'future.'.PHP_EOL.PHP_EOL, + ], + 'Report width matches longest line: 666; the message should not wrap' => [ + // Length = 4 padding + 75 base line + 587 custom message. + 'reportWidth' => 666, + 'expectedOutput' => $summaryLine.str_repeat('-', 666).PHP_EOL + .'- Fixtures.Deprecated.WithLongReplacement'.PHP_EOL + .' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vel vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium sed. Fusce egestas congue massa semper cursus. Donec quis pretium tellus. In lacinia, augue ut ornare porttitor, diam nunc faucibus purus, et accumsan eros sapien at sem. Sed pulvinar aliquam malesuada. Aliquam erat volutpat. Mauris gravida rutrum lectus at egestas. Fusce tempus elit in tincidunt dictum. Suspendisse dictum egestas sapien, eget ullamcorper metus elementum semper. Vestibulum sem justo, consectetur ac tincidunt et, finibus eget libero.' + .PHP_EOL.PHP_EOL + .'Deprecated sniffs are still run, but will stop working at some point in the future.'.PHP_EOL.PHP_EOL, + ], + 'Report width wide: 1000; delimiter line length should match longest line' => [ + 'reportWidth' => 1000, + 'expectedOutput' => $summaryLine.str_repeat('-', 666).PHP_EOL + .'- Fixtures.Deprecated.WithLongReplacement'.PHP_EOL + .' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vel vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium sed. Fusce egestas congue massa semper cursus. Donec quis pretium tellus. In lacinia, augue ut ornare porttitor, diam nunc faucibus purus, et accumsan eros sapien at sem. Sed pulvinar aliquam malesuada. Aliquam erat volutpat. Mauris gravida rutrum lectus at egestas. Fusce tempus elit in tincidunt dictum. Suspendisse dictum egestas sapien, eget ullamcorper metus elementum semper. Vestibulum sem justo, consectetur ac tincidunt et, finibus eget libero.' + .PHP_EOL.PHP_EOL + .'Deprecated sniffs are still run, but will stop working at some point in the future.'.PHP_EOL.PHP_EOL, + ], + ]; + // phpcs:enable + + }//end dataReportWidthIsRespected() + + + /** + * Test deprecated sniffs are listed alphabetically in the deprecated sniffs warning. + * + * Additionally, this test verifies that deprecated sniffs are still registered to run. + * + * @return void + */ + public function testDeprecatedSniffsAreListedAlphabetically() + { + // Set up the ruleset. + $standard = __DIR__.'/ShowSniffDeprecationsOrderTest.xml'; + $config = new ConfigDouble(["--standard=$standard", '--no-colors']); + $ruleset = new Ruleset($config); + + $expected = 'WARNING: The SniffDeprecationTest standard uses 2 deprecated sniffs'.PHP_EOL; + $expected .= '--------------------------------------------------------------------------------'.PHP_EOL; + $expected .= '- Fixtures.Deprecated.WithoutReplacement'.PHP_EOL; + $expected .= ' This sniff has been deprecated since v3.4.0 and will be removed in v4.0.0.'.PHP_EOL; + $expected .= '- Fixtures.Deprecated.WithReplacement'.PHP_EOL; + $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; + $expected .= ' Use the Stnd.Category.OtherSniff sniff instead.'.PHP_EOL.PHP_EOL; + $expected .= 'Deprecated sniffs are still run, but will stop working at some point in the'.PHP_EOL; + $expected .= 'future.'.PHP_EOL.PHP_EOL; + + $this->expectOutputString($expected); + + $ruleset->showSniffDeprecations(); + + // Verify that the sniffs have been registered to run. + $this->assertCount(2, $ruleset->sniffCodes, 'Incorrect number of sniff codes registered'); + $this->assertArrayHasKey( + 'Fixtures.Deprecated.WithoutReplacement', + $ruleset->sniffCodes, + 'WithoutReplacement sniff not registered' + ); + $this->assertArrayHasKey( + 'Fixtures.Deprecated.WithReplacement', + $ruleset->sniffCodes, + 'WithReplacement sniff not registered' + ); + + }//end testDeprecatedSniffsAreListedAlphabetically() + + + /** + * Test that an exception is thrown when any of the interface required methods does not + * comply with the return type/value requirements. + * + * @param string $standard The standard to use for the test. + * @param string $exceptionMessage The contents of the expected exception message. + * + * @dataProvider dataExceptionIsThrownOnIncorrectlyImplementedInterface + * + * @return void + */ + public function testExceptionIsThrownOnIncorrectlyImplementedInterface($standard, $exceptionMessage) + { + $exception = 'PHP_CodeSniffer\Exceptions\RuntimeException'; + if (method_exists($this, 'expectException') === true) { + // PHPUnit 5+. + $this->expectException($exception); + $this->expectExceptionMessage($exceptionMessage); + } else { + // PHPUnit 4. + $this->setExpectedException($exception, $exceptionMessage); + } + + // Set up the ruleset. + $standard = __DIR__.'/'.$standard; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + $ruleset->showSniffDeprecations(); + + }//end testExceptionIsThrownOnIncorrectlyImplementedInterface() + + + /** + * Data provider. + * + * @see testExceptionIsThrownOnIncorrectlyImplementedInterface() + * + * @return array> + */ + public static function dataExceptionIsThrownOnIncorrectlyImplementedInterface() + { + return [ + 'getDeprecationVersion() does not return a string' => [ + 'standard' => 'ShowSniffDeprecationsInvalidDeprecationVersionTest.xml', + 'exceptionMessage' => 'The Fixtures\Sniffs\DeprecatedInvalid\InvalidDeprecationVersionSniff::getDeprecationVersion() method must return a non-empty string, received double', + ], + 'getRemovalVersion() does not return a string' => [ + 'standard' => 'ShowSniffDeprecationsInvalidRemovalVersionTest.xml', + 'exceptionMessage' => 'The Fixtures\Sniffs\DeprecatedInvalid\InvalidRemovalVersionSniff::getRemovalVersion() method must return a non-empty string, received array', + ], + 'getDeprecationMessage() does not return a string' => [ + 'standard' => 'ShowSniffDeprecationsInvalidDeprecationMessageTest.xml', + 'exceptionMessage' => 'The Fixtures\Sniffs\DeprecatedInvalid\InvalidDeprecationMessageSniff::getDeprecationMessage() method must return a string, received object', + ], + 'getDeprecationVersion() returns an empty string' => [ + 'standard' => 'ShowSniffDeprecationsEmptyDeprecationVersionTest.xml', + 'exceptionMessage' => 'The Fixtures\Sniffs\DeprecatedInvalid\EmptyDeprecationVersionSniff::getDeprecationVersion() method must return a non-empty string, received ""', + ], + 'getRemovalVersion() returns an empty string' => [ + 'standard' => 'ShowSniffDeprecationsEmptyRemovalVersionTest.xml', + 'exceptionMessage' => 'The Fixtures\Sniffs\DeprecatedInvalid\EmptyRemovalVersionSniff::getRemovalVersion() method must return a non-empty string, received ""', + ], + ]; + + }//end dataExceptionIsThrownOnIncorrectlyImplementedInterface() + + +}//end class diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml new file mode 100644 index 0000000000..4c1dec2203 --- /dev/null +++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + From 3fb0d958b05c53443be907ebf42a190577c90abb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 16 Jan 2024 21:18:31 +0100 Subject: [PATCH 368/874] Explain: mark deprecated sniffs as such This commit makes a small adjustment to the output of the `-e` (explain) command. Deprecated sniffs will now be marked with a trailing `*` asterix and if the standard contains deprecated sniffs, a line will show at the end of the output to explain that the `*` means that a sniff is deprecated. Includes a test documenting and safeguarding this behaviour. --- src/Ruleset.php | 8 ++++++ tests/Core/Ruleset/ExplainTest.php | 42 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/Ruleset.php b/src/Ruleset.php index 7c7b1a4b3c..b99d484fef 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -301,10 +301,18 @@ public function explain() } }//end if + if (isset($this->deprecatedSniffs[$sniff]) === true) { + $sniff .= ' *'; + } + $sniffsInStandard[] = $sniff; ++$lastCount; }//end foreach + if (count($this->deprecatedSniffs) > 0) { + echo PHP_EOL.'* Sniffs marked with an asterix are deprecated.'.PHP_EOL; + } + }//end explain() diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index 73943d3757..fc84f88ac7 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -166,6 +166,48 @@ public function testExplainCustomRuleset() }//end testExplainCustomRuleset() + /** + * Test the output of the "explain" command for a standard containing both deprecated + * and non-deprecated sniffs. + * + * Tests that: + * - Deprecated sniffs are marked with an asterix in the list. + * - A footnote is displayed explaining the asterix. + * - And that the "standard uses # deprecated sniffs" listing is **not** displayed. + * + * @return void + */ + public function testExplainWithDeprecatedSniffs() + { + // Set up the ruleset. + $standard = __DIR__."/ShowSniffDeprecationsTest.xml"; + $config = new ConfigDouble(["--standard=$standard", '-e']); + $ruleset = new Ruleset($config); + + $expected = PHP_EOL; + $expected .= 'The SniffDeprecationTest standard contains 9 sniffs'.PHP_EOL.PHP_EOL; + + $expected .= 'Fixtures (9 sniffs)'.PHP_EOL; + $expected .= '-------------------'.PHP_EOL; + $expected .= ' Fixtures.Deprecated.WithLongReplacement *'.PHP_EOL; + $expected .= ' Fixtures.Deprecated.WithoutReplacement *'.PHP_EOL; + $expected .= ' Fixtures.Deprecated.WithReplacement *'.PHP_EOL; + $expected .= ' Fixtures.Deprecated.WithReplacementContainingLinuxNewlines *'.PHP_EOL; + $expected .= ' Fixtures.Deprecated.WithReplacementContainingNewlines *'.PHP_EOL; + $expected .= ' Fixtures.SetProperty.AllowedAsDeclared'.PHP_EOL; + $expected .= ' Fixtures.SetProperty.AllowedViaMagicMethod'.PHP_EOL; + $expected .= ' Fixtures.SetProperty.AllowedViaStdClass'.PHP_EOL; + $expected .= ' Fixtures.SetProperty.NotAllowedViaAttribute'.PHP_EOL.PHP_EOL; + + $expected .= '* Sniffs marked with an asterix are deprecated.'.PHP_EOL; + + $this->expectOutputString($expected); + + $ruleset->explain(); + + }//end testExplainWithDeprecatedSniffs() + + /** * Test that each standard passed on the command-line is explained separately. * From 3baecd7627c55f52044ef09f0b9b5b09b714dd0c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 31 Dec 2023 01:38:28 +0100 Subject: [PATCH 369/874] Filters/ExactMatch: deprecate the `getBlacklist()` and `getWhitelist()` methods Deprecate the `getBlacklist()` and `getWhitelist()` methods and introduce the `getDisallowedFiles()` and `getAllowedFiles()` replacement methods. When available in child classes, the `getDisallowedFiles()` and `getAllowedFiles()` methods will take precedence over the deprecated `getBlacklist()` and `getWhitelist()` methods. Fixes 198 --- src/Filters/ExactMatch.php | 56 ++++++++++++++++++++++++++++++++++--- src/Filters/GitModified.php | 40 ++++++++++++++++++++++++-- src/Filters/GitStaged.php | 40 ++++++++++++++++++++++++-- 3 files changed, 128 insertions(+), 8 deletions(-) diff --git a/src/Filters/ExactMatch.php b/src/Filters/ExactMatch.php index d41fccd255..c929fe8102 100644 --- a/src/Filters/ExactMatch.php +++ b/src/Filters/ExactMatch.php @@ -47,22 +47,32 @@ public function accept() } if ($this->disallowedFiles === null) { - $this->disallowedFiles = $this->getblacklist(); + $this->disallowedFiles = $this->getDisallowedFiles(); + + // BC-layer. + if ($this->disallowedFiles === null) { + $this->disallowedFiles = $this->getBlacklist(); + } } if ($this->allowedFiles === null) { - $this->allowedFiles = $this->getwhitelist(); + $this->allowedFiles = $this->getAllowedFiles(); + + // BC-layer. + if ($this->allowedFiles === null) { + $this->allowedFiles = $this->getWhitelist(); + } } $filePath = Util\Common::realpath($this->current()); - // If file is both disallowed and allowed, the disallowed files list takes precedence. + // If a file is both disallowed and allowed, the disallowed files list takes precedence. if (isset($this->disallowedFiles[$filePath]) === true) { return false; } if (empty($this->allowedFiles) === true && empty($this->disallowedFiles) === false) { - // We are only checking a disallowed files list, so everything else should be allowed. + // We are only checking the disallowed files list, so everything else should be allowed. return true; } @@ -92,6 +102,11 @@ public function getChildren() /** * Get a list of file paths to exclude. * + * @deprecated 3.9.0 Implement the `getDisallowedFiles()` method instead. + * The `getDisallowedFiles()` method will be made abstract and therefore required + * in v4.0 and this method will be removed. + * If both methods are implemented, the new `getDisallowedFiles()` method will take precedence. + * * @return array */ abstract protected function getBlacklist(); @@ -100,9 +115,42 @@ abstract protected function getBlacklist(); /** * Get a list of file paths to include. * + * @deprecated 3.9.0 Implement the `getAllowedFiles()` method instead. + * The `getAllowedFiles()` method will be made abstract and therefore required + * in v4.0 and this method will be removed. + * If both methods are implemented, the new `getAllowedFiles()` method will take precedence. + * * @return array */ abstract protected function getWhitelist(); + /** + * Get a list of file paths to exclude. + * + * @since 3.9.0 Replaces the deprecated `getBlacklist()` method. + * + * @return array|null + */ + protected function getDisallowedFiles() + { + return null; + + }//end getDisallowedFiles() + + + /** + * Get a list of file paths to include. + * + * @since 3.9.0 Replaces the deprecated `getWhitelist()` method. + * + * @return array|null + */ + protected function getAllowedFiles() + { + return null; + + }//end getAllowedFiles() + + }//end class diff --git a/src/Filters/GitModified.php b/src/Filters/GitModified.php index 3395e06d8a..dcd9752819 100644 --- a/src/Filters/GitModified.php +++ b/src/Filters/GitModified.php @@ -18,21 +18,41 @@ class GitModified extends ExactMatch /** * Get a list of file paths to exclude. * + * @since 3.9.0 + * * @return array */ - protected function getBlacklist() + protected function getDisallowedFiles() { return []; + }//end getDisallowedFiles() + + + /** + * Get a list of file paths to exclude. + * + * @deprecated 3.9.0 Overload the `getDisallowedFiles()` method instead. + * + * @codeCoverageIgnore + * + * @return array + */ + protected function getBlacklist() + { + return $this->getDisallowedFiles(); + }//end getBlacklist() /** * Get a list of file paths to include. * + * @since 3.9.0 + * * @return array */ - protected function getWhitelist() + protected function getAllowedFiles() { $modified = []; @@ -59,6 +79,22 @@ protected function getWhitelist() return $modified; + }//end getAllowedFiles() + + + /** + * Get a list of file paths to include. + * + * @deprecated 3.9.0 Overload the `getAllowedFiles()` method instead. + * + * @codeCoverageIgnore + * + * @return array + */ + protected function getWhitelist() + { + return $this->getAllowedFiles(); + }//end getWhitelist() diff --git a/src/Filters/GitStaged.php b/src/Filters/GitStaged.php index 94c91940b2..5e18359b09 100644 --- a/src/Filters/GitStaged.php +++ b/src/Filters/GitStaged.php @@ -20,21 +20,41 @@ class GitStaged extends ExactMatch /** * Get a list of file paths to exclude. * + * @since 3.9.0 + * * @return array */ - protected function getBlacklist() + protected function getDisallowedFiles() { return []; + }//end getDisallowedFiles() + + + /** + * Get a list of file paths to exclude. + * + * @deprecated 3.9.0 Overload the `getDisallowedFiles()` method instead. + * + * @codeCoverageIgnore + * + * @return array + */ + protected function getBlacklist() + { + return $this->getDisallowedFiles(); + }//end getBlacklist() /** * Get a list of file paths to include. * + * @since 3.9.0 + * * @return array */ - protected function getWhitelist() + protected function getAllowedFiles() { $modified = []; @@ -61,6 +81,22 @@ protected function getWhitelist() return $modified; + }//end getAllowedFiles() + + + /** + * Get a list of file paths to include. + * + * @deprecated 3.9.0 Overload the `getAllowedFiles()` method instead. + * + * @codeCoverageIgnore + * + * @return array + */ + protected function getWhitelist() + { + return $this->getAllowedFiles(); + }//end getWhitelist() From 3527d8391a3d9ef39acec1f2bd5d4c40408af947 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 20 Jan 2024 21:34:26 +0100 Subject: [PATCH 370/874] Generic/ArbitraryParenthesesSpacing: improve handling of switch-case scope closers Follow up on squizlabs/PHP_CodeSniffer 2826 which was fixed via squizlabs/PHP_CodeSniffer 2876. The sniff explicitly only intends to handle _arbitrary_ parentheses and tries to avoid clashes with sniffs handling the parentheses spacing of function calls and language construct invocations. This is done by the sniff bowing out early when the token before the open parenthesis is a token which can be used in a (variable) function call or one of a select list of reserved keywords. The previous PR tweaked the "bowing out" to allow the sniff to operate on arbitrary parentheses which directly follow the close curly brace of a a previous scope. The additional condition added was, however, not limited to `T_CLOSE_CURLY_BRACKET` tokens. This has led to a new false positive: When a `die()`/`exit()` is used within a `switch-case` statement, the `die`/`exit` keyword will be regarded as a scope closer for the `case` statement, in which case, the parentheses for the `die`/`exit` would now be treated as arbitrary instead of as belonging to the `die`/`exit` keyword. This commit fixes this by limiting the previously introduced check for a scope closer to curly braces only. Includes tests proving the bug and safeguarding the fix. --- .../WhiteSpace/ArbitraryParenthesesSpacingSniff.php | 3 ++- .../ArbitraryParenthesesSpacingUnitTest.1.inc | 10 ++++++++++ .../ArbitraryParenthesesSpacingUnitTest.1.inc.fixed | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php index 7b4368d6c4..0963cdf528 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php @@ -103,7 +103,8 @@ public function process(File $phpcsFile, $stackPtr) $preOpener = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true); if ($preOpener !== false && isset($this->ignoreTokens[$tokens[$preOpener]['code']]) === true - && isset($tokens[$preOpener]['scope_condition']) === false + && ($tokens[$preOpener]['code'] !== T_CLOSE_CURLY_BRACKET + || isset($tokens[$preOpener]['scope_condition']) === false ) ) { // Function or language construct call. return; diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc index 8e17dbb644..4ce050840f 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc @@ -180,3 +180,13 @@ class NonArbitraryParenthesesWithKeywords { $b = match ( $a ) { 1 => true, }; + +// Parentheses after die/exit in a switch case should be ignored. +switch ( $type ) { + case A: + exit( 1 ); + case B: + die(); + default: + break; +} diff --git a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc.fixed index c215753ccb..a002280811 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.1.inc.fixed @@ -168,3 +168,13 @@ class NonArbitraryParenthesesWithKeywords { $b = match ( $a ) { 1 => true, }; + +// Parentheses after die/exit in a switch case should be ignored. +switch ( $type ) { + case A: + exit( 1 ); + case B: + die(); + default: + break; +} From 89990e2ab9a98acc39b0f94bfea69a204cb0eb77 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 25 Jan 2024 19:14:02 +0100 Subject: [PATCH 371/874] CONTRIBUTING: limit line length for readability --- .github/CONTRIBUTING.md | 114 ++++++++++++++++++++++++++++------------ 1 file changed, 79 insertions(+), 35 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 2f3d5cc292..b73cfbc464 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -6,15 +6,18 @@ Thank you for your interest in contributing to PHP_CodeSniffer! ## Reporting Bugs -Please search the [open issues](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues) to see if your issue has been reported already and if so, comment in that issue if you have additional information, instead of opening a new one. +Please search the [open issues](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues) to see if your issue has been reported +already and if so, comment in that issue if you have additional information, instead of opening a new one. Before reporting a bug, you should check what sniff an error is coming from. Running `phpcs` with the `-s` flag will show the name of the sniff for each error. -If the error code starts with anything other than `Generic`, `MySource`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend`, the error is likely coming from an external PHP_CodeSniffer standard. +If the error code starts with anything other than `Generic`, `MySource`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend`, +the error is likely coming from an external PHP_CodeSniffer standard. **Please report bugs for externally maintained sniffs to the appropriate repository.** -Bug reports containing a minimal code sample which can be used to reproduce the issue are highly appreciated as those are most easily actionable. +Bug reports containing a minimal code sample which can be used to reproduce the issue are highly appreciated as those are most +easily actionable. :point_right: Reports which only include a _screenshot_ of the code will be closed without hesitation as not actionable. @@ -24,14 +27,17 @@ Bug reports containing a minimal code sample which can be used to reproduce the PHP_CodeSniffer is a developer tool and should generally not be used in a production environment. Having said that, responsible disclosure of security issues is highly appreciated. -Issues can be reported privately to the maintainers by opening a [Security vulnerability report](https://github.com/PHPCSStandards/PHP_CodeSniffer/security/advisories/new). +Issues can be reported privately to the maintainers by opening a +[Security vulnerability report](https://github.com/PHPCSStandards/PHP_CodeSniffer/security/advisories/new). ### Support/Questions About Using PHP_CodeSniffer -Please read the [documentation in the wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki) before opening an issue with a support question. +Please read the [documentation in the wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki) before opening an issue +with a support question. -The [discussion forum](https://github.com/PHPCSStandards/PHP_CodeSniffer/discussions) or [StackOverflow](https://stackoverflow.com/questions/tagged/phpcodesniffer) are the appropriate places for support questions. +The [discussion forum](https://github.com/PHPCSStandards/PHP_CodeSniffer/discussions) or +[StackOverflow](https://stackoverflow.com/questions/tagged/phpcodesniffer) are the appropriate places for support questions. ## Contributing Without Writing Code @@ -43,16 +49,19 @@ We welcome bug triage. Bug triage is the action of verifying a reported bug is reproducible and is actually an issue. This includes checking whether the bug is something which should be fixed in **_this_** repository. -To find bugs which need triage, look for issues and PRs with the ["Status: triage"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20triage) label. +To find bugs which need triage, look for issues and PRs with the +["Status: triage"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20triage) label. #### Typical bug triage tasks: * Verify whether the bug is reproducible with the given information. * Ask for additional information if it is not. -* If you find the issue is reported to the wrong repo, ask the reporter to report it to the correct external standard repo and suggest closing the issue. +* If you find the issue is reported to the wrong repo, ask the reporter to report it to the correct external standard repo + and suggest closing the issue. Additionally, for older issues: * Check whether an issue still exists or has been fixed in `master` since the issue was initially reported. -* If it has been fixed, document (in a comment) which commit/PR was responsible for fixing the issue and suggest closing the ticket. +* If it has been fixed, document (in a comment) which commit/PR was responsible for fixing the issue + and suggest closing the ticket. ### Testing Open Pull Requests @@ -61,7 +70,9 @@ Testing pull requests to verify they fix the issue they are supposed to fix with To get access to a PHPCS version which includes the patch from a pull request, you can: * Either use a git clone of the PHP_CodeSniffer repository and check out the PR. -* Or download the PHAR file(s) for the PR, which is available from the [Test workflow](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml) as an artifact of the workflow run. +* Or download the PHAR file(s) for the PR, which is available from the + [Test workflow](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml) + as an artifact of the workflow run. The PHAR files can be found on the summary page of the test workflow run for the PR. If the workflow has not been run (yet), the PHAR artifact may not be available (yet). @@ -69,14 +80,17 @@ To get access to a PHPCS version which includes the patch from a pull request, y * Verify that the patch solves the originally reported problem. * Verify that the tests added in the PR fail without the fix and pass with the fix. * For a fix for false negatives: verify that the correct error message(s) are thrown by the patched code. -* Run the patched PHPCS version against real codebases to see if the fix creates any side effects (new false positives/false negatives). +* Run the patched PHPCS version against real codebases to see if the fix creates any side effects + (new false positives/false negatives). ### Writing sniff documentation -Sniffs in PHP_CodeSniffer should preferably be accompanied by documentation. There is currently still a lot of [documentation missing](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/148). +Sniffs in PHP_CodeSniffer should preferably be accompanied by documentation. There is currently still a lot of +[documentation missing](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/148). -Sniff documentation is provided via XML files in the standard's `Docs` directory and is available to end-users via the command-line and/or can be compiled into an HTML or Markdown file. +Sniff documentation is provided via XML files in the standard's `Docs` directory and is available to end-users +via the command-line and/or can be compiled into an HTML or Markdown file. To see an example of some of the available documentation, run: ```bash @@ -95,11 +109,13 @@ The XML files consist of several parts: * The `title` attribute in the `` tag should generally reflect the name of the sniff. * Each XML file can contain multiple `` blocks. * Each `` block can be accompanied by one or more `` blocks. -* Each code comparison block should have two `` blocks, the first one showing "valid" code, the second one showing "invalid" code. +* Each code comparison block should have two `` blocks, the first one showing "valid" code, the second one + showing "invalid" code. Some guidelines to get you started: * Keep it as simple as possible. -* When a sniff shows multiple different errors/warnings, it is recommended to have a separate `` block for each error/warning. +* When a sniff shows multiple different errors/warnings, it is recommended to have a separate `` block + for each error/warning. * The title of a "good" code sample (on the left) should start with `Valid:`. * The title of a "bad" code sample (on the right) should start with `Invalid:`. * Don't use example code which can be traced back to a specific project. @@ -123,39 +139,52 @@ There are also tasks looking for contributions, which don't necessarily fall int #### Issues marked with "Status: waiting for opinions" -Proposals for new features, proposals for (structural) changes to PHP_CodeSniffer itself or to the contributor workflow, will initially be marked with the ["Status: waiting for opinions"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20waiting%20for%20opinions) label. +Proposals for new features, proposals for (structural) changes to PHP_CodeSniffer itself or to the contributor workflow, +will initially be marked with the +["Status: waiting for opinions"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20waiting%20for%20opinions) +label. This is an open invitation for interested parties to gather their thoughts about the issue and to leave their opinion. -> Kind request: If you don't have something to add to the discussion, but do want to indicate a positive or negative opinion on a topic, please add an emoji on the original post instead of leaving a comment. +> Kind request: If you don't have something to add to the discussion, but do want to indicate a positive or negative opinion +> on a topic, please add an emoji on the original post instead of leaving a comment. #### Issues marked with "Status: needs investigation" Sometimes an issue has been identified, but it has not yet been pinpointed what the exact cause of the problem is. -Other times, like with syntax changes in PHP itself, PHP_CodeSniffer _may_, or _may not_, handle them correctly and this will need verification. +Other times, like with syntax changes in PHP itself, PHP_CodeSniffer _may_, or _may not_, handle them correctly +and this will need verification. -Issues like these will be marked with the ["Status: needs investigation"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20needs%20investigation) and investigating those can be a good way to learn more about the source code of PHP_CodeSniffer. +Issues like these will be marked with the +["Status: needs investigation"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20needs%20investigation) +and investigating those can be a good way to learn more about the source code of PHP_CodeSniffer. #### Issues marked with "Status: help wanted" -If you don't know where to start, having a browse through issues marked with the ["Status: help wanted"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20help%20wanted) and/or the ["Status: good first issue"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20good%20first%20issue) labels. +If you don't know where to start, having a browse through issues marked with the +["Status: help wanted"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20help%20wanted) and/or the +["Status: good first issue"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20good%20first%20issue) labels. ## Contributing With Code ### Requesting/Submitting New Features -Ideally, start by [opening an issue](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/new/choose) to check whether the feature is something which is suitable to be included in PHP_CodeSniffer. +Ideally, start by [opening an issue](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/new/choose) to check whether +the feature is something which is suitable to be included in PHP_CodeSniffer. It's possible that a feature may be rejected at an early stage, and it's better to find out before you write the code. -It is also good to discuss potential different implementation options ahead of time and get guidance for the preferred option from the maintainers. +It is also good to discuss potential different implementation options ahead of time and get guidance for the preferred option +from the maintainers. -Note: There may be an issue or PR open already. If so, please join the discussion in that issue or PR instead of opening a duplicate issue/PR. +Note: There may be an issue or PR open already. If so, please join the discussion in that issue or PR instead of opening +a duplicate issue/PR. > Please note: Auto-fixers will only be accepted for "non-risky" sniffs. -> If a fixer could cause parse errors or a change in the behaviour of the scanned code, the fixer will **NOT** be accepted in PHP_CodeSniffer and may be better suited to an external standard. +> If a fixer could cause parse errors or a change in the behaviour of the scanned code, the fixer will **NOT** be accepted +> in PHP_CodeSniffer and may be better suited to an external standard. ### Getting started @@ -168,7 +197,8 @@ Note: There may be an issue or PR open already. If so, please join the discussio ### While working on a patch -Please make sure your code conforms to the PHPCS coding standard, is covered by tests and that all the PHP_CodeSniffer unit tests still pass. +Please make sure your code conforms to the PHPCS coding standard, is covered by tests and that all the PHP_CodeSniffer +unit tests still pass. Also, please make sure your code is compatible with the PHP_CodeSniffer minimum supported PHP version, PHP 5.4. @@ -178,7 +208,8 @@ To help you with this, a number of convenience scripts are available: * `composer cbf` will run the autofixers for code style violations. * `composer test` will run the unit tests. * `composer coverage` will run the unit tests with code coverage and show a text summary. -* `composer coverage-local` will run the unit tests with code coverage and generate an HTML coverage report, which will be placed in a `build/coverage-html` subdirectory. +* `composer coverage-local` will run the unit tests with code coverage and generate an HTML coverage report, + which will be placed in a `build/coverage-html` subdirectory. * `composer build` will build the phpcs.phar and phpcbf.phar files. N.B.: You can ignore any skipped tests as these are for external tools. @@ -195,20 +226,29 @@ For example, for the sniff named `Generic.NamingConventions.ConstructorName`: * The sniff lives in the `src/Standards/Generic/Sniffs/NamingConventions/` directory. * The tests live in the `src/Standards/Generic/Tests/NamingConventions/` directory. * The tests consist of two files: - - `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc` which is the test _case_ file containing code for the sniff to analyse. - - `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php` which is the test file, containing two methods, `getErrorList()` and `getWarningList()`, which should each return an array with as the keys the line number in the test _case_ file and as the values the number of errors or warnings which are expected on each line. - Only lines on which errors/warnings are expected need to be included in the lists. All other lines will automatically be set to expect no errors and no warnings. + - `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc` which is the test _case_ file containing + code for the sniff to analyse. + - `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php` which is the test file, containing two methods, + `getErrorList()` and `getWarningList()`, which should each return an array with as the keys the line number + in the test _case_ file and as the values the number of errors or warnings which are expected on each line. + Only lines on which errors/warnings are expected need to be included in the lists. All other lines will automatically + be set to expect no errors and no warnings. #### Multiple test case files -At times, one test _case_ file is not enough, for instance when the sniff needs to behave differently depending on whether or code is namespaced or not, or when a sniff needs to check something at the top of a file. +At times, one test _case_ file is not enough, for instance when the sniff needs to behave differently depending on whether or code +is namespaced or not, or when a sniff needs to check something at the top of a file. The test framework allows for multiple test _case_ files. In that case, the files should be numbered and the number should be placed between the file name and the extension. -So for the above example, the `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc` would be renamed to `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.1.inc` and additional test case files should be numbered sequentially like `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.2.inc`, `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.3.inc` etc. +So for the above example, the `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc` would be renamed to +`src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.1.inc` and additional test case files should be numbered +sequentially like `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.2.inc`, +`src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.3.inc` etc. -The `getErrorList()` and the `getWarningList()` methods will receive an optional `$testFile=''` parameter with the file name of the file being scanned - `ConstructorNameUnitTest.2.inc` - and should return the appropriate array for each file. +The `getErrorList()` and the `getWarningList()` methods will receive an optional `$testFile=''` parameter with the file name +of the file being scanned - `ConstructorNameUnitTest.2.inc` - and should return the appropriate array for each file. #### Testing fixers @@ -216,7 +256,9 @@ If a sniff contains errors/warnings which can be auto-fixed, these fixers should This is done by adding a test _case_ file with an extra `.fixed` extension for each test _case_ file which expects fixes. -For example, if the above `Generic.NamingConventions.ConstructorName` would contain an auto-fixer, there should be an additional `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc.fixed` file containing the code as it is expected to be after the fixer has run. +For example, if the above `Generic.NamingConventions.ConstructorName` would contain an auto-fixer, there should be an +additional `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc.fixed` file containing the code +as it is expected to be after the fixer has run. The test framework will compare the actual fixes made with the expected fixes and will fail the tests if these don't match. @@ -226,7 +268,8 @@ Some guidelines for submitting pull requests (PRs) and improving the chance that * Please keep your PR as small as possible, but no smaller than that. If your change is complex, make sure you add a proper commit message explaining what you have done and why. * Please clean up your branch before pulling your PR. - Small PRs using atomic, descriptive commits are hugely appreciated as it will make reviewing your changes easier for the maintainers. + Small PRs using atomic, descriptive commits are hugely appreciated as it will make reviewing your changes + easier for the maintainers. * Only open your PR when you've finished work on it, and you are confident that it is ready for review. * Please make sure your pull request passes all continuous integration checks. PRs which are failing their CI checks will likely be ignored by the maintainers or closed. @@ -237,4 +280,5 @@ However, the maintainers time is also valuable and often, more scarce, so please ## Licensing -By contributing code to this repository, you agree to license your code for use under the [BSD-3-Clause license](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt). +By contributing code to this repository, you agree to license your code for use under the +[BSD-3-Clause license](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt). From 2d7f618eda0c47ef0f1c58b576345c3d7ce17bbc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 24 Jan 2024 03:13:27 +0100 Subject: [PATCH 372/874] CONTRIBUTING: iterate on the guidelines * Fix some typos. * Add some extra information about how to handle tests related to parse errors/live coding. * Add some additional information about git best practices. * Add words of warning about copyright violations and AI generated PRs. --- .github/CONTRIBUTING.md | 77 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index b73cfbc464..bf0a72d5e3 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -122,7 +122,7 @@ Some guidelines to get you started: * Each line within the code sample should be max 48 characters. * Code used in code samples should be valid PHP. * To highlight the "good" and the "bad" bits in the code examples, surround those bits with ` ...` tags. - These will be removed automatically when using the text generator, but ensure highlighting of the code in Markdown/HTML. + These will be removed automatically when using the text generator, but ensure highlighting of the code in HTML. * The indentation in the XML file should use spaces only. Four spaces for each indent. Make sure to test the documentation before submitting a PR by running: @@ -162,7 +162,7 @@ and investigating those can be a good way to learn more about the source code of #### Issues marked with "Status: help wanted" -If you don't know where to start, having a browse through issues marked with the +If you don't know where to start, have a browse through issues marked with the ["Status: help wanted"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20help%20wanted) and/or the ["Status: good first issue"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20good%20first%20issue) labels. @@ -236,7 +236,7 @@ For example, for the sniff named `Generic.NamingConventions.ConstructorName`: #### Multiple test case files -At times, one test _case_ file is not enough, for instance when the sniff needs to behave differently depending on whether or code +At times, one test _case_ file is not enough, for instance when the sniff needs to behave differently depending on whether code is namespaced or not, or when a sniff needs to check something at the top of a file. The test framework allows for multiple test _case_ files. @@ -262,6 +262,31 @@ as it is expected to be after the fixer has run. The test framework will compare the actual fixes made with the expected fixes and will fail the tests if these don't match. +#### Tests related to parse errors/live coding + +PHP_CodeSniffer can be, and is, regularly used during live coding via an IDE integration. + +This means that sniffs will often need to contain extra defensive coding related to this. +It is common for sniffs to bow out early for parse errors/live coding when it cannot be reliably determined whether +the code should be flagged or not. Additionally, making auto-fixes to code in a parse error state can make things worse. + +This defensive coding in a sniff should, of course, also be safeguarded via tests. + +Parse/compile errors can take various forms. Some can be handled without much problems by PHPCS, some can not. + +If a code snippet to be tested could lead to a broken token stream due to a parse/compile error, the code snippet should always +be put in a separate test case file by itself and be accompanied by a comment stating the test is an intentional parse error. + +Example: +```php + Date: Thu, 25 Jan 2024 19:41:05 -0300 Subject: [PATCH 373/874] Generic/IncrementDecrementSpacing: add XML documentation (#287) * Generic/IncrementDecrementSpacing: add XML documentation --- .../IncrementDecrementSpacingStandard.xml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/Standards/Generic/Docs/WhiteSpace/IncrementDecrementSpacingStandard.xml diff --git a/src/Standards/Generic/Docs/WhiteSpace/IncrementDecrementSpacingStandard.xml b/src/Standards/Generic/Docs/WhiteSpace/IncrementDecrementSpacingStandard.xml new file mode 100644 index 0000000000..92532fc685 --- /dev/null +++ b/src/Standards/Generic/Docs/WhiteSpace/IncrementDecrementSpacingStandard.xml @@ -0,0 +1,26 @@ + + + + + + + $i; +--$i['key']['id']; +ClassName::$prop++; +$obj->prop--; + ]]> + + + $i; +-- $i['key']['id']; +ClassName::$prop ++; +$obj->prop +--; + ]]> + + + From 6ba301a8ff26d674d586fdd9073f1322d1a89b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C5=BDoljom?= Date: Fri, 26 Jan 2024 14:31:48 +0100 Subject: [PATCH 374/874] [Documentation] PSR12 - Control Structure Spacing (#182) * Add the documentation for the PSR12 Control Structure Spacing sniff --- .../ControlStructureSpacingStandard.xml | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml diff --git a/src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml b/src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml new file mode 100644 index 0000000000..db4fe8028d --- /dev/null +++ b/src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml @@ -0,0 +1,124 @@ + + + + + + + ($expr) { +} + ]]> + + + ( $expr) { +} + ]]> + + + + + ($expr) { +} + ]]> + + + ) { +} + ]]> + + + + + + + + $expr1 + && $expr2 +) { +} + ]]> + + + ($expr1 + && $expr2 +) { +} + ]]> + + + + + $expr1 + && $expr2 +) { +} + ]]> + + + $expr1 + && $expr2 + && $expr3 +) { +} + ]]> + + + + + + + + ) { +} + ]]> + + + && $expr2) { +} + ]]> + + + + + ) { +} + ]]> + + + ) { +} + ]]> + + + From 39b2fed47e321aefab64d3f7a55543133fe4fc27 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 16 Jan 2024 11:42:16 -0300 Subject: [PATCH 375/874] Generic/ByteOrderMark: rename test case file To add more tests that need to go into separate files. --- ...rMarkUnitTest.inc => ByteOrderMarkUnitTest.1.inc} | 0 .../Generic/Tests/Files/ByteOrderMarkUnitTest.php | 12 ++++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) rename src/Standards/Generic/Tests/Files/{ByteOrderMarkUnitTest.inc => ByteOrderMarkUnitTest.1.inc} (100%) diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc rename to src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php index 3d80c618f6..c777d64047 100644 --- a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php @@ -26,11 +26,19 @@ final class ByteOrderMarkUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [1 => 1]; + switch ($testFile) { + case 'ByteOrderMarkUnitTest.1.inc': + return [1 => 1]; + + default: + return []; + } }//end getErrorList() From a9642e50ce2cfc0049837d53725598b4b06ed9fc Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 16 Jan 2024 11:58:23 -0300 Subject: [PATCH 376/874] Generic/ByteOrderMark: improve test coverage This commit adds four more tests case files: * 2 to cover the cases where the sniff is triggered but the file does not contain a BOM character. One of these files is in UTF-8 encoding without a BOM, the other is in ANSI/iso-8859-1 encoding. * 2 to cover the different UTF-16 encodings with a BOM character. Includes adding a comment to the original test case file to document the encoding (UTF-8 with BOM) of that file. --- .../Tests/Files/ByteOrderMarkUnitTest.1.inc | 7 ++++--- .../Tests/Files/ByteOrderMarkUnitTest.2.inc | 3 +++ .../Tests/Files/ByteOrderMarkUnitTest.3.inc | 1 + .../Tests/Files/ByteOrderMarkUnitTest.4.inc | Bin 0 -> 208 bytes .../Tests/Files/ByteOrderMarkUnitTest.5.inc | Bin 0 -> 202 bytes .../Generic/Tests/Files/ByteOrderMarkUnitTest.php | 2 ++ 6 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.2.inc create mode 100644 src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.3.inc create mode 100644 src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.4.inc create mode 100644 src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.5.inc diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.1.inc b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.1.inc index dc3bf59670..a50b622609 100644 --- a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.1.inc +++ b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.1.inc @@ -1,3 +1,4 @@ - + \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.2.inc b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.2.inc new file mode 100644 index 0000000000..6d61f0e1e7 --- /dev/null +++ b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.2.inc @@ -0,0 +1,3 @@ + + +

Some HTML

diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.3.inc b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.3.inc new file mode 100644 index 0000000000..ff1e2bf7d5 --- /dev/null +++ b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.3.inc @@ -0,0 +1 @@ +

Some HTML at the beginning of an ANSI/iso-8859-1 encoded file without a byte order mark (BOM) character

diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.4.inc b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.4.inc new file mode 100644 index 0000000000000000000000000000000000000000..312974a8286305fd6c2f894b66e061ad4da9bbd0 GIT binary patch literal 208 zcmXYr%?<%U5QM+8rkq`&Mfd`mn{bX62%_idI@y(J>PghrU*YxK-VM@it z>=;8Mu;9v#T=Wz*s)1EXD9fJwvl5S;H{ZzF|67fiOi5j4$%?Ymqw|pB2e5%63jhEB literal 0 HcmV?d00001 diff --git a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php index c777d64047..c1c3e292e3 100644 --- a/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php @@ -34,6 +34,8 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'ByteOrderMarkUnitTest.1.inc': + case 'ByteOrderMarkUnitTest.4.inc': + case 'ByteOrderMarkUnitTest.5.inc': return [1 => 1]; default: From ee00afcbc7912e67e10aca7b9a5759776d659d88 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 31 Dec 2023 10:37:18 +0100 Subject: [PATCH 377/874] GH Actions: re-attempt upgrade actions/[upload|download]-artifact from 3 to 4 The upstream issue appears to have been fixed. Let's try this again. Re-does PR 172+173 and reverts PR 204. Ref: actions/download-artifact 249 Fixes 208 --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 970be4bf63..7a6c6677d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: run: php scripts/build-phar.php - name: Upload the PHPCS phar - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: phpcs-phar path: ./phpcs.phar @@ -48,7 +48,7 @@ jobs: retention-days: 28 - name: Upload the PHPCBF phar - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: phpcbf-phar path: ./phpcbf.phar @@ -165,7 +165,7 @@ jobs: - name: Download the PHPCS phar if: ${{ matrix.custom_ini == false }} - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: phpcs-phar From 4b77eb3a4a73201175946be91f75ed1ad2e9bea5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Jan 2024 04:36:22 +0100 Subject: [PATCH 378/874] Tests/Tokenizer: make failure messages more descriptive Most Tokenizer tests first assert that the token `'code'` is correct and after that, that the token `'type'` is correct. When the first assertion fails, an error message like this will be displayed: `Failed asserting that 357 is identical to 313.` That's because the PHP native token constants are integers. And even if someone would memorize all token constant integers, the integer values are different depending on the PHP version being used. All in all, that makes error messages like the above hard to decipher. To mitigate this, a number of the Tokenizer tests already used the `$msg` parameter for the `assertSame()` call. This commit adds this `$msg` parameter to more assertions to make the failure messages actually useful. Includes introducing an interim `$tokenArray` variable in a lot of these tests to keep the line length in check. --- tests/Core/Tokenizer/BackfillEnumTest.php | 31 +++++++------- .../BackfillNumericSeparatorTest.php | 18 ++++++--- tests/Core/Tokenizer/BackfillReadonlyTest.php | 18 +++++---- tests/Core/Tokenizer/BitwiseOrTest.php | 18 +++++---- .../ContextSensitiveKeywordsTest.php | 28 ++++++++----- tests/Core/Tokenizer/EnumCaseTest.php | 40 +++++++++---------- tests/Core/Tokenizer/FinallyTest.php | 18 +++++---- tests/Core/Tokenizer/GotoLabelTest.php | 9 +++-- tests/Core/Tokenizer/ShortArrayTest.php | 34 +++++++++------- .../Tokenizer/StableCommentWhitespaceTest.php | 12 +++++- .../StableCommentWhitespaceWinTest.php | 12 +++++- tests/Core/Tokenizer/TypeIntersectionTest.php | 18 +++++---- .../UndoNamespacedNameSingleTokenTest.php | 13 +++++- 13 files changed, 162 insertions(+), 107 deletions(-) diff --git a/tests/Core/Tokenizer/BackfillEnumTest.php b/tests/Core/Tokenizer/BackfillEnumTest.php index 6027c181dd..b48651ac3e 100644 --- a/tests/Core/Tokenizer/BackfillEnumTest.php +++ b/tests/Core/Tokenizer/BackfillEnumTest.php @@ -30,21 +30,21 @@ final class BackfillEnumTest extends AbstractMethodUnitTest */ public function testEnums($testMarker, $testContent, $openerOffset, $closerOffset) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $enum = $this->getTargetToken($testMarker, [T_ENUM, T_STRING], $testContent); + $tokenArray = $tokens[$enum]; - $enum = $this->getTargetToken($testMarker, [T_ENUM, T_STRING], $testContent); + $this->assertSame(T_ENUM, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_ENUM (code)'); + $this->assertSame('T_ENUM', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_ENUM (type)'); - $this->assertSame(T_ENUM, $tokens[$enum]['code']); - $this->assertSame('T_ENUM', $tokens[$enum]['type']); + $this->assertArrayHasKey('scope_condition', $tokenArray); + $this->assertArrayHasKey('scope_opener', $tokenArray); + $this->assertArrayHasKey('scope_closer', $tokenArray); - $this->assertArrayHasKey('scope_condition', $tokens[$enum]); - $this->assertArrayHasKey('scope_opener', $tokens[$enum]); - $this->assertArrayHasKey('scope_closer', $tokens[$enum]); + $this->assertSame($enum, $tokenArray['scope_condition']); - $this->assertSame($enum, $tokens[$enum]['scope_condition']); - - $scopeOpener = $tokens[$enum]['scope_opener']; - $scopeCloser = $tokens[$enum]['scope_closer']; + $scopeOpener = $tokenArray['scope_opener']; + $scopeCloser = $tokenArray['scope_closer']; $expectedScopeOpener = ($enum + $openerOffset); $expectedScopeCloser = ($enum + $closerOffset); @@ -138,11 +138,12 @@ public static function dataEnums() */ public function testNotEnums($testMarker, $testContent) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_ENUM, T_STRING], $testContent); + $tokenArray = $tokens[$target]; - $target = $this->getTargetToken($testMarker, [T_ENUM, T_STRING], $testContent); - $this->assertSame(T_STRING, $tokens[$target]['code']); - $this->assertSame('T_STRING', $tokens[$target]['type']); + $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); + $this->assertSame('T_STRING', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (type)'); }//end testNotEnums() diff --git a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php index b953a3ac93..107b9443f1 100644 --- a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php +++ b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php @@ -10,6 +10,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +use PHP_CodeSniffer\Util\Tokens; final class BackfillNumericSeparatorTest extends AbstractMethodUnitTest { @@ -29,12 +30,13 @@ final class BackfillNumericSeparatorTest extends AbstractMethodUnitTest */ public function testBackfill($marker, $type, $value) { - $tokens = self::$phpcsFile->getTokens(); - $number = $this->getTargetToken($marker, [T_LNUMBER, T_DNUMBER]); + $tokens = self::$phpcsFile->getTokens(); + $number = $this->getTargetToken($marker, [T_LNUMBER, T_DNUMBER]); + $tokenArray = $tokens[$number]; - $this->assertSame(constant($type), $tokens[$number]['code']); - $this->assertSame($type, $tokens[$number]['type']); - $this->assertSame($value, $tokens[$number]['content']); + $this->assertSame(constant($type), $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not '.$type.' (code)'); + $this->assertSame($type, $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not '.$type.' (type)'); + $this->assertSame($value, $tokenArray['content']); }//end testBackfill() @@ -153,7 +155,11 @@ public function testNoBackfill($testMarker, $expectedTokens) foreach ($expectedTokens as $key => $expectedToken) { $i = ($number + $key); - $this->assertSame($expectedToken['code'], $tokens[$i]['code']); + $this->assertSame( + $expectedToken['code'], + $tokens[$i]['code'], + 'Token tokenized as '.Tokens::tokenName($tokens[$i]['code']).', not '.Tokens::tokenName($expectedToken['code']) + ); $this->assertSame($expectedToken['content'], $tokens[$i]['content']); } diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index f044e924a6..a5ff50e06d 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -29,11 +29,12 @@ final class BackfillReadonlyTest extends AbstractMethodUnitTest */ public function testReadonly($testMarker, $testContent='readonly') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_READONLY, T_STRING], $testContent); + $tokenArray = $tokens[$target]; - $target = $this->getTargetToken($testMarker, [T_READONLY, T_STRING], $testContent); - $this->assertSame(T_READONLY, $tokens[$target]['code']); - $this->assertSame('T_READONLY', $tokens[$target]['type']); + $this->assertSame(T_READONLY, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_READONLY (code)'); + $this->assertSame('T_READONLY', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_READONLY (type)'); }//end testReadonly() @@ -174,11 +175,12 @@ public static function dataReadonly() */ public function testNotReadonly($testMarker, $testContent='readonly') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_READONLY, T_STRING], $testContent); + $tokenArray = $tokens[$target]; - $target = $this->getTargetToken($testMarker, [T_READONLY, T_STRING], $testContent); - $this->assertSame(T_STRING, $tokens[$target]['code']); - $this->assertSame('T_STRING', $tokens[$target]['type']); + $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); + $this->assertSame('T_STRING', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (type)'); }//end testNotReadonly() diff --git a/tests/Core/Tokenizer/BitwiseOrTest.php b/tests/Core/Tokenizer/BitwiseOrTest.php index a21f6f174a..4802777238 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.php +++ b/tests/Core/Tokenizer/BitwiseOrTest.php @@ -27,11 +27,12 @@ final class BitwiseOrTest extends AbstractMethodUnitTest */ public function testBitwiseOr($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_BITWISE_OR, T_TYPE_UNION]); + $tokenArray = $tokens[$target]; - $opener = $this->getTargetToken($testMarker, [T_BITWISE_OR, T_TYPE_UNION]); - $this->assertSame(T_BITWISE_OR, $tokens[$opener]['code']); - $this->assertSame('T_BITWISE_OR', $tokens[$opener]['type']); + $this->assertSame(T_BITWISE_OR, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_BITWISE_OR (code)'); + $this->assertSame('T_BITWISE_OR', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_BITWISE_OR (type)'); }//end testBitwiseOr() @@ -78,11 +79,12 @@ public static function dataBitwiseOr() */ public function testTypeUnion($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_BITWISE_OR, T_TYPE_UNION]); + $tokenArray = $tokens[$target]; - $opener = $this->getTargetToken($testMarker, [T_BITWISE_OR, T_TYPE_UNION]); - $this->assertSame(T_TYPE_UNION, $tokens[$opener]['code']); - $this->assertSame('T_TYPE_UNION', $tokens[$opener]['type']); + $this->assertSame(T_TYPE_UNION, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_TYPE_UNION (code)'); + $this->assertSame('T_TYPE_UNION', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_TYPE_UNION (type)'); }//end testTypeUnion() diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php index e30a86fa8f..0dec381f9b 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php @@ -28,12 +28,12 @@ final class ContextSensitiveKeywordsTest extends AbstractMethodUnitTest */ public function testStrings($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, (Tokens::$contextSensitiveKeywords + [T_STRING, T_NULL, T_FALSE, T_TRUE, T_PARENT, T_SELF])); + $tokenArray = $tokens[$target]; - $token = $this->getTargetToken($testMarker, (Tokens::$contextSensitiveKeywords + [T_STRING, T_NULL, T_FALSE, T_TRUE, T_PARENT, T_SELF])); - - $this->assertSame(T_STRING, $tokens[$token]['code']); - $this->assertSame('T_STRING', $tokens[$token]['type']); + $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); + $this->assertSame('T_STRING', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (type)'); }//end testStrings() @@ -167,15 +167,23 @@ public static function dataStrings() */ public function testKeywords($testMarker, $expectedTokenType) { - $tokens = self::$phpcsFile->getTokens(); - - $token = $this->getTargetToken( + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken( $testMarker, (Tokens::$contextSensitiveKeywords + [T_ANON_CLASS, T_MATCH_DEFAULT, T_PARENT, T_SELF, T_STRING, T_NULL, T_FALSE, T_TRUE]) ); + $tokenArray = $tokens[$target]; - $this->assertSame(constant($expectedTokenType), $tokens[$token]['code']); - $this->assertSame($expectedTokenType, $tokens[$token]['type']); + $this->assertSame( + constant($expectedTokenType), + $tokenArray['code'], + 'Token tokenized as '.$tokenArray['type'].', not '.$expectedTokenType.' (code)' + ); + $this->assertSame( + $expectedTokenType, + $tokenArray['type'], + 'Token tokenized as '.$tokenArray['type'].', not '.$expectedTokenType.' (type)' + ); }//end testKeywords() diff --git a/tests/Core/Tokenizer/EnumCaseTest.php b/tests/Core/Tokenizer/EnumCaseTest.php index 26a8699daf..1e6dcf6642 100644 --- a/tests/Core/Tokenizer/EnumCaseTest.php +++ b/tests/Core/Tokenizer/EnumCaseTest.php @@ -28,16 +28,16 @@ final class EnumCaseTest extends AbstractMethodUnitTest */ public function testEnumCases($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $enumCase = $this->getTargetToken($testMarker, [T_ENUM_CASE, T_CASE]); + $tokenArray = $tokens[$enumCase]; - $enumCase = $this->getTargetToken($testMarker, [T_ENUM_CASE, T_CASE]); + $this->assertSame(T_ENUM_CASE, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_ENUM_CASE (code)'); + $this->assertSame('T_ENUM_CASE', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_ENUM_CASE (type)'); - $this->assertSame(T_ENUM_CASE, $tokens[$enumCase]['code']); - $this->assertSame('T_ENUM_CASE', $tokens[$enumCase]['type']); - - $this->assertArrayNotHasKey('scope_condition', $tokens[$enumCase], 'Scope condition is set'); - $this->assertArrayNotHasKey('scope_opener', $tokens[$enumCase], 'Scope opener is set'); - $this->assertArrayNotHasKey('scope_closer', $tokens[$enumCase], 'Scope closer is set'); + $this->assertArrayNotHasKey('scope_condition', $tokenArray, 'Scope condition is set'); + $this->assertArrayNotHasKey('scope_opener', $tokenArray, 'Scope opener is set'); + $this->assertArrayNotHasKey('scope_closer', $tokenArray, 'Scope closer is set'); }//end testEnumCases() @@ -77,16 +77,16 @@ public static function dataEnumCases() */ public function testNotEnumCases($testMarker) { - $tokens = self::$phpcsFile->getTokens(); - - $case = $this->getTargetToken($testMarker, [T_ENUM_CASE, T_CASE]); + $tokens = self::$phpcsFile->getTokens(); + $case = $this->getTargetToken($testMarker, [T_ENUM_CASE, T_CASE]); + $tokenArray = $tokens[$case]; - $this->assertSame(T_CASE, $tokens[$case]['code']); - $this->assertSame('T_CASE', $tokens[$case]['type']); + $this->assertSame(T_CASE, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_CASE (code)'); + $this->assertSame('T_CASE', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_CASE (type)'); - $this->assertArrayHasKey('scope_condition', $tokens[$case], 'Scope condition is not set'); - $this->assertArrayHasKey('scope_opener', $tokens[$case], 'Scope opener is not set'); - $this->assertArrayHasKey('scope_closer', $tokens[$case], 'Scope closer is not set'); + $this->assertArrayHasKey('scope_condition', $tokenArray, 'Scope condition is not set'); + $this->assertArrayHasKey('scope_opener', $tokenArray, 'Scope opener is not set'); + $this->assertArrayHasKey('scope_closer', $tokenArray, 'Scope closer is not set'); }//end testNotEnumCases() @@ -125,12 +125,12 @@ public static function dataNotEnumCases() */ public function testKeywordAsEnumCaseNameShouldBeString($testMarker) { - $tokens = self::$phpcsFile->getTokens(); - + $tokens = self::$phpcsFile->getTokens(); $enumCaseName = $this->getTargetToken($testMarker, [T_STRING, T_INTERFACE, T_TRAIT, T_ENUM, T_FUNCTION, T_FALSE, T_DEFAULT, T_ARRAY]); + $tokenArray = $tokens[$enumCaseName]; - $this->assertSame(T_STRING, $tokens[$enumCaseName]['code']); - $this->assertSame('T_STRING', $tokens[$enumCaseName]['type']); + $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); + $this->assertSame('T_STRING', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (type)'); }//end testKeywordAsEnumCaseNameShouldBeString() diff --git a/tests/Core/Tokenizer/FinallyTest.php b/tests/Core/Tokenizer/FinallyTest.php index 428fb356ff..455dad8ac0 100644 --- a/tests/Core/Tokenizer/FinallyTest.php +++ b/tests/Core/Tokenizer/FinallyTest.php @@ -27,11 +27,12 @@ final class FinallyTest extends AbstractMethodUnitTest */ public function testFinallyKeyword($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_FINALLY, T_STRING]); + $tokenArray = $tokens[$target]; - $target = $this->getTargetToken($testMarker, [T_FINALLY, T_STRING]); - $this->assertSame(T_FINALLY, $tokens[$target]['code']); - $this->assertSame('T_FINALLY', $tokens[$target]['type']); + $this->assertSame(T_FINALLY, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_FINALLY (code)'); + $this->assertSame('T_FINALLY', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_FINALLY (type)'); }//end testFinallyKeyword() @@ -66,11 +67,12 @@ public static function dataFinallyKeyword() */ public function testFinallyNonKeyword($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_FINALLY, T_STRING]); + $tokenArray = $tokens[$target]; - $target = $this->getTargetToken($testMarker, [T_FINALLY, T_STRING]); - $this->assertSame(T_STRING, $tokens[$target]['code']); - $this->assertSame('T_STRING', $tokens[$target]['type']); + $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); + $this->assertSame('T_STRING', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (type)'); }//end testFinallyNonKeyword() diff --git a/tests/Core/Tokenizer/GotoLabelTest.php b/tests/Core/Tokenizer/GotoLabelTest.php index 62a0a697ed..869c76f19b 100644 --- a/tests/Core/Tokenizer/GotoLabelTest.php +++ b/tests/Core/Tokenizer/GotoLabelTest.php @@ -120,11 +120,12 @@ public static function dataGotoDeclaration() */ public function testNotAGotoDeclaration($testMarker, $testContent) { - $tokens = self::$phpcsFile->getTokens(); - $target = $this->getTargetToken($testMarker, [T_GOTO_LABEL, T_STRING], $testContent); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_GOTO_LABEL, T_STRING], $testContent); + $tokenArray = $tokens[$target]; - $this->assertSame(T_STRING, $tokens[$target]['code']); - $this->assertSame('T_STRING', $tokens[$target]['type']); + $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); + $this->assertSame('T_STRING', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (type)'); }//end testNotAGotoDeclaration() diff --git a/tests/Core/Tokenizer/ShortArrayTest.php b/tests/Core/Tokenizer/ShortArrayTest.php index a4273adc90..884795d60c 100644 --- a/tests/Core/Tokenizer/ShortArrayTest.php +++ b/tests/Core/Tokenizer/ShortArrayTest.php @@ -27,16 +27,19 @@ final class ShortArrayTest extends AbstractMethodUnitTest */ public function testSquareBrackets($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $opener = $this->getTargetToken($testMarker, [T_OPEN_SQUARE_BRACKET, T_OPEN_SHORT_ARRAY]); + $tokenArray = $tokens[$opener]; - $opener = $this->getTargetToken($testMarker, [T_OPEN_SQUARE_BRACKET, T_OPEN_SHORT_ARRAY]); - $this->assertSame(T_OPEN_SQUARE_BRACKET, $tokens[$opener]['code']); - $this->assertSame('T_OPEN_SQUARE_BRACKET', $tokens[$opener]['type']); + $this->assertSame(T_OPEN_SQUARE_BRACKET, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_OPEN_SQUARE_BRACKET (code)'); + $this->assertSame('T_OPEN_SQUARE_BRACKET', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_OPEN_SQUARE_BRACKET (type)'); if (isset($tokens[$opener]['bracket_closer']) === true) { - $closer = $tokens[$opener]['bracket_closer']; - $this->assertSame(T_CLOSE_SQUARE_BRACKET, $tokens[$closer]['code']); - $this->assertSame('T_CLOSE_SQUARE_BRACKET', $tokens[$closer]['type']); + $closer = $tokens[$opener]['bracket_closer']; + $tokenArray = $tokens[$closer]; + + $this->assertSame(T_CLOSE_SQUARE_BRACKET, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_CLOSE_SQUARE_BRACKET (code)'); + $this->assertSame('T_CLOSE_SQUARE_BRACKET', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_CLOSE_SQUARE_BRACKET (type)'); } }//end testSquareBrackets() @@ -92,16 +95,19 @@ public static function dataSquareBrackets() */ public function testShortArrays($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $opener = $this->getTargetToken($testMarker, [T_OPEN_SQUARE_BRACKET, T_OPEN_SHORT_ARRAY]); + $tokenArray = $tokens[$opener]; - $opener = $this->getTargetToken($testMarker, [T_OPEN_SQUARE_BRACKET, T_OPEN_SHORT_ARRAY]); - $this->assertSame(T_OPEN_SHORT_ARRAY, $tokens[$opener]['code']); - $this->assertSame('T_OPEN_SHORT_ARRAY', $tokens[$opener]['type']); + $this->assertSame(T_OPEN_SHORT_ARRAY, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_OPEN_SHORT_ARRAY (code)'); + $this->assertSame('T_OPEN_SHORT_ARRAY', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_OPEN_SHORT_ARRAY (type)'); if (isset($tokens[$opener]['bracket_closer']) === true) { - $closer = $tokens[$opener]['bracket_closer']; - $this->assertSame(T_CLOSE_SHORT_ARRAY, $tokens[$closer]['code']); - $this->assertSame('T_CLOSE_SHORT_ARRAY', $tokens[$closer]['type']); + $closer = $tokens[$opener]['bracket_closer']; + $tokenArray = $tokens[$closer]; + + $this->assertSame(T_CLOSE_SHORT_ARRAY, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_CLOSE_SHORT_ARRAY (code)'); + $this->assertSame('T_CLOSE_SHORT_ARRAY', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_CLOSE_SHORT_ARRAY (type)'); } }//end testShortArrays() diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php index 466aecd1c9..cd54e687ec 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php @@ -39,8 +39,16 @@ public function testCommentTokenization($testMarker, $expectedTokens) $comment = $this->getTargetToken($testMarker, Tokens::$commentTokens); foreach ($expectedTokens as $key => $tokenInfo) { - $this->assertSame(constant($tokenInfo['type']), $tokens[$comment]['code']); - $this->assertSame($tokenInfo['type'], $tokens[$comment]['type']); + $this->assertSame( + constant($tokenInfo['type']), + $tokens[$comment]['code'], + 'Token tokenized as '.Tokens::tokenName($tokens[$comment]['code']).', not '.$tokenInfo['type'].' (code)' + ); + $this->assertSame( + $tokenInfo['type'], + $tokens[$comment]['type'], + 'Token tokenized as '.$tokens[$comment]['type'].', not '.$tokenInfo['type'].' (type)' + ); $this->assertSame($tokenInfo['content'], $tokens[$comment]['content']); ++$comment; diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php index d63159224d..2247192a5b 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php @@ -36,8 +36,16 @@ public function testCommentTokenization($testMarker, $expectedTokens) $comment = $this->getTargetToken($testMarker, Tokens::$commentTokens); foreach ($expectedTokens as $key => $tokenInfo) { - $this->assertSame(constant($tokenInfo['type']), $tokens[$comment]['code']); - $this->assertSame($tokenInfo['type'], $tokens[$comment]['type']); + $this->assertSame( + constant($tokenInfo['type']), + $tokens[$comment]['code'], + 'Token tokenized as '.Tokens::tokenName($tokens[$comment]['code']).', not '.$tokenInfo['type'].' (code)' + ); + $this->assertSame( + $tokenInfo['type'], + $tokens[$comment]['type'], + 'Token tokenized as '.$tokens[$comment]['type'].', not '.$tokenInfo['type'].' (type)' + ); $this->assertSame($tokenInfo['content'], $tokens[$comment]['content']); ++$comment; diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.php b/tests/Core/Tokenizer/TypeIntersectionTest.php index 5ac025240b..5a11be1262 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.php +++ b/tests/Core/Tokenizer/TypeIntersectionTest.php @@ -28,11 +28,12 @@ final class TypeIntersectionTest extends AbstractMethodUnitTest */ public function testBitwiseAnd($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_BITWISE_AND, T_TYPE_INTERSECTION]); + $tokenArray = $tokens[$target]; - $opener = $this->getTargetToken($testMarker, [T_BITWISE_AND, T_TYPE_INTERSECTION]); - $this->assertSame(T_BITWISE_AND, $tokens[$opener]['code']); - $this->assertSame('T_BITWISE_AND', $tokens[$opener]['type']); + $this->assertSame(T_BITWISE_AND, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_BITWISE_AND (code)'); + $this->assertSame('T_BITWISE_AND', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_BITWISE_AND (type)'); }//end testBitwiseAnd() @@ -81,11 +82,12 @@ public static function dataBitwiseAnd() */ public function testTypeIntersection($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = self::$phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_BITWISE_AND, T_TYPE_INTERSECTION]); + $tokenArray = $tokens[$target]; - $opener = $this->getTargetToken($testMarker, [T_BITWISE_AND, T_TYPE_INTERSECTION]); - $this->assertSame(T_TYPE_INTERSECTION, $tokens[$opener]['code']); - $this->assertSame('T_TYPE_INTERSECTION', $tokens[$opener]['type']); + $this->assertSame(T_TYPE_INTERSECTION, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_TYPE_INTERSECTION (code)'); + $this->assertSame('T_TYPE_INTERSECTION', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_TYPE_INTERSECTION (type)'); }//end testTypeIntersection() diff --git a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php index 6db1156652..3a15aae155 100644 --- a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php +++ b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php @@ -20,6 +20,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +use PHP_CodeSniffer\Util\Tokens; final class UndoNamespacedNameSingleTokenTest extends AbstractMethodUnitTest { @@ -42,8 +43,16 @@ public function testIdentifierTokenization($testMarker, $expectedTokens) $identifier = $this->getTargetToken($testMarker, constant($expectedTokens[0]['type'])); foreach ($expectedTokens as $key => $tokenInfo) { - $this->assertSame(constant($tokenInfo['type']), $tokens[$identifier]['code']); - $this->assertSame($tokenInfo['type'], $tokens[$identifier]['type']); + $this->assertSame( + constant($tokenInfo['type']), + $tokens[$identifier]['code'], + 'Token tokenized as '.Tokens::tokenName($tokens[$identifier]['code']).', not '.$tokenInfo['type'].' (code)' + ); + $this->assertSame( + $tokenInfo['type'], + $tokens[$identifier]['type'], + 'Token tokenized as '.$tokens[$identifier]['type'].', not '.$tokenInfo['type'].' (type)' + ); $this->assertSame($tokenInfo['content'], $tokens[$identifier]['content']); ++$identifier; From d03baccf6eb7d4578c8c230075c60b4985f69f4a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 29 Jan 2024 03:49:07 +0100 Subject: [PATCH 379/874] AbstractMethodUnitTest: move getTargetToken() logic to static method The Core test suite is going to get at least one more test case and this new test case class will also need a `getTargetToken()` method. To prevent having to duplicate the logic and needing to maintain it in multiple places, this commit introduces a `getTargetTokenFromFile()` method which takes a `$phpcsFile` parameter, which allows for the method to become `static`, which in turn allows for the method to be used by other test case classes. The original `getTargetToken()` method still has the same functionality as before, it now just calls the `getTargetTokenFromFile()` method under the hood. --- tests/Core/AbstractMethodUnitTest.php | 33 ++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/tests/Core/AbstractMethodUnitTest.php b/tests/Core/AbstractMethodUnitTest.php index 9923d6d168..9f7cefec17 100644 --- a/tests/Core/AbstractMethodUnitTest.php +++ b/tests/Core/AbstractMethodUnitTest.php @@ -11,6 +11,7 @@ use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; use ReflectionProperty; @@ -92,8 +93,28 @@ public static function initializeFile() */ public function getTargetToken($commentString, $tokenType, $tokenContent=null) { - $start = (self::$phpcsFile->numTokens - 1); - $comment = self::$phpcsFile->findPrevious( + return self::getTargetTokenFromFile(self::$phpcsFile, $commentString, $tokenType, $tokenContent); + + }//end getTargetToken() + + + /** + * Get the token pointer for a target token based on a specific comment found on the line before. + * + * Note: the test delimiter comment MUST start with "/* test" to allow this function to + * distinguish between comments used *in* a test and test delimiters. + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file to find the token in. + * @param string $commentString The delimiter comment to look for. + * @param int|string|array $tokenType The type of token(s) to look for. + * @param string $tokenContent Optional. The token content for the target token. + * + * @return int + */ + public static function getTargetTokenFromFile(File $phpcsFile, $commentString, $tokenType, $tokenContent=null) + { + $start = ($phpcsFile->numTokens - 1); + $comment = $phpcsFile->findPrevious( T_COMMENT, $start, null, @@ -101,7 +122,7 @@ public function getTargetToken($commentString, $tokenType, $tokenContent=null) $commentString ); - $tokens = self::$phpcsFile->getTokens(); + $tokens = $phpcsFile->getTokens(); $end = ($start + 1); // Limit the token finding to between this and the next delimiter comment. @@ -116,7 +137,7 @@ public function getTargetToken($commentString, $tokenType, $tokenContent=null) } } - $target = self::$phpcsFile->findNext( + $target = $phpcsFile->findNext( $tokenType, ($comment + 1), $end, @@ -130,12 +151,12 @@ public function getTargetToken($commentString, $tokenType, $tokenContent=null) $msg .= ' With token content: '.$tokenContent; } - $this->assertFalse(true, $msg); + self::assertFalse(true, $msg); } return $target; - }//end getTargetToken() + }//end getTargetTokenFromFile() /** From 921285eadb6d4dea691af080724c77342ed0568f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 29 Jan 2024 04:14:47 +0100 Subject: [PATCH 380/874] Tests: new `AbstractTokenizerTestCase` class Until now, code coverage was not being recorded for the Tokenizer tests due to the way the tests were set up. This new `AbstractTokenizerTestCase` class is intended to fix this. **Background info:** * Code run in a `setUpBeforeClass()` method does not cause code coverage to be recorded. * Code run in a `setUp()` method _does_ cause code coverage to be recorded. Now, the `AbstractMethodUnitTest` test case class was originally set up to allow for testing the utility methods in the `File` class. To do so in the most efficient way and to allow the tests to be fast, the file containing the code being used in the tests, is only tokenized once in a `setUpBeforeClass()` method. Over time, when Tokenizer tests were being introduced, the `AbstractMethodUnitTest` class also started to be used by these, which was fine as code coverage wasn't being measured or recorded anyway. However, this last part has been changed recently via PR 144, so now it is time to ensure that the Tokenizer related tests record code coverage too. This new test case class allows for that by moving the tokenization of the code used in the tests from `setUpBeforeClass()` to a `setUp()` method. As the tokenized file won't change during the test run, this is still only done once, but as that "once" is now in the `setUp()` method, it should allow for code coverage to be recorded. Note: while code coverage can now be measured and recorded for Tokenizer related tests, it will still not be very precise as the `Tokenizer\PHP` class contains "monster methods", which means that the `@covers` tags in the Tokenizer related tests cannot be set up to target only a small, specific part of that class, as targeted by the test. But that's a problem for another time. Loosely related to 146 --- .../Tokenizer/AbstractTokenizerTestCase.php | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 tests/Core/Tokenizer/AbstractTokenizerTestCase.php diff --git a/tests/Core/Tokenizer/AbstractTokenizerTestCase.php b/tests/Core/Tokenizer/AbstractTokenizerTestCase.php new file mode 100644 index 0000000000..b51dde79d7 --- /dev/null +++ b/tests/Core/Tokenizer/AbstractTokenizerTestCase.php @@ -0,0 +1,105 @@ + + * @copyright 2018-2019 Juliette Reinders Folmer. All rights reserved. + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +use PHPUnit\Framework\TestCase; + +abstract class AbstractTokenizerTestCase extends TestCase +{ + + /** + * The file extension of the test case file (without leading dot). + * + * This allows child classes to overrule the default `inc` with, for instance, + * `js` or `css` when applicable. + * + * @var string + */ + protected $fileExtension = 'inc'; + + /** + * The tab width setting to use when tokenizing the file. + * + * This allows for test case files to use a different tab width than the default. + * + * @var integer + */ + protected $tabWidth = 4; + + /** + * The \PHP_CodeSniffer\Files\File object containing the parsed contents of the test case file. + * + * @var \PHP_CodeSniffer\Files\File + */ + protected $phpcsFile; + + + /** + * Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file. + * + * The test case file for a unit test class has to be in the same directory + * directory and use the same file name as the test class, using the .inc extension. + * + * @before + * + * @return void + */ + protected function initializeFile() + { + if (isset($this->phpcsFile) === false) { + $config = new ConfigDouble(); + // Also set a tab-width to enable testing tab-replaced vs `orig_content`. + $config->tabWidth = $this->tabWidth; + + $ruleset = new Ruleset($config); + + // Default to a file with the same name as the test class. Extension is property based. + $relativeCN = str_replace(__NAMESPACE__, '', get_called_class()); + $relativePath = str_replace('\\', DIRECTORY_SEPARATOR, $relativeCN); + $pathToTestFile = realpath(__DIR__).$relativePath.'.'.$this->fileExtension; + + // Make sure the file gets parsed correctly based on the file type. + $contents = 'phpcs_input_file: '.$pathToTestFile.PHP_EOL; + $contents .= file_get_contents($pathToTestFile); + + $this->phpcsFile = new DummyFile($contents, $ruleset, $config); + $this->phpcsFile->process(); + } + + }//end initializeFile() + + + /** + * Get the token pointer for a target token based on a specific comment found on the line before. + * + * Note: the test delimiter comment MUST start with "/* test" to allow this function to + * distinguish between comments used *in* a test and test delimiters. + * + * @param string $commentString The delimiter comment to look for. + * @param int|string|array $tokenType The type of token(s) to look for. + * @param string $tokenContent Optional. The token content for the target token. + * + * @return int + */ + protected function getTargetToken($commentString, $tokenType, $tokenContent=null) + { + return AbstractMethodUnitTest::getTargetTokenFromFile($this->phpcsFile, $commentString, $tokenType, $tokenContent); + + }//end getTargetToken() + + +}//end class From af03a22b20d3d018beb94429e4750a6126f48428 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 29 Jan 2024 04:18:52 +0100 Subject: [PATCH 381/874] Implement use of the new AbstractTokenizerTestCase class --- .../AnonClassParenthesisOwnerTest.php | 10 ++-- tests/Core/Tokenizer/ArrayKeywordTest.php | 10 ++-- tests/Core/Tokenizer/AttributesTest.php | 18 +++--- tests/Core/Tokenizer/BackfillEnumTest.php | 8 +-- .../BackfillExplicitOctalNotationTest.php | 6 +- tests/Core/Tokenizer/BackfillFnTokenTest.php | 22 ++++---- .../Core/Tokenizer/BackfillMatchTokenTest.php | 13 ++--- .../BackfillNumericSeparatorTest.php | 7 +-- tests/Core/Tokenizer/BackfillReadonlyTest.php | 8 +-- tests/Core/Tokenizer/BitwiseOrTest.php | 8 +-- .../ContextSensitiveKeywordsTest.php | 7 +-- tests/Core/Tokenizer/DefaultKeywordTest.php | 12 ++-- tests/Core/Tokenizer/DoubleArrowTest.php | 10 ++-- .../Core/Tokenizer/DoubleQuotedStringTest.php | 6 +- tests/Core/Tokenizer/EnumCaseTest.php | 10 ++-- tests/Core/Tokenizer/FinallyTest.php | 8 +-- tests/Core/Tokenizer/GotoLabelTest.php | 10 ++-- .../Tokenizer/HeredocNowdocCloserTest.php | 6 +- tests/Core/Tokenizer/HeredocStringTest.php | 8 +-- .../NamedFunctionCallArgumentsTest.php | 55 +++++++++---------- .../Tokenizer/NullsafeObjectOperatorTest.php | 11 ++-- .../ScopeSettingWithNamespaceOperatorTest.php | 6 +- tests/Core/Tokenizer/ShortArrayTest.php | 8 +-- .../Tokenizer/StableCommentWhitespaceTest.php | 5 +- .../StableCommentWhitespaceWinTest.php | 5 +- tests/Core/Tokenizer/TypeIntersectionTest.php | 8 +-- .../UndoNamespacedNameSingleTokenTest.php | 5 +- 27 files changed, 122 insertions(+), 168 deletions(-) diff --git a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php index c923371ce0..a22481c0cf 100644 --- a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php +++ b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class AnonClassParenthesisOwnerTest extends AbstractMethodUnitTest +final class AnonClassParenthesisOwnerTest extends AbstractTokenizerTestCase { @@ -27,7 +25,7 @@ final class AnonClassParenthesisOwnerTest extends AbstractMethodUnitTest */ public function testAnonClassNoParentheses($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $anonClass = $this->getTargetToken($testMarker, T_ANON_CLASS); $this->assertFalse(array_key_exists('parenthesis_owner', $tokens[$anonClass])); @@ -50,7 +48,7 @@ public function testAnonClassNoParentheses($testMarker) */ public function testAnonClassNoParenthesesNextOpenClose($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $function = $this->getTargetToken($testMarker, T_FUNCTION); $opener = $this->getTargetToken($testMarker, T_OPEN_PARENTHESIS); @@ -99,7 +97,7 @@ public static function dataAnonClassNoParentheses() */ public function testAnonClassWithParentheses($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $anonClass = $this->getTargetToken($testMarker, T_ANON_CLASS); $opener = $this->getTargetToken($testMarker, T_OPEN_PARENTHESIS); $closer = $this->getTargetToken($testMarker, T_CLOSE_PARENTHESIS); diff --git a/tests/Core/Tokenizer/ArrayKeywordTest.php b/tests/Core/Tokenizer/ArrayKeywordTest.php index 653b6a18b2..4e2a04a700 100644 --- a/tests/Core/Tokenizer/ArrayKeywordTest.php +++ b/tests/Core/Tokenizer/ArrayKeywordTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class ArrayKeywordTest extends AbstractMethodUnitTest +final class ArrayKeywordTest extends AbstractTokenizerTestCase { @@ -29,7 +27,7 @@ final class ArrayKeywordTest extends AbstractMethodUnitTest */ public function testArrayKeyword($testMarker, $testContent='array') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_ARRAY, T_STRING], $testContent); $tokenArray = $tokens[$token]; @@ -89,7 +87,7 @@ public static function dataArrayKeyword() */ public function testArrayType($testMarker, $testContent='array') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_ARRAY, T_STRING], $testContent); $tokenArray = $tokens[$token]; @@ -144,7 +142,7 @@ public static function dataArrayType() */ public function testNotArrayKeyword($testMarker, $testContent='array') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_ARRAY, T_STRING], $testContent); $tokenArray = $tokens[$token]; diff --git a/tests/Core/Tokenizer/AttributesTest.php b/tests/Core/Tokenizer/AttributesTest.php index 86c0fa5ea0..e073ce1f90 100644 --- a/tests/Core/Tokenizer/AttributesTest.php +++ b/tests/Core/Tokenizer/AttributesTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class AttributesTest extends AbstractMethodUnitTest +final class AttributesTest extends AbstractTokenizerTestCase { @@ -31,7 +29,7 @@ final class AttributesTest extends AbstractMethodUnitTest */ public function testAttribute($testMarker, $length, $tokenCodes) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $attribute = $this->getTargetToken($testMarker, T_ATTRIBUTE); $this->assertArrayHasKey('attribute_closer', $tokens[$attribute]); @@ -294,7 +292,7 @@ public static function dataAttribute() */ public function testTwoAttributesOnTheSameLine() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $attribute = $this->getTargetToken('/* testTwoAttributeOnTheSameLine */', T_ATTRIBUTE); $this->assertArrayHasKey('attribute_closer', $tokens[$attribute]); @@ -318,7 +316,7 @@ public function testTwoAttributesOnTheSameLine() */ public function testAttributeAndLineComment() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $attribute = $this->getTargetToken('/* testAttributeAndCommentOnTheSameLine */', T_ATTRIBUTE); $this->assertArrayHasKey('attribute_closer', $tokens[$attribute]); @@ -348,7 +346,7 @@ public function testAttributeAndLineComment() */ public function testAttributeOnParameters($testMarker, $position, $length, array $tokenCodes) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $function = $this->getTargetToken($testMarker, T_FUNCTION); $attribute = ($function + $position); @@ -455,7 +453,7 @@ public static function dataAttributeOnParameters() */ public function testAttributeContainingTextLookingLikeCloseTag($testMarker, $length, array $expectedTokensAttribute, array $expectedTokensAfter) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $attribute = $this->getTargetToken($testMarker, T_ATTRIBUTE); @@ -601,7 +599,7 @@ public static function dataAttributeOnTextLookingLikeCloseTag() */ public function testInvalidAttribute() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $attribute = $this->getTargetToken('/* testInvalidAttribute */', T_ATTRIBUTE); @@ -622,7 +620,7 @@ public function testInvalidAttribute() */ public function testNestedAttributes() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $tokenCodes = [ T_STRING, T_NS_SEPARATOR, diff --git a/tests/Core/Tokenizer/BackfillEnumTest.php b/tests/Core/Tokenizer/BackfillEnumTest.php index b48651ac3e..3ce48f6553 100644 --- a/tests/Core/Tokenizer/BackfillEnumTest.php +++ b/tests/Core/Tokenizer/BackfillEnumTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class BackfillEnumTest extends AbstractMethodUnitTest +final class BackfillEnumTest extends AbstractTokenizerTestCase { @@ -30,7 +28,7 @@ final class BackfillEnumTest extends AbstractMethodUnitTest */ public function testEnums($testMarker, $testContent, $openerOffset, $closerOffset) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $enum = $this->getTargetToken($testMarker, [T_ENUM, T_STRING], $testContent); $tokenArray = $tokens[$enum]; @@ -138,7 +136,7 @@ public static function dataEnums() */ public function testNotEnums($testMarker, $testContent) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, [T_ENUM, T_STRING], $testContent); $tokenArray = $tokens[$target]; diff --git a/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php b/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php index 7d98541dc4..609a54c00f 100644 --- a/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php +++ b/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class BackfillExplicitOctalNotationTest extends AbstractMethodUnitTest +final class BackfillExplicitOctalNotationTest extends AbstractTokenizerTestCase { @@ -30,7 +28,7 @@ final class BackfillExplicitOctalNotationTest extends AbstractMethodUnitTest */ public function testExplicitOctalNotation($marker, $value, $nextToken, $nextContent) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $number = $this->getTargetToken($marker, [T_LNUMBER]); diff --git a/tests/Core/Tokenizer/BackfillFnTokenTest.php b/tests/Core/Tokenizer/BackfillFnTokenTest.php index 1f4cd05011..8245b18756 100644 --- a/tests/Core/Tokenizer/BackfillFnTokenTest.php +++ b/tests/Core/Tokenizer/BackfillFnTokenTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class BackfillFnTokenTest extends AbstractMethodUnitTest +final class BackfillFnTokenTest extends AbstractTokenizerTestCase { @@ -106,7 +104,7 @@ public function testNestedOuter() */ public function testNestedInner() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken('/* testNestedInner */', T_FN); $this->backfillHelper($token, true); @@ -137,7 +135,7 @@ public function testNestedInner() */ public function testNestedSharedCloser() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken('/* testNestedSharedCloserOuter */', T_FN); $this->backfillHelper($token); @@ -380,7 +378,7 @@ public function testNamespaceOperatorInTypes() */ public function testKeywordReturnTypes() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $testMarkers = [ 'Self', @@ -453,7 +451,7 @@ public function testUnionReturnType() */ public function testTernary() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken('/* testTernary */', T_FN); $this->backfillHelper($token); @@ -505,7 +503,7 @@ public function testTernary() */ public function testTernaryWithTypes() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken('/* testTernaryWithTypes */', T_FN); $this->backfillHelper($token); @@ -563,7 +561,7 @@ public function testWithMatchValueAndMore() */ public function testInMatchValue($testMarker, $openerOffset, $closerOffset, $expectedCloserType, $expectedCloserFriendlyName) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, T_FN); $this->backfillHelper($token); @@ -647,7 +645,7 @@ public function testNestedInMethod() */ public function testNotAnArrowFunction($testMarker, $testContent='fn') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_STRING, T_FN], $testContent); $tokenArray = $tokens[$token]; @@ -745,7 +743,7 @@ public static function dataNotAnArrowFunction() */ private function backfillHelper($token, $skipScopeCloserCheck=false) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $this->assertTrue(array_key_exists('scope_condition', $tokens[$token]), 'Scope condition is not set'); $this->assertTrue(array_key_exists('scope_opener', $tokens[$token]), 'Scope opener is not set'); @@ -797,7 +795,7 @@ private function backfillHelper($token, $skipScopeCloserCheck=false) */ private function scopePositionTestHelper($token, $openerOffset, $closerOffset, $expectedCloserType='semicolon') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $expectedScopeOpener = ($token + $openerOffset); $expectedScopeCloser = ($token + $closerOffset); diff --git a/tests/Core/Tokenizer/BackfillMatchTokenTest.php b/tests/Core/Tokenizer/BackfillMatchTokenTest.php index 02e8fb748c..9f7df35402 100644 --- a/tests/Core/Tokenizer/BackfillMatchTokenTest.php +++ b/tests/Core/Tokenizer/BackfillMatchTokenTest.php @@ -10,10 +10,9 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -final class BackfillMatchTokenTest extends AbstractMethodUnitTest +final class BackfillMatchTokenTest extends AbstractTokenizerTestCase { @@ -32,7 +31,7 @@ final class BackfillMatchTokenTest extends AbstractMethodUnitTest */ public function testMatchExpression($testMarker, $openerOffset, $closerOffset, $testContent='match') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_STRING, T_MATCH], $testContent); $tokenArray = $tokens[$token]; @@ -213,7 +212,7 @@ public static function dataMatchExpression() */ public function testNotAMatchStructure($testMarker, $testContent='match') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_STRING, T_MATCH], $testContent); $tokenArray = $tokens[$token]; @@ -228,7 +227,7 @@ public function testNotAMatchStructure($testMarker, $testContent='match') $this->assertArrayNotHasKey('parenthesis_opener', $tokenArray, 'Parenthesis opener is set'); $this->assertArrayNotHasKey('parenthesis_closer', $tokenArray, 'Parenthesis closer is set'); - $next = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($token + 1), null, true); + $next = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($token + 1), null, true); if ($next !== false && $tokens[$next]['code'] === T_OPEN_PARENTHESIS) { $this->assertArrayNotHasKey('parenthesis_owner', $tokenArray, 'Parenthesis owner is set for opener after'); } @@ -477,7 +476,7 @@ public static function dataSwitchCaseVersusMatch() */ private function scopeTestHelper($token, $openerOffset, $closerOffset, $skipScopeCloserCheck=false) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $tokenArray = $tokens[$token]; $tokenType = $tokenArray['type']; $expectedScopeOpener = ($token + $openerOffset); @@ -532,7 +531,7 @@ private function scopeTestHelper($token, $openerOffset, $closerOffset, $skipScop */ private function parenthesisTestHelper($token) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $tokenArray = $tokens[$token]; $tokenType = $tokenArray['type']; diff --git a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php index 107b9443f1..b27dd8a059 100644 --- a/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php +++ b/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php @@ -9,10 +9,9 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -final class BackfillNumericSeparatorTest extends AbstractMethodUnitTest +final class BackfillNumericSeparatorTest extends AbstractTokenizerTestCase { @@ -30,7 +29,7 @@ final class BackfillNumericSeparatorTest extends AbstractMethodUnitTest */ public function testBackfill($marker, $type, $value) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $number = $this->getTargetToken($marker, [T_LNUMBER, T_DNUMBER]); $tokenArray = $tokens[$number]; @@ -150,7 +149,7 @@ public static function dataTestBackfill() */ public function testNoBackfill($testMarker, $expectedTokens) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $number = $this->getTargetToken($testMarker, [T_LNUMBER, T_DNUMBER]); foreach ($expectedTokens as $key => $expectedToken) { diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index a5ff50e06d..8fbc3ffa6c 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class BackfillReadonlyTest extends AbstractMethodUnitTest +final class BackfillReadonlyTest extends AbstractTokenizerTestCase { @@ -29,7 +27,7 @@ final class BackfillReadonlyTest extends AbstractMethodUnitTest */ public function testReadonly($testMarker, $testContent='readonly') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, [T_READONLY, T_STRING], $testContent); $tokenArray = $tokens[$target]; @@ -175,7 +173,7 @@ public static function dataReadonly() */ public function testNotReadonly($testMarker, $testContent='readonly') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, [T_READONLY, T_STRING], $testContent); $tokenArray = $tokens[$target]; diff --git a/tests/Core/Tokenizer/BitwiseOrTest.php b/tests/Core/Tokenizer/BitwiseOrTest.php index 4802777238..71a1c51ccb 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.php +++ b/tests/Core/Tokenizer/BitwiseOrTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class BitwiseOrTest extends AbstractMethodUnitTest +final class BitwiseOrTest extends AbstractTokenizerTestCase { @@ -27,7 +25,7 @@ final class BitwiseOrTest extends AbstractMethodUnitTest */ public function testBitwiseOr($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, [T_BITWISE_OR, T_TYPE_UNION]); $tokenArray = $tokens[$target]; @@ -79,7 +77,7 @@ public static function dataBitwiseOr() */ public function testTypeUnion($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, [T_BITWISE_OR, T_TYPE_UNION]); $tokenArray = $tokens[$target]; diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php index 0dec381f9b..bd81cd6ea6 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php @@ -9,10 +9,9 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -final class ContextSensitiveKeywordsTest extends AbstractMethodUnitTest +final class ContextSensitiveKeywordsTest extends AbstractTokenizerTestCase { @@ -28,7 +27,7 @@ final class ContextSensitiveKeywordsTest extends AbstractMethodUnitTest */ public function testStrings($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, (Tokens::$contextSensitiveKeywords + [T_STRING, T_NULL, T_FALSE, T_TRUE, T_PARENT, T_SELF])); $tokenArray = $tokens[$target]; @@ -167,7 +166,7 @@ public static function dataStrings() */ public function testKeywords($testMarker, $expectedTokenType) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken( $testMarker, (Tokens::$contextSensitiveKeywords + [T_ANON_CLASS, T_MATCH_DEFAULT, T_PARENT, T_SELF, T_STRING, T_NULL, T_FALSE, T_TRUE]) diff --git a/tests/Core/Tokenizer/DefaultKeywordTest.php b/tests/Core/Tokenizer/DefaultKeywordTest.php index efbce192f8..cee3d263de 100644 --- a/tests/Core/Tokenizer/DefaultKeywordTest.php +++ b/tests/Core/Tokenizer/DefaultKeywordTest.php @@ -10,9 +10,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class DefaultKeywordTest extends AbstractMethodUnitTest +final class DefaultKeywordTest extends AbstractTokenizerTestCase { @@ -33,7 +31,7 @@ final class DefaultKeywordTest extends AbstractMethodUnitTest */ public function testMatchDefault($testMarker, $testContent='default') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_MATCH_DEFAULT, T_DEFAULT, T_STRING], $testContent); $tokenArray = $tokens[$token]; @@ -123,7 +121,7 @@ public static function dataMatchDefault() */ public function testSwitchDefault($testMarker, $openerOffset, $closerOffset, $conditionStop=null, $testContent='default') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_MATCH_DEFAULT, T_DEFAULT, T_STRING], $testContent); $tokenArray = $tokens[$token]; @@ -234,7 +232,7 @@ public static function dataSwitchDefault() */ public function testNotDefaultKeyword($testMarker, $testContent='DEFAULT') { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_MATCH_DEFAULT, T_DEFAULT, T_STRING], $testContent); $tokenArray = $tokens[$token]; @@ -334,7 +332,7 @@ public static function dataNotDefaultKeyword() */ public function testIssue3326() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken('/* testClassConstant */', [T_SEMICOLON]); $tokenArray = $tokens[$token]; diff --git a/tests/Core/Tokenizer/DoubleArrowTest.php b/tests/Core/Tokenizer/DoubleArrowTest.php index 6fe3a5eee8..4b2ebef66f 100644 --- a/tests/Core/Tokenizer/DoubleArrowTest.php +++ b/tests/Core/Tokenizer/DoubleArrowTest.php @@ -11,9 +11,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class DoubleArrowTest extends AbstractMethodUnitTest +final class DoubleArrowTest extends AbstractTokenizerTestCase { @@ -29,7 +27,7 @@ final class DoubleArrowTest extends AbstractMethodUnitTest */ public function testDoubleArrow($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_DOUBLE_ARROW, T_MATCH_ARROW, T_FN_ARROW]); $tokenArray = $tokens[$token]; @@ -114,7 +112,7 @@ public static function dataDoubleArrow() */ public function testMatchArrow($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_DOUBLE_ARROW, T_MATCH_ARROW, T_FN_ARROW]); $tokenArray = $tokens[$token]; @@ -201,7 +199,7 @@ public static function dataMatchArrow() */ public function testFnArrow($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $token = $this->getTargetToken($testMarker, [T_DOUBLE_ARROW, T_MATCH_ARROW, T_FN_ARROW]); $tokenArray = $tokens[$token]; diff --git a/tests/Core/Tokenizer/DoubleQuotedStringTest.php b/tests/Core/Tokenizer/DoubleQuotedStringTest.php index 6d9526e008..83ba0aab7a 100644 --- a/tests/Core/Tokenizer/DoubleQuotedStringTest.php +++ b/tests/Core/Tokenizer/DoubleQuotedStringTest.php @@ -10,9 +10,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class DoubleQuotedStringTest extends AbstractMethodUnitTest +final class DoubleQuotedStringTest extends AbstractTokenizerTestCase { @@ -29,7 +27,7 @@ final class DoubleQuotedStringTest extends AbstractMethodUnitTest */ public function testDoubleQuotedString($testMarker, $expectedContent) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, T_DOUBLE_QUOTED_STRING); $this->assertSame($expectedContent, $tokens[$target]['content']); diff --git a/tests/Core/Tokenizer/EnumCaseTest.php b/tests/Core/Tokenizer/EnumCaseTest.php index 1e6dcf6642..f5b68507d6 100644 --- a/tests/Core/Tokenizer/EnumCaseTest.php +++ b/tests/Core/Tokenizer/EnumCaseTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class EnumCaseTest extends AbstractMethodUnitTest +final class EnumCaseTest extends AbstractTokenizerTestCase { @@ -28,7 +26,7 @@ final class EnumCaseTest extends AbstractMethodUnitTest */ public function testEnumCases($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $enumCase = $this->getTargetToken($testMarker, [T_ENUM_CASE, T_CASE]); $tokenArray = $tokens[$enumCase]; @@ -77,7 +75,7 @@ public static function dataEnumCases() */ public function testNotEnumCases($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $case = $this->getTargetToken($testMarker, [T_ENUM_CASE, T_CASE]); $tokenArray = $tokens[$case]; @@ -125,7 +123,7 @@ public static function dataNotEnumCases() */ public function testKeywordAsEnumCaseNameShouldBeString($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $enumCaseName = $this->getTargetToken($testMarker, [T_STRING, T_INTERFACE, T_TRAIT, T_ENUM, T_FUNCTION, T_FALSE, T_DEFAULT, T_ARRAY]); $tokenArray = $tokens[$enumCaseName]; diff --git a/tests/Core/Tokenizer/FinallyTest.php b/tests/Core/Tokenizer/FinallyTest.php index 455dad8ac0..a73ac57e50 100644 --- a/tests/Core/Tokenizer/FinallyTest.php +++ b/tests/Core/Tokenizer/FinallyTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class FinallyTest extends AbstractMethodUnitTest +final class FinallyTest extends AbstractTokenizerTestCase { @@ -27,7 +25,7 @@ final class FinallyTest extends AbstractMethodUnitTest */ public function testFinallyKeyword($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, [T_FINALLY, T_STRING]); $tokenArray = $tokens[$target]; @@ -67,7 +65,7 @@ public static function dataFinallyKeyword() */ public function testFinallyNonKeyword($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, [T_FINALLY, T_STRING]); $tokenArray = $tokens[$target]; diff --git a/tests/Core/Tokenizer/GotoLabelTest.php b/tests/Core/Tokenizer/GotoLabelTest.php index 869c76f19b..6917e939ea 100644 --- a/tests/Core/Tokenizer/GotoLabelTest.php +++ b/tests/Core/Tokenizer/GotoLabelTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class GotoLabelTest extends AbstractMethodUnitTest +final class GotoLabelTest extends AbstractTokenizerTestCase { @@ -28,7 +26,7 @@ final class GotoLabelTest extends AbstractMethodUnitTest */ public function testGotoStatement($testMarker, $testContent) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $label = $this->getTargetToken($testMarker, T_STRING); @@ -74,7 +72,7 @@ public static function dataGotoStatement() */ public function testGotoDeclaration($testMarker, $testContent) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $label = $this->getTargetToken($testMarker, T_GOTO_LABEL); @@ -120,7 +118,7 @@ public static function dataGotoDeclaration() */ public function testNotAGotoDeclaration($testMarker, $testContent) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, [T_GOTO_LABEL, T_STRING], $testContent); $tokenArray = $tokens[$target]; diff --git a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php index 9973f4ec61..d43768f0e4 100644 --- a/tests/Core/Tokenizer/HeredocNowdocCloserTest.php +++ b/tests/Core/Tokenizer/HeredocNowdocCloserTest.php @@ -9,14 +9,12 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - /** * Heredoc/nowdoc closer token test. * * @requires PHP 7.3 */ -final class HeredocNowdocCloserTest extends AbstractMethodUnitTest +final class HeredocNowdocCloserTest extends AbstractTokenizerTestCase { @@ -33,7 +31,7 @@ final class HeredocNowdocCloserTest extends AbstractMethodUnitTest */ public function testHeredocNowdocCloserTabReplacement($testMarker, $expected) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $closer = $this->getTargetToken($testMarker, [T_END_HEREDOC, T_END_NOWDOC]); diff --git a/tests/Core/Tokenizer/HeredocStringTest.php b/tests/Core/Tokenizer/HeredocStringTest.php index 16d06c118e..da3f361b2d 100644 --- a/tests/Core/Tokenizer/HeredocStringTest.php +++ b/tests/Core/Tokenizer/HeredocStringTest.php @@ -10,9 +10,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class HeredocStringTest extends AbstractMethodUnitTest +final class HeredocStringTest extends AbstractTokenizerTestCase { @@ -29,7 +27,7 @@ final class HeredocStringTest extends AbstractMethodUnitTest */ public function testHeredocString($testMarker, $expectedContent) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, T_HEREDOC); $this->assertSame($expectedContent."\n", $tokens[$target]['content']); @@ -50,7 +48,7 @@ public function testHeredocString($testMarker, $expectedContent) */ public function testHeredocStringWrapped($testMarker, $expectedContent) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $testMarker = substr($testMarker, 0, -3).'Wrapped */'; $target = $this->getTargetToken($testMarker, T_HEREDOC); diff --git a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php index 52df789115..058129f560 100644 --- a/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php +++ b/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php @@ -9,10 +9,9 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -final class NamedFunctionCallArgumentsTest extends AbstractMethodUnitTest +final class NamedFunctionCallArgumentsTest extends AbstractTokenizerTestCase { @@ -30,7 +29,7 @@ final class NamedFunctionCallArgumentsTest extends AbstractMethodUnitTest */ public function testNamedFunctionCallArguments($testMarker, $parameters) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); foreach ($parameters as $content) { $label = $this->getTargetToken($testMarker, [T_STRING, T_PARAM_NAME], $content); @@ -47,7 +46,7 @@ public function testNamedFunctionCallArguments($testMarker, $parameters) ); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); $this->assertSame( ':', @@ -295,7 +294,7 @@ public static function dataNamedFunctionCallArguments() */ public function testOtherTstringInFunctionCall($testMarker, $content) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $label = $this->getTargetToken($testMarker, [T_STRING, T_PARAM_NAME], $content); @@ -354,12 +353,12 @@ public static function dataOtherTstringInFunctionCall() */ public function testMixedPositionalAndNamedArgsWithTernary() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $true = $this->getTargetToken('/* testMixedPositionalAndNamedArgsWithTernary */', T_TRUE); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($true + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($true + 1), null, true); $this->assertSame( T_INLINE_ELSE, @@ -375,7 +374,7 @@ public function testMixedPositionalAndNamedArgsWithTernary() $label = $this->getTargetToken('/* testMixedPositionalAndNamedArgsWithTernary */', T_PARAM_NAME, 'name'); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); $this->assertSame( ':', @@ -406,7 +405,7 @@ public function testMixedPositionalAndNamedArgsWithTernary() */ public function testNamedArgWithTernary() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); /* * First argument. @@ -415,7 +414,7 @@ public function testNamedArgWithTernary() $label = $this->getTargetToken('/* testNamedArgWithTernary */', T_PARAM_NAME, 'label'); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); $this->assertSame( ':', @@ -436,7 +435,7 @@ public function testNamedArgWithTernary() $true = $this->getTargetToken('/* testNamedArgWithTernary */', T_TRUE); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($true + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($true + 1), null, true); $this->assertSame( T_INLINE_ELSE, @@ -456,7 +455,7 @@ public function testNamedArgWithTernary() $label = $this->getTargetToken('/* testNamedArgWithTernary */', T_PARAM_NAME, 'more'); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); $this->assertSame( ':', @@ -477,7 +476,7 @@ public function testNamedArgWithTernary() $true = $this->getTargetToken('/* testNamedArgWithTernary */', T_STRING, 'CONSTANT_A'); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($true + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($true + 1), null, true); $this->assertSame( T_INLINE_ELSE, @@ -503,7 +502,7 @@ public function testNamedArgWithTernary() */ public function testTernaryWithFunctionCallsInThenElse() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); /* * Then. @@ -512,7 +511,7 @@ public function testTernaryWithFunctionCallsInThenElse() $label = $this->getTargetToken('/* testTernaryWithFunctionCallsInThenElse */', T_PARAM_NAME, 'label'); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); $this->assertSame( ':', @@ -533,7 +532,7 @@ public function testTernaryWithFunctionCallsInThenElse() $closeParens = $this->getTargetToken('/* testTernaryWithFunctionCallsInThenElse */', T_CLOSE_PARENTHESIS); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($closeParens + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($closeParens + 1), null, true); $this->assertSame( T_INLINE_ELSE, @@ -553,7 +552,7 @@ public function testTernaryWithFunctionCallsInThenElse() $label = $this->getTargetToken('/* testTernaryWithFunctionCallsInThenElse */', T_PARAM_NAME, 'more'); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); $this->assertSame( ':', @@ -583,12 +582,12 @@ public function testTernaryWithFunctionCallsInThenElse() */ public function testTernaryWithConstantsInThenElse() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $constant = $this->getTargetToken('/* testTernaryWithConstantsInThenElse */', T_STRING, 'CONSTANT_NAME'); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($constant + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($constant + 1), null, true); $this->assertSame( T_INLINE_ELSE, @@ -613,12 +612,12 @@ public function testTernaryWithConstantsInThenElse() */ public function testSwitchStatement() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $label = $this->getTargetToken('/* testSwitchCaseWithConstant */', T_STRING, 'MY_CONSTANT'); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); $this->assertSame( T_COLON, @@ -634,7 +633,7 @@ public function testSwitchStatement() $label = $this->getTargetToken('/* testSwitchCaseWithClassProperty */', T_STRING, 'property'); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); $this->assertSame( T_COLON, @@ -650,7 +649,7 @@ public function testSwitchStatement() $default = $this->getTargetToken('/* testSwitchDefault */', T_DEFAULT); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($default + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($default + 1), null, true); $this->assertSame( T_COLON, @@ -675,7 +674,7 @@ public function testSwitchStatement() */ public function testParseErrorVariableLabel() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $label = $this->getTargetToken('/* testParseErrorDynamicName */', [T_VARIABLE, T_PARAM_NAME], '$variableStoringParamName'); @@ -691,7 +690,7 @@ public function testParseErrorVariableLabel() ); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); $this->assertSame( ':', @@ -725,7 +724,7 @@ public function testParseErrorVariableLabel() */ public function testOtherColonsInTernary($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $startOfStatement = $this->getTargetToken($testMarker, T_VARIABLE); @@ -792,7 +791,7 @@ public static function dataOtherColonsInTernary() */ public function testReservedKeywordsAsName($testMarker, $tokenTypes, $tokenContent) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $label = $this->getTargetToken($testMarker, $tokenTypes, $tokenContent); $this->assertSame( @@ -807,7 +806,7 @@ public function testReservedKeywordsAsName($testMarker, $tokenTypes, $tokenConte ); // Get the next non-empty token. - $colon = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); + $colon = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($label + 1), null, true); $this->assertSame( ':', diff --git a/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php b/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php index f4b424d964..f97ff69786 100644 --- a/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php +++ b/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php @@ -9,10 +9,9 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -final class NullsafeObjectOperatorTest extends AbstractMethodUnitTest +final class NullsafeObjectOperatorTest extends AbstractTokenizerTestCase { /** @@ -36,7 +35,7 @@ final class NullsafeObjectOperatorTest extends AbstractMethodUnitTest */ public function testObjectOperator() { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $operator = $this->getTargetToken('/* testObjectOperator */', $this->find); $this->assertSame(T_OBJECT_OPERATOR, $tokens[$operator]['code'], 'Failed asserting code is object operator'); @@ -57,7 +56,7 @@ public function testObjectOperator() */ public function testNullsafeObjectOperator($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $operator = $this->getTargetToken($testMarker, $this->find); $this->assertSame(T_NULLSAFE_OBJECT_OPERATOR, $tokens[$operator]['code'], 'Failed asserting code is nullsafe object operator'); @@ -97,14 +96,14 @@ public static function dataNullsafeObjectOperator() */ public function testTernaryThen($testMarker, $testObjectOperator=false) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $operator = $this->getTargetToken($testMarker, $this->find); $this->assertSame(T_INLINE_THEN, $tokens[$operator]['code'], 'Failed asserting code is inline then'); $this->assertSame('T_INLINE_THEN', $tokens[$operator]['type'], 'Failed asserting type is inline then'); if ($testObjectOperator === true) { - $next = self::$phpcsFile->findNext(Tokens::$emptyTokens, ($operator + 1), null, true); + $next = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($operator + 1), null, true); $this->assertSame(T_OBJECT_OPERATOR, $tokens[$next]['code'], 'Failed asserting code is object operator'); $this->assertSame('T_OBJECT_OPERATOR', $tokens[$next]['type'], 'Failed asserting type is object operator'); } diff --git a/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php b/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php index aa2a229ca9..5359b7282d 100644 --- a/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php +++ b/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class ScopeSettingWithNamespaceOperatorTest extends AbstractMethodUnitTest +final class ScopeSettingWithNamespaceOperatorTest extends AbstractTokenizerTestCase { @@ -30,7 +28,7 @@ final class ScopeSettingWithNamespaceOperatorTest extends AbstractMethodUnitTest */ public function testScopeSetting($testMarker, $tokenTypes, $open=T_OPEN_CURLY_BRACKET, $close=T_CLOSE_CURLY_BRACKET) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, $tokenTypes); $opener = $this->getTargetToken($testMarker, $open); diff --git a/tests/Core/Tokenizer/ShortArrayTest.php b/tests/Core/Tokenizer/ShortArrayTest.php index 884795d60c..235a6e86ce 100644 --- a/tests/Core/Tokenizer/ShortArrayTest.php +++ b/tests/Core/Tokenizer/ShortArrayTest.php @@ -9,9 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class ShortArrayTest extends AbstractMethodUnitTest +final class ShortArrayTest extends AbstractTokenizerTestCase { @@ -27,7 +25,7 @@ final class ShortArrayTest extends AbstractMethodUnitTest */ public function testSquareBrackets($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $opener = $this->getTargetToken($testMarker, [T_OPEN_SQUARE_BRACKET, T_OPEN_SHORT_ARRAY]); $tokenArray = $tokens[$opener]; @@ -95,7 +93,7 @@ public static function dataSquareBrackets() */ public function testShortArrays($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $opener = $this->getTargetToken($testMarker, [T_OPEN_SQUARE_BRACKET, T_OPEN_SHORT_ARRAY]); $tokenArray = $tokens[$opener]; diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php index cd54e687ec..b3b19c6bae 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceTest.php @@ -15,10 +15,9 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -final class StableCommentWhitespaceTest extends AbstractMethodUnitTest +final class StableCommentWhitespaceTest extends AbstractTokenizerTestCase { @@ -35,7 +34,7 @@ final class StableCommentWhitespaceTest extends AbstractMethodUnitTest */ public function testCommentTokenization($testMarker, $expectedTokens) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $comment = $this->getTargetToken($testMarker, Tokens::$commentTokens); foreach ($expectedTokens as $key => $tokenInfo) { diff --git a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php index 2247192a5b..2d0ce30d85 100644 --- a/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php +++ b/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php @@ -12,10 +12,9 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -final class StableCommentWhitespaceWinTest extends AbstractMethodUnitTest +final class StableCommentWhitespaceWinTest extends AbstractTokenizerTestCase { @@ -32,7 +31,7 @@ final class StableCommentWhitespaceWinTest extends AbstractMethodUnitTest */ public function testCommentTokenization($testMarker, $expectedTokens) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $comment = $this->getTargetToken($testMarker, Tokens::$commentTokens); foreach ($expectedTokens as $key => $tokenInfo) { diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.php b/tests/Core/Tokenizer/TypeIntersectionTest.php index 5a11be1262..32710f7fef 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.php +++ b/tests/Core/Tokenizer/TypeIntersectionTest.php @@ -10,9 +10,7 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -final class TypeIntersectionTest extends AbstractMethodUnitTest +final class TypeIntersectionTest extends AbstractTokenizerTestCase { @@ -28,7 +26,7 @@ final class TypeIntersectionTest extends AbstractMethodUnitTest */ public function testBitwiseAnd($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, [T_BITWISE_AND, T_TYPE_INTERSECTION]); $tokenArray = $tokens[$target]; @@ -82,7 +80,7 @@ public static function dataBitwiseAnd() */ public function testTypeIntersection($testMarker) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $target = $this->getTargetToken($testMarker, [T_BITWISE_AND, T_TYPE_INTERSECTION]); $tokenArray = $tokens[$target]; diff --git a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php index 3a15aae155..9e1038dcfb 100644 --- a/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php +++ b/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php @@ -19,10 +19,9 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHP_CodeSniffer\Util\Tokens; -final class UndoNamespacedNameSingleTokenTest extends AbstractMethodUnitTest +final class UndoNamespacedNameSingleTokenTest extends AbstractTokenizerTestCase { @@ -39,7 +38,7 @@ final class UndoNamespacedNameSingleTokenTest extends AbstractMethodUnitTest */ public function testIdentifierTokenization($testMarker, $expectedTokens) { - $tokens = self::$phpcsFile->getTokens(); + $tokens = $this->phpcsFile->getTokens(); $identifier = $this->getTargetToken($testMarker, constant($expectedTokens[0]['type'])); foreach ($expectedTokens as $key => $tokenInfo) { From 1f0a0ad176e80ad921041cf4d345642a96104753 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 29 Jan 2024 04:19:17 +0100 Subject: [PATCH 382/874] AttributesTest: add missing `@covers` tag --- tests/Core/Tokenizer/AttributesTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Core/Tokenizer/AttributesTest.php b/tests/Core/Tokenizer/AttributesTest.php index e073ce1f90..764a9bef42 100644 --- a/tests/Core/Tokenizer/AttributesTest.php +++ b/tests/Core/Tokenizer/AttributesTest.php @@ -615,6 +615,7 @@ public function testInvalidAttribute() * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize * @covers PHP_CodeSniffer\Tokenizers\PHP::findCloser * @covers PHP_CodeSniffer\Tokenizers\PHP::parsePhpAttribute + * @covers PHP_CodeSniffer\Tokenizers\PHP::createAttributesNestingMap * * @return void */ From 4e56e6fe4d9296aa121e908ca79781bbc0310bfe Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 29 Jan 2024 04:20:32 +0100 Subject: [PATCH 383/874] Tokenizer/PHP::resolveSimpleToken(): add dedicated tests This adds a set of dedicated tests for the tokens handled via the `PHP::resolveSimpleToken()` method. Related to 146 --- .../Tokenizer/AbstractTokenizerTestCase.php | 19 + .../Core/Tokenizer/ResolveSimpleTokenTest.inc | 51 +++ .../Core/Tokenizer/ResolveSimpleTokenTest.php | 432 ++++++++++++++++++ 3 files changed, 502 insertions(+) create mode 100644 tests/Core/Tokenizer/ResolveSimpleTokenTest.inc create mode 100644 tests/Core/Tokenizer/ResolveSimpleTokenTest.php diff --git a/tests/Core/Tokenizer/AbstractTokenizerTestCase.php b/tests/Core/Tokenizer/AbstractTokenizerTestCase.php index b51dde79d7..3225fe6fa2 100644 --- a/tests/Core/Tokenizer/AbstractTokenizerTestCase.php +++ b/tests/Core/Tokenizer/AbstractTokenizerTestCase.php @@ -17,6 +17,7 @@ use PHP_CodeSniffer\Tests\ConfigDouble; use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHPUnit\Framework\TestCase; +use ReflectionProperty; abstract class AbstractTokenizerTestCase extends TestCase { @@ -102,4 +103,22 @@ protected function getTargetToken($commentString, $tokenType, $tokenContent=null }//end getTargetToken() + /** + * Clear the static "resolved tokens" cache property on the Tokenizer\PHP class. + * + * This method should be used selectively by tests to ensure the code under test is actually hit + * by the test testing the code. + * + * @return void + */ + public static function clearResolvedTokensCache() + { + $property = new ReflectionProperty('PHP_CodeSniffer\Tokenizers\PHP', 'resolveTokenCache'); + $property->setAccessible(true); + $property->setValue(null, []); + $property->setAccessible(false); + + }//end clearResolvedTokensCache() + + }//end class diff --git a/tests/Core/Tokenizer/ResolveSimpleTokenTest.inc b/tests/Core/Tokenizer/ResolveSimpleTokenTest.inc new file mode 100644 index 0000000000..d7383d8e69 --- /dev/null +++ b/tests/Core/Tokenizer/ResolveSimpleTokenTest.inc @@ -0,0 +1,51 @@ + $var; + +/* testBooleanNot */ +$a = ! $var; + +/* testComma */ +echo $a, $b, $c; + +/* testAsperand */ +$a = @callMe(); + +/* testDollarAndCurlies */ +echo ${$var}; + +/* testBacktick */ +$a = `ls -e`; diff --git a/tests/Core/Tokenizer/ResolveSimpleTokenTest.php b/tests/Core/Tokenizer/ResolveSimpleTokenTest.php new file mode 100644 index 0000000000..706b1fe3c7 --- /dev/null +++ b/tests/Core/Tokenizer/ResolveSimpleTokenTest.php @@ -0,0 +1,432 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer; + +use PHP_CodeSniffer\Util\Tokens; + +/** + * Tests that simple tokens are assigned the correct token type and code. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::resolveSimpleToken + */ +final class ResolveSimpleTokenTest extends AbstractTokenizerTestCase +{ + + + /** + * Clear the "resolved tokens" cache before running this test as otherwise the code + * under test may not be run during the test. + * + * @beforeClass + * + * @return void + */ + public static function clearTokenCache() + { + parent::clearResolvedTokensCache(); + + }//end clearTokenCache() + + + /** + * Verify tokenization of parentheses, square brackets, curly brackets and a switch colon. + * + * @return void + */ + public function testBracesAndColon() + { + $expectedSequence = [ + T_OPEN_PARENTHESIS, + T_VARIABLE, + T_OPEN_SQUARE_BRACKET, + T_LNUMBER, + T_CLOSE_SQUARE_BRACKET, + T_CLOSE_PARENTHESIS, + T_OPEN_CURLY_BRACKET, + T_CASE, + T_STRING, + T_COLON, + T_BREAK, + T_SEMICOLON, + T_CLOSE_CURLY_BRACKET, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_SWITCH); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testBracesAndColon() + + + /** + * Verify tokenization of colon after named parameter. + * + * @return void + */ + public function testNamedParamColon() + { + $expectedSequence = [ + T_OPEN_PARENTHESIS, + T_PARAM_NAME, + T_COLON, + T_VARIABLE, + T_CLOSE_PARENTHESIS, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_STRING); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testNamedParamColon() + + + /** + * Verify tokenization of colon for a return type. + * + * @return void + */ + public function testReturnTypeColon() + { + $expectedSequence = [ + T_EQUAL, + T_CLOSURE, + T_OPEN_PARENTHESIS, + T_CLOSE_PARENTHESIS, + T_COLON, + T_STRING, + T_OPEN_CURLY_BRACKET, + T_CLOSE_CURLY_BRACKET, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_VARIABLE); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testReturnTypeColon() + + + /** + * Verify tokenization of a concatenation operator. + * + * @return void + */ + public function testConcat() + { + $expectedSequence = [ + T_STRING_CONCAT, + T_VARIABLE, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_CONSTANT_ENCAPSED_STRING); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testConcat() + + + /** + * Verify tokenization of simple math operators. + * + * @return void + */ + public function testSimpleMathTokens() + { + $expectedSequence = [ + T_EQUAL, + T_LNUMBER, + T_MULTIPLY, + T_LNUMBER, + T_DIVIDE, + T_LNUMBER, + T_PLUS, + T_LNUMBER, + T_MINUS, + T_LNUMBER, + T_MODULUS, + T_LNUMBER, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_VARIABLE); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testSimpleMathTokens() + + + /** + * Verify tokenization of unary plus/minus operators. + * + * @return void + */ + public function testUnaryPlusMinus() + { + $expectedSequence = [ + T_EQUAL, + T_PLUS, + T_LNUMBER, + T_DIVIDE, + T_MINUS, + T_LNUMBER, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_VARIABLE); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testUnaryPlusMinus() + + + /** + * Verify tokenization of bitwise operator tokens. + * + * @return void + */ + public function testBitwiseTokens() + { + $expectedSequence = [ + T_EQUAL, + T_STRING, + T_BITWISE_XOR, + T_STRING, + T_BITWISE_AND, + T_STRING, + T_BITWISE_OR, + T_STRING, + T_BITWISE_NOT, + T_STRING, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_VARIABLE); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testBitwiseTokens() + + + /** + * Verify tokenization of bitwise operator tokens. + * + * @return void + */ + public function testBitwiseOrInCatch() + { + $expectedSequence = [ + T_OPEN_PARENTHESIS, + T_STRING, + T_BITWISE_OR, + T_STRING, + T_VARIABLE, + T_CLOSE_PARENTHESIS, + T_OPEN_CURLY_BRACKET, + T_CLOSE_CURLY_BRACKET, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_CATCH); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testBitwiseOrInCatch() + + + /** + * Verify tokenization of a less than operator. + * + * @return void + */ + public function testLessThan() + { + $expectedSequence = [ + T_LESS_THAN, + T_VARIABLE, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_LNUMBER); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testLessThan() + + + /** + * Verify tokenization of a greater than operator. + * + * @return void + */ + public function testGreaterThan() + { + $expectedSequence = [ + T_GREATER_THAN, + T_VARIABLE, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_LNUMBER); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testGreaterThan() + + + /** + * Verify tokenization of a boolean not operator. + * + * @return void + */ + public function testBooleanNot() + { + $expectedSequence = [ + T_BOOLEAN_NOT, + T_VARIABLE, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_EQUAL); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testBooleanNot() + + + /** + * Verify tokenization of commas. + * + * @return void + */ + public function testComma() + { + $expectedSequence = [ + T_COMMA, + T_VARIABLE, + T_COMMA, + T_VARIABLE, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_VARIABLE); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testComma() + + + /** + * Verify tokenization of the silence operator. + * + * @return void + */ + public function testAsperand() + { + $expectedSequence = [ + T_ASPERAND, + T_STRING, + T_OPEN_PARENTHESIS, + T_CLOSE_PARENTHESIS, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_EQUAL); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testAsperand() + + + /** + * Verify tokenization of the dollar token and curlies for a variable variable. + * + * @return void + */ + public function testDollarAndCurlies() + { + $expectedSequence = [ + T_DOLLAR, + T_OPEN_CURLY_BRACKET, + T_VARIABLE, + T_CLOSE_CURLY_BRACKET, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_ECHO); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testDollarAndCurlies() + + + /** + * Verify tokenization of the backtick operator. + * + * @return void + */ + public function testBacktick() + { + $expectedSequence = [ + T_BACKTICK, + T_ENCAPSED_AND_WHITESPACE, + T_BACKTICK, + T_SEMICOLON, + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_EQUAL); + + $this->checkTokenSequence(($target + 1), $expectedSequence); + + }//end testBacktick() + + + /** + * Test helper. Check a token sequence complies with an expected token sequence. + * + * @param int $startPtr The position in the file to start checking from. + * @param array $expectedSequence The consecutive token constants to expect. + * + * @return void + */ + private function checkTokenSequence($startPtr, array $expectedSequence) + { + $tokens = $this->phpcsFile->getTokens(); + + $sequenceKey = 0; + $sequenceCount = count($expectedSequence); + + for ($i = $startPtr; $sequenceKey < $sequenceCount; $i++) { + if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) { + // Ignore whitespace and comments, not interested in the tokenization of those for these tests. + continue; + } + + $expectedTokenName = Tokens::tokenName($expectedSequence[$sequenceKey]); + + $this->assertSame( + $expectedSequence[$sequenceKey], + $tokens[$i]['code'], + 'Token tokenized as '.Tokens::tokenName($tokens[$i]['code']).', not '.$expectedTokenName.' (code)' + ); + + $this->assertSame( + $expectedTokenName, + $tokens[$i]['type'], + 'Token tokenized as '.$tokens[$i]['type'].', not '.$expectedTokenName.' (type)' + ); + + ++$sequenceKey; + }//end for + + }//end checkTokenSequence() + + +}//end class From 0d2bba18b325a99c8ae64452fb26704301be9286 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 29 Jan 2024 06:06:38 +0100 Subject: [PATCH 384/874] Tests/Tokenizer: split `ContextSensitiveKeywordsTest` ... as one part of these tests is about the PHP native context sensitive keywords and the other part is about PHPCS native tokens for certain keyword. These things are handled in different parts of the `Tokenizer\PHP` class and, in part, need different `@covers` tags. --- .../ContextSensitiveKeywordsTest.inc | 39 +- .../ContextSensitiveKeywordsTest.php | 405 +++++++----------- .../OtherContextSensitiveKeywordsTest.inc | 53 +++ .../OtherContextSensitiveKeywordsTest.php | 193 +++++++++ 4 files changed, 412 insertions(+), 278 deletions(-) create mode 100644 tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc create mode 100644 tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.php diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc index bc98c49f3d..aedc49cc67 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc @@ -53,7 +53,6 @@ class ContextSensitiveKeywords const /* testMatch */ MATCH = 'MATCH'; const /* testNamespace */ NAMESPACE = 'NAMESPACE'; const /* testNew */ NEW = 'NEW'; - const /* testParent */ PARENT = 'PARENT'; const /* testPrint */ PRINT = 'PRINT'; const /* testPrivate */ PRIVATE = 'PRIVATE'; const /* testProtected */ PROTECTED = 'PROTECTED'; @@ -62,7 +61,6 @@ class ContextSensitiveKeywords const /* testRequire */ REQUIRE = 'REQUIRE'; const /* testRequireOnce */ REQUIRE_ONCE = 'REQUIRE_ONCE'; const /* testReturn */ RETURN = 'RETURN'; - const /* testSelf */ SELF = 'SELF'; const /* testStatic */ STATIC = 'STATIC'; const /* testSwitch */ SWITCH = 'SWITCH'; const /* testThrows */ THROW = 'THROW'; @@ -78,10 +76,6 @@ class ContextSensitiveKeywords const /* testAnd */ AND = 'LOGICAL_AND'; const /* testOr */ OR = 'LOGICAL_OR'; const /* testXor */ XOR = 'LOGICAL_XOR'; - - const /* testFalse */ FALSE = 'FALSE', - const /* testTrue */ TRUE = 'TRUE', - const /* testNull */ NULL = 'NULL', } namespace /* testKeywordAfterNamespaceShouldBeString */ class; @@ -110,10 +104,6 @@ namespace /* testNamespaceNameIsString1 */ my\ /* testNamespaceNameIsString2 */ /* testFinalIsKeyword */ final /* testFunctionIsKeyword */ function someFunction( /* testCallableIsKeyword */ callable $callable, - /* testSelfIsKeyword */ - self $self, - /* testParentIsKeyword */ - parent $parent ) { /* testReturnIsKeyword */ return $this; @@ -220,9 +210,7 @@ $anonymousClass = new /* testAnonymousClassIsKeyword */ class {}; $anonymousClass2 = new class /* testExtendsInAnonymousClassIsKeyword */ extends SomeParent {}; $anonymousClass3 = new class /* testImplementsInAnonymousClassIsKeyword */ implements SomeInterface {}; -$instantiated1 = new /* testClassInstantiationParentIsKeyword */ parent(); -$instantiated2 = new /* testClassInstantiationSelfIsKeyword */ SELF; -$instantiated3 = new /* testClassInstantiationStaticIsKeyword */ static($param); +$instantiated = new /* testClassInstantiationStaticIsKeyword */ static($param); class Foo extends /* testNamespaceInNameIsKeyword */ namespace\Exception {} @@ -230,35 +218,10 @@ class Foo extends /* testNamespaceInNameIsKeyword */ namespace\Exception function /* testKeywordAfterFunctionShouldBeString */ eval() {} function /* testKeywordAfterFunctionByRefShouldBeString */ &switch() {} -function /* testKeywordSelfAfterFunctionByRefShouldBeString */ &self() {} function /* testKeywordStaticAfterFunctionByRefShouldBeString */ &static() {} -function /* testKeywordParentAfterFunctionByRefShouldBeString */ &parent() {} -function /* testKeywordFalseAfterFunctionByRefShouldBeString */ &false() {} -function /* testKeywordTrueAfterFunctionByRefShouldBeString */ & true () {} -function /* testKeywordNullAfterFunctionByRefShouldBeString */ &NULL() {} -/* testKeywordAsFunctionCallNameShouldBeStringSelf */ self(); /* testKeywordAsFunctionCallNameShouldBeStringStatic */ static(); $obj-> /* testKeywordAsMethodCallNameShouldBeStringStatic */ static(); -/* testKeywordAsFunctionCallNameShouldBeStringParent */ parent(); -/* testKeywordAsFunctionCallNameShouldBeStringFalse */ false(); -/* testKeywordAsFunctionCallNameShouldBeStringTrue */ True (); -/* testKeywordAsFunctionCallNameShouldBeStringNull */ null /*comment*/ (); - -$instantiated4 = new /* testClassInstantiationFalseIsString */ False(); -$instantiated5 = new /* testClassInstantiationTrueIsString */ true (); -$instantiated6 = new /* testClassInstantiationNullIsString */ null(); $function = /* testStaticIsKeywordBeforeClosure */ static function(/* testStaticIsKeywordWhenParamType */ static $param) {}; $arrow = /* testStaticIsKeywordBeforeArrow */ static fn(): /* testStaticIsKeywordWhenReturnType */ static => 10; - -function standAloneFalseTrueNullTypesAndMore( - /* testFalseIsKeywordAsParamType */ false $paramA, - /* testTrueIsKeywordAsParamType */ true $paramB, - /* testNullIsKeywordAsParamType */ null $paramC, -) /* testFalseIsKeywordAsReturnType */ false | /* testTrueIsKeywordAsReturnType */ true | /* testNullIsKeywordAsReturnType */ null { - if ($a === /* testFalseIsKeywordInComparison */ false - || $a === /* testTrueIsKeywordInComparison */ true - || $a === /* testNullIsKeywordInComparison */ null - ) {} -} diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php index bd81cd6ea6..9116782479 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php @@ -1,6 +1,6 @@ * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) @@ -28,7 +28,7 @@ final class ContextSensitiveKeywordsTest extends AbstractTokenizerTestCase public function testStrings($testMarker) { $tokens = $this->phpcsFile->getTokens(); - $target = $this->getTargetToken($testMarker, (Tokens::$contextSensitiveKeywords + [T_STRING, T_NULL, T_FALSE, T_TRUE, T_PARENT, T_SELF])); + $target = $this->getTargetToken($testMarker, (Tokens::$contextSensitiveKeywords + [T_STRING])); $tokenArray = $tokens[$target]; $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); @@ -47,107 +47,88 @@ public function testStrings($testMarker) public static function dataStrings() { return [ - 'constant declaration: abstract' => ['/* testAbstract */'], - 'constant declaration: array' => ['/* testArray */'], - 'constant declaration: as' => ['/* testAs */'], - 'constant declaration: break' => ['/* testBreak */'], - 'constant declaration: callable' => ['/* testCallable */'], - 'constant declaration: case' => ['/* testCase */'], - 'constant declaration: catch' => ['/* testCatch */'], - 'constant declaration: class' => ['/* testClass */'], - 'constant declaration: clone' => ['/* testClone */'], - 'constant declaration: const' => ['/* testConst */'], - 'constant declaration: continue' => ['/* testContinue */'], - 'constant declaration: declare' => ['/* testDeclare */'], - 'constant declaration: default' => ['/* testDefault */'], - 'constant declaration: do' => ['/* testDo */'], - 'constant declaration: echo' => ['/* testEcho */'], - 'constant declaration: else' => ['/* testElse */'], - 'constant declaration: elseif' => ['/* testElseIf */'], - 'constant declaration: empty' => ['/* testEmpty */'], - 'constant declaration: enddeclare' => ['/* testEndDeclare */'], - 'constant declaration: endfor' => ['/* testEndFor */'], - 'constant declaration: endforeach' => ['/* testEndForeach */'], - 'constant declaration: endif' => ['/* testEndIf */'], - 'constant declaration: endswitch' => ['/* testEndSwitch */'], - 'constant declaration: endwhile' => ['/* testEndWhile */'], - 'constant declaration: enum' => ['/* testEnum */'], - 'constant declaration: eval' => ['/* testEval */'], - 'constant declaration: exit' => ['/* testExit */'], - 'constant declaration: extends' => ['/* testExtends */'], - 'constant declaration: final' => ['/* testFinal */'], - 'constant declaration: finally' => ['/* testFinally */'], - 'constant declaration: fn' => ['/* testFn */'], - 'constant declaration: for' => ['/* testFor */'], - 'constant declaration: foreach' => ['/* testForeach */'], - 'constant declaration: function' => ['/* testFunction */'], - 'constant declaration: global' => ['/* testGlobal */'], - 'constant declaration: goto' => ['/* testGoto */'], - 'constant declaration: if' => ['/* testIf */'], - 'constant declaration: implements' => ['/* testImplements */'], - 'constant declaration: include' => ['/* testInclude */'], - 'constant declaration: include_once' => ['/* testIncludeOnce */'], - 'constant declaration: instanceof' => ['/* testInstanceOf */'], - 'constant declaration: insteadof' => ['/* testInsteadOf */'], - 'constant declaration: interface' => ['/* testInterface */'], - 'constant declaration: isset' => ['/* testIsset */'], - 'constant declaration: list' => ['/* testList */'], - 'constant declaration: match' => ['/* testMatch */'], - 'constant declaration: namespace' => ['/* testNamespace */'], - 'constant declaration: new' => ['/* testNew */'], - 'constant declaration: parent' => ['/* testParent */'], - 'constant declaration: print' => ['/* testPrint */'], - 'constant declaration: private' => ['/* testPrivate */'], - 'constant declaration: protected' => ['/* testProtected */'], - 'constant declaration: public' => ['/* testPublic */'], - 'constant declaration: readonly' => ['/* testReadonly */'], - 'constant declaration: require' => ['/* testRequire */'], - 'constant declaration: require_once' => ['/* testRequireOnce */'], - 'constant declaration: return' => ['/* testReturn */'], - 'constant declaration: self' => ['/* testSelf */'], - 'constant declaration: static' => ['/* testStatic */'], - 'constant declaration: switch' => ['/* testSwitch */'], - 'constant declaration: throws' => ['/* testThrows */'], - 'constant declaration: trait' => ['/* testTrait */'], - 'constant declaration: try' => ['/* testTry */'], - 'constant declaration: unset' => ['/* testUnset */'], - 'constant declaration: use' => ['/* testUse */'], - 'constant declaration: var' => ['/* testVar */'], - 'constant declaration: while' => ['/* testWhile */'], - 'constant declaration: yield' => ['/* testYield */'], - 'constant declaration: yield_from' => ['/* testYieldFrom */'], - 'constant declaration: and' => ['/* testAnd */'], - 'constant declaration: or' => ['/* testOr */'], - 'constant declaration: xor' => ['/* testXor */'], - 'constant declaration: false' => ['/* testFalse */'], - 'constant declaration: true' => ['/* testTrue */'], - 'constant declaration: null' => ['/* testNull */'], - - 'namespace declaration: class' => ['/* testKeywordAfterNamespaceShouldBeString */'], - 'namespace declaration (partial): my' => ['/* testNamespaceNameIsString1 */'], - 'namespace declaration (partial): class' => ['/* testNamespaceNameIsString2 */'], - 'namespace declaration (partial): foreach' => ['/* testNamespaceNameIsString3 */'], - - 'function declaration: eval' => ['/* testKeywordAfterFunctionShouldBeString */'], - 'function declaration with return by ref: switch' => ['/* testKeywordAfterFunctionByRefShouldBeString */'], - 'function declaration with return by ref: self' => ['/* testKeywordSelfAfterFunctionByRefShouldBeString */'], - 'function declaration with return by ref: static' => ['/* testKeywordStaticAfterFunctionByRefShouldBeString */'], - 'function declaration with return by ref: parent' => ['/* testKeywordParentAfterFunctionByRefShouldBeString */'], - 'function declaration with return by ref: false' => ['/* testKeywordFalseAfterFunctionByRefShouldBeString */'], - 'function declaration with return by ref: true' => ['/* testKeywordTrueAfterFunctionByRefShouldBeString */'], - 'function declaration with return by ref: null' => ['/* testKeywordNullAfterFunctionByRefShouldBeString */'], - - 'function call: self' => ['/* testKeywordAsFunctionCallNameShouldBeStringSelf */'], - 'function call: static' => ['/* testKeywordAsFunctionCallNameShouldBeStringStatic */'], - 'method call: static' => ['/* testKeywordAsMethodCallNameShouldBeStringStatic */'], - 'function call: parent' => ['/* testKeywordAsFunctionCallNameShouldBeStringParent */'], - 'function call: false' => ['/* testKeywordAsFunctionCallNameShouldBeStringFalse */'], - 'function call: true' => ['/* testKeywordAsFunctionCallNameShouldBeStringTrue */'], - 'function call: null; with comment between keyword and parentheses' => ['/* testKeywordAsFunctionCallNameShouldBeStringNull */'], - - 'class instantiation: false' => ['/* testClassInstantiationFalseIsString */'], - 'class instantiation: true' => ['/* testClassInstantiationTrueIsString */'], - 'class instantiation: null' => ['/* testClassInstantiationNullIsString */'], + 'constant declaration: abstract' => ['/* testAbstract */'], + 'constant declaration: array' => ['/* testArray */'], + 'constant declaration: as' => ['/* testAs */'], + 'constant declaration: break' => ['/* testBreak */'], + 'constant declaration: callable' => ['/* testCallable */'], + 'constant declaration: case' => ['/* testCase */'], + 'constant declaration: catch' => ['/* testCatch */'], + 'constant declaration: class' => ['/* testClass */'], + 'constant declaration: clone' => ['/* testClone */'], + 'constant declaration: const' => ['/* testConst */'], + 'constant declaration: continue' => ['/* testContinue */'], + 'constant declaration: declare' => ['/* testDeclare */'], + 'constant declaration: default' => ['/* testDefault */'], + 'constant declaration: do' => ['/* testDo */'], + 'constant declaration: echo' => ['/* testEcho */'], + 'constant declaration: else' => ['/* testElse */'], + 'constant declaration: elseif' => ['/* testElseIf */'], + 'constant declaration: empty' => ['/* testEmpty */'], + 'constant declaration: enddeclare' => ['/* testEndDeclare */'], + 'constant declaration: endfor' => ['/* testEndFor */'], + 'constant declaration: endforeach' => ['/* testEndForeach */'], + 'constant declaration: endif' => ['/* testEndIf */'], + 'constant declaration: endswitch' => ['/* testEndSwitch */'], + 'constant declaration: endwhile' => ['/* testEndWhile */'], + 'constant declaration: enum' => ['/* testEnum */'], + 'constant declaration: eval' => ['/* testEval */'], + 'constant declaration: exit' => ['/* testExit */'], + 'constant declaration: extends' => ['/* testExtends */'], + 'constant declaration: final' => ['/* testFinal */'], + 'constant declaration: finally' => ['/* testFinally */'], + 'constant declaration: fn' => ['/* testFn */'], + 'constant declaration: for' => ['/* testFor */'], + 'constant declaration: foreach' => ['/* testForeach */'], + 'constant declaration: function' => ['/* testFunction */'], + 'constant declaration: global' => ['/* testGlobal */'], + 'constant declaration: goto' => ['/* testGoto */'], + 'constant declaration: if' => ['/* testIf */'], + 'constant declaration: implements' => ['/* testImplements */'], + 'constant declaration: include' => ['/* testInclude */'], + 'constant declaration: include_once' => ['/* testIncludeOnce */'], + 'constant declaration: instanceof' => ['/* testInstanceOf */'], + 'constant declaration: insteadof' => ['/* testInsteadOf */'], + 'constant declaration: interface' => ['/* testInterface */'], + 'constant declaration: isset' => ['/* testIsset */'], + 'constant declaration: list' => ['/* testList */'], + 'constant declaration: match' => ['/* testMatch */'], + 'constant declaration: namespace' => ['/* testNamespace */'], + 'constant declaration: new' => ['/* testNew */'], + 'constant declaration: print' => ['/* testPrint */'], + 'constant declaration: private' => ['/* testPrivate */'], + 'constant declaration: protected' => ['/* testProtected */'], + 'constant declaration: public' => ['/* testPublic */'], + 'constant declaration: readonly' => ['/* testReadonly */'], + 'constant declaration: require' => ['/* testRequire */'], + 'constant declaration: require_once' => ['/* testRequireOnce */'], + 'constant declaration: return' => ['/* testReturn */'], + 'constant declaration: static' => ['/* testStatic */'], + 'constant declaration: switch' => ['/* testSwitch */'], + 'constant declaration: throws' => ['/* testThrows */'], + 'constant declaration: trait' => ['/* testTrait */'], + 'constant declaration: try' => ['/* testTry */'], + 'constant declaration: unset' => ['/* testUnset */'], + 'constant declaration: use' => ['/* testUse */'], + 'constant declaration: var' => ['/* testVar */'], + 'constant declaration: while' => ['/* testWhile */'], + 'constant declaration: yield' => ['/* testYield */'], + 'constant declaration: yield_from' => ['/* testYieldFrom */'], + 'constant declaration: and' => ['/* testAnd */'], + 'constant declaration: or' => ['/* testOr */'], + 'constant declaration: xor' => ['/* testXor */'], + + 'namespace declaration: class' => ['/* testKeywordAfterNamespaceShouldBeString */'], + 'namespace declaration (partial): my' => ['/* testNamespaceNameIsString1 */'], + 'namespace declaration (partial): class' => ['/* testNamespaceNameIsString2 */'], + 'namespace declaration (partial): foreach' => ['/* testNamespaceNameIsString3 */'], + + 'function declaration: eval' => ['/* testKeywordAfterFunctionShouldBeString */'], + 'function declaration with return by ref: switch' => ['/* testKeywordAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: static' => ['/* testKeywordStaticAfterFunctionByRefShouldBeString */'], + + 'function call: static' => ['/* testKeywordAsFunctionCallNameShouldBeStringStatic */'], + 'method call: static' => ['/* testKeywordAsMethodCallNameShouldBeStringStatic */'], ]; }//end dataStrings() @@ -167,10 +148,7 @@ public static function dataStrings() public function testKeywords($testMarker, $expectedTokenType) { $tokens = $this->phpcsFile->getTokens(); - $target = $this->getTargetToken( - $testMarker, - (Tokens::$contextSensitiveKeywords + [T_ANON_CLASS, T_MATCH_DEFAULT, T_PARENT, T_SELF, T_STRING, T_NULL, T_FALSE, T_TRUE]) - ); + $target = $this->getTargetToken($testMarker, (Tokens::$contextSensitiveKeywords + [T_ANON_CLASS, T_MATCH_DEFAULT, T_STRING])); $tokenArray = $tokens[$target]; $this->assertSame( @@ -197,395 +175,342 @@ public function testKeywords($testMarker, $expectedTokenType) public static function dataKeywords() { return [ - 'namespace: declaration' => [ + 'namespace: declaration' => [ 'testMarker' => '/* testNamespaceIsKeyword */', 'expectedTokenType' => 'T_NAMESPACE', ], - 'abstract: class declaration' => [ + 'abstract: class declaration' => [ 'testMarker' => '/* testAbstractIsKeyword */', 'expectedTokenType' => 'T_ABSTRACT', ], - 'class: declaration' => [ + 'class: declaration' => [ 'testMarker' => '/* testClassIsKeyword */', 'expectedTokenType' => 'T_CLASS', ], - 'extends: in class declaration' => [ + 'extends: in class declaration' => [ 'testMarker' => '/* testExtendsIsKeyword */', 'expectedTokenType' => 'T_EXTENDS', ], - 'implements: in class declaration' => [ + 'implements: in class declaration' => [ 'testMarker' => '/* testImplementsIsKeyword */', 'expectedTokenType' => 'T_IMPLEMENTS', ], - 'use: in trait import' => [ + 'use: in trait import' => [ 'testMarker' => '/* testUseIsKeyword */', 'expectedTokenType' => 'T_USE', ], - 'insteadof: in trait import' => [ + 'insteadof: in trait import' => [ 'testMarker' => '/* testInsteadOfIsKeyword */', 'expectedTokenType' => 'T_INSTEADOF', ], - 'as: in trait import' => [ + 'as: in trait import' => [ 'testMarker' => '/* testAsIsKeyword */', 'expectedTokenType' => 'T_AS', ], - 'const: declaration' => [ + 'const: declaration' => [ 'testMarker' => '/* testConstIsKeyword */', 'expectedTokenType' => 'T_CONST', ], - 'private: property declaration' => [ + 'private: property declaration' => [ 'testMarker' => '/* testPrivateIsKeyword */', 'expectedTokenType' => 'T_PRIVATE', ], - 'protected: property declaration' => [ + 'protected: property declaration' => [ 'testMarker' => '/* testProtectedIsKeyword */', 'expectedTokenType' => 'T_PROTECTED', ], - 'public: property declaration' => [ + 'public: property declaration' => [ 'testMarker' => '/* testPublicIsKeyword */', 'expectedTokenType' => 'T_PUBLIC', ], - 'var: property declaration' => [ + 'var: property declaration' => [ 'testMarker' => '/* testVarIsKeyword */', 'expectedTokenType' => 'T_VAR', ], - 'static: property declaration' => [ + 'static: property declaration' => [ 'testMarker' => '/* testStaticIsKeyword */', 'expectedTokenType' => 'T_STATIC', ], - 'readonly: property declaration' => [ + 'readonly: property declaration' => [ 'testMarker' => '/* testReadonlyIsKeyword */', 'expectedTokenType' => 'T_READONLY', ], - 'final: function declaration' => [ + 'final: function declaration' => [ 'testMarker' => '/* testFinalIsKeyword */', 'expectedTokenType' => 'T_FINAL', ], - 'function: declaration' => [ + 'function: declaration' => [ 'testMarker' => '/* testFunctionIsKeyword */', 'expectedTokenType' => 'T_FUNCTION', ], - 'callable: param type declaration' => [ + 'callable: param type declaration' => [ 'testMarker' => '/* testCallableIsKeyword */', 'expectedTokenType' => 'T_CALLABLE', ], - 'self: param type declaration' => [ - 'testMarker' => '/* testSelfIsKeyword */', - 'expectedTokenType' => 'T_SELF', - ], - 'parent: param type declaration' => [ - 'testMarker' => '/* testParentIsKeyword */', - 'expectedTokenType' => 'T_PARENT', - ], - 'return: statement' => [ + 'return: statement' => [ 'testMarker' => '/* testReturnIsKeyword */', 'expectedTokenType' => 'T_RETURN', ], - 'interface: declaration' => [ + 'interface: declaration' => [ 'testMarker' => '/* testInterfaceIsKeyword */', 'expectedTokenType' => 'T_INTERFACE', ], - 'trait: declaration' => [ + 'trait: declaration' => [ 'testMarker' => '/* testTraitIsKeyword */', 'expectedTokenType' => 'T_TRAIT', ], - 'enum: declaration' => [ + 'enum: declaration' => [ 'testMarker' => '/* testEnumIsKeyword */', 'expectedTokenType' => 'T_ENUM', ], - 'new: named instantiation' => [ + 'new: named instantiation' => [ 'testMarker' => '/* testNewIsKeyword */', 'expectedTokenType' => 'T_NEW', ], - 'instanceof: comparison' => [ + 'instanceof: comparison' => [ 'testMarker' => '/* testInstanceOfIsKeyword */', 'expectedTokenType' => 'T_INSTANCEOF', ], - 'clone' => [ + 'clone' => [ 'testMarker' => '/* testCloneIsKeyword */', 'expectedTokenType' => 'T_CLONE', ], - 'if' => [ + 'if' => [ 'testMarker' => '/* testIfIsKeyword */', 'expectedTokenType' => 'T_IF', ], - 'empty' => [ + 'empty' => [ 'testMarker' => '/* testEmptyIsKeyword */', 'expectedTokenType' => 'T_EMPTY', ], - 'elseif' => [ + 'elseif' => [ 'testMarker' => '/* testElseIfIsKeyword */', 'expectedTokenType' => 'T_ELSEIF', ], - 'else' => [ + 'else' => [ 'testMarker' => '/* testElseIsKeyword */', 'expectedTokenType' => 'T_ELSE', ], - 'endif' => [ + 'endif' => [ 'testMarker' => '/* testEndIfIsKeyword */', 'expectedTokenType' => 'T_ENDIF', ], - 'for' => [ + 'for' => [ 'testMarker' => '/* testForIsKeyword */', 'expectedTokenType' => 'T_FOR', ], - 'endfor' => [ + 'endfor' => [ 'testMarker' => '/* testEndForIsKeyword */', 'expectedTokenType' => 'T_ENDFOR', ], - 'foreach' => [ + 'foreach' => [ 'testMarker' => '/* testForeachIsKeyword */', 'expectedTokenType' => 'T_FOREACH', ], - 'endforeach' => [ + 'endforeach' => [ 'testMarker' => '/* testEndForeachIsKeyword */', 'expectedTokenType' => 'T_ENDFOREACH', ], - 'switch' => [ + 'switch' => [ 'testMarker' => '/* testSwitchIsKeyword */', 'expectedTokenType' => 'T_SWITCH', ], - 'case: in switch' => [ + 'case: in switch' => [ 'testMarker' => '/* testCaseIsKeyword */', 'expectedTokenType' => 'T_CASE', ], - 'default: in switch' => [ + 'default: in switch' => [ 'testMarker' => '/* testDefaultIsKeyword */', 'expectedTokenType' => 'T_DEFAULT', ], - 'endswitch' => [ + 'endswitch' => [ 'testMarker' => '/* testEndSwitchIsKeyword */', 'expectedTokenType' => 'T_ENDSWITCH', ], - 'break: in switch' => [ + 'break: in switch' => [ 'testMarker' => '/* testBreakIsKeyword */', 'expectedTokenType' => 'T_BREAK', ], - 'continue: in switch' => [ + 'continue: in switch' => [ 'testMarker' => '/* testContinueIsKeyword */', 'expectedTokenType' => 'T_CONTINUE', ], - 'do' => [ + 'do' => [ 'testMarker' => '/* testDoIsKeyword */', 'expectedTokenType' => 'T_DO', ], - 'while' => [ + 'while' => [ 'testMarker' => '/* testWhileIsKeyword */', 'expectedTokenType' => 'T_WHILE', ], - 'endwhile' => [ + 'endwhile' => [ 'testMarker' => '/* testEndWhileIsKeyword */', 'expectedTokenType' => 'T_ENDWHILE', ], - 'try' => [ + 'try' => [ 'testMarker' => '/* testTryIsKeyword */', 'expectedTokenType' => 'T_TRY', ], - 'throw: statement' => [ + 'throw: statement' => [ 'testMarker' => '/* testThrowIsKeyword */', 'expectedTokenType' => 'T_THROW', ], - 'catch' => [ + 'catch' => [ 'testMarker' => '/* testCatchIsKeyword */', 'expectedTokenType' => 'T_CATCH', ], - 'finally' => [ + 'finally' => [ 'testMarker' => '/* testFinallyIsKeyword */', 'expectedTokenType' => 'T_FINALLY', ], - 'global' => [ + 'global' => [ 'testMarker' => '/* testGlobalIsKeyword */', 'expectedTokenType' => 'T_GLOBAL', ], - 'echo' => [ + 'echo' => [ 'testMarker' => '/* testEchoIsKeyword */', 'expectedTokenType' => 'T_ECHO', ], - 'print: statement' => [ + 'print: statement' => [ 'testMarker' => '/* testPrintIsKeyword */', 'expectedTokenType' => 'T_PRINT', ], - 'die: statement' => [ + 'die: statement' => [ 'testMarker' => '/* testDieIsKeyword */', 'expectedTokenType' => 'T_EXIT', ], - 'eval' => [ + 'eval' => [ 'testMarker' => '/* testEvalIsKeyword */', 'expectedTokenType' => 'T_EVAL', ], - 'exit: statement' => [ + 'exit: statement' => [ 'testMarker' => '/* testExitIsKeyword */', 'expectedTokenType' => 'T_EXIT', ], - 'isset' => [ + 'isset' => [ 'testMarker' => '/* testIssetIsKeyword */', 'expectedTokenType' => 'T_ISSET', ], - 'unset' => [ + 'unset' => [ 'testMarker' => '/* testUnsetIsKeyword */', 'expectedTokenType' => 'T_UNSET', ], - 'include' => [ + 'include' => [ 'testMarker' => '/* testIncludeIsKeyword */', 'expectedTokenType' => 'T_INCLUDE', ], - 'include_once' => [ + 'include_once' => [ 'testMarker' => '/* testIncludeOnceIsKeyword */', 'expectedTokenType' => 'T_INCLUDE_ONCE', ], - 'require' => [ + 'require' => [ 'testMarker' => '/* testRequireIsKeyword */', 'expectedTokenType' => 'T_REQUIRE', ], - 'require_once' => [ + 'require_once' => [ 'testMarker' => '/* testRequireOnceIsKeyword */', 'expectedTokenType' => 'T_REQUIRE_ONCE', ], - 'list' => [ + 'list' => [ 'testMarker' => '/* testListIsKeyword */', 'expectedTokenType' => 'T_LIST', ], - 'goto' => [ + 'goto' => [ 'testMarker' => '/* testGotoIsKeyword */', 'expectedTokenType' => 'T_GOTO', ], - 'match' => [ + 'match' => [ 'testMarker' => '/* testMatchIsKeyword */', 'expectedTokenType' => 'T_MATCH', ], - 'default: in match expression' => [ + 'default: in match expression' => [ 'testMarker' => '/* testMatchDefaultIsKeyword */', 'expectedTokenType' => 'T_MATCH_DEFAULT', ], - 'fn' => [ + 'fn' => [ 'testMarker' => '/* testFnIsKeyword */', 'expectedTokenType' => 'T_FN', ], - 'yield' => [ + 'yield' => [ 'testMarker' => '/* testYieldIsKeyword */', 'expectedTokenType' => 'T_YIELD', ], - 'yield from' => [ + 'yield from' => [ 'testMarker' => '/* testYieldFromIsKeyword */', 'expectedTokenType' => 'T_YIELD_FROM', ], - 'declare' => [ + 'declare' => [ 'testMarker' => '/* testDeclareIsKeyword */', 'expectedTokenType' => 'T_DECLARE', ], - 'enddeclare' => [ + 'enddeclare' => [ 'testMarker' => '/* testEndDeclareIsKeyword */', 'expectedTokenType' => 'T_ENDDECLARE', ], - 'and: in if' => [ + 'and: in if' => [ 'testMarker' => '/* testAndIsKeyword */', 'expectedTokenType' => 'T_LOGICAL_AND', ], - 'or: in if' => [ + 'or: in if' => [ 'testMarker' => '/* testOrIsKeyword */', 'expectedTokenType' => 'T_LOGICAL_OR', ], - 'xor: in if' => [ + 'xor: in if' => [ 'testMarker' => '/* testXorIsKeyword */', 'expectedTokenType' => 'T_LOGICAL_XOR', ], - 'class: anon class declaration' => [ + 'class: anon class declaration' => [ 'testMarker' => '/* testAnonymousClassIsKeyword */', 'expectedTokenType' => 'T_ANON_CLASS', ], - 'extends: anon class declaration' => [ + 'extends: anon class declaration' => [ 'testMarker' => '/* testExtendsInAnonymousClassIsKeyword */', 'expectedTokenType' => 'T_EXTENDS', ], - 'implements: anon class declaration' => [ + 'implements: anon class declaration' => [ 'testMarker' => '/* testImplementsInAnonymousClassIsKeyword */', 'expectedTokenType' => 'T_IMPLEMENTS', ], - 'parent: class instantiation' => [ - 'testMarker' => '/* testClassInstantiationParentIsKeyword */', - 'expectedTokenType' => 'T_PARENT', - ], - 'self: class instantiation' => [ - 'testMarker' => '/* testClassInstantiationSelfIsKeyword */', - 'expectedTokenType' => 'T_SELF', - ], - 'static: class instantiation' => [ + 'static: class instantiation' => [ 'testMarker' => '/* testClassInstantiationStaticIsKeyword */', 'expectedTokenType' => 'T_STATIC', ], - 'namespace: operator' => [ + 'namespace: operator' => [ 'testMarker' => '/* testNamespaceInNameIsKeyword */', 'expectedTokenType' => 'T_NAMESPACE', ], - 'static: closure declaration' => [ + 'static: closure declaration' => [ 'testMarker' => '/* testStaticIsKeywordBeforeClosure */', 'expectedTokenType' => 'T_STATIC', ], - 'static: parameter type (illegal)' => [ + 'static: parameter type (illegal)' => [ 'testMarker' => '/* testStaticIsKeywordWhenParamType */', 'expectedTokenType' => 'T_STATIC', ], - 'static: arrow function declaration' => [ + 'static: arrow function declaration' => [ 'testMarker' => '/* testStaticIsKeywordBeforeArrow */', 'expectedTokenType' => 'T_STATIC', ], - 'static: return type for arrow function' => [ + 'static: return type for arrow function' => [ 'testMarker' => '/* testStaticIsKeywordWhenReturnType */', 'expectedTokenType' => 'T_STATIC', ], - - 'false: param type declaration' => [ - 'testMarker' => '/* testFalseIsKeywordAsParamType */', - 'expectedTokenType' => 'T_FALSE', - ], - 'true: param type declaration' => [ - 'testMarker' => '/* testTrueIsKeywordAsParamType */', - 'expectedTokenType' => 'T_TRUE', - ], - 'null: param type declaration' => [ - 'testMarker' => '/* testNullIsKeywordAsParamType */', - 'expectedTokenType' => 'T_NULL', - ], - 'false: return type declaration in union' => [ - 'testMarker' => '/* testFalseIsKeywordAsReturnType */', - 'expectedTokenType' => 'T_FALSE', - ], - 'true: return type declaration in union' => [ - 'testMarker' => '/* testTrueIsKeywordAsReturnType */', - 'expectedTokenType' => 'T_TRUE', - ], - 'null: return type declaration in union' => [ - 'testMarker' => '/* testNullIsKeywordAsReturnType */', - 'expectedTokenType' => 'T_NULL', - ], - 'false: in comparison' => [ - 'testMarker' => '/* testFalseIsKeywordInComparison */', - 'expectedTokenType' => 'T_FALSE', - ], - 'true: in comparison' => [ - 'testMarker' => '/* testTrueIsKeywordInComparison */', - 'expectedTokenType' => 'T_TRUE', - ], - 'null: in comparison' => [ - 'testMarker' => '/* testNullIsKeywordInComparison */', - 'expectedTokenType' => 'T_NULL', - ], ]; }//end dataKeywords() diff --git a/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc b/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc new file mode 100644 index 0000000000..f19992c150 --- /dev/null +++ b/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc @@ -0,0 +1,53 @@ + + * @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer; + +/** + * Tests the conversion of PHPCS native context sensitive keyword tokens to T_STRING. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * @covers PHP_CodeSniffer\Tokenizers\PHP::standardiseToken + */ +final class OtherContextSensitiveKeywordsTest extends AbstractTokenizerTestCase +{ + + + /** + * Clear the "resolved tokens" cache before running this test as otherwise the code + * under test may not be run during the test. + * + * @beforeClass + * + * @return void + */ + public static function clearTokenCache() + { + parent::clearResolvedTokensCache(); + + }//end clearTokenCache() + + + /** + * Test that context sensitive keyword is tokenized as string when it should be string. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * + * @dataProvider dataStrings + * + * @return void + */ + public function testStrings($testMarker) + { + $tokens = $this->phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_STRING, T_NULL, T_FALSE, T_TRUE, T_PARENT, T_SELF]); + $tokenArray = $tokens[$target]; + + $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); + $this->assertSame('T_STRING', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (type)'); + + }//end testStrings() + + + /** + * Data provider. + * + * @see testStrings() + * + * @return array> + */ + public static function dataStrings() + { + return [ + 'constant declaration: parent' => ['/* testParent */'], + 'constant declaration: self' => ['/* testSelf */'], + 'constant declaration: false' => ['/* testFalse */'], + 'constant declaration: true' => ['/* testTrue */'], + 'constant declaration: null' => ['/* testNull */'], + + 'function declaration with return by ref: self' => ['/* testKeywordSelfAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: parent' => ['/* testKeywordParentAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: false' => ['/* testKeywordFalseAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: true' => ['/* testKeywordTrueAfterFunctionByRefShouldBeString */'], + 'function declaration with return by ref: null' => ['/* testKeywordNullAfterFunctionByRefShouldBeString */'], + + 'function call: self' => ['/* testKeywordAsFunctionCallNameShouldBeStringSelf */'], + 'function call: parent' => ['/* testKeywordAsFunctionCallNameShouldBeStringParent */'], + 'function call: false' => ['/* testKeywordAsFunctionCallNameShouldBeStringFalse */'], + 'function call: true' => ['/* testKeywordAsFunctionCallNameShouldBeStringTrue */'], + 'function call: null; with comment between keyword and parentheses' => ['/* testKeywordAsFunctionCallNameShouldBeStringNull */'], + + 'class instantiation: false' => ['/* testClassInstantiationFalseIsString */'], + 'class instantiation: true' => ['/* testClassInstantiationTrueIsString */'], + 'class instantiation: null' => ['/* testClassInstantiationNullIsString */'], + ]; + + }//end dataStrings() + + + /** + * Test that context sensitive keyword is tokenized as keyword when it should be keyword. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param string $expectedTokenType The expected token type. + * + * @dataProvider dataKeywords + * + * @return void + */ + public function testKeywords($testMarker, $expectedTokenType) + { + $tokens = $this->phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, [T_STRING, T_NULL, T_FALSE, T_TRUE, T_PARENT, T_SELF]); + $tokenArray = $tokens[$target]; + + $this->assertSame( + constant($expectedTokenType), + $tokenArray['code'], + 'Token tokenized as '.$tokenArray['type'].', not '.$expectedTokenType.' (code)' + ); + $this->assertSame( + $expectedTokenType, + $tokenArray['type'], + 'Token tokenized as '.$tokenArray['type'].', not '.$expectedTokenType.' (type)' + ); + + }//end testKeywords() + + + /** + * Data provider. + * + * @see testKeywords() + * + * @return array + */ + public static function dataKeywords() + { + return [ + 'self: param type declaration' => [ + 'testMarker' => '/* testSelfIsKeyword */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: param type declaration' => [ + 'testMarker' => '/* testParentIsKeyword */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'parent: class instantiation' => [ + 'testMarker' => '/* testClassInstantiationParentIsKeyword */', + 'expectedTokenType' => 'T_PARENT', + ], + 'self: class instantiation' => [ + 'testMarker' => '/* testClassInstantiationSelfIsKeyword */', + 'expectedTokenType' => 'T_SELF', + ], + + 'false: param type declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsParamType */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: param type declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsParamType */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: param type declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsParamType */', + 'expectedTokenType' => 'T_NULL', + ], + 'false: return type declaration in union' => [ + 'testMarker' => '/* testFalseIsKeywordAsReturnType */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: return type declaration in union' => [ + 'testMarker' => '/* testTrueIsKeywordAsReturnType */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: return type declaration in union' => [ + 'testMarker' => '/* testNullIsKeywordAsReturnType */', + 'expectedTokenType' => 'T_NULL', + ], + 'false: in comparison' => [ + 'testMarker' => '/* testFalseIsKeywordInComparison */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: in comparison' => [ + 'testMarker' => '/* testTrueIsKeywordInComparison */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: in comparison' => [ + 'testMarker' => '/* testNullIsKeywordInComparison */', + 'expectedTokenType' => 'T_NULL', + ], + ]; + + }//end dataKeywords() + + +}//end class From f548efa559f217d76e9a5dfa1964ab45958ec618 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 27 Jan 2024 18:44:44 +0100 Subject: [PATCH 385/874] PSR2/ClassDeclaration: bug fix - space before class keyword is not checked correctly * If there would be a newline + indentation between a modifier keyword and the "class" keyword, the space between them would not be flagged as incorrect (should be one space). * Along the same lines, if there would be a comment between the modifier keyword and the "class" keyword, the space between them would not be checked, let alone flagged. Fixed now. Includes additional tests. --- .../Sniffs/Classes/ClassDeclarationSniff.php | 75 +++++++++++-------- .../Classes/ClassDeclarationUnitTest.inc | 25 +++++++ .../ClassDeclarationUnitTest.inc.fixed | 23 ++++++ .../Classes/ClassDeclarationUnitTest.php | 5 ++ 4 files changed, 95 insertions(+), 33 deletions(-) diff --git a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php index 6d59b89ae9..22cf2abc0f 100644 --- a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php @@ -65,42 +65,51 @@ public function processOpen(File $phpcsFile, $stackPtr) $stackPtrType = strtolower($tokens[$stackPtr]['content']); // Check alignment of the keyword and braces. - if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { - $prevContent = $tokens[($stackPtr - 1)]['content']; - if ($prevContent !== $phpcsFile->eolChar) { - $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar)); - $spaces = strlen($blankSpace); - - if (in_array($tokens[($stackPtr - 2)]['code'], [T_ABSTRACT, T_FINAL, T_READONLY], true) === true - && $spaces !== 1 - ) { - $prevContent = strtolower($tokens[($stackPtr - 2)]['content']); - $error = 'Expected 1 space between %s and %s keywords; %s found'; - $data = [ - $prevContent, - $stackPtrType, - $spaces, - ]; - - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeKeyword', $data); - if ($fix === true) { - $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' '); - } - } - } else if ($tokens[($stackPtr - 2)]['code'] === T_ABSTRACT - || $tokens[($stackPtr - 2)]['code'] === T_FINAL - || $tokens[($stackPtr - 2)]['code'] === T_READONLY - ) { - $prevContent = strtolower($tokens[($stackPtr - 2)]['content']); - $error = 'Expected 1 space between %s and %s keywords; newline found'; - $data = [ - $prevContent, + $classModifiers = [ + T_ABSTRACT => T_ABSTRACT, + T_FINAL => T_FINAL, + T_READONLY => T_READONLY, + ]; + + $prevNonSpace = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); + + if (isset($classModifiers[$tokens[$prevNonEmpty]['code']]) === true) { + $spaces = 0; + $errorCode = 'SpaceBeforeKeyword'; + if ($tokens[$prevNonEmpty]['line'] !== $tokens[$stackPtr]['line']) { + $spaces = 'newline'; + $errorCode = 'NewlineBeforeKeyword'; + } else if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { + $spaces = $tokens[($stackPtr - 1)]['length']; + } + + if ($spaces !== 1) { + $error = 'Expected 1 space between %s and %s keywords; %s found'; + $data = [ + strtolower($tokens[$prevNonEmpty]['content']), $stackPtrType, + $spaces, ]; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NewlineBeforeKeyword', $data); - if ($fix === true) { - $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' '); + if ($prevNonSpace !== $prevNonEmpty) { + // Comment found between modifier and class keyword. Do not auto-fix. + $phpcsFile->addError($error, $stackPtr, $errorCode, $data); + } else { + $fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode, $data); + if ($fix === true) { + if ($spaces === 0) { + $phpcsFile->fixer->addContentBefore($stackPtr, ' '); + } else { + $phpcsFile->fixer->beginChangeset(); + $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' '); + for ($i = ($stackPtr - 2); $i > $prevNonSpace; $i--) { + $phpcsFile->fixer->replaceToken($i, ' '); + } + + $phpcsFile->fixer->endChangeset(); + } + } } }//end if }//end if diff --git a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc index f241a1a2fc..303846b721 100644 --- a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc +++ b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc @@ -257,3 +257,28 @@ if (!class_exists('IndentedDeclaration')) { } } + +// Space between modifier and class keyword would not be flagged nor fixed if newline + indentation. +final + class FinalClassWithIndentation + { + } + +readonly + class ReadonlyClassWithIndentation + { + } + +// And would also not be flagged if there was a comment between (not auto-fixable). +final/*comment*/class FinalClassWithComment +{ +} +abstract /*comment*/ class AbstractClassWithComment +{ +} + +readonly + // comment + class ReadonlyClassWithComment + { + } diff --git a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed index bb72318720..78dbbbb4b2 100644 --- a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed +++ b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed @@ -247,3 +247,26 @@ if (!class_exists('IndentedDeclaration')) { function foo() {} } } + +// Space between modifier and class keyword would not be flagged nor fixed if newline + indentation. +final class FinalClassWithIndentation +{ + } + +readonly class ReadonlyClassWithIndentation +{ + } + +// And would also not be flagged if there was a comment between (not auto-fixable). +final/*comment*/class FinalClassWithComment +{ +} +abstract /*comment*/ class AbstractClassWithComment +{ +} + +readonly + // comment + class ReadonlyClassWithComment + { + } diff --git a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php index 26e2c8c98e..b74d811c17 100644 --- a/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php @@ -71,6 +71,11 @@ public function getErrorList() 244 => 1, 248 => 1, 258 => 1, + 263 => 1, + 268 => 1, + 273 => 1, + 276 => 1, + 282 => 1, ]; }//end getErrorList() From afc03c639a05998876ce8d7cf7b757132c30c5aa Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Jan 2024 06:12:43 +0100 Subject: [PATCH 386/874] Generic/LowerCaseType: bug fix in intersection type ignore code PR squizlabs/PHP_CodeSniffer 3581 introduced support for PHP 8.1 intersection types. _Note: the sniff, or PHPCS itself for that matter, currently does not (yet) support PHP 8.2 DNF types. Once support for DNF types has been added, this sniff will need a further update/fix. For now, for the purpose of this sniff, intersection types should be skipped as they cannot contain the simple types for which the case is being checked by this sniff. However, the check for whether a type is an intersection type or not was wrong. The `'*type_token'` key for each of these checks contains the stack pointer to the _first_ token in the type declaration, so the comparison with `T_TYPE_INTERSECTION` will always yield `false`. This did not lead to false positives due to how the type is handled after that, but is still a bug which should be fixed. --- src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php index a835d7ed85..74103c805c 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php @@ -135,7 +135,7 @@ public function process(File $phpcsFile, $stackPtr) $error = 'PHP property type declarations must be lowercase; expected "%s" but found "%s"'; $errorCode = 'PropertyTypeFound'; - if ($props['type_token'] === T_TYPE_INTERSECTION) { + if (strpos($type, '&') !== false) { // Intersection types don't support simple types. } else if (strpos($type, '|') !== false) { $this->processUnionType( @@ -167,7 +167,7 @@ public function process(File $phpcsFile, $stackPtr) $error = 'PHP return type declarations must be lowercase; expected "%s" but found "%s"'; $errorCode = 'ReturnTypeFound'; - if ($props['return_type_token'] === T_TYPE_INTERSECTION) { + if (strpos($returnType, '&') !== false) { // Intersection types don't support simple types. } else if (strpos($returnType, '|') !== false) { $this->processUnionType( @@ -199,7 +199,7 @@ public function process(File $phpcsFile, $stackPtr) $error = 'PHP parameter type declarations must be lowercase; expected "%s" but found "%s"'; $errorCode = 'ParamTypeFound'; - if ($param['type_hint_token'] === T_TYPE_INTERSECTION) { + if (strpos($typeHint, '&') !== false) { // Intersection types don't support simple types. } else if (strpos($typeHint, '|') !== false) { $this->processUnionType( From 27ce14ffcb6c5bf6c1fc10afb65a23dc192abe84 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 31 Jan 2024 22:54:58 +0100 Subject: [PATCH 387/874] File::getMethodProperties(): add extra test with nullable static return type --- tests/Core/File/GetMethodPropertiesTest.inc | 5 ++++ tests/Core/File/GetMethodPropertiesTest.php | 26 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tests/Core/File/GetMethodPropertiesTest.inc b/tests/Core/File/GetMethodPropertiesTest.inc index 1bc570595e..24d8cc692e 100644 --- a/tests/Core/File/GetMethodPropertiesTest.inc +++ b/tests/Core/File/GetMethodPropertiesTest.inc @@ -79,6 +79,11 @@ class ReturnMe { private function myFunction(): static { return $this; } + + /* testReturnTypeNullableStatic */ + function myNullableFunction(): ?static { + return $this; + } } /* testPHP8MixedTypeHint */ diff --git a/tests/Core/File/GetMethodPropertiesTest.php b/tests/Core/File/GetMethodPropertiesTest.php index bb861010a3..85a36bb2b4 100644 --- a/tests/Core/File/GetMethodPropertiesTest.php +++ b/tests/Core/File/GetMethodPropertiesTest.php @@ -561,6 +561,32 @@ public function testReturnTypeStatic() }//end testReturnTypeStatic() + /** + * Test a function with return type "?static". + * + * @return void + */ + public function testReturnTypeNullableStatic() + { + // Offsets are relative to the T_FUNCTION token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '?static', + 'return_type_token' => 8, + 'return_type_end_token' => 8, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testReturnTypeNullableStatic() + + /** * Test a function with return type "mixed". * From e59ef4bdd6f75b2110d13fa6e340fd36e65fd0bf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 27 Jan 2024 20:33:31 +0100 Subject: [PATCH 388/874] Runner: allow the Performance report when running `phpcbf` As things were, a `phpcbf` run overruled the `Config::$reports` setting / `--report=...` CLI arguments to always only show the `Cbf` report. As running the Performance report can also be useful for `phpcbf` (to find particularly slow fixers), I'm proposing to change the logic which overrules the reports setting for `phpcbf` to allow for displaying the `Performance` report as well (if requested). --- src/Runner.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Runner.php b/src/Runner.php index 053c67cfaf..57cfb03251 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -194,7 +194,15 @@ public function runPHPCBF() $this->config->showSources = false; $this->config->recordErrors = false; $this->config->reportFile = null; - $this->config->reports = ['cbf' => null]; + + // Only use the "Cbf" report, but allow for the Performance report as well. + $originalReports = array_change_key_case($this->config->reports, CASE_LOWER); + $newReports = ['cbf' => null]; + if (array_key_exists('performance', $originalReports) === true) { + $newReports['performance'] = $originalReports['performance']; + } + + $this->config->reports = $newReports; // If a standard tries to set command line arguments itself, some // may be blocked because PHPCBF is running, so stop the script From 9244858468eb0fd9832e60e33018f217940b01ec Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 27 Jan 2024 04:47:26 +0100 Subject: [PATCH 389/874] PHP 8.3 | Tokenizer/PHP: add support for readonly anonymous classes PHP 8.3 introduced readonly anonymous classes, fixing an oversight in the PHP 8.2 introduction of readonly classes. As things were, for PHP 8.1+, the tokenizer would change the token code for the `readonly` keyword from `T_READONLY` to `T_STRING` in the "context sensitive keyword" layer, thinking it to be a class name. And for PHP < 8.1, the readonly polyfill would ignore the token as it being preceded by the `new` keyword would be seen as conflicting with the "context sensitive keyword" layer, which meant it would not be re-tokenized from `T_STRING` to `T_READONLY`. This commit fixes both. Includes adding tests in a number of pre-existing test classes to cover this change. --- src/Tokenizers/PHP.php | 20 ++++++++++++++++++- .../AnonClassParenthesisOwnerTest.inc | 10 ++++++++++ .../AnonClassParenthesisOwnerTest.php | 6 ++++++ tests/Core/Tokenizer/BackfillReadonlyTest.inc | 13 ++++++++++++ tests/Core/Tokenizer/BackfillReadonlyTest.php | 11 ++++++++++ .../ContextSensitiveKeywordsTest.inc | 6 +++++- .../ContextSensitiveKeywordsTest.php | 6 +++++- 7 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index e8ad0db793..9c66d811f1 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -621,6 +621,23 @@ protected function tokenize($string) $preserveKeyword = true; } + // `new readonly class` should be preserved. + if ($finalTokens[$lastNotEmptyToken]['code'] === T_NEW + && strtolower($token[1]) === 'readonly' + ) { + for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { + if (is_array($tokens[$i]) === false + || isset(Util\Tokens::$emptyTokens[$tokens[$i][0]]) === false + ) { + break; + } + } + + if (is_array($tokens[$i]) === true && $tokens[$i][0] === T_CLASS) { + $preserveKeyword = true; + } + } + // `new class extends` `new class implements` should be preserved if (($token[0] === T_EXTENDS || $token[0] === T_IMPLEMENTS) && $finalTokens[$lastNotEmptyToken]['code'] === T_CLASS @@ -1315,7 +1332,8 @@ protected function tokenize($string) if ($tokenIsArray === true && strtolower($token[1]) === 'readonly' - && isset($this->tstringContexts[$finalTokens[$lastNotEmptyToken]['code']]) === false + && (isset($this->tstringContexts[$finalTokens[$lastNotEmptyToken]['code']]) === false + || $finalTokens[$lastNotEmptyToken]['code'] === T_NEW) ) { // Get the next non-whitespace token. for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { diff --git a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.inc b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.inc index 5867691c64..3ee1afd0d0 100644 --- a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.inc +++ b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.inc @@ -5,6 +5,11 @@ $anonClass = new class { function __construct() {} }; +/* testReadonlyNoParentheses */ +$anonClass = new readonly class { + function __construct() {} +}; + /* testNoParenthesesAndEmptyTokens */ $anonClass = new class // phpcs:ignore Standard.Cat { @@ -14,6 +19,11 @@ $anonClass = new class // phpcs:ignore Standard.Cat /* testWithParentheses */ $anonClass = new class() {}; +/* testReadonlyWithParentheses */ +$anonClass = new readonly class() { + function __construct() {} +}; + /* testWithParenthesesAndEmptyTokens */ $anonClass = new class /*comment */ () {}; diff --git a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php index a22481c0cf..79eb742e19 100644 --- a/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php +++ b/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php @@ -76,6 +76,9 @@ public static function dataAnonClassNoParentheses() 'plain' => [ 'testMarker' => '/* testNoParentheses */', ], + 'readonly' => [ + 'testMarker' => '/* testReadonlyNoParentheses */', + ], 'declaration contains comments and extra whitespace' => [ 'testMarker' => '/* testNoParenthesesAndEmptyTokens */', ], @@ -139,6 +142,9 @@ public static function dataAnonClassWithParentheses() 'plain' => [ 'testMarker' => '/* testWithParentheses */', ], + 'readonly' => [ + 'testMarker' => '/* testReadonlyWithParentheses */', + ], 'declaration contains comments and extra whitespace' => [ 'testMarker' => '/* testWithParenthesesAndEmptyTokens */', ], diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.inc b/tests/Core/Tokenizer/BackfillReadonlyTest.inc index cbc91f13a3..eb36e38706 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.inc +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.inc @@ -138,6 +138,19 @@ class ReadonlyWithDisjunctiveNormalForm public function readonly (A&B $param): void {} } +/* testReadonlyAnonClassWithParens */ +$anon = new readonly class() {}; + +/* testReadonlyAnonClassWithoutParens */ +$anon = new Readonly class {}; + +/* testReadonlyAnonClassWithCommentsAndWhitespace */ +$anon = new +// comment +READONLY +// phpcs:ignore Stnd.Cat.Sniff +class {}; + /* testParseErrorLiveCoding */ // This must be the last test in the file. readonly diff --git a/tests/Core/Tokenizer/BackfillReadonlyTest.php b/tests/Core/Tokenizer/BackfillReadonlyTest.php index 8fbc3ffa6c..0befb47b75 100644 --- a/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/tests/Core/Tokenizer/BackfillReadonlyTest.php @@ -151,6 +151,17 @@ public static function dataReadonly() 'property declaration, constructor property promotion, DNF type and reference' => [ 'testMarker' => '/* testReadonlyConstructorPropertyPromotionWithDNFAndReference */', ], + 'anon class declaration, with parentheses' => [ + 'testMarker' => '/* testReadonlyAnonClassWithParens */', + ], + 'anon class declaration, without parentheses' => [ + 'testMarker' => '/* testReadonlyAnonClassWithoutParens */', + 'testContent' => 'Readonly', + ], + 'anon class declaration, with comments and whitespace' => [ + 'testMarker' => '/* testReadonlyAnonClassWithCommentsAndWhitespace */', + 'testContent' => 'READONLY', + ], 'live coding / parse error' => [ 'testMarker' => '/* testParseErrorLiveCoding */', ], diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc index aedc49cc67..abbfa62d4d 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc @@ -99,12 +99,16 @@ namespace /* testNamespaceNameIsString1 */ my\ /* testNamespaceNameIsString2 */ /* testVarIsKeyword */ var $var; /* testStaticIsKeyword */ static $static; - /* testReadonlyIsKeyword */ readonly $readonly; + /* testReadonlyIsKeywordForProperty */ readonly $readonly; /* testFinalIsKeyword */ final /* testFunctionIsKeyword */ function someFunction( /* testCallableIsKeyword */ callable $callable, ) { + $anon = new /* testReadonlyIsKeywordForAnonClass */ readonly class() { + public function foo() {} + }; + /* testReturnIsKeyword */ return $this; } diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php index 9116782479..0c311a73bb 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php @@ -232,7 +232,7 @@ public static function dataKeywords() 'expectedTokenType' => 'T_STATIC', ], 'readonly: property declaration' => [ - 'testMarker' => '/* testReadonlyIsKeyword */', + 'testMarker' => '/* testReadonlyIsKeywordForProperty */', 'expectedTokenType' => 'T_READONLY', ], 'final: function declaration' => [ @@ -247,6 +247,10 @@ public static function dataKeywords() 'testMarker' => '/* testCallableIsKeyword */', 'expectedTokenType' => 'T_CALLABLE', ], + 'readonly: anon class declaration' => [ + 'testMarker' => '/* testReadonlyIsKeywordForAnonClass */', + 'expectedTokenType' => 'T_READONLY', + ], 'return: statement' => [ 'testMarker' => '/* testReturnIsKeyword */', 'expectedTokenType' => 'T_RETURN', From 3189b6b459ec2ab8d84c94b03ead85f179d73dd9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 27 Jan 2024 17:20:36 +0100 Subject: [PATCH 390/874] PHP 8.3 | Squiz/LowercaseClassKeywords: add tests with readonly anonymous classes Sniff already handles this and handles it correctly. --- .../Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc | 2 ++ .../Tests/Classes/LowercaseClassKeywordsUnitTest.inc.fixed | 2 ++ .../Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php | 1 + 3 files changed, 5 insertions(+) diff --git a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc index eb724505eb..da47fa179e 100644 --- a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc +++ b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc @@ -12,3 +12,5 @@ ReadOnly class MyClass } $a = new CLASS() {}; + +$anon = new ReadOnly class() {}; diff --git a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc.fixed index 672fdfb3c4..0c18bc86b7 100644 --- a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.inc.fixed @@ -12,3 +12,5 @@ readonly class MyClass } $a = new class() {}; + +$anon = new readonly class() {}; diff --git a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php index 9bbc66fb1d..7fc45e786b 100644 --- a/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/LowercaseClassKeywordsUnitTest.php @@ -40,6 +40,7 @@ public function getErrorList() 10 => 1, 11 => 1, 14 => 1, + 16 => 1, ]; return $errors; From a65d0f3f8facecbc39dc0c767f3b420dd5f3412a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 27 Jan 2024 17:21:58 +0100 Subject: [PATCH 391/874] PHP 8.2/8.3 | Squiz/ScopeKeywordSpacing: add tests with readonly classes Adds test for both plain readonly classes (PHP 8.2) as well as anonymous readonly classes (PHP 8.3). Sniff already handles this and handles it correctly. --- .../Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc | 8 ++++++++ .../WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed | 8 ++++++++ .../Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc index a76f42fef4..49eaa2b633 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc @@ -139,3 +139,11 @@ class ReadonlyTest { public function __construct(readonly protected float|int $x, public readonly?string &$y = 'test') {} } + +// PHP 8.2 readonly classes. +readonly class ReadonlyClassTest {} +readonly class ReadonlyClassTest {} + +// PHP 8.3 readonly anonymous classes. +$anon = new readonly class {}; +$anon = new readonly class {}; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed index 7fd80626d5..4c116c76ad 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed @@ -133,3 +133,11 @@ class ReadonlyTest { public function __construct(readonly protected float|int $x, public readonly ?string &$y = 'test') {} } + +// PHP 8.2 readonly classes. +readonly class ReadonlyClassTest {} +readonly class ReadonlyClassTest {} + +// PHP 8.3 readonly anonymous classes. +$anon = new readonly class {}; +$anon = new readonly class {}; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php index 52bd129ace..cc58d4e797 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php @@ -56,6 +56,8 @@ public function getErrorList($testFile='') 134 => 2, 138 => 2, 140 => 3, + 145 => 1, + 149 => 1, ]; case 'ScopeKeywordSpacingUnitTest.3.inc': From d7ea272668cc64a28b390464f7650e36b9f4d584 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 27 Jan 2024 17:48:04 +0100 Subject: [PATCH 392/874] PHP 8.3 | PSR12/AnonClassDeclaration: add tests with readonly anonymous classes The underlying `PSR2.Classes.ClassDeclaration` sniff, which does the actual checking of the space between a potential modifier keyword and the `class` keyword, already handles this correctly (after squizlabs/PHP_CodeSniffer 3826 and 307). Note: tests were only added to the PSR12 sniffs as that sniffs registers the `T_ANON_CLASS` token. The `PEAR.Classes.ClassDeclaration` sniff and the `PSR2` and `Squiz` versions, which both extend the `PEAR` class, don't need tests as none of those listen for the `T_ANON_CLASS` token. --- .../PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc | 6 ++++++ .../Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed | 5 +++++ .../PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc index fe3ee02ef8..386b12c226 100644 --- a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc +++ b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc @@ -88,3 +88,9 @@ $instance = new class() extends SomeClass implements SomeInterface{ public function __construct() {} }; + +// PHP 8.3 readonly anonymous classes. +$anon = new readonly class {}; +$anon = new readonly class {}; +$anon = new readonly + class {}; diff --git a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed index 4a6c5a1f1a..28b38f7086 100644 --- a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed +++ b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed @@ -91,3 +91,8 @@ $instance = new class () extends SomeClass implements { public function __construct() {} }; + +// PHP 8.3 readonly anonymous classes. +$anon = new readonly class {}; +$anon = new readonly class {}; +$anon = new readonly class {}; diff --git a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php index 06104444ae..240352704f 100644 --- a/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php +++ b/src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php @@ -55,6 +55,8 @@ public function getErrorList() 75 => 1, 87 => 1, 88 => 1, + 94 => 1, + 96 => 1, ]; }//end getErrorList() From cd522835fcb79593eb00582d5b97905ffce8395a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 4 Feb 2024 00:39:15 +0100 Subject: [PATCH 393/874] New `Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence` sniff (#197) This PR adds a sniff that detects mixed boolean operators (`&&`, `||`) within a single expression without making precedence clear using parentheses. --- ...licitBooleanOperatorPrecedenceStandard.xml | 44 ++++++ ...ExplicitBooleanOperatorPrecedenceSniff.php | 119 ++++++++++++++++ ...licitBooleanOperatorPrecedenceUnitTest.inc | 131 ++++++++++++++++++ ...licitBooleanOperatorPrecedenceUnitTest.php | 91 ++++++++++++ 4 files changed, 385 insertions(+) create mode 100644 src/Standards/Generic/Docs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceStandard.xml create mode 100644 src/Standards/Generic/Sniffs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceSniff.php create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.inc create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.php diff --git a/src/Standards/Generic/Docs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceStandard.xml b/src/Standards/Generic/Docs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceStandard.xml new file mode 100644 index 0000000000..006dbff44a --- /dev/null +++ b/src/Standards/Generic/Docs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceStandard.xml @@ -0,0 +1,44 @@ + + + + + + + ($one && $two) || $three; +$result2 = $one && ($two || $three); +$result3 = ($one && !$two) xor $three; +$result4 = $one && (!$two xor $three); + +if ( + ($result && !$result3) + || (!$result && $result3) +) {} + ]]> + + + $one && $two || $three; + +$result3 = $one && !$two xor $three; + + +if ( + $result && !$result3 + || !$result && $result3 +) {} + ]]> + + + diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceSniff.php new file mode 100644 index 0000000000..93afe2e35a --- /dev/null +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceSniff.php @@ -0,0 +1,119 @@ + + * $one = false; + * $two = false; + * $three = true; + * + * $result = $one && $two || $three; + * $result3 = $one && !$two xor $three; + *
+ * + * {@internal The unary `!` operator is not handled, because its high precedence matches its visuals of + * applying only to the sub-expression right next to it, making it unlikely that someone would + * misinterpret its precedence. Requiring parentheses around it would reduce the readability of + * expressions due to the additional characters, especially if multiple subexpressions / variables + * need to be negated.} + * + * Sister-sniff to the `Squiz.ControlStructures.InlineIfDeclaration` and + * `Squiz.Formatting.OperatorBracket.MissingBrackets` sniffs. + * + * @author Tim Duesterhus + * @copyright 2021-2023 WoltLab GmbH. + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + +class RequireExplicitBooleanOperatorPrecedenceSniff implements Sniff +{ + + /** + * Array of tokens this test searches for to find either a boolean + * operator or the start of the current (sub-)expression. Used for + * performance optimization purposes. + * + * @var array + */ + private $searchTargets = []; + + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + $this->searchTargets = Tokens::$booleanOperators; + $this->searchTargets += Tokens::$blockOpeners; + $this->searchTargets[T_INLINE_THEN] = T_INLINE_THEN; + $this->searchTargets[T_INLINE_ELSE] = T_INLINE_ELSE; + + return Tokens::$booleanOperators; + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * + * @return void + */ + public function process(File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $start = $phpcsFile->findStartOfStatement($stackPtr); + + $previous = $phpcsFile->findPrevious( + $this->searchTargets, + ($stackPtr - 1), + $start, + false, + null, + true + ); + + if ($previous === false) { + // No token found. + return; + } + + if ($tokens[$previous]['code'] === $tokens[$stackPtr]['code']) { + // Identical operator found. + return; + } + + if (in_array($tokens[$previous]['code'], [T_INLINE_THEN, T_INLINE_ELSE], true) === true) { + // Beginning of the expression found for the ternary conditional operator. + return; + } + + if (isset(Tokens::$blockOpeners[$tokens[$previous]['code']]) === true) { + // Beginning of the expression found for a block opener. Needed to + // correctly handle match arms. + return; + } + + // We found a mismatching operator, thus we must report the error. + $error = 'Mixing different binary boolean operators within an expression'; + $error .= ' without using parentheses to clarify precedence is not allowed.'; + $phpcsFile->addError($error, $stackPtr, 'MissingParentheses'); + + }//end process() + + +}//end class diff --git a/src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.inc b/src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.inc new file mode 100644 index 0000000000..f46ab9081f --- /dev/null +++ b/src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.inc @@ -0,0 +1,131 @@ + true, +}; + +match (true) { + // Not OK. + $a || $b && $c => true, +}; + +match (true) { + // OK. + $a || $b => true, + $a && $b => true, +}; + +match (true) { + // Debatable. + $a || $b, $a && $b => true, +}; + +// OK. +$foo = fn ($a, $b, $c) => $a && ($b || $c); + +// Not OK. +$foo = fn ($a, $b, $c) => $a && $b || $c; + +// OK. +$foo = $a && (fn ($a, $b, $c) => $a || $b); + +// Debatable. +$foo = $a && fn ($a, $b, $c) => $a || $b; + +// OK. +\array_map( + fn ($a, $b, $c) => $a || $b, + $a && $b +); + +match (true) { + // Not OK. + $a || ($b && $c) && $d => true, + // Not OK. + $b && $c['a'] || $d => true, + // Not OK. + $b && ${$var} || $d => true, +}; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.php new file mode 100644 index 0000000000..db6642e32b --- /dev/null +++ b/src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.php @@ -0,0 +1,91 @@ + + * @copyright 2021-2023 WoltLab GmbH. + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Standards\Generic\Tests\CodeAnalysis; + +use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; + +/** + * Unit test class for the RequireExplicitBooleanOperatorPrecedence sniff. + * + * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\RequireExplicitBooleanOperatorPrecedenceSniff + */ +final class RequireExplicitBooleanOperatorPrecedenceUnitTest extends AbstractSniffUnitTest +{ + + + /** + * Returns the lines where errors should occur. + * + * The key of the array should represent the line number and the value + * should represent the number of errors that should occur on that line. + * + * @return array + */ + public function getErrorList() + { + return [ + 3 => 1, + 7 => 1, + 12 => 1, + 17 => 1, + 29 => 1, + 31 => 1, + 33 => 1, + 34 => 1, + 35 => 1, + 37 => 1, + 39 => 1, + 41 => 2, + 43 => 2, + 44 => 1, + 47 => 1, + 61 => 1, + 65 => 3, + 68 => 2, + 71 => 1, + 72 => 1, + 73 => 1, + 76 => 2, + 78 => 1, + 79 => 1, + 80 => 1, + 81 => 2, + 83 => 1, + 92 => 1, + 110 => 1, + 126 => 1, + 128 => 1, + 130 => 1, + + // Debatable. + 103 => 1, + 116 => 1, + ]; + + }//end getErrorList() + + + /** + * Returns the lines where warnings should occur. + * + * The key of the array should represent the line number and the value + * should represent the number of warnings that should occur on that line. + * + * @return array + */ + public function getWarningList() + { + return []; + + }//end getWarningList() + + +}//end class From 0144b0c5a08d43876e4ce58086a625027a935cc0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Dec 2023 01:16:04 +0100 Subject: [PATCH 394/874] CS: add the RequireExplicitBooleanOperatorPrecedence sniff to PHPCS native ruleset This commit adds the new sniff as introduced in 197 by TimWolla to the PHPCS native ruleset and fixes the few conditions which were ambiguous in this codebase. --- phpcs.xml.dist | 3 +++ .../PEAR/Sniffs/Commenting/FunctionCommentSniff.php | 8 ++++---- .../Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php | 4 ++-- src/Tokenizers/PHP.php | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index a5fa45793e..9185cd41b0 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -129,6 +129,9 @@ + + + tests/bootstrap\.php diff --git a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php index 48ff5f254e..ee242cf6e1 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php @@ -60,10 +60,10 @@ public function register() public function process(File $phpcsFile, $stackPtr) { $scopeModifier = $phpcsFile->getMethodProperties($stackPtr)['scope']; - if ($scopeModifier === 'protected' - && $this->minimumVisibility === 'public' - || $scopeModifier === 'private' - && ($this->minimumVisibility === 'public' || $this->minimumVisibility === 'protected') + if (($scopeModifier === 'protected' + && $this->minimumVisibility === 'public') + || ($scopeModifier === 'private' + && ($this->minimumVisibility === 'public' || $this->minimumVisibility === 'protected')) ) { return; } diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php index da149cae58..773d25d4f5 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php @@ -108,8 +108,8 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) // Remove the newline after the docblock, and any entirely // empty lines before the member var. - if ($tokens[$i]['code'] === T_WHITESPACE - && $tokens[$i]['line'] === $tokens[$prev]['line'] + if (($tokens[$i]['code'] === T_WHITESPACE + && $tokens[$i]['line'] === $tokens[$prev]['line']) || ($tokens[$i]['column'] === 1 && $tokens[$i]['line'] !== $tokens[($i + 1)]['line']) ) { diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 9c66d811f1..ecee80c430 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -1727,7 +1727,7 @@ protected function tokenize($string) || (stripos($newContent, '0b') === 0 && bindec(str_replace('_', '', $newContent)) > PHP_INT_MAX) || (stripos($newContent, '0o') === 0 && octdec(str_replace('_', '', $newContent)) > PHP_INT_MAX) || (stripos($newContent, '0x') !== 0 - && stripos($newContent, 'e') !== false || strpos($newContent, '.') !== false) + && (stripos($newContent, 'e') !== false || strpos($newContent, '.') !== false)) || (strpos($newContent, '0') === 0 && stripos($newContent, '0x') !== 0 && stripos($newContent, '0b') !== 0 && octdec(str_replace('_', '', $newContent)) > PHP_INT_MAX) || (strpos($newContent, '0') !== 0 && str_replace('_', '', $newContent) > PHP_INT_MAX)) From 3f25050b93255df533eb533807c3d6695c7b6e3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 05:24:11 +0000 Subject: [PATCH 395/874] GH Actions: Bump peter-evans/create-pull-request from 5 to 6 Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 5 to 6. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v5...v6) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/happy-new-year.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/happy-new-year.yml b/.github/workflows/happy-new-year.yml index 2c31aa9cdd..380569e44b 100644 --- a/.github/workflows/happy-new-year.yml +++ b/.github/workflows/happy-new-year.yml @@ -73,7 +73,7 @@ jobs: run: exit 1 - name: Create pull request - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v6 with: base: ${{ steps.branches.outputs.BASE }} branch: ${{ steps.branches.outputs.PR_BRANCH }} From 225de103df44feafd38ebf59526c5057c133626f Mon Sep 17 00:00:00 2001 From: Joachim Noreiko Date: Mon, 5 Feb 2024 10:40:11 +0000 Subject: [PATCH 396/874] Fixed documentation for -s option. --- src/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index dd76cfc598..25b3a4f431 100644 --- a/src/Config.php +++ b/src/Config.php @@ -1407,7 +1407,7 @@ public function printPHPCSUsage() echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL; echo ' -w Print both warnings and errors (this is the default)'.PHP_EOL; echo ' -l Local directory only, no recursion'.PHP_EOL; - echo ' -s Show sniff codes in all reports'.PHP_EOL; + echo ' -s Show error codes in all reports'.PHP_EOL; echo ' -a Run interactively'.PHP_EOL; echo ' -e Explain a standard by showing the sniffs it includes'.PHP_EOL; echo ' -p Show progress of the run'.PHP_EOL; From 5fd4059f1b727849ad424b884619e9808d38a9fa Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Jan 2024 00:13:55 +0100 Subject: [PATCH 397/874] PHP 8.3 | PSR12/ClassInstantiation: allow for readonly anonymous classes The sniff is supposed to ignore anonymous class instantiations completely as otherwise it could create a conflict between this sniff and the PSR12 sniff checking anonymous class declarations. As things were, however, the sniff would add parentheses after the `new` keyword or after an attribute if an anonymous class was declared as `readonly`, as allowed since PHP 8.3. Fixed now. Includes minor simplification - the sniff would previously _jump over_ attributes attached to anonymous classes to get to the `class` keyword only to bow out later for anonymous classes anyway. Now, the sniff will bow out straight away when either an attribute, the `readonly` keyword or the `class` keyword for an anonymous class declaration is encountered. As `readonly` cannot be used as class name and attributes cannot be attached to (non-anonymous) class instantiations, this should maintain the previous behaviour, while also allowing for PHP 8.3 readonly anonymous classes and it should yield a very small performance benefit as well. Includes unit tests. --- .../Sniffs/Classes/ClassInstantiationSniff.php | 15 ++++++--------- .../Tests/Classes/ClassInstantiationUnitTest.inc | 4 ++++ .../Classes/ClassInstantiationUnitTest.inc.fixed | 4 ++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php b/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php index 2130b8ddbc..048cb60ccf 100644 --- a/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php @@ -64,12 +64,14 @@ public function process(File $phpcsFile, $stackPtr) continue; } - // Skip over potential attributes for anonymous classes. + // Bow out when this is an anonymous class. + // Anonymous classes are the only situation which would allow for an attribute + // or for the readonly keyword between "new" and the class "name". if ($tokens[$i]['code'] === T_ATTRIBUTE - && isset($tokens[$i]['attribute_closer']) === true + || $tokens[$i]['code'] === T_READONLY + || $tokens[$i]['code'] === T_ANON_CLASS ) { - $i = $tokens[$i]['attribute_closer']; - continue; + return; } if ($tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET @@ -87,11 +89,6 @@ public function process(File $phpcsFile, $stackPtr) return; } - if ($tokens[$classNameEnd]['code'] === T_ANON_CLASS) { - // Ignore anon classes. - return; - } - if ($tokens[$classNameEnd]['code'] === T_OPEN_PARENTHESIS) { // Using parenthesis. return; diff --git a/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc b/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc index 9fd1548072..264116779f 100644 --- a/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc +++ b/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc @@ -45,3 +45,7 @@ $anonWithAttribute = new #[SomeAttribute('summary')] class { $foo = new parent(); $foo = new parent; + +// PHP 8.3: safeguard that the sniff ignores anonymous classes, even when declared as readonly. +$anon = new readonly class {}; +$anon = new #[MyAttribute] readonly class {}; diff --git a/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc.fixed b/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc.fixed index aa9d0c7209..1e580f45d9 100644 --- a/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc.fixed +++ b/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc.fixed @@ -45,3 +45,7 @@ $anonWithAttribute = new #[SomeAttribute('summary')] class { $foo = new parent(); $foo = new parent(); + +// PHP 8.3: safeguard that the sniff ignores anonymous classes, even when declared as readonly. +$anon = new readonly class {}; +$anon = new #[MyAttribute] readonly class {}; From 53dd20ca94c44a4614add3cea56c2cfe76626ab0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 1 Feb 2024 02:52:09 +0100 Subject: [PATCH 398/874] PHP 8.3 | Tokenizer/PHP: add support for typed OO constants PHP 8.3 introduced typed OO constants, where the type is between the `const` keyword and the constant name. All type variations are supported, including nullable types, union types, intersection types, with the exception of `callable`, `void` and `never`. `self` and `static` types are only allowed in Enum constants. This PR adds support for typed OO constants in the Tokenizer layer of PHPCS. The following issues had to be fixed to support typed constants: 1. Consistently tokenizing the constant _name_ as `T_STRING`, even if the name mirrors a reserved keyword, like `foreach` or a special keyword, like `self` or `true`. 2. Tokenizing a `?` at the start of a constant type declaration as `T_NULLABLE`. 3. Tokenizing a `|` and `&` operators within a constant type declaration as `T_TYPE_UNION` and `T_TYPE_INTERSECTION` respectively. Each and every part of the above has been covered by extensive tests. Includes additional tests safeguarding that the `array` keyword when used in a type declaration for a constant is tokenized as `T_STRING`. Ref: https://wiki.php.net/rfc/typed_class_constants --- src/Tokenizers/PHP.php | 102 +++- tests/Core/Tokenizer/ArrayKeywordTest.inc | 10 +- tests/Core/Tokenizer/ArrayKeywordTest.php | 17 +- tests/Core/Tokenizer/BitwiseOrTest.inc | 24 + tests/Core/Tokenizer/BitwiseOrTest.php | 9 + .../ContextSensitiveKeywordsTest.inc | 6 + .../ContextSensitiveKeywordsTest.php | 19 + .../OtherContextSensitiveKeywordsTest.inc | 14 + .../OtherContextSensitiveKeywordsTest.php | 90 +++ tests/Core/Tokenizer/TypeIntersectionTest.inc | 24 + tests/Core/Tokenizer/TypeIntersectionTest.php | 9 + tests/Core/Tokenizer/TypedConstantsTest.inc | 132 +++++ tests/Core/Tokenizer/TypedConstantsTest.php | 515 ++++++++++++++++++ 13 files changed, 963 insertions(+), 8 deletions(-) create mode 100644 tests/Core/Tokenizer/TypedConstantsTest.inc create mode 100644 tests/Core/Tokenizer/TypedConstantsTest.php diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index ecee80c430..31cc0237a2 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -526,8 +526,9 @@ protected function tokenize($string) $numTokens = count($tokens); $lastNotEmptyToken = 0; - $insideInlineIf = []; - $insideUseGroup = false; + $insideInlineIf = []; + $insideUseGroup = false; + $insideConstDeclaration = false; $commentTokenizer = new Comment(); @@ -608,7 +609,8 @@ protected function tokenize($string) if ($tokenIsArray === true && isset(Util\Tokens::$contextSensitiveKeywords[$token[0]]) === true && (isset($this->tstringContexts[$finalTokens[$lastNotEmptyToken]['code']]) === true - || $finalTokens[$lastNotEmptyToken]['content'] === '&') + || $finalTokens[$lastNotEmptyToken]['content'] === '&' + || $insideConstDeclaration === true) ) { if (isset($this->tstringContexts[$finalTokens[$lastNotEmptyToken]['code']]) === true) { $preserveKeyword = false; @@ -665,6 +667,30 @@ protected function tokenize($string) } }//end if + // Types in typed constants should not be touched, but the constant name should be. + if ((isset($this->tstringContexts[$finalTokens[$lastNotEmptyToken]['code']]) === true + && $finalTokens[$lastNotEmptyToken]['code'] === T_CONST) + || $insideConstDeclaration === true + ) { + $preserveKeyword = true; + + // Find the next non-empty token. + for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { + if (is_array($tokens[$i]) === true + && isset(Util\Tokens::$emptyTokens[$tokens[$i][0]]) === true + ) { + continue; + } + + break; + } + + if ($tokens[$i] === '=' || $tokens[$i] === ';') { + $preserveKeyword = false; + $insideConstDeclaration = false; + } + }//end if + if ($finalTokens[$lastNotEmptyToken]['content'] === '&') { $preserveKeyword = true; @@ -698,6 +724,26 @@ protected function tokenize($string) } }//end if + /* + Mark the start of a constant declaration to allow for handling keyword to T_STRING + convertion for constant names using reserved keywords. + */ + + if ($tokenIsArray === true && $token[0] === T_CONST) { + $insideConstDeclaration = true; + } + + /* + Close an open "inside constant declaration" marker when no keyword convertion was needed. + */ + + if ($insideConstDeclaration === true + && $tokenIsArray === false + && ($token[0] === '=' || $token[0] === ';') + ) { + $insideConstDeclaration = false; + } + /* Special case for `static` used as a function name, i.e. `static()`. */ @@ -1869,6 +1915,20 @@ protected function tokenize($string) $newToken = []; $newToken['content'] = '?'; + // For typed constants, we only need to check the token before the ? to be sure. + if ($finalTokens[$lastNotEmptyToken]['code'] === T_CONST) { + $newToken['code'] = T_NULLABLE; + $newToken['type'] = 'T_NULLABLE'; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* token $stackPtr changed from ? to T_NULLABLE".PHP_EOL; + } + + $finalTokens[$newStackPtr] = $newToken; + $newStackPtr++; + continue; + } + /* * Check if the next non-empty token is one of the tokens which can be used * in type declarations. If not, it's definitely a ternary. @@ -2236,7 +2296,30 @@ function return types. We want to keep the parenthesis map clean, if ($tokenIsArray === true && $token[0] === T_STRING) { $preserveTstring = false; - if (isset($this->tstringContexts[$finalTokens[$lastNotEmptyToken]['code']]) === true) { + // True/false/parent/self/static in typed constants should be fixed to their own token, + // but the constant name should not be. + if ((isset($this->tstringContexts[$finalTokens[$lastNotEmptyToken]['code']]) === true + && $finalTokens[$lastNotEmptyToken]['code'] === T_CONST) + || $insideConstDeclaration === true + ) { + // Find the next non-empty token. + for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { + if (is_array($tokens[$i]) === true + && isset(Util\Tokens::$emptyTokens[$tokens[$i][0]]) === true + ) { + continue; + } + + break; + } + + if ($tokens[$i] === '=') { + $preserveTstring = true; + $insideConstDeclaration = false; + } + } else if (isset($this->tstringContexts[$finalTokens[$lastNotEmptyToken]['code']]) === true + && $finalTokens[$lastNotEmptyToken]['code'] !== T_CONST + ) { $preserveTstring = true; // Special case for syntax like: return new self/new parent @@ -3008,6 +3091,12 @@ protected function processAdditional() $suspectedType = 'return'; } + if ($this->tokens[$x]['code'] === T_EQUAL) { + // Possible constant declaration, the `T_STRING` name will have been skipped over already. + $suspectedType = 'constant'; + break; + } + break; }//end for @@ -3049,6 +3138,11 @@ protected function processAdditional() break; } + if ($suspectedType === 'constant' && $this->tokens[$x]['code'] === T_CONST) { + $confirmed = true; + break; + } + if ($suspectedType === 'property or parameter' && (isset(Util\Tokens::$scopeModifiers[$this->tokens[$x]['code']]) === true || $this->tokens[$x]['code'] === T_VAR diff --git a/tests/Core/Tokenizer/ArrayKeywordTest.inc b/tests/Core/Tokenizer/ArrayKeywordTest.inc index ce5c553cf6..ce211bda2a 100644 --- a/tests/Core/Tokenizer/ArrayKeywordTest.inc +++ b/tests/Core/Tokenizer/ArrayKeywordTest.inc @@ -21,10 +21,10 @@ $var = array( ); /* testFunctionDeclarationParamType */ -function foo(array $a) {} +function typedParam(array $a) {} /* testFunctionDeclarationReturnType */ -function foo($a) : int|array|null {} +function returnType($a) : int|array|null {} class Bar { /* testClassConst */ @@ -32,4 +32,10 @@ class Bar { /* testClassMethod */ public function array() {} + + /* testOOConstType */ + const array /* testTypedOOConstName */ ARRAY = /* testOOConstDefault */ array(); + + /* testOOPropertyType */ + protected array $property; } diff --git a/tests/Core/Tokenizer/ArrayKeywordTest.php b/tests/Core/Tokenizer/ArrayKeywordTest.php index 4e2a04a700..f81706c330 100644 --- a/tests/Core/Tokenizer/ArrayKeywordTest.php +++ b/tests/Core/Tokenizer/ArrayKeywordTest.php @@ -68,6 +68,9 @@ public static function dataArrayKeyword() 'nested: inner array' => [ 'testMarker' => '/* testNestedArray */', ], + 'OO constant default value' => [ + 'testMarker' => '/* testOOConstDefault */', + ], ]; }//end dataArrayKeyword() @@ -122,6 +125,12 @@ public static function dataArrayType() 'function union return type' => [ 'testMarker' => '/* testFunctionDeclarationReturnType */', ], + 'OO constant type' => [ + 'testMarker' => '/* testOOConstType */', + ], + 'OO property type' => [ + 'testMarker' => '/* testOOPropertyType */', + ], ]; }//end dataArrayType() @@ -167,13 +176,17 @@ public function testNotArrayKeyword($testMarker, $testContent='array') public static function dataNotArrayKeyword() { return [ - 'class-constant-name' => [ + 'class-constant-name' => [ 'testMarker' => '/* testClassConst */', 'testContent' => 'ARRAY', ], - 'class-method-name' => [ + 'class-method-name' => [ 'testMarker' => '/* testClassMethod */', ], + 'class-constant-name-after-type' => [ + 'testMarker' => '/* testTypedOOConstName */', + 'testContent' => 'ARRAY', + ], ]; }//end dataNotArrayKeyword() diff --git a/tests/Core/Tokenizer/BitwiseOrTest.inc b/tests/Core/Tokenizer/BitwiseOrTest.inc index 4667ad025b..5afc1e5bdf 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.inc +++ b/tests/Core/Tokenizer/BitwiseOrTest.inc @@ -9,6 +9,30 @@ $result = $value | $test /* testBitwiseOr2 */ | $another; class TypeUnion { + /* testTypeUnionOOConstSimple */ + public const Foo|Bar SIMPLE = new Foo; + + /* testTypeUnionOOConstReverseModifierOrder */ + protected final const int|float MODIFIERS_REVERSED /* testBitwiseOrOOConstDefaultValue */ = E_WARNING | E_NOTICE; + + const + /* testTypeUnionOOConstMulti1 */ + array | + /* testTypeUnionOOConstMulti2 */ + Traversable | // phpcs:ignore Stnd.Cat.Sniff + false + /* testTypeUnionOOConstMulti3 */ + | null MULTI_UNION = false; + + /* testTypeUnionOOConstNamespaceRelative */ + final protected const namespace\Sub\NameA|namespace\Sub\NameB NAMESPACE_RELATIVE = new namespace\Sub\NameB; + + /* testTypeUnionOOConstPartiallyQualified */ + const Partially\Qualified\NameA|Partially\Qualified\NameB PARTIALLY_QUALIFIED = new Partially\Qualified\NameA; + + /* testTypeUnionOOConstFullyQualified */ + const \Fully\Qualified\NameA|\Fully\Qualified\NameB FULLY_QUALIFIED = new \Fully\Qualified\NameB(); + /* testTypeUnionPropertySimple */ public static Foo|Bar $obj; diff --git a/tests/Core/Tokenizer/BitwiseOrTest.php b/tests/Core/Tokenizer/BitwiseOrTest.php index 71a1c51ccb..8e3e264f5b 100644 --- a/tests/Core/Tokenizer/BitwiseOrTest.php +++ b/tests/Core/Tokenizer/BitwiseOrTest.php @@ -47,6 +47,7 @@ public static function dataBitwiseOr() return [ 'in simple assignment 1' => ['/* testBitwiseOr1 */'], 'in simple assignment 2' => ['/* testBitwiseOr2 */'], + 'in OO constant default value' => ['/* testBitwiseOrOOConstDefaultValue */'], 'in property default value' => ['/* testBitwiseOrPropertyDefaultValue */'], 'in method parameter default value' => ['/* testBitwiseOrParamDefaultValue */'], 'in return statement' => ['/* testBitwiseOr3 */'], @@ -97,6 +98,14 @@ public function testTypeUnion($testMarker) public static function dataTypeUnion() { return [ + 'type for OO constant' => ['/* testTypeUnionOOConstSimple */'], + 'type for OO constant, reversed modifier order' => ['/* testTypeUnionOOConstReverseModifierOrder */'], + 'type for OO constant, first of multi-union' => ['/* testTypeUnionOOConstMulti1 */'], + 'type for OO constant, middle of multi-union + comments' => ['/* testTypeUnionOOConstMulti2 */'], + 'type for OO constant, last of multi-union' => ['/* testTypeUnionOOConstMulti3 */'], + 'type for OO constant, using namespace relative names' => ['/* testTypeUnionOOConstNamespaceRelative */'], + 'type for OO constant, using partially qualified names' => ['/* testTypeUnionOOConstPartiallyQualified */'], + 'type for OO constant, using fully qualified names' => ['/* testTypeUnionOOConstFullyQualified */'], 'type for static property' => ['/* testTypeUnionPropertySimple */'], 'type for static property, reversed modifier order' => ['/* testTypeUnionPropertyReverseModifierOrder */'], 'type for property, first of multi-union' => ['/* testTypeUnionPropertyMulti1 */'], diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc index abbfa62d4d..2d471285c2 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc @@ -76,6 +76,12 @@ class ContextSensitiveKeywords const /* testAnd */ AND = 'LOGICAL_AND'; const /* testOr */ OR = 'LOGICAL_OR'; const /* testXor */ XOR = 'LOGICAL_XOR'; + + const /* testArrayIsTstringInConstType */ array /* testArrayNameForTypedConstant */ ARRAY = /* testArrayIsKeywordInConstDefault */ array(); + const /* testStaticIsKeywordAsConstType */ static /* testStaticIsNameForTypedConstant */ STATIC = new /* testStaticIsKeywordAsConstDefault */ static; + + const int|bool /* testPrivateNameForUnionTypedConstant */ PRIVATE = 'PRIVATE'; + const Foo&Bar /* testFinalNameForIntersectionTypedConstant */ FINAL = 'FINAL'; } namespace /* testKeywordAfterNamespaceShouldBeString */ class; diff --git a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php index 0c311a73bb..51c5453873 100644 --- a/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php +++ b/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php @@ -118,6 +118,12 @@ public static function dataStrings() 'constant declaration: or' => ['/* testOr */'], 'constant declaration: xor' => ['/* testXor */'], + 'constant declaration: array in type' => ['/* testArrayIsTstringInConstType */'], + 'constant declaration: array, name after type' => ['/* testArrayNameForTypedConstant */'], + 'constant declaration: static, name after type' => ['/* testStaticIsNameForTypedConstant */'], + 'constant declaration: private, name after type' => ['/* testPrivateNameForUnionTypedConstant */'], + 'constant declaration: final, name after type' => ['/* testFinalNameForIntersectionTypedConstant */'], + 'namespace declaration: class' => ['/* testKeywordAfterNamespaceShouldBeString */'], 'namespace declaration (partial): my' => ['/* testNamespaceNameIsString1 */'], 'namespace declaration (partial): class' => ['/* testNamespaceNameIsString2 */'], @@ -179,6 +185,19 @@ public static function dataKeywords() 'testMarker' => '/* testNamespaceIsKeyword */', 'expectedTokenType' => 'T_NAMESPACE', ], + 'array: default value in const decl' => [ + 'testMarker' => '/* testArrayIsKeywordInConstDefault */', + 'expectedTokenType' => 'T_ARRAY', + ], + 'static: type in constant declaration' => [ + 'testMarker' => '/* testStaticIsKeywordAsConstType */', + 'expectedTokenType' => 'T_STATIC', + ], + 'static: value in constant declaration' => [ + 'testMarker' => '/* testStaticIsKeywordAsConstDefault */', + 'expectedTokenType' => 'T_STATIC', + ], + 'abstract: class declaration' => [ 'testMarker' => '/* testAbstractIsKeyword */', 'expectedTokenType' => 'T_ABSTRACT', diff --git a/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc b/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc index f19992c150..50b2c2ee24 100644 --- a/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc +++ b/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc @@ -51,3 +51,17 @@ function standAloneFalseTrueNullTypesAndMore( || $a === /* testNullIsKeywordInComparison */ null ) {} } + +class TypedConstProp { + const /* testFalseIsKeywordAsConstType */ false /* testFalseIsNameForTypedConstant */ FALSE = /* testFalseIsKeywordAsConstDefault */ false; + const /* testTrueIsKeywordAsConstType */ true /* testTrueIsNameForTypedConstant */ TRUE = /* testTrueIsKeywordAsConstDefault */ true; + const /* testNullIsKeywordAsConstType */ null /* testNullIsNameForTypedConstant */ NULL = /* testNullIsKeywordAsConstDefault */ null; + const /* testSelfIsKeywordAsConstType */ self /* testSelfIsNameForTypedConstant */ SELF = new /* testSelfIsKeywordAsConstDefault */ self; + const /* testParentIsKeywordAsConstType */ parent /* testParentIsNameForTypedConstant */ PARENT = new /* testParentIsKeywordAsConstDefault */ parent; + + public /* testFalseIsKeywordAsPropertyType */ false $false = /* testFalseIsKeywordAsPropertyDefault */ false; + protected readonly /* testTrueIsKeywordAsPropertyType */ true $true = /* testTrueIsKeywordAsPropertyDefault */ true; + static private /* testNullIsKeywordAsPropertyType */ null $null = /* testNullIsKeywordAsPropertyDefault */ null; + var /* testSelfIsKeywordAsPropertyType */ self $self = new /* testSelfIsKeywordAsPropertyDefault */ self; + protected /* testParentIsKeywordAsPropertyType */ parent $parent = new /* testParentIsKeywordAsPropertyDefault */ parent; +} diff --git a/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.php b/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.php index cb55d5ca7e..7473cdf3c9 100644 --- a/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.php +++ b/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.php @@ -86,6 +86,12 @@ public static function dataStrings() 'class instantiation: false' => ['/* testClassInstantiationFalseIsString */'], 'class instantiation: true' => ['/* testClassInstantiationTrueIsString */'], 'class instantiation: null' => ['/* testClassInstantiationNullIsString */'], + + 'constant declaration: false as name after type' => ['/* testFalseIsNameForTypedConstant */'], + 'constant declaration: true as name after type' => ['/* testTrueIsNameForTypedConstant */'], + 'constant declaration: null as name after type' => ['/* testNullIsNameForTypedConstant */'], + 'constant declaration: self as name after type' => ['/* testSelfIsNameForTypedConstant */'], + 'constant declaration: parent as name after type' => ['/* testParentIsNameForTypedConstant */'], ]; }//end dataStrings() @@ -185,6 +191,90 @@ public static function dataKeywords() 'testMarker' => '/* testNullIsKeywordInComparison */', 'expectedTokenType' => 'T_NULL', ], + + 'false: type in OO constant declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsConstType */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: type in OO constant declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsConstType */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: type in OO constant declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsConstType */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: type in OO constant declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsConstType */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: type in OO constant declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsConstType */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: value in constant declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsConstDefault */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: value in constant declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsConstDefault */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: value in constant declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsConstDefault */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: value in constant declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsConstDefault */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: value in constant declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsConstDefault */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: type in property declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsPropertyType */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: type in property declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsPropertyType */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: type in property declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsPropertyType */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: type in property declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsPropertyType */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: type in property declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsPropertyType */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: value in property declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsPropertyDefault */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: value in property declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsPropertyDefault */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: value in property declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsPropertyDefault */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: value in property declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsPropertyDefault */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: value in property declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsPropertyDefault */', + 'expectedTokenType' => 'T_PARENT', + ], ]; }//end dataKeywords() diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.inc b/tests/Core/Tokenizer/TypeIntersectionTest.inc index 10cd56b2db..d9a68db363 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.inc +++ b/tests/Core/Tokenizer/TypeIntersectionTest.inc @@ -9,6 +9,30 @@ $result = $value & $test /* testBitwiseAnd2 */ & $another; class TypeIntersection { + /* testTypeIntersectionOOConstSimple */ + public const Foo&Bar SIMPLE = new Foo(); + + /* testTypeIntersectionOOConstReverseModifierOrder */ + protected final const Something&Nothing MODIFIERS_REVERSED /* testBitwiseAndOOConstDefaultValue */ = E_WARNING & E_NOTICE; + + const + /* testTypeIntersectionOOConstMulti1 */ + Foo & + /* testTypeIntersectionOOConstMulti2 */ + Traversable & // phpcs:ignore Stnd.Cat.Sniff + Boo + /* testTypeIntersectionOOConstMulti3 */ + & Bar MULTI_INTERSECTION = false; + + /* testTypeIntersectionOOConstNamespaceRelative */ + const namespace\Sub\NameA&namespace\Sub\NameB NAMESPACE_RELATIVE = new namespace\Sub\NameB; + + /* testTypeIntersectionOOConstPartiallyQualified */ + const Partially\Qualified\NameA&Partially\Qualified\NameB PARTIALLY_QUALIFIED = new Partially\Qualified\NameA; + + /* testTypeIntersectionOOConstFullyQualified */ + const \Fully\Qualified\NameA&\Fully\Qualified\NameB FULLY_QUALIFIED = new \Fully\Qualified\NameB(); + /* testTypeIntersectionPropertySimple */ public static Foo&Bar $obj; diff --git a/tests/Core/Tokenizer/TypeIntersectionTest.php b/tests/Core/Tokenizer/TypeIntersectionTest.php index 32710f7fef..c719850c19 100644 --- a/tests/Core/Tokenizer/TypeIntersectionTest.php +++ b/tests/Core/Tokenizer/TypeIntersectionTest.php @@ -48,6 +48,7 @@ public static function dataBitwiseAnd() return [ 'in simple assignment 1' => ['/* testBitwiseAnd1 */'], 'in simple assignment 2' => ['/* testBitwiseAnd2 */'], + 'in OO constant default value' => ['/* testBitwiseAndOOConstDefaultValue */'], 'in property default value' => ['/* testBitwiseAndPropertyDefaultValue */'], 'in method parameter default value' => ['/* testBitwiseAndParamDefaultValue */'], 'reference for method parameter' => ['/* testBitwiseAnd3 */'], @@ -100,6 +101,14 @@ public function testTypeIntersection($testMarker) public static function dataTypeIntersection() { return [ + 'type for OO constant' => ['/* testTypeIntersectionOOConstSimple */'], + 'type for OO constant, reversed modifier order' => ['/* testTypeIntersectionOOConstReverseModifierOrder */'], + 'type for OO constant, first of multi-intersect' => ['/* testTypeIntersectionOOConstMulti1 */'], + 'type for OO constant, middle of multi-intersect + comments' => ['/* testTypeIntersectionOOConstMulti2 */'], + 'type for OO constant, last of multi-intersect' => ['/* testTypeIntersectionOOConstMulti3 */'], + 'type for OO constant, using namespace relative names' => ['/* testTypeIntersectionOOConstNamespaceRelative */'], + 'type for OO constant, using partially qualified names' => ['/* testTypeIntersectionOOConstPartiallyQualified */'], + 'type for OO constant, using fully qualified names' => ['/* testTypeIntersectionOOConstFullyQualified */'], 'type for static property' => ['/* testTypeIntersectionPropertySimple */'], 'type for static property, reversed modifier order' => ['/* testTypeIntersectionPropertyReverseModifierOrder */'], 'type for property, first of multi-intersect' => ['/* testTypeIntersectionPropertyMulti1 */'], diff --git a/tests/Core/Tokenizer/TypedConstantsTest.inc b/tests/Core/Tokenizer/TypedConstantsTest.inc new file mode 100644 index 0000000000..a68831392c --- /dev/null +++ b/tests/Core/Tokenizer/TypedConstantsTest.inc @@ -0,0 +1,132 @@ +const ? 0 : 1; + +/* testGlobalConstantCannotBeTyped */ +const GLOBAL_UNTYPED = true; + +/* testGlobalConstantTypedShouldStillBeHandled */ +const ?int GLOBAL_TYPED = true; + +class ClassWithPlainTypedConstants { + /* testClassConstFinalUntyped */ + final const FINAL_UNTYPED = true; + + /* testClassConstVisibilityUntyped */ + public const /*comment*/VISIBLE_UNTYPED = true; + + /* testClassConstTypedTrue */ + const true TYPED_TRUE = true; + /* testClassConstTypedFalse */ + final const false TYPED_FALSE = false; + /* testClassConstTypedNull */ + public const null TYPED_NULL = null; + /* testClassConstTypedBool */ + final protected const/*comment*/bool TYPED_BOOL = false; + /* testClassConstTypedInt */ + private const int TYPED_INT = 0; + /* testClassConstTypedFloat */ + const float TYPED_FLOAT = 0.5; + /* testClassConstTypedString */ + public final const string/*comment*/TYPED_STRING = 'string'; + /* testClassConstTypedArray */ + private final const array TYPED_ARRAY = []; + /* testClassConstTypedObject */ + const + object + TYPED_OBJECT = MyClass::getInstance(); + /* testClassConstTypedIterable */ + const iterable typed_iterable = []; + /* testClassConstTypedMixed */ + const mixed TYPED_MIXED = 'string'; + + /* testClassConstTypedClassUnqualified */ + const MyClass TYPED_UNQUALIFIED_CLASSNAME = MyClass::getInstance(); + /* testClassConstTypedClassFullyQualified */ + public const \MyClass TYPED_FULLY_QUALIFIED_CLASSNAME = MyClass::getInstance(); + /* testClassConstTypedClassNamespaceRelative */ + protected const namespace\MyClass TYPED_NAMESPACE_RELATIVE_CLASSNAME = MyClass::getInstance(); + /* testClassConstTypedClassPartiallyQualified */ + private const Partial\MyClass TYPED_PARTIALLY_QUALIFIED_CLASSNAME = MyClass::getInstance(); + /* testClassConstTypedParent */ + const parent TYPED_PARENT = parent::getInstance(); + + // Illegal types - the fact that these are not allowed in PHP is not the concern of the PHPCS tokenizer. + /* testClassConstTypedCallable */ + protected const callable TYPED_CALLABLE = 'function_name'; + /* testClassConstTypedVoid */ + protected const void TYPED_VOID = null; + /* testClassConstTypedNever */ + protected const NEVER TYPED_NEVER = null; +} + +trait TraitWithNullableTypedConstants { + /* testTraitConstTypedNullableTrue */ + const ?true TYPED_TRUE = true; + /* testTraitConstTypedNullableFalse */ + final const ?false TYPED_FALSE = false; + /* testTraitConstTypedNullableNull */ + public const ?null TYPED_NULL = null; + /* testTraitConstTypedNullableBool */ + final protected const ?bool TYPED_BOOL = false; + /* testTraitConstTypedNullableInt */ + private const ?int TYPED_INT = 0; + /* testTraitConstTypedNullableFloat */ + const ? /*comment*/ float TYPED_FLOAT = 0.5; + /* testTraitConstTypedNullableString */ + public final const ?string TYPED_STRING = 'string'; + /* testTraitConstTypedNullableArray */ + private final const ? array TYPED_ARRAY = []; + /* testTraitConstTypedNullableObject */ + const ?object TYPED_OBJECT = MyClass::getInstance(); + /* testTraitConstTypedNullableIterable */ + const ?iterable TYPED_ITERABLE = []; + /* testTraitConstTypedNullableMixed */ + const ?mixed TYPED_MIXED = 'string'; + + /* testTraitConstTypedNullableClassUnqualified */ + const ?MyClass TYPED_UNQUALIFIED_CLASSNAME = MyClass::getInstance(); + /* testTraitConstTypedNullableClassFullyQualified */ + public const ?\MyClass TYPED_FULLY_QUALIFIED_CLASSNAME = MyClass::getInstance(); + /* testTraitConstTypedNullableClassNamespaceRelative */ + protected const ?namespace\MyClass TYPED_NAMESPACE_RELATIVE_CLASSNAME = MyClass::getInstance(); + /* testTraitConstTypedNullableClassPartiallyQualified */ + private const ?Partial\MyClass TYPED_PARTIALLY_QUALIFIED_CLASSNAME = MyClass::getInstance(); + /* testTraitConstTypedNullableParent */ + const ?parent TYPED_PARENT = parent::getInstance(); +} + +interface InterfaceWithUnionTypedConstants { + /* testInterfaceConstTypedUnionTrueNull */ + const true|null /*comment*/ UNION_TRUE_NULL = true; + /* testInterfaceConstTypedUnionArrayObject */ + const array|object UNION_ARRAY_OBJECT = []; + /* testInterfaceConstTypedUnionStringArrayInt */ + const string | array | int UNION_STRING_ARRAY_INT = 'array middle'; + /* testInterfaceConstTypedUnionFloatBoolArray */ + const float /*comment*/| bool|array UNION_FLOAT_BOOL_ARRAY = false; + /* testInterfaceConstTypedUnionIterableFalse */ + const iterable|false UNION_ITERABLE_FALSE = false; + /* testInterfaceConstTypedUnionUnqualifiedNamespaceRelative */ + const Unqualified|namespace\Relative UNION_UNQUALIFIED_NSRELATIVE = new Unqualified(); + /* testInterfaceConstTypedUnionFullyQualifiedPartiallyQualified */ + const \Fully\Qualified|Partially\Qualified UNION_FQN_PARTIAL = new Partial\Qualified; +} + +enum EnumWithIntersectionTypedConstants { + // Illegal types in a class, but legal in an enum. + /* testEnumConstTypedSelf */ + final const self TYPED_SELF = self::getInstance(); + /* testEnumConstTypedStatic */ + const static TYPED_STATIC = static::getInstance(); + /* testEnumConstTypedNullableSelf */ + public const ?self TYPED_SELF = self::getInstance(); + /* testEnumConstTypedNullableStatic */ + const ?static TYPED_STATIC = static::getInstance(); + + /* testEnumConstTypedIntersectUnqualifiedNamespaceRelative */ + const Unqualified&namespace\Relative UNION_UNQUALIFIED_NSRELATIVE = new Unqualified(); + /* testEnumConstTypedIntersectFullyQualifiedPartiallyQualified */ + const \Fully\Qualified&Partially\Qualified UNION_FQN_PARTIAL = new Partial\Qualified; +} diff --git a/tests/Core/Tokenizer/TypedConstantsTest.php b/tests/Core/Tokenizer/TypedConstantsTest.php new file mode 100644 index 0000000000..0c4a9b6146 --- /dev/null +++ b/tests/Core/Tokenizer/TypedConstantsTest.php @@ -0,0 +1,515 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer; + +use PHP_CodeSniffer\Util\Tokens; + +final class TypedConstantsTest extends AbstractTokenizerTestCase +{ + + + /** + * Test that a ? after a "const" which is not the constant keyword is tokenized as ternary then, not as the nullable operator. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * + * @return void + */ + public function testTernaryIsInlineThen() + { + $tokens = $this->phpcsFile->getTokens(); + $target = $this->getTargetToken('/* testTernaryIsTernaryAfterConst */', [T_NULLABLE, T_INLINE_THEN]); + + $this->assertSame( + T_INLINE_THEN, + $tokens[$target]['code'], + 'Token tokenized as '.Tokens::tokenName($tokens[$target]['code']).', not T_INLINE_THEN (code)' + ); + $this->assertSame( + 'T_INLINE_THEN', + $tokens[$target]['type'], + 'Token tokenized as '.$tokens[$target]['type'].', not T_INLINE_THEN (type)' + ); + + }//end testTernaryIsInlineThen() + + + /** + * Test the token name for an untyped constant is tokenized as T_STRING. + * + * @param string $testMarker The comment prefacing the target token. + * + * @dataProvider dataUntypedConstant + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * + * @return void + */ + public function testUntypedConstant($testMarker) + { + $tokens = $this->phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, T_CONST); + + for ($i = ($target + 1); $tokens[$i]['code'] !== T_EQUAL; $i++) { + if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) { + // Ignore whitespace and comments, not interested in the tokenization of those. + continue; + } + + $this->assertSame( + T_STRING, + $tokens[$i]['code'], + 'Token tokenized as '.Tokens::tokenName($tokens[$i]['code']).', not T_STRING (code)' + ); + $this->assertSame( + 'T_STRING', + $tokens[$i]['type'], + 'Token tokenized as '.$tokens[$i]['type'].', not T_STRING (type)' + ); + } + + }//end testUntypedConstant() + + + /** + * Data provider. + * + * @see testUntypedConstant() + * + * @return array> + */ + public static function dataUntypedConstant() + { + return [ + 'non OO constant (untyped)' => [ + 'testMarker' => '/* testGlobalConstantCannotBeTyped */', + ], + 'OO constant, final, untyped' => [ + 'testMarker' => '/* testClassConstFinalUntyped */', + ], + 'OO constant, public, untyped, with comment' => [ + 'testMarker' => '/* testClassConstVisibilityUntyped */', + ], + ]; + + }//end dataUntypedConstant() + + + /** + * Test the tokens in the type of a typed constant as well as the constant name are tokenized correctly. + * + * @param string $testMarker The comment prefacing the target token. + * @param string $sequence The expected token sequence. + * + * @dataProvider dataTypedConstant + * @dataProvider dataNullableTypedConstant + * @dataProvider dataUnionTypedConstant + * @dataProvider dataIntersectionTypedConstant + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * + * @return void + */ + public function testTypedConstant($testMarker, array $sequence) + { + $tokens = $this->phpcsFile->getTokens(); + $target = $this->getTargetToken($testMarker, T_CONST); + + $current = 0; + for ($i = ($target + 1); $tokens[$i]['code'] !== T_EQUAL; $i++) { + if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) { + // Ignore whitespace and comments, not interested in the tokenization of those. + continue; + } + + $this->assertSame( + $sequence[$current], + $tokens[$i]['code'], + 'Token tokenized as '.Tokens::tokenName($tokens[$i]['code']).', not '.Tokens::tokenName($sequence[$current]).' (code)' + ); + + ++$current; + } + + }//end testTypedConstant() + + + /** + * Data provider. + * + * @see testTypedConstant() + * + * @return array> + */ + public static function dataTypedConstant() + { + $data = [ + 'simple type: true' => [ + 'testMarker' => '/* testClassConstTypedTrue */', + 'sequence' => [T_TRUE], + ], + 'simple type: false' => [ + 'testMarker' => '/* testClassConstTypedFalse */', + 'sequence' => [T_FALSE], + ], + 'simple type: null' => [ + 'testMarker' => '/* testClassConstTypedNull */', + 'sequence' => [T_NULL], + ], + 'simple type: bool' => [ + 'testMarker' => '/* testClassConstTypedBool */', + 'sequence' => [T_STRING], + ], + 'simple type: int' => [ + 'testMarker' => '/* testClassConstTypedInt */', + 'sequence' => [T_STRING], + ], + 'simple type: float' => [ + 'testMarker' => '/* testClassConstTypedFloat */', + 'sequence' => [T_STRING], + ], + 'simple type: string' => [ + 'testMarker' => '/* testClassConstTypedString */', + 'sequence' => [T_STRING], + ], + 'simple type: array' => [ + 'testMarker' => '/* testClassConstTypedArray */', + 'sequence' => [T_STRING], + ], + 'simple type: object' => [ + 'testMarker' => '/* testClassConstTypedObject */', + 'sequence' => [T_STRING], + ], + 'simple type: iterable' => [ + 'testMarker' => '/* testClassConstTypedIterable */', + 'sequence' => [T_STRING], + ], + 'simple type: mixed' => [ + 'testMarker' => '/* testClassConstTypedMixed */', + 'sequence' => [T_STRING], + ], + 'simple type: unqualified name' => [ + 'testMarker' => '/* testClassConstTypedClassUnqualified */', + 'sequence' => [T_STRING], + ], + 'simple type: fully qualified name' => [ + 'testMarker' => '/* testClassConstTypedClassFullyQualified */', + 'sequence' => [ + T_NS_SEPARATOR, + T_STRING, + ], + ], + 'simple type: namespace relative name' => [ + 'testMarker' => '/* testClassConstTypedClassNamespaceRelative */', + 'sequence' => [ + T_NAMESPACE, + T_NS_SEPARATOR, + T_STRING, + ], + ], + 'simple type: partially qualified name' => [ + 'testMarker' => '/* testClassConstTypedClassPartiallyQualified */', + 'sequence' => [ + T_STRING, + T_NS_SEPARATOR, + T_STRING, + ], + ], + 'simple type: parent' => [ + 'testMarker' => '/* testClassConstTypedParent */', + 'sequence' => [T_PARENT], + ], + + 'simple type: callable (invalid)' => [ + 'testMarker' => '/* testClassConstTypedCallable */', + 'sequence' => [T_CALLABLE], + ], + 'simple type: void (invalid)' => [ + 'testMarker' => '/* testClassConstTypedVoid */', + 'sequence' => [T_STRING], + ], + 'simple type: NEVER (invalid)' => [ + 'testMarker' => '/* testClassConstTypedNever */', + 'sequence' => [T_STRING], + ], + + 'simple type: self (only valid in enum)' => [ + 'testMarker' => '/* testEnumConstTypedSelf */', + 'sequence' => [T_SELF], + ], + 'simple type: static (only valid in enum)' => [ + 'testMarker' => '/* testEnumConstTypedStatic */', + 'sequence' => [T_STATIC], + ], + ]; + + // The constant name, as the last token in the sequence, is always T_STRING. + foreach ($data as $key => $value) { + $data[$key]['sequence'][] = T_STRING; + } + + return $data; + + }//end dataTypedConstant() + + + /** + * Data provider. + * + * @see testTypedConstant() + * + * @return array> + */ + public static function dataNullableTypedConstant() + { + $data = [ + // Global constants cannot be typed in PHP, but that's not our concern. + 'global typed constant, invalid, ?int' => [ + 'testMarker' => '/* testGlobalConstantTypedShouldStillBeHandled */', + 'sequence' => [T_STRING], + ], + + // OO constants. + 'nullable type: true' => [ + 'testMarker' => '/* testTraitConstTypedNullableTrue */', + 'sequence' => [T_TRUE], + ], + 'nullable type: false' => [ + 'testMarker' => '/* testTraitConstTypedNullableFalse */', + 'sequence' => [T_FALSE], + ], + 'nullable type: null' => [ + 'testMarker' => '/* testTraitConstTypedNullableNull */', + 'sequence' => [T_NULL], + ], + 'nullable type: bool' => [ + 'testMarker' => '/* testTraitConstTypedNullableBool */', + 'sequence' => [T_STRING], + ], + 'nullable type: int' => [ + 'testMarker' => '/* testTraitConstTypedNullableInt */', + 'sequence' => [T_STRING], + ], + 'nullable type: float' => [ + 'testMarker' => '/* testTraitConstTypedNullableFloat */', + 'sequence' => [T_STRING], + ], + 'nullable type: string' => [ + 'testMarker' => '/* testTraitConstTypedNullableString */', + 'sequence' => [T_STRING], + ], + 'nullable type: array' => [ + 'testMarker' => '/* testTraitConstTypedNullableArray */', + 'sequence' => [T_STRING], + ], + 'nullable type: object' => [ + 'testMarker' => '/* testTraitConstTypedNullableObject */', + 'sequence' => [T_STRING], + ], + 'nullable type: iterable' => [ + 'testMarker' => '/* testTraitConstTypedNullableIterable */', + 'sequence' => [T_STRING], + ], + 'nullable type: mixed' => [ + 'testMarker' => '/* testTraitConstTypedNullableMixed */', + 'sequence' => [T_STRING], + ], + 'nullable type: unqualified name' => [ + 'testMarker' => '/* testTraitConstTypedNullableClassUnqualified */', + 'sequence' => [T_STRING], + ], + 'nullable type: fully qualified name' => [ + 'testMarker' => '/* testTraitConstTypedNullableClassFullyQualified */', + 'sequence' => [ + T_NS_SEPARATOR, + T_STRING, + ], + ], + 'nullable type: namespace relative name' => [ + 'testMarker' => '/* testTraitConstTypedNullableClassNamespaceRelative */', + 'sequence' => [ + T_NAMESPACE, + T_NS_SEPARATOR, + T_STRING, + ], + ], + 'nullable type: partially qualified name' => [ + 'testMarker' => '/* testTraitConstTypedNullableClassPartiallyQualified */', + 'sequence' => [ + T_STRING, + T_NS_SEPARATOR, + T_STRING, + ], + ], + 'nullable type: parent' => [ + 'testMarker' => '/* testTraitConstTypedNullableParent */', + 'sequence' => [T_PARENT], + ], + + 'nullable type: self (only valid in enum)' => [ + 'testMarker' => '/* testEnumConstTypedNullableSelf */', + 'sequence' => [T_SELF], + ], + 'nullable type: static (only valid in enum)' => [ + 'testMarker' => '/* testEnumConstTypedNullableStatic */', + 'sequence' => [T_STATIC], + ], + ]; + + // The nullable operator, as the first token in the sequence, is always T_NULLABLE. + // The constant name, as the last token in the sequence, is always T_STRING. + foreach ($data as $key => $value) { + array_unshift($data[$key]['sequence'], T_NULLABLE); + $data[$key]['sequence'][] = T_STRING; + } + + return $data; + + }//end dataNullableTypedConstant() + + + /** + * Data provider. + * + * @see testTypedConstant() + * + * @return array> + */ + public static function dataUnionTypedConstant() + { + $data = [ + 'union type: true|null' => [ + 'testMarker' => '/* testInterfaceConstTypedUnionTrueNull */', + 'sequence' => [ + T_TRUE, + T_TYPE_UNION, + T_NULL, + ], + ], + 'union type: array|object' => [ + 'testMarker' => '/* testInterfaceConstTypedUnionArrayObject */', + 'sequence' => [ + T_STRING, + T_TYPE_UNION, + T_STRING, + ], + ], + 'union type: string|array|int' => [ + 'testMarker' => '/* testInterfaceConstTypedUnionStringArrayInt */', + 'sequence' => [ + T_STRING, + T_TYPE_UNION, + T_STRING, + T_TYPE_UNION, + T_STRING, + ], + ], + 'union type: float|bool|array' => [ + 'testMarker' => '/* testInterfaceConstTypedUnionFloatBoolArray */', + 'sequence' => [ + T_STRING, + T_TYPE_UNION, + T_STRING, + T_TYPE_UNION, + T_STRING, + ], + ], + 'union type: iterable|false' => [ + 'testMarker' => '/* testInterfaceConstTypedUnionIterableFalse */', + 'sequence' => [ + T_STRING, + T_TYPE_UNION, + T_FALSE, + ], + ], + 'union type: Unqualified|Namespace\Relative' => [ + 'testMarker' => '/* testInterfaceConstTypedUnionUnqualifiedNamespaceRelative */', + 'sequence' => [ + T_STRING, + T_TYPE_UNION, + T_NAMESPACE, + T_NS_SEPARATOR, + T_STRING, + ], + ], + 'union type: FQN|Partial' => [ + 'testMarker' => '/* testInterfaceConstTypedUnionFullyQualifiedPartiallyQualified */', + 'sequence' => [ + T_NS_SEPARATOR, + T_STRING, + T_NS_SEPARATOR, + T_STRING, + T_TYPE_UNION, + T_STRING, + T_NS_SEPARATOR, + T_STRING, + ], + ], + ]; + + // The constant name, as the last token in the sequence, is always T_STRING. + foreach ($data as $key => $value) { + $data[$key]['sequence'][] = T_STRING; + } + + return $data; + + }//end dataUnionTypedConstant() + + + /** + * Data provider. + * + * @see testTypedConstant() + * + * @return array> + */ + public static function dataIntersectionTypedConstant() + { + $data = [ + 'intersection type: Unqualified&Namespace\Relative' => [ + 'testMarker' => '/* testEnumConstTypedIntersectUnqualifiedNamespaceRelative */', + 'sequence' => [ + T_STRING, + T_TYPE_INTERSECTION, + T_NAMESPACE, + T_NS_SEPARATOR, + T_STRING, + ], + ], + 'intersection type: FQN&Partial' => [ + 'testMarker' => '/* testEnumConstTypedIntersectFullyQualifiedPartiallyQualified */', + 'sequence' => [ + T_NS_SEPARATOR, + T_STRING, + T_NS_SEPARATOR, + T_STRING, + T_TYPE_INTERSECTION, + T_STRING, + T_NS_SEPARATOR, + T_STRING, + ], + ], + ]; + + // The constant name, as the last token in the sequence, is always T_STRING. + foreach ($data as $key => $value) { + $data[$key]['sequence'][] = T_STRING; + } + + return $data; + + }//end dataIntersectionTypedConstant() + + +}//end class From 99abd2c89af632139c6304b2ab86bdfa897eeabc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 7 Feb 2024 12:59:29 +0100 Subject: [PATCH 399/874] Squiz/IncrementDecrementUsage: bug fix - code without whitespace [1] As this is a sniff looking for certain functional code patterns, the sniff should disregard whitespace and comments when looking for the relevant tokens to determine whether the code under scan contains the code pattern the sniff is looking for. The sniff, however, does not do this correctly (in multiple places). This commit fixes just one of these issues, as reported in 325. For this particular issue, the `$startPtr` for the `findNext()` is incremented for each `while` loop, but the initial `$startPtr` was also incremented, which meant that if there was no whitespace after an equals sign, the first relevant token was being skipped over. Fixed now. Includes tests. Fixes 325 --- .../Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php | 4 ++-- .../Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc | 3 +++ .../Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php index b0af660db5..1b0c8393d2 100644 --- a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php @@ -165,8 +165,8 @@ protected function processAssignment($phpcsFile, $stackPtr) // We have only one variable, and it's the same as what is being assigned, // so we need to check what is being added or subtracted. - $nextNumber = ($stackPtr + 1); - $previousNumber = ($stackPtr + 1); + $nextNumber = $stackPtr; + $previousNumber = $stackPtr; $numberCount = 0; while (($nextNumber = $phpcsFile->findNext([T_LNUMBER], ($nextNumber + 1), $statementEnd, false)) !== false) { $previousNumber = $nextNumber; diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc index a4f82d1a8c..352adadc15 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc @@ -40,3 +40,6 @@ $expected[($i + 1)]['sort_order'] = ($i + 1); $id = $id.($obj->i++).$id; $id = $obj?->i++.$id; $id = $obj?->i++*10; + +$var+=1; +$var-=1; diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php index 037fee96c2..fe41c280c7 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php @@ -42,6 +42,8 @@ public function getErrorList() 31 => 1, 41 => 1, 42 => 1, + 44 => 1, + 45 => 1, ]; }//end getErrorList() From c29805db42c916b214c781320629cc9c72e855b8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 7 Feb 2024 13:17:46 +0100 Subject: [PATCH 400/874] Squiz/IncrementDecrementUsage: bug fix - code without whitespace [2] As this is a sniff looking for certain functional code patterns, the sniff should disregard whitespace and comments when looking for the relevant tokens to determine whether the code under scan contains the code pattern the sniff is looking for. The sniff, however, does not do this correctly (in multiple places). This commit fixes the same issue as fixed in the previous commit, but now specifically for the part in the code where it is checking that a `$var = $var + 1;` like statement only has one variable in the code comprising the value being assigned. Same as before, the `$startPtr` for the `findNext()` is incremented for each `while` loop, but the initial `$startPtr` was also incremented, which meant that if there was no whitespace after an equals sign, the first relevant token was being skipped over. Fixed now. Includes tests. --- .../Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php | 4 ++-- .../Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc | 3 +++ .../Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php index 1b0c8393d2..7fa4c28428 100644 --- a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php @@ -145,8 +145,8 @@ protected function processAssignment($phpcsFile, $stackPtr) } if ($tokens[$stackPtr]['code'] === T_EQUAL) { - $nextVar = ($stackPtr + 1); - $previousVariable = ($stackPtr + 1); + $nextVar = $stackPtr; + $previousVariable = $stackPtr; $variableCount = 0; while (($nextVar = $phpcsFile->findNext(T_VARIABLE, ($nextVar + 1), $statementEnd)) !== false) { $previousVariable = $nextVar; diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc index 352adadc15..985e7c36ab 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc @@ -43,3 +43,6 @@ $id = $obj?->i++*10; $var+=1; $var-=1; + +$var=$var+1; +$var=$var-1; diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php index fe41c280c7..921f8f9b1f 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php @@ -44,6 +44,8 @@ public function getErrorList() 42 => 1, 44 => 1, 45 => 1, + 47 => 1, + 48 => 1, ]; }//end getErrorList() From b0c442a57ec5d661e487c094af00195e7a383c6a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 7 Feb 2024 13:03:55 +0100 Subject: [PATCH 401/874] Squiz/IncrementDecrementUsage: bug fix - comments between variable and equal sign As this is a sniff looking for certain functional code patterns, the sniff should disregard whitespace and comments when looking for the relevant tokens to determine whether the code under scan contains the code pattern the sniff is looking for. The sniff, however, does not do this correctly (in multiple places). This commit fixes another one of these issues. In this case, if there was a comment between the `$var` and the subsequent equal sign, the sniff would incorrectly disregard the assignment as one which should be examined. Fixed now. Includes tests. --- .../Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php | 2 +- .../Tests/Operators/IncrementDecrementUsageUnitTest.inc | 5 +++++ .../Tests/Operators/IncrementDecrementUsageUnitTest.php | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php index 7fa4c28428..515d1cd25a 100644 --- a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php @@ -120,7 +120,7 @@ protected function processAssignment($phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $assignedVar = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + $assignedVar = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); // Not an assignment, return. if ($tokens[$assignedVar]['code'] !== T_VARIABLE) { return; diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc index 985e7c36ab..629fc8bc98 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc @@ -46,3 +46,8 @@ $var-=1; $var=$var+1; $var=$var-1; + +$var /*comment*/ +=1; +$var + // phpcs:ignore Something + -=1; diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php index 921f8f9b1f..f34b00841d 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php @@ -46,6 +46,8 @@ public function getErrorList() 45 => 1, 47 => 1, 48 => 1, + 50 => 1, + 53 => 1, ]; }//end getErrorList() From 1643fb65e19ea7f7d3171c4434efa51d01b17936 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 7 Feb 2024 13:09:46 +0100 Subject: [PATCH 402/874] Squiz/IncrementDecrementUsage: bug fix - comments in value being assigned As this is a sniff looking for certain functional code patterns, the sniff should disregard whitespace and comments when looking for the relevant tokens to determine whether the code under scan contains the code pattern the sniff is looking for. The sniff, however, does not do this correctly (in multiple places). This commit fixes one more of these issues. In this case, if there was a comment anywhere in the value being assigned, the sniff would incorrectly disregard the assignment as one which should be examined. Fixed now. Includes tests. --- .../Sniffs/Operators/IncrementDecrementUsageSniff.php | 10 ++++++++-- .../Operators/IncrementDecrementUsageUnitTest.inc | 3 +++ .../Operators/IncrementDecrementUsageUnitTest.php | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php index 515d1cd25a..a39e44e123 100644 --- a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php @@ -129,8 +129,14 @@ protected function processAssignment($phpcsFile, $stackPtr) $statementEnd = $phpcsFile->findNext([T_SEMICOLON, T_CLOSE_PARENTHESIS, T_CLOSE_SQUARE_BRACKET, T_CLOSE_CURLY_BRACKET], $stackPtr); // If there is anything other than variables, numbers, spaces or operators we need to return. - $noiseTokens = $phpcsFile->findNext([T_LNUMBER, T_VARIABLE, T_WHITESPACE, T_PLUS, T_MINUS, T_OPEN_PARENTHESIS], ($stackPtr + 1), $statementEnd, true); - + $find = Tokens::$emptyTokens; + $find[] = T_LNUMBER; + $find[] = T_VARIABLE; + $find[] = T_PLUS; + $find[] = T_MINUS; + $find[] = T_OPEN_PARENTHESIS; + + $noiseTokens = $phpcsFile->findNext($find, ($stackPtr + 1), $statementEnd, true); if ($noiseTokens !== false) { return; } diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc index 629fc8bc98..266695970e 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.inc @@ -51,3 +51,6 @@ $var /*comment*/ +=1; $var // phpcs:ignore Something -=1; + +$var += /*comment*/ 1; +$var = ( $var /*comment*/ - 1 /*comment*/); diff --git a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php index f34b00841d..e27e196b13 100644 --- a/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/IncrementDecrementUsageUnitTest.php @@ -48,6 +48,8 @@ public function getErrorList() 48 => 1, 50 => 1, 53 => 1, + 55 => 1, + 56 => 1, ]; }//end getErrorList() From 9d014368f2bed2d71472a87492ec772591e4a125 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Thu, 8 Feb 2024 12:44:21 +0000 Subject: [PATCH 403/874] PSR2/UseDeclaration - refine testcase While this test-case was always intended to be a parse error, it wasn't intended to be _that_ parse error. The initial intention was that this particular case (unfinished group) not be fixable. That was the case when the code was initially written, but a later change enabled the auto-fixer and broke this. I have opened to track the incorrect fixer changes being applied in the other parse error case. --- .../PSR2/Tests/Namespaces/UseDeclarationUnitTest.17.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.17.inc b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.17.inc index f0f664ad78..5bc9618d87 100644 --- a/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.17.inc +++ b/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.17.inc @@ -1,3 +1,3 @@ Date: Thu, 8 Feb 2024 13:20:38 +0000 Subject: [PATCH 404/874] PSR12/DeclareStatement - rename test files --- ...est.inc => DeclareStatementUnitTest.1.inc} | 0 ...d => DeclareStatementUnitTest.1.inc.fixed} | 0 .../Tests/Files/DeclareStatementUnitTest.php | 59 +++++++++++-------- 3 files changed, 33 insertions(+), 26 deletions(-) rename src/Standards/PSR12/Tests/Files/{DeclareStatementUnitTest.inc => DeclareStatementUnitTest.1.inc} (100%) rename src/Standards/PSR12/Tests/Files/{DeclareStatementUnitTest.inc.fixed => DeclareStatementUnitTest.1.inc.fixed} (100%) diff --git a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.inc b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.1.inc similarity index 100% rename from src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.inc rename to src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.1.inc diff --git a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.inc.fixed b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.1.inc.fixed similarity index 100% rename from src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.inc.fixed rename to src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.1.inc.fixed diff --git a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php index 3fbf8760f0..84d31447d1 100644 --- a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php +++ b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.php @@ -26,35 +26,42 @@ final class DeclareStatementUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 2 => 1, - 3 => 1, - 4 => 1, - 5 => 2, - 6 => 1, - 7 => 1, - 9 => 2, - 10 => 1, - 11 => 3, - 12 => 2, - 13 => 1, - 14 => 2, - 16 => 3, - 19 => 3, - 22 => 1, - 24 => 1, - 26 => 3, - 28 => 3, - 34 => 2, - 43 => 1, - 46 => 1, - 47 => 1, - 49 => 1, - ]; + switch ($testFile) { + case 'DeclareStatementUnitTest.1.inc': + return [ + 2 => 1, + 3 => 1, + 4 => 1, + 5 => 2, + 6 => 1, + 7 => 1, + 9 => 2, + 10 => 1, + 11 => 3, + 12 => 2, + 13 => 1, + 14 => 2, + 16 => 3, + 19 => 3, + 22 => 1, + 24 => 1, + 26 => 3, + 28 => 3, + 34 => 2, + 43 => 1, + 46 => 1, + 47 => 1, + 49 => 1, + ]; + default: + return []; + }//end switch }//end getErrorList() From 7f5c88a3742fae2fb1f6217fe34b44b8410988d4 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Thu, 8 Feb 2024 13:21:36 +0000 Subject: [PATCH 405/874] PSR12/DeclareStatement - handle parse error --- src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php | 6 ++++++ .../PSR12/Tests/Files/DeclareStatementUnitTest.2.inc | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.2.inc diff --git a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php index b59d6c5cdb..d9615f9a4e 100644 --- a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php @@ -110,6 +110,12 @@ public function process(File $phpcsFile, $stackPtr) // There should be no space between equal sign and directive value. $value = $phpcsFile->findNext(T_WHITESPACE, ($equals + 1), null, true); + + if ($value === false) { + // Live coding / parse error. + return; + } + if ($equals !== false) { if ($tokens[($equals + 1)]['type'] !== 'T_LNUMBER') { $error = 'Expected no space between equal sign and the directive value in a declare statement'; diff --git a/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.2.inc b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.2.inc new file mode 100644 index 0000000000..01c3a016db --- /dev/null +++ b/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.2.inc @@ -0,0 +1,3 @@ + Date: Fri, 9 Feb 2024 01:08:30 +0000 Subject: [PATCH 406/874] Test-suite - Show warning when ".fixed" file not found (#336) This commit updates the `AbstractSniffUnitTest` class used for the sniff tests to show a non-build-failing warning when a test case file would lead to fixable errors/warnings, but there is no `.fixed` version available for the test case file to verify the fixes being made. This is a preliminary step towards making missing `.fixed` files a test failing error in PHPCS 4.0. Note: the warning will only show when tests are being run on PHPUnit 7.3.0 or higher. --- tests/Standards/AbstractSniffUnitTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Standards/AbstractSniffUnitTest.php b/tests/Standards/AbstractSniffUnitTest.php index b57c2ac659..c400758468 100644 --- a/tests/Standards/AbstractSniffUnitTest.php +++ b/tests/Standards/AbstractSniffUnitTest.php @@ -190,15 +190,17 @@ final public function testSniff() // Check for a .fixed file to check for accuracy of fixes. $fixedFile = $testFile.'.fixed'; + $filename = basename($testFile); if (file_exists($fixedFile) === true) { $diff = $phpcsFile->fixer->generateDiff($fixedFile); if (trim($diff) !== '') { - $filename = basename($testFile); $fixedFilename = basename($fixedFile); $failureMessages[] = "Fixed version of $filename does not match expected version in $fixedFilename; the diff is\n$diff"; } + } else if (is_callable([$this, 'addWarning']) === true) { + $this->addWarning("Missing fixed version of $filename to verify the accuracy of fixes, while the sniff is making fixes against the test case file"); } - } + }//end if // Restore the config. $config->setSettings($oldConfig); From 35abfb046fa6e0a707e506964e30df80fb53da83 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 4 Aug 2023 19:35:59 +0200 Subject: [PATCH 407/874] PHP 8.3 | Generic/LowerCaseConstant: add support for typed constants Type declarations are explicitly not checked by this sniff. PHP 8.3 introduces typed constants. This means that the sniff now also needs to ensure that it doesn't flag non-lowercase `true`/`false`/`null` in the type declaration for a constant. Fixed now. Includes tests. --- .../Sniffs/PHP/LowerCaseConstantSniff.php | 16 ++++++++++++++++ .../Tests/PHP/LowerCaseConstantUnitTest.inc | 8 ++++++++ .../PHP/LowerCaseConstantUnitTest.inc.fixed | 8 ++++++++ .../Tests/PHP/LowerCaseConstantUnitTest.php | 2 ++ 4 files changed, 34 insertions(+) diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php index cae35eeb41..4447f46304 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php @@ -81,6 +81,9 @@ public function register() $targets[] = T_CLOSURE; $targets[] = T_FN; + // Register constant keyword to filter out type declarations. + $targets[] = T_CONST; + return $targets; }//end register() @@ -101,6 +104,19 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); + // Skip over potential type declarations for constants. + if ($tokens[$stackPtr]['code'] === T_CONST) { + // Constant must always have a value assigned to it, so we can just look for the assignment + // operator. Anything between the const keyword and the assignment can be safely ignored. + $skipTo = $phpcsFile->findNext(T_EQUAL, ($stackPtr + 1)); + if ($skipTo !== false) { + return $skipTo; + } + + // If we're at the end of the file, just return. + return; + } + /* * Skip over type declarations for properties. * diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc index 5dfb75560a..07e54e2581 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc @@ -144,6 +144,14 @@ readonly class Properties { } } +// PHP 8.3 introduces typed constants. +class TypedConstants { + const MyClass|NULL|TRUE|FALSE MYCONST = FALSE; +} + +// Global constants can not be typed. +const MYCONST = TRUE; + // Last coding/parse error. // This has to be the last test in the file. function UnclosedCurly (): FALSE { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed index 6b999cc456..723a7221e5 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.inc.fixed @@ -144,6 +144,14 @@ readonly class Properties { } } +// PHP 8.3 introduces typed constants. +class TypedConstants { + const MyClass|NULL|TRUE|FALSE MYCONST = false; +} + +// Global constants can not be typed. +const MYCONST = true; + // Last coding/parse error. // This has to be the last test in the file. function UnclosedCurly (): FALSE { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php index 0d1ea8b2ab..f156263348 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php @@ -64,6 +64,8 @@ public function getErrorList($testFile='') 121 => 1, 125 => 1, 129 => 1, + 149 => 1, + 153 => 1, ]; case 'LowerCaseConstantUnitTest.js': From b265092abb9fe229ebc5eb9e950644abfd2d62c0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Jan 2024 07:05:58 +0100 Subject: [PATCH 408/874] PHP 8.3 | Generic/LowerCaseType: add support for typed constants This sniff is specifically targeted at type declarations. PHP 8.3 introduces typed constants. This means that the sniff now also needs to check OO constant declarations. Fixed now. Includes tests. --- .../Generic/Sniffs/PHP/LowerCaseTypeSniff.php | 68 +++++++++++- .../Tests/PHP/LowerCaseTypeUnitTest.inc | 30 ++++++ .../Tests/PHP/LowerCaseTypeUnitTest.inc.fixed | 30 ++++++ .../Tests/PHP/LowerCaseTypeUnitTest.php | 100 ++++++++++-------- 4 files changed, 181 insertions(+), 47 deletions(-) diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php index 74103c805c..7fb3b85840 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php @@ -87,7 +87,7 @@ public function process(File $phpcsFile, $stackPtr) } /* - * Check property types. + * Check OO constant and property types. */ if (isset(Tokens::$ooScopeTokens[$tokens[$stackPtr]['code']]) === true) { @@ -97,7 +97,7 @@ public function process(File $phpcsFile, $stackPtr) for ($i = ($tokens[$stackPtr]['scope_opener'] + 1); $i < $tokens[$stackPtr]['scope_closer']; $i++) { // Skip over potentially large docblocks. - if ($tokens[$i]['code'] === \T_DOC_COMMENT_OPEN_TAG + if ($tokens[$i]['code'] === T_DOC_COMMENT_OPEN_TAG && isset($tokens[$i]['comment_closer']) === true ) { $i = $tokens[$i]['comment_closer']; @@ -105,14 +105,74 @@ public function process(File $phpcsFile, $stackPtr) } // Skip over function declarations and everything nested within. - if ($tokens[$i]['code'] === \T_FUNCTION + if ($tokens[$i]['code'] === T_FUNCTION && isset($tokens[$i]['scope_closer']) === true ) { $i = $tokens[$i]['scope_closer']; continue; } - if ($tokens[$i]['code'] !== \T_VARIABLE) { + if ($tokens[$i]['code'] === T_CONST) { + $ignore = Tokens::$emptyTokens; + $ignore[T_NULLABLE] = T_NULLABLE; + + $startOfType = $phpcsFile->findNext($ignore, ($i + 1), null, true); + if ($startOfType === false) { + // Parse error/live coding. Nothing to do. Rest of loop is moot. + return; + } + + $assignmentOperator = $phpcsFile->findNext([T_EQUAL, T_SEMICOLON], ($startOfType + 1)); + if ($assignmentOperator === false || $tokens[$assignmentOperator]['code'] !== T_EQUAL) { + // Parse error/live coding. Nothing to do. Rest of loop is moot. + return; + } + + $constName = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($assignmentOperator - 1), null, true); + if ($startOfType !== $constName) { + $endOfType = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($constName - 1), null, true); + + $type = ''; + $isUnionType = false; + $isIntersectionType = false; + for ($j = $startOfType; $j <= $endOfType; $j++) { + if (isset($ignore[$tokens[$j]['code']]) === true) { + continue; + } + + if ($tokens[$j]['code'] === T_TYPE_UNION) { + $isUnionType = true; + } + + if ($tokens[$j]['code'] === T_TYPE_INTERSECTION) { + $isIntersectionType = true; + } + + $type .= $tokens[$j]['content']; + } + + $error = 'PHP constant type declarations must be lowercase; expected "%s" but found "%s"'; + $errorCode = 'ConstantTypeFound'; + + if ($isIntersectionType === true) { + // Intersection types don't support simple types. + } else if ($isUnionType === true) { + $this->processUnionType( + $phpcsFile, + $startOfType, + $endOfType, + $error, + $errorCode + ); + } else if (isset($this->phpTypes[strtolower($type)]) === true) { + $this->processType($phpcsFile, $startOfType, $type, $error, $errorCode); + } + }//end if + + continue; + }//end if + + if ($tokens[$i]['code'] !== T_VARIABLE) { continue; } diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc index 56393c0b24..6674970e10 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc @@ -95,6 +95,36 @@ $arrow = fn (Int $a, String $b, BOOL $c, Array $d, Foo\Bar $e) : Float => $a * $ $cl = function (False $a, TRUE $b, Null $c): ?True {}; +class TypedClassConstants +{ + const UNTYPED = null; + const FLOAT = 'Reserved keyword as name is valid and should not be changed'; + const OBJECT = 'Reserved keyword as name is valid and should not be changed'; + + const ClassName FIRST = null; + public const Int SECOND = 0; + private const ?BOOL THIRD = false; + public const Self FOURTH = null; +} +interface TypedInterfaceConstants +{ + protected const PaRenT FIRST = null; + private const ARRAY SECOND = []; + public const Float THIRD = 2.5; + final const ?STRING FOURTH = 'fourth'; +} +trait TypedTraitConstants { + const IterablE FIRST = null; + const Object SECOND = null; + const Mixed THIRD = 'third'; +} +enum TypedEnumConstants { + public const Iterable|FALSE|NULL FIRST = null; + protected const SELF|Parent /* comment */ |\Fully\Qualified\ClassName|UnQualifiedClass SECOND = null; + private const ClassName|/*comment*/Float|STRING|False THIRD = 'third'; + public const sTRing | aRRaY | FaLSe FOURTH = 'fourth'; +} + // Intentional error, should be ignored by the sniff. interface PropertiesNotAllowed { public $notAllowed; diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed index c1055c726b..59e4af8352 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed @@ -95,6 +95,36 @@ $arrow = fn (int $a, string $b, bool $c, array $d, Foo\Bar $e) : float => $a * $ $cl = function (false $a, true $b, null $c): ?true {}; +class TypedClassConstants +{ + const UNTYPED = null; + const FLOAT = 'Reserved keyword as name is valid and should not be changed'; + const OBJECT = 'Reserved keyword as name is valid and should not be changed'; + + const ClassName FIRST = null; + public const int SECOND = 0; + private const ?bool THIRD = false; + public const self FOURTH = null; +} +interface TypedInterfaceConstants +{ + protected const parent FIRST = null; + private const array SECOND = []; + public const float THIRD = 2.5; + final const ?string FOURTH = 'fourth'; +} +trait TypedTraitConstants { + const iterable FIRST = null; + const object SECOND = null; + const mixed THIRD = 'third'; +} +enum TypedEnumConstants { + public const iterable|false|null FIRST = null; + protected const self|parent /* comment */ |\Fully\Qualified\ClassName|UnQualifiedClass SECOND = null; + private const ClassName|/*comment*/float|string|false THIRD = 'third'; + public const string | array | false FOURTH = 'fourth'; +} + // Intentional error, should be ignored by the sniff. interface PropertiesNotAllowed { public $notAllowed; diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php index 0eaf7f5319..c5cfbb18aa 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php @@ -31,48 +31,62 @@ final class LowerCaseTypeUnitTest extends AbstractSniffUnitTest public function getErrorList() { return [ - 14 => 1, - 15 => 1, - 16 => 1, - 17 => 1, - 18 => 1, - 21 => 4, - 22 => 3, - 23 => 3, - 25 => 1, - 26 => 2, - 27 => 2, - 32 => 4, - 36 => 1, - 37 => 1, - 38 => 1, - 39 => 1, - 43 => 2, - 44 => 1, - 46 => 1, - 49 => 1, - 51 => 2, - 53 => 1, - 55 => 2, - 60 => 1, - 61 => 1, - 62 => 1, - 63 => 1, - 64 => 1, - 65 => 1, - 66 => 1, - 67 => 1, - 68 => 1, - 69 => 1, - 71 => 3, - 72 => 2, - 73 => 3, - 74 => 3, - 78 => 3, - 82 => 2, - 85 => 1, - 94 => 5, - 96 => 4, + 14 => 1, + 15 => 1, + 16 => 1, + 17 => 1, + 18 => 1, + 21 => 4, + 22 => 3, + 23 => 3, + 25 => 1, + 26 => 2, + 27 => 2, + 32 => 4, + 36 => 1, + 37 => 1, + 38 => 1, + 39 => 1, + 43 => 2, + 44 => 1, + 46 => 1, + 49 => 1, + 51 => 2, + 53 => 1, + 55 => 2, + 60 => 1, + 61 => 1, + 62 => 1, + 63 => 1, + 64 => 1, + 65 => 1, + 66 => 1, + 67 => 1, + 68 => 1, + 69 => 1, + 71 => 3, + 72 => 2, + 73 => 3, + 74 => 3, + 78 => 3, + 82 => 2, + 85 => 1, + 94 => 5, + 96 => 4, + 105 => 1, + 106 => 1, + 107 => 1, + 111 => 1, + 112 => 1, + 113 => 1, + 114 => 1, + 117 => 1, + 118 => 1, + 119 => 1, + 122 => 3, + 123 => 2, + 124 => 3, + 125 => 3, ]; }//end getErrorList() @@ -89,7 +103,7 @@ public function getErrorList() public function getWarningList() { // Warning from getMemberProperties() about parse error. - return [100 => 1]; + return [130 => 1]; }//end getWarningList() From 45bf3ad5dcbd2b0df8cb7bffb1afe9cb1ec0e331 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Jan 2024 07:21:10 +0100 Subject: [PATCH 409/874] PHP 8.3 | Generic/UpperCaseConstantName: add support for typed constants This sniff is specifically targeted at constant names. PHP 8.3 introduces typed constants. This means that the sniff now needs to jump over a potentially declared constant type to get at the constant name. Fixed now. Includes tests. Fixes squizlabs/PHP_CodeSniffer 3927 Closes squizlabs/PHP_CodeSniffer 3936 --- .../NamingConventions/UpperCaseConstantNameSniff.php | 12 ++++++++++-- .../UpperCaseConstantNameUnitTest.inc | 10 ++++++++++ .../UpperCaseConstantNameUnitTest.php | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index 1373d3b0e3..f62cfe94bd 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -46,8 +46,16 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); if ($tokens[$stackPtr]['code'] === T_CONST) { - // This is a class constant. - $constant = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); + // This is a constant declared with the "const" keyword. + // This may be an OO constant, in which case it could be typed, so we need to + // jump over a potential type to get to the name. + $assignmentOperator = $phpcsFile->findNext([T_EQUAL, T_SEMICOLON], ($stackPtr + 1)); + if ($assignmentOperator === false || $tokens[$assignmentOperator]['code'] !== T_EQUAL) { + // Parse error/live coding. Nothing to do. Rest of loop is moot. + return; + } + + $constant = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($assignmentOperator - 1), ($stackPtr + 1), true); if ($constant === false) { return; } diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc index 6bf96f251c..20bbf90e26 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc @@ -31,3 +31,13 @@ class ClassConstBowOutTest { } $foo->getBar()?->define('foo'); + +// PHP 8.3 introduces typed constants. +class TypedConstants { + const MISSING_VALUE; // Parse error. + const MyClass MYCONST = new MyClass; + const int VALID_NAME = 0; + const INT invalid_name = 0; + const FALSE false = false; // Yes, false can be used as a constant name, don't ask. + const array ARRAY = array(); // Same goes for array. +} diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php index 907d8bb5be..afe3625589 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php @@ -38,6 +38,8 @@ public function getErrorList() 19 => 1, 28 => 1, 30 => 1, + 40 => 1, + 41 => 1, ]; }//end getErrorList() From 5730352ba2ddaf6a8797f2db89edbedb2e192efc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Jan 2024 10:00:02 +0100 Subject: [PATCH 410/874] Tests: minor docs fixes * Fix class description. * Improve type specificity in docblocks. --- tests/Core/Config/ReportWidthTest.php | 2 +- tests/Core/Filters/AbstractFilterTestCase.php | 2 +- tests/Core/Tokenizer/DoubleArrowTest.php | 6 +++--- tests/Core/Tokenizer/ShortArrayTest.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Core/Config/ReportWidthTest.php b/tests/Core/Config/ReportWidthTest.php index 3b3881ce01..2e67fa2691 100644 --- a/tests/Core/Config/ReportWidthTest.php +++ b/tests/Core/Config/ReportWidthTest.php @@ -265,7 +265,7 @@ public function testReportWidthInputHandling($input, $expected) /** * Data provider. * - * @return array + * @return array> */ public static function dataReportWidthInputHandling() { diff --git a/tests/Core/Filters/AbstractFilterTestCase.php b/tests/Core/Filters/AbstractFilterTestCase.php index 9091d1998e..e2caebc54b 100644 --- a/tests/Core/Filters/AbstractFilterTestCase.php +++ b/tests/Core/Filters/AbstractFilterTestCase.php @@ -1,6 +1,6 @@ * @copyright 2023 PHPCSStandards Contributors diff --git a/tests/Core/Tokenizer/DoubleArrowTest.php b/tests/Core/Tokenizer/DoubleArrowTest.php index 4b2ebef66f..768ff65d74 100644 --- a/tests/Core/Tokenizer/DoubleArrowTest.php +++ b/tests/Core/Tokenizer/DoubleArrowTest.php @@ -43,7 +43,7 @@ public function testDoubleArrow($testMarker) * * @see testDoubleArrow() * - * @return array + * @return array> */ public static function dataDoubleArrow() { @@ -128,7 +128,7 @@ public function testMatchArrow($testMarker) * * @see testMatchArrow() * - * @return array + * @return array> */ public static function dataMatchArrow() { @@ -215,7 +215,7 @@ public function testFnArrow($testMarker) * * @see testFnArrow() * - * @return array + * @return array> */ public static function dataFnArrow() { diff --git a/tests/Core/Tokenizer/ShortArrayTest.php b/tests/Core/Tokenizer/ShortArrayTest.php index 235a6e86ce..189523863e 100644 --- a/tests/Core/Tokenizer/ShortArrayTest.php +++ b/tests/Core/Tokenizer/ShortArrayTest.php @@ -48,7 +48,7 @@ public function testSquareBrackets($testMarker) * * @see testSquareBrackets() * - * @return array + * @return array> */ public static function dataSquareBrackets() { @@ -116,7 +116,7 @@ public function testShortArrays($testMarker) * * @see testShortArrays() * - * @return array + * @return array> */ public static function dataShortArrays() { From 63dc421a30b13bf53e5ab45e9c7470c71bbabe97 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 26 Jan 2024 15:37:01 +0100 Subject: [PATCH 411/874] CONTRIBUTING: fix typo --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index bf0a72d5e3..17d9c9b2f9 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -318,7 +318,7 @@ While not strictly required, it is greatly appreciated if you comply with the fo * Being wordy in the commit message is not a bad thing. It is greatly preferable to have the details about a fix in the commit message over just having those details in the PR description. - Code hosting platforms comes and go (think: SourceForge, PEAR), commit messages are here to stay, even if the code base + Code hosting platforms come and go (think: SourceForge, PEAR), commit messages are here to stay, even if the code base would move to another platform at some point in the future. * Ensure that the tests (and docs) related to a particular fix are in the same commit. It is much harder to track down what a particular code snippet in a test case file was supposed to be testing if the fix From 21219d15705314fdce6943509c9a3760bad2060e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 26 Jan 2024 15:48:49 +0100 Subject: [PATCH 412/874] README: minor tweak --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 383fed2ac3..d375015b43 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ PHP_CodeSniffer
> [!NOTE] -> This package is the continuation of the now abandoned [PHP_CodeSniffer package which was created by Squizlabs](https://github.com/squizlabs/PHP_CodeSniffer). +> This package is the official continuation of the now abandoned [PHP_CodeSniffer package which was created by Squizlabs](https://github.com/squizlabs/PHP_CodeSniffer). ## About From 8e92de68e896ceb10f0fd592d6997b43756fd382 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 19 Jan 2024 04:07:51 +0100 Subject: [PATCH 413/874] Changelog: various tweaks * Add missing contributor link Follow up on 243, just noticed I missed one which could be a link. * Minor syntax fix. Follow up on original import. --- CHANGELOG.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 049117693f..b2fb80ad0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -449,7 +449,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 for the patch + - 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 @@ -649,9 +649,9 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Spaces are now correctly escaped in the paths to external on Windows - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.CodeAnalysis.UnusedFunctionParameter can now be configured to ignore variable usage for specific type hints - -- This allows you to suppress warnings for some variables that are not required, but leave warnings for others - -- Set the ignoreTypeHints array property to a list of type hints to ignore - -- Thanks to [Petr Bugyík][@o5] for the patch + - This allows you to suppress warnings for some variables that are not required, but leave warnings for others + - Set the ignoreTypeHints array property to a list of type hints to ignore + - Thanks to [Petr Bugyík][@o5] for the patch - Generic.Formatting.MultipleStatementAlignment can now align statements at the start of the assignment token - Previously, the sniff enforced that the values were aligned, even if this meant the assignment tokens were not - Now, the sniff can enforce that the assignment tokens are aligned, even if this means the values are not @@ -5611,6 +5611,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@andrei-propertyguru]: https://github.com/andrei-propertyguru [@AndrewDawes]: https://github.com/AndrewDawes [@andygrunwald]: https://github.com/andygrunwald +[@andypost]: https://github.com/andypost [@annechko]: https://github.com/annechko [@anomiex]: https://github.com/anomiex [@arnested]: https://github.com/arnested From 479b4dc593bf07028df528e3d173130f68578929 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 16 Jan 2024 05:15:34 +0100 Subject: [PATCH 414/874] CS: various minor fixes ... for things which have sneaked in. --- .../Tests/WhiteSpace/DisallowTabIndentUnitTest.php | 2 +- .../PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php | 2 +- src/Tokenizers/PHP.php | 2 +- tests/Core/AbstractMethodUnitTest.php | 1 - tests/Core/File/GetClassPropertiesTest.php | 8 ++++---- tests/Core/Filters/AbstractFilterTestCase.php | 2 +- tests/Core/Filters/Filter/AcceptTest.php | 1 - 9 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php index 94b833d657..7a5f15e9f5 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php @@ -103,7 +103,7 @@ public function getErrorList($testFile='') ]; case 'DisallowTabIndentUnitTest.3.inc': - if (\PHP_VERSION_ID >= 70300) { + if (PHP_VERSION_ID >= 70300) { return [ 7 => 1, 13 => 1, diff --git a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php index d4792f5e30..552bfea46a 100644 --- a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php @@ -98,7 +98,7 @@ public function process(File $phpcsFile, $stackPtr) $indent = str_repeat(' ', ($tokens[$first]['column'] - 1)); $phpcsFile->fixer->beginChangeset(); - if ($tokens[($prev + 1)]['code'] === \T_WHITESPACE) { + if ($tokens[($prev + 1)]['code'] === T_WHITESPACE) { $phpcsFile->fixer->replaceToken(($prev + 1), ''); } diff --git a/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php index 5ec0d470be..1bc369a2a0 100644 --- a/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php @@ -56,7 +56,7 @@ public function process(File $phpcsFile, $stackPtr) break; } - if (\array_key_exists($condition, Tokens::$ooScopeTokens) === true) { + if (array_key_exists($condition, Tokens::$ooScopeTokens) === true) { // Ignore methods in OOP structures defined within functions. return; } diff --git a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index a5db965b66..4c0d6bcb7e 100644 --- a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -275,7 +275,7 @@ public function process(File $phpcsFile, $stackPtr) } // Skip HTML whitespace. - if ($tokens[$i]['code'] === T_INLINE_HTML && \trim($tokens[$i]['content']) === '') { + if ($tokens[$i]['code'] === T_INLINE_HTML && trim($tokens[$i]['content']) === '') { continue; } diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 31cc0237a2..4be5400a05 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -3106,7 +3106,7 @@ protected function processAdditional() } if ($suspectedType === 'property or parameter') { - unset($allowed[\T_STATIC]); + unset($allowed[T_STATIC]); } $typeTokenCount = 0; diff --git a/tests/Core/AbstractMethodUnitTest.php b/tests/Core/AbstractMethodUnitTest.php index 9f7cefec17..b8522bf4bb 100644 --- a/tests/Core/AbstractMethodUnitTest.php +++ b/tests/Core/AbstractMethodUnitTest.php @@ -14,7 +14,6 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; -use ReflectionProperty; abstract class AbstractMethodUnitTest extends TestCase { diff --git a/tests/Core/File/GetClassPropertiesTest.php b/tests/Core/File/GetClassPropertiesTest.php index 1bebc5893f..4841b50b6b 100644 --- a/tests/Core/File/GetClassPropertiesTest.php +++ b/tests/Core/File/GetClassPropertiesTest.php @@ -52,15 +52,15 @@ public static function dataNotAClassException() return [ 'interface' => [ 'testMarker' => '/* testNotAClass */', - 'tokenType' => \T_INTERFACE, + 'tokenType' => T_INTERFACE, ], 'anon-class' => [ 'testMarker' => '/* testAnonClass */', - 'tokenType' => \T_ANON_CLASS, + 'tokenType' => T_ANON_CLASS, ], 'enum' => [ 'testMarker' => '/* testEnum */', - 'tokenType' => \T_ENUM, + 'tokenType' => T_ENUM, ], ]; @@ -79,7 +79,7 @@ public static function dataNotAClassException() */ public function testGetClassProperties($testMarker, $expected) { - $class = $this->getTargetToken($testMarker, \T_CLASS); + $class = $this->getTargetToken($testMarker, T_CLASS); $result = self::$phpcsFile->getClassProperties($class); $this->assertSame($expected, $result); diff --git a/tests/Core/Filters/AbstractFilterTestCase.php b/tests/Core/Filters/AbstractFilterTestCase.php index 9091d1998e..762814e359 100644 --- a/tests/Core/Filters/AbstractFilterTestCase.php +++ b/tests/Core/Filters/AbstractFilterTestCase.php @@ -73,7 +73,7 @@ protected function getMockedClass($className, array $constructorArgs=[], $method { $mockedObj = $this->getMockBuilder($className); - if (\method_exists($mockedObj, 'onlyMethods') === true) { + if (method_exists($mockedObj, 'onlyMethods') === true) { // PHPUnit 8+. if (is_array($methodsToMock) === true) { return $mockedObj diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index 64765f3af0..8d622061df 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -10,7 +10,6 @@ namespace PHP_CodeSniffer\Tests\Core\Filters\Filter; -use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Filters\Filter; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\ConfigDouble; From 392b2b5f0e2a3a88f18fd619258c9f5fea527875 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Thu, 15 Feb 2024 14:38:15 +0000 Subject: [PATCH 415/874] Add auto-generated ".fixed" file --- ...losingDeclarationCommentUnitTest.inc.fixed | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed diff --git a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed new file mode 100644 index 0000000000..3288305c50 --- /dev/null +++ b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed @@ -0,0 +1,89 @@ + Date: Thu, 15 Feb 2024 14:49:49 +0000 Subject: [PATCH 416/874] Avoid adding extra newlines when adding a comment --- .../Sniffs/Commenting/ClosingDeclarationCommentSniff.php | 2 +- .../Commenting/ClosingDeclarationCommentUnitTest.inc.fixed | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php index 45bcdbdef6..afc7ac071a 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php @@ -110,7 +110,7 @@ public function process(File $phpcsFile, $stackPtr) } else { $fix = $phpcsFile->addFixableError('Expected %s', $closingBracket, 'Missing', $data); if ($fix === true) { - $phpcsFile->fixer->replaceToken($closingBracket, '}'.$comment.$phpcsFile->eolChar); + $phpcsFile->fixer->replaceToken($closingBracket, '}'.$comment); } } diff --git a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed index 3288305c50..4515c41a4b 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed @@ -58,17 +58,14 @@ class TestClass { }//end class - abstract class TestClass { }//end class - interface TestClass { }//end interface - class MyClass { public function myFunction(); @@ -84,6 +81,5 @@ class TestClass enum MissingClosingComment { }//end enum - enum HasClosingComment { }//end enum From 4a9addc9bb0f29d4fc9357e0be126a7265a53d77 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Jan 2024 23:08:14 +0100 Subject: [PATCH 417/874] Changelog for the 3.9.0 release --- CHANGELOG.md | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2fb80ad0e..511c8eff78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,123 @@ The file documents changes to the PHP_CodeSniffer project. _Nothing yet._ +## [3.9.0] - 2024-02-16 + +### 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][@jrfnl] 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][@jrfnl] 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][@jrfnl] 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][@TimWolla] 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][@jrfnl] 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][@dingo-d] and [Rodrigo Primo][@rodrigoprimo] for the patches + +### Changed +- The Performance report can now also be used for a `phpcbf` run. [#308] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- 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][@fredden] for the patch +- The following sniffs have received performance related improvements: + - Squiz.PHP.EmbeddedPhp + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Various housekeeping, including improvements to the tests and documentation + - Thanks to [Dan Wallis][@fredden], [Joachim Noreiko][@joachim-n], [Remi Collet][@remicollet], [Rodrigo Primo][@rodrigoprimo] and [Juliette Reinders Folmer][@jrfnl] for their contributions + +### 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][@jrfnl] 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]. + - This sniff will be removed in version 4.0.0. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch + +### 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. + - Thanks to [Dan Wallis][@fredden] for the patch +- Fixed bug [#196] : Squiz.PHP.EmbeddedPhp : fixer will no longer leave behind trailing whitespace when moving code to another line. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#196] : Squiz.PHP.EmbeddedPhp : will now determine the needed indent with higher precision in multiple situations. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- 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. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#235] : Generic.CodeAnalysis.ForLoopWithTestFunctionCall : prevent a potential PHP 8.3 deprecation notice during live coding + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch +- Fixed bug [#288] : Generic.WhiteSpace.IncrementDecrementSpacing : error message for post-in/decrement will now correctly inform about new lines found before the operator. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch +- Fixed bug [#296] : Generic.WhiteSpace.ArbitraryParenthesesSpacing : false positive for non-arbitrary parentheses when these follow the scope closer of a `switch` `case`. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- 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. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#325] : Squiz.Operators.IncrementDecrementUsage : the sniff was underreporting when there was (no) whitespace and/or comments in unexpected places. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#335] : PSR12.Files.DeclareStatement : bow out in a certain parse error situation to prevent incorrect auto-fixes from being made. + - Thanks to [Dan Wallis][@fredden] for the patch +- Fixed bug [#340] : Squiz.Commenting.ClosingDeclarationComment : no longer adds a stray newline when adding a missing comment. + - Thanks to [Dan Wallis][@fredden] for the patch + +### 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. + +[#2448]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2448 +[#2471]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2471 +[#27]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/27 +[#127]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/127 +[#196]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/196 +[#197]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/197 +[#198]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/198 +[#227]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/227 +[#235]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/235 +[#277]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/277 +[#281]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/281 +[#288]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/288 +[#296]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/296 +[#307]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/307 +[#308]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/308 +[#309]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/309 +[#321]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/321 +[#324]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/324 +[#325]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/325 +[#330]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/330 +[#331]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/331 +[#332]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/332 +[#335]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/335 +[#336]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/336 +[#340]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/340 ## [3.8.1] - 2024-01-11 @@ -52,7 +169,6 @@ _Nothing yet._ [#211]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/211 [#226]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/226 - ## [3.8.0] - 2023-12-08 [Squizlabs/PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is dead. Long live [PHPCSStandards/PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer)! @@ -5502,6 +5618,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo --> [Unreleased]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/master...HEAD +[3.9.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.8.1...3.9.0 [3.8.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.8.0...3.8.1 [3.8.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.2...3.8.0 [3.7.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.1...3.7.2 @@ -5694,6 +5811,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@jeffslofish]: https://github.com/jeffslofish [@jmarcil]: https://github.com/jmarcil [@jnrbsn]: https://github.com/jnrbsn +[@joachim-n]: https://github.com/joachim-n [@joelposti]: https://github.com/joelposti [@johanderuijter]: https://github.com/johanderuijter [@johnmaguire]: https://github.com/johnmaguire @@ -5752,6 +5870,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@r3nat]: https://github.com/r3nat [@raul338]: https://github.com/raul338 [@realmfoo]: https://github.com/realmfoo +[@remicollet]: https://github.com/remicollet [@renaatdemuynck]: https://github.com/renaatdemuynck [@renan]: https://github.com/renan [@rhorber]: https://github.com/rhorber @@ -5787,6 +5906,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@thomasjfox]: https://github.com/thomasjfox [@till]: https://github.com/till [@timoschinkel]: https://github.com/timoschinkel +[@TimWolla]: https://github.com/TimWolla [@uniquexor]: https://github.com/uniquexor [@valorin]: https://github.com/valorin [@VasekPurchart]: https://github.com/VasekPurchart From 6f7c59671423eeaeb77a969847253820b579594e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 16 Feb 2024 16:31:13 +0100 Subject: [PATCH 418/874] Config: update version nr to next --- src/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index 25b3a4f431..6f1dc2d5b6 100644 --- a/src/Config.php +++ b/src/Config.php @@ -81,7 +81,7 @@ class Config * * @var string */ - const VERSION = '3.9.0'; + const VERSION = '3.9.1'; /** * Package stability; either stable, beta or alpha. From ce60f4ca2fca18fa11bef244db508f4d8dc1ffd8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 17 Feb 2024 04:05:16 +0100 Subject: [PATCH 419/874] Tests: data set keys should match parameter names Initially to prevent issues with a few PHPUnit versions which were around in the early days of PHP 8.0, where these would accidentally be seen as parameter names. So, as a best practice, when using keys in data sets, the keys should match the parameter names of the receiving test method. An ulterior reason to make this change is that PHPUnit 11 will always treat the keys as parameter names, so this can be seen as a preparation step for allowing for PHPUnit 11 support in PHPCS 4.0. --- tests/Core/Config/ReportWidthTest.php | 6 +++--- tests/Core/ErrorSuppressionTest.php | 6 +++--- tests/Core/File/IsReferenceTest.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Core/Config/ReportWidthTest.php b/tests/Core/Config/ReportWidthTest.php index 2e67fa2691..d10e7a07d9 100644 --- a/tests/Core/Config/ReportWidthTest.php +++ b/tests/Core/Config/ReportWidthTest.php @@ -244,7 +244,7 @@ public function testReportWidthInputHandlingForAuto() /** * Test that the report width will be set correctly for various types of input. * - * @param mixed $input Input value received. + * @param mixed $value Input value received. * @param int $expected Expected report width. * * @dataProvider dataReportWidthInputHandling @@ -252,10 +252,10 @@ public function testReportWidthInputHandlingForAuto() * * @return void */ - public function testReportWidthInputHandling($input, $expected) + public function testReportWidthInputHandling($value, $expected) { $config = new Config(); - $config->reportWidth = $input; + $config->reportWidth = $value; $this->assertSame($expected, $config->reportWidth); diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index 4ae1e33ba2..e8b7935cc1 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -730,9 +730,9 @@ public static function dataSuppressFile() { return [ 'no suppression' => [ - 'before' => '', - 'after' => '', - 'expectedErrors' => 1, + 'before' => '', + 'after' => '', + 'expectedWarnings' => 1, ], // Process with suppression. diff --git a/tests/Core/File/IsReferenceTest.php b/tests/Core/File/IsReferenceTest.php index bbe31baef2..62eb600333 100644 --- a/tests/Core/File/IsReferenceTest.php +++ b/tests/Core/File/IsReferenceTest.php @@ -36,16 +36,16 @@ public function testNotBitwiseAndToken() /** * Test correctly identifying whether a "bitwise and" token is a reference or not. * - * @param string $identifier Comment which precedes the test case. + * @param string $testMarker Comment which precedes the test case. * @param bool $expected Expected function output. * * @dataProvider dataIsReference * * @return void */ - public function testIsReference($identifier, $expected) + public function testIsReference($testMarker, $expected) { - $bitwiseAnd = $this->getTargetToken($identifier, T_BITWISE_AND); + $bitwiseAnd = $this->getTargetToken($testMarker, T_BITWISE_AND); $result = self::$phpcsFile->isReference($bitwiseAnd); $this->assertSame($expected, $result); From a31ef61a098fe5766c868d8a39b4a659e742257d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 17 Feb 2024 08:01:45 +0100 Subject: [PATCH 420/874] Remove more remnants of PEAR installation support Follow up after #4 and #39 The alternative path referred to in the bin scripts and the test bootstrap was specific for running via a PEAR install. This should no longer be needed (nor will this work). --- bin/phpcbf | 6 +----- bin/phpcs | 6 +----- tests/bootstrap.php | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/bin/phpcbf b/bin/phpcbf index 2e86a40e62..c804bdf10e 100755 --- a/bin/phpcbf +++ b/bin/phpcbf @@ -8,11 +8,7 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -if (is_file(__DIR__.'/../autoload.php') === true) { - include_once __DIR__.'/../autoload.php'; -} else { - include_once 'PHP/CodeSniffer/autoload.php'; -} +require_once __DIR__.'/../autoload.php'; $runner = new PHP_CodeSniffer\Runner(); $exitCode = $runner->runPHPCBF(); diff --git a/bin/phpcs b/bin/phpcs index e8e8b02894..d098bf8783 100755 --- a/bin/phpcs +++ b/bin/phpcs @@ -8,11 +8,7 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -if (is_file(__DIR__.'/../autoload.php') === true) { - include_once __DIR__.'/../autoload.php'; -} else { - include_once 'PHP/CodeSniffer/autoload.php'; -} +require_once __DIR__.'/../autoload.php'; $runner = new PHP_CodeSniffer\Runner(); $exitCode = $runner->runPHPCS(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8d91b156f7..cf4936daa8 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -19,11 +19,7 @@ define('PHP_CODESNIFFER_VERBOSITY', 0); } -if (is_file(__DIR__.'/../autoload.php') === true) { - include_once __DIR__.'/../autoload.php'; -} else { - include_once 'PHP/CodeSniffer/autoload.php'; -} +require_once __DIR__.'/../autoload.php'; $tokens = new \PHP_CodeSniffer\Util\Tokens(); From 3756f11efafcc49ac770a40b7b3228897a6982ac Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 17 Feb 2024 07:48:28 +0100 Subject: [PATCH 421/874] CS: alphabetically order import use statements Follow up on squizlabs/PHP_CodeSniffer 2714 Note: sniffs which have been removed in 4.0 have been excluded from this commit. --- src/Files/DummyFile.php | 2 +- src/Files/File.php | 6 +++--- src/Files/FileList.php | 4 ++-- src/Files/LocalFile.php | 2 +- src/Filters/Filter.php | 4 ++-- src/Generators/Generator.php | 2 +- src/Sniffs/AbstractPatternSniff.php | 4 ++-- src/Sniffs/AbstractScopeSniff.php | 2 +- src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php | 2 +- .../Sniffs/NamingConventions/ValidVariableNameSniff.php | 2 +- tests/Core/AbstractMethodUnitTest.php | 2 +- tests/Core/AllTests.php | 2 +- tests/Core/ErrorSuppressionTest.php | 2 +- tests/Core/Tokenizer/AbstractTokenizerTestCase.php | 2 +- tests/Standards/AbstractSniffUnitTest.php | 2 +- tests/Standards/AllSniffs.php | 4 ++-- tests/TestSuite.php | 2 +- tests/TestSuite7.php | 2 +- 18 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Files/DummyFile.php b/src/Files/DummyFile.php index eb947fd2a9..f5dc7cc7ac 100644 --- a/src/Files/DummyFile.php +++ b/src/Files/DummyFile.php @@ -14,8 +14,8 @@ namespace PHP_CodeSniffer\Files; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Ruleset; class DummyFile extends File { diff --git a/src/Files/File.php b/src/Files/File.php index 7b54bea179..f40d9f7f2a 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -9,12 +9,12 @@ namespace PHP_CodeSniffer\Files; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Fixer; -use PHP_CodeSniffer\Util; use PHP_CodeSniffer\Exceptions\RuntimeException; use PHP_CodeSniffer\Exceptions\TokenizerException; +use PHP_CodeSniffer\Fixer; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Util; class File { diff --git a/src/Files/FileList.php b/src/Files/FileList.php index 13357ecdef..9589b4369d 100644 --- a/src/Files/FileList.php +++ b/src/Files/FileList.php @@ -12,10 +12,10 @@ namespace PHP_CodeSniffer\Files; use PHP_CodeSniffer\Autoload; -use PHP_CodeSniffer\Util; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Exceptions\DeepExitException; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Util; use ReturnTypeWillChange; class FileList implements \Iterator, \Countable diff --git a/src/Files/LocalFile.php b/src/Files/LocalFile.php index c2af77c42a..babfe69c31 100644 --- a/src/Files/LocalFile.php +++ b/src/Files/LocalFile.php @@ -9,8 +9,8 @@ namespace PHP_CodeSniffer\Files; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Util\Cache; use PHP_CodeSniffer\Util\Common; diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index c72518c660..af88a59668 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -9,9 +9,9 @@ namespace PHP_CodeSniffer\Filters; -use PHP_CodeSniffer\Util; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Util; use ReturnTypeWillChange; class Filter extends \RecursiveFilterIterator diff --git a/src/Generators/Generator.php b/src/Generators/Generator.php index 483cae800f..3b69ddf27b 100644 --- a/src/Generators/Generator.php +++ b/src/Generators/Generator.php @@ -12,8 +12,8 @@ namespace PHP_CodeSniffer\Generators; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Autoload; +use PHP_CodeSniffer\Ruleset; abstract class Generator { diff --git a/src/Sniffs/AbstractPatternSniff.php b/src/Sniffs/AbstractPatternSniff.php index 86dc10d408..e895365688 100644 --- a/src/Sniffs/AbstractPatternSniff.php +++ b/src/Sniffs/AbstractPatternSniff.php @@ -9,10 +9,10 @@ namespace PHP_CodeSniffer\Sniffs; +use PHP_CodeSniffer\Exceptions\RuntimeException; use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Util\Tokens; use PHP_CodeSniffer\Tokenizers\PHP; -use PHP_CodeSniffer\Exceptions\RuntimeException; +use PHP_CodeSniffer\Util\Tokens; abstract class AbstractPatternSniff implements Sniff { diff --git a/src/Sniffs/AbstractScopeSniff.php b/src/Sniffs/AbstractScopeSniff.php index 74201ab8eb..86a140781b 100644 --- a/src/Sniffs/AbstractScopeSniff.php +++ b/src/Sniffs/AbstractScopeSniff.php @@ -26,8 +26,8 @@ namespace PHP_CodeSniffer\Sniffs; -use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Exceptions\RuntimeException; +use PHP_CodeSniffer\Files\File; abstract class AbstractScopeSniff implements Sniff { diff --git a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php index 5ae72362d4..24ea495b48 100644 --- a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php @@ -9,8 +9,8 @@ namespace PHP_CodeSniffer\Standards\Zend\Sniffs\Files; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; class ClosingTagSniff implements Sniff diff --git a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php index 2dfeb39aa6..41b1948101 100644 --- a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -9,9 +9,9 @@ namespace PHP_CodeSniffer\Standards\Zend\Sniffs\NamingConventions; +use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\AbstractVariableSniff; use PHP_CodeSniffer\Util\Common; -use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Util\Tokens; class ValidVariableNameSniff extends AbstractVariableSniff diff --git a/tests/Core/AbstractMethodUnitTest.php b/tests/Core/AbstractMethodUnitTest.php index b8522bf4bb..5d625891c9 100644 --- a/tests/Core/AbstractMethodUnitTest.php +++ b/tests/Core/AbstractMethodUnitTest.php @@ -9,9 +9,9 @@ namespace PHP_CodeSniffer\Tests\Core; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Files\DummyFile; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; diff --git a/tests/Core/AllTests.php b/tests/Core/AllTests.php index 60547bb363..a5465f9878 100644 --- a/tests/Core/AllTests.php +++ b/tests/Core/AllTests.php @@ -11,8 +11,8 @@ namespace PHP_CodeSniffer\Tests\Core; use PHP_CodeSniffer\Tests\FileList; -use PHPUnit\TextUI\TestRunner; use PHPUnit\Framework\TestSuite; +use PHPUnit\TextUI\TestRunner; class AllTests { diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index e8b7935cc1..ccd9f479e7 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -9,8 +9,8 @@ namespace PHP_CodeSniffer\Tests\Core; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\ConfigDouble; use PHPUnit\Framework\TestCase; diff --git a/tests/Core/Tokenizer/AbstractTokenizerTestCase.php b/tests/Core/Tokenizer/AbstractTokenizerTestCase.php index 3225fe6fa2..aa2dc18d1d 100644 --- a/tests/Core/Tokenizer/AbstractTokenizerTestCase.php +++ b/tests/Core/Tokenizer/AbstractTokenizerTestCase.php @@ -12,8 +12,8 @@ namespace PHP_CodeSniffer\Tests\Core\Tokenizer; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\ConfigDouble; use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; use PHPUnit\Framework\TestCase; diff --git a/tests/Standards/AbstractSniffUnitTest.php b/tests/Standards/AbstractSniffUnitTest.php index c400758468..6e28aac912 100644 --- a/tests/Standards/AbstractSniffUnitTest.php +++ b/tests/Standards/AbstractSniffUnitTest.php @@ -14,8 +14,8 @@ namespace PHP_CodeSniffer\Tests\Standards; use PHP_CodeSniffer\Exceptions\RuntimeException; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Files\LocalFile; +use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\ConfigDouble; use PHP_CodeSniffer\Util\Common; use PHPUnit\Framework\TestCase; diff --git a/tests/Standards/AllSniffs.php b/tests/Standards/AllSniffs.php index e355d90dab..8c734064e4 100644 --- a/tests/Standards/AllSniffs.php +++ b/tests/Standards/AllSniffs.php @@ -9,10 +9,10 @@ namespace PHP_CodeSniffer\Tests\Standards; -use PHP_CodeSniffer\Util\Standards; use PHP_CodeSniffer\Autoload; -use PHPUnit\TextUI\TestRunner; +use PHP_CodeSniffer\Util\Standards; use PHPUnit\Framework\TestSuite; +use PHPUnit\TextUI\TestRunner; class AllSniffs { diff --git a/tests/TestSuite.php b/tests/TestSuite.php index ff7bde7e43..4598a85623 100644 --- a/tests/TestSuite.php +++ b/tests/TestSuite.php @@ -9,8 +9,8 @@ namespace PHP_CodeSniffer\Tests; -use PHPUnit\Framework\TestSuite as PHPUnit_TestSuite; use PHPUnit\Framework\TestResult; +use PHPUnit\Framework\TestSuite as PHPUnit_TestSuite; class TestSuite extends PHPUnit_TestSuite { diff --git a/tests/TestSuite7.php b/tests/TestSuite7.php index a4dabf5fc2..fd1977a8ca 100644 --- a/tests/TestSuite7.php +++ b/tests/TestSuite7.php @@ -9,8 +9,8 @@ namespace PHP_CodeSniffer\Tests; -use PHPUnit\Framework\TestSuite as PHPUnit_TestSuite; use PHPUnit\Framework\TestResult; +use PHPUnit\Framework\TestSuite as PHPUnit_TestSuite; class TestSuite extends PHPUnit_TestSuite { From 8974f2662ac60cc2d6a545eda35e41c6f0fb62e8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 18 Feb 2024 02:02:39 +0100 Subject: [PATCH 422/874] CS: always import all used classes [1] ... instead of using fully qualified global/PHP native classes inline. --- src/Config.php | 10 ++++++---- src/Exceptions/DeepExitException.php | 4 +++- src/Exceptions/RuntimeException.php | 4 +++- src/Exceptions/TokenizerException.php | 4 +++- src/Files/FileList.php | 16 +++++++++++----- src/Filters/Filter.php | 7 +++++-- src/Generators/Generator.php | 8 +++++--- src/Generators/HTML.php | 12 +++++++----- src/Generators/Markdown.php | 10 ++++++---- src/Generators/Text.php | 10 ++++++---- src/Reports/Checkstyle.php | 3 ++- src/Reports/Code.php | 3 ++- src/Reports/Junit.php | 3 ++- src/Reports/Xml.php | 3 ++- src/Ruleset.php | 9 ++++++--- src/Runner.php | 3 ++- .../Sniffs/PHP/DeprecatedFunctionsSniff.php | 4 +++- .../Sniffs/Classes/PropertyDeclarationSniff.php | 3 ++- src/Util/Cache.php | 12 ++++++++---- src/Util/Common.php | 4 +++- src/Util/Standards.php | 5 +++-- tests/FileList.php | 16 ++++++++++------ tests/Standards/AbstractSniffUnitTest.php | 3 ++- tests/Standards/AllSniffs.php | 4 +++- 24 files changed, 105 insertions(+), 55 deletions(-) diff --git a/src/Config.php b/src/Config.php index 6f1dc2d5b6..31540ae714 100644 --- a/src/Config.php +++ b/src/Config.php @@ -12,6 +12,8 @@ namespace PHP_CodeSniffer; +use Exception; +use Phar; use PHP_CodeSniffer\Exceptions\DeepExitException; use PHP_CodeSniffer\Exceptions\RuntimeException; use PHP_CodeSniffer\Util\Common; @@ -812,7 +814,7 @@ public function processLongArgument($arg, $pos) try { $this->setConfigData($key, $value); - } catch (\Exception $e) { + } catch (Exception $e) { throw new DeepExitException($e->getMessage().PHP_EOL, 3); } @@ -840,7 +842,7 @@ public function processLongArgument($arg, $pos) } else { try { $this->setConfigData($key, null); - } catch (\Exception $e) { + } catch (Exception $e) { throw new DeepExitException($e->getMessage().PHP_EOL, 3); } @@ -1608,7 +1610,7 @@ public static function setConfigData($key, $value, $temp=false) if ($temp === false) { $path = ''; if (is_callable('\Phar::running') === true) { - $path = \Phar::running(false); + $path = Phar::running(false); } if ($path !== '') { @@ -1679,7 +1681,7 @@ public static function getAllConfigData() $path = ''; if (is_callable('\Phar::running') === true) { - $path = \Phar::running(false); + $path = Phar::running(false); } if ($path !== '') { diff --git a/src/Exceptions/DeepExitException.php b/src/Exceptions/DeepExitException.php index 7732c6da48..6943e033ed 100644 --- a/src/Exceptions/DeepExitException.php +++ b/src/Exceptions/DeepExitException.php @@ -12,7 +12,9 @@ namespace PHP_CodeSniffer\Exceptions; -class DeepExitException extends \Exception +use Exception; + +class DeepExitException extends Exception { }//end class diff --git a/src/Exceptions/RuntimeException.php b/src/Exceptions/RuntimeException.php index a3d590984c..25eacd0b18 100644 --- a/src/Exceptions/RuntimeException.php +++ b/src/Exceptions/RuntimeException.php @@ -9,7 +9,9 @@ namespace PHP_CodeSniffer\Exceptions; -class RuntimeException extends \RuntimeException +use RuntimeException as PHPRuntimeException; + +class RuntimeException extends PHPRuntimeException { }//end class diff --git a/src/Exceptions/TokenizerException.php b/src/Exceptions/TokenizerException.php index ad25ace198..1cf53d6237 100644 --- a/src/Exceptions/TokenizerException.php +++ b/src/Exceptions/TokenizerException.php @@ -9,7 +9,9 @@ namespace PHP_CodeSniffer\Exceptions; -class TokenizerException extends \Exception +use Exception; + +class TokenizerException extends Exception { }//end class diff --git a/src/Files/FileList.php b/src/Files/FileList.php index 9589b4369d..f11d1c34b9 100644 --- a/src/Files/FileList.php +++ b/src/Files/FileList.php @@ -11,14 +11,20 @@ namespace PHP_CodeSniffer\Files; +use Countable; +use FilesystemIterator; +use Iterator; use PHP_CodeSniffer\Autoload; use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Exceptions\DeepExitException; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Util; +use RecursiveArrayIterator; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; use ReturnTypeWillChange; -class FileList implements \Iterator, \Countable +class FileList implements Iterator, Countable { /** @@ -80,9 +86,9 @@ public function __construct(Config $config, Ruleset $ruleset) $filterClass = $this->getFilterClass(); - $di = new \RecursiveDirectoryIterator($path, (\RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)); + $di = new RecursiveDirectoryIterator($path, (RecursiveDirectoryIterator::SKIP_DOTS | FilesystemIterator::FOLLOW_SYMLINKS)); $filter = new $filterClass($di, $path, $config, $ruleset); - $iterator = new \RecursiveIteratorIterator($filter); + $iterator = new RecursiveIteratorIterator($filter); foreach ($iterator as $file) { $this->files[$file->getPathname()] = null; @@ -121,9 +127,9 @@ public function addFile($path, $file=null) $filterClass = $this->getFilterClass(); - $di = new \RecursiveArrayIterator([$path]); + $di = new RecursiveArrayIterator([$path]); $filter = new $filterClass($di, $path, $this->config, $this->ruleset); - $iterator = new \RecursiveIteratorIterator($filter); + $iterator = new RecursiveIteratorIterator($filter); foreach ($iterator as $path) { $this->files[$path] = $file; diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index af88a59668..a37ef4684c 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -9,12 +9,15 @@ namespace PHP_CodeSniffer\Filters; +use FilesystemIterator; use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Util; +use RecursiveDirectoryIterator; +use RecursiveFilterIterator; use ReturnTypeWillChange; -class Filter extends \RecursiveFilterIterator +class Filter extends RecursiveFilterIterator { /** @@ -137,7 +140,7 @@ public function getChildren() { $filterClass = get_called_class(); $children = new $filterClass( - new \RecursiveDirectoryIterator($this->current(), (\RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)), + new RecursiveDirectoryIterator($this->current(), (RecursiveDirectoryIterator::SKIP_DOTS | FilesystemIterator::FOLLOW_SYMLINKS)), $this->basedir, $this->config, $this->ruleset diff --git a/src/Generators/Generator.php b/src/Generators/Generator.php index 3b69ddf27b..af0e0f5c40 100644 --- a/src/Generators/Generator.php +++ b/src/Generators/Generator.php @@ -12,6 +12,8 @@ namespace PHP_CodeSniffer\Generators; +use DOMDocument; +use DOMNode; use PHP_CodeSniffer\Autoload; use PHP_CodeSniffer\Ruleset; @@ -70,7 +72,7 @@ public function __construct(Ruleset $ruleset) * * @return string */ - protected function getTitle(\DOMNode $doc) + protected function getTitle(DOMNode $doc) { return $doc->getAttribute('title'); @@ -90,7 +92,7 @@ protected function getTitle(\DOMNode $doc) public function generate() { foreach ($this->docFiles as $file) { - $doc = new \DOMDocument(); + $doc = new DOMDocument(); $doc->load($file); $documentation = $doc->getElementsByTagName('documentation')->item(0); $this->processSniff($documentation); @@ -111,7 +113,7 @@ public function generate() * @return void * @see generate() */ - abstract protected function processSniff(\DOMNode $doc); + abstract protected function processSniff(DOMNode $doc); }//end class diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php index 55acd9e172..a042f36be9 100644 --- a/src/Generators/HTML.php +++ b/src/Generators/HTML.php @@ -13,6 +13,8 @@ namespace PHP_CodeSniffer\Generators; +use DOMDocument; +use DOMNode; use PHP_CodeSniffer\Config; class HTML extends Generator @@ -32,7 +34,7 @@ public function generate() $this->printToc(); foreach ($this->docFiles as $file) { - $doc = new \DOMDocument(); + $doc = new DOMDocument(); $doc->load($file); $documentation = $doc->getElementsByTagName('documentation')->item(0); $this->processSniff($documentation); @@ -145,7 +147,7 @@ protected function printToc() echo '
+ + + + + + + + +
Valid: Lorem ipsum dolor sit amet.Invalid: Maecenas non rutrum dolor.
class Code {}class Comparison {}
+ +

One Standard Block, Code Comparison

+

Documentation contains one standard block and one code comparison.

+ + + + + + + + + +
Valid: Lorem ipsum dolor sit amet.Invalid: Maecenas non rutrum dolor.
class Code {}class Comparison {}
+
+

One Standard Block, No Code

+

Documentation contains one standard block and no code comparison.

+
+

One Standard Block, Two Code Comparisons

+

Documentation contains one standard block and two code comparisons.

+ + + + + + + + + +
Valid: Etiam commodo magna at vestibulum blandit.Invalid: Vivamus lacinia ante velit.
class Code {}class Comparison {}
+ + + + + + + + + +
Valid: Pellentesque nisi neque.Invalid: Mauris dictum metus quis maximus pharetra.
$one = 10;$a = 10;
+
+

Two Standard Blocks, No Code

+

This is standard block one.

+

This is standard block two.

+
+

Two Standard Blocks, One Code Comparison

+

This is standard block one.

+ + + + + + + + + +
Valid: Vestibulum et orci condimentum.Invalid: Donec in nisl ut tortor convallis interdum.
class Code {}class Comparison {}
+

This is standard block two.

+
+

Two Standard Blocks, Three Code Comparisons

+

This is standard block one.

+ + + + + + + + + +
Valid: Vestibulum et orci condimentum.Invalid: Donec in nisl ut tortor convallis interdum.
class Code {}class Comparison {}
+

This is standard block two.

+ + + + + + + + + +
Valid: Pellentesque nisi neque.Invalid: Mauris dictum metus quis maximus pharetra.
$one = 10;$a = 10;
+ + + + + + + + + +
Valid: Quisque sagittis nisi vitae.Invalid: Morbi ac libero vitae lorem.
echo $foo;print $foo;
+
+ + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md b/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md new file mode 100644 index 0000000000..d613df2951 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md @@ -0,0 +1,171 @@ +# GeneratorTest Coding Standard + +## No Content + +## Code Comparison Only, Missing Standard Block + + + + + + + + + +
Valid: Lorem ipsum dolor sit amet.Invalid: Maecenas non rutrum dolor.
+ + class Code {} + + + + class Comparison {} + +
+ +## One Standard Block, Code Comparison +Documentation contains one standard block and one code comparison. + + + + + + + + + +
Valid: Lorem ipsum dolor sit amet.Invalid: Maecenas non rutrum dolor.
+ + class Code {} + + + + class Comparison {} + +
+ +## One Standard Block, No Code +Documentation contains one standard block and no code comparison. + +## One Standard Block, Two Code Comparisons +Documentation contains one standard block and two code comparisons. + + + + + + + + + +
Valid: Etiam commodo magna at vestibulum blandit.Invalid: Vivamus lacinia ante velit.
+ + class Code {} + + + + class Comparison {} + +
+ + + + + + + + + +
Valid: Pellentesque nisi neque.Invalid: Mauris dictum metus quis maximus pharetra.
+ + $one = 10; + + + + $a = 10; + +
+ +## Two Standard Blocks, No Code +This is standard block one. +This is standard block two. + +## Two Standard Blocks, One Code Comparison +This is standard block one. + + + + + + + + + +
Valid: Vestibulum et orci condimentum.Invalid: Donec in nisl ut tortor convallis interdum.
+ + class Code {} + + + + class Comparison {} + +
+This is standard block two. + +## Two Standard Blocks, Three Code Comparisons +This is standard block one. + + + + + + + + + +
Valid: Vestibulum et orci condimentum.Invalid: Donec in nisl ut tortor convallis interdum.
+ + class Code {} + + + + class Comparison {} + +
+This is standard block two. + + + + + + + + + +
Valid: Pellentesque nisi neque.Invalid: Mauris dictum metus quis maximus pharetra.
+ + $one = 10; + + + + $a = 10; + +
+ + + + + + + + + +
Valid: Quisque sagittis nisi vitae.Invalid: Morbi ac libero vitae lorem.
+ + echo $foo; + + + + print $foo; + +
+Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.txt b/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.txt new file mode 100644 index 0000000000..dcb404eec5 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.txt @@ -0,0 +1,111 @@ + +--------------------------------------------- +| GENERATORTEST CODING STANDARD: NO CONTENT | +--------------------------------------------- + + +------------------------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: CODE COMPARISON ONLY, MISSING STANDARD BLOCK | +------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Lorem ipsum dolor sit amet. | Invalid: Maecenas non rutrum dolor. | +---------------------------------------------------------------------------------------------------- +| class Code {} | class Comparison {} | +---------------------------------------------------------------------------------------------------- + + +---------------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: ONE STANDARD BLOCK, CODE COMPARISON | +---------------------------------------------------------------------- + +Documentation contains one standard block and one code comparison. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Lorem ipsum dolor sit amet. | Invalid: Maecenas non rutrum dolor. | +---------------------------------------------------------------------------------------------------- +| class Code {} | class Comparison {} | +---------------------------------------------------------------------------------------------------- + + +-------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: ONE STANDARD BLOCK, NO CODE | +-------------------------------------------------------------- + +Documentation contains one standard block and no code comparison. + + +--------------------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: ONE STANDARD BLOCK, TWO CODE COMPARISONS | +--------------------------------------------------------------------------- + +Documentation contains one standard block and two code comparisons. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Etiam commodo magna at vestibulum | Invalid: Vivamus lacinia ante velit. | +| blandit. | | +---------------------------------------------------------------------------------------------------- +| class Code {} | class Comparison {} | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Pellentesque nisi neque. | Invalid: Mauris dictum metus quis maximus | +| | pharetra. | +---------------------------------------------------------------------------------------------------- +| $one = 10; | $a = 10; | +---------------------------------------------------------------------------------------------------- + + +--------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: TWO STANDARD BLOCKS, NO CODE | +--------------------------------------------------------------- + +This is standard block one. + +This is standard block two. + + +--------------------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: TWO STANDARD BLOCKS, ONE CODE COMPARISON | +--------------------------------------------------------------------------- + +This is standard block one. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Vestibulum et orci condimentum. | Invalid: Donec in nisl ut tortor convallis | +| | interdum. | +---------------------------------------------------------------------------------------------------- +| class Code {} | class Comparison {} | +---------------------------------------------------------------------------------------------------- + +This is standard block two. + + +------------------------------------------------------------------------------ +| GENERATORTEST CODING STANDARD: TWO STANDARD BLOCKS, THREE CODE COMPARISONS | +------------------------------------------------------------------------------ + +This is standard block one. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Vestibulum et orci condimentum. | Invalid: Donec in nisl ut tortor convallis | +| | interdum. | +---------------------------------------------------------------------------------------------------- +| class Code {} | class Comparison {} | +---------------------------------------------------------------------------------------------------- + +This is standard block two. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Pellentesque nisi neque. | Invalid: Mauris dictum metus quis maximus | +| | pharetra. | +---------------------------------------------------------------------------------------------------- +| $one = 10; | $a = 10; | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Quisque sagittis nisi vitae. | Invalid: Morbi ac libero vitae lorem. | +---------------------------------------------------------------------------------------------------- +| echo $foo; | print $foo; | +---------------------------------------------------------------------------------------------------- + diff --git a/tests/Core/Generators/Fixtures/HTMLDouble.php b/tests/Core/Generators/Fixtures/HTMLDouble.php new file mode 100644 index 0000000000..9203724085 --- /dev/null +++ b/tests/Core/Generators/Fixtures/HTMLDouble.php @@ -0,0 +1,40 @@ +'; + echo 'Documentation generated on #REDACTED#'; + echo ' by PHP_CodeSniffer #VERSION#'; + echo ''.PHP_EOL; + echo ' '.PHP_EOL; + echo ''.PHP_EOL; + } + + /** + * Print the _real_ footer of the HTML page. + * + * @return void + */ + public function printRealFooter() + { + parent::printFooter(); + } +} diff --git a/tests/Core/Generators/Fixtures/MarkdownDouble.php b/tests/Core/Generators/Fixtures/MarkdownDouble.php new file mode 100644 index 0000000000..6f51f3ec4c --- /dev/null +++ b/tests/Core/Generators/Fixtures/MarkdownDouble.php @@ -0,0 +1,36 @@ +getTitle($doc), PHP_EOL; + } +} diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/NoContentStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/NoContentStandard.xml new file mode 100644 index 0000000000..83afee8e83 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/NoContentStandard.xml @@ -0,0 +1,2 @@ + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/NoDocumentationElementStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/NoDocumentationElementStandard.xml new file mode 100644 index 0000000000..ca8290f1b4 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/NoDocumentationElementStandard.xml @@ -0,0 +1,2 @@ + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneCodeComparisonNoStandardStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneCodeComparisonNoStandardStandard.xml new file mode 100644 index 0000000000..c2af9098a5 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneCodeComparisonNoStandardStandard.xml @@ -0,0 +1,14 @@ + + + + class Code {} + ]]> + + + class Comparison {} + ]]> + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneStandardBlockCodeComparisonStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneStandardBlockCodeComparisonStandard.xml new file mode 100644 index 0000000000..c3ce35cd71 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneStandardBlockCodeComparisonStandard.xml @@ -0,0 +1,19 @@ + + + + + + + class Code {} + ]]> + + + class Comparison {} + ]]> + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneStandardBlockNoCodeStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneStandardBlockNoCodeStandard.xml new file mode 100644 index 0000000000..fc014949e7 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneStandardBlockNoCodeStandard.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneStandardBlockTwoCodeComparisonsStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneStandardBlockTwoCodeComparisonsStandard.xml new file mode 100644 index 0000000000..19559e6720 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/OneStandardBlockTwoCodeComparisonsStandard.xml @@ -0,0 +1,31 @@ + + + + + + + class Code {} + ]]> + + + class Comparison {} + ]]> + + + + + $one = 10; + ]]> + + + $a = 10; + ]]> + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/TwoStandardBlocksNoCodeStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/TwoStandardBlocksNoCodeStandard.xml new file mode 100644 index 0000000000..f5f621ecdc --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/TwoStandardBlocksNoCodeStandard.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/TwoStandardBlocksOneCodeComparisonStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/TwoStandardBlocksOneCodeComparisonStandard.xml new file mode 100644 index 0000000000..a5b3a3216e --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/TwoStandardBlocksOneCodeComparisonStandard.xml @@ -0,0 +1,24 @@ + + + + + + + Code {} + ]]> + + + Comparison {} + ]]> + + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/TwoStandardBlocksThreeCodeComparisonsStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/TwoStandardBlocksThreeCodeComparisonsStandard.xml new file mode 100644 index 0000000000..540ac7eaf7 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Structure/TwoStandardBlocksThreeCodeComparisonsStandard.xml @@ -0,0 +1,48 @@ + + + + + + + class Code {} + ]]> + + + class Comparison {} + ]]> + + + + + + + + $one = 10; + ]]> + + + $a = 10; + ]]> + + + + + echo $foo; + ]]> + + + print $foo; + ]]> + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/DummySniff.php b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/DummySniff.php new file mode 100644 index 0000000000..1a2546b111 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/DummySniff.php @@ -0,0 +1,25 @@ + + + + diff --git a/tests/Core/Generators/GeneratorTest.php b/tests/Core/Generators/GeneratorTest.php new file mode 100644 index 0000000000..30536518f6 --- /dev/null +++ b/tests/Core/Generators/GeneratorTest.php @@ -0,0 +1,241 @@ + $expected The expected list of found docs. + * + * @dataProvider dataConstructor + * + * @return void + */ + public function testConstructor($standard, array $expected) + { + // Set up the ruleset. + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + $generator = new MockGenerator($ruleset); + $this->assertSame($expected, $generator->docFiles); + + }//end testConstructor() + + + /** + * Data provider. + * + * @return array>> + */ + public static function dataConstructor() + { + $pathToDocsInFixture = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'; + $pathToDocsInFixture .= DIRECTORY_SEPARATOR.'StandardWithDocs'; + $pathToDocsInFixture .= DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR; + + return [ + 'Standard without docs' => [ + 'standard' => __DIR__.'/NoDocsTest.xml', + 'expected' => [], + ], + 'Standard with an invalid doc file' => [ + 'standard' => __DIR__.'/NoValidDocsTest.xml', + 'expected' => [ + $pathToDocsInFixture.'Structure'.DIRECTORY_SEPARATOR.'NoDocumentationElementStandard.xml', + ], + ], + 'Standard with one doc file' => [ + 'standard' => __DIR__.'/OneDocTest.xml', + 'expected' => [ + $pathToDocsInFixture.'Structure'.DIRECTORY_SEPARATOR.'OneStandardBlockNoCodeStandard.xml', + ], + ], + 'Standard with multiple doc files' => [ + 'standard' => __DIR__.'/StructureDocsTest.xml', + 'expected' => [ + $pathToDocsInFixture.'Structure'.DIRECTORY_SEPARATOR.'NoContentStandard.xml', + $pathToDocsInFixture.'Structure'.DIRECTORY_SEPARATOR.'OneCodeComparisonNoStandardStandard.xml', + $pathToDocsInFixture.'Structure'.DIRECTORY_SEPARATOR.'OneStandardBlockCodeComparisonStandard.xml', + $pathToDocsInFixture.'Structure'.DIRECTORY_SEPARATOR.'OneStandardBlockNoCodeStandard.xml', + $pathToDocsInFixture.'Structure'.DIRECTORY_SEPARATOR.'OneStandardBlockTwoCodeComparisonsStandard.xml', + $pathToDocsInFixture.'Structure'.DIRECTORY_SEPARATOR.'TwoStandardBlocksNoCodeStandard.xml', + $pathToDocsInFixture.'Structure'.DIRECTORY_SEPARATOR.'TwoStandardBlocksOneCodeComparisonStandard.xml', + $pathToDocsInFixture.'Structure'.DIRECTORY_SEPARATOR.'TwoStandardBlocksThreeCodeComparisonsStandard.xml', + ], + ], + ]; + + }//end dataConstructor() + + + /** + * Verify that an XML doc which isn't valid documentation yields an Exception to warn devs. + * + * This should not be hidden via defensive coding! + * + * @return void + */ + public function testGeneratingInvalidDocsResultsInException() + { + // Set up the ruleset. + $standard = __DIR__.'/NoValidDocsTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + if (PHP_VERSION_ID >= 80000) { + $exception = 'TypeError'; + $message = 'processSniff(): Argument #1 ($doc) must be of type DOMNode, null given'; + } else if (PHP_VERSION_ID >= 70000) { + $exception = 'TypeError'; + $message = 'processSniff() must be an instance of DOMNode, null given'; + } else { + $exception = 'PHPUnit_Framework_Error'; + $message = 'processSniff() must be an instance of DOMNode, null given'; + } + + if (method_exists($this, 'expectExceptionMessage') === true) { + // PHPUnit 5.2.0+. + $this->expectException($exception); + $this->expectExceptionMessage($message); + } else { + // Ancient PHPUnit. + $this->setExpectedException($exception, $message); + } + + $generator = new MockGenerator($ruleset); + $generator->generate(); + + }//end testGeneratingInvalidDocsResultsInException() + + + /** + * Verify the wiring for the generate() function. + * + * @param string $standard The standard to use for the test. + * @param string $expected The expected function output. + * + * @dataProvider dataGeneratingDocs + * + * @return void + */ + public function testGeneratingDocs($standard, $expected) + { + // Set up the ruleset. + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + $this->expectOutputString($expected); + + $generator = new MockGenerator($ruleset); + $generator->generate(); + + }//end testGeneratingDocs() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataGeneratingDocs() + { + $multidocExpected = []; + $multidocExpected[] = 'No Content'; + $multidocExpected[] = 'Code Comparison Only, Missing Standard Block'; + $multidocExpected[] = 'One Standard Block, Code Comparison'; + $multidocExpected[] = 'One Standard Block, No Code'; + $multidocExpected[] = 'One Standard Block, Two Code Comparisons'; + $multidocExpected[] = 'Two Standard Blocks, No Code'; + $multidocExpected[] = 'Two Standard Blocks, One Code Comparison'; + $multidocExpected[] = 'Two Standard Blocks, Three Code Comparisons'; + $multidocExpected = implode(PHP_EOL, $multidocExpected).PHP_EOL; + + return [ + 'Standard without docs' => [ + 'standard' => __DIR__.'/NoDocsTest.xml', + 'expected' => '', + ], + 'Standard with one doc file' => [ + 'standard' => __DIR__.'/OneDocTest.xml', + 'expected' => 'One Standard Block, No Code'.PHP_EOL, + ], + 'Standard with multiple doc files' => [ + 'standard' => __DIR__.'/StructureDocsTest.xml', + 'expected' => $multidocExpected, + ], + ]; + + }//end dataGeneratingDocs() + + + /** + * Test that the documentation for each standard passed on the command-line is shown separately. + * + * @covers \PHP_CodeSniffer\Runner::runPHPCS + * + * @return void + */ + public function testGeneratorWillShowEachStandardSeparately() + { + $standard = __DIR__.'/OneDocTest.xml'; + $_SERVER['argv'] = [ + 'phpcs', + '--generator=Text', + "--standard=$standard,PSR1", + '--report-width=80', + ]; + + $regex = '`^ + \R* # Optional blank line at the start. + (?: + (?P-+\R) # Line with dashes. + \|[ ]GENERATORTEST[ ]CODING[ ]STANDARD:[ ][^\|]+\|\R # Doc title line with prefix expected for first standard. + (?P>delimiter) # Line with dashes. + .+?\R{2} # Standard description. + ) # Only expect this group once. + (?: + (?P>delimiter) # Line with dashes. + \|[ ]PSR1[ ]CODING[ ]STANDARD:[ ][^\|]+\|\R # Doc title line with prefix expected for second standard. + (?P>delimiter) # Line with dashes. + .+?\R+ # Standard description. + (?: + -+[ ]CODE[ ]COMPARISON[ ]-+\R # Code Comparison starter line with dashes. + (?:.+?(?P>delimiter)\R){2} # Arbitrary text followed by a delimiter line. + )* # Code comparison is optional and can exist multiple times. + \R+ + ){3,} # This complete group should occur at least three times. + `sx'; + + $this->expectOutputRegex($regex); + + $runner = new Runner(); + $runner->runPHPCS(); + + }//end testGeneratorWillShowEachStandardSeparately() + + +}//end class diff --git a/tests/Core/Generators/HTMLTest.php b/tests/Core/Generators/HTMLTest.php new file mode 100644 index 0000000000..4140937ab7 --- /dev/null +++ b/tests/Core/Generators/HTMLTest.php @@ -0,0 +1,104 @@ +assertNotFalse($expected, 'Output expectation file could not be found'); + + // Make the test OS independent. + $expected = str_replace("\n", PHP_EOL, $expected); + $this->expectOutputString($expected); + + $generator = new HTMLDouble($ruleset); + $generator->generate(); + + }//end testDocs() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataDocs() + { + return [ + 'Standard without docs' => [ + 'standard' => __DIR__.'/NoDocsTest.xml', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputNoDocs.html', + ], + 'Standard with one doc file' => [ + 'standard' => __DIR__.'/OneDocTest.xml', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputOneDoc.html', + ], + 'Standard with multiple doc files' => [ + 'standard' => __DIR__.'/StructureDocsTest.xml', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStructureDocs.html', + ], + ]; + + }//end dataDocs() + + + /** + * Test the generated footer. + * + * @return void + */ + public function testFooter() + { + // Set up the ruleset. + $standard = __DIR__.'/OneDocTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + $regex = '`^
'; + $regex .= 'Documentation generated on [A-Z][a-z]{2}, [0-9]{2} [A-Z][a-z]{2} 20[0-9]{2} [0-2][0-9](?::[0-5][0-9]){2} [+-][0-9]{4}'; + $regex .= ' by PHP_CodeSniffer [3-9]\.[0-9]+.[0-9]+'; + $regex .= '
\R \R\R$`'; + $this->expectOutputRegex($regex); + + $generator = new HTMLDouble($ruleset); + $generator->printRealFooter(); + + }//end testFooter() + + +}//end class diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php new file mode 100644 index 0000000000..9a3e540044 --- /dev/null +++ b/tests/Core/Generators/MarkdownTest.php @@ -0,0 +1,102 @@ +assertNotFalse($expected, 'Output expectation file could not be found'); + + // Make the test OS independent. + $expected = str_replace("\n", PHP_EOL, $expected); + $this->expectOutputString($expected); + + $generator = new MarkdownDouble($ruleset); + $generator->generate(); + + }//end testDocs() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataDocs() + { + return [ + 'Standard without docs' => [ + 'standard' => __DIR__.'/NoDocsTest.xml', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputNoDocs.md', + ], + 'Standard with one doc file' => [ + 'standard' => __DIR__.'/OneDocTest.xml', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputOneDoc.md', + ], + 'Standard with multiple doc files' => [ + 'standard' => __DIR__.'/StructureDocsTest.xml', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStructureDocs.md', + ], + ]; + + }//end dataDocs() + + + /** + * Test the generated footer. + * + * @return void + */ + public function testFooter() + { + // Set up the ruleset. + $standard = __DIR__.'/OneDocTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + $regex = '`^Documentation generated on [A-Z][a-z]{2}, [0-9]{2} [A-Z][a-z]{2} 20[0-9]{2} [0-2][0-9](?::[0-5][0-9]){2} [+-][0-9]{4}'; + $regex .= ' by \[PHP_CodeSniffer [3-9]\.[0-9]+.[0-9]+\]\(https://github\.com/PHPCSStandards/PHP_CodeSniffer\)\R$`'; + $this->expectOutputRegex($regex); + + $generator = new MarkdownDouble($ruleset); + $generator->printRealFooter(); + + }//end testFooter() + + +}//end class diff --git a/tests/Core/Generators/NoDocsTest.xml b/tests/Core/Generators/NoDocsTest.xml new file mode 100644 index 0000000000..51df8395c0 --- /dev/null +++ b/tests/Core/Generators/NoDocsTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Generators/NoValidDocsTest.xml b/tests/Core/Generators/NoValidDocsTest.xml new file mode 100644 index 0000000000..94dda4e714 --- /dev/null +++ b/tests/Core/Generators/NoValidDocsTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Generators/OneDocTest.xml b/tests/Core/Generators/OneDocTest.xml new file mode 100644 index 0000000000..83ca4384e5 --- /dev/null +++ b/tests/Core/Generators/OneDocTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Generators/StructureDocsTest.xml b/tests/Core/Generators/StructureDocsTest.xml new file mode 100644 index 0000000000..45811bee67 --- /dev/null +++ b/tests/Core/Generators/StructureDocsTest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/Core/Generators/TextTest.php b/tests/Core/Generators/TextTest.php new file mode 100644 index 0000000000..40544557f2 --- /dev/null +++ b/tests/Core/Generators/TextTest.php @@ -0,0 +1,80 @@ +assertNotFalse($expected, 'Output expectation file could not be found'); + + // Make the test OS independent. + $expected = str_replace("\n", PHP_EOL, $expected); + $this->expectOutputString($expected); + + $generator = new Text($ruleset); + $generator->generate(); + + }//end testDocs() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataDocs() + { + return [ + 'Standard without docs' => [ + 'standard' => __DIR__.'/NoDocsTest.xml', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt', + ], + 'Standard with one doc file' => [ + 'standard' => __DIR__.'/OneDocTest.xml', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputOneDoc.txt', + ], + 'Standard with multiple doc files' => [ + 'standard' => __DIR__.'/StructureDocsTest.xml', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStructureDocs.txt', + ], + ]; + + }//end dataDocs() + + +}//end class From 3d64cb24a7a4d78531b91bce41cea8c27736a51c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 14 Nov 2024 01:29:08 +0100 Subject: [PATCH 771/874] RuleInclusionAbsoluteWindowsTest: minor tweaks * Switching the test skipping from an inline condition to a PHPUnit annotation. * Adding the `@group Windows` annotation to ensure this test will run for code coverage on Windows in CI. --- .../Ruleset/RuleInclusionAbsoluteWindowsTest.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php index cba45ee399..9dd0370b28 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php @@ -16,7 +16,9 @@ /** * Tests for the \PHP_CodeSniffer\Ruleset class using a Windows-style absolute path to include a sniff. * - * @covers \PHP_CodeSniffer\Ruleset + * @covers \PHP_CodeSniffer\Ruleset + * @requires OS ^WIN.*. + * @group Windows */ final class RuleInclusionAbsoluteWindowsTest extends TestCase { @@ -52,10 +54,6 @@ final class RuleInclusionAbsoluteWindowsTest extends TestCase */ public function initializeConfigAndRuleset() { - if (DIRECTORY_SEPARATOR === '/') { - $this->markTestSkipped('Windows specific test'); - } - $this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; $repoRootDir = dirname(dirname(dirname(__DIR__))); @@ -85,9 +83,7 @@ public function initializeConfigAndRuleset() */ public function resetRuleset() { - if (DIRECTORY_SEPARATOR !== '/') { - file_put_contents($this->standard, $this->contents); - } + file_put_contents($this->standard, $this->contents); }//end resetRuleset() From 76927ef412ea9534dc0939698593686f909e5c26 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Nov 2024 00:50:07 +0100 Subject: [PATCH 772/874] Generators/Generator: minor tweak * Predefine the find/replace values as these don't change within the loop. * Only call `str_replace()` once with arrays for find/replace. --- src/Generators/Generator.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Generators/Generator.php b/src/Generators/Generator.php index ab81baed76..873ac3f3fa 100644 --- a/src/Generators/Generator.php +++ b/src/Generators/Generator.php @@ -6,7 +6,9 @@ * in a standard. * * @author Greg Sherwood + * @author Juliette Reinders Folmer * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) + * @copyright 2024 PHPCSStandards and contributors * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ @@ -46,14 +48,18 @@ public function __construct(Ruleset $ruleset) { $this->ruleset = $ruleset; + $find = [ + DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR, + 'Sniff.php', + ]; + $replace = [ + DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR, + 'Standard.xml', + ]; + foreach ($ruleset->sniffs as $className => $sniffClass) { $file = Autoload::getLoadedFileName($className); - $docFile = str_replace( - DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR, - DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR, - $file - ); - $docFile = str_replace('Sniff.php', 'Standard.xml', $docFile); + $docFile = str_replace($find, $replace, $file); if (is_file($docFile) === true) { $this->docFiles[] = $docFile; From 36e674617cca09ae73f958ed032549ad0843c3d2 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Nov 2024 08:58:43 +0100 Subject: [PATCH 773/874] Generators HTML/Markdown: don't print header/footer when there are no docs As things were, the Markdown/HTML header and footer would always be printed, even if there were no docs to display. In my opinion, there should be no output if there are no docs. This is in line with the `Text` output, which would already not generate any output when there are no docs. Includes updated test expectations. --- src/Generators/HTML.php | 4 + src/Generators/Markdown.php | 4 + .../Expectations/ExpectedOutputNoDocs.html | 78 ------------------- .../Expectations/ExpectedOutputNoDocs.md | 2 - tests/Core/Generators/HTMLTest.php | 2 +- tests/Core/Generators/MarkdownTest.php | 2 +- 6 files changed, 10 insertions(+), 82 deletions(-) delete mode 100644 tests/Core/Generators/Expectations/ExpectedOutputNoDocs.html delete mode 100644 tests/Core/Generators/Expectations/ExpectedOutputNoDocs.md diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php index 0fce7c99ae..f2f2e64bdd 100644 --- a/src/Generators/HTML.php +++ b/src/Generators/HTML.php @@ -103,6 +103,10 @@ class HTML extends Generator */ public function generate() { + if (empty($this->docFiles) === true) { + return; + } + ob_start(); $this->printHeader(); $this->printToc(); diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index de207ec601..8739961697 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -27,6 +27,10 @@ class Markdown extends Generator */ public function generate() { + if (empty($this->docFiles) === true) { + return; + } + ob_start(); $this->printHeader(); diff --git a/tests/Core/Generators/Expectations/ExpectedOutputNoDocs.html b/tests/Core/Generators/Expectations/ExpectedOutputNoDocs.html deleted file mode 100644 index 060de7aa63..0000000000 --- a/tests/Core/Generators/Expectations/ExpectedOutputNoDocs.html +++ /dev/null @@ -1,78 +0,0 @@ - - - GeneratorTest Coding Standards - - - -

GeneratorTest Coding Standards

-

Table of Contents

-
    -
-
Documentation generated on #REDACTED# by PHP_CodeSniffer #VERSION#
- - diff --git a/tests/Core/Generators/Expectations/ExpectedOutputNoDocs.md b/tests/Core/Generators/Expectations/ExpectedOutputNoDocs.md deleted file mode 100644 index ece2692187..0000000000 --- a/tests/Core/Generators/Expectations/ExpectedOutputNoDocs.md +++ /dev/null @@ -1,2 +0,0 @@ -# GeneratorTest Coding Standard -Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/HTMLTest.php b/tests/Core/Generators/HTMLTest.php index 4140937ab7..17ef7c9bcf 100644 --- a/tests/Core/Generators/HTMLTest.php +++ b/tests/Core/Generators/HTMLTest.php @@ -62,7 +62,7 @@ public static function dataDocs() return [ 'Standard without docs' => [ 'standard' => __DIR__.'/NoDocsTest.xml', - 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputNoDocs.html', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt', ], 'Standard with one doc file' => [ 'standard' => __DIR__.'/OneDocTest.xml', diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index 9a3e540044..1a89b7e8ee 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -62,7 +62,7 @@ public static function dataDocs() return [ 'Standard without docs' => [ 'standard' => __DIR__.'/NoDocsTest.xml', - 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputNoDocs.md', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt', ], 'Standard with one doc file' => [ 'standard' => __DIR__.'/OneDocTest.xml', From 382069574e9cfada9244ddd2a106d6c7ca35a9aa Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Nov 2024 16:36:10 +0100 Subject: [PATCH 774/874] Generators/Markdown: reset error_reporting to original value As things were, the `Markdown` class changes the PHP error level (to prevent potentially getting a warning about the timezone not being set), but doesn't reset the error level back to the original error level once the "risky" code has been executed. Fixed now. This was previously already fixed for the `HTML` class in PR squizlabs/PHP_CodeSniffer 488 Includes adding a test to safeguard this for both classes. These tests need to be run in isolation so as not get interference from the fact that the code is run in a test environment. I.e. without the `@runInSeparateProcess`, the test wouldn't fail when it should. --- src/Generators/Markdown.php | 3 ++- tests/Core/Generators/HTMLTest.php | 28 ++++++++++++++++++++++++++ tests/Core/Generators/MarkdownTest.php | 28 ++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index de207ec601..97e8717c1f 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -69,9 +69,10 @@ protected function printFooter() { // Turn off errors so we don't get timezone warnings if people // don't have their timezone set. - error_reporting(0); + $errorLevel = error_reporting(0); echo 'Documentation generated on '.date('r'); echo ' by [PHP_CodeSniffer '.Config::VERSION.'](https://github.com/PHPCSStandards/PHP_CodeSniffer)'.PHP_EOL; + error_reporting($errorLevel); }//end printFooter() diff --git a/tests/Core/Generators/HTMLTest.php b/tests/Core/Generators/HTMLTest.php index 4140937ab7..211d8c446e 100644 --- a/tests/Core/Generators/HTMLTest.php +++ b/tests/Core/Generators/HTMLTest.php @@ -101,4 +101,32 @@ public function testFooter() }//end testFooter() + /** + * Safeguard that the footer logic doesn't permanently change the error level. + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * @return void + */ + public function testFooterResetsErrorReportingToOriginalSetting() + { + $expected = error_reporting(); + + // Set up the ruleset. + $standard = __DIR__.'/OneDocTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + // We know there will be output, but we're not interested in the output for this test. + ob_start(); + $generator = new HTMLDouble($ruleset); + $generator->printRealFooter(); + ob_end_clean(); + + $this->assertSame($expected, error_reporting()); + + }//end testFooterResetsErrorReportingToOriginalSetting() + + }//end class diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index 9a3e540044..394b0ce5c1 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -99,4 +99,32 @@ public function testFooter() }//end testFooter() + /** + * Safeguard that the footer logic doesn't permanently change the error level. + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * @return void + */ + public function testFooterResetsErrorReportingToOriginalSetting() + { + $expected = error_reporting(); + + // Set up the ruleset. + $standard = __DIR__.'/OneDocTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + // We know there will be output, but we're not interested in the output for this test. + ob_start(); + $generator = new MarkdownDouble($ruleset); + $generator->printRealFooter(); + ob_end_clean(); + + $this->assertSame($expected, error_reporting()); + + }//end testFooterResetsErrorReportingToOriginalSetting() + + }//end class From 78d3d3d9db029209ad96c8ec2c7a86c32ddf65b5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 15 Nov 2024 16:15:31 +0100 Subject: [PATCH 775/874] RuleInclusionTest: record code coverage Code executed during "before class" methods is not recorded for code coverage, while code executed in "before" methods is, but the "before" method is executed before _every_ test in the class, not just once before the tests in the class run. So, to record code coverage, while still maintaining the performance benefits of only creating the Config and Ruleset objects once, the code still sets a static property and will only run if that static property has not been filled yet. --- tests/Core/Ruleset/RuleInclusionTest.php | 38 +++++++++++++----------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index ef3ad83cac..175febf30a 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -47,35 +47,37 @@ final class RuleInclusionTest extends TestCase /** * Initialize the config and ruleset objects based on the `RuleInclusionTest.xml` ruleset file. * - * @beforeClass + * @before * * @return void */ public static function initializeConfigAndRuleset() { - $standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; - self::$standard = $standard; + if (self::$standard === '') { + $standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; + self::$standard = $standard; - // On-the-fly adjust the ruleset test file to be able to test - // sniffs included with relative paths. - $contents = file_get_contents($standard); - self::$contents = $contents; + // On-the-fly adjust the ruleset test file to be able to test + // sniffs included with relative paths. + $contents = file_get_contents($standard); + self::$contents = $contents; - $repoRootDir = basename(dirname(dirname(dirname(__DIR__)))); + $repoRootDir = basename(dirname(dirname(dirname(__DIR__)))); - $newPath = $repoRootDir; - if (DIRECTORY_SEPARATOR === '\\') { - $newPath = str_replace('\\', '/', $repoRootDir); - } + $newPath = $repoRootDir; + if (DIRECTORY_SEPARATOR === '\\') { + $newPath = str_replace('\\', '/', $repoRootDir); + } - $adjusted = str_replace('%path_root_dir%', $newPath, $contents); + $adjusted = str_replace('%path_root_dir%', $newPath, $contents); - if (file_put_contents($standard, $adjusted) === false) { - self::markTestSkipped('On the fly ruleset adjustment failed'); - } + if (file_put_contents($standard, $adjusted) === false) { + self::markTestSkipped('On the fly ruleset adjustment failed'); + } - $config = new ConfigDouble(["--standard=$standard"]); - self::$ruleset = new Ruleset($config); + $config = new ConfigDouble(["--standard=$standard"]); + self::$ruleset = new Ruleset($config); + }//end if }//end initializeConfigAndRuleset() From 7e29324efefc6db1efe3ea0b2e733254f22345d8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 15 Nov 2024 16:04:43 +0100 Subject: [PATCH 776/874] RuleInclusionTest: add test with directory include --- tests/Core/Ruleset/RuleInclusionTest.php | 10 +++++++++- tests/Core/Ruleset/RuleInclusionTest.xml | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index 175febf30a..3f6a7180d6 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -103,7 +103,7 @@ public function resetRuleset() */ public function testHasSniffCodes() { - $this->assertCount(48, self::$ruleset->sniffCodes); + $this->assertCount(49, self::$ruleset->sniffCodes); }//end testHasSniffCodes() @@ -320,6 +320,10 @@ public static function dataRegisteredSniffCodes() 'Generic.Metrics.CyclomaticComplexity', 'PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff', ], + [ + 'Squiz.Files.FileExtension', + 'PHP_CodeSniffer\Standards\Squiz\Sniffs\Files\FileExtensionSniff', + ], [ 'Generic.NamingConventions.CamelCapsFunctionName', 'PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff', @@ -470,6 +474,10 @@ public static function dataSettingInvalidPropertiesOnStandardsAndCategoriesSilen 'sniffClass' => 'PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators\OperatorSpacingSniff', 'propertyName' => 'setforallincategory', ], + 'Set property for all sniffs in included category directory' => [ + 'sniffClass' => 'PHP_CodeSniffer\Standards\Squiz\Sniffs\Files\FileExtensionSniff', + 'propertyName' => 'setforsquizfilessniffs', + ], ]; }//end dataSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails() diff --git a/tests/Core/Ruleset/RuleInclusionTest.xml b/tests/Core/Ruleset/RuleInclusionTest.xml index 8275fe0111..6b5c0a970b 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.xml +++ b/tests/Core/Ruleset/RuleInclusionTest.xml @@ -27,6 +27,14 @@
+ + + + + + + + @@ -39,6 +47,7 @@ + From 168c0d1bf200c435b47dabcdf59c17bbd17cbe45 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 12 Nov 2024 12:20:43 +0100 Subject: [PATCH 777/874] Changelog for the 3.11.1 release --- CHANGELOG.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e15f42e726..5a4ba6aedf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,25 @@ The file documents changes to the PHP_CodeSniffer project. _Nothing yet._ +## [3.11.1] - 2024-11-16 + +### Changed +- Output from the `--generator=...` feature will respect the OS-expected EOL char in more places. [#671] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Various housekeeping, including improvements to the tests and documentation. + - Thanks to [Bartosz Dziewoński][@MatmaRex] and [Juliette Reinders Folmer][@jrfnl] for their contributions. + +### Fixed +- Fixed bug [#674] : Generic.WhiteSpace.HereNowdocIdentifierSpacing broken XML documentation + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- 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][@jrfnl] for the patch. + +[#671]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/671 +[#674]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/674 +[#675]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/675 + ## [3.11.0] - 2024-11-12 ### Added @@ -7133,6 +7152,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo --> [Unreleased]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/master...HEAD +[3.11.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.11.0...3.11.1 [3.11.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.10.3...3.11.0 [3.10.3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.10.2...3.10.3 [3.10.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.10.1...3.10.2 @@ -7370,6 +7390,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@maryo]: https://github.com/maryo [@MasterOdin]: https://github.com/MasterOdin [@mathroc]: https://github.com/mathroc +[@MatmaRex]: https://github.com/MatmaRex [@maxgalbu]: https://github.com/maxgalbu [@mcuelenaere]: https://github.com/mcuelenaere [@mhujer]: https://github.com/mhujer From 98c89728cd2cf2de6d966821f098204af5a3f274 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 16 Nov 2024 13:34:59 +0100 Subject: [PATCH 778/874] Config: update version nr to next --- src/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index e954c140ed..dda15a5553 100644 --- a/src/Config.php +++ b/src/Config.php @@ -85,7 +85,7 @@ class Config * * @var string */ - const VERSION = '3.11.1'; + const VERSION = '3.11.2'; /** * Package stability; either stable, beta or alpha. From dfce5e2767b076a8de43faf82dda5b87eef37501 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 18 Nov 2024 18:53:49 +0100 Subject: [PATCH 779/874] Generators HTML/Markdown: add extra test around error silencing Follow up on 688, which safeguarded/fixed that the `error_reporting` would be reset to its original value, this commit now adds tests to cover the original situation which caused the error silencing to be introduced in the first place. --- tests/Core/Generators/HTMLTest.php | 43 ++++++++++++++++++++++++++ tests/Core/Generators/MarkdownTest.php | 43 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/tests/Core/Generators/HTMLTest.php b/tests/Core/Generators/HTMLTest.php index 758b9a8133..e8724a0544 100644 --- a/tests/Core/Generators/HTMLTest.php +++ b/tests/Core/Generators/HTMLTest.php @@ -129,4 +129,47 @@ public function testFooterResetsErrorReportingToOriginalSetting() }//end testFooterResetsErrorReportingToOriginalSetting() + /** + * Safeguard that users won't see a PHP warning about the timezone not being set when calling date(). + * + * The warning we don't want to see is: + * "date(): It is not safe to rely on the system's timezone settings. You are *required* to use + * the date.timezone setting or the date_default_timezone_set() function. In case you used any of + * those methods and you are still getting this warning, you most likely misspelled the timezone + * identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select + * your timezone." + * + * JRF: Based on my tests, the warning only occurs on PHP < 7.0, but never a bad thing to safeguard this + * on a wider range of PHP versions. + * + * Note: as of PHP 8.2, PHP no longer accepts an empty string as timezone and will use `UTC` instead, + * so the warning on calling date() in the code itself would not display anyway. + * + * @requires PHP < 8.2 + * + * @doesNotPerformAssertions + * + * @return void + */ + public function testFooterDoesntThrowWarningOnMissingTimezone() + { + $originalIni = @ini_set('date.timezone', ''); + + // Set up the ruleset. + $standard = __DIR__.'/OneDocTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + // We know there will be output, but we're not interested in the output for this test. + ob_start(); + $generator = new HTMLDouble($ruleset); + $generator->printRealFooter(); + ob_end_clean(); + + // Reset the timezone to its original state. + ini_set('date.timezone', $originalIni); + + }//end testFooterDoesntThrowWarningOnMissingTimezone() + + }//end class diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index c76cd153d3..adba19518f 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -127,4 +127,47 @@ public function testFooterResetsErrorReportingToOriginalSetting() }//end testFooterResetsErrorReportingToOriginalSetting() + /** + * Safeguard that users won't see a PHP warning about the timezone not being set when calling date(). + * + * The warning we don't want to see is: + * "date(): It is not safe to rely on the system's timezone settings. You are *required* to use + * the date.timezone setting or the date_default_timezone_set() function. In case you used any of + * those methods and you are still getting this warning, you most likely misspelled the timezone + * identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select + * your timezone." + * + * JRF: Based on my tests, the warning only occurs on PHP < 7.0, but never a bad thing to safeguard this + * on a wider range of PHP versions. + * + * Note: as of PHP 8.2, PHP no longer accepts an empty string as timezone and will use `UTC` instead, + * so the warning on calling date() in the code itself would not display anyway. + * + * @requires PHP < 8.2 + * + * @doesNotPerformAssertions + * + * @return void + */ + public function testFooterDoesntThrowWarningOnMissingTimezone() + { + $originalIni = @ini_set('date.timezone', ''); + + // Set up the ruleset. + $standard = __DIR__.'/OneDocTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + // We know there will be output, but we're not interested in the output for this test. + ob_start(); + $generator = new MarkdownDouble($ruleset); + $generator->printRealFooter(); + ob_end_clean(); + + // Reset the timezone to its original state. + ini_set('date.timezone', $originalIni); + + }//end testFooterDoesntThrowWarningOnMissingTimezone() + + }//end class From a52c354504de019fd65eef66d806c617ea9fd103 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 18 Nov 2024 04:45:21 +0100 Subject: [PATCH 780/874] ShowSniffDeprecationsTest: fix bug in tests Wasn't noticeable, still a bug. --- tests/Core/Ruleset/ShowSniffDeprecationsTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php index 8e81f96a25..43f850f051 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php +++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php @@ -146,7 +146,7 @@ public function testDeprecatedSniffsListDoesNotShowWhenSelectedSniffsAreNotDepre ]; foreach ($sniffs as $sniffCode) { $parts = explode('.', strtolower($sniffCode)); - $sniffName = $parts[0].'\sniffs\\'.$parts[1].'\\'.$parts[2].'sniff'; + $sniffName = $parts[0].'\\sniffs\\'.$parts[1].'\\'.$parts[2].'sniff'; $restrictions[strtolower($sniffName)] = true; } @@ -158,7 +158,7 @@ public function testDeprecatedSniffsListDoesNotShowWhenSelectedSniffsAreNotDepre $sniffFiles[] = $sniffFile; } - $ruleset->registerSniffs($allSniffs, $restrictions, []); + $ruleset->registerSniffs($sniffFiles, $restrictions, []); $ruleset->populateTokenListeners(); $this->expectOutputString(''); @@ -195,7 +195,7 @@ public function testDeprecatedSniffsListDoesNotShowWhenAllDeprecatedSniffsAreExc ]; foreach ($exclude as $sniffCode) { $parts = explode('.', strtolower($sniffCode)); - $sniffName = $parts[0].'\sniffs\\'.$parts[1].'\\'.$parts[2].'sniff'; + $sniffName = $parts[0].'\\sniffs\\'.$parts[1].'\\'.$parts[2].'sniff'; $exclusions[strtolower($sniffName)] = true; } @@ -207,7 +207,7 @@ public function testDeprecatedSniffsListDoesNotShowWhenAllDeprecatedSniffsAreExc $sniffFiles[] = $sniffFile; } - $ruleset->registerSniffs($allSniffs, [], $exclusions); + $ruleset->registerSniffs($sniffFiles, [], $exclusions); $ruleset->populateTokenListeners(); $this->expectOutputString(''); From 2a045d31d0d3099bf024022613a48aacbd77aef9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 5 Nov 2024 01:47:08 +0100 Subject: [PATCH 781/874] Generators/HTML: only display a TOC when there is more than one doc --- src/Generators/HTML.php | 5 +++++ tests/Core/Generators/Expectations/ExpectedOutputOneDoc.html | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php index f2f2e64bdd..0f3733b984 100644 --- a/src/Generators/HTML.php +++ b/src/Generators/HTML.php @@ -156,6 +156,11 @@ protected function printHeader() */ protected function printToc() { + // Only show a TOC when there are two or more docs to display. + if (count($this->docFiles) < 2) { + return; + } + echo '

Table of Contents

'.PHP_EOL; echo '
    '.PHP_EOL; diff --git a/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.html b/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.html index 772d3861ec..2100809e71 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.html +++ b/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.html @@ -70,10 +70,6 @@

    GeneratorTest Coding Standards

    -

    Table of Contents

    -

    One Standard Block, No Code

    Documentation contains one standard block and no code comparison.

    From 12235bda7805484c8ffe4fd9a53df5bfbaa5e63f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Nov 2024 16:13:12 +0100 Subject: [PATCH 782/874] Generators/Markdown: fix footer not parsing As things were, if the output of the Markdown doc generation would be used in a Markdown-friendly environment, the footer would not be interpreted as markdown and would not display correctly. Fixed now by adding a blank line at the start of the footer. Includes updated test expectations. --- src/Generators/Markdown.php | 2 +- tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md | 1 + .../Core/Generators/Expectations/ExpectedOutputStructureDocs.md | 1 + tests/Core/Generators/Fixtures/MarkdownDouble.php | 2 +- tests/Core/Generators/MarkdownTest.php | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index d8e700b8ca..ab30cd59a7 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -74,7 +74,7 @@ protected function printFooter() // Turn off errors so we don't get timezone warnings if people // don't have their timezone set. $errorLevel = error_reporting(0); - echo 'Documentation generated on '.date('r'); + echo PHP_EOL.'Documentation generated on '.date('r'); echo ' by [PHP_CodeSniffer '.Config::VERSION.'](https://github.com/PHPCSStandards/PHP_CodeSniffer)'.PHP_EOL; error_reporting($errorLevel); diff --git a/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md b/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md index f8deb0ce20..0cc0ecceae 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md @@ -2,4 +2,5 @@ ## One Standard Block, No Code Documentation contains one standard block and no code comparison. + Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md b/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md index d613df2951..116af5df1e 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md @@ -168,4 +168,5 @@ This is standard block two. + Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Fixtures/MarkdownDouble.php b/tests/Core/Generators/Fixtures/MarkdownDouble.php index 6f51f3ec4c..ed2a5d8f58 100644 --- a/tests/Core/Generators/Fixtures/MarkdownDouble.php +++ b/tests/Core/Generators/Fixtures/MarkdownDouble.php @@ -20,7 +20,7 @@ class MarkdownDouble extends Markdown */ protected function printFooter() { - echo 'Documentation generated on *REDACTED*'; + echo PHP_EOL.'Documentation generated on *REDACTED*'; echo ' by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)'.PHP_EOL; } diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index adba19518f..0610678dbe 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -89,7 +89,7 @@ public function testFooter() $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); - $regex = '`^Documentation generated on [A-Z][a-z]{2}, [0-9]{2} [A-Z][a-z]{2} 20[0-9]{2} [0-2][0-9](?::[0-5][0-9]){2} [+-][0-9]{4}'; + $regex = '`^\RDocumentation generated on [A-Z][a-z]{2}, [0-9]{2} [A-Z][a-z]{2} 20[0-9]{2} [0-2][0-9](?::[0-5][0-9]){2} [+-][0-9]{4}'; $regex .= ' by \[PHP_CodeSniffer [3-9]\.[0-9]+.[0-9]+\]\(https://github\.com/PHPCSStandards/PHP_CodeSniffer\)\R$`'; $this->expectOutputRegex($regex); From 8c08a1de329bff95d10e2999b449ad483e497a36 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 16 Nov 2024 23:29:14 +0100 Subject: [PATCH 783/874] Tests/Ruleset/XML fixtures: add direct link between fixture and test using the fixture Small tweak to make sure the XML rulesets used for specific tests are directly linked to those tests via the XML ruleset name - this should make the tests more self-documenting. --- tests/Core/Ruleset/ExplainTest.php | 2 +- tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml | 2 +- .../Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml | 2 +- tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml | 2 +- ...pertyAppliesPropertyToMultipleSniffsInCategoryTest.xml | 2 +- ...tThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml | 2 +- ...tThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml | 2 +- .../Ruleset/SetPropertyNotAllowedViaAttributeTest.xml | 2 +- .../SetPropertyThrowsErrorOnInvalidPropertyTest.xml | 2 +- .../ShowSniffDeprecationsEmptyDeprecationVersionTest.xml | 2 +- .../ShowSniffDeprecationsEmptyRemovalVersionTest.xml | 2 +- ...ShowSniffDeprecationsInvalidDeprecationMessageTest.xml | 2 +- ...ShowSniffDeprecationsInvalidDeprecationVersionTest.xml | 2 +- .../ShowSniffDeprecationsInvalidRemovalVersionTest.xml | 2 +- tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml | 2 +- .../Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml | 2 +- tests/Core/Ruleset/ShowSniffDeprecationsTest.php | 8 ++++---- tests/Core/Ruleset/ShowSniffDeprecationsTest.xml | 2 +- 18 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index 5438c65cfc..0d899608df 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -185,7 +185,7 @@ public function testExplainWithDeprecatedSniffs() $ruleset = new Ruleset($config); $expected = PHP_EOL; - $expected .= 'The SniffDeprecationTest standard contains 9 sniffs'.PHP_EOL.PHP_EOL; + $expected .= 'The ShowSniffDeprecationsTest standard contains 9 sniffs'.PHP_EOL.PHP_EOL; $expected .= 'Fixtures (9 sniffs)'.PHP_EOL; $expected .= '-------------------'.PHP_EOL; diff --git a/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml b/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml index 5840d0c362..89005ad2d1 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml b/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml index 7ff2178247..deb6944d08 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml b/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml index 387f419e8d..475ba5cff3 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml b/tests/Core/Ruleset/SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml index 7c4ca4fd35..67fcca351d 100644 --- a/tests/Core/Ruleset/SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml +++ b/tests/Core/Ruleset/SetPropertyAppliesPropertyToMultipleSniffsInCategoryTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml b/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml index 979b48f522..a678c91555 100644 --- a/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml +++ b/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategoryTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml b/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml index 48a36a8313..8ce97e2dd3 100644 --- a/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml +++ b/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml b/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml index 7caae3d393..da5423913c 100644 --- a/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml +++ b/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyThrowsErrorOnInvalidPropertyTest.xml b/tests/Core/Ruleset/SetPropertyThrowsErrorOnInvalidPropertyTest.xml index 5dca1a010d..a1742618a2 100644 --- a/tests/Core/Ruleset/SetPropertyThrowsErrorOnInvalidPropertyTest.xml +++ b/tests/Core/Ruleset/SetPropertyThrowsErrorOnInvalidPropertyTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml index 5e2480bf2f..f10654fc40 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml index 6e667375af..0298571804 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml index d325167994..295d7b998a 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml index 89d83ab528..c7accdf29f 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml index c1eb062e1c..c5abf66da8 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml index 3ce96ce89f..6e3f6be53e 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml index 9f1cc85155..8a7870a585 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php index 43f850f051..bef388bcbc 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php +++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php @@ -234,7 +234,7 @@ public function testDeprecatedSniffsWarning() $config = new ConfigDouble(["--standard=$standard", '--no-colors']); $ruleset = new Ruleset($config); - $expected = 'WARNING: The SniffDeprecationTest standard uses 5 deprecated sniffs'.PHP_EOL; + $expected = 'WARNING: The ShowSniffDeprecationsTest standard uses 5 deprecated sniffs'.PHP_EOL; $expected .= '--------------------------------------------------------------------------------'.PHP_EOL; $expected .= '- Fixtures.Deprecated.WithLongReplacement'.PHP_EOL; $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; @@ -321,13 +321,13 @@ public function testReportWidthIsRespected($reportWidth, $expectedOutput) */ public static function dataReportWidthIsRespected() { - $summaryLine = 'WARNING: The SniffDeprecationTest standard uses 1 deprecated sniff'.PHP_EOL; + $summaryLine = 'WARNING: The ShowSniffDeprecationsTest standard uses 1 deprecated sniff'.PHP_EOL; // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- Test readability is more important. return [ 'Report width small: 40; with truncated sniff name and wrapped header and footer lines' => [ 'reportWidth' => 40, - 'expectedOutput' => 'WARNING: The SniffDeprecationTest'.PHP_EOL + 'expectedOutput' => 'WARNING: The ShowSniffDeprecationsTest'.PHP_EOL .'standard uses 1 deprecated sniff'.PHP_EOL .'----------------------------------------'.PHP_EOL .'- Fixtures.Deprecated.WithLongRepla...'.PHP_EOL @@ -409,7 +409,7 @@ public function testDeprecatedSniffsAreListedAlphabetically() $config = new ConfigDouble(["--standard=$standard", '--no-colors']); $ruleset = new Ruleset($config); - $expected = 'WARNING: The SniffDeprecationTest standard uses 2 deprecated sniffs'.PHP_EOL; + $expected = 'WARNING: The ShowSniffDeprecationsTest standard uses 2 deprecated sniffs'.PHP_EOL; $expected .= '--------------------------------------------------------------------------------'.PHP_EOL; $expected .= '- Fixtures.Deprecated.WithoutReplacement'.PHP_EOL; $expected .= ' This sniff has been deprecated since v3.4.0 and will be removed in v4.0.0.'.PHP_EOL; diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml index 4c1dec2203..4665f439b5 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml @@ -1,5 +1,5 @@ - + From 80b5656d6cef3a7a8d2cc82472caa128c33abecf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 14 Nov 2024 01:58:05 +0100 Subject: [PATCH 784/874] Tests/Ruleset/fixtures: move existing fixtures to subdirectory For some new tests, some test fixtures outside a standard directory structure and/or in a seperate standard directory structure are needed. This commit moves the pre-existing sniff test fixtures to a subdirectory to allow for the upcoming additional test fixtures. Includes updating the standard/ruleset to have a namespace prefix ("Fixtures"), so that aspect of things can now also be tested. --- tests/Core/Ruleset/ExplainTest.php | 22 ++++---- .../Deprecated/WithLongReplacementSniff.php | 2 +- ...eplacementContainingLinuxNewlinesSniff.php | 2 +- ...WithReplacementContainingNewlinesSniff.php | 2 +- .../Deprecated/WithReplacementSniff.php | 2 +- .../Deprecated/WithoutReplacementSniff.php | 2 +- .../EmptyDeprecationVersionSniff.php | 2 +- .../EmptyRemovalVersionSniff.php | 2 +- .../InvalidDeprecationMessageSniff.php | 2 +- .../InvalidDeprecationVersionSniff.php | 2 +- .../InvalidRemovalVersionSniff.php | 2 +- .../SetProperty/AllowedAsDeclaredSniff.php | 2 +- .../AllowedViaMagicMethodSniff.php | 2 +- .../SetProperty/AllowedViaStdClassSniff.php | 2 +- .../NotAllowedViaAttributeSniff.php | 2 +- .../Ruleset/Fixtures/TestStandard/ruleset.xml | 4 ++ tests/Core/Ruleset/Fixtures/ruleset.xml | 4 -- .../SetPropertyAllowedAsDeclaredTest.xml | 2 +- .../SetPropertyAllowedViaMagicMethodTest.xml | 2 +- .../SetPropertyAllowedViaStdClassTest.xml | 2 +- .../SetPropertyNotAllowedViaAttributeTest.xml | 2 +- tests/Core/Ruleset/SetSniffPropertyTest.php | 16 +++--- ...eprecationsEmptyDeprecationVersionTest.xml | 4 +- ...iffDeprecationsEmptyRemovalVersionTest.xml | 4 +- ...recationsInvalidDeprecationMessageTest.xml | 4 +- ...recationsInvalidDeprecationVersionTest.xml | 4 +- ...fDeprecationsInvalidRemovalVersionTest.xml | 4 +- .../ShowSniffDeprecationsOrderTest.xml | 6 +-- .../ShowSniffDeprecationsReportWidthTest.xml | 4 +- .../Ruleset/ShowSniffDeprecationsTest.php | 50 +++++++++---------- .../Ruleset/ShowSniffDeprecationsTest.xml | 6 +-- 31 files changed, 84 insertions(+), 84 deletions(-) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/Deprecated/WithLongReplacementSniff.php (96%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php (95%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php (95%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/Deprecated/WithReplacementSniff.php (93%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/Deprecated/WithoutReplacementSniff.php (93%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php (92%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php (92%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php (92%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php (92%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php (92%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/SetProperty/AllowedAsDeclaredSniff.php (89%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php (92%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/SetProperty/AllowedViaStdClassSniff.php (88%) rename tests/Core/Ruleset/Fixtures/{ => TestStandard}/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php (89%) create mode 100644 tests/Core/Ruleset/Fixtures/TestStandard/ruleset.xml delete mode 100644 tests/Core/Ruleset/Fixtures/ruleset.xml diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index 0d899608df..48df24f473 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -187,17 +187,17 @@ public function testExplainWithDeprecatedSniffs() $expected = PHP_EOL; $expected .= 'The ShowSniffDeprecationsTest standard contains 9 sniffs'.PHP_EOL.PHP_EOL; - $expected .= 'Fixtures (9 sniffs)'.PHP_EOL; - $expected .= '-------------------'.PHP_EOL; - $expected .= ' Fixtures.Deprecated.WithLongReplacement *'.PHP_EOL; - $expected .= ' Fixtures.Deprecated.WithoutReplacement *'.PHP_EOL; - $expected .= ' Fixtures.Deprecated.WithReplacement *'.PHP_EOL; - $expected .= ' Fixtures.Deprecated.WithReplacementContainingLinuxNewlines *'.PHP_EOL; - $expected .= ' Fixtures.Deprecated.WithReplacementContainingNewlines *'.PHP_EOL; - $expected .= ' Fixtures.SetProperty.AllowedAsDeclared'.PHP_EOL; - $expected .= ' Fixtures.SetProperty.AllowedViaMagicMethod'.PHP_EOL; - $expected .= ' Fixtures.SetProperty.AllowedViaStdClass'.PHP_EOL; - $expected .= ' Fixtures.SetProperty.NotAllowedViaAttribute'.PHP_EOL.PHP_EOL; + $expected .= 'TestStandard (9 sniffs)'.PHP_EOL; + $expected .= '-----------------------'.PHP_EOL; + $expected .= ' TestStandard.Deprecated.WithLongReplacement *'.PHP_EOL; + $expected .= ' TestStandard.Deprecated.WithoutReplacement *'.PHP_EOL; + $expected .= ' TestStandard.Deprecated.WithReplacement *'.PHP_EOL; + $expected .= ' TestStandard.Deprecated.WithReplacementContainingLinuxNewlines *'.PHP_EOL; + $expected .= ' TestStandard.Deprecated.WithReplacementContainingNewlines *'.PHP_EOL; + $expected .= ' TestStandard.SetProperty.AllowedAsDeclared'.PHP_EOL; + $expected .= ' TestStandard.SetProperty.AllowedViaMagicMethod'.PHP_EOL; + $expected .= ' TestStandard.SetProperty.AllowedViaStdClass'.PHP_EOL; + $expected .= ' TestStandard.SetProperty.NotAllowedViaAttribute'.PHP_EOL.PHP_EOL; $expected .= '* Sniffs marked with an asterix are deprecated.'.PHP_EOL; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithLongReplacementSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithLongReplacementSniff.php similarity index 96% rename from tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithLongReplacementSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithLongReplacementSniff.php index 40c23113d5..659d89ee2a 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithLongReplacementSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithLongReplacementSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest */ -namespace Fixtures\Sniffs\Deprecated; +namespace Fixtures\TestStandard\Sniffs\Deprecated; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\DeprecatedSniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php similarity index 95% rename from tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php index 0363927db7..d870cbf7e4 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest */ -namespace Fixtures\Sniffs\Deprecated; +namespace Fixtures\TestStandard\Sniffs\Deprecated; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\DeprecatedSniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php similarity index 95% rename from tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php index e9e76c8c0e..2516d7cd2e 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest */ -namespace Fixtures\Sniffs\Deprecated; +namespace Fixtures\TestStandard\Sniffs\Deprecated; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\DeprecatedSniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementSniff.php similarity index 93% rename from tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementSniff.php index a633982817..1953448672 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest */ -namespace Fixtures\Sniffs\Deprecated; +namespace Fixtures\TestStandard\Sniffs\Deprecated; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\DeprecatedSniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithoutReplacementSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithoutReplacementSniff.php similarity index 93% rename from tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithoutReplacementSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithoutReplacementSniff.php index d6d3887106..888e08fd13 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithoutReplacementSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithoutReplacementSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest */ -namespace Fixtures\Sniffs\Deprecated; +namespace Fixtures\TestStandard\Sniffs\Deprecated; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\DeprecatedSniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php similarity index 92% rename from tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php index 8d3dcd4218..4e26b7b761 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest */ -namespace Fixtures\Sniffs\DeprecatedInvalid; +namespace Fixtures\TestStandard\Sniffs\DeprecatedInvalid; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\DeprecatedSniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php similarity index 92% rename from tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php index 828b169284..cdf15c3031 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest */ -namespace Fixtures\Sniffs\DeprecatedInvalid; +namespace Fixtures\TestStandard\Sniffs\DeprecatedInvalid; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\DeprecatedSniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php similarity index 92% rename from tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php index a6819825f7..368bd4140b 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest */ -namespace Fixtures\Sniffs\DeprecatedInvalid; +namespace Fixtures\TestStandard\Sniffs\DeprecatedInvalid; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\DeprecatedSniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php similarity index 92% rename from tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php index d51aa876ca..b8218ad57e 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest */ -namespace Fixtures\Sniffs\DeprecatedInvalid; +namespace Fixtures\TestStandard\Sniffs\DeprecatedInvalid; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\DeprecatedSniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php similarity index 92% rename from tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php index a10997bbcd..1177e73338 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest */ -namespace Fixtures\Sniffs\DeprecatedInvalid; +namespace Fixtures\TestStandard\Sniffs\DeprecatedInvalid; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\DeprecatedSniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedAsDeclaredSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedAsDeclaredSniff.php similarity index 89% rename from tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedAsDeclaredSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedAsDeclaredSniff.php index c26160b279..a8f0364c54 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedAsDeclaredSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedAsDeclaredSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest */ -namespace Fixtures\Sniffs\SetProperty; +namespace Fixtures\TestStandard\Sniffs\SetProperty; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php similarity index 92% rename from tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php index 04097bb91a..98eb22c573 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest */ -namespace Fixtures\Sniffs\SetProperty; +namespace Fixtures\TestStandard\Sniffs\SetProperty; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaStdClassSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaStdClassSniff.php similarity index 88% rename from tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaStdClassSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaStdClassSniff.php index 30418729dc..0f58b2e001 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaStdClassSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaStdClassSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest */ -namespace Fixtures\Sniffs\SetProperty; +namespace Fixtures\TestStandard\Sniffs\SetProperty; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; diff --git a/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php similarity index 89% rename from tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php rename to tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php index e895a87a8b..bb52355827 100644 --- a/tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php @@ -5,7 +5,7 @@ * @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest */ -namespace Fixtures\Sniffs\SetProperty; +namespace Fixtures\TestStandard\Sniffs\SetProperty; use AllowDynamicProperties; use PHP_CodeSniffer\Files\File; diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/ruleset.xml b/tests/Core/Ruleset/Fixtures/TestStandard/ruleset.xml new file mode 100644 index 0000000000..345c4837eb --- /dev/null +++ b/tests/Core/Ruleset/Fixtures/TestStandard/ruleset.xml @@ -0,0 +1,4 @@ + + + + diff --git a/tests/Core/Ruleset/Fixtures/ruleset.xml b/tests/Core/Ruleset/Fixtures/ruleset.xml deleted file mode 100644 index 11a899adae..0000000000 --- a/tests/Core/Ruleset/Fixtures/ruleset.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml b/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml index 89005ad2d1..88eaa5ebf9 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml @@ -1,7 +1,7 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml b/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml index deb6944d08..e8502e7ff6 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedViaMagicMethodTest.xml @@ -1,7 +1,7 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml b/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml index 475ba5cff3..bfbfaf5e6f 100644 --- a/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml +++ b/tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml @@ -1,7 +1,7 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml b/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml index da5423913c..c6a14c259c 100644 --- a/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml +++ b/tests/Core/Ruleset/SetPropertyNotAllowedViaAttributeTest.xml @@ -1,7 +1,7 @@ - + diff --git a/tests/Core/Ruleset/SetSniffPropertyTest.php b/tests/Core/Ruleset/SetSniffPropertyTest.php index 36e6f0097b..51bd0e2989 100644 --- a/tests/Core/Ruleset/SetSniffPropertyTest.php +++ b/tests/Core/Ruleset/SetSniffPropertyTest.php @@ -34,8 +34,8 @@ final class SetSniffPropertyTest extends TestCase */ public function testSniffPropertiesGetSetWhenAllowed($name) { - $sniffCode = "Fixtures.SetProperty.{$name}"; - $sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff'; + $sniffCode = "TestStandard.SetProperty.{$name}"; + $sniffClass = 'Fixtures\TestStandard\Sniffs\SetProperty\\'.$name.'Sniff'; $properties = [ 'arbitrarystring' => 'arbitraryvalue', 'arbitraryarray' => [ @@ -163,7 +163,7 @@ public function testSetPropertyThrowsErrorOnInvalidProperty() public function testSetPropertyThrowsErrorWhenPropertyOnlyAllowedViaAttribute() { $exceptionClass = 'PHP_CodeSniffer\Exceptions\RuntimeException'; - $exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff Fixtures.SetProperty.NotAllowedViaAttribute'; + $exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff TestStandard.SetProperty.NotAllowedViaAttribute'; if (method_exists($this, 'expectException') === true) { $this->expectException($exceptionClass); $this->expectExceptionMessage($exceptionMsg); @@ -225,8 +225,8 @@ public function testSetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCateg public function testDirectCallWithNewArrayFormatSetsProperty() { $name = 'AllowedAsDeclared'; - $sniffCode = "Fixtures.SetProperty.{$name}"; - $sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff'; + $sniffCode = "TestStandard.SetProperty.{$name}"; + $sniffClass = 'Fixtures\TestStandard\Sniffs\SetProperty\\'.$name.'Sniff'; // Set up the ruleset. $standard = __DIR__."/SetProperty{$name}Test.xml"; @@ -276,8 +276,8 @@ public function testDirectCallWithNewArrayFormatSetsProperty() public function testDirectCallWithOldArrayFormatSetsProperty($propertyValue) { $name = 'AllowedAsDeclared'; - $sniffCode = "Fixtures.SetProperty.{$name}"; - $sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff'; + $sniffCode = "TestStandard.SetProperty.{$name}"; + $sniffClass = 'Fixtures\TestStandard\Sniffs\SetProperty\\'.$name.'Sniff'; // Set up the ruleset. $standard = __DIR__."/SetProperty{$name}Test.xml"; @@ -383,7 +383,7 @@ public function testDirectCallWithOldArrayFormatThrowsDeprecationNotice() } $name = 'AllowedAsDeclared'; - $sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff'; + $sniffClass = 'Fixtures\TestStandard\Sniffs\SetProperty\\'.$name.'Sniff'; // Set up the ruleset. $standard = __DIR__."/SetProperty{$name}Test.xml"; diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml index f10654fc40..75527e2b1d 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml @@ -1,8 +1,8 @@ - + - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml index 0298571804..150fc3e526 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml @@ -1,8 +1,8 @@ - + - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml index 295d7b998a..973e065a13 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml @@ -1,8 +1,8 @@ - + - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml index c7accdf29f..493adfd1ef 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml @@ -1,8 +1,8 @@ - + - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml index c5abf66da8..358cb0df5f 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml @@ -1,8 +1,8 @@ - + - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml index 6e3f6be53e..fbc0cb7b74 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml @@ -1,10 +1,10 @@ - + - - + + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml index 8a7870a585..86cc615c4e 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml @@ -1,8 +1,8 @@ - + - + diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php index bef388bcbc..c31f7b4a83 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php +++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php @@ -141,8 +141,8 @@ public function testDeprecatedSniffsListDoesNotShowWhenSelectedSniffsAreNotDepre $restrictions = []; $sniffs = [ - 'Fixtures.SetProperty.AllowedAsDeclared', - 'Fixtures.SetProperty.AllowedViaStdClass', + 'TestStandard.SetProperty.AllowedAsDeclared', + 'TestStandard.SetProperty.AllowedViaStdClass', ]; foreach ($sniffs as $sniffCode) { $parts = explode('.', strtolower($sniffCode)); @@ -187,11 +187,11 @@ public function testDeprecatedSniffsListDoesNotShowWhenAllDeprecatedSniffsAreExc $exclusions = []; $exclude = [ - 'Fixtures.Deprecated.WithLongReplacement', - 'Fixtures.Deprecated.WithoutReplacement', - 'Fixtures.Deprecated.WithReplacement', - 'Fixtures.Deprecated.WithReplacementContainingLinuxNewlines', - 'Fixtures.Deprecated.WithReplacementContainingNewlines', + 'TestStandard.Deprecated.WithLongReplacement', + 'TestStandard.Deprecated.WithoutReplacement', + 'TestStandard.Deprecated.WithReplacement', + 'TestStandard.Deprecated.WithReplacementContainingLinuxNewlines', + 'TestStandard.Deprecated.WithReplacementContainingNewlines', ]; foreach ($exclude as $sniffCode) { $parts = explode('.', strtolower($sniffCode)); @@ -236,7 +236,7 @@ public function testDeprecatedSniffsWarning() $expected = 'WARNING: The ShowSniffDeprecationsTest standard uses 5 deprecated sniffs'.PHP_EOL; $expected .= '--------------------------------------------------------------------------------'.PHP_EOL; - $expected .= '- Fixtures.Deprecated.WithLongReplacement'.PHP_EOL; + $expected .= '- TestStandard.Deprecated.WithLongReplacement'.PHP_EOL; $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; $expected .= ' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vel'.PHP_EOL; $expected .= ' vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium sed.'.PHP_EOL; @@ -247,12 +247,12 @@ public function testDeprecatedSniffsWarning() $expected .= ' dictum. Suspendisse dictum egestas sapien, eget ullamcorper metus elementum'.PHP_EOL; $expected .= ' semper. Vestibulum sem justo, consectetur ac tincidunt et, finibus eget'.PHP_EOL; $expected .= ' libero.'.PHP_EOL; - $expected .= '- Fixtures.Deprecated.WithoutReplacement'.PHP_EOL; + $expected .= '- TestStandard.Deprecated.WithoutReplacement'.PHP_EOL; $expected .= ' This sniff has been deprecated since v3.4.0 and will be removed in v4.0.0.'.PHP_EOL; - $expected .= '- Fixtures.Deprecated.WithReplacement'.PHP_EOL; + $expected .= '- TestStandard.Deprecated.WithReplacement'.PHP_EOL; $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; $expected .= ' Use the Stnd.Category.OtherSniff sniff instead.'.PHP_EOL; - $expected .= '- Fixtures.Deprecated.WithReplacementContainingLinuxNewlines'.PHP_EOL; + $expected .= '- TestStandard.Deprecated.WithReplacementContainingLinuxNewlines'.PHP_EOL; $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; $expected .= ' Lorem ipsum dolor sit amet, consectetur adipiscing elit.'.PHP_EOL; $expected .= ' Fusce vel vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium'.PHP_EOL; @@ -262,7 +262,7 @@ public function testDeprecatedSniffsWarning() $expected .= ' eros sapien at sem.'.PHP_EOL; $expected .= ' Sed pulvinar aliquam malesuada. Aliquam erat volutpat. Mauris gravida rutrum'.PHP_EOL; $expected .= ' lectus at egestas.'.PHP_EOL; - $expected .= '- Fixtures.Deprecated.WithReplacementContainingNewlines'.PHP_EOL; + $expected .= '- TestStandard.Deprecated.WithReplacementContainingNewlines'.PHP_EOL; $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; $expected .= ' Lorem ipsum dolor sit amet, consectetur adipiscing elit.'.PHP_EOL; $expected .= ' Fusce vel vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium'.PHP_EOL; @@ -330,7 +330,7 @@ public static function dataReportWidthIsRespected() 'expectedOutput' => 'WARNING: The ShowSniffDeprecationsTest'.PHP_EOL .'standard uses 1 deprecated sniff'.PHP_EOL .'----------------------------------------'.PHP_EOL - .'- Fixtures.Deprecated.WithLongRepla...'.PHP_EOL + .'- TestStandard.Deprecated.WithLongR...'.PHP_EOL .' This sniff has been deprecated since'.PHP_EOL .' v3.8.0 and will be removed in'.PHP_EOL .' v4.0.0. Lorem ipsum dolor sit amet,'.PHP_EOL @@ -358,7 +358,7 @@ public static function dataReportWidthIsRespected() 'Report width default: 80' => [ 'reportWidth' => 80, 'expectedOutput' => $summaryLine.str_repeat('-', 80).PHP_EOL - .'- Fixtures.Deprecated.WithLongReplacement'.PHP_EOL + .'- TestStandard.Deprecated.WithLongReplacement'.PHP_EOL .' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL .' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vel'.PHP_EOL .' vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium sed.'.PHP_EOL @@ -376,7 +376,7 @@ public static function dataReportWidthIsRespected() // Length = 4 padding + 75 base line + 587 custom message. 'reportWidth' => 666, 'expectedOutput' => $summaryLine.str_repeat('-', 666).PHP_EOL - .'- Fixtures.Deprecated.WithLongReplacement'.PHP_EOL + .'- TestStandard.Deprecated.WithLongReplacement'.PHP_EOL .' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vel vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium sed. Fusce egestas congue massa semper cursus. Donec quis pretium tellus. In lacinia, augue ut ornare porttitor, diam nunc faucibus purus, et accumsan eros sapien at sem. Sed pulvinar aliquam malesuada. Aliquam erat volutpat. Mauris gravida rutrum lectus at egestas. Fusce tempus elit in tincidunt dictum. Suspendisse dictum egestas sapien, eget ullamcorper metus elementum semper. Vestibulum sem justo, consectetur ac tincidunt et, finibus eget libero.' .PHP_EOL.PHP_EOL .'Deprecated sniffs are still run, but will stop working at some point in the future.'.PHP_EOL.PHP_EOL, @@ -384,7 +384,7 @@ public static function dataReportWidthIsRespected() 'Report width wide: 1000; delimiter line length should match longest line' => [ 'reportWidth' => 1000, 'expectedOutput' => $summaryLine.str_repeat('-', 666).PHP_EOL - .'- Fixtures.Deprecated.WithLongReplacement'.PHP_EOL + .'- TestStandard.Deprecated.WithLongReplacement'.PHP_EOL .' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vel vestibulum nunc. Sed luctus dolor tortor, eu euismod purus pretium sed. Fusce egestas congue massa semper cursus. Donec quis pretium tellus. In lacinia, augue ut ornare porttitor, diam nunc faucibus purus, et accumsan eros sapien at sem. Sed pulvinar aliquam malesuada. Aliquam erat volutpat. Mauris gravida rutrum lectus at egestas. Fusce tempus elit in tincidunt dictum. Suspendisse dictum egestas sapien, eget ullamcorper metus elementum semper. Vestibulum sem justo, consectetur ac tincidunt et, finibus eget libero.' .PHP_EOL.PHP_EOL .'Deprecated sniffs are still run, but will stop working at some point in the future.'.PHP_EOL.PHP_EOL, @@ -411,9 +411,9 @@ public function testDeprecatedSniffsAreListedAlphabetically() $expected = 'WARNING: The ShowSniffDeprecationsTest standard uses 2 deprecated sniffs'.PHP_EOL; $expected .= '--------------------------------------------------------------------------------'.PHP_EOL; - $expected .= '- Fixtures.Deprecated.WithoutReplacement'.PHP_EOL; + $expected .= '- TestStandard.Deprecated.WithoutReplacement'.PHP_EOL; $expected .= ' This sniff has been deprecated since v3.4.0 and will be removed in v4.0.0.'.PHP_EOL; - $expected .= '- Fixtures.Deprecated.WithReplacement'.PHP_EOL; + $expected .= '- TestStandard.Deprecated.WithReplacement'.PHP_EOL; $expected .= ' This sniff has been deprecated since v3.8.0 and will be removed in v4.0.0.'.PHP_EOL; $expected .= ' Use the Stnd.Category.OtherSniff sniff instead.'.PHP_EOL.PHP_EOL; $expected .= 'Deprecated sniffs are still run, but will stop working at some point in the'.PHP_EOL; @@ -426,12 +426,12 @@ public function testDeprecatedSniffsAreListedAlphabetically() // Verify that the sniffs have been registered to run. $this->assertCount(2, $ruleset->sniffCodes, 'Incorrect number of sniff codes registered'); $this->assertArrayHasKey( - 'Fixtures.Deprecated.WithoutReplacement', + 'TestStandard.Deprecated.WithoutReplacement', $ruleset->sniffCodes, 'WithoutReplacement sniff not registered' ); $this->assertArrayHasKey( - 'Fixtures.Deprecated.WithReplacement', + 'TestStandard.Deprecated.WithReplacement', $ruleset->sniffCodes, 'WithReplacement sniff not registered' ); @@ -484,23 +484,23 @@ public static function dataExceptionIsThrownOnIncorrectlyImplementedInterface() return [ 'getDeprecationVersion() does not return a string' => [ 'standard' => 'ShowSniffDeprecationsInvalidDeprecationVersionTest.xml', - 'exceptionMessage' => 'The Fixtures\Sniffs\DeprecatedInvalid\InvalidDeprecationVersionSniff::getDeprecationVersion() method must return a non-empty string, received double', + 'exceptionMessage' => 'The Fixtures\TestStandard\Sniffs\DeprecatedInvalid\InvalidDeprecationVersionSniff::getDeprecationVersion() method must return a non-empty string, received double', ], 'getRemovalVersion() does not return a string' => [ 'standard' => 'ShowSniffDeprecationsInvalidRemovalVersionTest.xml', - 'exceptionMessage' => 'The Fixtures\Sniffs\DeprecatedInvalid\InvalidRemovalVersionSniff::getRemovalVersion() method must return a non-empty string, received array', + 'exceptionMessage' => 'The Fixtures\TestStandard\Sniffs\DeprecatedInvalid\InvalidRemovalVersionSniff::getRemovalVersion() method must return a non-empty string, received array', ], 'getDeprecationMessage() does not return a string' => [ 'standard' => 'ShowSniffDeprecationsInvalidDeprecationMessageTest.xml', - 'exceptionMessage' => 'The Fixtures\Sniffs\DeprecatedInvalid\InvalidDeprecationMessageSniff::getDeprecationMessage() method must return a string, received object', + 'exceptionMessage' => 'The Fixtures\TestStandard\Sniffs\DeprecatedInvalid\InvalidDeprecationMessageSniff::getDeprecationMessage() method must return a string, received object', ], 'getDeprecationVersion() returns an empty string' => [ 'standard' => 'ShowSniffDeprecationsEmptyDeprecationVersionTest.xml', - 'exceptionMessage' => 'The Fixtures\Sniffs\DeprecatedInvalid\EmptyDeprecationVersionSniff::getDeprecationVersion() method must return a non-empty string, received ""', + 'exceptionMessage' => 'The Fixtures\TestStandard\Sniffs\DeprecatedInvalid\EmptyDeprecationVersionSniff::getDeprecationVersion() method must return a non-empty string, received ""', ], 'getRemovalVersion() returns an empty string' => [ 'standard' => 'ShowSniffDeprecationsEmptyRemovalVersionTest.xml', - 'exceptionMessage' => 'The Fixtures\Sniffs\DeprecatedInvalid\EmptyRemovalVersionSniff::getRemovalVersion() method must return a non-empty string, received ""', + 'exceptionMessage' => 'The Fixtures\TestStandard\Sniffs\DeprecatedInvalid\EmptyRemovalVersionSniff::getRemovalVersion() method must return a non-empty string, received ""', ], ]; diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml index 4665f439b5..38c7e02221 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml @@ -1,10 +1,10 @@ - + - - + + From 4e36c11f8e67d159ab24f9a31dd638140791fc31 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 16 Nov 2024 22:44:14 +0100 Subject: [PATCH 785/874] Ruleset: add tests for custom property type handling Add tests specifically aimed at testing the type handling of sniff properties set via a ruleset and via inline annotations. The current tests document the existing behaviour, which contains some oddities, but fixing these could be considered a breaking change, so should wait until PHPCS 4.0. --- tests/Core/Ruleset/ExplainTest.php | 9 +- .../Fixtures/PropertyTypeHandlingInline.inc | 26 ++ .../SetProperty/PropertyTypeHandlingSniff.php | 125 ++++++++++ .../PropertyTypeHandlingInlineTest.xml | 6 + .../Core/Ruleset/PropertyTypeHandlingTest.php | 234 ++++++++++++++++++ .../Core/Ruleset/PropertyTypeHandlingTest.xml | 44 ++++ 6 files changed, 440 insertions(+), 4 deletions(-) create mode 100644 tests/Core/Ruleset/Fixtures/PropertyTypeHandlingInline.inc create mode 100644 tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingSniff.php create mode 100644 tests/Core/Ruleset/PropertyTypeHandlingInlineTest.xml create mode 100644 tests/Core/Ruleset/PropertyTypeHandlingTest.php create mode 100644 tests/Core/Ruleset/PropertyTypeHandlingTest.xml diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index 48df24f473..db52b3cd22 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -185,10 +185,10 @@ public function testExplainWithDeprecatedSniffs() $ruleset = new Ruleset($config); $expected = PHP_EOL; - $expected .= 'The ShowSniffDeprecationsTest standard contains 9 sniffs'.PHP_EOL.PHP_EOL; + $expected .= 'The ShowSniffDeprecationsTest standard contains 10 sniffs'.PHP_EOL.PHP_EOL; - $expected .= 'TestStandard (9 sniffs)'.PHP_EOL; - $expected .= '-----------------------'.PHP_EOL; + $expected .= 'TestStandard (10 sniffs)'.PHP_EOL; + $expected .= '------------------------'.PHP_EOL; $expected .= ' TestStandard.Deprecated.WithLongReplacement *'.PHP_EOL; $expected .= ' TestStandard.Deprecated.WithoutReplacement *'.PHP_EOL; $expected .= ' TestStandard.Deprecated.WithReplacement *'.PHP_EOL; @@ -197,7 +197,8 @@ public function testExplainWithDeprecatedSniffs() $expected .= ' TestStandard.SetProperty.AllowedAsDeclared'.PHP_EOL; $expected .= ' TestStandard.SetProperty.AllowedViaMagicMethod'.PHP_EOL; $expected .= ' TestStandard.SetProperty.AllowedViaStdClass'.PHP_EOL; - $expected .= ' TestStandard.SetProperty.NotAllowedViaAttribute'.PHP_EOL.PHP_EOL; + $expected .= ' TestStandard.SetProperty.NotAllowedViaAttribute'.PHP_EOL; + $expected .= ' TestStandard.SetProperty.PropertyTypeHandling'.PHP_EOL.PHP_EOL; $expected .= '* Sniffs marked with an asterix are deprecated.'.PHP_EOL; diff --git a/tests/Core/Ruleset/Fixtures/PropertyTypeHandlingInline.inc b/tests/Core/Ruleset/Fixtures/PropertyTypeHandlingInline.inc new file mode 100644 index 0000000000..984f8cd2c2 --- /dev/null +++ b/tests/Core/Ruleset/Fixtures/PropertyTypeHandlingInline.inc @@ -0,0 +1,26 @@ +string,10=>10,float=>1.5,null=>null,true=>true,false=>false + +// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsOldSchoolArrayWithOnlyValues[] string, 10, 1.5, null, true, false +// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsOldSchoolArrayWithKeysAndValues[] string=>string,10=>10,float=>1.5,null=>null,true=>true,false=>false + +echo 'hello!'; diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingSniff.php new file mode 100644 index 0000000000..be4c2147db --- /dev/null +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingSniff.php @@ -0,0 +1,125 @@ + + */ + public $expectsArrayWithOnlyValues; + + /** + * Used to verify that array properties with keys get parsed to a proper array. + * + * @var array + */ + public $expectsArrayWithKeysAndValues; + + /** + * Used to verify that array properties passed as a string get parsed to a proper array. + * + * @var array + */ + public $expectsOldSchoolArrayWithOnlyValues; + + /** + * Used to verify that array properties passed as a string with keys get parsed to a proper array. + * + * @var array + */ + public $expectsOldSchoolArrayWithKeysAndValues; + + public function register() + { + return [T_ECHO]; + } + + public function process(File $phpcsFile, $stackPtr) + { + // Do something. + } +} diff --git a/tests/Core/Ruleset/PropertyTypeHandlingInlineTest.xml b/tests/Core/Ruleset/PropertyTypeHandlingInlineTest.xml new file mode 100644 index 0000000000..0bdadc7de0 --- /dev/null +++ b/tests/Core/Ruleset/PropertyTypeHandlingInlineTest.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/Core/Ruleset/PropertyTypeHandlingTest.php b/tests/Core/Ruleset/PropertyTypeHandlingTest.php new file mode 100644 index 0000000000..4c5cd516a7 --- /dev/null +++ b/tests/Core/Ruleset/PropertyTypeHandlingTest.php @@ -0,0 +1,234 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Files\LocalFile; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHPUnit\Framework\TestCase; + +/** + * Test the handling of property value types for properties set via the ruleset and inline. + * + * @covers \PHP_CodeSniffer\Ruleset::processRule + * @covers \PHP_CodeSniffer\Ruleset::setSniffProperty + */ +final class PropertyTypeHandlingTest extends TestCase +{ + + /** + * Sniff code for the sniff used in these tests. + * + * @var string + */ + const SNIFF_CODE = 'TestStandard.SetProperty.PropertyTypeHandling'; + + /** + * Class name of the sniff used in these tests. + * + * @var string + */ + const SNIFF_CLASS = 'Fixtures\\TestStandard\\Sniffs\\SetProperty\\PropertyTypeHandlingSniff'; + + + /** + * Test the value type handling for properties set via a ruleset. + * + * @param string $propertyName Property name. + * @param mixed $expected Expected property value. + * + * @dataProvider dataTypeHandling + * + * @return void + */ + public function testTypeHandlingWhenSetViaRuleset($propertyName, $expected) + { + $sniffObject = $this->getSniffObjectForRuleset(); + + $this->assertSame($expected, $sniffObject->$propertyName); + + }//end testTypeHandlingWhenSetViaRuleset() + + + /** + * Test the value type handling for properties set inline in a test case file. + * + * @param string $propertyName Property name. + * @param mixed $expected Expected property value. + * + * @dataProvider dataTypeHandling + * + * @return void + */ + public function testTypeHandlingWhenSetInline($propertyName, $expected) + { + $sniffObject = $this->getSniffObjectAfterProcessingFile(); + + $this->assertSame($expected, $sniffObject->$propertyName); + + }//end testTypeHandlingWhenSetInline() + + + /** + * Data provider. + * + * @see self::testTypeHandlingWhenSetViaRuleset() + * + * @return array> + */ + public static function dataTypeHandling() + { + $expectedArrayOnlyValues = [ + 'string', + '10', + '1.5', + 'null', + 'true', + 'false', + ]; + $expectedArrayKeysAndValues = [ + 'string' => 'string', + 10 => '10', + 'float' => '1.5', + 'null' => 'null', + 'true' => 'true', + 'false' => 'false', + ]; + + return [ + 'String value (default)' => [ + 'propertyName' => 'expectsString', + 'expected' => 'arbitraryvalue', + ], + 'String with whitespace only value becomes null' => [ + 'propertyName' => 'emptyStringBecomesNull', + 'expected' => null, + ], + 'Integer value gets set as string' => [ + 'propertyName' => 'expectsIntButAcceptsString', + 'expected' => '12345', + ], + 'Float value gets set as string' => [ + 'propertyName' => 'expectsFloatButAcceptsString', + 'expected' => '12.345', + ], + 'Null value gets set as string' => [ + 'propertyName' => 'expectsNull', + 'expected' => 'null', + ], + 'Null (uppercase) value gets set as string' => [ + 'propertyName' => 'expectsNullCase', + 'expected' => 'NULL', + ], + 'True value gets set as boolean' => [ + 'propertyName' => 'expectsBooleanTrue', + 'expected' => true, + ], + 'True (mixed case) value gets set as string' => [ + 'propertyName' => 'expectsBooleanTrueCase', + 'expected' => 'True', + ], + 'False value gets set as boolean' => [ + 'propertyName' => 'expectsBooleanFalse', + 'expected' => false, + ], + 'False (mixed case) value gets set as string' => [ + 'propertyName' => 'expectsBooleanFalseCase', + 'expected' => 'fALSe', + ], + 'Array with only values (new style)' => [ + 'propertyName' => 'expectsArrayWithOnlyValues', + 'expected' => $expectedArrayOnlyValues, + ], + 'Array with keys and values (new style)' => [ + 'propertyName' => 'expectsArrayWithKeysAndValues', + 'expected' => $expectedArrayKeysAndValues, + ], + 'Array with only values (old style)' => [ + 'propertyName' => 'expectsOldSchoolArrayWithOnlyValues', + 'expected' => $expectedArrayOnlyValues, + ], + 'Array with keys and values (old style)' => [ + 'propertyName' => 'expectsOldSchoolArrayWithKeysAndValues', + 'expected' => $expectedArrayKeysAndValues, + ], + ]; + + }//end dataTypeHandling() + + + /** + * Test Helper. + * + * @see self::testTypeHandlingWhenSetViaRuleset() + * + * @return \PHP_CodeSniffer\Sniffs\Sniff + */ + private function getSniffObjectForRuleset() + { + static $sniffObject; + + if (isset($sniffObject) === false) { + // Set up the ruleset. + $standard = __DIR__."/PropertyTypeHandlingTest.xml"; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + // Verify that our target sniff has been registered. + $this->assertArrayHasKey(self::SNIFF_CODE, $ruleset->sniffCodes, 'Target sniff not registered'); + $this->assertSame(self::SNIFF_CLASS, $ruleset->sniffCodes[self::SNIFF_CODE], 'Target sniff not registered with the correct class'); + $this->assertArrayHasKey(self::SNIFF_CLASS, $ruleset->sniffs, 'Sniff class not listed in registered sniffs'); + + $sniffObject = $ruleset->sniffs[self::SNIFF_CLASS]; + } + + return $sniffObject; + + }//end getSniffObjectForRuleset() + + + /** + * Test Helper + * + * @see self::testTypeHandlingWhenSetInline() + * + * @return \PHP_CodeSniffer\Sniffs\Sniff + */ + private function getSniffObjectAfterProcessingFile() + { + static $sniffObject; + + if (isset($sniffObject) === false) { + // Set up the ruleset. + $standard = __DIR__."/PropertyTypeHandlingInlineTest.xml"; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + // Verify that our target sniff has been registered. + $this->assertArrayHasKey(self::SNIFF_CODE, $ruleset->sniffCodes, 'Target sniff not registered'); + $this->assertSame(self::SNIFF_CLASS, $ruleset->sniffCodes[self::SNIFF_CODE], 'Target sniff not registered with the correct class'); + $this->assertArrayHasKey(self::SNIFF_CLASS, $ruleset->sniffs, 'Sniff class not listed in registered sniffs'); + + $sniffObject = $ruleset->sniffs[self::SNIFF_CLASS]; + + // Process the file with inline phpcs:set annotations. + $testFile = realpath(__DIR__.'/Fixtures/PropertyTypeHandlingInline.inc'); + $this->assertNotFalse($testFile); + + $phpcsFile = new LocalFile($testFile, $ruleset, $config); + $phpcsFile->process(); + } + + return $sniffObject; + + }//end getSniffObjectAfterProcessingFile() + + +}//end class diff --git a/tests/Core/Ruleset/PropertyTypeHandlingTest.xml b/tests/Core/Ruleset/PropertyTypeHandlingTest.xml new file mode 100644 index 0000000000..76817837e7 --- /dev/null +++ b/tests/Core/Ruleset/PropertyTypeHandlingTest.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From bed42db81566e9e25f62fffb974a62304aaef724 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 17 Nov 2024 18:56:15 +0100 Subject: [PATCH 786/874] Tests: set up mechanism to allow for testing CBF specific code See the description of how this works in the `CONTRIBUTING` file for more information. Includes adjustments to the GH Actions workflows to ensure the CBF specific tests are: * Always run for the `quicktest` and "normal" test runs. * Run for code coverage and that the code coverage reports are send in a way that they can be merged correctly. Includes adding a "requires CS mode" condition to a few tests which would otherwise fail in CBF mode. --- .github/CONTRIBUTING.md | 30 ++++++++++++ .github/workflows/quicktest.yml | 5 ++ .github/workflows/test.yml | 32 ++++++++++++- phpunit.xml.dist | 10 ++++ tests/Core/Generators/GeneratorTest.php | 4 ++ tests/Core/Ruleset/ExplainTest.php | 4 ++ .../Ruleset/ShowSniffDeprecationsTest.php | 48 +++++++++++++++++-- tests/bootstrap.php | 21 +++++++- 8 files changed, 147 insertions(+), 7 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 27b1aa42ba..8dd294c50c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -346,6 +346,36 @@ However, there are a few places which include OS-specific conditions, most notab Tests which cover code which have Windows specific conditions should be marked with a `@group Windows` annotation to allow for running those tests separately/selectively in CI. +#### Tests covering code which has CS/CBF specific behaviour + +There are a few places in PHPCS where code uses a global `PHP_CODESNIFFER_CBF` constant to determine what to do. +This makes testing this code more complicated. + +Tests which will only work correctly when `PHP_CODESNIFFER_CBF === false` should get the following test skip condition at the top of the test method: +```php +if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); +} +``` + +Tests which are specifically intended to cover code run when `PHP_CODESNIFFER_CBF === true` should: +1. Be annotated with `@group CBF`. +2. Have a test skip condition at the top of the test method like so: + ```php + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + ``` + +By default, the tests are run with the `PHP_CODESNIFFER_CBF` constant set to `false` and tests in the `@group CBF` will not be run. + +To run the tests specific to the use of `PHP_CODESNIFFER_CBF === true`: +1. Set `` in a `phpunit.xml` file or set the ENV variable on an OS-level. +2. Run the tests like so: + ```bash + vendor/bin/phpunit --group CBF --exclude-group nothing + ``` + ### Submitting Your Pull Request diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index ed24bec539..5edde2a41a 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -76,6 +76,11 @@ jobs: if: ${{ matrix.os == 'windows-latest' }} run: php "vendor/bin/phpunit" tests/AllTests.php --group Windows --no-coverage + - name: 'PHPUnit: run select tests in CBF mode' + run: php "vendor/bin/phpunit" tests/AllTests.php --group CBF --exclude-group nothing --no-coverage + env: + PHP_CODESNIFFER_CBF: '1' + # Note: The code style check is run as an integration test. - name: 'PHPCS: check code style without cache, no parallel' run: php "bin/phpcs" --no-cache --parallel=1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0113b7e8a7..e84fad9571 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -183,6 +183,11 @@ jobs: if: ${{ matrix.skip_tests != true }} run: php "vendor/bin/phpunit" tests/AllTests.php --no-coverage + - name: 'PHPUnit: run select tests in CBF mode' + run: php "vendor/bin/phpunit" tests/AllTests.php --group CBF --exclude-group nothing --no-coverage + env: + PHP_CODESNIFFER_CBF: '1' + - name: 'PHPCS: check code style without cache, no parallel' if: ${{ matrix.custom_ini == false && matrix.php != '7.4' }} run: php "bin/phpcs" --no-cache --parallel=1 @@ -311,6 +316,22 @@ jobs: if: ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }} run: php "vendor/bin/phpunit" tests/AllTests.php --coverage-cache ./build/phpunit-cache + - name: "Run select tests in CBF mode with code coverage (PHPUnit < 9.3)" + if: ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION < '9.3' }} + run: > + php "vendor/bin/phpunit" tests/AllTests.php + --group CBF --exclude-group nothing --coverage-clover build/logs/clover-cbf.xml + env: + PHP_CODESNIFFER_CBF: '1' + + - name: "Run select tests in CBF mode with code coverage (PHPUnit 9.3+)" + if: ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }} + run: > + php "vendor/bin/phpunit" tests/AllTests.php --coverage-cache ./build/phpunit-cache + --group CBF --exclude-group nothing --coverage-clover build/logs/clover-cbf.xml + env: + PHP_CODESNIFFER_CBF: '1' + - name: "Run the unit tests which may have different outcomes on Windows with code coverage (PHPUnit < 9.3)" if: ${{ matrix.os == 'windows-latest' && steps.phpunit_version.outputs.VERSION < '9.3' }} run: php "vendor/bin/phpunit" tests/AllTests.php --group Windows @@ -319,7 +340,7 @@ jobs: if: ${{ matrix.os == 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }} run: php "vendor/bin/phpunit" tests/AllTests.php --group Windows --coverage-cache ./build/phpunit-cache - - name: Upload coverage results to Coveralls + - name: "Upload coverage results to Coveralls (normal run)" if: ${{ success() }} uses: coverallsapp/github-action@v2 with: @@ -328,6 +349,15 @@ jobs: flag-name: os-${{ matrix.os }}-php-${{ matrix.php }}-custom-ini-${{ matrix.custom_ini }} parallel: true + - name: "Upload coverage results to Coveralls (CBF run)" + if: ${{ matrix.os != 'windows-latest' && success() }} + uses: coverallsapp/github-action@v2 + with: + format: clover + file: build/logs/clover-cbf.xml + flag-name: cbf-os-${{ matrix.os }}-ubuntu-latest-php-${{ matrix.php }}-custom-ini-${{ matrix.custom_ini }} + parallel: true + coveralls-finish: needs: coverage if: always() && needs.coverage.result == 'success' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1402588f20..cf2b588c86 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -18,6 +18,12 @@ + + + CBF + + + ./src @@ -32,4 +38,8 @@ + + + + diff --git a/tests/Core/Generators/GeneratorTest.php b/tests/Core/Generators/GeneratorTest.php index 30536518f6..441c499874 100644 --- a/tests/Core/Generators/GeneratorTest.php +++ b/tests/Core/Generators/GeneratorTest.php @@ -201,6 +201,10 @@ public static function dataGeneratingDocs() */ public function testGeneratorWillShowEachStandardSeparately() { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + $standard = __DIR__.'/OneDocTest.xml'; $_SERVER['argv'] = [ 'phpcs', diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index 48df24f473..4ec5b48317 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -217,6 +217,10 @@ public function testExplainWithDeprecatedSniffs() */ public function testExplainWillExplainEachStandardSeparately() { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + $standard = __DIR__.'/ExplainSingleSniffTest.xml'; $_SERVER['argv'] = [ 'phpcs', diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php index c31f7b4a83..2a36c34c65 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php +++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php @@ -67,7 +67,7 @@ public static function dataHasSniffDeprecations() /** - * Test that the listing with deprecated sniffs will not show when specific command-line options are being used. + * Test that the listing with deprecated sniffs will not show when specific command-line options are being used [1]. * * @param string $standard The standard to use for the test. * @param array $additionalArgs Optional. Additional arguments to pass. @@ -102,24 +102,62 @@ public function testDeprecatedSniffsListDoesNotShow($standard, $additionalArgs=[ public static function dataDeprecatedSniffsListDoesNotShow() { return [ - 'Standard not using deprecated sniffs: PSR1' => [ + 'Standard not using deprecated sniffs: PSR1' => [ 'standard' => 'PSR1', ], - 'Standard using deprecated sniffs; explain mode' => [ + 'Standard using deprecated sniffs; explain mode' => [ 'standard' => __DIR__.'/ShowSniffDeprecationsTest.xml', 'additionalArgs' => ['-e'], ], - 'Standard using deprecated sniffs; quiet mode' => [ + 'Standard using deprecated sniffs; quiet mode' => [ 'standard' => __DIR__.'/ShowSniffDeprecationsTest.xml', 'additionalArgs' => ['-q'], ], + ]; + + }//end dataDeprecatedSniffsListDoesNotShow() + + + /** + * Test that the listing with deprecated sniffs will not show when specific command-line options are being used [2]. + * + * {@internal Separate test method for the same thing as this test will only work in CS mode.} + * + * @param string $standard The standard to use for the test. + * @param array $additionalArgs Optional. Additional arguments to pass. + * + * @dataProvider dataDeprecatedSniffsListDoesNotShowNeedsCsMode + * + * @return void + */ + public function testDeprecatedSniffsListDoesNotShowNeedsCsMode($standard, $additionalArgs=[]) + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $this->testDeprecatedSniffsListDoesNotShow($standard, $additionalArgs); + + }//end testDeprecatedSniffsListDoesNotShowNeedsCsMode() + + + /** + * Data provider. + * + * @see testDeprecatedSniffsListDoesNotShowNeedsCsMode() + * + * @return array>> + */ + public static function dataDeprecatedSniffsListDoesNotShowNeedsCsMode() + { + return [ 'Standard using deprecated sniffs; documentation is requested' => [ 'standard' => __DIR__.'/ShowSniffDeprecationsTest.xml', 'additionalArgs' => ['--generator=text'], ], ]; - }//end dataDeprecatedSniffsListDoesNotShow() + }//end dataDeprecatedSniffsListDoesNotShowNeedsCsMode() /** diff --git a/tests/bootstrap.php b/tests/bootstrap.php index cf4936daa8..e8ebdbbdd0 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,8 +11,27 @@ define('PHP_CODESNIFFER_IN_TESTS', true); } +/* + * Determine whether the test suite should be run in CBF mode. + * + * Use `` in a `phpunit.xml` file + * or set the ENV variable at an OS-level to enable CBF mode. + * + * To run the CBF specific tests, use the following command: + * vendor/bin/phpunit --group CBF --exclude-group nothing + * + * If the ENV variable has not been set, or is set to "false", the tests will run in CS mode. + */ + if (defined('PHP_CODESNIFFER_CBF') === false) { - define('PHP_CODESNIFFER_CBF', false); + $cbfMode = getenv('PHP_CODESNIFFER_CBF'); + if ($cbfMode === '1') { + define('PHP_CODESNIFFER_CBF', true); + echo 'Note: Tests are running in "CBF" mode'.PHP_EOL.PHP_EOL; + } else { + define('PHP_CODESNIFFER_CBF', false); + echo 'Note: Tests are running in "CS" mode'.PHP_EOL.PHP_EOL; + } } if (defined('PHP_CODESNIFFER_VERBOSITY') === false) { From a25d8cf6770fea45ae0b86cb2375b39ac1b25411 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 19 Nov 2024 21:11:05 +0100 Subject: [PATCH 787/874] Tests/Ruleset: introduce an abstract base TestCase Introduce an abstract base TestCase with some helper methods specifically for tests testing aspects of the `Ruleset` class. --- .../Core/Ruleset/AbstractRulesetTestCase.php | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 tests/Core/Ruleset/AbstractRulesetTestCase.php diff --git a/tests/Core/Ruleset/AbstractRulesetTestCase.php b/tests/Core/Ruleset/AbstractRulesetTestCase.php new file mode 100644 index 0000000000..41c6394431 --- /dev/null +++ b/tests/Core/Ruleset/AbstractRulesetTestCase.php @@ -0,0 +1,115 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHPUnit\Framework\TestCase; + +abstract class AbstractRulesetTestCase extends TestCase +{ + + /** + * The fully qualified name of the PHPCS runtime exception class. + * + * @var string + */ + const RUNTIME_EXCEPTION = 'PHP_CodeSniffer\Exceptions\RuntimeException'; + + + /** + * Asserts that an object has a specified property in a PHPUnit cross-version compatible manner. + * + * @param string $propertyName The name of the property. + * @param object $object The object on which to check whether the property exists. + * @param string $message Optional failure message to display. + * + * @return void + */ + protected function assertXObjectHasProperty($propertyName, $object, $message='') + { + if (method_exists($this, 'assertObjectHasProperty') === true) { + $this->assertObjectHasProperty($propertyName, $object, $message); + } else { + // PHPUnit < 9.6.11. + $this->assertObjectHasAttribute($propertyName, $object, $message); + } + + }//end assertXObjectHasProperty() + + + /** + * Asserts that an object does not have a specified property + * in a PHPUnit cross-version compatible manner. + * + * @param string $propertyName The name of the property. + * @param object $object The object on which to check whether the property exists. + * @param string $message Optional failure message to display. + * + * @return void + */ + protected function assertXObjectNotHasProperty($propertyName, $object, $message='') + { + if (method_exists($this, 'assertObjectNotHasProperty') === true) { + $this->assertObjectNotHasProperty($propertyName, $object, $message); + } else { + // PHPUnit < 9.6.11. + $this->assertObjectNotHasAttribute($propertyName, $object, $message); + } + + }//end assertXObjectNotHasProperty() + + + /** + * Helper method to tell PHPUnit to expect a PHPCS RuntimeException with a certain message + * in a PHPUnit cross-version compatible manner. + * + * @param string $message The expected exception message. + * + * @return void + */ + protected function expectRuntimeExceptionMessage($message) + { + if (method_exists($this, 'expectException') === true) { + // PHPUnit 5+. + $this->expectException(self::RUNTIME_EXCEPTION); + $this->expectExceptionMessage($message); + } else { + // PHPUnit 4. + $this->setExpectedException(self::RUNTIME_EXCEPTION, $message); + } + + }//end expectRuntimeExceptionMessage() + + + /** + * Helper method to tell PHPUnit to expect a PHPCS RuntimeException which matches a regex patten + * in a PHPUnit cross-version compatible manner. + * + * @param string $regex The regex which should match. + * + * @return void + */ + protected function expectRuntimeExceptionRegex($regex) + { + if (method_exists($this, 'expectExceptionMessageMatches') === true) { + $this->expectException(self::RUNTIME_EXCEPTION); + $this->expectExceptionMessageMatches($regex); + } else if (method_exists($this, 'expectExceptionMessageRegExp') === true) { + // PHPUnit < 8.4.0. + $this->expectException(self::RUNTIME_EXCEPTION); + $this->expectExceptionMessageRegExp($regex); + } else { + // PHPUnit < 5.2.0. + $this->setExpectedExceptionRegExp(self::RUNTIME_EXCEPTION, $regex); + } + + }//end expectRuntimeExceptionRegex() + + +}//end class From db02f0d9935fde609c39fc35272871e2b904e326 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 19 Nov 2024 21:14:56 +0100 Subject: [PATCH 788/874] Tests/Ruleset: start using the new `AbstractRulesetTestCase` Start using the new `AbstractRulesetTestCase` in pre-existing `Ruleset` tests. --- tests/Core/Ruleset/RuleInclusionTest.php | 15 +++-------- tests/Core/Ruleset/SetSniffPropertyTest.php | 26 +++++-------------- .../Ruleset/ShowSniffDeprecationsTest.php | 14 +++------- 3 files changed, 13 insertions(+), 42 deletions(-) diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index 3f6a7180d6..e016a7ea1a 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -11,15 +11,14 @@ use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\ConfigDouble; -use PHPUnit\Framework\TestCase; -use ReflectionObject; +use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; /** * Tests for the \PHP_CodeSniffer\Ruleset class. * * @covers \PHP_CodeSniffer\Ruleset */ -final class RuleInclusionTest extends TestCase +final class RuleInclusionTest extends AbstractRulesetTestCase { /** @@ -352,10 +351,7 @@ public static function dataRegisteredSniffCodes() public function testSettingProperties($sniffClass, $propertyName, $expectedValue) { $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs); - - $hasProperty = (new ReflectionObject(self::$ruleset->sniffs[$sniffClass]))->hasProperty($propertyName); - $errorMsg = sprintf('Property %s does not exist on sniff class %s', $propertyName, $sniffClass); - $this->assertTrue($hasProperty, $errorMsg); + $this->assertXObjectHasProperty($propertyName, self::$ruleset->sniffs[$sniffClass]); $actualValue = self::$ruleset->sniffs[$sniffClass]->$propertyName; $this->assertSame($expectedValue, $actualValue); @@ -444,10 +440,7 @@ public static function dataSettingProperties() public function testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails($sniffClass, $propertyName) { $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs, 'Sniff class '.$sniffClass.' not listed in registered sniffs'); - - $hasProperty = (new ReflectionObject(self::$ruleset->sniffs[$sniffClass]))->hasProperty($propertyName); - $errorMsg = sprintf('Property %s registered for sniff %s which does not support it', $propertyName, $sniffClass); - $this->assertFalse($hasProperty, $errorMsg); + $this->assertXObjectNotHasProperty($propertyName, self::$ruleset->sniffs[$sniffClass]); }//end testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails() diff --git a/tests/Core/Ruleset/SetSniffPropertyTest.php b/tests/Core/Ruleset/SetSniffPropertyTest.php index 51bd0e2989..ed902b9084 100644 --- a/tests/Core/Ruleset/SetSniffPropertyTest.php +++ b/tests/Core/Ruleset/SetSniffPropertyTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\ConfigDouble; -use PHPUnit\Framework\TestCase; +use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; use ReflectionObject; /** @@ -19,7 +19,7 @@ * * @covers \PHP_CodeSniffer\Ruleset::setSniffProperty */ -final class SetSniffPropertyTest extends TestCase +final class SetSniffPropertyTest extends AbstractRulesetTestCase { @@ -135,15 +135,8 @@ public function testSetPropertyAppliesPropertyToMultipleSniffsInCategory() */ public function testSetPropertyThrowsErrorOnInvalidProperty() { - $exceptionClass = 'PHP_CodeSniffer\Exceptions\RuntimeException'; - $exceptionMsg = 'Ruleset invalid. Property "indentation" does not exist on sniff Generic.Arrays.ArrayIndent'; - if (method_exists($this, 'expectException') === true) { - $this->expectException($exceptionClass); - $this->expectExceptionMessage($exceptionMsg); - } else { - // PHPUnit < 5.2.0. - $this->setExpectedException($exceptionClass, $exceptionMsg); - } + $exceptionMsg = 'Ruleset invalid. Property "indentation" does not exist on sniff Generic.Arrays.ArrayIndent'; + $this->expectRuntimeExceptionMessage($exceptionMsg); // Set up the ruleset. $standard = __DIR__.'/SetPropertyThrowsErrorOnInvalidPropertyTest.xml'; @@ -162,15 +155,8 @@ public function testSetPropertyThrowsErrorOnInvalidProperty() */ public function testSetPropertyThrowsErrorWhenPropertyOnlyAllowedViaAttribute() { - $exceptionClass = 'PHP_CodeSniffer\Exceptions\RuntimeException'; - $exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff TestStandard.SetProperty.NotAllowedViaAttribute'; - if (method_exists($this, 'expectException') === true) { - $this->expectException($exceptionClass); - $this->expectExceptionMessage($exceptionMsg); - } else { - // PHPUnit < 5.2.0. - $this->setExpectedException($exceptionClass, $exceptionMsg); - } + $exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff TestStandard.SetProperty.NotAllowedViaAttribute'; + $this->expectRuntimeExceptionMessage($exceptionMsg); // Set up the ruleset. $standard = __DIR__.'/SetPropertyNotAllowedViaAttributeTest.xml'; diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php index c31f7b4a83..0c142d9772 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsTest.php +++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.php @@ -11,7 +11,7 @@ use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\ConfigDouble; -use PHPUnit\Framework\TestCase; +use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; /** * Tests PHPCS native handling of sniff deprecations. @@ -19,7 +19,7 @@ * @covers \PHP_CodeSniffer\Ruleset::hasSniffDeprecations * @covers \PHP_CodeSniffer\Ruleset::showSniffDeprecations */ -final class ShowSniffDeprecationsTest extends TestCase +final class ShowSniffDeprecationsTest extends AbstractRulesetTestCase { @@ -452,15 +452,7 @@ public function testDeprecatedSniffsAreListedAlphabetically() */ public function testExceptionIsThrownOnIncorrectlyImplementedInterface($standard, $exceptionMessage) { - $exception = 'PHP_CodeSniffer\Exceptions\RuntimeException'; - if (method_exists($this, 'expectException') === true) { - // PHPUnit 5+. - $this->expectException($exception); - $this->expectExceptionMessage($exceptionMessage); - } else { - // PHPUnit 4. - $this->setExpectedException($exception, $exceptionMessage); - } + $this->expectRuntimeExceptionMessage($exceptionMessage); // Set up the ruleset. $standard = __DIR__.'/'.$standard; From b5a81c6a08ae46855c4fdef0df191137562f9a3f Mon Sep 17 00:00:00 2001 From: Juliette <663378+jrfnl@users.noreply.github.com> Date: Fri, 22 Nov 2024 20:01:54 +0100 Subject: [PATCH 789/874] Ruleset::getIgnorePatterns(): add tests (#705) --- tests/Core/Ruleset/GetIgnorePatternsTest.php | 111 +++++++++++++++++++ tests/Core/Ruleset/GetIgnorePatternsTest.xml | 19 ++++ 2 files changed, 130 insertions(+) create mode 100644 tests/Core/Ruleset/GetIgnorePatternsTest.php create mode 100644 tests/Core/Ruleset/GetIgnorePatternsTest.xml diff --git a/tests/Core/Ruleset/GetIgnorePatternsTest.php b/tests/Core/Ruleset/GetIgnorePatternsTest.php new file mode 100644 index 0000000000..ae6b8bea50 --- /dev/null +++ b/tests/Core/Ruleset/GetIgnorePatternsTest.php @@ -0,0 +1,111 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHPUnit\Framework\TestCase; + +/** + * Test the Ruleset::getIgnorePatterns() method. + * + * @covers \PHP_CodeSniffer\Ruleset::getIgnorePatterns + */ +final class GetIgnorePatternsTest extends TestCase +{ + + /** + * The Ruleset object. + * + * @var \PHP_CodeSniffer\Ruleset + */ + private static $ruleset; + + + /** + * Initialize the config and ruleset objects for this test. + * + * @beforeClass + * + * @return void + */ + public static function initializeConfigAndRuleset() + { + // Set up the ruleset. + $standard = __DIR__."/GetIgnorePatternsTest.xml"; + $config = new ConfigDouble(["--standard=$standard"]); + self::$ruleset = new Ruleset($config); + + }//end initializeConfigAndRuleset() + + + /** + * Test retrieving ignore patterns. + * + * @param string|null $listener The listener to get patterns for or null for all patterns. + * @param array> $expected The expected function output. + * + * @dataProvider dataGetIgnorePatterns + * + * @return void + */ + public function testGetIgnorePatterns($listener, $expected) + { + $this->assertSame($expected, self::$ruleset->getIgnorePatterns($listener)); + + }//end testGetIgnorePatterns() + + + /** + * Data provider. + * + * @see self::testGetIgnorePatterns() + * + * @return array>|null>> + */ + public static function dataGetIgnorePatterns() + { + return [ + 'All ignore patterns' => [ + 'listener' => null, + 'expected' => [ + 'PSR1.Classes.ClassDeclaration' => [ + './src/*/file.php' => 'absolute', + './bin/' => 'relative', + ], + 'Generic.Formatting.SpaceAfterCast' => [ + './src/*/test\\.php$' => 'absolute', + ], + './tests/' => 'absolute', + './vendor/*' => 'absolute', + '*/node-modules/*' => 'relative', + ], + ], + 'Ignore patterns for PSR1.Classes.ClassDeclaration' => [ + 'listener' => 'PSR1.Classes.ClassDeclaration', + 'expected' => [ + './src/*/file.php' => 'absolute', + './bin/' => 'relative', + ], + ], + 'Ignore patterns for Generic.Formatting.SpaceAfterCast' => [ + 'listener' => 'Generic.Formatting.SpaceAfterCast', + 'expected' => ['./src/*/test\\.php$' => 'absolute'], + ], + 'Ignore patterns for sniff without ignore patterns' => [ + 'listener' => 'PSR1.Files.SideEffects', + 'expected' => [], + ], + ]; + + }//end dataGetIgnorePatterns() + + +}//end class diff --git a/tests/Core/Ruleset/GetIgnorePatternsTest.xml b/tests/Core/Ruleset/GetIgnorePatternsTest.xml new file mode 100644 index 0000000000..7fcfdc237d --- /dev/null +++ b/tests/Core/Ruleset/GetIgnorePatternsTest.xml @@ -0,0 +1,19 @@ + + + + ./tests/ + ./vendor/* + */node-modules/* + + + + + ./src/*/file.php + ./bin/ + + + + ./src/*/test\.php$ + + + From a480170b38aca33442f11edbb7d4ee18af17475c Mon Sep 17 00:00:00 2001 From: Juliette <663378+jrfnl@users.noreply.github.com> Date: Fri, 22 Nov 2024 20:21:53 +0100 Subject: [PATCH 790/874] Ruleset::getIncludePatterns(): add tests (#706) --- tests/Core/Ruleset/GetIncludePatternsTest.php | 108 ++++++++++++++++++ tests/Core/Ruleset/GetIncludePatternsTest.xml | 15 +++ 2 files changed, 123 insertions(+) create mode 100644 tests/Core/Ruleset/GetIncludePatternsTest.php create mode 100644 tests/Core/Ruleset/GetIncludePatternsTest.xml diff --git a/tests/Core/Ruleset/GetIncludePatternsTest.php b/tests/Core/Ruleset/GetIncludePatternsTest.php new file mode 100644 index 0000000000..a38401b614 --- /dev/null +++ b/tests/Core/Ruleset/GetIncludePatternsTest.php @@ -0,0 +1,108 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHPUnit\Framework\TestCase; + +/** + * Test the Ruleset::getIncludePatterns() method. + * + * @covers \PHP_CodeSniffer\Ruleset::getIncludePatterns + */ +final class GetIncludePatternsTest extends TestCase +{ + + /** + * The Ruleset object. + * + * @var \PHP_CodeSniffer\Ruleset + */ + private static $ruleset; + + + /** + * Initialize the config and ruleset objects for this test. + * + * @beforeClass + * + * @return void + */ + public static function initializeConfigAndRuleset() + { + // Set up the ruleset. + $standard = __DIR__."/GetIncludePatternsTest.xml"; + $config = new ConfigDouble(["--standard=$standard"]); + self::$ruleset = new Ruleset($config); + + }//end initializeConfigAndRuleset() + + + /** + * Test retrieving include patterns. + * + * @param string|null $listener The listener to get patterns for or null for all patterns. + * @param array> $expected The expected function output. + * + * @dataProvider dataGetIncludePatterns + * + * @return void + */ + public function testGetIncludePatterns($listener, $expected) + { + $this->assertSame($expected, self::$ruleset->getIncludePatterns($listener)); + + }//end testGetIncludePatterns() + + + /** + * Data provider. + * + * @see self::testGetIncludePatterns() + * + * @return array>|null>> + */ + public static function dataGetIncludePatterns() + { + return [ + 'All include patterns' => [ + 'listener' => null, + 'expected' => [ + 'PSR1.Classes.ClassDeclaration' => [ + './src/*/file.php' => 'absolute', + './bin/' => 'relative', + ], + 'Generic.Formatting.SpaceAfterCast' => [ + './src/*/test\\.php$' => 'absolute', + ], + ], + ], + 'Include patterns for PSR1.Classes.ClassDeclaration' => [ + 'listener' => 'PSR1.Classes.ClassDeclaration', + 'expected' => [ + './src/*/file.php' => 'absolute', + './bin/' => 'relative', + ], + ], + 'Include patterns for Generic.Formatting.SpaceAfterCast' => [ + 'listener' => 'Generic.Formatting.SpaceAfterCast', + 'expected' => ['./src/*/test\\.php$' => 'absolute'], + ], + 'Include patterns for sniff without include patterns' => [ + 'listener' => 'PSR1.Files.SideEffects', + 'expected' => [], + ], + ]; + + }//end dataGetIncludePatterns() + + +}//end class diff --git a/tests/Core/Ruleset/GetIncludePatternsTest.xml b/tests/Core/Ruleset/GetIncludePatternsTest.xml new file mode 100644 index 0000000000..c24f93f548 --- /dev/null +++ b/tests/Core/Ruleset/GetIncludePatternsTest.xml @@ -0,0 +1,15 @@ + + + + + + + ./src/*/file.php + ./bin/ + + + + ./src/*/test\.php$ + + + From 9ed4ae8a9349f0319f5db9b76e9234c824926d5b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 22 Nov 2024 20:43:16 +0100 Subject: [PATCH 791/874] GH Actions/test: allow concurrency for build against "main" branches The `concurrency` setting will cancel running workflows is a new push to the same branch is seen. This is useful to prevent unnecessary workflow runs (as the previous push was superseded, so the outcome is no longer relevant). However, for the "main" branches (`master` and `4.0`), this workflow cancelling means that if multiple PRs are merged in succession, only the code coverage for the _last_ merge is recorded in Coveralls as the workflow runs on `master` for the previous merges will have been cancelled. While in practice, it's not a biggie, it does make it more difficult to identify which commit/merge added or decreased code coverage. With this in mind, I'm making a small change to the `concurrency` setting for the `test` workflow only to allow those to always finish when the workflow is run for the "main" branches. --- .github/workflows/test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e84fad9571..1ea04c9384 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,11 +14,13 @@ on: # Allow manually triggering the workflow. workflow_dispatch: -# Cancels all previous workflow runs for the same branch that have not yet completed. +# Cancels all previous workflow runs for the same branch that have not yet completed, +# but don't cancel when it's one of the "main" branches as that prevents +# accurate monitoring of code coverage. concurrency: # The concurrency group contains the workflow name and the branch name. group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: ${{ github.ref_name != 'master' && github.ref_name != '4.0' }} jobs: build: From 8b8aa2e4b11fb60ddea76fae6d2a6b5fbcffa8f8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Nov 2024 00:03:59 +0100 Subject: [PATCH 792/874] Generators: add tests for handling documentation titles This adds dedicated tests for specific issues which can be encountered with the `title` attribute for `` elements. This initial set of tests for this documents the current behaviour. This behaviour may not always be the desired behaviour, in which case, this will be fixed in follow-up commits. --- tests/Core/Generators/AllValidDocsTest.xml | 10 +++ .../ExpectedOutputDocumentationTitleCase.html | 78 +++++++++++++++++++ .../ExpectedOutputDocumentationTitleCase.md | 6 ++ .../ExpectedOutputDocumentationTitleCase.txt | 7 ++ ...xpectedOutputDocumentationTitleLength.html | 78 +++++++++++++++++++ .../ExpectedOutputDocumentationTitleLength.md | 6 ++ ...ExpectedOutputDocumentationTitleLength.txt | 7 ++ .../DocumentationTitleCaseStandard.xml | 7 ++ .../DocumentationTitleLengthStandard.xml | 7 ++ .../Content/DocumentationTitleCaseSniff.php | 12 +++ .../Content/DocumentationTitleLengthSniff.php | 12 +++ tests/Core/Generators/HTMLTest.php | 61 +++++++++++++++ tests/Core/Generators/MarkdownTest.php | 61 +++++++++++++++ tests/Core/Generators/TextTest.php | 61 +++++++++++++++ 14 files changed, 413 insertions(+) create mode 100644 tests/Core/Generators/AllValidDocsTest.xml create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.txt create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/DocumentationTitleCaseStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/DocumentationTitleLengthStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/DocumentationTitleCaseSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/DocumentationTitleLengthSniff.php diff --git a/tests/Core/Generators/AllValidDocsTest.xml b/tests/Core/Generators/AllValidDocsTest.xml new file mode 100644 index 0000000000..71a0c7f7a5 --- /dev/null +++ b/tests/Core/Generators/AllValidDocsTest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.html b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.html new file mode 100644 index 0000000000..98184e1e85 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.html @@ -0,0 +1,78 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    +
    +

    lowercase title

    +

    This is a standard block.

    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.md b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.md new file mode 100644 index 0000000000..d0464a4efa --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.md @@ -0,0 +1,6 @@ +# GeneratorTest Coding Standard + +## lowercase title +This is a standard block. + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.txt b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.txt new file mode 100644 index 0000000000..c762a01d96 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.txt @@ -0,0 +1,7 @@ + +-------------------------------------------------- +| GENERATORTEST CODING STANDARD: LOWERCASE TITLE | +-------------------------------------------------- + +This is a standard block. + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.html b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.html new file mode 100644 index 0000000000..e94beac1ca --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.html @@ -0,0 +1,78 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    This is a very very very very very very very very very very very long title

    +

    This is a standard block.

    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.md b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.md new file mode 100644 index 0000000000..29f5972a7c --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.md @@ -0,0 +1,6 @@ +# GeneratorTest Coding Standard + +## This is a very very very very very very very very very very very long title +This is a standard block. + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.txt b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.txt new file mode 100644 index 0000000000..2787b8cdfe --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.txt @@ -0,0 +1,7 @@ + +-------------------------------------------------------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: THIS IS A VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY LONG TITLE | +-------------------------------------------------------------------------------------------------------------- + +This is a standard block. + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/DocumentationTitleCaseStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/DocumentationTitleCaseStandard.xml new file mode 100644 index 0000000000..a4078e3dee --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/DocumentationTitleCaseStandard.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/DocumentationTitleLengthStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/DocumentationTitleLengthStandard.xml new file mode 100644 index 0000000000..2448927640 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/DocumentationTitleLengthStandard.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/DocumentationTitleCaseSniff.php b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/DocumentationTitleCaseSniff.php new file mode 100644 index 0000000000..09ffdac68e --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/DocumentationTitleCaseSniff.php @@ -0,0 +1,12 @@ + true]; + $ruleset->registerSniffs([$sniffFile], $restrictions, []); + + $expected = file_get_contents($pathToExpected); + $this->assertNotFalse($expected, 'Output expectation file could not be found'); + + // Make the test OS independent. + $expected = str_replace("\n", PHP_EOL, $expected); + $this->expectOutputString($expected); + + $generator = new HTMLDouble($ruleset); + $generator->generate(); + + }//end testDocSpecifics() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataDocSpecifics() + { + return [ + 'Documentation title: case' => [ + 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleCase', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleCase.html', + ], + 'Documentation title: length' => [ + 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleLength', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleLength.html', + ], + ]; + + }//end dataDocSpecifics() + + /** * Test the generated footer. * diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index 0610678dbe..b7ba2f5fb1 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -77,6 +77,67 @@ public static function dataDocs() }//end dataDocs() + /** + * Test the generated docs for the handling of specific parts of the documentation. + * + * @param string $sniffs The specific fixture sniffs to verify the docs for. + * @param string $pathToExpected Path to a file containing the expected function output. + * + * @dataProvider dataDocSpecifics + * + * @return void + */ + public function testDocSpecifics($sniffs, $pathToExpected) + { + // Set up the ruleset. + $standard = __DIR__.'/AllValidDocsTest.xml'; + $config = new ConfigDouble(["--standard=$standard", "--sniffs=$sniffs"]); + $ruleset = new Ruleset($config); + + // In tests, the `--sniffs` setting doesn't work out of the box. + $sniffParts = explode('.', $sniffs); + $sniffFile = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.$sniffParts[0].DIRECTORY_SEPARATOR; + $sniffFile .= 'Sniffs'.DIRECTORY_SEPARATOR.$sniffParts[1].DIRECTORY_SEPARATOR.$sniffParts[2].'Sniff.php'; + + $sniffParts = array_map('strtolower', $sniffParts); + $sniffName = $sniffParts[0].'\sniffs\\'.$sniffParts[1].'\\'.$sniffParts[2].'sniff'; + $restrictions = [$sniffName => true]; + $ruleset->registerSniffs([$sniffFile], $restrictions, []); + + $expected = file_get_contents($pathToExpected); + $this->assertNotFalse($expected, 'Output expectation file could not be found'); + + // Make the test OS independent. + $expected = str_replace("\n", PHP_EOL, $expected); + $this->expectOutputString($expected); + + $generator = new MarkdownDouble($ruleset); + $generator->generate(); + + }//end testDocSpecifics() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataDocSpecifics() + { + return [ + 'Documentation title: case' => [ + 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleCase', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleCase.md', + ], + 'Documentation title: length' => [ + 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleLength', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleLength.md', + ], + ]; + + }//end dataDocSpecifics() + + /** * Test the generated footer. * diff --git a/tests/Core/Generators/TextTest.php b/tests/Core/Generators/TextTest.php index 40544557f2..f571aff71d 100644 --- a/tests/Core/Generators/TextTest.php +++ b/tests/Core/Generators/TextTest.php @@ -77,4 +77,65 @@ public static function dataDocs() }//end dataDocs() + /** + * Test the generated docs for the handling of specific parts of the documentation. + * + * @param string $sniffs The specific fixture sniffs to verify the docs for. + * @param string $pathToExpected Path to a file containing the expected function output. + * + * @dataProvider dataDocSpecifics + * + * @return void + */ + public function testDocSpecifics($sniffs, $pathToExpected) + { + // Set up the ruleset. + $standard = __DIR__.'/AllValidDocsTest.xml'; + $config = new ConfigDouble(["--standard=$standard", "--sniffs=$sniffs"]); + $ruleset = new Ruleset($config); + + // In tests, the `--sniffs` setting doesn't work out of the box. + $sniffParts = explode('.', $sniffs); + $sniffFile = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.$sniffParts[0].DIRECTORY_SEPARATOR; + $sniffFile .= 'Sniffs'.DIRECTORY_SEPARATOR.$sniffParts[1].DIRECTORY_SEPARATOR.$sniffParts[2].'Sniff.php'; + + $sniffParts = array_map('strtolower', $sniffParts); + $sniffName = $sniffParts[0].'\sniffs\\'.$sniffParts[1].'\\'.$sniffParts[2].'sniff'; + $restrictions = [$sniffName => true]; + $ruleset->registerSniffs([$sniffFile], $restrictions, []); + + $expected = file_get_contents($pathToExpected); + $this->assertNotFalse($expected, 'Output expectation file could not be found'); + + // Make the test OS independent. + $expected = str_replace("\n", PHP_EOL, $expected); + $this->expectOutputString($expected); + + $generator = new Text($ruleset); + $generator->generate(); + + }//end testDocSpecifics() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataDocSpecifics() + { + return [ + 'Documentation title: case' => [ + 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleCase', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleCase.txt', + ], + 'Documentation title: length' => [ + 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleLength', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleLength.txt', + ], + ]; + + }//end dataDocSpecifics() + + }//end class From 3f33a50bc30ad101c79cce94a7395ea6556062c3 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Nov 2024 09:57:22 +0100 Subject: [PATCH 793/874] Generators: add tests for handling element This adds dedicated tests for specific issues which can be encountered in a `` XML element. This initial set of tests for this documents the current behaviour. This behaviour may not always be the desired behaviour, in which case, this will be fixed in follow-up commits. --- .../ExpectedOutputStandardBlankLines.html | 82 +++++++++++++++++++ .../ExpectedOutputStandardBlankLines.md | 10 +++ .../ExpectedOutputStandardBlankLines.txt | 11 +++ .../ExpectedOutputStandardEncoding.html | 79 ++++++++++++++++++ .../ExpectedOutputStandardEncoding.md | 7 ++ .../ExpectedOutputStandardEncoding.txt | 9 ++ .../ExpectedOutputStandardIndent.html | 81 ++++++++++++++++++ .../ExpectedOutputStandardIndent.md | 9 ++ .../ExpectedOutputStandardIndent.txt | 10 +++ .../ExpectedOutputStandardLineWrapping.html | 80 ++++++++++++++++++ .../ExpectedOutputStandardLineWrapping.md | 8 ++ .../ExpectedOutputStandardLineWrapping.txt | 11 +++ .../Content/StandardBlankLinesStandard.xml | 13 +++ .../Docs/Content/StandardEncodingStandard.xml | 8 ++ .../Docs/Content/StandardIndentStandard.xml | 10 +++ .../Content/StandardLineWrappingStandard.xml | 9 ++ .../Content/StandardBlankLinesSniff.php | 12 +++ .../Sniffs/Content/StandardEncodingSniff.php | 12 +++ .../Sniffs/Content/StandardIndentSniff.php | 12 +++ .../Content/StandardLineWrappingSniff.php | 12 +++ tests/Core/Generators/HTMLTest.php | 20 ++++- tests/Core/Generators/MarkdownTest.php | 20 ++++- tests/Core/Generators/TextTest.php | 20 ++++- 23 files changed, 539 insertions(+), 6 deletions(-) create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.txt create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardBlankLinesStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardEncodingStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardIndentStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardLineWrappingStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/StandardBlankLinesSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/StandardEncodingSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/StandardIndentSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/StandardLineWrappingSniff.php diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.html b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.html new file mode 100644 index 0000000000..5c6539d0ca --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.html @@ -0,0 +1,82 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Standard Element, blank line handling

    +

    There is a blank line at the start of this standard. + + And the above blank line is also deliberate to test part of the logic. + + Let's also end on a blank line to test that too.

    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md new file mode 100644 index 0000000000..43ba99d2db --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md @@ -0,0 +1,10 @@ +# GeneratorTest Coding Standard + +## Standard Element, blank line handling +There is a blank line at the start of this standard. + + And the above blank line is also deliberate to test part of the logic. + + Let's also end on a blank line to test that too. + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.txt b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.txt new file mode 100644 index 0000000000..1cdad0b11a --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.txt @@ -0,0 +1,11 @@ + +------------------------------------------------------------------------ +| GENERATORTEST CODING STANDARD: STANDARD ELEMENT, BLANK LINE HANDLING | +------------------------------------------------------------------------ + +There is a blank line at the start of this standard. + +And the above blank line is also deliberate to test part of the logic. + +Let's also end on a blank line to test that too. + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.html b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.html new file mode 100644 index 0000000000..5b1c8ca3c3 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.html @@ -0,0 +1,79 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Standard Element, handling of HTML tags

    +

    The use of tags in standard descriptions is allowed and their handling should be safeguarded. + Other tags, like <a href="example.com">link</a>, <b>bold</bold>, <script></script> are not allowed and will be encoded for display when the HTML or Markdown report is used.

    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md new file mode 100644 index 0000000000..f04de7f096 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md @@ -0,0 +1,7 @@ +# GeneratorTest Coding Standard + +## Standard Element, handling of HTML tags +The use of *tags* in standard descriptions is allowed and their handling should be *safeguarded*. + Other tags, like <a href="example.com">link</a>, <b>bold</bold>, <script></script> are not allowed and will be encoded for display when the HTML or Markdown report is used. + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.txt b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.txt new file mode 100644 index 0000000000..a464b86e29 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.txt @@ -0,0 +1,9 @@ + +-------------------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: STANDARD ELEMENT, HANDLING OF HTML TAGS | +-------------------------------------------------------------------------- + +The use of *tags* in standard descriptions is allowed and their handling should be *safeguarded*. +Other tags, like link, bold, are not allowed +and will be encoded for display when the HTML or Markdown report is used. + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.html b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.html new file mode 100644 index 0000000000..4c4bcb54ac --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.html @@ -0,0 +1,81 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Standard Element, indentation should be ignored

    +

    This line has no indentation. + This line has 4 spaces indentation. + This line has 8 spaces indentation. + This line has 4 spaces indentation.

    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md new file mode 100644 index 0000000000..77c7244a12 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md @@ -0,0 +1,9 @@ +# GeneratorTest Coding Standard + +## Standard Element, indentation should be ignored +This line has no indentation. + This line has 4 spaces indentation. + This line has 8 spaces indentation. + This line has 4 spaces indentation. + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.txt b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.txt new file mode 100644 index 0000000000..fef00b9dc9 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.txt @@ -0,0 +1,10 @@ + +---------------------------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: STANDARD ELEMENT, INDENTATION SHOULD BE IGNORED | +---------------------------------------------------------------------------------- + +This line has no indentation. +This line has 4 spaces indentation. +This line has 8 spaces indentation. +This line has 4 spaces indentation. + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.html b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.html new file mode 100644 index 0000000000..8ca982efc1 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.html @@ -0,0 +1,80 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Standard Element, line wrapping handling

    +

    This line has to be exactly 99 chars to test part of the logic.------------------------------------ + And this line has to be exactly 100 chars.---------------------------------------------------------- + And here we have a line which should start wrapping as it is longer than 100 chars. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pellentesque iaculis enim quis hendrerit. Morbi ultrices in odio pharetra commodo.

    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md new file mode 100644 index 0000000000..68703400cc --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md @@ -0,0 +1,8 @@ +# GeneratorTest Coding Standard + +## Standard Element, line wrapping handling +This line has to be exactly 99 chars to test part of the logic.------------------------------------ + And this line has to be exactly 100 chars.---------------------------------------------------------- + And here we have a line which should start wrapping as it is longer than 100 chars. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pellentesque iaculis enim quis hendrerit. Morbi ultrices in odio pharetra commodo. + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.txt b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.txt new file mode 100644 index 0000000000..6f09fbe335 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.txt @@ -0,0 +1,11 @@ + +--------------------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: STANDARD ELEMENT, LINE WRAPPING HANDLING | +--------------------------------------------------------------------------- + +This line has to be exactly 99 chars to test part of the logic.------------------------------------ +And this line has to be exactly 100 chars.---------------------------------------------------------- +And here we have a line which should start wrapping as it is longer than 100 chars. Lorem ipsum +dolor sit amet, consectetur adipiscing elit. Aenean pellentesque iaculis enim quis hendrerit. Morbi +ultrices in odio pharetra commodo. + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardBlankLinesStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardBlankLinesStandard.xml new file mode 100644 index 0000000000..10c47bf46a --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardBlankLinesStandard.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardEncodingStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardEncodingStandard.xml new file mode 100644 index 0000000000..3e34c3f9f7 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardEncodingStandard.xml @@ -0,0 +1,8 @@ + + + tags in standard descriptions is allowed and their handling should be safeguarded. + Other tags, like link, bold, are not allowed and will be encoded for display when the HTML or Markdown report is used. + ]]> + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardIndentStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardIndentStandard.xml new file mode 100644 index 0000000000..b2ec6c5e3c --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardIndentStandard.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardLineWrappingStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardLineWrappingStandard.xml new file mode 100644 index 0000000000..66bbb96275 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/StandardLineWrappingStandard.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/StandardBlankLinesSniff.php b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/StandardBlankLinesSniff.php new file mode 100644 index 0000000000..dfd4b57001 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/StandardBlankLinesSniff.php @@ -0,0 +1,12 @@ + [ + 'Documentation title: case' => [ 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleCase', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleCase.html', ], - 'Documentation title: length' => [ + 'Documentation title: length' => [ 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleLength', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleLength.html', ], + 'Standard Element: blank line handling' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardBlankLines', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardBlankLines.html', + ], + 'Standard Element: encoding of special characters' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardEncoding', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardEncoding.html', + ], + 'Standard Element: indent handling' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardIndent', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardIndent.html', + ], + 'Standard Element: line wrapping' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.html', + ], ]; }//end dataDocSpecifics() diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index b7ba2f5fb1..c93beb4416 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -125,14 +125,30 @@ public function testDocSpecifics($sniffs, $pathToExpected) public static function dataDocSpecifics() { return [ - 'Documentation title: case' => [ + 'Documentation title: case' => [ 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleCase', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleCase.md', ], - 'Documentation title: length' => [ + 'Documentation title: length' => [ 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleLength', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleLength.md', ], + 'Standard Element: blank line handling' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardBlankLines', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardBlankLines.md', + ], + 'Standard Element: encoding of special characters' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardEncoding', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardEncoding.md', + ], + 'Standard Element: indent handling' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardIndent', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardIndent.md', + ], + 'Standard Element: line wrapping' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.md', + ], ]; }//end dataDocSpecifics() diff --git a/tests/Core/Generators/TextTest.php b/tests/Core/Generators/TextTest.php index f571aff71d..d9740bda22 100644 --- a/tests/Core/Generators/TextTest.php +++ b/tests/Core/Generators/TextTest.php @@ -125,14 +125,30 @@ public function testDocSpecifics($sniffs, $pathToExpected) public static function dataDocSpecifics() { return [ - 'Documentation title: case' => [ + 'Documentation title: case' => [ 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleCase', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleCase.txt', ], - 'Documentation title: length' => [ + 'Documentation title: length' => [ 'sniffs' => 'StandardWithDocs.Content.DocumentationTitleLength', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputDocumentationTitleLength.txt', ], + 'Standard Element: blank line handling' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardBlankLines', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardBlankLines.txt', + ], + 'Standard Element: encoding of special characters' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardEncoding', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardEncoding.txt', + ], + 'Standard Element: indent handling' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardIndent', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardIndent.txt', + ], + 'Standard Element: line wrapping' => [ + 'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.txt', + ], ]; }//end dataDocSpecifics() From 65d57b134b60be9669d58add1211edfb7db091a4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 5 Nov 2024 00:25:49 +0100 Subject: [PATCH 794/874] Generators HTML/Markdown: consistent encoding cross-PHP The default value for the `$flags` parameter of the `htmlspecialchars()` function changed in PHP 8.1.0. Previously, the default was `ENT_COMPAT`. Now the default is `ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401`. The most notable differences are: * Single quotes will be encoded. * Invalid code unit sequences will be replace by a Unicode Replacement Character. For consistent output cross-version PHP, it is advised to always explicitly pass the `$flags` parameter` and not rely on the default value. Fixed now and using the _new_ `$flags` default value as the parameter value. This commit allows for the tests to have the same output expectations cross-version PHP. For end-users, the differences shouldn't have been noticeable. --- src/Generators/HTML.php | 2 +- src/Generators/Markdown.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php index 0f3733b984..0ca4496963 100644 --- a/src/Generators/HTML.php +++ b/src/Generators/HTML.php @@ -235,7 +235,7 @@ public function processSniff(DOMNode $doc) protected function printTextBlock(DOMNode $node) { $content = trim($node->nodeValue); - $content = htmlspecialchars($content); + $content = htmlspecialchars($content, (ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401)); // Use the correct line endings based on the OS. $content = str_replace("\n", PHP_EOL, $content); diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index ab30cd59a7..6df243a459 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -116,7 +116,7 @@ protected function processSniff(DOMNode $doc) protected function printTextBlock(DOMNode $node) { $content = trim($node->nodeValue); - $content = htmlspecialchars($content); + $content = htmlspecialchars($content, (ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401)); // Use the correct line endings based on the OS. $content = str_replace("\n", PHP_EOL, $content); From 02fe7005958cacbb003934650e5cf21a2a58d6b6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Nov 2024 19:59:07 +0100 Subject: [PATCH 795/874] Generators: add tests for handling code sample titles This adds dedicated tests for specific issues which can be encountered with the `title` attribute for `` elements. This initial set of tests for this documents the current behaviour. This behaviour may not always be the desired behaviour, in which case, this will be fixed in follow-up commits. --- .../ExpectedOutputCodeTitleLineWrapping.html | 118 ++++++++++++++++++ .../ExpectedOutputCodeTitleLineWrapping.md | 78 ++++++++++++ .../ExpectedOutputCodeTitleLineWrapping.txt | 33 +++++ .../ExpectedOutputCodeTitleWhitespace.html | 98 +++++++++++++++ .../ExpectedOutputCodeTitleWhitespace.md | 43 +++++++ .../ExpectedOutputCodeTitleWhitespace.txt | 22 ++++ .../Content/CodeTitleLineWrappingStandard.xml | 55 ++++++++ .../Content/CodeTitleWhitespaceStandard.xml | 32 +++++ .../Content/CodeTitleLineWrappingSniff.php | 12 ++ .../Content/CodeTitleWhitespaceSniff.php | 12 ++ tests/Core/Generators/HTMLTest.php | 8 ++ tests/Core/Generators/MarkdownTest.php | 8 ++ tests/Core/Generators/TextTest.php | 8 ++ 13 files changed, 527 insertions(+) create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleLineWrappingStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleWhitespaceStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleLineWrappingSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleWhitespaceSniff.php diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.html new file mode 100644 index 0000000000..fc35fdf0bf --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.html @@ -0,0 +1,118 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Code Title, line wrapping

    +

    This is a standard block.

    + + + + + + + + + +
    Valid: exactly 45 character long description.Invalid: exactly 45 char long description---.
    // Dummy.// Dummy.
    + + + + + + + + + +
    Valid: exactly 46 character long description-.Invalid: exactly 46 character long description
    // Dummy.// Dummy.
    + + + + + + + + + +
    Valid: exactly 47 character long description--.Invalid: exactly 47 character long description.
    // Dummy.// Dummy.
    + + + + + + + + + +
    Valid: this description is longer than 46 characters and will wrap.Invalid: this description is longer than 46 characters and will wrap.
    // Dummy.// Dummy.
    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md new file mode 100644 index 0000000000..e5b7251aa2 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md @@ -0,0 +1,78 @@ +# GeneratorTest Coding Standard + +## Code Title, line wrapping +This is a standard block. + + + + + + + + + +
    Valid: exactly 45 character long description.Invalid: exactly 45 char long description---.
    + + // Dummy. + + + + // Dummy. + +
    + + + + + + + + + +
    Valid: exactly 46 character long description-.Invalid: exactly 46 character long description
    + + // Dummy. + + + + // Dummy. + +
    + + + + + + + + + +
    Valid: exactly 47 character long description--.Invalid: exactly 47 character long description.
    + + // Dummy. + + + + // Dummy. + +
    + + + + + + + + + +
    Valid: this description is longer than 46 characters and will wrap.Invalid: this description is longer than 46 characters and will wrap.
    + + // Dummy. + + + + // Dummy. + +
    + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.txt b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.txt new file mode 100644 index 0000000000..11925c4cbb --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.txt @@ -0,0 +1,33 @@ + +------------------------------------------------------------ +| GENERATORTEST CODING STANDARD: CODE TITLE, LINE WRAPPING | +------------------------------------------------------------ + +This is a standard block. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: exactly 45 character long description. | Invalid: exactly 45 char long description---. | +---------------------------------------------------------------------------------------------------- +| // Dummy. | // Dummy. | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: exactly 46 character long description-. | Invalid: exactly 46 character long description | +---------------------------------------------------------------------------------------------------- +| // Dummy. | // Dummy. | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: exactly 47 character long | Invalid: exactly 47 character long | +| description--. | description. | +---------------------------------------------------------------------------------------------------- +| // Dummy. | // Dummy. | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: this description is longer than 46 | Invalid: this description is longer than 46 | +| characters and will wrap. | characters and will wrap. | +---------------------------------------------------------------------------------------------------- +| // Dummy. | // Dummy. | +---------------------------------------------------------------------------------------------------- + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html new file mode 100644 index 0000000000..a64cdb4deb --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html @@ -0,0 +1,98 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Code Title, whitespace handling

    +

    This is a standard block.

    + + + + + + + + + +
    Valid: spaces at start of description.Invalid: spaces at end making line > 46 chars.
    // Dummy.// Dummy.
    + + + + + + + + + +
    Valid: spaces at start + end of description. Invalid: spaces ' ' in description.
    // Note: description above without the
    // trailing whitespace fits in 46 chars.
    // Dummy.
    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md new file mode 100644 index 0000000000..509abf6720 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md @@ -0,0 +1,43 @@ +# GeneratorTest Coding Standard + +## Code Title, whitespace handling +This is a standard block. + + + + + + + + + +
    Valid: spaces at start of description.Invalid: spaces at end making line > 46 chars.
    + + // Dummy. + + + + // Dummy. + +
    + + + + + + + + + +
    Valid: spaces at start + end of description. Invalid: spaces ' ' in description.
    + + // Note: description above without the + // trailing whitespace fits in 46 chars. + + + + // Dummy. + +
    + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt new file mode 100644 index 0000000000..80a6cc690b --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt @@ -0,0 +1,22 @@ + +------------------------------------------------------------------ +| GENERATORTEST CODING STANDARD: CODE TITLE, WHITESPACE HANDLING | +------------------------------------------------------------------ + +This is a standard block. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: spaces at start of description. | Invalid: spaces at end making line > 46 chars. | +| | | +---------------------------------------------------------------------------------------------------- +| // Dummy. | // Dummy. | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: spaces at start + end of description. | Invalid: spaces ' ' in description. | +| | | +---------------------------------------------------------------------------------------------------- +| // Note: description above without the | // Dummy. | +| // trailing whitespace fits in 46 chars. | | +---------------------------------------------------------------------------------------------------- + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleLineWrappingStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleLineWrappingStandard.xml new file mode 100644 index 0000000000..b773f7a88c --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleLineWrappingStandard.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleWhitespaceStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleWhitespaceStandard.xml new file mode 100644 index 0000000000..2829720259 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeTitleWhitespaceStandard.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleLineWrappingSniff.php b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleLineWrappingSniff.php new file mode 100644 index 0000000000..560b7884c2 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeTitleLineWrappingSniff.php @@ -0,0 +1,12 @@ + 'StandardWithDocs.Content.StandardLineWrapping', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.html', ], + 'Code Title: line wrapping' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleLineWrapping', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleLineWrapping.html', + ], + 'Code Title: whitespace handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.html', + ], ]; }//end dataDocSpecifics() diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index c93beb4416..9612b36b84 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -149,6 +149,14 @@ public static function dataDocSpecifics() 'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.md', ], + 'Code Title: line wrapping' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleLineWrapping', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleLineWrapping.md', + ], + 'Code Title: whitespace handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.md', + ], ]; }//end dataDocSpecifics() diff --git a/tests/Core/Generators/TextTest.php b/tests/Core/Generators/TextTest.php index d9740bda22..2e0c48035e 100644 --- a/tests/Core/Generators/TextTest.php +++ b/tests/Core/Generators/TextTest.php @@ -149,6 +149,14 @@ public static function dataDocSpecifics() 'sniffs' => 'StandardWithDocs.Content.StandardLineWrapping', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputStandardLineWrapping.txt', ], + 'Code Title: line wrapping' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleLineWrapping', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleLineWrapping.txt', + ], + 'Code Title: whitespace handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.txt', + ], ]; }//end dataDocSpecifics() From 87d50300a9e23547dae82c118bbe9adaad598b49 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Nov 2024 23:43:45 +0100 Subject: [PATCH 796/874] Generators: add tests for handling code samples This adds dedicated tests for specific issues which can be encountered with the contents of `` elements. This initial set of tests for this documents the current behaviour. This behaviour may not always be the desired behaviour, in which case, this will be fixed in follow-up commits. --- ...xpectedOutputCodeComparisonBlankLines.html | 88 +++++++++++++++++ .../ExpectedOutputCodeComparisonBlankLines.md | 34 +++++++ ...ExpectedOutputCodeComparisonBlankLines.txt | 18 ++++ ...pectedOutputCodeComparisonBlockLength.html | 98 +++++++++++++++++++ ...ExpectedOutputCodeComparisonBlockLength.md | 46 +++++++++ ...xpectedOutputCodeComparisonBlockLength.txt | 23 +++++ .../ExpectedOutputCodeComparisonEncoding.html | 88 +++++++++++++++++ .../ExpectedOutputCodeComparisonEncoding.md | 47 +++++++++ .../ExpectedOutputCodeComparisonEncoding.txt | 26 +++++ ...xpectedOutputCodeComparisonLineLength.html | 89 +++++++++++++++++ .../ExpectedOutputCodeComparisonLineLength.md | 30 ++++++ ...ExpectedOutputCodeComparisonLineLength.txt | 18 ++++ .../CodeComparisonBlankLinesStandard.xml | 33 +++++++ .../CodeComparisonBlockLengthStandard.xml | 35 +++++++ .../CodeComparisonEncodingStandard.xml | 42 ++++++++ .../CodeComparisonLineLengthStandard.xml | 25 +++++ .../Content/CodeComparisonBlankLinesSniff.php | 12 +++ .../CodeComparisonBlockLengthSniff.php | 12 +++ .../Content/CodeComparisonEncodingSniff.php | 12 +++ .../Content/CodeComparisonLineLengthSniff.php | 12 +++ tests/Core/Generators/HTMLTest.php | 16 +++ tests/Core/Generators/MarkdownTest.php | 16 +++ tests/Core/Generators/TextTest.php | 16 +++ 23 files changed, 836 insertions(+) create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.txt create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonBlankLinesStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonBlockLengthStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonEncodingStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonLineLengthStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeComparisonBlankLinesSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeComparisonBlockLengthSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeComparisonEncodingSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeComparisonLineLengthSniff.php diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.html new file mode 100644 index 0000000000..788ef612d8 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.html @@ -0,0 +1,88 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Code Comparison, blank lines

    +

    This is a standard block.

    + + + + + + + + + +
    Valid: Checking handling of blank lines.Invalid: Checking handling of blank lines.
    // First line of the code sample is
    // deliberately empty.

    // We also have a blank line in the middle.

    // And a blank line at the end.
    // First line of the code sample is
    // deliberately empty.

    // We also have a blank line in the middle.

    // And a blank line at the end.
    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.md new file mode 100644 index 0000000000..79efd01775 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.md @@ -0,0 +1,34 @@ +# GeneratorTest Coding Standard + +## Code Comparison, blank lines +This is a standard block. + + + + + + + + + +
    Valid: Checking handling of blank lines.Invalid: Checking handling of blank lines.
    + + // First line of the code sample is + // deliberately empty. + + // We also have a blank line in the middle. + + // And a blank line at the end. + + + + // First line of the code sample is + // deliberately empty. + + // We also have a blank line in the middle. + + // And a blank line at the end. + +
    + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.txt b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.txt new file mode 100644 index 0000000000..a7fd41d901 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.txt @@ -0,0 +1,18 @@ + +--------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: CODE COMPARISON, BLANK LINES | +--------------------------------------------------------------- + +This is a standard block. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Checking handling of blank lines. | Invalid: Checking handling of blank lines. | +---------------------------------------------------------------------------------------------------- +| // First line of the code sample is | // First line of the code sample is | +| // deliberately empty. | // deliberately empty. | +| | | +| // We also have a blank line in the middle. | // We also have a blank line in the middle. | +| | | +| // And a blank line at the end. | // And a blank line at the end. | +---------------------------------------------------------------------------------------------------- + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.html new file mode 100644 index 0000000000..a8bfc97f7c --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.html @@ -0,0 +1,98 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Code Comparison, block length

    +

    This is a standard block.

    + + + + + + + + + +
    Valid: code sample A has more lines than B.Invalid: shorter.
    // This code sample has more lines
    // than the "invalid" one.
    $one = 10;
    $a = 10;
    + + + + + + + + + +
    Valid: shorter.Invalid: code sample B has more lines than A.
    echo $foo;// This code sample has more lines
    // than the "valid" one.
    print $foo;
    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.md new file mode 100644 index 0000000000..b9b64b31c6 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.md @@ -0,0 +1,46 @@ +# GeneratorTest Coding Standard + +## Code Comparison, block length +This is a standard block. + + + + + + + + + +
    Valid: code sample A has more lines than B.Invalid: shorter.
    + + // This code sample has more lines + // than the "invalid" one. + $one = 10; + + + + $a = 10; + +
    + + + + + + + + + +
    Valid: shorter.Invalid: code sample B has more lines than A.
    + + echo $foo; + + + + // This code sample has more lines + // than the "valid" one. + print $foo; + +
    + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.txt b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.txt new file mode 100644 index 0000000000..c2fb737f45 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.txt @@ -0,0 +1,23 @@ + +---------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: CODE COMPARISON, BLOCK LENGTH | +---------------------------------------------------------------- + +This is a standard block. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: code sample A has more lines than B. | Invalid: shorter. | +---------------------------------------------------------------------------------------------------- +| // This code sample has more lines | $a = 10; | +| // than the "invalid" one. | | +| $one = 10; | | +---------------------------------------------------------------------------------------------------- + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: shorter. | Invalid: code sample B has more lines than A. | +---------------------------------------------------------------------------------------------------- +| echo $foo; | // This code sample has more lines | +| | // than the "valid" one. | +| | print $foo; | +---------------------------------------------------------------------------------------------------- + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.html new file mode 100644 index 0000000000..ff9f6df12b --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.html @@ -0,0 +1,88 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Code Comparison, char encoding

    +

    This is a standard block.

    + + + + + + + + + +
    Valid: Vestibulum et orci condimentum.Invalid: Donec in nisl ut tortor convallis interdum.
    <?php

    // The above PHP tag is specifically testing
    // handling of that in generated HTML doc.

    // Now let's also check the handling of
    // comparison operators in code samples...
    $a = $b < $c;
    $d = $e > $f;
    $g = $h <= $i;
    $j = $k >= $l;
    $m = $n <=> $o;
    <?php

    // The above PHP tag is specifically testing
    // handling of that in generated HTML doc.

    // Now let's also check the handling of
    // comparison operators in code samples
    // in combination with "em" tags.
    $a = $b < $c;
    $d = $e > $f;
    $g = $h <= $i;
    $j = $k >= $l;
    $m = $n <=> $o;
    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.md new file mode 100644 index 0000000000..4c3832fa3f --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.md @@ -0,0 +1,47 @@ +# GeneratorTest Coding Standard + +## Code Comparison, char encoding +This is a standard block. + + + + + + + + + +
    Valid: Vestibulum et orci condimentum.Invalid: Donec in nisl ut tortor convallis interdum.
    + + $f; + $g = $h <= $i; + $j = $k >= $l; + $m = $n <=> $o; + + + + $f; + $g = $h <= $i; + $j = $k >= $l; + $m = $n <=> $o; + +
    + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.txt b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.txt new file mode 100644 index 0000000000..7ffcf4df51 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.txt @@ -0,0 +1,26 @@ + +----------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: CODE COMPARISON, CHAR ENCODING | +----------------------------------------------------------------- + +This is a standard block. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Vestibulum et orci condimentum. | Invalid: Donec in nisl ut tortor convallis | +| | interdum. | +---------------------------------------------------------------------------------------------------- +| $f; | $a = $b < $c; | +| $g = $h <= $i; | $d = $e > $f; | +| $j = $k >= $l; | $g = $h <= $i; | +| $m = $n <=> $o; | $j = $k >= $l; | +| | $m = $n <=> $o; | +---------------------------------------------------------------------------------------------------- + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.html new file mode 100644 index 0000000000..2f7abc69a4 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.html @@ -0,0 +1,89 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Code Comparison, line length

    +

    Ensure there is no PHP "Warning: str_repeat(): Second argument has to be greater than or equal to 0". + Ref: squizlabs/PHP_CodeSniffer#2522

    + + + + + + + + + +
    Valid: contains line which is too long.Invalid: contains line which is too long.
    class Foo extends Bar implements Countable, Serializable
    {
    }
    class Foo extends Bar
    {
        public static function foobar($param1, $param2) {}
    }
    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md new file mode 100644 index 0000000000..f695814ba8 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md @@ -0,0 +1,30 @@ +# GeneratorTest Coding Standard + +## Code Comparison, line length +Ensure there is no PHP "Warning: str_repeat(): Second argument has to be greater than or equal to 0". + Ref: squizlabs/PHP_CodeSniffer#2522 + + + + + + + + + +
    Valid: contains line which is too long.Invalid: contains line which is too long.
    + + class Foo extends Bar implements Countable, Serializable + { + } + + + + class Foo extends Bar + { + public static function foobar($param1, $param2) {} + } + +
    + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.txt b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.txt new file mode 100644 index 0000000000..e8a665cd45 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.txt @@ -0,0 +1,18 @@ + +--------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: CODE COMPARISON, LINE LENGTH | +--------------------------------------------------------------- + +Ensure there is no PHP "Warning: str_repeat(): Second argument has to be greater than or equal to +0". +Ref: squizlabs/PHP_CodeSniffer#2522 + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: contains line which is too long. | Invalid: contains line which is too long. | +---------------------------------------------------------------------------------------------------- +| class Foo extends Bar implements Countable, Serializable| class Foo extends Bar | +| { | { | +| } | public static function foobar($param1, $param2) {}| +| | } | +---------------------------------------------------------------------------------------------------- + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonBlankLinesStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonBlankLinesStandard.xml new file mode 100644 index 0000000000..bcaf82bbb6 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonBlankLinesStandard.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonBlockLengthStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonBlockLengthStandard.xml new file mode 100644 index 0000000000..c479a7fd0f --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonBlockLengthStandard.xml @@ -0,0 +1,35 @@ + + + + + + + $one = 10; + ]]> + + + $a = 10; + ]]> + + + + + echo $foo; + ]]> + + + print $foo; + ]]> + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonEncodingStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonEncodingStandard.xml new file mode 100644 index 0000000000..c366553f3e --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonEncodingStandard.xml @@ -0,0 +1,42 @@ + + + + + + + $f; +$g = $h <= $i; +$j = $k >= $l; +$m = $n <=> $o; + ]]> + + + + +// The above PHP tag is specifically testing +// handling of that in generated HTML doc. + +// Now let's also check the handling of +// comparison operators in code samples +// in combination with "em" tags. +$a = $b < $c; +$d = $e > $f; +$g = $h <= $i; +$j = $k >= $l; +$m = $n <=> $o; + ]]> + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonLineLengthStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonLineLengthStandard.xml new file mode 100644 index 0000000000..b4431ea84d --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Content/CodeComparisonLineLengthStandard.xml @@ -0,0 +1,25 @@ + + + + + + + Countable, Serializable +{ +} + ]]> + + + foobar($param1, $param2) {} +} + ]]> + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeComparisonBlankLinesSniff.php b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeComparisonBlankLinesSniff.php new file mode 100644 index 0000000000..1e56bf9cf8 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Content/CodeComparisonBlankLinesSniff.php @@ -0,0 +1,12 @@ + 'StandardWithDocs.Content.CodeTitleWhitespace', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.html', ], + 'Code Comparison: blank line handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlankLines', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlankLines.html', + ], + 'Code Comparison: different block lengths' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlockLength', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlockLength.html', + ], + 'Code Comparison: encoding of special characters' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonEncoding', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonEncoding.html', + ], + 'Code Comparison: line length handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonLineLength', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonLineLength.html', + ], ]; }//end dataDocSpecifics() diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index 9612b36b84..515b832c59 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -157,6 +157,22 @@ public static function dataDocSpecifics() 'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.md', ], + 'Code Comparison: blank line handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlankLines', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlankLines.md', + ], + 'Code Comparison: different block lengths' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlockLength', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlockLength.md', + ], + 'Code Comparison: encoding of special characters' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonEncoding', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonEncoding.md', + ], + 'Code Comparison: line length handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonLineLength', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonLineLength.md', + ], ]; }//end dataDocSpecifics() diff --git a/tests/Core/Generators/TextTest.php b/tests/Core/Generators/TextTest.php index 2e0c48035e..fd7388d256 100644 --- a/tests/Core/Generators/TextTest.php +++ b/tests/Core/Generators/TextTest.php @@ -157,6 +157,22 @@ public static function dataDocSpecifics() 'sniffs' => 'StandardWithDocs.Content.CodeTitleWhitespace', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeTitleWhitespace.txt', ], + 'Code Comparison: blank line handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlankLines', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlankLines.txt', + ], + 'Code Comparison: different block lengths' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonBlockLength', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonBlockLength.txt', + ], + 'Code Comparison: encoding of special characters' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonEncoding', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonEncoding.txt', + ], + 'Code Comparison: line length handling' => [ + 'sniffs' => 'StandardWithDocs.Content.CodeComparisonLineLength', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonLineLength.txt', + ], ]; }//end dataDocSpecifics() From fe3111c308aa51acd2873b58e69e381b27d109ec Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 23 Nov 2024 03:37:48 +0100 Subject: [PATCH 797/874] GH Actions: tweak auto-label configuration * Handle the new `Core Component: Generators` label. * Improve regex to identify documentation changes (prevent confusion over tests). --- .github/labeler.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index bd6a522938..3dd66bbb81 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -21,6 +21,10 @@ labels: draft: false files: - "src/Fixer.php$" + - label: "Core Component: Generators" + draft: false + files: + - "src/Generators/.*" - label: "Core Component: Reports" draft: false files: @@ -90,7 +94,7 @@ labels: - label: "Type: documentation" draft: false files: - - '/Docs/[A-Za-z0-9-]*/.*Standard.xml$' + - 'src/Standards/.*/Docs/[A-Za-z0-9-]*/.*Standard.xml$' - label: "Type: documentation" draft: false files: From e2dcc7f6da2fa98a1553fe563d90f6bcda440c05 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Nov 2024 13:19:18 +0100 Subject: [PATCH 798/874] Generators: add tests covering handling of unsupported doc structures This adds a set of dedicated tests to safeguard how XML docs which don't follow the specification are handled. This initial set of tests for this documents the current behaviour. This behaviour may not always be the desired behaviour, in which case, this will be fixed in follow-up commits. --- ...dOutputUnsupportedElementAtWrongLevel.html | 77 ++++++++++++++++ ...tedOutputUnsupportedElementAtWrongLevel.md | 5 ++ ...edOutputUnsupportedElementAtWrongLevel.txt | 5 ++ ...edOutputUnsupportedOneElmAtWrongLevel.html | 78 ++++++++++++++++ ...ctedOutputUnsupportedOneElmAtWrongLevel.md | 6 ++ ...tedOutputUnsupportedOneElmAtWrongLevel.txt | 7 ++ ...tputUnsupportedSuperfluousCodeElement.html | 88 +++++++++++++++++++ ...OutputUnsupportedSuperfluousCodeElement.md | 24 +++++ ...utputUnsupportedSuperfluousCodeElement.txt | 13 +++ ...pectedOutputUnsupportedUnknownElement.html | 77 ++++++++++++++++ ...ExpectedOutputUnsupportedUnknownElement.md | 5 ++ ...xpectedOutputUnsupportedUnknownElement.txt | 5 ++ .../ElementAtWrongLevelStandard.xml | 8 ++ .../OneElmAtWrongLevelStandard.xml | 13 +++ .../SuperfluousCodeElementStandard.xml | 24 +++++ .../Unsupported/UnknownElementStandard.xml | 7 ++ .../Unsupported/ElementAtWrongLevelSniff.php | 12 +++ .../Unsupported/OneElmAtWrongLevelSniff.php | 12 +++ .../SuperfluousCodeElementSniff.php | 12 +++ .../Unsupported/UnknownElementSniff.php | 12 +++ tests/Core/Generators/HTMLTest.php | 16 ++++ tests/Core/Generators/MarkdownTest.php | 16 ++++ tests/Core/Generators/TextTest.php | 16 ++++ 23 files changed, 538 insertions(+) create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.txt create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.html create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.md create mode 100644 tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.txt create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/ElementAtWrongLevelStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/OneElmAtWrongLevelStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/SuperfluousCodeElementStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/UnknownElementStandard.xml create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Unsupported/ElementAtWrongLevelSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Unsupported/OneElmAtWrongLevelSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Unsupported/SuperfluousCodeElementSniff.php create mode 100644 tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Unsupported/UnknownElementSniff.php diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.html b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.html new file mode 100644 index 0000000000..dfa5670f0e --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.html @@ -0,0 +1,77 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Code element at wrong level

    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.md b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.md new file mode 100644 index 0000000000..669ea0f4c6 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.md @@ -0,0 +1,5 @@ +# GeneratorTest Coding Standard + +## Code element at wrong level + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.txt b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.txt new file mode 100644 index 0000000000..940832ced1 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.txt @@ -0,0 +1,5 @@ + +-------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: CODE ELEMENT AT WRONG LEVEL | +-------------------------------------------------------------- + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.html b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.html new file mode 100644 index 0000000000..dc86a6c42f --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.html @@ -0,0 +1,78 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    One element correct, one element wrong level

    +

    This is a standard block at the correct level.

    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.md b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.md new file mode 100644 index 0000000000..f6eda21036 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.md @@ -0,0 +1,6 @@ +# GeneratorTest Coding Standard + +## One element correct, one element wrong level +This is a standard block at the correct level. + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.txt b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.txt new file mode 100644 index 0000000000..4d1aaeaa12 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.txt @@ -0,0 +1,7 @@ + +------------------------------------------------------------------------------- +| GENERATORTEST CODING STANDARD: ONE ELEMENT CORRECT, ONE ELEMENT WRONG LEVEL | +------------------------------------------------------------------------------- + +This is a standard block at the correct level. + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.html b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.html new file mode 100644 index 0000000000..967381e3a9 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.html @@ -0,0 +1,88 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Superfluous code element

    +

    This is a standard block.

    + + + + + + + + + +
    Valid: Checking handling of blank lines.Invalid: Checking handling of blank lines.
    $valid = true;$invalid = true;
    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.md b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.md new file mode 100644 index 0000000000..131c6cc45a --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.md @@ -0,0 +1,24 @@ +# GeneratorTest Coding Standard + +## Superfluous code element +This is a standard block. + + + + + + + + + +
    Valid: Checking handling of blank lines.Invalid: Checking handling of blank lines.
    + + $valid = true; + + + + $invalid = true; + +
    + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.txt b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.txt new file mode 100644 index 0000000000..1307eebfd1 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.txt @@ -0,0 +1,13 @@ + +----------------------------------------------------------- +| GENERATORTEST CODING STANDARD: SUPERFLUOUS CODE ELEMENT | +----------------------------------------------------------- + +This is a standard block. + +----------------------------------------- CODE COMPARISON ------------------------------------------ +| Valid: Checking handling of blank lines. | Invalid: Checking handling of blank lines. | +---------------------------------------------------------------------------------------------------- +| $valid = true; | $invalid = true; | +---------------------------------------------------------------------------------------------------- + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.html b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.html new file mode 100644 index 0000000000..770d08bbc7 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.html @@ -0,0 +1,77 @@ + + + GeneratorTest Coding Standards + + + +

    GeneratorTest Coding Standards

    + +

    Unknown element

    +
    + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.md b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.md new file mode 100644 index 0000000000..a8be8f9928 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.md @@ -0,0 +1,5 @@ +# GeneratorTest Coding Standard + +## Unknown element + +Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.txt b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.txt new file mode 100644 index 0000000000..3e2f564720 --- /dev/null +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.txt @@ -0,0 +1,5 @@ + +-------------------------------------------------- +| GENERATORTEST CODING STANDARD: UNKNOWN ELEMENT | +-------------------------------------------------- + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/ElementAtWrongLevelStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/ElementAtWrongLevelStandard.xml new file mode 100644 index 0000000000..68519dd2be --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/ElementAtWrongLevelStandard.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/OneElmAtWrongLevelStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/OneElmAtWrongLevelStandard.xml new file mode 100644 index 0000000000..6c1dd164aa --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/OneElmAtWrongLevelStandard.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/SuperfluousCodeElementStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/SuperfluousCodeElementStandard.xml new file mode 100644 index 0000000000..333786a337 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/SuperfluousCodeElementStandard.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/UnknownElementStandard.xml b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/UnknownElementStandard.xml new file mode 100644 index 0000000000..c9ec3227fa --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Docs/Unsupported/UnknownElementStandard.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Unsupported/ElementAtWrongLevelSniff.php b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Unsupported/ElementAtWrongLevelSniff.php new file mode 100644 index 0000000000..6ed5c2be69 --- /dev/null +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/Unsupported/ElementAtWrongLevelSniff.php @@ -0,0 +1,12 @@ + 'StandardWithDocs.Content.CodeComparisonLineLength', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonLineLength.html', ], + 'Unsupported: element at the wrong level' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.ElementAtWrongLevel', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.html', + ], + 'Unsupported: one correct elm, one at wrong level' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.OneElmAtWrongLevel', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.html', + ], + 'Unsupported: superfluous code element' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.SuperfluousCodeElement', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.html', + ], + 'Unsupported: unknown element' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.UnknownElement', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedUnknownElement.html', + ], ]; }//end dataDocSpecifics() diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index 515b832c59..54f60d075e 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -173,6 +173,22 @@ public static function dataDocSpecifics() 'sniffs' => 'StandardWithDocs.Content.CodeComparisonLineLength', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonLineLength.md', ], + 'Unsupported: element at the wrong level' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.ElementAtWrongLevel', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.md', + ], + 'Unsupported: one correct elm, one at wrong level' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.OneElmAtWrongLevel', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.md', + ], + 'Unsupported: superfluous code element' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.SuperfluousCodeElement', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.md', + ], + 'Unsupported: unknown element' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.UnknownElement', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedUnknownElement.md', + ], ]; }//end dataDocSpecifics() diff --git a/tests/Core/Generators/TextTest.php b/tests/Core/Generators/TextTest.php index fd7388d256..b0c5f2807f 100644 --- a/tests/Core/Generators/TextTest.php +++ b/tests/Core/Generators/TextTest.php @@ -173,6 +173,22 @@ public static function dataDocSpecifics() 'sniffs' => 'StandardWithDocs.Content.CodeComparisonLineLength', 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputCodeComparisonLineLength.txt', ], + 'Unsupported: element at the wrong level' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.ElementAtWrongLevel', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.txt', + ], + 'Unsupported: one correct elm, one at wrong level' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.OneElmAtWrongLevel', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.txt', + ], + 'Unsupported: superfluous code element' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.SuperfluousCodeElement', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.txt', + ], + 'Unsupported: unknown element' => [ + 'sniffs' => 'StandardWithDocs.Unsupported.UnknownElement', + 'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputUnsupportedUnknownElement.txt', + ], ]; }//end dataDocSpecifics() From 9780e28bee398fabc13c2f05819626c91802a0d8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 5 Nov 2024 02:07:08 +0100 Subject: [PATCH 799/874] Generators/Markdown: add blank line after title As per the guidelines for cross-flavour markdown, it is best to always have a blank line below a header. Ref: * https://www.markdownguide.org/basic-syntax/#heading-best-practices --- src/Generators/Markdown.php | 2 +- .../ExpectedOutputCodeComparisonBlankLines.md | 1 + .../ExpectedOutputCodeComparisonBlockLength.md | 1 + .../Expectations/ExpectedOutputCodeComparisonEncoding.md | 1 + .../ExpectedOutputCodeComparisonLineLength.md | 1 + .../Expectations/ExpectedOutputCodeTitleLineWrapping.md | 1 + .../Expectations/ExpectedOutputCodeTitleWhitespace.md | 1 + .../Expectations/ExpectedOutputDocumentationTitleCase.md | 1 + .../ExpectedOutputDocumentationTitleLength.md | 1 + .../Core/Generators/Expectations/ExpectedOutputOneDoc.md | 1 + .../Expectations/ExpectedOutputStandardBlankLines.md | 1 + .../Expectations/ExpectedOutputStandardEncoding.md | 1 + .../Expectations/ExpectedOutputStandardIndent.md | 1 + .../Expectations/ExpectedOutputStandardLineWrapping.md | 1 + .../Expectations/ExpectedOutputStructureDocs.md | 8 ++++++++ .../ExpectedOutputUnsupportedElementAtWrongLevel.md | 1 + .../ExpectedOutputUnsupportedOneElmAtWrongLevel.md | 1 + .../ExpectedOutputUnsupportedSuperfluousCodeElement.md | 1 + .../ExpectedOutputUnsupportedUnknownElement.md | 1 + 19 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index 6df243a459..76dbb0605f 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -93,7 +93,7 @@ protected function printFooter() protected function processSniff(DOMNode $doc) { $title = $this->getTitle($doc); - echo PHP_EOL."## $title".PHP_EOL; + echo PHP_EOL."## $title".PHP_EOL.PHP_EOL; foreach ($doc->childNodes as $node) { if ($node->nodeName === 'standard') { diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.md index 79efd01775..ef25f893c4 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlankLines.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Code Comparison, blank lines + This is a standard block. diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.md index b9b64b31c6..526f110b34 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonBlockLength.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Code Comparison, block length + This is a standard block.
    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.md index 4c3832fa3f..052d3cb3e0 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonEncoding.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Code Comparison, char encoding + This is a standard block.
    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md index f695814ba8..89ae055bfb 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Code Comparison, line length + Ensure there is no PHP "Warning: str_repeat(): Second argument has to be greater than or equal to 0". Ref: squizlabs/PHP_CodeSniffer#2522
    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md index e5b7251aa2..a0d6a8e6a2 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleLineWrapping.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Code Title, line wrapping + This is a standard block.
    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md index 509abf6720..2d04562c7e 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Code Title, whitespace handling + This is a standard block.
    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.md b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.md index d0464a4efa..0d63b04a95 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleCase.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## lowercase title + This is a standard block. Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.md b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.md index 29f5972a7c..252f5fca69 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputDocumentationTitleLength.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## This is a very very very very very very very very very very very long title + This is a standard block. Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md b/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md index 0cc0ecceae..f6130736ff 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## One Standard Block, No Code + Documentation contains one standard block and no code comparison. Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md index 43ba99d2db..6b3d6ed107 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Standard Element, blank line handling + There is a blank line at the start of this standard. And the above blank line is also deliberate to test part of the logic. diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md index f04de7f096..f682daf611 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Standard Element, handling of HTML tags + The use of *tags* in standard descriptions is allowed and their handling should be *safeguarded*. Other tags, like <a href="example.com">link</a>, <b>bold</bold>, <script></script> are not allowed and will be encoded for display when the HTML or Markdown report is used. diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md index 77c7244a12..1f3916153e 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Standard Element, indentation should be ignored + This line has no indentation. This line has 4 spaces indentation. This line has 8 spaces indentation. diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md index 68703400cc..1a2cd9f19c 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Standard Element, line wrapping handling + This line has to be exactly 99 chars to test part of the logic.------------------------------------ And this line has to be exactly 100 chars.---------------------------------------------------------- And here we have a line which should start wrapping as it is longer than 100 chars. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pellentesque iaculis enim quis hendrerit. Morbi ultrices in odio pharetra commodo. diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md b/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md index 116af5df1e..fec8989451 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md @@ -2,7 +2,9 @@ ## No Content + ## Code Comparison Only, Missing Standard Block +
    @@ -23,6 +25,7 @@
    Valid: Lorem ipsum dolor sit amet.
    ## One Standard Block, Code Comparison + Documentation contains one standard block and one code comparison. @@ -44,9 +47,11 @@ Documentation contains one standard block and one code comparison.
    ## One Standard Block, No Code + Documentation contains one standard block and no code comparison. ## One Standard Block, Two Code Comparisons + Documentation contains one standard block and two code comparisons. @@ -86,10 +91,12 @@ Documentation contains one standard block and two code comparisons.
    ## Two Standard Blocks, No Code + This is standard block one. This is standard block two. ## Two Standard Blocks, One Code Comparison + This is standard block one. @@ -112,6 +119,7 @@ This is standard block one. This is standard block two. ## Two Standard Blocks, Three Code Comparisons + This is standard block one.
    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.md b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.md index 669ea0f4c6..048f028d57 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedElementAtWrongLevel.md @@ -2,4 +2,5 @@ ## Code element at wrong level + Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.md b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.md index f6eda21036..aa9cc47279 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedOneElmAtWrongLevel.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## One element correct, one element wrong level + This is a standard block at the correct level. Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.md b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.md index 131c6cc45a..f6cdad9467 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedSuperfluousCodeElement.md @@ -1,6 +1,7 @@ # GeneratorTest Coding Standard ## Superfluous code element + This is a standard block.
    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.md b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.md index a8be8f9928..211415225f 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputUnsupportedUnknownElement.md @@ -2,4 +2,5 @@ ## Unknown element + Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) From baec97ea62e91f51d881636ca2f73e368855935b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Nov 2024 19:20:44 +0100 Subject: [PATCH 800/874] Generators/HTML: fix line break handling As things were, line breaks in a `` block were not respected for proper display in HTML. This has now been fixed by: * Recognizing a blank line after a text line as an indicator that the next line should be a new paragraph. * In all other cases, a line break will be translated to an HTML line break. Includes updated test expectations. --- src/Generators/HTML.php | 31 ++++++++++++++++--- ...xpectedOutputCodeComparisonLineLength.html | 4 +-- .../ExpectedOutputStandardBlankLines.html | 8 ++--- .../ExpectedOutputStandardEncoding.html | 4 +-- .../ExpectedOutputStandardIndent.html | 8 ++--- .../ExpectedOutputStandardLineWrapping.html | 6 ++-- 6 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php index 0ca4496963..8e2001e2e5 100644 --- a/src/Generators/HTML.php +++ b/src/Generators/HTML.php @@ -237,14 +237,35 @@ protected function printTextBlock(DOMNode $node) $content = trim($node->nodeValue); $content = htmlspecialchars($content, (ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401)); - // Use the correct line endings based on the OS. - $content = str_replace("\n", PHP_EOL, $content); - - // Allow em tags only. + // Allow only em tags. $content = str_replace('<em>', '', $content); $content = str_replace('</em>', '', $content); - echo "

    $content

    ".PHP_EOL; + $nodeLines = explode("\n", $content); + $lineCount = count($nodeLines); + $lines = []; + + for ($i = 0; $i < $lineCount; $i++) { + $currentLine = trim($nodeLines[$i]); + + if (isset($nodeLines[($i + 1)]) === false) { + // We're at the end of the text, just add the line. + $lines[] = $currentLine; + } else { + $nextLine = trim($nodeLines[($i + 1)]); + if ($nextLine === '') { + // Next line is a blank line, end the paragraph and start a new one. + // Also skip over the blank line. + $lines[] = $currentLine.'

    '.PHP_EOL.'

    '; + ++$i; + } else { + // Next line is not blank, so just add a line break. + $lines[] = $currentLine.'
    '.PHP_EOL; + } + } + } + + echo '

    '.implode('', $lines).'

    '.PHP_EOL; }//end printTextBlock() diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.html index 2f7abc69a4..b876e6b1e9 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.html +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.html @@ -72,8 +72,8 @@

    GeneratorTest Coding Standards

    Code Comparison, line length

    -

    Ensure there is no PHP "Warning: str_repeat(): Second argument has to be greater than or equal to 0". - Ref: squizlabs/PHP_CodeSniffer#2522

    +

    Ensure there is no PHP "Warning: str_repeat(): Second argument has to be greater than or equal to 0".
    +Ref: squizlabs/PHP_CodeSniffer#2522

    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.html b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.html index 5c6539d0ca..4c45757b57 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.html +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.html @@ -72,11 +72,9 @@

    GeneratorTest Coding Standards

    Standard Element, blank line handling

    -

    There is a blank line at the start of this standard. - - And the above blank line is also deliberate to test part of the logic. - - Let's also end on a blank line to test that too.

    +

    There is a blank line at the start of this standard.

    +

    And the above blank line is also deliberate to test part of the logic.

    +

    Let's also end on a blank line to test that too.

    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.html b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.html index 5b1c8ca3c3..106e835a74 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.html +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.html @@ -72,8 +72,8 @@

    GeneratorTest Coding Standards

    Standard Element, handling of HTML tags

    -

    The use of tags in standard descriptions is allowed and their handling should be safeguarded. - Other tags, like <a href="example.com">link</a>, <b>bold</bold>, <script></script> are not allowed and will be encoded for display when the HTML or Markdown report is used.

    +

    The use of tags in standard descriptions is allowed and their handling should be safeguarded.
    +Other tags, like <a href="example.com">link</a>, <b>bold</bold>, <script></script> are not allowed and will be encoded for display when the HTML or Markdown report is used.

    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.html b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.html index 4c4bcb54ac..b3aad7f45c 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.html +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.html @@ -72,10 +72,10 @@

    GeneratorTest Coding Standards

    Standard Element, indentation should be ignored

    -

    This line has no indentation. - This line has 4 spaces indentation. - This line has 8 spaces indentation. - This line has 4 spaces indentation.

    +

    This line has no indentation.
    +This line has 4 spaces indentation.
    +This line has 8 spaces indentation.
    +This line has 4 spaces indentation.

    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.html b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.html index 8ca982efc1..d54d94c38f 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.html +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.html @@ -72,9 +72,9 @@

    GeneratorTest Coding Standards

    Standard Element, line wrapping handling

    -

    This line has to be exactly 99 chars to test part of the logic.------------------------------------ - And this line has to be exactly 100 chars.---------------------------------------------------------- - And here we have a line which should start wrapping as it is longer than 100 chars. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pellentesque iaculis enim quis hendrerit. Morbi ultrices in odio pharetra commodo.

    +

    This line has to be exactly 99 chars to test part of the logic.------------------------------------
    +And this line has to be exactly 100 chars.----------------------------------------------------------
    +And here we have a line which should start wrapping as it is longer than 100 chars. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pellentesque iaculis enim quis hendrerit. Morbi ultrices in odio pharetra commodo.

    From aed8d933745e84ec7d1983c813a94a0a762e6f44 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Nov 2024 00:55:28 +0100 Subject: [PATCH 801/874] Generators/Text::printTitle(): minor tweaks Just removing some duplicate function calls. --- src/Generators/Text.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Generators/Text.php b/src/Generators/Text.php index ce419ba118..419bcc3d56 100644 --- a/src/Generators/Text.php +++ b/src/Generators/Text.php @@ -5,7 +5,9 @@ * Output is designed to be displayed in a terminal and is wrapped to 100 characters. * * @author Greg Sherwood + * @author Juliette Reinders Folmer * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) + * @copyright 2024 PHPCSStandards and contributors * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ @@ -52,13 +54,15 @@ public function processSniff(DOMNode $doc) */ protected function printTitle(DOMNode $doc) { - $title = $this->getTitle($doc); - $standard = $this->ruleset->name; + $title = $this->getTitle($doc); + $standard = $this->ruleset->name; + $displayTitle = "$standard CODING STANDARD: $title"; + $titleLength = strlen($displayTitle); echo PHP_EOL; - echo str_repeat('-', (strlen("$standard CODING STANDARD: $title") + 4)); - echo strtoupper(PHP_EOL."| $standard CODING STANDARD: $title |".PHP_EOL); - echo str_repeat('-', (strlen("$standard CODING STANDARD: $title") + 4)); + echo str_repeat('-', ($titleLength + 4)); + echo strtoupper(PHP_EOL."| $displayTitle |".PHP_EOL); + echo str_repeat('-', ($titleLength + 4)); echo PHP_EOL.PHP_EOL; }//end printTitle() From 08f41dfa4b7d7aa50b6b4f1dcda7b1c6daeabdbf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 24 Nov 2024 18:12:48 +0100 Subject: [PATCH 802/874] Util/HelpTest: test CBF-only code Now PR 703 has unblocked testing of PHPCBF-only code, the `// @codeCoverageIgnore` annotation for this CBF-only code in the `Util\Help` class can be removed and this code can now be tested. This commit adjusts the relevant test method to ensure that the CBF-only code is also tested. --- src/Util/Help.php | 2 +- tests/Core/Util/Help/HelpTest.php | 52 ++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/Util/Help.php b/src/Util/Help.php index 5a686a97aa..a6a64eedb7 100644 --- a/src/Util/Help.php +++ b/src/Util/Help.php @@ -270,7 +270,7 @@ private function printUsage() { $command = 'phpcs'; if (defined('PHP_CODESNIFFER_CBF') === true && PHP_CODESNIFFER_CBF === true) { - $command = 'phpcbf'; // @codeCoverageIgnore + $command = 'phpcbf'; } $this->printCategoryHeader('Usage'); diff --git a/tests/Core/Util/Help/HelpTest.php b/tests/Core/Util/Help/HelpTest.php index f09a4c1799..b3d51a5c78 100644 --- a/tests/Core/Util/Help/HelpTest.php +++ b/tests/Core/Util/Help/HelpTest.php @@ -3,7 +3,7 @@ * Tests to verify that the "help" command functions as expected. * * @author Juliette Reinders Folmer - * @copyright 2024 Juliette Reinders Folmer. All rights reserved. + * @copyright 2024 PHPCSStandards and contributors * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ @@ -386,7 +386,7 @@ public static function dataOptionFilteringSpacerHandling() /** - * Test that if no short/long options are passed, only usage information is displayed (and displayed correctly). + * Test that if no short/long options are passed, only usage information is displayed (CS mode). * * @param array $cliArgs Command line arguments. * @param string $expectedRegex Regex to validate expected output. @@ -395,7 +395,51 @@ public static function dataOptionFilteringSpacerHandling() * * @return void */ - public function testDisplayUsage($cliArgs, $expectedRegex) + public function testDisplayUsageCS($cliArgs, $expectedRegex) + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $expectedRegex = str_replace('phpc(bf|s)', 'phpcs', $expectedRegex); + $this->verifyDisplayUsage($cliArgs, $expectedRegex); + + }//end testDisplayUsageCS() + + + /** + * Test that if no short/long options are passed, only usage information is displayed (CBF mode). + * + * @param array $cliArgs Command line arguments. + * @param string $expectedRegex Regex to validate expected output. + * + * @dataProvider dataDisplayUsage + * @group CBF + * + * @return void + */ + public function testDisplayUsageCBF($cliArgs, $expectedRegex) + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $expectedRegex = str_replace('phpc(bf|s)', 'phpcbf', $expectedRegex); + $this->verifyDisplayUsage($cliArgs, $expectedRegex); + + }//end testDisplayUsageCBF() + + + /** + * Helper method to test that if no short/long options are passed, only usage information is displayed + * (and displayed correctly). + * + * @param array $cliArgs Command line arguments. + * @param string $expectedRegex Regex to validate expected output. + * + * @return void + */ + private function verifyDisplayUsage($cliArgs, $expectedRegex) { $help = new Help(new ConfigDouble($cliArgs), []); @@ -403,7 +447,7 @@ public function testDisplayUsage($cliArgs, $expectedRegex) $help->display(); - }//end testDisplayUsage() + }//end verifyDisplayUsage() /** From 609ac109d19d61f97ce572f5a806274801a024ac Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 26 Nov 2024 00:16:35 -0300 Subject: [PATCH 803/874] Generic/LowercasedFilename: improve code coverage (#681) Includes adding a test for handling STDIN per suggestion during code review. --- .../Files/LowercasedFilenameUnitTest.php | 45 +++++++++++++++++++ .../Files/lowercased_filename_unit_test.inc | 1 + 2 files changed, 46 insertions(+) create mode 100644 src/Standards/Generic/Tests/Files/lowercased_filename_unit_test.inc diff --git a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php index 894a86dfed..ea7d5aa8b2 100644 --- a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php @@ -9,6 +9,9 @@ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; +use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; /** @@ -20,6 +23,24 @@ final class LowercasedFilenameUnitTest extends AbstractSniffUnitTest { + /** + * Get a list of all test files to check. + * + * @param string $testFileBase The base path that the unit tests files will have. + * + * @return string[] + */ + protected function getTestFiles($testFileBase) + { + $testFileDir = dirname($testFileBase); + $testFiles = parent::getTestFiles($testFileBase); + $testFiles[] = $testFileDir.DIRECTORY_SEPARATOR.'lowercased_filename_unit_test.inc'; + + return $testFiles; + + }//end getTestFiles() + + /** * Returns the lines where errors should occur. * @@ -58,4 +79,28 @@ public function getWarningList() }//end getWarningList() + /** + * Test the sniff bails early when handling STDIN. + * + * @return void + */ + public function testStdIn() + { + $config = new ConfigDouble(); + $config->standards = ['Generic']; + $config->sniffs = ['Generic.Files.LowercasedFilename']; + + $ruleset = new Ruleset($config); + + $content = 'process(); + + $this->assertSame(0, $file->getErrorCount()); + $this->assertSame(0, $file->getWarningCount()); + $this->assertCount(0, $file->getErrors()); + + }//end testStdIn() + + }//end class diff --git a/src/Standards/Generic/Tests/Files/lowercased_filename_unit_test.inc b/src/Standards/Generic/Tests/Files/lowercased_filename_unit_test.inc new file mode 100644 index 0000000000..b3d9bbc7f3 --- /dev/null +++ b/src/Standards/Generic/Tests/Files/lowercased_filename_unit_test.inc @@ -0,0 +1 @@ + Date: Thu, 25 Apr 2024 14:01:48 -0300 Subject: [PATCH 804/874] Generic/EmptyPHPStatement: remove some unreachable code * Removed two unreachable conditions. `$prevNonEmpty` will never be `false` as there will always be at least a PHP open tag token before the semicolon token. * Removed unreachable default case `$tokens[$stackPtr]['type']` will always be either `T_SEMICOLON` or `T_CLOSE_TAG` as those are the two tokens that this sniff listens for. So, the default case will never be reached. --- .../Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php index 4ecf630378..eb7c50ce85 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php @@ -53,10 +53,6 @@ public function process(File $phpcsFile, $stackPtr) case 'T_SEMICOLON': $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($prevNonEmpty === false) { - return; - } - if ($tokens[$prevNonEmpty]['code'] !== T_SEMICOLON && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG_WITH_ECHO @@ -128,9 +124,8 @@ public function process(File $phpcsFile, $stackPtr) case 'T_CLOSE_TAG': $prevNonEmpty = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($prevNonEmpty === false - || ($tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG - && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG_WITH_ECHO) + if ($tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG + && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG_WITH_ECHO ) { return; } @@ -150,10 +145,6 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->endChangeset(); } break; - - default: - // Deliberately left empty. - break; }//end switch }//end process() From 498ecdaa1e066eb14de82631f65a6be837f1e3c6 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 20 Nov 2024 17:20:21 -0300 Subject: [PATCH 805/874] Generic/EmptyPHPStatement: rename test case file Doing this to be able to create another test file to test the sniff with the short open tag. --- ...st.inc => EmptyPHPStatementUnitTest.1.inc} | 0 ... => EmptyPHPStatementUnitTest.1.inc.fixed} | 0 .../EmptyPHPStatementUnitTest.php | 51 +++++++++++-------- 3 files changed, 29 insertions(+), 22 deletions(-) rename src/Standards/Generic/Tests/CodeAnalysis/{EmptyPHPStatementUnitTest.inc => EmptyPHPStatementUnitTest.1.inc} (100%) rename src/Standards/Generic/Tests/CodeAnalysis/{EmptyPHPStatementUnitTest.inc.fixed => EmptyPHPStatementUnitTest.1.inc.fixed} (100%) diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.inc b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.inc rename to src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.inc.fixed b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc.fixed similarity index 100% rename from src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.inc.fixed rename to src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc.fixed diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php index 1b31b5f288..66db633e52 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php @@ -41,31 +41,38 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return [ - 9 => 1, - 12 => 1, - 15 => 1, - 18 => 1, - 21 => 1, - 22 => 1, - 31 => 1, - 33 => 1, - 43 => 1, - 45 => 1, - 49 => 1, - 50 => 1, - 57 => 1, - 59 => 1, - 61 => 1, - 63 => 2, - 71 => 1, - 72 => 1, - 80 => 1, - ]; + switch ($testFile) { + case 'EmptyPHPStatementUnitTest.1.inc': + return [ + 9 => 1, + 12 => 1, + 15 => 1, + 18 => 1, + 21 => 1, + 22 => 1, + 31 => 1, + 33 => 1, + 43 => 1, + 45 => 1, + 49 => 1, + 50 => 1, + 57 => 1, + 59 => 1, + 61 => 1, + 63 => 2, + 71 => 1, + 72 => 1, + 80 => 1, + ]; + default: + return []; + }//end switch }//end getWarningList() From 6105bf7d66d65b34a4fb6ba8bd0df0a03d9304a1 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 20 Nov 2024 17:55:05 -0300 Subject: [PATCH 806/874] Generic/EmptyPHPStatement: add tests for the short open tag --- .../EmptyPHPStatementUnitTest.2.inc | 27 +++++++++++++++++ .../EmptyPHPStatementUnitTest.2.inc.fixed | 23 ++++++++++++++ .../EmptyPHPStatementUnitTest.php | 30 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.2.inc create mode 100644 src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.2.inc.fixed diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.2.inc b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.2.inc new file mode 100644 index 0000000000..a9f895d71b --- /dev/null +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.2.inc @@ -0,0 +1,27 @@ + + + + + +/* + * Test empty statement: no code between PHP open and close tag. + */ + + + + + + + + + + + + diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.2.inc.fixed b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.2.inc.fixed new file mode 100644 index 0000000000..fd27d0a25c --- /dev/null +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.2.inc.fixed @@ -0,0 +1,23 @@ + + + + + +/* + * Test empty statement: no code between PHP open and close tag. + */ + + + + + + + + + + + diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php index 66db633e52..1e59c0a398 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php @@ -20,6 +20,27 @@ final class EmptyPHPStatementUnitTest extends AbstractSniffUnitTest { + /** + * Get a list of all test files to check. + * + * @param string $testFileBase The base path that the unit tests files will have. + * + * @return string[] + */ + protected function getTestFiles($testFileBase) + { + $testFiles = [$testFileBase.'1.inc']; + + $option = (bool) ini_get('short_open_tag'); + if ($option === true) { + $testFiles[] = $testFileBase.'2.inc'; + } + + return $testFiles; + + }//end getTestFiles() + + /** * Returns the lines where errors should occur. * @@ -70,6 +91,15 @@ public function getWarningList($testFile='') 72 => 1, 80 => 1, ]; + case 'EmptyPHPStatementUnitTest.2.inc': + return [ + 3 => 1, + 4 => 1, + 13 => 1, + 15 => 1, + 25 => 1, + 27 => 1, + ]; default: return []; }//end switch From eb7c3a9a355ba9c010b9cc46e6fbf7ccaa9b0aea Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 25 Nov 2024 15:50:51 -0300 Subject: [PATCH 807/874] Generic/EmptyPHPStatement: minor tweaks to test case file * Updated tests to have more examples with more than one superfluous semicolon. * Minor test comment punctuation tweaks. --- .../Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc | 8 ++++---- .../CodeAnalysis/EmptyPHPStatementUnitTest.1.inc.fixed | 4 ++-- .../Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc index 080dda9382..83e071bf42 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc @@ -19,7 +19,7 @@ function_call(); ?> - + /* * Test empty statement: no code between PHP open and close tag. @@ -42,7 +42,7 @@ function_call(); --> - + @@ -53,7 +53,7 @@ function_call(); // Guard against false positives for two consecutive semicolons in a for statement. for ( $i = 0; ; $i++ ) {} -// Test for useless semicolons +// Test for useless semicolons. for ( $i = 0; ; $i++ ) {}; if (true) {}; @@ -80,7 +80,7 @@ if ($foo) { ; } -// Do not remove semicolon after match +// Do not remove semicolon after match. $c = match ($a) { 1 => true, }; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc.fixed index 7f16742288..6bf8b21261 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.1.inc.fixed @@ -48,7 +48,7 @@ function_call(); // Guard against false positives for two consecutive semicolons in a for statement. for ( $i = 0; ; $i++ ) {} -// Test for useless semicolons +// Test for useless semicolons. for ( $i = 0; ; $i++ ) {} if (true) {} @@ -74,7 +74,7 @@ echo $a{0}; if ($foo) { } -// Do not remove semicolon after match +// Do not remove semicolon after match. $c = match ($a) { 1 => true, }; diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php index 1e59c0a398..77542acbaa 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php @@ -76,11 +76,11 @@ public function getWarningList($testFile='') 15 => 1, 18 => 1, 21 => 1, - 22 => 1, + 22 => 2, 31 => 1, 33 => 1, 43 => 1, - 45 => 1, + 45 => 2, 49 => 1, 50 => 1, 57 => 1, From 715242ed676306b616cba8a8acfb549ee1663386 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 25 Nov 2024 03:36:48 +0100 Subject: [PATCH 808/874] Generic//EmptyPHPStatement: reduce complexity/nesting levels Follow up on #699 Commit 529bcba7a42ec35873c31459ae61bee67852e956 removed the unreachable `default` case from the `switch`, but even when it is not explicitly there, this still leaves an unreachable branch in the code flow. This commit takes the previous change one step further and removes the `switch` completely in favour of two separate `private` functions which each handle one specific token. N.B.: this commit will be easier to review while ignoring whitespace changes. --- .../CodeAnalysis/EmptyPHPStatementSniff.php | 188 ++++++++++-------- 1 file changed, 109 insertions(+), 79 deletions(-) diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php index eb7c50ce85..6fbfdc0b2b 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php @@ -48,106 +48,136 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - switch ($tokens[$stackPtr]['type']) { - // Detect `something();;`. - case 'T_SEMICOLON': - $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); - - if ($tokens[$prevNonEmpty]['code'] !== T_SEMICOLON - && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG - && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG_WITH_ECHO + if ($tokens[$stackPtr]['code'] === T_SEMICOLON) { + $this->processSemicolon($phpcsFile, $stackPtr); + } else { + $this->processCloseTag($phpcsFile, $stackPtr); + } + + }//end process() + + + /** + * Detect `something();;`. + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * + * @return void + */ + private function processSemicolon(File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($tokens[$prevNonEmpty]['code'] !== T_SEMICOLON + && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG + && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG_WITH_ECHO + ) { + if (isset($tokens[$prevNonEmpty]['scope_condition']) === false) { + return; + } + + if ($tokens[$prevNonEmpty]['scope_opener'] !== $prevNonEmpty + && $tokens[$prevNonEmpty]['code'] !== T_CLOSE_CURLY_BRACKET ) { - if (isset($tokens[$prevNonEmpty]['scope_condition']) === false) { - return; - } + return; + } - if ($tokens[$prevNonEmpty]['scope_opener'] !== $prevNonEmpty - && $tokens[$prevNonEmpty]['code'] !== T_CLOSE_CURLY_BRACKET - ) { - return; - } + $scopeOwner = $tokens[$tokens[$prevNonEmpty]['scope_condition']]['code']; + if ($scopeOwner === T_CLOSURE || $scopeOwner === T_ANON_CLASS || $scopeOwner === T_MATCH) { + return; + } - $scopeOwner = $tokens[$tokens[$prevNonEmpty]['scope_condition']]['code']; - if ($scopeOwner === T_CLOSURE || $scopeOwner === T_ANON_CLASS || $scopeOwner === T_MATCH) { - return; - } + // Else, it's something like `if (foo) {};` and the semicolon is not needed. + } - // Else, it's something like `if (foo) {};` and the semicolon is not needed. + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { + $nested = $tokens[$stackPtr]['nested_parenthesis']; + $lastCloser = array_pop($nested); + if (isset($tokens[$lastCloser]['parenthesis_owner']) === true + && $tokens[$tokens[$lastCloser]['parenthesis_owner']]['code'] === T_FOR + ) { + // Empty for() condition. + return; } + } - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { - $nested = $tokens[$stackPtr]['nested_parenthesis']; - $lastCloser = array_pop($nested); - if (isset($tokens[$lastCloser]['parenthesis_owner']) === true - && $tokens[$tokens[$lastCloser]['parenthesis_owner']]['code'] === T_FOR - ) { - // Empty for() condition. - return; + $fix = $phpcsFile->addFixableWarning( + 'Empty PHP statement detected: superfluous semicolon.', + $stackPtr, + 'SemicolonWithoutCodeDetected' + ); + + if ($fix === true) { + $phpcsFile->fixer->beginChangeset(); + + if ($tokens[$prevNonEmpty]['code'] === T_OPEN_TAG + || $tokens[$prevNonEmpty]['code'] === T_OPEN_TAG_WITH_ECHO + ) { + // Check for superfluous whitespace after the semicolon which should be + // removed as the `fixer->replaceToken(($stackPtr + 1), $replacement); } } - $fix = $phpcsFile->addFixableWarning( - 'Empty PHP statement detected: superfluous semicolon.', - $stackPtr, - 'SemicolonWithoutCodeDetected' - ); - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); - - if ($tokens[$prevNonEmpty]['code'] === T_OPEN_TAG - || $tokens[$prevNonEmpty]['code'] === T_OPEN_TAG_WITH_ECHO + for ($i = $stackPtr; $i > $prevNonEmpty; $i--) { + if ($tokens[$i]['code'] !== T_SEMICOLON + && $tokens[$i]['code'] !== T_WHITESPACE ) { - // Check for superfluous whitespace after the semicolon which will be - // removed as the `fixer->replaceToken(($stackPtr + 1), $replacement); - } + break; } - for ($i = $stackPtr; $i > $prevNonEmpty; $i--) { - if ($tokens[$i]['code'] !== T_SEMICOLON - && $tokens[$i]['code'] !== T_WHITESPACE - ) { - break; - } + $phpcsFile->fixer->replaceToken($i, ''); + } - $phpcsFile->fixer->replaceToken($i, ''); - } + $phpcsFile->fixer->endChangeset(); + }//end if - $phpcsFile->fixer->endChangeset(); - }//end if - break; + }//end processSemicolon() - // Detect ``. - case 'T_CLOSE_TAG': - $prevNonEmpty = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG - && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG_WITH_ECHO - ) { - return; - } + /** + * Detect ``. + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * + * @return void + */ + private function processCloseTag(File $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); - $fix = $phpcsFile->addFixableWarning( - 'Empty PHP open/close tag combination detected.', - $prevNonEmpty, - 'EmptyPHPOpenCloseTagsDetected' - ); - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); + $prevNonEmpty = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG + && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG_WITH_ECHO + ) { + return; + } - for ($i = $prevNonEmpty; $i <= $stackPtr; $i++) { - $phpcsFile->fixer->replaceToken($i, ''); - } + $fix = $phpcsFile->addFixableWarning( + 'Empty PHP open/close tag combination detected.', + $prevNonEmpty, + 'EmptyPHPOpenCloseTagsDetected' + ); - $phpcsFile->fixer->endChangeset(); + if ($fix === true) { + $phpcsFile->fixer->beginChangeset(); + + for ($i = $prevNonEmpty; $i <= $stackPtr; $i++) { + $phpcsFile->fixer->replaceToken($i, ''); } - break; - }//end switch - }//end process() + $phpcsFile->fixer->endChangeset(); + } + + }//end processCloseTag() }//end class From 1a84fdac1b5558d9e89ccdffb8ac992198757473 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 26 Nov 2024 05:18:48 +0100 Subject: [PATCH 809/874] GH Actions: run phar building test more selectively This workflow is a safeguard to ensure that the PHAR files can be build against any of the supported PHP versions. There are only a few files involved in building the PHAR files, so there isn't really any need to run this workflow for every PR and every merge. It only really needs to run when any of the involved files have changed. Also, keep in mind that the PHAR which is distributed for releases is build on PHP 8.0 and will still be build in the `test` workflow for every PR and every merge, so the functionality of the distribution PHARs is still guaranteed either way. --- .github/workflows/build-phar.yml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-phar.yml b/.github/workflows/build-phar.yml index 403be803cb..b091e24c45 100644 --- a/.github/workflows/build-phar.yml +++ b/.github/workflows/build-phar.yml @@ -1,14 +1,31 @@ name: Build PHARs on: - # Run on pushes to master and on all pull requests. + # Run on pushes to master and on pull requests which touch files used when building the PHARs. # Prevent the build from running when there are only irrelevant changes. push: branches: - master - paths-ignore: - - '**.md' + paths: + - '.github/workflows/build-phar.yml' + - 'scripts/build-phar.php' + - 'autoload.php' + - 'src/Config.php' + - 'src/Exceptions/RuntimeException.php' + - 'src/Exceptions/TokenizerException.php' + - 'src/Tokenizers/PHP.php' + - 'src/Util/Tokens.php' pull_request: + paths: + - '.github/workflows/build-phar.yml' + - 'scripts/build-phar.php' + - 'autoload.php' + - 'src/Config.php' + - 'src/Exceptions/RuntimeException.php' + - 'src/Exceptions/TokenizerException.php' + - 'src/Tokenizers/PHP.php' + - 'src/Util/Tokens.php' + # Allow manually triggering the workflow. workflow_dispatch: From 243aaf4d674d45f966ea296fee11b2c453bc6ae2 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 26 Nov 2024 15:36:12 +0100 Subject: [PATCH 810/874] GH Actions: fix snafu with code coverage Follow up on commit 755f0bc35a466e063f55fa7e7697a05e1289c644, which simplified the `custom_ini` setting for the code coverage builds, but did so incorrectly, meaning that code which needs the `short_open_tag=On` setting was no longer being recorded as covered. Fixed now. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ea04c9384..d295e91204 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -256,8 +256,8 @@ jobs: shell: bash run: | # Set the "short_open_tag" ini to make sure specific conditions are tested. - if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '5.4' ]]; then - echo 'PHP_INI=, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On' >> "$GITHUB_OUTPUT" + if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.2' ]]; then + echo 'PHP_INI=, date.timezone=Australia/Sydney, short_open_tag=On' >> "$GITHUB_OUTPUT" fi - name: Install PHP From f8ed72b9768797c7db92db0f002a64d65b6478d8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Nov 2024 08:00:21 +0100 Subject: [PATCH 811/874] GH Actions/test: allow concurrency for code coverage builds - take two Follow up on 710, which was added with the following reasoning: > The `concurrency` setting will cancel running workflows if a new push to the same branch is seen. This is useful to prevent unnecessary workflow runs (as the previous push was superseded, so the outcome is no longer relevant). > > However, for the "main" branches (`master` and `4.0`), this workflow cancelling means that if multiple PRs are merged in succession, only the code coverage for the _last_ merge is recorded in Coveralls as the workflow runs on `master` for the previous merges will have been cancelled. > > While in practice, it's not a biggie, it does make it more difficult to identify which commit/merge added or decreased code coverage. Let's try this again. The previous attempt to prevent cancelling code coverage builds for merges to the "main" branches is not working as intended and is still cancelling builds. This is likely due to the way GH looks at concurrency groups: > By default, GitHub Actions allows multiple jobs within the same workflow, multiple workflow runs within the same repository, and multiple workflow runs across a repository owner's account to run concurrently. This means that multiple workflow runs, jobs, or steps can run at the same time. > > You can use `*.concurrency` to ensure that only a single job or workflow using the same concurrency group will run at a time. > > This means that there can be at most one running and one pending job in a concurrency group at any time. When a concurrent job or workflow is queued, if another job or workflow using the same concurrency group in the repository is in progress, the queued job or workflow will be `pending`. Any existing `pending` job or workflow in the same concurrency group, if it exists, will be canceled and the new queued job or workflow will take its place. Interpreting this strictly, this appears to mean that, as soon as a `concurrency` `group` name is defined, there can now only be - at most - two builds for that group - one running, one queued -, while without the `concurrency` `group` name being associated with a build, there can be unlimited concurrent builds. This means that code coverage builds for merges in quick succession are still being killed off. This new attempt now moves the `concurrency` setting from the workflow level to the "job" level and adds the `job` name to the `group` key. This should hopefully still allow for cancelling in progress builds for the `build` and `test` jobs, while leaving the `coverage` (and `coveralls-finish`) jobs alone. The down-side of this change (providing it works) is that it can't be limited to the "main" branches, which means that the `coverage` jobs will now continue running for _every_ push to an open pull request as well. While a little wasteful, that appears to be the price to pay. Refs: * https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs --- .github/workflows/test.yml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d295e91204..212798b30f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,16 +14,14 @@ on: # Allow manually triggering the workflow. workflow_dispatch: -# Cancels all previous workflow runs for the same branch that have not yet completed, -# but don't cancel when it's one of the "main" branches as that prevents -# accurate monitoring of code coverage. -concurrency: - # The concurrency group contains the workflow name and the branch name. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref_name != 'master' && github.ref_name != '4.0' }} - jobs: build: + # Cancels all previous runs of this particular job for the same branch that have not yet completed. + concurrency: + # The concurrency group contains the workflow name, job name and the branch name. + group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }} + cancel-in-progress: true + runs-on: ubuntu-latest name: "Build Phar on PHP: 8.0" @@ -82,6 +80,12 @@ jobs: run: php phpcbf.phar ./scripts test: + # Cancels all previous runs of this particular job for the same branch that have not yet completed. + concurrency: + # The concurrency group contains the workflow name, job name, job index and the branch name. + group: ${{ github.workflow }}-${{ github.job }}-${{ strategy.job-index }}-${{ github.ref }} + cancel-in-progress: true + runs-on: ubuntu-latest needs: build @@ -215,6 +219,8 @@ jobs: run: php phpcs.phar coverage: + # Explicitly *NOT* setting "concurrency" for this job to allow for monitoring code coverage for all merges. + runs-on: ${{ matrix.os }} strategy: @@ -256,8 +262,8 @@ jobs: shell: bash run: | # Set the "short_open_tag" ini to make sure specific conditions are tested. - if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.2' ]]; then - echo 'PHP_INI=, date.timezone=Australia/Sydney, short_open_tag=On' >> "$GITHUB_OUTPUT" + if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.2' ]]; then + echo 'PHP_INI=, date.timezone=Australia/Sydney, short_open_tag=On' >> "$GITHUB_OUTPUT" fi - name: Install PHP From a60ed631b1c1ec6d36ed12a0fd929b4f3a49d226 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 5 Nov 2024 20:10:43 -0300 Subject: [PATCH 812/874] Generic/UpperCaseConstantName: handle unconventional spacing and comments after `define(` This commit fixes false negatives in the sniff when handling unconventional spacing and comments after `define(`. When checking for the constant name after the opening parenthesis, the sniff would incorrectly exclude only whitespaces while comments can also be placed between the opening parenthesis and the constant name. Looking for the constant name by getting the next non-empty token after the opening parenthesis fixes this problem. The added tests also include comments between `define` and the opening parenthesis but that was already handled correctly by the sniff. --- .../NamingConventions/UpperCaseConstantNameSniff.php | 4 ++-- .../UpperCaseConstantNameUnitTest.inc | 10 ++++++++++ .../UpperCaseConstantNameUnitTest.php | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index f62cfe94bd..5be892e880 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -103,8 +103,8 @@ public function process(File $phpcsFile, $stackPtr) return; } - // The next non-whitespace token must be the constant name. - $constPtr = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), null, true); + // The next non-empty token must be the constant name. + $constPtr = $phpcsFile->findNext(Tokens::$emptyTokens, ($openBracket + 1), null, true); if ($tokens[$constPtr]['code'] !== T_CONSTANT_ENCAPSED_STRING) { return; } diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc index 20bbf90e26..60bb415cf9 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc @@ -41,3 +41,13 @@ class TypedConstants { const FALSE false = false; // Yes, false can be used as a constant name, don't ask. const array ARRAY = array(); // Same goes for array. } + +define /* comment */ ( /* comment */ 'CommentsInUnconventionalPlaces', 'value' ); + +define +// comment +( + // phpcs:ignore Stnd.Cat.SniffName -- for reasons. + 'CommentsInUnconventionalPlaces', + 'value' +); diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php index afe3625589..4394951012 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php @@ -40,6 +40,8 @@ public function getErrorList() 30 => 1, 40 => 1, 41 => 1, + 45 => 1, + 47 => 1, ]; }//end getErrorList() From 67ae15447a4313175adebb94c02d3ee5d66666f4 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 6 Nov 2024 11:33:23 -0300 Subject: [PATCH 813/874] Generic/UpperCaseConstantName: handle unconventional spacing and comments before `define` This commit fixes false positives in the sniff when handling unconventional spacing and comments before `define`. When checking to see if the `define` found is not a method call, the sniff would incorrectly exclude only whitespaces. But comments can also be placed between `define` and one of the tokens the sniff looks for (T_OBJECT_OPERATOR, T_DOUBLE_COLON or T_NULLSAFE_OBJECT_OPERATOR). Looking for the first non-empty token before `define` fixes this problem. --- .../Sniffs/NamingConventions/UpperCaseConstantNameSniff.php | 2 +- .../NamingConventions/UpperCaseConstantNameUnitTest.inc | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index 5be892e880..a2c22ecb73 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -88,7 +88,7 @@ public function process(File $phpcsFile, $stackPtr) } // Make sure this is not a method call. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR || $tokens[$prev]['code'] === T_DOUBLE_COLON || $tokens[$prev]['code'] === T_NULLSAFE_OBJECT_OPERATOR diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc index 60bb415cf9..6531b8d49a 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc @@ -51,3 +51,8 @@ define 'CommentsInUnconventionalPlaces', 'value' ); + +$foo-> /* comment */ define('bar'); +$foo?-> +// phpcs:ignore Stnd.Cat.SniffName -- for reasons. +define('bar'); From fb13110e0a20acded44ad5de61c375f0ac3d1b7a Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 6 Nov 2024 12:07:58 -0300 Subject: [PATCH 814/874] Generic/UpperCaseConstantName: false positives when constant name is "DEFINE" This commit fixes false positives when the sniff encounters a constant named "DEFINE". When looking for calls to `define()`, the code was checking only if there was a non-empty token after `define`. Instead, it should check if the next non-empty token after `define` is `T_OPEN_PARENTHESIS`. --- .../Sniffs/NamingConventions/UpperCaseConstantNameSniff.php | 2 +- .../Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index a2c22ecb73..3b59343cd0 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -99,7 +99,7 @@ public function process(File $phpcsFile, $stackPtr) // If the next non-whitespace token after this token // is not an opening parenthesis then it is not a function call. $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); - if ($openBracket === false) { + if ($openBracket === false || $tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { return; } diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc index 6531b8d49a..7ca6196c78 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc @@ -56,3 +56,5 @@ $foo-> /* comment */ define('bar'); $foo?-> // phpcs:ignore Stnd.Cat.SniffName -- for reasons. define('bar'); + +const DEFINE = 'value'; From 66837c3367f64544431757ad6912bd503a2ec454 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 6 Nov 2024 12:07:58 -0300 Subject: [PATCH 815/874] Generic/UpperCaseConstantName: fix attributes false positive This commit fixes false positives in the sniff when handling attributes called `define`. Before this change the sniff was not taking into account that `define` is a valid name for an attribute, and it would incorrectly handle these cases as calls to the `define()` function. --- .../NamingConventions/UpperCaseConstantNameSniff.php | 5 +++++ .../NamingConventions/UpperCaseConstantNameUnitTest.inc | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index 3b59343cd0..6a0e39b49f 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -96,6 +96,11 @@ public function process(File $phpcsFile, $stackPtr) return; } + // Make sure this is not an attribute. + if (empty($tokens[$stackPtr]['nested_attributes']) === false) { + return; + } + // If the next non-whitespace token after this token // is not an opening parenthesis then it is not a function call. $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc index 7ca6196c78..1680676fb6 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc @@ -58,3 +58,12 @@ $foo?-> define('bar'); const DEFINE = 'value'; + +#[Define('some param')] +class MyClass {} + +#[ + AttributeA, + define('some param') +] +class MyClass {} From 0ac027f5c7f3d7d1f4eb683158cd294bc5bc0712 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 5 Nov 2024 20:40:50 -0300 Subject: [PATCH 816/874] Generic/UpperCaseConstantName: minor improvement to the error message and metrics This commit implements a minor improvement to the error message and metric recording when handling calls to `define()`. Now the line of the error or the line recorded in the metric will be the line of the constant name. Before it was the line of the T_DEFINE token. --- .../NamingConventions/UpperCaseConstantNameSniff.php | 8 ++++---- .../NamingConventions/UpperCaseConstantNameUnitTest.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index 6a0e39b49f..f129aa6ef2 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -133,9 +133,9 @@ public function process(File $phpcsFile, $stackPtr) if (strtoupper($constName) !== $constName) { if (strtolower($constName) === $constName) { - $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'lower'); + $phpcsFile->recordMetric($constPtr, 'Constant name case', 'lower'); } else { - $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'mixed'); + $phpcsFile->recordMetric($constPtr, 'Constant name case', 'mixed'); } $error = 'Constants must be uppercase; expected %s but found %s'; @@ -143,9 +143,9 @@ public function process(File $phpcsFile, $stackPtr) $prefix.strtoupper($constName), $prefix.$constName, ]; - $phpcsFile->addError($error, $stackPtr, 'ConstantNotUpperCase', $data); + $phpcsFile->addError($error, $constPtr, 'ConstantNotUpperCase', $data); } else { - $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'upper'); + $phpcsFile->recordMetric($constPtr, 'Constant name case', 'upper'); } }//end process() diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php index 4394951012..797627ae7f 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php @@ -41,7 +41,7 @@ public function getErrorList() 40 => 1, 41 => 1, 45 => 1, - 47 => 1, + 51 => 1, ]; }//end getErrorList() From d129e9b60292f8106c028ab744e83ef42b62bba2 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 11 Nov 2024 11:43:44 -0300 Subject: [PATCH 817/874] Generic/UpperCaseConstantName: remove special case for double-colon In early versions of this sniff, constant names were checked not only when defined, but also when used. At that time, code was added to handle the dynamic retrieval of class constants in calls to `constant()` by checking if the constant name contained a double-colon (see https://github.com/squizlabs/PHP_CodeSniffer/commit/610b0cc3f1584ccd050a4970ab80843832c46d73 and https://pear.php.net/bugs/bug.php?id=18670). If so, the sniff would enforce upper case only for the substring after the double-colon. Later, another commit removed support for constant usage (https://github.com/squizlabs/PHP_CodeSniffer/commit/4af13118b1fedd89faadd78b9bc and https://pear.php.net/bugs/bug.php?id=20090). It seems to me that the code that is removed in this commit, should have been removed when support for constant usage was removed. The removed code is only triggered when a constant is defined using `define()`. As far as I can tell, over time, PHP changed how it behaves when a double-colon is passed as part of the first parameter of `define()`. However, never in a way that justifies special treatment in the context of this sniff (https://3v4l.org/erZcK). At least not since PHP 5.0 (I'm assuming it is not needed to check PHP 4). --- .../NamingConventions/UpperCaseConstantNameSniff.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index f129aa6ef2..c06695c105 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -115,14 +115,7 @@ public function process(File $phpcsFile, $stackPtr) } $constName = $tokens[$constPtr]['content']; - - // Check for constants like self::CONSTANT. - $prefix = ''; - $splitPos = strpos($constName, '::'); - if ($splitPos !== false) { - $prefix = substr($constName, 0, ($splitPos + 2)); - $constName = substr($constName, ($splitPos + 2)); - } + $prefix = ''; // Strip namespace from constant like /foo/bar/CONSTANT. $splitPos = strrpos($constName, '\\'); From 17b916441acf2ea9d38c4ad999ca004e8cd0b2c9 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 5 Nov 2024 08:27:27 -0300 Subject: [PATCH 818/874] Generic/UpperCaseConstantName: rename test case file Doing this to be able to create tests with syntax errors on separate files. --- ...nc => UpperCaseConstantNameUnitTest.1.inc} | 0 .../UpperCaseConstantNameUnitTest.php | 35 +++++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) rename src/Standards/Generic/Tests/NamingConventions/{UpperCaseConstantNameUnitTest.inc => UpperCaseConstantNameUnitTest.1.inc} (100%) diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc rename to src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php index 797627ae7f..aafe62a56b 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.php @@ -26,23 +26,30 @@ final class UpperCaseConstantNameUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the test file to process. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 8 => 1, - 10 => 1, - 12 => 1, - 14 => 1, - 19 => 1, - 28 => 1, - 30 => 1, - 40 => 1, - 41 => 1, - 45 => 1, - 51 => 1, - ]; + switch ($testFile) { + case 'UpperCaseConstantNameUnitTest.1.inc': + return [ + 8 => 1, + 10 => 1, + 12 => 1, + 14 => 1, + 19 => 1, + 28 => 1, + 30 => 1, + 40 => 1, + 41 => 1, + 45 => 1, + 51 => 1, + ]; + default: + return []; + } }//end getErrorList() From 2e6885061f28fe311862055f762fa6398847db19 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 8 Nov 2024 11:22:04 -0300 Subject: [PATCH 819/874] Generic/UpperCaseConstantName: `findNext()` may return `false` This commit takes into account that `findNext()` may return `false` and properly handles this case in the modified `if` condition. There were no issues without this extra check, as when `$constPtr` is `false`, `$tokens[$constPrt]` evaluates to the first token in the stack and the first token can never be `T_CONSTANT_ENCAPSED_STRING`, so the sniff would bail early anyway. --- .../NamingConventions/UpperCaseConstantNameSniff.php | 2 +- .../NamingConventions/UpperCaseConstantNameUnitTest.2.inc | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.2.inc diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index c06695c105..8461a1abaf 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -110,7 +110,7 @@ public function process(File $phpcsFile, $stackPtr) // The next non-empty token must be the constant name. $constPtr = $phpcsFile->findNext(Tokens::$emptyTokens, ($openBracket + 1), null, true); - if ($tokens[$constPtr]['code'] !== T_CONSTANT_ENCAPSED_STRING) { + if ($constPtr === false || $tokens[$constPtr]['code'] !== T_CONSTANT_ENCAPSED_STRING) { return; } diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.2.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.2.inc new file mode 100644 index 0000000000..4136912dc9 --- /dev/null +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.2.inc @@ -0,0 +1,7 @@ + Date: Wed, 6 Nov 2024 10:51:23 -0300 Subject: [PATCH 820/874] Generic/UpperCaseConstantName: improve code coverage Includes updating a sniff code comment to better describe what it does. Some of the cases described were not covered by tests before the changes in this commit. --- .../UpperCaseConstantNameSniff.php | 5 ++++- .../UpperCaseConstantNameUnitTest.1.inc | 19 ++++++++++++++++--- .../UpperCaseConstantNameUnitTest.3.inc | 7 +++++++ .../UpperCaseConstantNameUnitTest.4.inc | 7 +++++++ .../UpperCaseConstantNameUnitTest.php | 2 ++ 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.3.inc create mode 100644 src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.4.inc diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index 8461a1abaf..ad4d936b96 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -108,7 +108,10 @@ public function process(File $phpcsFile, $stackPtr) return; } - // The next non-empty token must be the constant name. + // Bow out if next non-empty token after the opening parenthesis is not a string (the + // constant name). This could happen when live coding, if the constant is a variable or an + // expression, or if handling a first-class callable or a function definition outside the + // global scope. $constPtr = $phpcsFile->findNext(Tokens::$emptyTokens, ($openBracket + 1), null, true); if ($constPtr === false || $tokens[$constPtr]['code'] !== T_CONSTANT_ENCAPSED_STRING) { return; diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc index 1680676fb6..cb60d04986 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc @@ -5,7 +5,7 @@ namespace foo\bar; namespace bar\foo\baz; define('VALID_NAME', true); -define('invalidName', true); +DEFINE('invalidName', true); define("VALID_NAME", true); define("invalidName", true); define('bar\foo\baz\VALID_NAME_WITH_NAMESPACE', true); @@ -37,9 +37,9 @@ class TypedConstants { const MISSING_VALUE; // Parse error. const MyClass MYCONST = new MyClass; const int VALID_NAME = 0; - const INT invalid_name = 0; + final public const INT invalid_name = 0; const FALSE false = false; // Yes, false can be used as a constant name, don't ask. - const array ARRAY = array(); // Same goes for array. + final protected const array ARRAY = array(); // Same goes for array. } define /* comment */ ( /* comment */ 'CommentsInUnconventionalPlaces', 'value' ); @@ -67,3 +67,16 @@ class MyClass {} define('some param') ] class MyClass {} + +const MixedCase = 1; + +define('lower_case_name', 'value'); +define($var, 'sniff should bow out'); +define(constantName(), 'sniff should bow out'); +define($obj->constantName(), 'sniff should bow out'); +define(MyClass::constantName(), 'sniff should bow out'); +define(condition() ? 'name1' : 'name2', 'sniff should bow out'); + +// Valid if outside the global namespace. Sniff should bow out. +function define($param) {} +$callable = define(...); diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.3.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.3.inc new file mode 100644 index 0000000000..5808142144 --- /dev/null +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.3.inc @@ -0,0 +1,7 @@ + 1, 45 => 1, 51 => 1, + 71 => 1, + 73 => 1, ]; default: return []; From 60803038e5e997f0b4868e9c8747effffcdbf0b2 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 26 Nov 2024 15:33:41 -0300 Subject: [PATCH 821/874] Improve tests based on feedback from PR review --- .../UpperCaseConstantNameUnitTest.1.inc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc index cb60d04986..93a8835c01 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc @@ -77,6 +77,13 @@ define($obj->constantName(), 'sniff should bow out'); define(MyClass::constantName(), 'sniff should bow out'); define(condition() ? 'name1' : 'name2', 'sniff should bow out'); +$callable = define(...); + // Valid if outside the global namespace. Sniff should bow out. function define($param) {} -$callable = define(...); + +class MyClass { + public function define($param) {} +} + +$a = ($cond) ? DEFINE : SOMETHING_ELSE; From fe50ba77278628fc0e38d3bed6114e864ec3b198 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 26 Nov 2024 15:44:11 -0300 Subject: [PATCH 822/874] Generic/UpperCaseConstantName: fix false positive for class instantiation This commit fixes a false positive that would trigger an error when this sniff encountered the instantiation of a class named `Define`. --- .../Sniffs/NamingConventions/UpperCaseConstantNameSniff.php | 3 ++- .../NamingConventions/UpperCaseConstantNameUnitTest.1.inc | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index ad4d936b96..259fa2963d 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -87,11 +87,12 @@ public function process(File $phpcsFile, $stackPtr) return; } - // Make sure this is not a method call. + // Make sure this is not a method call or class instantiation. $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR || $tokens[$prev]['code'] === T_DOUBLE_COLON || $tokens[$prev]['code'] === T_NULLSAFE_OBJECT_OPERATOR + || $tokens[$prev]['code'] === T_NEW ) { return; } diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc index 93a8835c01..7c1dc41a04 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc @@ -87,3 +87,5 @@ class MyClass { } $a = ($cond) ? DEFINE : SOMETHING_ELSE; + +$object = new Define('value'); From 829c9da3acb1f5ed824dbe0b558f0ecbdaf9b14e Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 26 Nov 2024 15:48:31 -0300 Subject: [PATCH 823/874] Generic/UpperCaseConstantName: move parse error test to its own file --- .../UpperCaseConstantNameUnitTest.1.inc | 2 +- .../UpperCaseConstantNameUnitTest.5.inc | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.5.inc diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc index 7c1dc41a04..c5af2349cb 100644 --- a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.1.inc @@ -34,7 +34,7 @@ $foo->getBar()?->define('foo'); // PHP 8.3 introduces typed constants. class TypedConstants { - const MISSING_VALUE; // Parse error. + const MyClass MYCONST = new MyClass; const int VALID_NAME = 0; final public const INT invalid_name = 0; diff --git a/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.5.inc b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.5.inc new file mode 100644 index 0000000000..96e36a3b1a --- /dev/null +++ b/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.5.inc @@ -0,0 +1,9 @@ + Date: Thu, 21 Nov 2024 08:55:34 -0300 Subject: [PATCH 824/874] Generic/OpeningFunctionBraceKernighanRichie: remove repeated call to findPrevious() This commit removes a repeated call to findPrevious() to get the pointer to the end of the function declaration. The same `$prev` variable that was defined a few lines above can be reused and there is no need to define it again calling `findPrevious()` with exactly the same parameters. --- .../Functions/OpeningFunctionBraceKernighanRitchieSniff.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php index ca259854e7..3b6c8227b5 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php @@ -99,7 +99,6 @@ public function process(File $phpcsFile, $stackPtr) $error = 'Opening brace should be on the same line as the declaration'; $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnNewLine'); if ($fix === true) { - $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($openingBrace - 1), $closeBracket, true); $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->addContent($prev, ' {'); $phpcsFile->fixer->replaceToken($openingBrace, ''); From a375eeace776843826d768c872ab2610bc1472d4 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 21 Nov 2024 15:31:34 -0300 Subject: [PATCH 825/874] Generic/OpeningFunctionBraceKernighanRichie: improve handling of tabs in a fixer This commit makes a tiny performance improvement to the sniff when handling fixing code with tabs. Before this change, the sniff would need two passes of the fixer for code with one tab before the opening brace. First, it would add a space between the tab and the opening brace. Then, on a second pass, it would replace the tab and the space with just one space. Now, it replaces the tab with the space directly without the need for a second pass. --- .../Functions/OpeningFunctionBraceKernighanRitchieSniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php index 3b6c8227b5..f8fa07582d 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php @@ -167,7 +167,7 @@ public function process(File $phpcsFile, $stackPtr) $data = [$length]; $fix = $phpcsFile->addFixableError($error, $openingBrace, 'SpaceBeforeBrace', $data); if ($fix === true) { - if ($length === 0 || $length === '\t') { + if ($length === 0) { $phpcsFile->fixer->addContentBefore($openingBrace, ' '); } else { $phpcsFile->fixer->replaceToken(($openingBrace - 1), ' '); From 111d8515795a703b26fce6d1f58fa12e281481f0 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 21 Nov 2024 07:50:56 -0300 Subject: [PATCH 826/874] Generic/OpeningFunctionBraceKernighanRichie: rename test case file Doing this to be able to create tests with syntax errors on separate files. --- ...nctionBraceKernighanRitchieUnitTest.1.inc} | 0 ...BraceKernighanRitchieUnitTest.1.inc.fixed} | 0 ...gFunctionBraceKernighanRitchieUnitTest.php | 69 ++++++++++--------- 3 files changed, 38 insertions(+), 31 deletions(-) rename src/Standards/Generic/Tests/Functions/{OpeningFunctionBraceKernighanRitchieUnitTest.inc => OpeningFunctionBraceKernighanRitchieUnitTest.1.inc} (100%) rename src/Standards/Generic/Tests/Functions/{OpeningFunctionBraceKernighanRitchieUnitTest.inc.fixed => OpeningFunctionBraceKernighanRitchieUnitTest.1.inc.fixed} (100%) diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc rename to src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc.fixed b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc.fixed similarity index 100% rename from src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc.fixed rename to src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc.fixed diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php index f98430768f..30e74ce105 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php @@ -26,40 +26,47 @@ final class OpeningFunctionBraceKernighanRitchieUnitTest extends AbstractSniffUn * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the test file to process. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 9 => 1, - 13 => 1, - 17 => 1, - 29 => 1, - 33 => 1, - 37 => 1, - 53 => 1, - 58 => 1, - 63 => 1, - 77 => 1, - 82 => 1, - 87 => 1, - 104 => 1, - 119 => 1, - 123 => 1, - 127 => 1, - 132 => 1, - 137 => 1, - 142 => 1, - 157 => 1, - 162 => 1, - 171 => 1, - 181 => 1, - 191 => 1, - 197 => 1, - 203 => 1, - 213 => 1, - 214 => 1, - ]; + switch ($testFile) { + case 'OpeningFunctionBraceKernighanRitchieUnitTest.1.inc': + return [ + 9 => 1, + 13 => 1, + 17 => 1, + 29 => 1, + 33 => 1, + 37 => 1, + 53 => 1, + 58 => 1, + 63 => 1, + 77 => 1, + 82 => 1, + 87 => 1, + 104 => 1, + 119 => 1, + 123 => 1, + 127 => 1, + 132 => 1, + 137 => 1, + 142 => 1, + 157 => 1, + 162 => 1, + 171 => 1, + 181 => 1, + 191 => 1, + 197 => 1, + 203 => 1, + 213 => 1, + 214 => 1, + ]; + default: + return []; + }//end switch }//end getErrorList() From 195346f36e4ad32b00584c63576f93b7053802ca Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 21 Nov 2024 08:51:33 -0300 Subject: [PATCH 827/874] Generic/OpeningFunctionBraceKernighanRichie: improve test coverage Includes removing unnecessary trailing spaces from empty lines in the test file. --- ...unctionBraceKernighanRitchieUnitTest.1.inc | 30 +++++++++++++---- ...nBraceKernighanRitchieUnitTest.1.inc.fixed | 32 +++++++++++++++---- ...unctionBraceKernighanRitchieUnitTest.2.inc | 11 +++++++ ...nBraceKernighanRitchieUnitTest.2.inc.fixed | 11 +++++++ ...unctionBraceKernighanRitchieUnitTest.3.inc | 7 ++++ ...gFunctionBraceKernighanRitchieUnitTest.php | 25 +++++++++++++++ 6 files changed, 104 insertions(+), 12 deletions(-) create mode 100644 src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc create mode 100644 src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc.fixed create mode 100644 src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.3.inc diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc index 6c937a823b..2e76d62155 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc @@ -23,16 +23,16 @@ class myClass // Good. function myFunction() { } - + // Brace should be on same line. function myFunction() { } - + // Too many spaces. function myFunction() { } - + // Uses tab. function myFunction() { } @@ -70,18 +70,18 @@ class myClass function myFunction($variable1, $variable2, $variable3, $variable4) { } - + // Brace should be on same line. function myFunction($variable1, $variable2, $variable3, $variable4) { } - + // Too many spaces. function myFunction($variable1, $variable2, $variable3, $variable4) { } - + // Uses tab. function myFunction($variable1, $variable2, $variable3, $variable4) { @@ -212,3 +212,21 @@ function myFunction($a, $lot, $of, $params) function myFunction() {} function myFunction() {} // Too many spaces with an empty function. function myFunction() {} // Too many spaces (tab) with an empty function. + +// phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkFunctions 0 +function shouldBeIgnored() +{} +// phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkFunctions 1 + +function dnfReturnType(): (Response&SuccessResponse)|AnotherResponse|string +{} + +function commentAfterOpeningBrace() { // Some comment. +} + +function variableAssignmentAfterOpeningBrace() { $a = 1; +} + +abstract class MyClass { + abstract public function abstractMethod(); +} diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc.fixed index bfb2283844..14e62eae90 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.1.inc.fixed @@ -22,15 +22,15 @@ class myClass // Good. function myFunction() { } - + // Brace should be on same line. function myFunction() { } - + // Too many spaces. function myFunction() { } - + // Uses tab. function myFunction() { } @@ -67,17 +67,17 @@ class myClass function myFunction($variable1, $variable2, $variable3, $variable4) { } - + // Brace should be on same line. function myFunction($variable1, $variable2, $variable3, $variable4) { } - + // Too many spaces. function myFunction($variable1, $variable2, $variable3, $variable4) { } - + // Uses tab. function myFunction($variable1, $variable2, $variable3, $variable4) { @@ -200,3 +200,23 @@ function myFunction($a, $lot, $of, $params) function myFunction() {} function myFunction() {} // Too many spaces with an empty function. function myFunction() {} // Too many spaces (tab) with an empty function. + +// phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkFunctions 0 +function shouldBeIgnored() +{} +// phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkFunctions 1 + +function dnfReturnType(): (Response&SuccessResponse)|AnotherResponse|string { +} + +function commentAfterOpeningBrace() { + // Some comment. +} + +function variableAssignmentAfterOpeningBrace() { + $a = 1; +} + +abstract class MyClass { + abstract public function abstractMethod(); +} diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc new file mode 100644 index 0000000000..a145bb9efe --- /dev/null +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc @@ -0,0 +1,11 @@ +tabWidth = 4; + } + + }//end setCliValues() + + /** * Returns the lines where errors should occur. * @@ -63,6 +80,14 @@ public function getErrorList($testFile='') 203 => 1, 213 => 1, 214 => 1, + 222 => 1, + 224 => 1, + 227 => 1, + ]; + case 'OpeningFunctionBraceKernighanRitchieUnitTest.2.inc': + return [ + 6 => 1, + 10 => 1, ]; default: return []; From 286cd814b8e105a472d64d68a9aba524862809a7 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 26 Nov 2024 16:54:28 -0300 Subject: [PATCH 828/874] Generic/OpeningFunctionBraceKernighanRitchie: simplify logic to find end of the function signature When finding the end of the function signature, the sniff had an unnecessary block of code to change the `$end` parameter passed to `findPrevious()` when handling a closure with a `use` statement. Since we are looking for the first non-empty token before the opening curly brace, it is not necessary to change the value of the `$end` parameter. Actually, we don't even need to limit the search and we can pass `null` (the default value). The returned first non-empty token will be the same anyway regardless if `$end` is the closing parenthesis before `use`, after `use` or `null`. --- .../OpeningFunctionBraceKernighanRitchieSniff.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php index f8fa07582d..1e2df37d86 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php @@ -72,17 +72,9 @@ public function process(File $phpcsFile, $stackPtr) } $openingBrace = $tokens[$stackPtr]['scope_opener']; - $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; - if ($tokens[$stackPtr]['code'] === T_CLOSURE) { - $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']); - if ($use !== false) { - $openBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1)); - $closeBracket = $tokens[$openBracket]['parenthesis_closer']; - } - } // Find the end of the function declaration. - $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($openingBrace - 1), $closeBracket, true); + $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($openingBrace - 1), null, true); $functionLine = $tokens[$prev]['line']; $braceLine = $tokens[$openingBrace]['line']; From 6b106cc18458f14c95ff6e6e435f61926c285c5c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Nov 2024 10:36:56 +0100 Subject: [PATCH 829/874] Generic/OpeningFunctionBraceKernighanRitchie: improve error message Follow up on 707 When there are multiple tabs between the end of the function signature and the open brace, the "found: $length" part of the error message would refer to the number of tabs found. This is inconsistent with other sniffs and confusing. This commit fixes this, while still maintaining the previous behaviour - as introduced via https://github.com/squizlabs/PHP_CodeSniffer/commit/c4b9807cdb661635b71d5c1950e05c5189904a70 - of special casing the messaging for a single tab - independently of whether or not tab replacement is in effect. Example for line 10 of test case file 2: ``` // Before: Expected 1 space before opening brace; found 3 // After: Expected 1 space before opening brace; found 11 ``` Covered via pre-existing tests in both test case files + some additional new tests. --- ...ningFunctionBraceKernighanRitchieSniff.php | 20 +++++++++++-------- ...unctionBraceKernighanRitchieUnitTest.2.inc | 8 ++++++++ ...nBraceKernighanRitchieUnitTest.2.inc.fixed | 8 ++++++++ ...gFunctionBraceKernighanRitchieUnitTest.php | 2 ++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php index 1e2df37d86..d5a84982cd 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php @@ -138,22 +138,26 @@ public function process(File $phpcsFile, $stackPtr) return; } - // We are looking for tabs, even if they have been replaced, because - // we enforce a space here. - if (isset($tokens[($openingBrace - 1)]['orig_content']) === true) { - $spacing = $tokens[($openingBrace - 1)]['orig_content']; - } else { - $spacing = $tokens[($openingBrace - 1)]['content']; - } - + // Enforce a single space. Tabs not allowed. + $spacing = $tokens[($openingBrace - 1)]['content']; if ($tokens[($openingBrace - 1)]['code'] !== T_WHITESPACE) { $length = 0; } else if ($spacing === "\t") { + // Tab without tab-width set, so no tab replacement has taken place. $length = '\t'; } else { $length = strlen($spacing); } + // If tab replacement is on, avoid confusing the user with a "expected 1 space, found 1" + // message when the "1" found is actually a tab, not a space. + if ($length === 1 + && isset($tokens[($openingBrace - 1)]['orig_content']) === true + && $tokens[($openingBrace - 1)]['orig_content'] === "\t" + ) { + $length = '\t'; + } + if ($length !== 1) { $error = 'Expected 1 space before opening brace; found %s'; $data = [$length]; diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc index a145bb9efe..36b5e8187d 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc @@ -9,3 +9,11 @@ function myFunction() { // Uses three tabs. function myFunction() { } + +// Uses one tab in a way that it translates to exactly one space with tab replacement. +function oneT() { +} + +// Mixed tabs and spaces. +function mixed() { +} diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc.fixed b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc.fixed index 515a93e50a..a3c47435de 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc.fixed +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.2.inc.fixed @@ -9,3 +9,11 @@ function myFunction() { // Uses three tabs. function myFunction() { } + +// Uses one tab in a way that it translates to exactly one space with tab replacement. +function oneT() { +} + +// Mixed tabs and spaces. +function mixed() { +} diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php index 0c1a99300a..747d54d84c 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php @@ -88,6 +88,8 @@ public function getErrorList($testFile='') return [ 6 => 1, 10 => 1, + 14 => 1, + 18 => 1, ]; default: return []; From ca4081cc4333d34e631d22cf9d3aad4bbd669ef8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Nov 2024 18:52:23 +0100 Subject: [PATCH 830/874] Generators/Markdown: fix line break and indentation handling As things were, line breaks in a `` block were not respected for proper display in markdown. As a side-effect of this, an indented text line in a `` block directly after a blank line, would unintentionally cause the markdown to display the line as a code block (via the indentation). This has now been fixed by: * Trimming indentation off each line. * Adding two spaces to the end of each line as long as the line is not followed by a blank line or at the end of the standard block. The two spaces will ensure markdown will recognize the line break (in most markdown flavours). Includes updated test expectations. Refs: * https://www.markdownguide.org/basic-syntax/#paragraph-best-practices * https://www.markdownguide.org/basic-syntax/#line-break-best-practices * https://daringfireball.net/projects/markdown/syntax#p --- src/Generators/Markdown.php | 30 +++++++++++++++---- .../ExpectedOutputCodeComparisonLineLength.md | 4 +-- .../ExpectedOutputStandardBlankLines.md | 4 +-- .../ExpectedOutputStandardEncoding.md | 4 +-- .../ExpectedOutputStandardIndent.md | 8 ++--- .../ExpectedOutputStandardLineWrapping.md | 6 ++-- 6 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index 76dbb0605f..eb51b60c77 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -117,14 +117,34 @@ protected function printTextBlock(DOMNode $node) { $content = trim($node->nodeValue); $content = htmlspecialchars($content, (ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401)); - - // Use the correct line endings based on the OS. - $content = str_replace("\n", PHP_EOL, $content); - $content = str_replace('<em>', '*', $content); $content = str_replace('</em>', '*', $content); - echo $content.PHP_EOL; + $nodeLines = explode("\n", $content); + $lineCount = count($nodeLines); + $lines = []; + + for ($i = 0; $i < $lineCount; $i++) { + $currentLine = trim($nodeLines[$i]); + if ($currentLine === '') { + // The text contained a blank line. Respect this. + $lines[] = ''; + continue; + } + + // Check if the _next_ line is blank. + if (isset($nodeLines[($i + 1)]) === false + || trim($nodeLines[($i + 1)]) === '' + ) { + // Next line is blank, just add the line. + $lines[] = $currentLine; + } else { + // Ensure that line breaks are respected in markdown. + $lines[] = $currentLine.' '; + } + } + + echo implode(PHP_EOL, $lines).PHP_EOL; }//end printTextBlock() diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md index 89ae055bfb..8dbf564261 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeComparisonLineLength.md @@ -2,8 +2,8 @@ ## Code Comparison, line length -Ensure there is no PHP "Warning: str_repeat(): Second argument has to be greater than or equal to 0". - Ref: squizlabs/PHP_CodeSniffer#2522 +Ensure there is no PHP "Warning: str_repeat(): Second argument has to be greater than or equal to 0". +Ref: squizlabs/PHP_CodeSniffer#2522
    Valid: contains line which is too long.
    diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md index 6b3d6ed107..f8663f14f3 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardBlankLines.md @@ -4,8 +4,8 @@ There is a blank line at the start of this standard. - And the above blank line is also deliberate to test part of the logic. +And the above blank line is also deliberate to test part of the logic. - Let's also end on a blank line to test that too. +Let's also end on a blank line to test that too. Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md index f682daf611..6183dc0037 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardEncoding.md @@ -2,7 +2,7 @@ ## Standard Element, handling of HTML tags -The use of *tags* in standard descriptions is allowed and their handling should be *safeguarded*. - Other tags, like <a href="example.com">link</a>, <b>bold</bold>, <script></script> are not allowed and will be encoded for display when the HTML or Markdown report is used. +The use of *tags* in standard descriptions is allowed and their handling should be *safeguarded*. +Other tags, like <a href="example.com">link</a>, <b>bold</bold>, <script></script> are not allowed and will be encoded for display when the HTML or Markdown report is used. Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md index 1f3916153e..46bea4c349 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardIndent.md @@ -2,9 +2,9 @@ ## Standard Element, indentation should be ignored -This line has no indentation. - This line has 4 spaces indentation. - This line has 8 spaces indentation. - This line has 4 spaces indentation. +This line has no indentation. +This line has 4 spaces indentation. +This line has 8 spaces indentation. +This line has 4 spaces indentation. Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md index 1a2cd9f19c..c94bed46b5 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStandardLineWrapping.md @@ -2,8 +2,8 @@ ## Standard Element, line wrapping handling -This line has to be exactly 99 chars to test part of the logic.------------------------------------ - And this line has to be exactly 100 chars.---------------------------------------------------------- - And here we have a line which should start wrapping as it is longer than 100 chars. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pellentesque iaculis enim quis hendrerit. Morbi ultrices in odio pharetra commodo. +This line has to be exactly 99 chars to test part of the logic.------------------------------------ +And this line has to be exactly 100 chars.---------------------------------------------------------- +And here we have a line which should start wrapping as it is longer than 100 chars. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pellentesque iaculis enim quis hendrerit. Morbi ultrices in odio pharetra commodo. Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) From 5a36502160c3c6fe115a1f2fa50cce7347cc6a96 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Nov 2024 20:26:51 +0100 Subject: [PATCH 831/874] Generators/Text: trim code titles As things were, whitespace at the start/end of a title could cause unnecessary line wrapping of the title. Fixed now. Includes updated test expectations. --- src/Generators/Text.php | 4 ++-- .../Expectations/ExpectedOutputCodeTitleWhitespace.txt | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Generators/Text.php b/src/Generators/Text.php index 419bcc3d56..e57556d08f 100644 --- a/src/Generators/Text.php +++ b/src/Generators/Text.php @@ -133,7 +133,7 @@ protected function printCodeComparisonBlock(DOMNode $node) { $codeBlocks = $node->getElementsByTagName('code'); $first = trim($codeBlocks->item(0)->nodeValue); - $firstTitle = $codeBlocks->item(0)->getAttribute('title'); + $firstTitle = trim($codeBlocks->item(0)->getAttribute('title')); $firstTitleLines = []; $tempTitle = ''; @@ -168,7 +168,7 @@ protected function printCodeComparisonBlock(DOMNode $node) $firstLines = explode("\n", $first); $second = trim($codeBlocks->item(1)->nodeValue); - $secondTitle = $codeBlocks->item(1)->getAttribute('title'); + $secondTitle = trim($codeBlocks->item(1)->getAttribute('title')); $secondTitleLines = []; $tempTitle = ''; diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt index 80a6cc690b..0db5a7dfae 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt @@ -6,15 +6,13 @@ This is a standard block. ----------------------------------------- CODE COMPARISON ------------------------------------------ -| Valid: spaces at start of description. | Invalid: spaces at end making line > 46 chars. | -| | | +| Valid: spaces at start of description. | Invalid: spaces at end making line > 46 chars. | ---------------------------------------------------------------------------------------------------- | // Dummy. | // Dummy. | ---------------------------------------------------------------------------------------------------- ----------------------------------------- CODE COMPARISON ------------------------------------------ -| Valid: spaces at start + end of description. | Invalid: spaces ' ' in description. | -| | | +| Valid: spaces at start + end of description. | Invalid: spaces ' ' in description. | ---------------------------------------------------------------------------------------------------- | // Note: description above without the | // Dummy. | | // trailing whitespace fits in 46 chars. | | From f2fedfbb0f6c6556583f36767d480b06efed762d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Nov 2024 23:23:07 +0100 Subject: [PATCH 832/874] Generators HTML/Markdown: fix whitespace handling in code title If there were multiple spaces next to each other in the title, this would be folded into one space for the display in HTML and Markdown. This could mangle the code title, so fixed now. Includes updated test expectations. --- src/Generators/HTML.php | 6 ++++-- src/Generators/Markdown.php | 6 ++++-- .../Expectations/ExpectedOutputCodeTitleWhitespace.html | 8 ++++---- .../Expectations/ExpectedOutputCodeTitleWhitespace.md | 8 ++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php index 8e2001e2e5..ba05d072df 100644 --- a/src/Generators/HTML.php +++ b/src/Generators/HTML.php @@ -281,7 +281,8 @@ protected function printCodeComparisonBlock(DOMNode $node) { $codeBlocks = $node->getElementsByTagName('code'); - $firstTitle = $codeBlocks->item(0)->getAttribute('title'); + $firstTitle = trim($codeBlocks->item(0)->getAttribute('title')); + $firstTitle = str_replace(' ', '  ', $firstTitle); $first = trim($codeBlocks->item(0)->nodeValue); $first = str_replace('', $first); @@ -289,7 +290,8 @@ protected function printCodeComparisonBlock(DOMNode $node) $first = str_replace('', '', $first); $first = str_replace('', '', $first); - $secondTitle = $codeBlocks->item(1)->getAttribute('title'); + $secondTitle = trim($codeBlocks->item(1)->getAttribute('title')); + $secondTitle = str_replace(' ', '  ', $secondTitle); $second = trim($codeBlocks->item(1)->nodeValue); $second = str_replace('', $second); diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index 76dbb0605f..77807b55e0 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -140,13 +140,15 @@ protected function printCodeComparisonBlock(DOMNode $node) { $codeBlocks = $node->getElementsByTagName('code'); - $firstTitle = $codeBlocks->item(0)->getAttribute('title'); + $firstTitle = trim($codeBlocks->item(0)->getAttribute('title')); + $firstTitle = str_replace(' ', '  ', $firstTitle); $first = trim($codeBlocks->item(0)->nodeValue); $first = str_replace("\n", PHP_EOL.' ', $first); $first = str_replace('', '', $first); $first = str_replace('', '', $first); - $secondTitle = $codeBlocks->item(1)->getAttribute('title'); + $secondTitle = trim($codeBlocks->item(1)->getAttribute('title')); + $secondTitle = str_replace(' ', '  ', $secondTitle); $second = trim($codeBlocks->item(1)->nodeValue); $second = str_replace("\n", PHP_EOL.' ', $second); $second = str_replace('', '', $second); diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html index a64cdb4deb..fe1c15bb47 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html @@ -75,8 +75,8 @@

    Code Title, whitespace handling

    This is a standard block.

    Valid: contains line which is too long.
    - - + + @@ -85,8 +85,8 @@

    Code Title, whitespace handling

    Valid: spaces at start of description.Invalid: spaces at end making line > 46 chars. Valid: spaces at start of description.Invalid: spaces at end making line > 46 chars.
    // Dummy.
    - - + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md index 2d04562c7e..e623ba98dd 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md @@ -5,8 +5,8 @@ This is a standard block.
    Valid: spaces at start + end of description. Invalid: spaces ' ' in description.Valid: spaces at start + end of description.Invalid: spaces '     ' in description.
    // Note: description above without the
    // trailing whitespace fits in 46 chars.
    - - + +
    Valid: spaces at start of description.Invalid: spaces at end making line > 46 chars. Valid: spaces at start of description.Invalid: spaces at end making line > 46 chars.
    @@ -23,8 +23,8 @@ This is a standard block.
    - - + +
    Valid: spaces at start + end of description. Invalid: spaces ' ' in description.Valid: spaces at start + end of description.Invalid: spaces '     ' in description.
    From 66d3ac5d9404e4731b807ec882116b377635a660 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 27 Nov 2024 13:06:28 +0100 Subject: [PATCH 833/874] Squiz ruleset: update property format The Squiz ruleset was still using the deprecated property setting array format for the `Generic.Debug.ClosureLinter` sniff. Fixed now. --- src/Standards/Squiz/ruleset.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Standards/Squiz/ruleset.xml b/src/Standards/Squiz/ruleset.xml index 87ab4c3e8a..82f5270ada 100644 --- a/src/Standards/Squiz/ruleset.xml +++ b/src/Standards/Squiz/ruleset.xml @@ -74,8 +74,14 @@ - - + + + + + + + + From e66802a1e0c6991c2aa7f5ee620bd1fa6320e5b7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 17 Nov 2024 02:22:11 +0100 Subject: [PATCH 834/874] Ruleset::processRuleset(): add tests for handling of broken rulesets --- ...ocessRulesetBrokenRulesetEmptyFileTest.xml | 0 ...cessRulesetBrokenRulesetMultiErrorTest.xml | 10 ++ ...essRulesetBrokenRulesetSingleErrorTest.xml | 2 + .../ProcessRulesetBrokenRulesetTest.php | 92 +++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 tests/Core/Ruleset/ProcessRulesetBrokenRulesetEmptyFileTest.xml create mode 100644 tests/Core/Ruleset/ProcessRulesetBrokenRulesetMultiErrorTest.xml create mode 100644 tests/Core/Ruleset/ProcessRulesetBrokenRulesetSingleErrorTest.xml create mode 100644 tests/Core/Ruleset/ProcessRulesetBrokenRulesetTest.php diff --git a/tests/Core/Ruleset/ProcessRulesetBrokenRulesetEmptyFileTest.xml b/tests/Core/Ruleset/ProcessRulesetBrokenRulesetEmptyFileTest.xml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/Core/Ruleset/ProcessRulesetBrokenRulesetMultiErrorTest.xml b/tests/Core/Ruleset/ProcessRulesetBrokenRulesetMultiErrorTest.xml new file mode 100644 index 0000000000..64294b9b78 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetBrokenRulesetMultiErrorTest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/Core/Ruleset/ProcessRulesetBrokenRulesetSingleErrorTest.xml b/tests/Core/Ruleset/ProcessRulesetBrokenRulesetSingleErrorTest.xml new file mode 100644 index 0000000000..e9c5bd7e47 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetBrokenRulesetSingleErrorTest.xml @@ -0,0 +1,2 @@ + + diff --git a/tests/Core/Ruleset/ProcessRulesetBrokenRulesetTest.php b/tests/Core/Ruleset/ProcessRulesetBrokenRulesetTest.php new file mode 100644 index 0000000000..95f67c21df --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetBrokenRulesetTest.php @@ -0,0 +1,92 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; + +/** + * Test handling of broken ruleset files. + * + * Note: these tests need to run in separate processes as otherwise they run into + * some weirdness with the libxml_get_errors()/libxml_clear_errors() functions + * (duplicate error messages). + * + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled + * + * @covers \PHP_CodeSniffer\Ruleset::processRuleset + */ +final class ProcessRulesetBrokenRulesetTest extends AbstractRulesetTestCase +{ + + + /** + * Test displaying an informative error message when an empty XML ruleset file is encountered. + * + * @return void + */ + public function testBrokenRulesetEmptyFile() + { + $standard = __DIR__.'/ProcessRulesetBrokenRulesetEmptyFileTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + + $regex = '`^Ruleset \S+ProcessRulesetBrokenRulesetEmptyFileTest\.xml is not valid\R$`'; + $this->expectRuntimeExceptionRegex($regex); + + new Ruleset($config); + + }//end testBrokenRulesetEmptyFile() + + + /** + * Test displaying an informative error message for a broken XML ruleset with a single XML error. + * + * @return void + */ + public function testBrokenRulesetSingleError() + { + $standard = __DIR__.'/ProcessRulesetBrokenRulesetSingleErrorTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + + $regex = '`^Ruleset \S+ProcessRulesetBrokenRulesetSingleErrorTest\.xml is not valid\R'; + $regex .= '- On line 3, column 1: Premature end of data in tag ruleset line 2\R$`'; + + $this->expectRuntimeExceptionRegex($regex); + + new Ruleset($config); + + }//end testBrokenRulesetSingleError() + + + /** + * Test displaying an informative error message for a broken XML ruleset with multiple XML errors. + * + * @return void + */ + public function testBrokenRulesetMultiError() + { + $standard = __DIR__.'/ProcessRulesetBrokenRulesetMultiErrorTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + + $regex = '`^Ruleset \S+ProcessRulesetBrokenRulesetMultiErrorTest\.xml is not valid\R'; + $regex .= '- On line 8, column 12: Opening and ending tag mismatch: property line 7 and rule\R'; + $regex .= '- On line 10, column 11: Opening and ending tag mismatch: properties line 5 and ruleset\R'; + $regex .= '- On line 11, column 1: Premature end of data in tag rule line 4\R$`'; + + $this->expectRuntimeExceptionRegex($regex); + + new Ruleset($config); + + }//end testBrokenRulesetMultiError() + + +}//end class From 0a364dcaa9dc1333fc8901d237f82acdf59bffcf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 18 Nov 2024 06:27:19 +0100 Subject: [PATCH 835/874] Ruleset::processRule(): add test for handling of invalid `` directives --- .../Ruleset/ProcessRuleInvalidTypeTest.php | 43 +++++++++++++++++++ .../Ruleset/ProcessRuleInvalidTypeTest.xml | 9 ++++ 2 files changed, 52 insertions(+) create mode 100644 tests/Core/Ruleset/ProcessRuleInvalidTypeTest.php create mode 100644 tests/Core/Ruleset/ProcessRuleInvalidTypeTest.xml diff --git a/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.php b/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.php new file mode 100644 index 0000000000..08a2e6b822 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.php @@ -0,0 +1,43 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; + +/** + * Test handling of invalid type elements. + * + * @covers \PHP_CodeSniffer\Ruleset::processRule + */ +final class ProcessRuleInvalidTypeTest extends AbstractRulesetTestCase +{ + + + /** + * Test displaying an informative error message when an invalid type is given. + * + * @return void + */ + public function testInvalidTypeHandling() + { + $standard = __DIR__.'/ProcessRuleInvalidTypeTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + + $message = 'Message type "notice" is invalid; must be "error" or "warning"'; + $this->expectRuntimeExceptionMessage($message); + + new Ruleset($config); + + }//end testInvalidTypeHandling() + + +}//end class diff --git a/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.xml b/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.xml new file mode 100644 index 0000000000..63c2aaf3c8 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRuleInvalidTypeTest.xml @@ -0,0 +1,9 @@ + + + + + + notice + + + From 0c2d6d4d37cf3f7df269c7d61ded72639ae23728 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 14 Nov 2024 08:52:18 -0300 Subject: [PATCH 836/874] Generic/CyclomaticComplexity: rename test case file Doing this to be able to create tests with syntax errors on separate files. --- ...inc => CyclomaticComplexityUnitTest.1.inc} | 0 .../Metrics/CyclomaticComplexityUnitTest.php | 42 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) rename src/Standards/Generic/Tests/Metrics/{CyclomaticComplexityUnitTest.inc => CyclomaticComplexityUnitTest.1.inc} (100%) diff --git a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc rename to src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php index 950ba3eec3..f7c75f79ca 100644 --- a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.php @@ -26,11 +26,18 @@ final class CyclomaticComplexityUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [118 => 1]; + switch ($testFile) { + case 'CyclomaticComplexityUnitTest.1.inc': + return [118 => 1]; + default: + return []; + } }//end getErrorList() @@ -41,21 +48,28 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return [ - 45 => 1, - 72 => 1, - 189 => 1, - 237 => 1, - 285 => 1, - 333 => 1, - 381 => 1, - 417 => 1, - 445 => 1, - ]; + switch ($testFile) { + case 'CyclomaticComplexityUnitTest.1.inc': + return [ + 45 => 1, + 72 => 1, + 189 => 1, + 237 => 1, + 285 => 1, + 333 => 1, + 381 => 1, + 417 => 1, + 445 => 1, + ]; + default: + return []; + } }//end getWarningList() From 2371b0ae53e19e598a55ddaf7da62aa8d15d500f Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 14 Nov 2024 09:02:51 -0300 Subject: [PATCH 837/874] Generic/CyclomaticComplexity: improve code coverage --- .../Metrics/CyclomaticComplexitySniff.php | 2 +- .../CyclomaticComplexityUnitTest.1.inc | 32 +++++++++++-------- .../CyclomaticComplexityUnitTest.2.inc | 7 ++++ .../CyclomaticComplexityUnitTest.3.inc | 7 ++++ 4 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.2.inc create mode 100644 src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.3.inc diff --git a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php index 8cba81daf2..c37140a990 100644 --- a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php @@ -60,7 +60,7 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - // Ignore abstract methods. + // Ignore abstract and interface methods. Bail early when live coding. if (isset($tokens[$stackPtr]['scope_opener']) === false) { return; } diff --git a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.1.inc b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.1.inc index 494dcc7694..9ee638b0cb 100644 --- a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.1.inc +++ b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.1.inc @@ -46,7 +46,7 @@ function complexityEleven() { while ($condition === true) { if ($condition) { - } else if ($cond) { + } elseif ($cond) { } } @@ -61,11 +61,11 @@ function complexityEleven() echo 'hi'; } break; - case '3': - break; default: break; } + + foreach ($array as $element) {} } @@ -136,14 +136,6 @@ function complexityTwentyOne() echo 'hi'; } break; - case '3': - switch ($cond) { - case '1': - break; - case '2': - break; - } - break; case '4': do { if ($condition) { @@ -159,8 +151,16 @@ function complexityTwentyOne() } break; } -} + try { + for ($i = 0; $i < 10; $i++) { + if ($i % 2) { + doSomething(); + } + } + } catch (Exception $e) { + } +} function complexityTenWithTernaries() { @@ -451,4 +451,10 @@ function complexityElevenWithNullSafeOperator() $bits = $object5->getX()?->getY()?->getZ(); } -?> +abstract class AbstractClass { + abstract public function sniffShouldIgnoreAbstractMethods(); +} + +interface MyInterface { + public function sniffShouldIgnoreInterfaceMethods(); +} diff --git a/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.2.inc b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.2.inc new file mode 100644 index 0000000000..9658af3005 --- /dev/null +++ b/src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.2.inc @@ -0,0 +1,7 @@ + Date: Mon, 2 Dec 2024 10:02:06 -0300 Subject: [PATCH 838/874] Generic/CyclomaticComplexity: ensure the sniff bails if `scope_closer` is not set Quoting @jrfnl: "Only checking for the scope_opener, when accessing/using both the scope_opener and scope_closer indexes, is probably fine in practical terms. However, the part of the code base which sets these indexes is not sufficiently covered by tests, nor does it document that those indexes will only be set if both can be set, so there may be edge case exceptions" (https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/684#discussion_r1865313147). The sniff was already working fine before this change. Checking if `scope_closer` is just an extra precaution to err on the side of caution. --- .../Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php index c37140a990..a6b17d1315 100644 --- a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php @@ -61,7 +61,7 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); // Ignore abstract and interface methods. Bail early when live coding. - if (isset($tokens[$stackPtr]['scope_opener']) === false) { + if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) { return; } From cb96819a180340e00ff1e73b66f7eb159a8017d8 Mon Sep 17 00:00:00 2001 From: Juliette <663378+jrfnl@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:52:55 +0100 Subject: [PATCH 839/874] Ruleset: add tests for handling of `php[cs|cbf]-only` attributes within a `` (#711) Add tests specifically aimed at verifying `phpcs-only` and `phpcbf-only` attributes for elements within a `` are read and handled correctly. --- ...ProcessRulesetShouldProcessElementTest.php | 388 ++++++++++++++++++ ...ProcessRulesetShouldProcessElementTest.xml | 54 +++ 2 files changed, 442 insertions(+) create mode 100644 tests/Core/Ruleset/ProcessRulesetShouldProcessElementTest.php create mode 100644 tests/Core/Ruleset/ProcessRulesetShouldProcessElementTest.xml diff --git a/tests/Core/Ruleset/ProcessRulesetShouldProcessElementTest.php b/tests/Core/Ruleset/ProcessRulesetShouldProcessElementTest.php new file mode 100644 index 0000000000..cd04ae78dc --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetShouldProcessElementTest.php @@ -0,0 +1,388 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHPUnit\Framework\TestCase; + +/** + * Test handling of `phpc(cs|cbf)-only` instructions at ruleset level. + * + * @covers \PHP_CodeSniffer\Ruleset::processRuleset + * @covers \PHP_CodeSniffer\Ruleset::shouldProcessElement + */ +final class ProcessRulesetShouldProcessElementTest extends TestCase +{ + + /** + * Cache to store the original ini values for ini settings being changed in these tests. + * + * @var array + */ + private static $originalIniValues = [ + 'bcmath.scale' => null, + 'docref_root' => null, + 'user_agent' => null, + ]; + + /** + * The Config object. + * + * @var \PHP_CodeSniffer\Tests\ConfigDouble + */ + private static $config; + + /** + * The Ruleset object. + * + * @var \PHP_CodeSniffer\Ruleset + */ + private static $ruleset; + + + /** + * Store the original ini values to allow for restoring them after the tests. + * + * @beforeClass + * + * @return void + */ + public static function saveOriginalIniValues() + { + foreach (self::$originalIniValues as $name => $null) { + $value = ini_get($name); + if ($value !== false) { + self::$originalIniValues[$name] = $value; + } + } + + }//end saveOriginalIniValues() + + + /** + * Initialize the config and ruleset objects for this test only once (but do allow recording code coverage). + * + * @before + * + * @return void + */ + protected function initializeConfigAndRuleset() + { + if (isset(self::$ruleset) === false) { + // Set up the ruleset. + $standard = __DIR__.'/ProcessRulesetShouldProcessElementTest.xml'; + self::$config = new ConfigDouble(["--standard=$standard"]); + self::$ruleset = new Ruleset(self::$config); + } + + }//end initializeConfigAndRuleset() + + + /** + * Destroy the Config object and restor the ini values after the tests. + * + * @afterClass + * + * @return void + */ + public static function restoreOriginalValues() + { + // Explicitly trigger __destruct() on the ConfigDouble to reset the Config statics. + // The explicit method call prevents potential stray test-local references to the $config object + // preventing the destructor from running the clean up (which without stray references would be + // automagically triggered when this object is destroyed, but we can't definitively rely on that). + if (isset(self::$config) === true) { + self::$config->__destruct(); + } + + foreach (self::$originalIniValues as $name => $value) { + if ($value === null) { + continue; + } + + ini_set($name, $value); + } + + }//end restoreOriginalValues() + + + /** + * Verify that in CS mode, phpcs-only directives are respected and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessConfigCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $this->assertSame('true', Config::getConfigData('neither'), 'Non-selective config directive was not applied.'); + $this->assertSame('true', Config::getConfigData('csOnly'), 'CS-only config directive was not applied.'); + $this->assertSame(null, Config::getConfigData('cbfOnly'), 'CBF-only config directive was applied, while it shouldn\'t have been.'); + + }//end testShouldProcessConfigCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are respected and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessConfigCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $this->assertSame('true', Config::getConfigData('neither'), 'Non-selective config directive was not applied.'); + $this->assertSame(null, Config::getConfigData('csOnly'), 'CS-only config directive was applied, while it shouldn\'t have been.'); + $this->assertSame('true', Config::getConfigData('cbfOnly'), 'CBF-only config directive was not applied.'); + + }//end testShouldProcessConfigCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are respected and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessArgCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $expectedExtensions = [ + 'php' => 'PHP', + 'phpt' => 'PHP', + ]; + $expectedReports = ['full' => null]; + + $this->assertSame($expectedExtensions, self::$config->extensions, 'Non-selective arg directive was not applied.'); + $this->assertTrue(self::$config->showProgress, 'Non-selective short arg directive was not applied [1].'); + $this->assertTrue(self::$config->showSources, 'Non-selective short arg directive was not applied [2].'); + $this->assertTrue(self::$config->colors, 'CS-only arg directive was not applied.'); + $this->assertSame($expectedReports, self::$config->reports, 'CBF-only arg directive was applied, while it shouldn\'t have been.'); + + }//end testShouldProcessArgCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are respected and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessArgCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $expectedExtensions = [ + 'php' => 'PHP', + 'phpt' => 'PHP', + ]; + $expectedReports = ['summary' => null]; + + $this->assertSame($expectedExtensions, self::$config->extensions, 'Non-selective arg directive was not applied.'); + $this->assertTrue(self::$config->showProgress, 'Non-selective short arg directive was not applied [1].'); + $this->assertTrue(self::$config->showSources, 'Non-selective short arg directive was not applied [2].'); + $this->assertFalse(self::$config->colors, 'CS-only arg directive was applied, while it shouldn\'t have been.'); + $this->assertSame($expectedReports, self::$config->reports, 'CBF-only arg directive was not applied.'); + + }//end testShouldProcessArgCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are respected and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessIniCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $this->assertSame('2', ini_get('bcmath.scale'), 'Non-selective ini directive was not applied.'); + $this->assertSame('path/to/docs/', ini_get('docref_root'), 'CS-only ini directive was not applied.'); + $this->assertSame('', ini_get('user_agent'), 'CBF-only ini directive was applied, while it shouldn\'t have been.'); + + }//end testShouldProcessIniCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are respected and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessIniCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $this->assertSame('2', ini_get('bcmath.scale'), 'Non-selective ini directive was not applied.'); + $this->assertSame('', ini_get('docref_root'), 'CS-only ini directive was applied, while it shouldn\'t have been..'); + $this->assertSame('Never mind', ini_get('user_agent'), 'CBF-only ini directive was not applied.'); + + }//end testShouldProcessIniCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are respected and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessExcludePatternCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $expected = [ + './tests/' => 'absolute', + './vendor/' => 'absolute', + ]; + + $this->assertSame($expected, self::$ruleset->ignorePatterns); + + }//end testShouldProcessExcludePatternCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are respected and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessExcludePatternCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $expected = [ + './tests/' => 'absolute', + './node-modules/' => 'absolute', + ]; + + $this->assertSame($expected, self::$ruleset->ignorePatterns); + + }//end testShouldProcessExcludePatternCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are respected and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessRuleCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $this->assertArrayHasKey('PEAR.Formatting.MultiLineAssignment', self::$ruleset->sniffCodes); + $this->assertArrayHasKey('Generic.Arrays.ArrayIndent', self::$ruleset->sniffCodes); + $this->assertArrayNotHasKey('PSR2.Classes.ClassDeclaration', self::$ruleset->sniffCodes); + + }//end testShouldProcessRuleCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are respected and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessRuleCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $this->assertArrayHasKey('PEAR.Formatting.MultiLineAssignment', self::$ruleset->sniffCodes); + $this->assertArrayNotHasKey('Generic.Arrays.ArrayIndent', self::$ruleset->sniffCodes); + $this->assertArrayHasKey('PSR2.Classes.ClassDeclaration', self::$ruleset->sniffCodes); + + }//end testShouldProcessRuleCbfonly() + + + /** + * Verify that in CS mode, phpcs-only in directives are respected and phpcbf-only in + * directives are ignored. + * + * @return void + */ + public function testShouldProcessRuleExcludeCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $expected = [ + 'PEAR.Formatting.MultiLineAssignment.Indent' => [ + 'severity' => 0, + ], + ]; + + $this->assertSame($expected, self::$ruleset->ruleset); + + }//end testShouldProcessRuleExcludeCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only in directives are respected and phpcs-only in + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessRuleExcludeCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $expected = [ + 'PEAR.Formatting.MultiLineAssignment.EqualSignLine' => [ + 'severity' => 0, + ], + ]; + + $this->assertSame($expected, self::$ruleset->ruleset); + + }//end testShouldProcessRuleExcludeCbfonly() + + +}//end class diff --git a/tests/Core/Ruleset/ProcessRulesetShouldProcessElementTest.xml b/tests/Core/Ruleset/ProcessRulesetShouldProcessElementTest.xml new file mode 100644 index 0000000000..62ea0e62f5 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetShouldProcessElementTest.xml @@ -0,0 +1,54 @@ + + + + . + + + + + + + + ./tests/ + + + + + + + + + ./vendor/ + + + + + + + + + + + + + ./node-modules/ + + + + + + + + From 585602f01659a1689c84efab6bbe91d33ad36c31 Mon Sep 17 00:00:00 2001 From: Juliette <663378+jrfnl@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:54:41 +0100 Subject: [PATCH 840/874] Ruleset: add tests for handling of `php[cs|cbf]-only` attributes within a `` (#712) Add tests specifically aimed at verifying `phpcs-only` and `phpcbf-only` attributes for elements within a `` are read and handled correctly. --- .../ProcessRuleShouldProcessElementTest.php | 660 ++++++++++++++++++ .../ProcessRuleShouldProcessElementTest.xml | 100 +++ 2 files changed, 760 insertions(+) create mode 100644 tests/Core/Ruleset/ProcessRuleShouldProcessElementTest.php create mode 100644 tests/Core/Ruleset/ProcessRuleShouldProcessElementTest.xml diff --git a/tests/Core/Ruleset/ProcessRuleShouldProcessElementTest.php b/tests/Core/Ruleset/ProcessRuleShouldProcessElementTest.php new file mode 100644 index 0000000000..7de34c1210 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRuleShouldProcessElementTest.php @@ -0,0 +1,660 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; + +/** + * Test handling of `phpc(cs|cbf)-only` instructions at rule level. + * + * @covers \PHP_CodeSniffer\Ruleset::processRule + * @covers \PHP_CodeSniffer\Ruleset::shouldProcessElement + */ +final class ProcessRuleShouldProcessElementTest extends AbstractRulesetTestCase +{ + + /** + * The Ruleset object. + * + * @var \PHP_CodeSniffer\Ruleset + */ + private static $ruleset; + + + /** + * Initialize the config and ruleset objects for this test. + * + * @before + * + * @return void + */ + protected function initializeConfigAndRuleset() + { + if (isset(self::$ruleset) === false) { + // Set up the ruleset. + $standard = __DIR__.'/ProcessRuleShouldProcessElementTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + self::$ruleset = new Ruleset($config); + } + + }//end initializeConfigAndRuleset() + + + /** + * Verify that in CS mode, phpcs-only directives are set and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessSeverityCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $key = 'severity'; + + // Verify that the non-selective severity directive IS applied. + $sniffCode = 'PSR1.Files.SideEffects'; + $this->assertRulesetPropertySame(3, $sniffCode, $key); + + // Verify that the CS-only severity directive IS applied. + $sniffCode = 'Generic.Metrics.CyclomaticComplexity'; + $this->assertRulesetPropertySame(2, $sniffCode, $key); + + // Verify that the CBF-only severity directive is NOT applied. + $sniffCode = 'PSR2.Namespaces.NamespaceDeclaration'; + $this->assertNotHasRulesetDirective($sniffCode, $key); + + }//end testShouldProcessSeverityCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are set and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessSeverityCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $key = 'severity'; + + // Verify that the non-selective severity directive IS applied. + $sniffCode = 'PSR1.Files.SideEffects'; + $this->assertRulesetPropertySame(3, $sniffCode, $key); + + // Verify that the CS-only severity directive is NOT applied. + $sniffCode = 'Generic.Metrics.CyclomaticComplexity'; + $this->assertNotHasRulesetDirective($sniffCode, $key); + + // Verify that the CBF-only severity directive IS applied. + $sniffCode = 'PSR2.Namespaces.NamespaceDeclaration'; + $this->assertRulesetPropertySame(4, $sniffCode, $key); + + }//end testShouldProcessSeverityCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are set and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessTypeCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $key = 'type'; + + // Verify that the non-selective type directive IS applied. + $sniffCode = 'PSR1.Files.SideEffects'; + $this->assertRulesetPropertySame('warning', $sniffCode, $key); + + // Verify that the CS-only type directive IS applied. + $sniffCode = 'Generic.Metrics.CyclomaticComplexity'; + $this->assertRulesetPropertySame('warning', $sniffCode, $key); + + // Verify that the CBF-only type directive is NOT applied. + $sniffCode = 'PSR2.Namespaces.NamespaceDeclaration'; + $this->assertNotHasRulesetDirective($sniffCode, $key); + + }//end testShouldProcessTypeCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are set and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessTypeCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $key = 'type'; + + // Verify that the non-selective type directive IS applied. + $sniffCode = 'PSR1.Files.SideEffects'; + $this->assertRulesetPropertySame('warning', $sniffCode, $key); + + // Verify that the CS-only type directive is NOT applied. + $sniffCode = 'Generic.Metrics.CyclomaticComplexity'; + $this->assertNotHasRulesetDirective($sniffCode, $key); + + // Verify that the CBF-only type directive IS applied. + $sniffCode = 'PSR2.Namespaces.NamespaceDeclaration'; + $this->assertRulesetPropertySame('error', $sniffCode, $key); + + }//end testShouldProcessTypeCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are set and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessMessageCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $key = 'message'; + + // Verify that the non-selective message directive IS applied. + $sniffCode = 'PSR1.Files.SideEffects'; + $this->assertRulesetPropertySame('A different warning message', $sniffCode, $key); + + // Verify that the CS-only message directive IS applied. + $sniffCode = 'Generic.Metrics.CyclomaticComplexity'; + $this->assertRulesetPropertySame('A different warning but only for phpcs', $sniffCode, $key); + + // Verify that the CBF-only message directive is NOT applied. + $sniffCode = 'PSR2.Namespaces.NamespaceDeclaration'; + $this->assertNotHasRulesetDirective($sniffCode, $key); + + }//end testShouldProcessMessageCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are set and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessMessageCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $key = 'message'; + + // Verify that the non-selective message directive IS applied. + $sniffCode = 'PSR1.Files.SideEffects'; + $this->assertRulesetPropertySame('A different warning message', $sniffCode, $key); + + // Verify that the CS-only message directive is NOT applied. + $sniffCode = 'Generic.Metrics.CyclomaticComplexity'; + $this->assertNotHasRulesetDirective($sniffCode, $key); + + // Verify that the CBF-only message directive IS applied. + $sniffCode = 'PSR2.Namespaces.NamespaceDeclaration'; + $this->assertRulesetPropertySame('A different warning but only for phpcbf', $sniffCode, $key); + + }//end testShouldProcessMessageCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are set and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessIncludePatternCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $includedKey = './vendor/'; + + // Verify that the non-selective include-pattern directive IS applied. + $sniffCode = 'PSR1.Methods.CamelCapsMethodName'; + $this->assertArrayHasKey($sniffCode, self::$ruleset->includePatterns, "Sniff $sniffCode not registered"); + $this->assertArrayHasKey($includedKey, self::$ruleset->includePatterns[$sniffCode], "Include pattern for sniff $sniffCode not registered"); + + // Verify that the CS-only include-pattern directive IS applied. + $sniffCode = 'Generic.Files.LineLength'; + $this->assertArrayHasKey($sniffCode, self::$ruleset->includePatterns, "Sniff $sniffCode not registered"); + $this->assertArrayHasKey($includedKey, self::$ruleset->includePatterns[$sniffCode], "Include pattern for sniff $sniffCode not registered"); + + // Verify that the CBF-only include-pattern directive is NOT applied. + $sniffCode = 'PSR2.Files.ClosingTag'; + $this->assertArrayNotHasKey($sniffCode, self::$ruleset->includePatterns, "Sniff $sniffCode was registered"); + + }//end testShouldProcessIncludePatternCsonly() + + + /** + * Verify that in CS mode, phpcbf-only directives are set and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessIncludePatternCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $includedKey = './vendor/'; + + // Verify that the non-selective include-pattern directive IS applied. + $sniffCode = 'PSR1.Methods.CamelCapsMethodName'; + $this->assertArrayHasKey($sniffCode, self::$ruleset->includePatterns, "Sniff $sniffCode not registered"); + $this->assertArrayHasKey($includedKey, self::$ruleset->includePatterns[$sniffCode], "Include pattern for sniff $sniffCode not registered"); + + // Verify that the CS-only include-pattern directive is NOT applied. + $sniffCode = 'Generic.Files.LineLength'; + $this->assertArrayNotHasKey($sniffCode, self::$ruleset->includePatterns, "Sniff $sniffCode was registered"); + + // Verify that the CBF-only include-pattern directive is IS applied. + $sniffCode = 'PSR2.Files.ClosingTag'; + $this->assertArrayHasKey($sniffCode, self::$ruleset->includePatterns, "Sniff $sniffCode not registered"); + $this->assertArrayHasKey($includedKey, self::$ruleset->includePatterns[$sniffCode], "Include pattern for sniff $sniffCode not registered"); + + }//end testShouldProcessIncludePatternCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are set and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessExcludePatternCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $excludedKey = './tests/'; + + // Verify that the non-selective exclude-pattern directive IS applied. + $sniffCode = 'PSR1.Classes.ClassDeclaration'; + $this->assertArrayHasKey($sniffCode, self::$ruleset->ignorePatterns, "Sniff $sniffCode not registered"); + $this->assertArrayHasKey($excludedKey, self::$ruleset->ignorePatterns[$sniffCode], "Ignore pattern for sniff $sniffCode not registered"); + + // Verify that the CS-only exclude-pattern directive IS applied. + $sniffCode = 'Generic.Formatting.SpaceAfterCast'; + $this->assertArrayHasKey($sniffCode, self::$ruleset->ignorePatterns, "Sniff $sniffCode not registered"); + $this->assertArrayHasKey($excludedKey, self::$ruleset->ignorePatterns[$sniffCode], "Ignore pattern for sniff $sniffCode not registered"); + + // Verify that the CBF-only exclude-pattern directive is NOT applied. + $sniffCode = 'PSR2.Methods.FunctionClosingBrace'; + $this->assertArrayNotHasKey($sniffCode, self::$ruleset->ignorePatterns, "Sniff $sniffCode was registered"); + + }//end testShouldProcessExcludePatternCsonly() + + + /** + * Verify that in CS mode, phpcbf-only directives are set and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessExcludePatternCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $excludedKey = './tests/'; + + // Verify that the non-selective exclude-pattern directive IS applied. + $sniffCode = 'PSR1.Classes.ClassDeclaration'; + $this->assertArrayHasKey($sniffCode, self::$ruleset->ignorePatterns, "Sniff $sniffCode not registered"); + $this->assertArrayHasKey($excludedKey, self::$ruleset->ignorePatterns[$sniffCode], "Ignore pattern for sniff $sniffCode not registered"); + + // Verify that the CS-only exclude-pattern directive is NOT applied. + $sniffCode = 'Generic.Formatting.SpaceAfterCast'; + $this->assertArrayNotHasKey($sniffCode, self::$ruleset->ignorePatterns, "Sniff $sniffCode was registered"); + + // Verify that the CBF-only exclude-pattern directive is IS applied. + $sniffCode = 'PSR2.Methods.FunctionClosingBrace'; + $this->assertArrayHasKey($sniffCode, self::$ruleset->ignorePatterns, "Sniff $sniffCode not registered"); + $this->assertArrayHasKey($excludedKey, self::$ruleset->ignorePatterns[$sniffCode], "Ignore pattern for sniff $sniffCode not registered"); + + }//end testShouldProcessExcludePatternCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are set and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessPropertiesCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $csSniffClass = 'PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff'; + $cbfSniffClass = 'PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\ClassDeclarationSniff'; + + $propertyName = 'indent'; + $propertyDefault = 4; + $propertyChanged = '2'; + + // Verify that the CS-only property directive IS applied. + $this->assertArrayHasKey($csSniffClass, self::$ruleset->sniffs, "Sniff $csSniffClass not registered"); + $this->assertXObjectHasProperty($propertyName, self::$ruleset->sniffs[$csSniffClass]); + + $actualValue = self::$ruleset->sniffs[$csSniffClass]->$propertyName; + $this->assertSame($propertyChanged, $actualValue, 'cs-only property change directive not applied'); + + // Verify that the CBF-only property directive is NOT applied. + $this->assertArrayHasKey($cbfSniffClass, self::$ruleset->sniffs, "Sniff $cbfSniffClass not registered"); + $this->assertXObjectHasProperty($propertyName, self::$ruleset->sniffs[$cbfSniffClass]); + + $actualValue = self::$ruleset->sniffs[$cbfSniffClass]->$propertyName; + $this->assertSame($propertyDefault, $actualValue, 'cbf-only property change directive was applied'); + + }//end testShouldProcessPropertiesCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are set and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessPropertiesCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $csSniffClass = 'PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff'; + $cbfSniffClass = 'PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\ClassDeclarationSniff'; + + $propertyName = 'indent'; + $propertyDefault = 4; + $propertyChanged = '2'; + + // Verify that the CS-only property directive is NOT applied. + $this->assertArrayHasKey($csSniffClass, self::$ruleset->sniffs, "Sniff $csSniffClass not registered"); + $this->assertXObjectHasProperty($propertyName, self::$ruleset->sniffs[$csSniffClass]); + + $actualValue = self::$ruleset->sniffs[$csSniffClass]->$propertyName; + $this->assertSame($propertyDefault, $actualValue, 'cs-only property change directive was applied'); + + // Verify that the CBF-only property directive IS applied. + $this->assertArrayHasKey($cbfSniffClass, self::$ruleset->sniffs, "Sniff $cbfSniffClass not registered"); + $this->assertXObjectHasProperty($propertyName, self::$ruleset->sniffs[$cbfSniffClass]); + + $actualValue = self::$ruleset->sniffs[$cbfSniffClass]->$propertyName; + $this->assertSame($propertyChanged, $actualValue, 'cbf-only property change directive not applied'); + + }//end testShouldProcessPropertiesCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are set and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessPropertyCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + // Verify the sniff is registed. + $sniffClass = 'PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff'; + $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs, "Sniff $sniffClass not registered"); + + $sniffObject = self::$ruleset->sniffs[$sniffClass]; + + // Verify that the non-selective property directive IS applied. + $propertyName = 'exact'; + $expected = true; + + $this->assertXObjectHasProperty($propertyName, $sniffObject); + $this->assertSame($expected, $sniffObject->$propertyName, 'Non-selective property change directive not applied'); + + // Verify that the CS-only property directive IS applied. + $propertyName = 'indent'; + $expected = '2'; + + $this->assertXObjectHasProperty($propertyName, $sniffObject); + $this->assertSame($expected, $sniffObject->$propertyName, 'cs-only property change directive not applied'); + + // Verify that the CBF-only property directive is NOT applied. + $propertyName = 'tabIndent'; + $expectedDefault = false; + + $this->assertXObjectHasProperty($propertyName, $sniffObject); + $this->assertSame($expectedDefault, $sniffObject->$propertyName, 'cbf-only property change directive was applied'); + + }//end testShouldProcessPropertyCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are set and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessPropertyCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + // Verify the sniff is registed. + $sniffClass = 'PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff'; + $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs, "Sniff $sniffClass not registered"); + + $sniffObject = self::$ruleset->sniffs[$sniffClass]; + + // Verify that the non-selective property directive IS applied. + $propertyName = 'exact'; + $expected = true; + + $this->assertXObjectHasProperty($propertyName, $sniffObject); + $this->assertSame($expected, $sniffObject->$propertyName, 'Non-selective property change directive not applied'); + + // Verify that the CS-only property directive is NOT applied. + $propertyName = 'indent'; + $expectedDefault = 4; + + $this->assertXObjectHasProperty($propertyName, $sniffObject); + $this->assertSame($expectedDefault, $sniffObject->$propertyName, 'cs-only property change directive was applied'); + + // Verify that the CBF-only property directive IS applied. + $propertyName = 'tabIndent'; + $expected = true; + + $this->assertXObjectHasProperty($propertyName, $sniffObject); + $this->assertSame($expected, $sniffObject->$propertyName, 'cbf-only property change directive not applied'); + + }//end testShouldProcessPropertyCbfonly() + + + /** + * Verify that in CS mode, phpcs-only directives are set and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessElementCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $expected = [ + // Non-selective element directive. + 'T_COMMENT', + // Phpcs-only element directive. + 'T_CLASS', + // Non-selective element directive via `extend`. + 'T_BACKTICK', + // Phpcs-only element directive via `extend`. + 'T_INTERFACE', + ]; + + $this->verifyShouldProcessElement($expected); + + }//end testShouldProcessElementCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are set and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessElementCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $expected = [ + // Non-selective element directive. + 'T_COMMENT', + // Phpcbf-only element directive. + 'T_ENUM', + // Non-selective element directive via `extend`. + 'T_BACKTICK', + // Phpcbf-only element directive via `extend`. + 'T_TRAIT', + ]; + + $this->verifyShouldProcessElement($expected); + + }//end testShouldProcessElementCbfonly() + + + /** + * Verify that directives are set correctly. + * + * @param array $expected Expected sniff property value. + * + * @return void + */ + private function verifyShouldProcessElement($expected) + { + // Verify the sniff is registed. + $sniffClass = 'PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff'; + $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs, "Sniff $sniffClass not registered"); + + // Verify the target property exists. + $sniffObject = self::$ruleset->sniffs[$sniffClass]; + $propertyName = 'ignoreIndentationTokens'; + + $this->assertXObjectHasProperty($propertyName, $sniffObject); + + // Verify the value. + $actualValue = $sniffObject->$propertyName; + $this->assertSame($expected, $actualValue, 'Selective element directives not applied correctly'); + + }//end verifyShouldProcessElement() + + + /** + * Custom assertion to verify that a Ruleset `$ruleset` property has a certain directive set for a certain sniff code. + * + * @param string $sniffCode Sniff code. + * @param string $key Array key. + * + * @return void + */ + private function assertHasRulesetDirective($sniffCode, $key) + { + $this->assertArrayHasKey($sniffCode, self::$ruleset->ruleset, "Sniff $sniffCode not registered"); + $this->assertTrue(is_array(self::$ruleset->ruleset[$sniffCode]), "Sniff $sniffCode is not an array"); + $this->assertArrayHasKey($key, self::$ruleset->ruleset[$sniffCode], "Directive $key not registered for sniff $sniffCode"); + + }//end assertHasRulesetDirective() + + + /** + * Custom assertion to verify that a Ruleset `$ruleset` property does NOT have a certain directive set for a certain sniff code. + * + * @param string $sniffCode Sniff code. + * @param string $key Array key. + * + * @return void + */ + private function assertNotHasRulesetDirective($sniffCode, $key) + { + if (isset(self::$ruleset->ruleset[$sniffCode]) === true + && is_array(self::$ruleset->ruleset[$sniffCode]) === true + && isset(self::$ruleset->ruleset[$sniffCode][$key]) === true + ) { + $this->fail("Directive $key is registered for sniff $sniffCode"); + } + + }//end assertNotHasRulesetDirective() + + + /** + * Custom assertion to verify that the value of a certain directive for a certain sniff code on the ruleset is correct. + * + * @param mixed $expected Expected value. + * @param string $sniffCode Sniff code. + * @param string $key Array key. + * + * @return void + */ + private function assertRulesetPropertySame($expected, $sniffCode, $key) + { + $this->assertHasRulesetDirective($sniffCode, $key); + + $actual = self::$ruleset->ruleset[$sniffCode][$key]; + $this->assertSame($expected, $actual, "Value for $key on sniff $sniffCode does not meet expectations"); + + }//end assertRulesetPropertySame() + + +}//end class diff --git a/tests/Core/Ruleset/ProcessRuleShouldProcessElementTest.xml b/tests/Core/Ruleset/ProcessRuleShouldProcessElementTest.xml new file mode 100644 index 0000000000..73a8116110 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRuleShouldProcessElementTest.xml @@ -0,0 +1,100 @@ + + + + + + 3 + warning + A different warning message + + + + ./vendor/ + + + + ./tests/ + + + + + + + 2 + warning + A different warning but only for phpcs + + + + ./vendor/ + + + + ./tests/ + + + + + + + + + + + 4 + error + A different warning but only for phpcbf + + + + ./vendor/ + + + + ./tests/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c942e6ac8187c05c32cc2eae4aeb5dd4277cf8c5 Mon Sep 17 00:00:00 2001 From: Juliette <663378+jrfnl@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:55:55 +0100 Subject: [PATCH 841/874] Ruleset::processRuleset(): add tests for handling `` directives (#715) Add tests specifically aimed at verifying `` elements are read and handled correctly. Note: as `autoload` directive are not stored in the ruleset, but directly lead to a file include using `include_once`, these tests need to run in a separate process to circumvent the possibility of test cross-contamination. --- .../ProcessRulesetAutoloadLoadAlways.1.php | 8 + .../ProcessRulesetAutoloadLoadAlways.2.php | 8 + .../ProcessRulesetAutoloadLoadAlways.3.php | 8 + .../ProcessRulesetAutoloadLoadAlways.4.php | 8 + .../ProcessRulesetAutoloadLoadPhpcbfOnly.php | 8 + .../ProcessRulesetAutoloadLoadPhpcsOnly.php | 8 + ...ProcessRulesetAutoloadFileNotFoundTest.xml | 8 + .../Ruleset/ProcessRulesetAutoloadTest.php | 164 ++++++++++++++++++ .../Ruleset/ProcessRulesetAutoloadTest.xml | 37 ++++ 9 files changed, 257 insertions(+) create mode 100644 tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadAlways.1.php create mode 100644 tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadAlways.2.php create mode 100644 tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadAlways.3.php create mode 100644 tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadAlways.4.php create mode 100644 tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadPhpcbfOnly.php create mode 100644 tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadPhpcsOnly.php create mode 100644 tests/Core/Ruleset/ProcessRulesetAutoloadFileNotFoundTest.xml create mode 100644 tests/Core/Ruleset/ProcessRulesetAutoloadTest.php create mode 100644 tests/Core/Ruleset/ProcessRulesetAutoloadTest.xml diff --git a/tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadAlways.1.php b/tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadAlways.1.php new file mode 100644 index 0000000000..2b1fadaf5e --- /dev/null +++ b/tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadAlways.1.php @@ -0,0 +1,8 @@ + + + + ./tests/Core/Ruleset/Fixtures/ThisFileDoesNotExist.php + + + + diff --git a/tests/Core/Ruleset/ProcessRulesetAutoloadTest.php b/tests/Core/Ruleset/ProcessRulesetAutoloadTest.php new file mode 100644 index 0000000000..a6a0dd4afe --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetAutoloadTest.php @@ -0,0 +1,164 @@ + instructions. + * + * @author Juliette Reinders Folmer + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; + +/** + * Test handling of instructions. + * + * Note: these tests need to run in separate processes as otherwise we cannot + * reliably determine whether or not the correct files were loaded as the + * underlying code uses `include_once`. + * + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled + * + * @covers \PHP_CodeSniffer\Ruleset::processRuleset + */ +final class ProcessRulesetAutoloadTest extends AbstractRulesetTestCase +{ + + + /** + * Verify that in CS mode, phpcs-only directives are respected and phpcbf-only + * directives are ignored. + * + * @return void + */ + public function testShouldProcessAutoloadCsonly() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('This test needs CS mode to run'); + } + + $originallyIncludes = get_included_files(); + + // Set up the ruleset. + $standard = __DIR__.'/ProcessRulesetAutoloadTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + new Ruleset($config); + + $finalIncludes = get_included_files(); + $diff = array_diff($finalIncludes, $originallyIncludes); + + $this->assertContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadAlways.1.php'), + $diff, + 'ProcessRulesetAutoloadLoadAlways.1.php autoload file was not loaded' + ); + $this->assertContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadAlways.2.php'), + $diff, + 'ProcessRulesetAutoloadLoadAlways.2.php autoload file was not loaded' + ); + $this->assertContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadAlways.3.php'), + $diff, + 'ProcessRulesetAutoloadLoadAlways.3.php autoload file was not loaded' + ); + $this->assertContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadAlways.4.php'), + $diff, + 'ProcessRulesetAutoloadLoadAlways.4.php autoload file was not loaded' + ); + $this->assertContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadPhpcsOnly.php'), + $diff, + 'ProcessRulesetAutoloadLoadPhpcsOnly.php autoload file was not loaded' + ); + $this->assertNotContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadPhpcbfOnly.php'), + $diff, + 'ProcessRulesetAutoloadLoadPhpcbfOnly.php autoload file was loaded, while it shouldn\'t have been' + ); + + }//end testShouldProcessAutoloadCsonly() + + + /** + * Verify that in CBF mode, phpcbf-only directives are respected and phpcs-only + * directives are ignored. + * + * @group CBF + * + * @return void + */ + public function testShouldProcessAutoloadCbfonly() + { + if (PHP_CODESNIFFER_CBF === false) { + $this->markTestSkipped('This test needs CBF mode to run'); + } + + $originallyIncludes = get_included_files(); + + // Set up the ruleset. + $standard = __DIR__.'/ProcessRulesetAutoloadTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + new Ruleset($config); + + $finalIncludes = get_included_files(); + $diff = array_diff($finalIncludes, $originallyIncludes); + + $this->assertContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadAlways.1.php'), + $diff, + 'ProcessRulesetAutoloadLoadAlways.1.php autoload file was not loaded' + ); + $this->assertContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadAlways.2.php'), + $diff, + 'ProcessRulesetAutoloadLoadAlways.2.php autoload file was not loaded' + ); + $this->assertContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadAlways.3.php'), + $diff, + 'ProcessRulesetAutoloadLoadAlways.3.php autoload file was not loaded' + ); + $this->assertContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadAlways.4.php'), + $diff, + 'ProcessRulesetAutoloadLoadAlways.4.php autoload file was not loaded' + ); + $this->assertNotContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadPhpcsOnly.php'), + $diff, + 'ProcessRulesetAutoloadLoadPhpcsOnly.php autoload file was loaded, while it shouldn\'t have been' + ); + $this->assertContains( + __DIR__.str_replace('/', DIRECTORY_SEPARATOR, '/Fixtures/ProcessRulesetAutoloadLoadPhpcbfOnly.php'), + $diff, + 'ProcessRulesetAutoloadLoadPhpcbfOnly.php autoload file was not loaded' + ); + + }//end testShouldProcessAutoloadCbfonly() + + + /** + * Test an exception is thrown when the directive points to a file which doesn't exist. + * + * @return void + */ + public function testFileNotFoundException() + { + $exceptionMsg = 'The specified autoload file "./tests/Core/Ruleset/Fixtures/ThisFileDoesNotExist.php" does not exist'; + $this->expectRuntimeExceptionMessage($exceptionMsg); + + // Set up the ruleset. + $standard = __DIR__.'/ProcessRulesetAutoloadFileNotFoundTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + new Ruleset($config); + + }//end testFileNotFoundException() + + +}//end class diff --git a/tests/Core/Ruleset/ProcessRulesetAutoloadTest.xml b/tests/Core/Ruleset/ProcessRulesetAutoloadTest.xml new file mode 100644 index 0000000000..450de65079 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetAutoloadTest.xml @@ -0,0 +1,37 @@ + + + + . + + + + ./Fixtures/ProcessRulesetAutoloadLoadAlways.1.php + Fixtures/ProcessRulesetAutoloadLoadAlways.2.php + + + ./tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadAlways.3.php + tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadAlways.4.php + + + ./tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadPhpcsOnly.php + + + ./tests/Core/Ruleset/Fixtures/ProcessRulesetAutoloadLoadPhpcbfOnly.php + + + + + From 130180d7ad841337478607141d60d98ee095672f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Nov 2024 14:56:11 +0100 Subject: [PATCH 842/874] GH Actions: change PHAR building to reusable workflow The workflows currently contain two jobs which build the PHAR files. In PHPCS 4.0, a third job will be added (in relation to 530), which will also need to build the PHAR files. This means that any changes to the steps in these jobs would then have to be made in three places. With this in mind, it makes sense to change the PHAR building to a reusable workflow, which can then be used by all three jobs. With this change, any changes to the steps of the job will only need to be made in one place. This commit makes it so. --- .github/workflows/build-phar.yml | 32 ++------- .github/workflows/reusable-build-phar.yml | 81 +++++++++++++++++++++++ .github/workflows/test.yml | 52 ++------------- 3 files changed, 92 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/reusable-build-phar.yml diff --git a/.github/workflows/build-phar.yml b/.github/workflows/build-phar.yml index b091e24c45..d1d37f5a70 100644 --- a/.github/workflows/build-phar.yml +++ b/.github/workflows/build-phar.yml @@ -8,6 +8,7 @@ on: - master paths: - '.github/workflows/build-phar.yml' + - '.github/workflows/reusable-build-phar.yml' - 'scripts/build-phar.php' - 'autoload.php' - 'src/Config.php' @@ -18,6 +19,7 @@ on: pull_request: paths: - '.github/workflows/build-phar.yml' + - '.github/workflows/reusable-build-phar.yml' - 'scripts/build-phar.php' - 'autoload.php' - 'src/Config.php' @@ -37,35 +39,13 @@ concurrency: jobs: build: - runs-on: ubuntu-latest - strategy: matrix: # Deliberately missing PHP 8.0 as that PHAR is build and used in the test workflow. - php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.1', '8.2', '8.3', '8.4', '8.5'] + php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.1', '8.2', '8.3', '8.4', 'nightly'] name: "Build Phar on PHP: ${{ matrix.php }}" - continue-on-error: ${{ matrix.php == '8.5' }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - ini-values: phar.readonly=Off, error_reporting=-1, display_errors=On - - - name: Build the phars - run: php scripts/build-phar.php - - # Both the below only check a file which is rarely changed and therefore unlikely to have issues. - # This test is about testing that the phars are functional, *not* about whether the code style complies. - - name: 'PHPCS: check code style using the Phar file to test the Phar is functional' - run: php phpcs.phar ./scripts - - - name: 'PHPCBF: fix code style using the Phar file to test the Phar is functional' - run: php phpcbf.phar ./scripts + uses: ./.github/workflows/reusable-build-phar.yml + with: + phpVersion: ${{ matrix.php }} diff --git a/.github/workflows/reusable-build-phar.yml b/.github/workflows/reusable-build-phar.yml new file mode 100644 index 0000000000..bac53d77ee --- /dev/null +++ b/.github/workflows/reusable-build-phar.yml @@ -0,0 +1,81 @@ +name: Build PHAR files + +on: + workflow_call: + inputs: + phpVersion: + description: "The PHP version to use. Defaults to PHP 8.0 as used for the releases." + type: string + required: false + default: '8.0' + uploadArtifacts: + description: "Whether or not to upload the artifacts. Defaults to false." + type: boolean + required: false + default: false + retentionDays: + description: "How long uploaded artifacts should remain available (in days). Defaults to 1 day." + type: string + required: false + default: 1 + createAttestations: + description: "Whether or not to create attestations for the artifacts. Defaults to false." + type: boolean + required: false + default: false + +jobs: + build: + runs-on: ubuntu-latest + name: "Build Phar on PHP: ${{ inputs.phpVersion }}" + + continue-on-error: ${{ inputs.phpVersion == 'nightly' }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ inputs.phpVersion }} + coverage: none + ini-values: phar.readonly=Off, error_reporting=-1, display_errors=On + + - name: Build the phar files + run: php scripts/build-phar.php + + # Provide provenance for generated binaries. + - name: Generate artifact attestations + if: ${{ inputs.createAttestations == true }} + uses: actions/attest-build-provenance@v1 + with: + subject-path: | + ${{ github.workspace }}/phpcs.phar + ${{ github.workspace }}/phpcbf.phar + + - name: Upload the PHPCS phar + if: ${{ inputs.uploadArtifacts == true }} + uses: actions/upload-artifact@v4 + with: + name: phpcs-phar + path: ./phpcs.phar + if-no-files-found: error + retention-days: ${{ inputs.retentionDays }} + + - name: Upload the PHPCBF phar + if: ${{ inputs.uploadArtifacts == true }} + uses: actions/upload-artifact@v4 + with: + name: phpcbf-phar + path: ./phpcbf.phar + if-no-files-found: error + retention-days: ${{ inputs.retentionDays }} + + # Both the below only check a file which is rarely changed and therefore unlikely to have issues. + # This test is about testing that the phars are functional, *not* about whether the code style complies. + - name: 'PHPCS: check code style using the Phar file to test the Phar is functional' + run: php phpcs.phar ./scripts + + - name: 'PHPCBF: fix code style using the Phar file to test the Phar is functional' + run: php phpcbf.phar ./scripts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 212798b30f..3d9d758301 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,6 @@ jobs: group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }} cancel-in-progress: true - runs-on: ubuntu-latest name: "Build Phar on PHP: 8.0" permissions: @@ -30,54 +29,13 @@ jobs: contents: read attestations: write - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' - coverage: none - ini-values: phar.readonly=Off, error_reporting=-1, display_errors=On - - - name: Build the phar - run: php scripts/build-phar.php - - # Provide provenance for generated binaries. + uses: ./.github/workflows/reusable-build-phar.yml + with: + uploadArtifacts: true + retentionDays: 28 # Only attests the build artifacts which will be used in the published releases as per the guidelines in "what to attest". # https://docs.github.com/en/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds - - name: Generate artifact attestations - if: ${{ github.ref_type == 'tag' }} - uses: actions/attest-build-provenance@v1 - with: - subject-path: | - ${{ github.workspace }}/phpcs.phar - ${{ github.workspace }}/phpcbf.phar - - - name: Upload the PHPCS phar - uses: actions/upload-artifact@v4 - with: - name: phpcs-phar - path: ./phpcs.phar - if-no-files-found: error - retention-days: 28 - - - name: Upload the PHPCBF phar - uses: actions/upload-artifact@v4 - with: - name: phpcbf-phar - path: ./phpcbf.phar - if-no-files-found: error - retention-days: 28 - - # Both the below only check a file which is rarely changed and therefore unlikely to have issues. - # This test is about testing that the phars are functional, *not* about whether the code style complies. - - name: 'PHPCS: check code style using the Phar file to test the Phar is functional' - run: php phpcs.phar ./scripts - - - name: 'PHPCBF: fix code style using the Phar file to test the Phar is functional' - run: php phpcbf.phar ./scripts + createAttestations: ${{ github.ref_type == 'tag' }} test: # Cancels all previous runs of this particular job for the same branch that have not yet completed. From cd617bf50c0bbd45106b546f1eb856b43faa5122 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 20 Nov 2024 03:11:10 +0100 Subject: [PATCH 843/874] Ruleset::expandSniffDirectory(): add test --- .../Core/Ruleset/ExpandSniffDirectoryTest.php | 78 +++++++++++++++++++ .../Core/Ruleset/ExpandSniffDirectoryTest.xml | 8 ++ .../.hidden/HiddenDirShouldBeIgnoredSniff.php | 15 ++++ .../src/MyStandard/AbstractSniff.php | 12 +++ .../src/MyStandard/DummySniff.php | 25 ++++++ .../.hidden/HiddenDirShouldBeIgnoredSniff.php | 15 ++++ .../src/MyStandard/Sniffs/AbstractSniff.php | 12 +++ .../Sniffs/CategoryA/.HiddenFileSniff.php | 12 +++ .../CategoryA/.hidden/DoNotFindMeSniff.txt | 0 .../.hidden/HiddenDirShouldBeIgnoredSniff.php | 15 ++++ .../Sniffs/CategoryA/DoNotFindMeSniff.txt | 12 +++ .../Sniffs/CategoryA/FindMeSniff.php | 12 +++ .../CategoryA/IncorrectFileExtensionSniff.inc | 12 +++ .../Sniffs/CategoryA/MissingSniffSuffix.php | 12 +++ .../IncorrectLevelShouldStillBeFoundSniff.php | 12 +++ .../Sniffs/CategoryB/AnotherAbstractSniff.php | 12 +++ .../Sniffs/CategoryB/FindMeSniff.php | 12 +++ .../IncorrectFileExtensionSniff.php3 | 12 +++ .../IncorrectLevelShouldStillBeFoundSniff.php | 12 +++ .../MyStandard/Utils/NotInSniffsDirSniff.php | 12 +++ .../Utils/SubDir/NotInSniffsDirSniff.php | 12 +++ .../.hiddenAbove/src/MyStandard/ruleset.xml | 4 + 22 files changed, 328 insertions(+) create mode 100644 tests/Core/Ruleset/ExpandSniffDirectoryTest.php create mode 100644 tests/Core/Ruleset/ExpandSniffDirectoryTest.xml create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/.hidden/HiddenDirShouldBeIgnoredSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/AbstractSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/DummySniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/.hidden/HiddenDirShouldBeIgnoredSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/AbstractSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryA/.HiddenFileSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryA/.hidden/DoNotFindMeSniff.txt create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryA/.hidden/HiddenDirShouldBeIgnoredSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryA/DoNotFindMeSniff.txt create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryA/FindMeSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryA/IncorrectFileExtensionSniff.inc create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryA/MissingSniffSuffix.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryA/Subdir/IncorrectLevelShouldStillBeFoundSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryB/AnotherAbstractSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryB/FindMeSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryB/IncorrectFileExtensionSniff.php3 create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/IncorrectLevelShouldStillBeFoundSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Utils/NotInSniffsDirSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/Utils/SubDir/NotInSniffsDirSniff.php create mode 100644 tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/ruleset.xml diff --git a/tests/Core/Ruleset/ExpandSniffDirectoryTest.php b/tests/Core/Ruleset/ExpandSniffDirectoryTest.php new file mode 100644 index 0000000000..8f7f4f93f6 --- /dev/null +++ b/tests/Core/Ruleset/ExpandSniffDirectoryTest.php @@ -0,0 +1,78 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHPUnit\Framework\TestCase; + +/** + * Test the Ruleset::expandSniffDirectory() method. + * + * @covers \PHP_CodeSniffer\Ruleset::expandSniffDirectory + */ +final class ExpandSniffDirectoryTest extends TestCase +{ + + + /** + * Test finding sniff files based on a given directory. + * + * This test verifies that: + * - Hidden (sub)directories are ignored, but the given directory is allowed to be within a hidden directory. + * - Hidden files are ignored. + * - Files without a "php" extension are ignored. + * - Files without a "Sniff" suffix in the file name are ignored. + * + * Note: the "[Another]AbstractSniff" files will be found and included in the return value + * from `Ruleset::expandSniffDirectory()`. + * Those are filtered out later in the `Ruleset::registerSniffs()` method. + * + * @return void + */ + public function testExpandSniffDirectory() + { + // Set up the ruleset. + $standard = __DIR__.'/ExpandSniffDirectoryTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + $expectedPathToRuleset = __DIR__.'/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/ruleset.xml'; + $expectedPathToRuleset = realpath($expectedPathToRuleset); + $this->assertNotFalse($expectedPathToRuleset, 'Ruleset file could not be found'); + $this->assertContains($expectedPathToRuleset, $ruleset->paths, 'Ruleset file not included in the "seen ruleset paths"'); + + /* + * Take note: the expectation includes some "undesirables" related to the convoluted directory structure + * in the "standard" used as a test fixture. + * + * That is okay as (for now) non-standard directory layouts are supported. + * + * This test is not about the standard directory layout. + */ + + $expectedSniffCodes = [ + '.Sniffs.IncorrectLevelShouldStillBeFound' => 'MyStandard\\Sniffs\\IncorrectLevelShouldStillBeFoundSniff', + 'MyStandard.CategoryA.FindMe' => 'MyStandard\\Sniffs\\CategoryA\\FindMeSniff', + 'MyStandard.CategoryB.FindMe' => 'MyStandard\\Sniffs\\CategoryB\\FindMeSniff', + 'Sniffs.SubDir.IncorrectLevelShouldStillBeFound' => 'MyStandard\\Sniffs\\CategoryA\\SubDir\\IncorrectLevelShouldStillBeFoundSniff', + ]; + + // Sort the value to make the tests stable as different OSes will read directories + // in a different order and the order is not relevant for these tests. Just the values. + $actual = $ruleset->sniffCodes; + ksort($actual); + + $this->assertSame($expectedSniffCodes, $actual, 'Registered sniffs do not match expectation'); + + }//end testExpandSniffDirectory() + + +}//end class diff --git a/tests/Core/Ruleset/ExpandSniffDirectoryTest.xml b/tests/Core/Ruleset/ExpandSniffDirectoryTest.xml new file mode 100644 index 0000000000..f2646da02a --- /dev/null +++ b/tests/Core/Ruleset/ExpandSniffDirectoryTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/.hidden/HiddenDirShouldBeIgnoredSniff.php b/tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/.hidden/HiddenDirShouldBeIgnoredSniff.php new file mode 100644 index 0000000000..3ee64dbba6 --- /dev/null +++ b/tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/.hidden/HiddenDirShouldBeIgnoredSniff.php @@ -0,0 +1,15 @@ + + + + From 48c5e81c546413bc150ee30317a2b0ad95d60cc7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 18 Nov 2024 20:57:53 +0100 Subject: [PATCH 844/874] Ruleset::setSniffProperty(): add test for edge case / unused sniff I haven't been able to come up with a _real_ situation in which [this condition](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/15db7232015d4fc1e023ef1eff0e65777a906f2c/src/Ruleset.php#L1476-L1479) could result in an early return - either via reading an XML ruleset or via inline `phpcs:set` annotation. Having said that, the method is `public` and is regularly used in test frameworks for external standards, so this code should remain in place. This commit now safeguards the behaviour via a test. --- tests/Core/Ruleset/SetSniffPropertyTest.php | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/Core/Ruleset/SetSniffPropertyTest.php b/tests/Core/Ruleset/SetSniffPropertyTest.php index ed902b9084..b974844c0c 100644 --- a/tests/Core/Ruleset/SetSniffPropertyTest.php +++ b/tests/Core/Ruleset/SetSniffPropertyTest.php @@ -202,6 +202,39 @@ public function testSetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCateg }//end testSetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCategory() + /** + * Test that attempting to set a property for a sniff which isn't registered will be ignored. + * + * @return void + */ + public function testDirectCallIgnoredPropertyForUnusedSniff() + { + $sniffCode = 'Generic.Formatting.SpaceAfterCast'; + $sniffClass = 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Formatting\\SpaceAfterCastSniff'; + + // Set up the ruleset. + $config = new ConfigDouble(['--standard=PSR1']); + $ruleset = new Ruleset($config); + + $ruleset->setSniffProperty( + $sniffClass, + 'ignoreNewlines', + [ + 'scope' => 'sniff', + 'value' => true, + ] + ); + + // Verify that there are sniffs registered. + $this->assertGreaterThan(0, count($ruleset->sniffCodes), 'No sniff codes registered'); + + // Verify that our target sniff has NOT been registered after attempting to set the property. + $this->assertArrayNotHasKey($sniffCode, $ruleset->sniffCodes, 'Unused sniff was registered in sniffCodes, but shouldn\'t have been'); + $this->assertArrayNotHasKey($sniffClass, $ruleset->sniffs, 'Unused sniff was registered in sniffs, but shouldn\'t have been'); + + }//end testDirectCallIgnoredPropertyForUnusedSniff() + + /** * Test that setting a property via a direct call to the Ruleset::setSniffProperty() method * sets the property correctly when using the new $settings array format. From a0ef0325f3e80ba1025565ce176472d585b38bc3 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 20 Nov 2024 01:42:14 +0100 Subject: [PATCH 845/874] Ruleset::processRuleset(); add various tests for things not already covered Mostly testing error handling and the handling of edge cases. --- .../Fixtures/InvalidNoSniffsDir/Sniffs | 0 .../Fixtures/InvalidNoSniffsDir/ruleset.xml | 4 + ...ssRulesetAutoExpandSniffsDirectoryTest.xml | 8 + .../ProcessRulesetExcludeSniffGroupTest.xml | 11 + .../ProcessRulesetInvalidNoSniffsDirTest.xml | 10 + tests/Core/Ruleset/ProcessRulesetMiscTest.xml | 25 ++ tests/Core/Ruleset/ProcessRulesetTest.php | 263 ++++++++++++++++++ 7 files changed, 321 insertions(+) create mode 100644 tests/Core/Ruleset/Fixtures/InvalidNoSniffsDir/Sniffs create mode 100644 tests/Core/Ruleset/Fixtures/InvalidNoSniffsDir/ruleset.xml create mode 100644 tests/Core/Ruleset/ProcessRulesetAutoExpandSniffsDirectoryTest.xml create mode 100644 tests/Core/Ruleset/ProcessRulesetExcludeSniffGroupTest.xml create mode 100644 tests/Core/Ruleset/ProcessRulesetInvalidNoSniffsDirTest.xml create mode 100644 tests/Core/Ruleset/ProcessRulesetMiscTest.xml create mode 100644 tests/Core/Ruleset/ProcessRulesetTest.php diff --git a/tests/Core/Ruleset/Fixtures/InvalidNoSniffsDir/Sniffs b/tests/Core/Ruleset/Fixtures/InvalidNoSniffsDir/Sniffs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/Core/Ruleset/Fixtures/InvalidNoSniffsDir/ruleset.xml b/tests/Core/Ruleset/Fixtures/InvalidNoSniffsDir/ruleset.xml new file mode 100644 index 0000000000..b85e7486e8 --- /dev/null +++ b/tests/Core/Ruleset/Fixtures/InvalidNoSniffsDir/ruleset.xml @@ -0,0 +1,4 @@ + + + + diff --git a/tests/Core/Ruleset/ProcessRulesetAutoExpandSniffsDirectoryTest.xml b/tests/Core/Ruleset/ProcessRulesetAutoExpandSniffsDirectoryTest.xml new file mode 100644 index 0000000000..6968808664 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetAutoExpandSniffsDirectoryTest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Core/Ruleset/ProcessRulesetExcludeSniffGroupTest.xml b/tests/Core/Ruleset/ProcessRulesetExcludeSniffGroupTest.xml new file mode 100644 index 0000000000..a83347ce8d --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetExcludeSniffGroupTest.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/tests/Core/Ruleset/ProcessRulesetInvalidNoSniffsDirTest.xml b/tests/Core/Ruleset/ProcessRulesetInvalidNoSniffsDirTest.xml new file mode 100644 index 0000000000..daa07f2e2a --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetInvalidNoSniffsDirTest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/Core/Ruleset/ProcessRulesetMiscTest.xml b/tests/Core/Ruleset/ProcessRulesetMiscTest.xml new file mode 100644 index 0000000000..56bf689818 --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetMiscTest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Core/Ruleset/ProcessRulesetTest.php b/tests/Core/Ruleset/ProcessRulesetTest.php new file mode 100644 index 0000000000..d53889a88c --- /dev/null +++ b/tests/Core/Ruleset/ProcessRulesetTest.php @@ -0,0 +1,263 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHPUnit\Framework\TestCase; + +/** + * Test various aspects of the Ruleset::processRuleset() method not covered via other tests. + * + * @covers \PHP_CodeSniffer\Ruleset::processRuleset + */ +final class ProcessRulesetTest extends TestCase +{ + + + /** + * Verify that a registered standard which doesn't have a "Sniffs" directory, but does have a file + * called "Sniffs" doesn't result in any errors being thrown. + * + * @return void + */ + public function testSniffsFileNotDirectory() + { + // Set up the ruleset. + $standard = __DIR__.'/ProcessRulesetInvalidNoSniffsDirTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + $expected = ['Generic.PHP.BacktickOperator' => 'PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\BacktickOperatorSniff']; + + $this->assertSame($expected, $ruleset->sniffCodes); + + }//end testSniffsFileNotDirectory() + + + /** + * Verify that all sniffs in a registered standard included in a ruleset automatically get added. + * + * @return void + */ + public function testAutoExpandSniffsDirectory() + { + // Set up the ruleset. + $standard = __DIR__.'/ProcessRulesetAutoExpandSniffsDirectoryTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + $std = 'TestStandard'; + $sniffDir = 'Fixtures\TestStandard\Sniffs'; + $expected = [ + "$std.Deprecated.WithLongReplacement" => "$sniffDir\Deprecated\WithLongReplacementSniff", + "$std.Deprecated.WithReplacement" => "$sniffDir\Deprecated\WithReplacementSniff", + "$std.Deprecated.WithReplacementContainingLinuxNewlines" => "$sniffDir\Deprecated\WithReplacementContainingLinuxNewlinesSniff", + "$std.Deprecated.WithReplacementContainingNewlines" => "$sniffDir\Deprecated\WithReplacementContainingNewlinesSniff", + "$std.Deprecated.WithoutReplacement" => "$sniffDir\Deprecated\WithoutReplacementSniff", + "$std.DeprecatedInvalid.EmptyDeprecationVersion" => "$sniffDir\DeprecatedInvalid\EmptyDeprecationVersionSniff", + "$std.DeprecatedInvalid.EmptyRemovalVersion" => "$sniffDir\DeprecatedInvalid\EmptyRemovalVersionSniff", + "$std.DeprecatedInvalid.InvalidDeprecationMessage" => "$sniffDir\DeprecatedInvalid\InvalidDeprecationMessageSniff", + "$std.DeprecatedInvalid.InvalidDeprecationVersion" => "$sniffDir\DeprecatedInvalid\InvalidDeprecationVersionSniff", + "$std.DeprecatedInvalid.InvalidRemovalVersion" => "$sniffDir\DeprecatedInvalid\InvalidRemovalVersionSniff", + "$std.SetProperty.AllowedAsDeclared" => "$sniffDir\SetProperty\AllowedAsDeclaredSniff", + "$std.SetProperty.AllowedViaMagicMethod" => "$sniffDir\SetProperty\AllowedViaMagicMethodSniff", + "$std.SetProperty.AllowedViaStdClass" => "$sniffDir\SetProperty\AllowedViaStdClassSniff", + "$std.SetProperty.NotAllowedViaAttribute" => "$sniffDir\SetProperty\NotAllowedViaAttributeSniff", + "$std.SetProperty.PropertyTypeHandling" => "$sniffDir\SetProperty\PropertyTypeHandlingSniff", + ]; + + // Sort the value to make the tests stable as different OSes will read directories + // in a different order and the order is not relevant for these tests. Just the values. + $actual = $ruleset->sniffCodes; + ksort($actual); + + $this->assertSame($expected, $actual); + + }//end testAutoExpandSniffsDirectory() + + + /** + * Verify handling of exclusions of groups of sniffs after inclusion via an even larger "group". + * + * @return void + */ + public function testExcludeSniffGroup() + { + // Set up the ruleset. + $standard = __DIR__.'/ProcessRulesetExcludeSniffGroupTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + $expected = [ + 'PSR1.Classes.ClassDeclaration' => 'PHP_CodeSniffer\Standards\PSR1\Sniffs\Classes\ClassDeclarationSniff', + 'PSR1.Methods.CamelCapsMethodName' => 'PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff', + ]; + + // Sort the value to make the tests stable as different OSes will read directories + // in a different order and the order is not relevant for these tests. Just the values. + $actual = $ruleset->sniffCodes; + ksort($actual); + + $this->assertSame($expected, $actual); + + }//end testExcludeSniffGroup() + + + /* + * No test for without "name" as there is nothing we can assert to verify it's being ignored. + */ + + + /** + * Test that an `` directive without a "value" attribute will be set to the ini equivalent of `true`. + * + * @return void + */ + public function testIniWithoutValue() + { + $originalValue = ini_get('user_agent'); + + // Set up the ruleset. + $this->getMiscRuleset(); + + $actualValue = ini_get('user_agent'); + // Reset the ini to its original value before the assertion to ensure it's never left in an incorrect state. + if ($originalValue !== false) { + ini_set('user_agent', $originalValue); + } + + $this->assertSame('1', $actualValue); + + }//end testIniWithoutValue() + + + /** + * Verify that inclusion of a single error code: + * - Includes the sniff, but sets "severity" for the sniff to 0; + * - Sets "severity" for the specific error code included to 5.; + * + * @return void + */ + public function testIncludeSingleErrorCode() + { + // Set up the ruleset. + $ruleset = $this->getMiscRuleset(); + + $key = 'severity'; + + $sniffCode = 'Generic.PHP.RequireStrictTypes'; + $this->assertArrayHasKey($sniffCode, $ruleset->ruleset, "Sniff $sniffCode not registered"); + $this->assertTrue(is_array($ruleset->ruleset[$sniffCode]), "Sniff $sniffCode is not an array"); + $this->assertArrayHasKey($key, $ruleset->ruleset[$sniffCode], "Directive $key not registered for sniff $sniffCode"); + $this->assertSame(0, $ruleset->ruleset[$sniffCode][$key], "$key has unexpected value for sniff $sniffCode"); + + $sniffCode = 'Generic.PHP.RequireStrictTypes.MissingDeclaration'; + $this->assertArrayHasKey($sniffCode, $ruleset->ruleset, "Sniff $sniffCode not registered"); + $this->assertTrue(is_array($ruleset->ruleset[$sniffCode]), "Sniff $sniffCode is not an array"); + $this->assertArrayHasKey($key, $ruleset->ruleset[$sniffCode], "Directive $key not registered for sniff $sniffCode"); + $this->assertSame(5, $ruleset->ruleset[$sniffCode][$key], "$key has unexpected value for sniff $sniffCode"); + + }//end testIncludeSingleErrorCode() + + + /** + * Verify that if all error codes, save one, from a sniff were previously excluded, an include for an additional + * error code from that same sniff will be respected. + * + * @return void + */ + public function testErrorCodeIncludeAfterExclude() + { + // Set up the ruleset. + $ruleset = $this->getMiscRuleset(); + + $key = 'severity'; + + $sniffCode = 'PEAR.Files.IncludingFile'; + $this->assertArrayHasKey($sniffCode, $ruleset->ruleset, "Sniff $sniffCode not registered"); + $this->assertTrue(is_array($ruleset->ruleset[$sniffCode]), "Sniff $sniffCode is not an array"); + $this->assertArrayHasKey($key, $ruleset->ruleset[$sniffCode], "Directive $key not registered for sniff $sniffCode"); + $this->assertSame(0, $ruleset->ruleset[$sniffCode][$key], "$key has unexpected value for sniff $sniffCode"); + + $sniffCode = 'PEAR.Files.IncludingFile.BracketsNotRequired'; + $this->assertArrayHasKey($sniffCode, $ruleset->ruleset, "Sniff $sniffCode not registered"); + $this->assertTrue(is_array($ruleset->ruleset[$sniffCode]), "Sniff $sniffCode is not an array"); + $this->assertArrayHasKey($key, $ruleset->ruleset[$sniffCode], "Directive $key not registered for sniff $sniffCode"); + $this->assertSame(5, $ruleset->ruleset[$sniffCode][$key], "$key has unexpected value for sniff $sniffCode"); + + $sniffCode = 'PEAR.Files.IncludingFile.UseRequire'; + $this->assertArrayHasKey($sniffCode, $ruleset->ruleset, "Sniff $sniffCode not registered"); + $this->assertTrue(is_array($ruleset->ruleset[$sniffCode]), "Sniff $sniffCode is not an array"); + $this->assertArrayHasKey($key, $ruleset->ruleset[$sniffCode], "Directive $key not registered for sniff $sniffCode"); + $this->assertSame(5, $ruleset->ruleset[$sniffCode][$key], "$key has unexpected value for sniff $sniffCode"); + + }//end testErrorCodeIncludeAfterExclude() + + + /** + * Verify that a element without a "ref" is completely ignored. + * + * @return void + */ + public function testRuleWithoutRefIsIgnored() + { + // Set up the ruleset. + $ruleset = $this->getMiscRuleset(); + + $sniffCode = 'Generic.Metrics.CyclomaticComplexity'; + $this->assertArrayNotHasKey($sniffCode, $ruleset->sniffCodes, "Sniff $sniffCode registered"); + $this->assertArrayNotHasKey($sniffCode, $ruleset->ruleset, "Sniff $sniffCode adjusted"); + + }//end testRuleWithoutRefIsIgnored() + + + /** + * Verify that no "ruleset adjustments" are registered via an `` without a "name". + * + * @return void + */ + public function testRuleExcludeWithoutNameIsIgnored() + { + // Set up the ruleset. + $ruleset = $this->getMiscRuleset(); + + $sniffCode = 'Generic.PHP.BacktickOperator'; + $this->assertArrayHasKey($sniffCode, $ruleset->sniffCodes, "Sniff $sniffCode not registered"); + $this->assertArrayNotHasKey($sniffCode, $ruleset->ruleset, "Sniff $sniffCode adjusted"); + + $sniffCode = 'Generic.PHP.BacktickOperator.Found'; + $this->assertArrayNotHasKey($sniffCode, $ruleset->ruleset, "Sniff $sniffCode adjusted"); + + }//end testRuleExcludeWithoutNameIsIgnored() + + + /** + * Test Helper. + * + * @return \PHP_CodeSniffer\Sniffs\Sniff + */ + private function getMiscRuleset() + { + static $ruleset; + + if (isset($ruleset) === false) { + // Set up the ruleset. + $standard = __DIR__.'/ProcessRulesetMiscTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + $ruleset = new Ruleset($config); + } + + return $ruleset; + + }//end getMiscRuleset() + + +}//end class From 856219c8b4c512f36224019bdd97b3488ef26030 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 25 Jun 2024 15:32:54 -0300 Subject: [PATCH 846/874] Squiz/ArrayDeclaration: improves test coverage This commit adds tests that were previously missing. There are still some uncovered lines in this sniff, those lines might be unreachable, but I did not investigate this at this time. There is also potentially some more relevant tests that could be added for lines that are already covered. This is also not addressed in this commit. --- .../Tests/Arrays/ArrayDeclarationUnitTest.1.inc | 13 ++++++++++++- .../Arrays/ArrayDeclarationUnitTest.1.inc.fixed | 10 ++++++++++ .../Tests/Arrays/ArrayDeclarationUnitTest.2.inc | 11 +++++++++++ .../Arrays/ArrayDeclarationUnitTest.2.inc.fixed | 10 ++++++++++ .../Tests/Arrays/ArrayDeclarationUnitTest.3.inc | 7 +++++++ .../Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php | 4 ++++ 6 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.3.inc diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc index cdbfff6c33..6a25ab9072 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc @@ -19,7 +19,7 @@ class TestClass 'height' => '', ); - private $_bad = Array( + private $_bad = ARRAY( 'width' => '', 'height' => '' ); @@ -547,3 +547,14 @@ $x = array( 1, static::helloWorld(), $class instanceof static, 2, ); + +$noSpaceBeforeDoubleArrow = array( + 'width'=> '', + 'height' => '', + ); + +$newlineAfterDoubleArrow = array( + 'width' => + '', + 'height' => '', + ); diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed index 6f8fe216a3..048f898c8d 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed @@ -586,3 +586,13 @@ $x = array( $class instanceof static, 2, ); + +$noSpaceBeforeDoubleArrow = array( + 'width' => '', + 'height' => '', + ); + +$newlineAfterDoubleArrow = array( + 'width' => '', + 'height' => '', + ); diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc index 90b026f023..f5f4c84234 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc @@ -536,3 +536,14 @@ $x = [ 1, static::helloWorld(), $class instanceof static, 2, ]; + +$noSpaceBeforeDoubleArrow = [ + 'width'=> '', + 'height' => '', + ]; + +$newlineAfterDoubleArrow = [ + 'width' => + '', + 'height' => '', + ]; diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed index 533be16a65..6ef97d6434 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed @@ -573,3 +573,13 @@ $x = [ $class instanceof static, 2, ]; + +$noSpaceBeforeDoubleArrow = [ + 'width' => '', + 'height' => '', + ]; + +$newlineAfterDoubleArrow = [ + 'width' => '', + 'height' => '', + ]; diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.3.inc b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.3.inc new file mode 100644 index 0000000000..beb5ae1aec --- /dev/null +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.3.inc @@ -0,0 +1,7 @@ + 1, 540 => 1, 547 => 2, + 552 => 1, + 557 => 1, ]; case 'ArrayDeclarationUnitTest.2.inc': return [ @@ -229,6 +231,8 @@ public function getErrorList($testFile='') 526 => 1, 529 => 1, 536 => 2, + 541 => 1, + 546 => 1, ]; default: return []; From 8e0074ace15f690f20b46c37be3ef9dfb94f4008 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 20 Nov 2024 12:05:58 -0300 Subject: [PATCH 847/874] Squiz/ArrayDeclaration: improve handling of short lists inside a foreach This commit improves how the `Squiz.Arrays.ArrayDeclaration` sniff handles short lists inside a foreach and fixes a false positive. See https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/527 --- .../Sniffs/Arrays/ArrayDeclarationSniff.php | 20 +++++++++++++++++++ .../Arrays/ArrayDeclarationUnitTest.2.inc | 6 ++++++ .../ArrayDeclarationUnitTest.2.inc.fixed | 6 ++++++ .../Arrays/ArrayDeclarationUnitTest.4.inc | 8 ++++++++ .../ArrayDeclarationUnitTest.4.inc.fixed | 8 ++++++++ .../Tests/Arrays/ArrayDeclarationUnitTest.php | 3 +++ 6 files changed, 51 insertions(+) create mode 100644 src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.4.inc create mode 100644 src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.4.inc.fixed diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php index 89cd7bd57f..efad97e4b3 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -45,6 +45,26 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); + // Prevent acting on short lists inside a foreach (see + // https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/527). + if ($tokens[$stackPtr]['code'] === T_OPEN_SHORT_ARRAY + && isset($tokens[$stackPtr]['nested_parenthesis']) === true + ) { + $nestedParens = $tokens[$stackPtr]['nested_parenthesis']; + $lastParenthesisCloser = end($nestedParens); + $lastParenthesisOpener = key($nestedParens); + + if (isset($tokens[$lastParenthesisCloser]['parenthesis_owner']) === true + && $tokens[$tokens[$lastParenthesisCloser]['parenthesis_owner']]['code'] === T_FOREACH + ) { + $asKeyword = $phpcsFile->findNext(T_AS, ($lastParenthesisOpener + 1), $lastParenthesisCloser); + + if ($asKeyword !== false && $asKeyword < $stackPtr) { + return; + } + } + } + if ($tokens[$stackPtr]['code'] === T_ARRAY) { $phpcsFile->recordMetric($stackPtr, 'Short array syntax used', 'no'); diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc index f5f4c84234..415042d89e 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc @@ -547,3 +547,9 @@ $newlineAfterDoubleArrow = [ '', 'height' => '', ]; + +// Sniff should ignore short lists when inside a foreach. +// https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/527 +foreach ($data as [, , $value]) {} +foreach ($array as $k => [$v1, , $v3]) {} +foreach ([$a ,$b] as $c) {} // Not a short list. Sniff should handle it. diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed index 6ef97d6434..d835064ba1 100644 --- a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed @@ -583,3 +583,9 @@ $newlineAfterDoubleArrow = [ 'width' => '', 'height' => '', ]; + +// Sniff should ignore short lists when inside a foreach. +// https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/527 +foreach ($data as [, , $value]) {} +foreach ($array as $k => [$v1, , $v3]) {} +foreach ([$a, $b] as $c) {} // Not a short list. Sniff should handle it. diff --git a/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.4.inc b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.4.inc new file mode 100644 index 0000000000..9d87a6e7fe --- /dev/null +++ b/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.4.inc @@ -0,0 +1,8 @@ + 2, 541 => 1, 546 => 1, + 555 => 2, ]; + case 'ArrayDeclarationUnitTest.4.inc': + return [8 => 1]; default: return []; }//end switch From 21dc8739143a4a5f3344e03a9f68310e20fd3c0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 05:56:48 +0000 Subject: [PATCH 848/874] GH Actions: Bump actions/attest-build-provenance from 1 to 2 Bumps [actions/attest-build-provenance](https://github.com/actions/attest-build-provenance) from 1 to 2. - [Release notes](https://github.com/actions/attest-build-provenance/releases) - [Changelog](https://github.com/actions/attest-build-provenance/blob/main/RELEASE.md) - [Commits](https://github.com/actions/attest-build-provenance/compare/v1...v2) --- updated-dependencies: - dependency-name: actions/attest-build-provenance dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/reusable-build-phar.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-build-phar.yml b/.github/workflows/reusable-build-phar.yml index bac53d77ee..3b42a20056 100644 --- a/.github/workflows/reusable-build-phar.yml +++ b/.github/workflows/reusable-build-phar.yml @@ -48,7 +48,7 @@ jobs: # Provide provenance for generated binaries. - name: Generate artifact attestations if: ${{ inputs.createAttestations == true }} - uses: actions/attest-build-provenance@v1 + uses: actions/attest-build-provenance@v2 with: subject-path: | ${{ github.workspace }}/phpcs.phar From 50216b19d064b1671b322f8b4ee2dd923d72bd4f Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 9 Dec 2024 14:40:52 -0300 Subject: [PATCH 849/874] Generic/NestingLevel: ensure the sniff bails if `scope_closer` is not set Quoting @jrfnl: "Only checking for the scope_opener, when accessing/using both the scope_opener and scope_closer indexes, is probably fine in practical terms. However, the part of the code base which sets these indexes is not sufficiently covered by tests, nor does it document that those indexes will only be set if both can be set, so there may be edge case exceptions" (#684 (comment)). The sniff was already working fine before this change. Checking if `scope_closer` is just an extra precaution to err on the side of caution. This commit also updates the related code comment to better reflect what the if condition does. --- src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php index 3c086c7fe4..d2672b5eeb 100644 --- a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php @@ -56,8 +56,8 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - // Ignore abstract methods. - if (isset($tokens[$stackPtr]['scope_opener']) === false) { + // Ignore abstract and interface methods. Bail early when live coding. + if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) { return; } From c1c85177660cb3dc97b81a767cf7bf6435680e72 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 19 Nov 2024 11:23:35 -0300 Subject: [PATCH 850/874] Generic/NestingLevel: rename test case file Doing this to be able to create tests with syntax errors on separate files. --- ...nitTest.inc => NestingLevelUnitTest.1.inc} | 0 .../Tests/Metrics/NestingLevelUnitTest.php | 28 ++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) rename src/Standards/Generic/Tests/Metrics/{NestingLevelUnitTest.inc => NestingLevelUnitTest.1.inc} (100%) diff --git a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.inc b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.1.inc similarity index 100% rename from src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.inc rename to src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.1.inc diff --git a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php index fda8d461c7..c26ca45692 100644 --- a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php +++ b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.php @@ -26,11 +26,18 @@ final class NestingLevelUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the test file to process. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile='') { - return [73 => 1]; + switch ($testFile) { + case 'NestingLevelUnitTest.1.inc': + return [73 => 1]; + default: + return []; + } }//end getErrorList() @@ -41,14 +48,21 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * + * @param string $testFile The name of the test file to process. + * * @return array */ - public function getWarningList() + public function getWarningList($testFile='') { - return [ - 27 => 1, - 46 => 1, - ]; + switch ($testFile) { + case 'NestingLevelUnitTest.1.inc': + return [ + 27 => 1, + 46 => 1, + ]; + default: + return []; + } }//end getWarningList() From 9794ed89907fae02a4164839b3ee7109e82a86d7 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 9 Dec 2024 14:50:56 -0300 Subject: [PATCH 851/874] Generic/NestingLevel: improve code coverage --- .../Generic/Tests/Metrics/NestingLevelUnitTest.1.inc | 8 +++++++- .../Generic/Tests/Metrics/NestingLevelUnitTest.2.inc | 7 +++++++ .../Generic/Tests/Metrics/NestingLevelUnitTest.3.inc | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.2.inc create mode 100644 src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.3.inc diff --git a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.1.inc b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.1.inc index 9708792418..5f8c1b1dcb 100644 --- a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.1.inc +++ b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.1.inc @@ -99,4 +99,10 @@ function nestingEleven() } } -?> +abstract class AbstractClass { + abstract public function sniffShouldIgnoreAbstractMethods(); +} + +interface MyInterface { + public function sniffShouldIgnoreInterfaceMethods(); +} diff --git a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.2.inc b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.2.inc new file mode 100644 index 0000000000..9658af3005 --- /dev/null +++ b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.2.inc @@ -0,0 +1,7 @@ + Date: Mon, 9 Dec 2024 16:33:02 -0300 Subject: [PATCH 852/874] Generic/NestingLevel: improve tests by adding more tokens This commit improves the tests by adding more tokens that increase the nesting level and are already considered by the sniff, but were not being used in the tests. --- .../Tests/Metrics/NestingLevelUnitTest.1.inc | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.1.inc b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.1.inc index 5f8c1b1dcb..3f1dd92617 100644 --- a/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.1.inc +++ b/src/Standards/Generic/Tests/Metrics/NestingLevelUnitTest.1.inc @@ -27,16 +27,16 @@ function nestingFive() function nestingSix() { if ($condition) { - echo 'hi'; - switch ($condition) - { + } else { + switch ($condition) { case '1': if ($condition === '1') { - if ($cond) { + } elseif ($condition === '2') { + do { foreach ($conds as $cond) { echo 'hi'; } - } + } while ($cond > 5); } break; } @@ -79,19 +79,19 @@ function nestingEleven() case '1': if ($condition === '1') { if ($cond) { - switch ($cond) { - case '1': - if ($cond === '1') { - foreach ($conds as $cond) { - if ($cond === 'hi') { - if ($cond !== 'bye') { - echo 'hi'; - } + try { + if ( $cond === '1' ) { + for ( $i = 0; $i < 10; $i ++ ) { + while ($i < 5) { + if ( $cond === 'hi' ) { + match ( $cond ) { + 'hi' => 'something', + }; } } } - break; - } + } + } catch (Exception $e) {} } } break; From 9bb88c4069594fa005bd50d9fd7cffc6645d13c4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Dec 2024 20:57:34 +0100 Subject: [PATCH 853/874] GH Actions: automate release verification steps While the actual releasing can not be fully automated (due to security concerns related to signing releases in a GHA workflow), there are a number of verification checks which are part of the release workflow, which _can_ be automated. These checks were previously done as manual spot-checks. With the new workflow, they will now be executed structurally and automatically whenever a release is published on GitHub. The checks which are automated via this workflow are as follows: * For the PHAR files which can be downloaded from the GH "releases" page, the (unversioned) PHAR files published on the GH Pages website and the versioned PHAR files published on the GH Pages website for Phive (but which can also be downloaded manually), the following checks will now be run automatically: - Is the PHAR file available and can it be downloaded ? - Is the ASC (detached signature) file available and can it be downloaded ? - Verify the PHAR file via the attestation (which was created when the PHAR was created for a tag). - Verify the PHAR file is GPG signed and the signature matches. - Verify the PHAR file is functional (simple command runs without problems). - Verify the version with which the PHAR file identifies itself is the expected version. * For Phive: - Install via Phive. This will automatically also check the PHAR file is signed and the signature matches. - Verify the Phive installed PHAR file via the attestation. - Verify the Phive installed PHAR file is functional (simple command runs without problems). - Verify the version with which the PHAR file identifies itself is the expected version. Note: these checks will only run for releases from this repo. If a fork of the repo would publish their own releases, the workflow would fail anyhow (as the releases wouldn't be published to the website, nor accessible via Phive), so may as well prevent the workflow from running altogether. --- .github/workflows/verify-release.yml | 203 +++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 .github/workflows/verify-release.yml diff --git a/.github/workflows/verify-release.yml b/.github/workflows/verify-release.yml new file mode 100644 index 0000000000..99f611526a --- /dev/null +++ b/.github/workflows/verify-release.yml @@ -0,0 +1,203 @@ +name: Verify release + +on: + # Run whenever a release is published. + release: + types: [published] + # And whenever this workflow is updated. + push: + paths: + - '.github/workflows/verify-release.yml' + pull_request: + paths: + - '.github/workflows/verify-release.yml' + # Allow manually triggering the workflow. + workflow_dispatch: + +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + ################################################################################## + # Verify the release is available in all the right places and works as expected. # + ################################################################################## + verify-available-downloads: + runs-on: ubuntu-latest + + # Only run this workflow in the context of this repo. + if: github.repository_owner == 'PHPCSStandards' + + strategy: + fail-fast: false + matrix: + download_flavour: + - "Release assets" + - "Unversioned web" + - "Versioned web" + pharfile: + - 'phpcs' + - 'phpcbf' + + name: "${{ matrix.download_flavour }}: ${{ matrix.pharfile }}" + + steps: + - name: Retrieve latest release info + uses: octokit/request-action@v2.x + id: get_latest_release + with: + route: GET /repos/PHPCSStandards/PHP_CodeSniffer/releases/latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "DEBUG: Show API request failure status" + if: ${{ failure() }} + run: "echo No release found. Request failed with status ${{ steps.get_latest_release.outputs.status }}" + + - name: Grab latest tag name from API response + id: version + run: | + echo "TAG=${{ fromJson(steps.get_latest_release.outputs.data).tag_name }}" >> "$GITHUB_OUTPUT" + + - name: "DEBUG: Show tag name found in API response" + run: "echo ${{ steps.version.outputs.TAG }}" + + - name: Set source URL and file name + id: source + shell: bash + run: | + if [[ "${{ matrix.download_flavour }}" == "Release assets" ]]; then + echo 'SRC=https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/latest/download/' >> "$GITHUB_OUTPUT" + echo "FILE=${{ matrix.pharfile }}.phar" >> "$GITHUB_OUTPUT" + elif [[ "${{ matrix.download_flavour }}" == "Unversioned web" ]]; then + echo 'SRC=https://phars.phpcodesniffer.com/' >> "$GITHUB_OUTPUT" + echo "FILE=${{ matrix.pharfile }}.phar" >> "$GITHUB_OUTPUT" + else + echo 'SRC=https://phars.phpcodesniffer.com/phars/' >> "$GITHUB_OUTPUT" + echo "FILE=${{ matrix.pharfile }}-${{ steps.version.outputs.TAG }}.phar" >> "$GITHUB_OUTPUT" + fi + + - name: Verify PHAR file is available and download + run: "wget -O ${{ steps.source.outputs.FILE }} ${{ steps.source.outputs.SRC }}${{ steps.source.outputs.FILE }}" + + - name: Verify signature file is available and download + run: "wget -O ${{ steps.source.outputs.FILE }}.asc ${{ steps.source.outputs.SRC }}${{ steps.source.outputs.FILE }}.asc" + + - name: "DEBUG: List files" + run: ls -Rlh + + - name: Verify attestation of the PHAR file + run: gh attestation verify ${{ steps.source.outputs.FILE }} -o PHPCSStandards + env: + GH_TOKEN: ${{ github.token }} + + - name: Download public key + env: + FINGERPRINT: "0x689DAD778FF08760E046228BA978220305CD5C32" + run: gpg --keyserver "hkps://keys.openpgp.org" --recv-keys "$FINGERPRINT" + + - name: Verify signature of the PHAR file + run: gpg --verify ${{ steps.source.outputs.FILE }}.asc ${{ steps.source.outputs.FILE }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 'latest' + ini-values: error_reporting=-1, display_errors=On + coverage: none + + # Note: the `.` is in the command to make it work for both PHPCS as well PHPCBF. + - name: Verify the PHAR is nominally functional + run: php ${{ steps.source.outputs.FILE }} . -e --standard=PSR12 + + - name: Grab the version + id: asset_version + env: + FILE_NAME: ${{ steps.source.outputs.FILE }} + # yamllint disable-line rule:line-length + run: echo "VERSION=$(php "$FILE_NAME" --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+(\.[0-9]+)+')" >> "$GITHUB_OUTPUT" + + - name: "DEBUG: Show grabbed version" + run: echo ${{ steps.asset_version.outputs.VERSION }} + + - name: Fail the build if the PHAR is not the correct version + if: ${{ steps.asset_version.outputs.VERSION != steps.version.outputs.TAG }} + run: exit 1 + + # ######################################### + # Verify install via PHIVE. + # ######################################### + verify-phive: + runs-on: ubuntu-latest + + # Only run this workflow in the context of this repo. + if: github.repository_owner == 'PHPCSStandards' + + strategy: + fail-fast: false + matrix: + pharfile: + - 'phpcs' + - 'phpcbf' + + name: "PHIVE: ${{ matrix.pharfile }}" + + steps: + - name: Retrieve latest release info + uses: octokit/request-action@v2.x + id: get_latest_release + with: + route: GET /repos/PHPCSStandards/PHP_CodeSniffer/releases/latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "DEBUG: Show API request failure status" + if: ${{ failure() }} + run: "echo No release found. Request failed with status ${{ steps.get_latest_release.outputs.status }}" + + - name: Grab latest tag name from API response + id: version + run: | + echo "TAG=${{ fromJson(steps.get_latest_release.outputs.data).tag_name }}" >> "$GITHUB_OUTPUT" + + - name: "DEBUG: Show tag name found in API response" + run: "echo ${{ steps.version.outputs.TAG }}" + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 'latest' + ini-values: error_reporting=-1, display_errors=On + coverage: none + tools: phive + + - name: Install + run: phive install ${{ matrix.pharfile }} --copy --trust-gpg-keys 689DAD778FF08760E046228BA978220305CD5C32 + + - name: "DEBUG: List files" + run: ls -R + + - name: Verify attestation of the PHAR file + run: gh attestation verify ./tools/${{ matrix.pharfile }} -o PHPCSStandards + env: + GH_TOKEN: ${{ github.token }} + + # Note: the `.` is in the command to make it work for both PHPCS as well PHPCBF. + - name: Verify the PHAR is nominally functional + run: php ./tools/${{ matrix.pharfile }} . -e --standard=PSR12 + + - name: Grab the version + id: asset_version + env: + FILE_NAME: ./tools/${{ matrix.pharfile }} + # yamllint disable-line rule:line-length + run: echo "VERSION=$(php "$FILE_NAME" --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+(\.[0-9]+)+')" >> "$GITHUB_OUTPUT" + + - name: "DEBUG: Show grabbed version" + run: echo ${{ steps.asset_version.outputs.VERSION }} + + - name: Fail the build if the PHAR is not the correct version + if: ${{ steps.asset_version.outputs.VERSION != steps.version.outputs.TAG }} + run: exit 1 From 224a57f7cea0bb5ead5edcb429dc725edd806cdb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Dec 2024 21:11:52 +0100 Subject: [PATCH 854/874] Add release checklist I've been using and fine-tuning this release checklist over the past year. As part of the efforts to document the processes and policies for this repo, I'm now publishing the checklist for transparency and to make this knowledge transferable. Note: some of the steps which this list previously included in my local copy have now been automated via the "verify-release" GH Actions workflow. These steps have been removed from this checklist. Fixes 32 --- .github/release-checklist.md | 126 +++++++++++++++++++++++++++++++++++ .remarkrc | 3 +- 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 .github/release-checklist.md diff --git a/.github/release-checklist.md b/.github/release-checklist.md new file mode 100644 index 0000000000..a57baeb50a --- /dev/null +++ b/.github/release-checklist.md @@ -0,0 +1,126 @@ +# Release checklist + +## Before Release + +### General + +- [ ] Verify, and if necessary, update the version constraints for dependencies in the `composer.json` - PR #xxx +- [ ] Verify that any new functions have type declarations (ClassName/array/callable) whenever possible. +- [ ] Verify that the license tags all refer to the _new_ organisation and no longer to Squizlabs. (easily overlooked in new files) +- [ ] Verify that `@copyright` tags in new files use `@copyright 20xx PHPCSStandards and contributors`. + +### Wiki + +- [ ] Fetch changes and check against vandalism. +- [ ] Verify that any new `public` properties are listed on the Customizable Properties page in the Wiki. +- [ ] Verify that any new sniffs which have `public` properties are listed on the Customizable Properties page in the Wiki. +- [ ] Verify that any new CLI options are listed in the Wiki. +- [ ] Verify that any new Reports have a section in the Reports page in the Wiki. + +### Majors only + +- [ ] Move old changelog entries to `CHANGELOG_OLD.md` file. +- [ ] Verify that everything deprecated during the previous major was removed. +- [ ] Update the wiki for any references to anything deprecated/removed. +- [ ] Change `Config::STABILITY` from "dev" to "stable" for the branch for the new major. - PR #xxx + +### Prepare changelog + +- [ ] Prepare changelog for the release and submit the PR. - PR #xxx + - Based on the tickets in the milestone. + - Double-check that any issues which were closed by PRs included in the release, have the milestone set. + - Compare with auto-generated release notes to ensure nothing is missed. + - :pencil2: Remember to add a release link at the bottom! +- [ ] Prepare extra sections for the GH release notes. + - Use "New contributors" list from the auto-generated notes. + - Use the milestone to gather the stats. + - Add sponsor link. + - Remove square brackets from all ticket links or make them proper full links (as GH markdown parser doesn't parse these correctly). + - Change all contributor links to full inline links (as GH markdown parser on the Releases page doesn't parse these correctly). + ```md +--- + +### New Contributors + +The PHP_CodeSniffer project is happy to welcome the following new contributors: +@...., @.... + +### Statistics + +**Closed**: # issues +**Merged**: ## 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](https://opencollective.com/php_codesniffer). If you already do so: thank you! + ``` + +### Milestone + +- [ ] Close the milestone +- [ ] Open a new milestone for the next release +- [ ] If any open PRs/issues which were milestoned for this release did not make it into the release, update their milestone. + + +## Release + +- [ ] Merge the changelog PR. + For now, cherrypick the changelog to the 4.0 branch. +- [ ] Make sure all CI builds for `master` are green. +- [ ] Create a tag for the release & push it. +- [ ] Make sure all CI builds are green. +- [ ] Download the PHAR files from the GH Actions test build page. +- [ ] Sign the PHAR files using: + ```bash + gpg -u my@email.com --detach-sign --output phpcs.phar.asc phpcs.phar + gpg -u my@email.com --detach-sign --output phpcbf.phar.asc phpcbf.phar + gpg -u my@email.com --detach-sign --output phpcs-x.x.x.phar.asc phpcs-x.x.x.phar + gpg -u my@email.com --detach-sign --output phpcbf-x.x.x.phar.asc phpcbf-x.x.x.phar + ``` + - If, for whatever reason, the key is no longer available or has expired: + -> generate a new key following the steps here: . + -> upload the new key following the steps here: . + -> update the key information in the README x 3. + -> update the key info in the verify-release GHA workflow. +- [ ] Get the SHA of the files for the phive.xml file + ```bash + # Linux + sha256sum ./phpcs-x.x.x.phar + sha256sum ./phpcbf-x.x.x.phar + + # Windows + certutil -hashfile ./phpcs-x.x.x.phar SHA256 + certutil -hashfile ./phpcbf-x.x.x.phar SHA256 + ``` +- Update the `gh-pages` branch: + - [ ] Add the new release to the `phive.xml` file. + - [ ] Add the versioned PHAR files + keys in PHAR dir. + - [ ] Add the unversioned PHAR files + keys in root dir. + - [ ] Verify the attestations of the PHAR files. + ```bash + gh attestation verify phpcs.phar -o PHPCSStandards + gh attestation verify phpcbf.phar -o PHPCSStandards + gh attestation verify phars/phpcs-x.x.x.phar -o PHPCSStandards + gh attestation verify phars/phpcbf-x.x.x.phar -o PHPCSStandards + ``` + - [ ] Commit & push the changes. + - [ ] Verify that the website regenerated correctly and that the phars can be downloaded. +- [ ] Create a release & copy & paste the changelog to it. + - [ ] Upload the unversioned PHAR files + asc files to the release. + - [ ] Announce the release in the discussions forum by checking the checkbox at the bottom of the release page. +- [ ] Make sure all CI builds are green, including the verify-release workflow. + + +## After Release + +- [ ] Update the version number in the `Config::VERSION` class constant in the `src/Config.php` file to the _next_ (patch) version. + This can always be adjusted again later if needs be if it is decided that the next version will be a minor/major, but at least for dev + it should clearly show that this is bleeding edge/unreleased. +- [ ] Close release announcement in the "Discussions" for previous minors (leave the announcements related to the current minor open). + + +### Publicize + +- [ ] Post on Mastodon about the release (official account). +- [ ] Post on X about the release (official account). +- [ ] Post on LinkedIn (personal account). diff --git a/.remarkrc b/.remarkrc index 038f7b6287..9c6cbc7b2b 100644 --- a/.remarkrc +++ b/.remarkrc @@ -13,7 +13,8 @@ { "skipUrlPatterns": [ "^https?://github\\.com/PHPCSStandards/PHP_CodeSniffer/compare/[0-9\\.]+?\\.{3}[0-9\\.]+", - "^https?://github\\.com/[A-Za-z0-9-]+" + "^https?://github\\.com/[A-Za-z0-9-]+", + "^https?://x\\.com/PHP_CodeSniffer" ] } ], From 644fc294d76540049f569cb8174f958d4c1c3c39 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 16 Nov 2024 13:05:28 +0100 Subject: [PATCH 855/874] Changelog for the 3.11.2 release For release this Wednesday (or earlier). --- CHANGELOG.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a4ba6aedf..4f05515907 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,61 @@ The file documents changes to the PHP_CodeSniffer project. _Nothing yet._ +## [3.11.2] - 2024-12-11 + +### 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][@jrfnl] for the patch. +- Generators/HTML: only display a Table of Contents when there is more than one sniff with documentation. [#697] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Generators/HTML: improved handling of line breaks in `` blocks. [#723] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Generators/Markdown: improved compatibility with the variety of available markdown parsers. [#722] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Generators/Markdown: improved handling of line breaks in `` blocks. [#737] + - This prevents additional paragraphs from being displayed as code blocks. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Generic.NamingConventions.UpperCaseConstantName: the exact token containing the non-uppercase constant name will now be identified with more accuracy. [#665] + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Generic.Functions.OpeningFunctionBraceKernighanRitchie: minor improvement to the error message wording. [#736] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Various housekeeping, including improvements to the tests and documentation. + - Thanks to [Rodrigo Primo][@rodrigoprimo] and [Juliette Reinders Folmer][@jrfnl] for their contributions. + +### Fixed +- Fixed bug [#527] : Squiz.Arrays.ArrayDeclaration: short lists within a foreach condition should be ignored. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Fixed bug [#665] : Generic.NamingConventions.UpperCaseConstantName: false positives and false negatives when code uses unconventional spacing and comments when calling `define()`. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Fixed bug [#665] : Generic.NamingConventions.UpperCaseConstantName: false positive when a constant named `DEFINE` is encountered. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Fixed bug [#665] : Generic.NamingConventions.UpperCaseConstantName: false positive for attribute class called `define`. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Fixed bug [#665] : Generic.NamingConventions.UpperCaseConstantName: false positive when handling the instantiation of a class named `define`. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Fixed bug [#688] : Generators/Markdown could leave error_reporting in an incorrect state. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Fixed bug [#698] : Generators/Markdown : link in the documentation footer would not parse as a link. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Fixed bug [#738] : Generators/Text: stray blank lines after code sample titles. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Fixed bug [#739] : Generators/HTML + Markdown: multi-space whitespace within a code sample title was folded into a single space. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. + +[#527]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/527 +[#665]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/665 +[#687]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/687 +[#688]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/688 +[#697]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/697 +[#698]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/698 +[#722]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/722 +[#723]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/723 +[#736]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/736 +[#737]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/737 +[#738]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/738 +[#739]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/739 + ## [3.11.1] - 2024-11-16 ### Changed @@ -337,7 +392,7 @@ _Nothing yet._ - Squiz.WhiteSpace.MemberVarSpacing - Squiz.WhiteSpace.ScopeClosingBrace - Squiz.WhiteSpace.SuperfluousWhitespace - - Thanks to [Jay McPartland][@jonmcp] and [Rodrigo Primo][@rodrigoprimo] for the patches. + - Thanks to [Jay McPartland][@jaymcp] and [Rodrigo Primo][@rodrigoprimo] for the patches. ### Changed - The following sniffs have received performance related improvements: @@ -350,7 +405,7 @@ _Nothing yet._ - External standards with sniff tests using the PHP_CodeSniffer native test framework will also benefit from these changes. - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. - Various housekeeping, including improvements to the tests and documentation. - - Thanks to [Jay McPartland][@jonmcp], [João Pedro Oliveira][@jpoliveira08], [Rodrigo Primo][@rodrigoprimo] and [Juliette Reinders Folmer][@jrfnl] for their contributions. + - Thanks to [Jay McPartland][@jaymcp], [João Pedro Oliveira][@jpoliveira08], [Rodrigo Primo][@rodrigoprimo] and [Juliette Reinders Folmer][@jrfnl] for their contributions. ### Fixed - Fixed bug [#289] : Squiz.WhiteSpace.OperatorSpacing and PSR12.Operators.OperatorSpacing : improved fixer conflict protection by more strenuously avoiding handling operators in declare statements. @@ -7152,6 +7207,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo --> [Unreleased]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/master...HEAD +[3.11.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.11.1...3.11.2 [3.11.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.11.0...3.11.1 [3.11.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.10.3...3.11.0 [3.10.3]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.10.2...3.10.3 @@ -7350,6 +7406,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@ivuorinen]: https://github.com/ivuorinen [@jasonmccreary]: https://github.com/jasonmccreary [@javer]: https://github.com/javer +[@jaymcp]: https://github.com/jaymcp [@JDGrimes]: https://github.com/JDGrimes [@jedgell]: https://github.com/jedgell [@jeffslofish]: https://github.com/jeffslofish @@ -7360,7 +7417,6 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@johanderuijter]: https://github.com/johanderuijter [@johnmaguire]: https://github.com/johnmaguire [@johnpbloch]: https://github.com/johnpbloch -[@jonmcp]: https://github.com/jonmcp [@JorisDebonnet]: https://github.com/JorisDebonnet [@josephzidell]: https://github.com/josephzidell [@joshdavis11]: https://github.com/joshdavis11 From 855f26176ae5bb2681c797a6cc22fa0124e06d90 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 11 Dec 2024 18:17:42 +0100 Subject: [PATCH 856/874] Config: update version nr to next --- src/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index dda15a5553..2bcc78e6ec 100644 --- a/src/Config.php +++ b/src/Config.php @@ -85,7 +85,7 @@ class Config * * @var string */ - const VERSION = '3.11.2'; + const VERSION = '3.11.3'; /** * Package stability; either stable, beta or alpha. From 98a0c4e47afc1d442700cce8b69f2edc30ceff9a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 12 Dec 2024 09:04:31 +0100 Subject: [PATCH 857/874] GH Actions/verify-release: show output for release attestations Apparently, by default, the GH CLI doesn't show any output when run from a GH Actions step. This can be confusing and it makes debugging the workflow harder as, in case of failure, it is unclear what the step failed on. The `GH_FORCE_TTY` environment variable (set to any value) should enable the normal output for the GH CLI command, which should fix this. Refs: * https://github.com/cli/cli/issues/10047 * https://cli.github.com/manual/gh_help_environment --- .github/workflows/verify-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/verify-release.yml b/.github/workflows/verify-release.yml index 99f611526a..7dcfac8fda 100644 --- a/.github/workflows/verify-release.yml +++ b/.github/workflows/verify-release.yml @@ -92,6 +92,7 @@ jobs: run: gh attestation verify ${{ steps.source.outputs.FILE }} -o PHPCSStandards env: GH_TOKEN: ${{ github.token }} + GH_FORCE_TTY: true - name: Download public key env: @@ -183,6 +184,7 @@ jobs: run: gh attestation verify ./tools/${{ matrix.pharfile }} -o PHPCSStandards env: GH_TOKEN: ${{ github.token }} + GH_FORCE_TTY: true # Note: the `.` is in the command to make it work for both PHPCS as well PHPCBF. - name: Verify the PHAR is nominally functional From d7ecf7e051f125021447a1e5716739fa196ea9a2 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 20 Nov 2024 08:43:16 +0100 Subject: [PATCH 858/874] Ruleset::registerSniffs(): add tests --- tests/Core/Ruleset/RegisterSniffsTest.php | 293 ++++++++++++++++++++++ 1 file changed, 293 insertions(+) create mode 100644 tests/Core/Ruleset/RegisterSniffsTest.php diff --git a/tests/Core/Ruleset/RegisterSniffsTest.php b/tests/Core/Ruleset/RegisterSniffsTest.php new file mode 100644 index 0000000000..706d6b8b5b --- /dev/null +++ b/tests/Core/Ruleset/RegisterSniffsTest.php @@ -0,0 +1,293 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHPUnit\Framework\TestCase; + +/** + * Test the Ruleset::registerSniffs() method. + * + * @covers \PHP_CodeSniffer\Ruleset::registerSniffs + */ +final class RegisterSniffsTest extends TestCase +{ + + /** + * The Ruleset object. + * + * @var \PHP_CodeSniffer\Ruleset + */ + private static $ruleset; + + /** + * Original value of the $sniffs property on the Ruleset. + * + * @var array + */ + private static $originalSniffs = []; + + /** + * List of Standards dir relative sniff files loaded for the PSR1 standard. + * + * @var array + */ + private static $psr1SniffFiles = [ + 'Generic/Sniffs/Files/ByteOrderMarkSniff.php', + 'Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php', + 'Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php', + 'Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php', + 'PSR1/Sniffs/Classes/ClassDeclarationSniff.php', + 'PSR1/Sniffs/Files/SideEffectsSniff.php', + 'PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php', + 'Squiz/Sniffs/Classes/ValidClassNameSniff.php', + ]; + + /** + * Absolute paths to the sniff files loaded for the PSR1 standard. + * + * @var array + */ + private static $psr1SniffAbsolutePaths = []; + + + /** + * Initialize the config and ruleset objects which will be used for some of these tests. + * + * @beforeClass + * + * @return void + */ + public static function initializeConfigAndRuleset() + { + // Set up the ruleset. + $config = new ConfigDouble(['--standard=PSR1']); + self::$ruleset = new Ruleset($config); + + // Remember the original value of the Ruleset::$sniff property as the tests adjust it. + self::$originalSniffs = self::$ruleset->sniffs; + + // Sort the value to make the tests stable as different OSes will read directories + // in a different order and the order is not relevant for these tests. Just the values. + ksort(self::$originalSniffs); + + // Update the sniff file list. + $standardsDir = dirname(dirname(dirname(__DIR__))).DIRECTORY_SEPARATOR; + $standardsDir .= 'src'.DIRECTORY_SEPARATOR.'Standards'.DIRECTORY_SEPARATOR; + + self::$psr1SniffAbsolutePaths = self::relativeToAbsoluteSniffFiles($standardsDir, self::$psr1SniffFiles); + + }//end initializeConfigAndRuleset() + + + /** + * Convert relative paths to absolute paths and ensure the paths use the correct OS-specific directory separator. + * + * @param string $baseDir Directory to which these paths are relative to. Including trailing slash. + * @param array $relativePaths Relative paths. + * + * @return array + */ + public static function relativeToAbsoluteSniffFiles($baseDir, $relativePaths) + { + $fileList = []; + foreach ($relativePaths as $sniffName) { + $sniffFile = str_replace('/', DIRECTORY_SEPARATOR, $sniffName); + $sniffFile = $baseDir.$sniffFile; + $fileList[] = $sniffFile; + } + + return $fileList; + + }//end relativeToAbsoluteSniffFiles() + + + /** + * Clear out the Ruleset::$sniffs property. + * + * @before + * + * @return void + */ + protected function clearOutSniffs() + { + // Clear out the Ruleset::$sniffs property. + self::$ruleset->sniffs = []; + + }//end clearOutSniffs() + + + /** + * Test that registering sniffs works as expected (simple base test case). + * + * @return void + */ + public function testRegisteredSniffsShouldBeTheSame() + { + self::$ruleset->registerSniffs(self::$psr1SniffAbsolutePaths, [], []); + + // Make sure the same sniff list was recreated (but without the objects having been created yet). + $this->assertSame(array_keys(self::$originalSniffs), array_keys(self::$ruleset->sniffs)); + $this->assertSame(array_keys(self::$originalSniffs), array_values(self::$ruleset->sniffs)); + + }//end testRegisteredSniffsShouldBeTheSame() + + + /** + * Test that if only specific sniffs are requested, only those are registered. + * + * {@internal Can't test this via the CLI arguments due to some code in the Ruleset class + * related to sniff tests.} + * + * @return void + */ + public function testRegisteredSniffsWithRestrictions() + { + $restrictions = [ + 'psr1\\sniffs\\classes\\classdeclarationsniff' => true, + 'psr1\\sniffs\\files\\sideeffectssniff' => true, + 'psr1\\sniffs\\methods\\camelcapsmethodnamesniff' => true, + ]; + + $expected = [ + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Classes\\ClassDeclarationSniff', + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Files\\SideEffectsSniff', + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Methods\\CamelCapsMethodNameSniff', + ]; + + self::$ruleset->registerSniffs(self::$psr1SniffAbsolutePaths, $restrictions, []); + + $this->assertSame($expected, array_keys(self::$ruleset->sniffs)); + + }//end testRegisteredSniffsWithRestrictions() + + + /** + * Test that sniffs excluded via the CLI are not registered. + * + * @return void + */ + public function testRegisteredSniffsWithExclusions() + { + // Set up the ruleset. + $args = [ + '--standard=PSR1', + '--exclude=PSR1.Classes.ClassDeclaration,PSR1.Files.SideEffects,PSR1.Methods.CamelCapsMethodName', + ]; + $config = new ConfigDouble($args); + $ruleset = new Ruleset($config); + + $expected = [ + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\ByteOrderMarkSniff', + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff', + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowAlternativePHPTagsSniff', + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowShortOpenTagSniff', + 'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\Classes\\ValidClassNameSniff', + ]; + + $actual = array_keys($ruleset->sniffs); + sort($actual); + + $this->assertSame($expected, $actual); + + }//end testRegisteredSniffsWithExclusions() + + + /** + * Test combining requesting specific sniffs and excluding a subset of those. + * + * @return void + */ + public function testRegisteredSniffsBothRestrictionsAndExclusions() + { + $restrictions = [ + 'generic\\sniffs\\namingconventions\\uppercaseconstantnamesniff' => true, + 'generic\\sniffs\\php\\disallowalternativephptagssniff' => true, + 'generic\\sniffs\\php\\disallowshortopentagsniff' => true, + 'psr1\\sniffs\\classes\\classdeclarationsniff' => true, + 'squiz\\sniffs\\classes\\validclassnamesniff' => true, + ]; + + $exclusions = [ + 'squiz\\sniffs\\classes\\validclassnamesniff' => true, + 'generic\\sniffs\\php\\disallowalternativephptagssniff' => true, + 'generic\\sniffs\\namingconventions\\uppercaseconstantnamesniff' => true, + ]; + + $expected = [ + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowShortOpenTagSniff', + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Classes\\ClassDeclarationSniff', + ]; + + self::$ruleset->registerSniffs(self::$psr1SniffAbsolutePaths, $restrictions, $exclusions); + + $this->assertEquals($expected, array_keys(self::$ruleset->sniffs)); + + }//end testRegisteredSniffsBothRestrictionsAndExclusions() + + + /** + * Verify that abstract sniffs are filtered out and not registered. + * + * @return void + */ + public function testRegisterSniffsFiltersOutAbstractClasses() + { + $extraPathsBaseDir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR; + $extraPaths = [ + 'DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/AbstractSniff.php', + 'DirectoryExpansion/.hiddenAbove/src/MyStandard/Sniffs/CategoryB/AnotherAbstractSniff.php', + ]; + $extraPaths = self::relativeToAbsoluteSniffFiles($extraPathsBaseDir, $extraPaths); + + $fileList = self::$psr1SniffAbsolutePaths; + foreach ($extraPaths as $path) { + $fileList[] = $path; + } + + self::$ruleset->registerSniffs($fileList, [], []); + + // Make sure the same sniff list was recreated (but without the objects having been created yet). + $this->assertSame(array_keys(self::$originalSniffs), array_keys(self::$ruleset->sniffs)); + $this->assertSame(array_keys(self::$originalSniffs), array_values(self::$ruleset->sniffs)); + + }//end testRegisterSniffsFiltersOutAbstractClasses() + + + /** + * Test that sniff files not in a "/Sniffs/" directory are filtered out and not registered. + * + * @return void + */ + public function testRegisteredSniffsFiltersOutFilePathsWithoutSniffsDir() + { + $extraPathsBaseDir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR; + $extraPaths = [ + 'DirectoryExpansion/.hiddenAbove/src/MyStandard/Utils/NotInSniffsDirSniff.php', + 'DirectoryExpansion/.hiddenAbove/src/MyStandard/Utils/SubDir/NotInSniffsDirSniff.php', + ]; + $extraPaths = self::relativeToAbsoluteSniffFiles($extraPathsBaseDir, $extraPaths); + + $fileList = self::$psr1SniffAbsolutePaths; + foreach ($extraPaths as $path) { + $fileList[] = $path; + } + + self::$ruleset->registerSniffs($fileList, [], []); + + // Make sure the same sniff list was recreated (but without the objects having been created yet). + $this->assertSame(array_keys(self::$originalSniffs), array_keys(self::$ruleset->sniffs)); + $this->assertSame(array_keys(self::$originalSniffs), array_values(self::$ruleset->sniffs)); + + }//end testRegisteredSniffsFiltersOutFilePathsWithoutSniffsDir() + + +}//end class From d6bbff928ca3228e43e3755f797cbd128a6ccb77 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 24 Oct 2024 23:18:46 +0200 Subject: [PATCH 859/874] Tokenizer/PHP: add extra tests for DNF type tokenization Tests taken from https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/630#issuecomment-2418664762 Props michalbundyra --- tests/Core/Tokenizers/PHP/DNFTypesTest.inc | 44 ++++++++- tests/Core/Tokenizers/PHP/DNFTypesTest.php | 106 +++++++++++++++------ 2 files changed, 121 insertions(+), 29 deletions(-) diff --git a/tests/Core/Tokenizers/PHP/DNFTypesTest.inc b/tests/Core/Tokenizers/PHP/DNFTypesTest.inc index 5043ab7db5..cd27474eb2 100644 --- a/tests/Core/Tokenizers/PHP/DNFTypesTest.inc +++ b/tests/Core/Tokenizers/PHP/DNFTypesTest.inc @@ -13,6 +13,12 @@ $a = $var ? $something : CONST_C | ( CONST_A & CONST_B ); /* testParensNoOwnerInShortTernary */ $a = $var ?: ( CONST_A & CONST_B ); +/* testFnCallParensNoOwnerInTernaryA */ +$var1 ? \X\call8() : /* testFnCallParensNoOwnerInTernaryB */ \Y\call9(); + +/* testPFnCallarensNoOwnerInShortTernary */ +$var2 ?: \Z\call10(); + /* testParensOwnerFunctionAmpersandInDefaultValue */ function defaultValueLooksLikeDNF( mixed $param = (CONST_A&CONST_B) ) {} @@ -53,6 +59,20 @@ callMe(label: CONST_A | CONST_B); /* testParensNoOwnerFunctionCallWithDNFLookALikeNamedParamIntersect */ callMe(label: CONST_A & CONST_B); +\Z1\call11( + /* testParensNoOwnerFunctionCallInNamedParam */ + param1: \Z2\call12(), + /* testParensOwnerArrowFunctionInNamedParam */ + param2: fn (): /* testDNFTypeArrowFnReturnInNamedParam */ int|(\Countable&\Iterable) + /* testParensNoOwnerFunctionCallInArrowFnReturn */ + => \Z3\call13(), + /* testParensOwnerClosureInNamedParam */ + param3: function (): /* testDNFTypeClosureReturnInNamedParam */ int|(\DateTime&\ArrayObject) { + /* testParensNoOwnerFunctionCallInClosureReturn */ + return \Z4\call14(); + }, +); + /* testSwitchControlStructureCondition */ switch (CONST_A | CONST_B) { /* testFunctionCallInSwitchCaseCondition */ @@ -70,17 +90,37 @@ switch (CONST_A | CONST_B) { /* testIfAlternativeSyntaxCondition */ if (true): /* testFunctionCallInIfBody */ - \B\call(); + \B\call(); /* testElseIfAlternativeSyntaxCondition */ elseif (10): /* testFunctionCallInElseIfBody */ - C\call(); + C\call(); +else: + /* testFunctionCallInElseBody */ + \C\call3(); endif; gotolabel: /* testFunctionCallInGotoBody */ \doSomething(); +/* testWhileAlternativeSyntaxCondition */ +while ($c3): + /* testFunctionCallInWhileBody */ + \D\call4(); +endwhile; + +/* testForAlternativeSyntaxCondition */ +for ($i = 0; $i < 10; $i++): + /* testFunctionCallInForBody */ + \F\call5(); +endfor; + +/* testForEachAlternativeSyntaxCondition */ +foreach ($array as $key => $value): + /* testFunctionCallInForeachBody */ + \G\call6(); +endforeach; /* * DNF parentheses. diff --git a/tests/Core/Tokenizers/PHP/DNFTypesTest.php b/tests/Core/Tokenizers/PHP/DNFTypesTest.php index 75e1b1dbdc..e72dd41596 100644 --- a/tests/Core/Tokenizers/PHP/DNFTypesTest.php +++ b/tests/Core/Tokenizers/PHP/DNFTypesTest.php @@ -113,6 +113,15 @@ public static function dataNormalParentheses() 'parens without owner in short ternary' => [ 'testMarker' => '/* testParensNoOwnerInShortTernary */', ], + 'parens without owner in ternary then (fn call in inline then)' => [ + 'testMarker' => '/* testFnCallParensNoOwnerInTernaryA */', + ], + 'parens without owner in ternary then (fn call in inline else)' => [ + 'testMarker' => '/* testFnCallParensNoOwnerInTernaryB */', + ], + 'parens without owner in short ternary (fn call)' => [ + 'testMarker' => '/* testPFnCallarensNoOwnerInShortTernary */', + ], 'parens with owner: function; & in default value' => [ 'testMarker' => '/* testParensOwnerFunctionAmpersandInDefaultValue */', ], @@ -158,6 +167,69 @@ public static function dataNormalParentheses() 'parens without owner, function call, named param + bitwise and' => [ 'testMarker' => '/* testParensNoOwnerFunctionCallWithDNFLookALikeNamedParamIntersect */', ], + 'parens without owner, function call in named param' => [ + 'testMarker' => '/* testParensNoOwnerFunctionCallInNamedParam */', + ], + 'parens with owner: fn; in named param' => [ + 'testMarker' => '/* testParensOwnerArrowFunctionInNamedParam */', + ], + 'parens without owner, function call in named param arrow return' => [ + 'testMarker' => '/* testParensNoOwnerFunctionCallInArrowFnReturn */', + ], + 'parens with owner: closure; in named param' => [ + 'testMarker' => '/* testParensOwnerClosureInNamedParam */', + ], + 'parens without owner, function call, named param closure return' => [ + 'testMarker' => '/* testParensNoOwnerFunctionCallInClosureReturn */', + ], + 'parens with owner: switch condition' => [ + 'testMarker' => '/* testSwitchControlStructureCondition */', + ], + 'parens without owner in switch-case condition' => [ + 'testMarker' => '/* testFunctionCallInSwitchCaseCondition */', + ], + 'parens without owner in switch-case body' => [ + 'testMarker' => '/* testFunctionCallInSwitchCaseBody */', + ], + 'parens without owner in switch-default body' => [ + 'testMarker' => '/* testFunctionCallInSwitchDefaultBody */', + ], + 'parens with owner: if condition, alternative syntax' => [ + 'testMarker' => '/* testIfAlternativeSyntaxCondition */', + ], + 'parens without owner in if body, alternative syntax' => [ + 'testMarker' => '/* testFunctionCallInIfBody */', + ], + 'parens with owner: elseif condition, alternative syntax' => [ + 'testMarker' => '/* testElseIfAlternativeSyntaxCondition */', + ], + 'parens without owner in elseif body, alternative syntax' => [ + 'testMarker' => '/* testFunctionCallInElseIfBody */', + ], + 'parens without owner in else body, alternative syntax' => [ + 'testMarker' => '/* testFunctionCallInElseBody */', + ], + 'parens without owner in goto body' => [ + 'testMarker' => '/* testFunctionCallInGotoBody */', + ], + 'parens with owner: while condition, alternative syntax' => [ + 'testMarker' => '/* testWhileAlternativeSyntaxCondition */', + ], + 'parens without owner in while body, alternative syntax' => [ + 'testMarker' => '/* testFunctionCallInWhileBody */', + ], + 'parens with owner: for condition, alternative syntax' => [ + 'testMarker' => '/* testForAlternativeSyntaxCondition */', + ], + 'parens without owner in for body, alternative syntax' => [ + 'testMarker' => '/* testFunctionCallInForBody */', + ], + 'parens with owner: foreach condition, alternative syntax' => [ + 'testMarker' => '/* testForEachAlternativeSyntaxCondition */', + ], + 'parens without owner in foreach body, alternative syntax' => [ + 'testMarker' => '/* testFunctionCallInForeachBody */', + ], 'parens without owner in OO const default value' => [ 'testMarker' => '/* testParensNoOwnerOOConstDefaultValue */', @@ -193,33 +265,6 @@ public static function dataNormalParentheses() 'parens without owner in arrow function return expression' => [ 'testMarker' => '/* testParensNoOwnerInArrowReturnExpression */', ], - 'parens with owner: switch condition' => [ - 'testMarker' => '/* testSwitchControlStructureCondition */', - ], - 'parens without owner in switch-case condition' => [ - 'testMarker' => '/* testFunctionCallInSwitchCaseCondition */', - ], - 'parens without owner in switch-case body' => [ - 'testMarker' => '/* testFunctionCallInSwitchCaseBody */', - ], - 'parens without owner in switch-default body' => [ - 'testMarker' => '/* testFunctionCallInSwitchDefaultBody */', - ], - 'parens with owner: if condition, alternative syntax' => [ - 'testMarker' => '/* testIfAlternativeSyntaxCondition */', - ], - 'parens without owner in if body, alternative syntax' => [ - 'testMarker' => '/* testFunctionCallInIfBody */', - ], - 'parens with owner: elseif condition, alternative syntax' => [ - 'testMarker' => '/* testElseIfAlternativeSyntaxCondition */', - ], - 'parens without owner in elseif body, alternative syntax' => [ - 'testMarker' => '/* testFunctionCallInElseIfBody */', - ], - 'parens without owner in goto body' => [ - 'testMarker' => '/* testFunctionCallInGotoBody */', - ], ]; }//end dataNormalParentheses() @@ -340,6 +385,13 @@ public function testDNFTypeParentheses($testMarker) public static function dataDNFTypeParentheses() { return [ + 'arrow function return type: in named parameter' => [ + 'testMarker' => '/* testDNFTypeArrowFnReturnInNamedParam */', + ], + 'closure return type: in named parameter' => [ + 'testMarker' => '/* testDNFTypeClosureReturnInNamedParam */', + ], + 'OO const type: unqualified classes' => [ 'testMarker' => '/* testDNFTypeOOConstUnqualifiedClasses */', ], From 3d14d004265ac6e38f3e161316cf51b7b4812414 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 12 Dec 2024 17:43:01 -0300 Subject: [PATCH 860/874] Config: add tests for the `--generator=` argument (#765) --- tests/Core/Config/GeneratorArgTest.php | 79 ++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 tests/Core/Config/GeneratorArgTest.php diff --git a/tests/Core/Config/GeneratorArgTest.php b/tests/Core/Config/GeneratorArgTest.php new file mode 100644 index 0000000000..f0b52db157 --- /dev/null +++ b/tests/Core/Config/GeneratorArgTest.php @@ -0,0 +1,79 @@ +assertSame($generatorName, $config->generator); + + }//end testGenerators() + + + /** + * Data provider for testGenerators(). + * + * @see self::testGenerators() + * + * @return array> + */ + public static function dataGeneratorNames() + { + return [ + ['Text'], + ['HTML'], + ['Markdown'], + ]; + + }//end dataGeneratorNames() + + + /** + * Ensure that only the first argument is processed and others are ignored. + * + * @return void + */ + public function testOnlySetOnce() + { + $config = new ConfigDouble( + [ + '--generator=Text', + '--generator=HTML', + '--generator=InvalidGenerator', + ] + ); + + $this->assertSame('Text', $config->generator); + + }//end testOnlySetOnce() + + +}//end class From 142ad8efa14994d82947464e10c94319e61d0feb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 14 Dec 2024 12:23:14 +0100 Subject: [PATCH 861/874] Ruleset::__construct(): add tests --- .../Core/Ruleset/ConstructorNoSniffsTest.xml | 6 + tests/Core/Ruleset/ConstructorTest.php | 293 ++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 tests/Core/Ruleset/ConstructorNoSniffsTest.xml create mode 100644 tests/Core/Ruleset/ConstructorTest.php diff --git a/tests/Core/Ruleset/ConstructorNoSniffsTest.xml b/tests/Core/Ruleset/ConstructorNoSniffsTest.xml new file mode 100644 index 0000000000..77ae02580b --- /dev/null +++ b/tests/Core/Ruleset/ConstructorNoSniffsTest.xml @@ -0,0 +1,6 @@ + + + + . + + diff --git a/tests/Core/Ruleset/ConstructorTest.php b/tests/Core/Ruleset/ConstructorTest.php new file mode 100644 index 0000000000..a0b3ab3088 --- /dev/null +++ b/tests/Core/Ruleset/ConstructorTest.php @@ -0,0 +1,293 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Autoload; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; + +/** + * Test various aspects of the Ruleset::__construct() method not covered via other tests. + * + * @covers \PHP_CodeSniffer\Ruleset::__construct + */ +final class ConstructorTest extends AbstractRulesetTestCase +{ + + + /** + * Test setting the ruleset name. + * + * @param array $cliArgs The CLI args to pass to the Config. + * @param string $expected The expected set ruleset name. + * + * @dataProvider dataHandlingStandardsPassedViaCLI + * + * @return void + */ + public function testHandlingStandardsPassedViaCLI($cliArgs, $expected) + { + $config = new ConfigDouble($cliArgs); + $ruleset = new Ruleset($config); + + $this->assertSame($expected, $ruleset->name); + + }//end testHandlingStandardsPassedViaCLI() + + + /** + * Data provider. + * + * @see testHandlingStandardsPassedViaCLI() + * + * @return array>> + */ + public static function dataHandlingStandardsPassedViaCLI() + { + return [ + 'Single standard passed' => [ + 'cliArgs' => ['--standard=PSR1'], + 'expected' => 'PSR1', + ], + 'Multiple standards passed' => [ + 'cliArgs' => ['--standard=PSR1,Zend'], + 'expected' => 'PSR1, Zend', + ], + 'Absolute path to standard directory passed' => [ + 'cliArgs' => [ + '--standard='.__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'TestStandard', + // Limit this to a valid sniff to prevent running into error messages unrelated to what + // is being tested here. + '--sniffs=TestStandard.ValidSniffs.RegisterEmptyArray', + ], + 'expected' => 'TestStandard', + ], + ]; + + }//end dataHandlingStandardsPassedViaCLI() + + + /** + * Verify that standards are registered with the Autoloader. + * + * @param array $cliArgs The CLI args to pass to the Config. + * @param array $expected Minimum set of standards expected to be registered with the autoloader. + * + * @dataProvider dataStandardsAreRegisteredWithAutoloader + * + * @return void + */ + public function testStandardsAreRegisteredWithAutoloader($cliArgs, $expected) + { + $config = new ConfigDouble($cliArgs); + new Ruleset($config); + + $autoloadPaths = Autoload::getSearchPaths(); + + // Note: doing a full comparison of the Autoloader registered standards would make this test unstable + // as the `CodeSniffer.conf` of the user running the tests could interfer if they have additional + // external standards registered. + // Also note that `--runtime-set` is being used to set `installed_paths` to prevent making any changes to + // the `CodeSniffer.conf` file of the user running the tests. + foreach ($expected as $path => $namespacedStandardName) { + $this->assertArrayHasKey($path, $autoloadPaths, "Path $path has not been registered with the autoloader"); + $this->assertSame($namespacedStandardName, $autoloadPaths[$path], 'Expected (namespaced) standard name does not match'); + } + + }//end testStandardsAreRegisteredWithAutoloader() + + + /** + * Data provider. + * + * @see testStandardsAreRegisteredWithAutoloader() + * + * @return array>> + */ + public static function dataStandardsAreRegisteredWithAutoloader() + { + $basePath = dirname(dirname(dirname(__DIR__))).DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'Standards'.DIRECTORY_SEPARATOR; + $defaultPaths = [ + $basePath.'MySource' => 'MySource', + $basePath.'PEAR' => 'PEAR', + $basePath.'PSR1' => 'PSR1', + $basePath.'PSR12' => 'PSR12', + $basePath.'PSR2' => 'PSR2', + $basePath.'Squiz' => 'Squiz', + $basePath.'Zend' => 'Zend', + ]; + + $data = [ + 'Default standards' => [ + 'cliArgs' => [ + '--standard=PSR1', + '--runtime-set installed_paths .', + ], + 'expected' => $defaultPaths, + ], + ]; + + $extraInstalledPath = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'DirectoryExpansion'; + $extraInstalledPath .= DIRECTORY_SEPARATOR.'.hiddenAbove'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'MyStandard'; + $data['Additional non-namespaced standard'] = [ + 'cliArgs' => [ + '--standard=MyStandard', + '--runtime-set', + 'installed_paths', + $extraInstalledPath, + ], + 'expected' => ($defaultPaths + [$extraInstalledPath => 'MyStandard']), + ]; + + $extraInstalledPath = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'TestStandard'; + $data['Additional namespaced standard'] = [ + 'cliArgs' => [ + '--standard=TestStandard', + '--runtime-set', + 'installed_paths', + $extraInstalledPath, + // Limit this to a valid sniff to prevent running into error messages unrelated to what + // is being tested here. + '--sniffs=TestStandard.ValidSniffs.RegisterEmptyArray', + ], + 'expected' => ($defaultPaths + [$extraInstalledPath => 'Fixtures\TestStandard']), + ]; + + return $data; + + }//end dataStandardsAreRegisteredWithAutoloader() + + + /** + * Verify handling of sniff restrictions in combination with the caching setting. + * + * @param array $cliArgs The CLI args to pass to the Config. + * @param bool $cache Whether to turn the cache on or off. + * @param array $expected Sniffs which are expected to have been registered. + * + * @dataProvider dataCachingVersusRestrictions + * + * @return void + */ + public function testCachingVersusRestrictions($cliArgs, $cache, $expected) + { + $config = new ConfigDouble($cliArgs); + + // Overrule the cache setting (which is being ignored in the Config when the tests are running). + $config->cache = $cache; + + $ruleset = new Ruleset($config); + + $actual = array_keys($ruleset->sniffs); + sort($actual); + + $this->assertSame($expected, $actual); + + }//end testCachingVersusRestrictions() + + + /** + * Data provider. + * + * Note: the test cases only use `--exclude` to restrict, + * + * @see testCachingVersusRestrictions() + * + * @return array>> + */ + public static function dataCachingVersusRestrictions() + { + $completeSet = [ + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\ByteOrderMarkSniff', + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff', + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowAlternativePHPTagsSniff', + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowShortOpenTagSniff', + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Classes\\ClassDeclarationSniff', + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Files\\SideEffectsSniff', + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Methods\\CamelCapsMethodNameSniff', + 'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\Classes\\ValidClassNameSniff', + ]; + + return [ + 'No restrictions, cache off' => [ + 'cliArgs' => ['--standard=PSR1'], + 'cache' => false, + 'expected' => $completeSet, + ], + 'Has exclusions, cache off' => [ + 'cliArgs' => [ + '--standard=PSR1', + '--exclude=Generic.Files.ByteOrderMark,Generic.PHP.DisallowShortOpenTag,PSR1.Files.SideEffects,Generic.PHP.DisallowAlternativePHPTags', + ], + 'cache' => false, + 'expected' => [ + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff', + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Classes\\ClassDeclarationSniff', + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Methods\\CamelCapsMethodNameSniff', + 'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\Classes\\ValidClassNameSniff', + ], + ], + 'Has sniff selection, cache off' => [ + 'cliArgs' => [ + '--standard=PSR1', + '--sniffs=Generic.Files.ByteOrderMark,Generic.PHP.DisallowShortOpenTag,PSR1.Files.SideEffects,Generic.PHP.DisallowAlternativePHPTags', + ], + 'cache' => false, + 'expected' => [ + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\ByteOrderMarkSniff', + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowAlternativePHPTagsSniff', + 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\DisallowShortOpenTagSniff', + 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Files\\SideEffectsSniff', + ], + ], + 'No restrictions, cache on' => [ + 'cliArgs' => ['--standard=PSR1'], + 'cache' => true, + 'expected' => $completeSet, + ], + 'Has exclusions, cache on' => [ + 'cliArgs' => [ + '--standard=PSR1', + '--exclude=Generic.Files.ByteOrderMark,Generic.PHP.DisallowAlternativePHPTags,Generic.PHP.DisallowShortOpenTag,PSR1.Files.SideEffects', + ], + 'cache' => true, + 'expected' => $completeSet, + ], + + /* + * "Has sniff selection, cache on" case cannot be tested due to the `Ruleset` class + * containing special handling of sniff selection when the tests are running. + */ + + ]; + + }//end dataCachingVersusRestrictions() + + + /** + * Test an exception is thrown when no sniffs have been registered via the ruleset. + * + * @return void + */ + public function testNoSniffsRegisteredException() + { + $standard = __DIR__.'/ConstructorNoSniffsTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + + $message = 'No sniffs were registered'; + $this->expectRuntimeExceptionMessage($message); + + new Ruleset($config); + + }//end testNoSniffsRegisteredException() + + +}//end class From 46b9a59532e2e2b4be04b884e075feaf8c470f2f Mon Sep 17 00:00:00 2001 From: Juliette <663378+jrfnl@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:28:17 +0100 Subject: [PATCH 862/874] Ruleset::populateTokenListeners(): add tests (#757) --- tests/Core/Ruleset/ExplainTest.php | 7 +- .../InvalidSniffs/RegisterNoArraySniff.php | 25 + .../ValidSniffs/RegisterEmptyArraySniff.php | 25 + ...ulateTokenListenersRegisterNoArrayTest.xml | 8 + .../Ruleset/PopulateTokenListenersTest.php | 548 ++++++++++++++++++ .../Ruleset/PopulateTokenListenersTest.xml | 45 ++ ...ssRulesetAutoExpandSniffsDirectoryTest.xml | 4 +- tests/Core/Ruleset/ProcessRulesetTest.php | 1 + .../Ruleset/ShowSniffDeprecationsTest.xml | 1 + 9 files changed, 660 insertions(+), 4 deletions(-) create mode 100644 tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffs/RegisterNoArraySniff.php create mode 100644 tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/ValidSniffs/RegisterEmptyArraySniff.php create mode 100644 tests/Core/Ruleset/PopulateTokenListenersRegisterNoArrayTest.xml create mode 100644 tests/Core/Ruleset/PopulateTokenListenersTest.php create mode 100644 tests/Core/Ruleset/PopulateTokenListenersTest.xml diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index 48866cc345..a0da428c9a 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -185,9 +185,9 @@ public function testExplainWithDeprecatedSniffs() $ruleset = new Ruleset($config); $expected = PHP_EOL; - $expected .= 'The ShowSniffDeprecationsTest standard contains 10 sniffs'.PHP_EOL.PHP_EOL; + $expected .= 'The ShowSniffDeprecationsTest standard contains 11 sniffs'.PHP_EOL.PHP_EOL; - $expected .= 'TestStandard (10 sniffs)'.PHP_EOL; + $expected .= 'TestStandard (11 sniffs)'.PHP_EOL; $expected .= '------------------------'.PHP_EOL; $expected .= ' TestStandard.Deprecated.WithLongReplacement *'.PHP_EOL; $expected .= ' TestStandard.Deprecated.WithoutReplacement *'.PHP_EOL; @@ -198,7 +198,8 @@ public function testExplainWithDeprecatedSniffs() $expected .= ' TestStandard.SetProperty.AllowedViaMagicMethod'.PHP_EOL; $expected .= ' TestStandard.SetProperty.AllowedViaStdClass'.PHP_EOL; $expected .= ' TestStandard.SetProperty.NotAllowedViaAttribute'.PHP_EOL; - $expected .= ' TestStandard.SetProperty.PropertyTypeHandling'.PHP_EOL.PHP_EOL; + $expected .= ' TestStandard.SetProperty.PropertyTypeHandling'.PHP_EOL; + $expected .= ' TestStandard.ValidSniffs.RegisterEmptyArray'.PHP_EOL.PHP_EOL; $expected .= '* Sniffs marked with an asterix are deprecated.'.PHP_EOL; diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffs/RegisterNoArraySniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffs/RegisterNoArraySniff.php new file mode 100644 index 0000000000..a77ac24fa5 --- /dev/null +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffs/RegisterNoArraySniff.php @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/tests/Core/Ruleset/PopulateTokenListenersTest.php b/tests/Core/Ruleset/PopulateTokenListenersTest.php new file mode 100644 index 0000000000..c0abfffd54 --- /dev/null +++ b/tests/Core/Ruleset/PopulateTokenListenersTest.php @@ -0,0 +1,548 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; +use PHP_CodeSniffer\Util\Tokens; +use ReflectionObject; +use ReflectionProperty; + +/** + * Test the Ruleset::populateTokenListeners() method. + * + * @covers \PHP_CodeSniffer\Ruleset::populateTokenListeners + */ +final class PopulateTokenListenersTest extends AbstractRulesetTestCase +{ + + /** + * The Ruleset object. + * + * @var \PHP_CodeSniffer\Ruleset + */ + private static $ruleset; + + + /** + * Initialize the config and ruleset objects for this test only once (but do allow recording code coverage). + * + * @before + * + * @return void + */ + protected function initializeConfigAndRuleset() + { + if (isset(self::$ruleset) === false) { + // Set up the ruleset. + $standard = __DIR__.'/PopulateTokenListenersTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + self::$ruleset = new Ruleset($config); + } + + }//end initializeConfigAndRuleset() + + + /** + * Test an exception is thrown when the register() method of a sniff doesn't return an array. + * + * @return void + */ + public function testSniffWhereRegisterDoesNotReturnAnArrayThrowsException() + { + $standard = __DIR__.'/PopulateTokenListenersRegisterNoArrayTest.xml'; + $config = new ConfigDouble(["--standard=$standard"]); + + $sniffClass = 'Fixtures\\TestStandard\\Sniffs\\InvalidSniffs\\RegisterNoArraySniff'; + $message = "Sniff $sniffClass register() method must return an array"; + $this->expectRuntimeExceptionMessage($message); + + new Ruleset($config); + + }//end testSniffWhereRegisterDoesNotReturnAnArrayThrowsException() + + + /** + * Test that a sniff not registering any tokens is not listed as a listener. + * + * @return void + */ + public function testSniffWithRegisterMethodReturningEmptyArrayIsSilentlyIgnored() + { + $target = 'Fixtures\\TestStandard\\Sniffs\\ValidSniffs\\RegisterEmptyArraySniff'; + + foreach (self::$ruleset->tokenListeners as $token => $listeners) { + $this->assertTrue(is_array($listeners), 'No listeners registered for token'.Tokens::tokenName($token)); + $this->assertArrayNotHasKey( + $target, + $listeners, + sprintf('Found the %s sniff registered for token %s', $target, Tokens::tokenName($token)) + ); + } + + }//end testSniffWithRegisterMethodReturningEmptyArrayIsSilentlyIgnored() + + + /** + * Tests that sniffs registering tokens, will end up listening to these tokens. + * + * @param string $sniffClass The FQN for the sniff class to check. + * @param int $expectedCount Expected number of tokens to which the sniff should be listening. + * + * @dataProvider dataSniffListensToTokenss + * + * @return void + */ + public function testRegistersSniffsToListenToTokens($sniffClass, $expectedCount) + { + $counter = 0; + + foreach (self::$ruleset->tokenListeners as $listeners) { + if (isset($listeners[$sniffClass]) === true) { + ++$counter; + } + } + + $this->assertSame($expectedCount, $counter); + + }//end testRegistersSniffsToListenToTokens() + + + /** + * Data provider. + * + * @see testSniffListensToTokens() + * + * @return array> + */ + public static function dataSniffListensToTokenss() + { + return [ + 'Generic.Files.EndFileNewline' => [ + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\EndFileNewlineSniff', + 'expectedCount' => 2, + ], + 'Generic.NamingConventions.UpperCaseConstantName' => [ + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff', + 'expectedCount' => 2, + ], + 'PSR1.Files.SideEffects' => [ + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Files\\SideEffectsSniff', + 'expectedCount' => 1, + ], + 'PSR12.ControlStructures.BooleanOperatorPlacement' => [ + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\PSR12\\Sniffs\\ControlStructures\\BooleanOperatorPlacementSniff', + 'expectedCount' => 5, + ], + 'Squiz.ControlStructures.ForEachLoopDeclaration' => [ + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\ControlStructures\\ForEachLoopDeclarationSniff', + 'expectedCount' => 1, + ], + 'TestStandard.Deprecated.WithReplacement' => [ + 'sniffClass' => 'Fixtures\\TestStandard\\Sniffs\\Deprecated\\WithReplacementSniff', + 'expectedCount' => 1, + ], + 'TestStandard.ValidSniffs.RegisterEmptyArray' => [ + 'sniffClass' => 'Fixtures\\TestStandard\\Sniffs\\ValidSniffs\\RegisterEmptyArraySniff', + 'expectedCount' => 0, + ], + ]; + + }//end dataSniffListensToTokenss() + + + /** + * Test that deprecated sniffs get recognized and added to the $deprecatedSniffs list. + * + * @return void + */ + public function testRegistersWhenADeprecatedSniffIsLoaded() + { + $property = new ReflectionProperty(self::$ruleset, 'deprecatedSniffs'); + $property->setAccessible(true); + $actualValue = $property->getValue(self::$ruleset); + $property->setAccessible(false); + + // Only verify there is one deprecated sniff registered. + // There are other tests which test the deprecated sniff handling in more detail. + $this->assertTrue(is_array($actualValue)); + $this->assertCount(1, $actualValue); + + }//end testRegistersWhenADeprecatedSniffIsLoaded() + + + /** + * Verify that the setting of properties on a sniff was not triggered when there are no properties being set. + * + * @return void + */ + public function testDoesntTriggerPropertySettingForNoProperties() + { + $sniffClass = 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff'; + + // Verify that our target sniff has been registered. + $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs, "Sniff class $sniffClass not listed in registered sniffs"); + + $sniffObject = self::$ruleset->sniffs[$sniffClass]; + $reflection = new ReflectionObject($sniffObject); + + // Just making sure there are no properties on the sniff object (which doesn't have declared properties). + $this->assertSame([], $reflection->getProperties(), "Unexpected properties found on sniff class $sniffClass"); + + }//end testDoesntTriggerPropertySettingForNoProperties() + + + /** + * Verify that the setting of properties on a sniff was triggered. + * + * @param string $sniffClass The FQN for the sniff class on which the property should be set. + * @param string $propertyName The property name. + * @param string $expected The expected property value. + * + * @dataProvider dataTriggersPropertySettingWhenPropertiesProvided + * + * @return void + */ + public function testTriggersPropertySettingWhenPropertiesProvided($sniffClass, $propertyName, $expected) + { + // Verify that our target sniff has been registered. + $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs, "Sniff class $sniffClass not listed in registered sniffs"); + + $sniffObject = self::$ruleset->sniffs[$sniffClass]; + + // Verify the property has been set. + $this->assertSame($expected, $sniffObject->$propertyName, "Property on sniff class $sniffClass set to unexpected value"); + + }//end testTriggersPropertySettingWhenPropertiesProvided() + + + /** + * Data provider. + * + * @see testTriggersPropertySettingWhenPropertiesProvided() + * + * @return array> + */ + public static function dataTriggersPropertySettingWhenPropertiesProvided() + { + return [ + 'Sniff with single property being set' => [ + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\PSR12\\Sniffs\\ControlStructures\\BooleanOperatorPlacementSniff', + 'propertyName' => 'allowOnly', + 'expected' => 'first', + ], + 'Sniff with multiple properties being set - first property' => [ + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\ControlStructures\\ForEachLoopDeclarationSniff', + 'propertyName' => 'requiredSpacesAfterOpen', + 'expected' => '3', + ], + 'Sniff with multiple properties being set - second property' => [ + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\ControlStructures\\ForEachLoopDeclarationSniff', + 'propertyName' => 'requiredSpacesBeforeClose', + 'expected' => '8', + ], + ]; + + }//end dataTriggersPropertySettingWhenPropertiesProvided() + + + /** + * Verifies that the "class" and "source" indexes get set. + * + * @return void + */ + public function testSetsClassAndSourceIndexes() + { + foreach (self::$ruleset->tokenListeners as $token => $listeners) { + $this->assertTrue(is_array($listeners), 'No listeners registered for token'.Tokens::tokenName($token)); + + foreach ($listeners as $className => $details) { + $this->assertArrayHasKey( + 'class', + $details, + sprintf('"tokenizers" key missing for sniff class %s for token %s', $className, Tokens::tokenName($token)) + ); + + $this->assertSame( + $className, + $details['class'], + sprintf('Unexpected value for "class" key for sniff class %s for token %s', $className, Tokens::tokenName($token)) + ); + + $this->assertArrayHasKey( + 'source', + $details, + sprintf('"source" key missing for sniff class %s for token %s', $className, Tokens::tokenName($token)) + ); + + $this->assertTrue( + is_string($details['source']), + sprintf('Value for "source" key is not a string for token %s', Tokens::tokenName($token)) + ); + + $expected = '.'.substr($className, (strrpos($className, '\\') + 1), -5); + + $this->assertStringEndsWith( + $expected, + $details['source'], + sprintf('Unexpected value for "source" key for sniff class %s for token %s', $className, Tokens::tokenName($token)) + ); + }//end foreach + }//end foreach + + }//end testSetsClassAndSourceIndexes() + + + /** + * Verifies that sniffs by default are listening for PHP files only. + * + * @return void + */ + public function testSetsSupportedTokenizersToPHPByDefault() + { + $exclude = 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\EndFileNewlineSniff'; + $expected = ['PHP' => 'PHP']; + + foreach (self::$ruleset->tokenListeners as $token => $listeners) { + $this->assertTrue(is_array($listeners), 'No listeners registered for token'.Tokens::tokenName($token)); + + foreach ($listeners as $className => $details) { + if ($className === $exclude) { + // Skip this one as it is the one sniff for which things will be different. + continue; + } + + $this->assertArrayHasKey( + 'tokenizers', + $details, + sprintf('"tokenizers" key missing for sniff class %s for token %s', $className, Tokens::tokenName($token)) + ); + + $this->assertSame( + $expected, + $details['tokenizers'], + sprintf('Unexpected value for "tokenizers" key for sniff class %s for token %s', $className, Tokens::tokenName($token)) + ); + } + }//end foreach + + }//end testSetsSupportedTokenizersToPHPByDefault() + + + /** + * Test that if a sniff has the $supportedTokenizers property set, the tokenizers listed there + * will be registered in the listeners array. + * + * @param int $token The token constant for which the sniff should be registered. + * + * @dataProvider dataSetsSupportedTokenizersWhenProvidedBySniff + * + * @return void + */ + public function testSetsSupportedTokenizersWhenProvidedBySniff($token) + { + $sniffClass = 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\EndFileNewlineSniff'; + $expected = [ + 'PHP' => 'PHP', + 'JS' => 'JS', + 'CSS' => 'CSS', + ]; + + $this->assertArrayHasKey( + $token, + self::$ruleset->tokenListeners, + sprintf('The token constant %s is not registered to the listeners array', Tokens::tokenName($token)) + ); + $this->assertArrayHasKey( + $sniffClass, + self::$ruleset->tokenListeners[$token], + sprintf('The sniff class %s is not registered for token %s', $sniffClass, Tokens::tokenName($token)) + ); + $this->assertArrayHasKey( + 'tokenizers', + self::$ruleset->tokenListeners[$token][$sniffClass], + sprintf('"tokenizers" key missing for sniff class %s for token %s', $sniffClass, Tokens::tokenName($token)) + ); + + $this->assertSame( + $expected, + self::$ruleset->tokenListeners[$token][$sniffClass]['tokenizers'], + sprintf('Unexpected value for "tokenizers" key for sniff class %s for token %s', $sniffClass, Tokens::tokenName($token)) + ); + + }//end testSetsSupportedTokenizersWhenProvidedBySniff() + + + /** + * Data provider. + * + * @see testSetsSupportedTokenizersWhenProvidedBySniff() + * + * @return array> + */ + public static function dataSetsSupportedTokenizersWhenProvidedBySniff() + { + return [ + 'T_OPEN_TAG' => [T_OPEN_TAG], + 'T_OPEN_TAG_WITH_ECHO' => [T_OPEN_TAG_WITH_ECHO], + ]; + + }//end dataSetsSupportedTokenizersWhenProvidedBySniff() + + + /** + * Verifies that by default no explicit include patterns are registered for sniffs. + * + * @return void + */ + public function testSetsIncludePatternsToEmptyArrayByDefault() + { + $exclude = 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff'; + + foreach (self::$ruleset->tokenListeners as $token => $listeners) { + $this->assertTrue(is_array($listeners), 'No listeners registered for token'.Tokens::tokenName($token)); + + foreach ($listeners as $className => $details) { + if ($className === $exclude) { + // Skip this one as it is the one sniff for which things will be different. + continue; + } + + $this->assertArrayHasKey( + 'include', + $details, + sprintf('"include" key missing for sniff class %s for token %s', $className, Tokens::tokenName($token)) + ); + + $this->assertSame( + [], + $details['include'], + sprintf('Unexpected value for "include" key for sniff class %s for token %s', $className, Tokens::tokenName($token)) + ); + } + }//end foreach + + }//end testSetsIncludePatternsToEmptyArrayByDefault() + + + /** + * Verifies that by default no explicit ignore patterns are registered for sniffs. + * + * @return void + */ + public function testSetsIgnorePatternsToEmptyArrayByDefault() + { + $exclude = 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Files\\SideEffectsSniff'; + + foreach (self::$ruleset->tokenListeners as $token => $listeners) { + $this->assertTrue(is_array($listeners), 'No listeners registered for token'.Tokens::tokenName($token)); + + foreach ($listeners as $className => $details) { + if ($className === $exclude) { + // Skip this one as it is the one sniff for which things will be different. + continue; + } + + $this->assertArrayHasKey( + 'ignore', + $details, + sprintf('"ignore" key missing for sniff class %s for token %s', $className, Tokens::tokenName($token)) + ); + + $this->assertSame( + [], + $details['ignore'], + sprintf('Unexpected value for "ignore" key for sniff class %s for token %s', $className, Tokens::tokenName($token)) + ); + } + }//end foreach + + }//end testSetsIgnorePatternsToEmptyArrayByDefault() + + + /** + * Tests that if there are <[include|exclude]-pattern> directives set on a sniff, these are set for the relevant listeners. + * + * Includes verification that the transformation of "regex"-like patterns is handled correctly. + * + * @param int|string $token A token constant on which the sniff should be registered. + * @param string $sniffClass The FQN for the sniff class on which the patterns should be registered. + * @param string $patternType The type of patterns expected to be registered for the sniff. + * + * @dataProvider dataSetsIncludeAndIgnorePatterns + * + * @return void + */ + public function testSetsIncludeAndIgnorePatterns($token, $sniffClass, $patternType) + { + $expected = [ + '/no-transformation/', + '/simple.*transformation/.*', + '/escaped\\,comma/becomes/comma/to/allow/commas/in/filenames.css', + '/pat?tern(is|regex)\\.php$', + ]; + + $this->assertArrayHasKey( + $token, + self::$ruleset->tokenListeners, + sprintf('The token constant %s is not registered to the listeners array', Tokens::tokenName($token)) + ); + $this->assertArrayHasKey( + $sniffClass, + self::$ruleset->tokenListeners[$token], + sprintf('The sniff class %s is not registered for token %s', $sniffClass, Tokens::tokenName($token)) + ); + $this->assertArrayHasKey( + $patternType, + self::$ruleset->tokenListeners[$token][$sniffClass], + sprintf('"%s" key missing for sniff class %s for token %s', $patternType, $sniffClass, Tokens::tokenName($token)) + ); + + $this->assertSame( + $expected, + self::$ruleset->tokenListeners[$token][$sniffClass][$patternType], + sprintf('Unexpected value for "%s" key for sniff class %s for token %s', $patternType, $sniffClass, Tokens::tokenName($token)) + ); + + }//end testSetsIncludeAndIgnorePatterns() + + + /** + * Data provider. + * + * @see testSetsIncludeAndIgnorePatterns() + * + * @return array> + */ + public static function dataSetsIncludeAndIgnorePatterns() + { + return [ + 'Sniff with s in the ruleset - first token' => [ + 'token' => T_STRING, + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff', + 'patternType' => 'include', + ], + 'Sniff with s in the ruleset - second token' => [ + 'token' => T_CONST, + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff', + 'patternType' => 'include', + ], + 'Sniff with s in the ruleset' => [ + 'token' => T_OPEN_TAG, + 'sniffClass' => 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Files\\SideEffectsSniff', + 'patternType' => 'ignore', + ], + ]; + + }//end dataSetsIncludeAndIgnorePatterns() + + +}//end class diff --git a/tests/Core/Ruleset/PopulateTokenListenersTest.xml b/tests/Core/Ruleset/PopulateTokenListenersTest.xml new file mode 100644 index 0000000000..f61ab500d0 --- /dev/null +++ b/tests/Core/Ruleset/PopulateTokenListenersTest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /no-transformation/ + /simple*transformation/* + /escaped\\,comma/becomes/comma/to/allow/commas/in/filenames.css + /pat?tern(is|regex)\.php$ + + + + + /no-transformation/ + /simple*transformation/* + /escaped\\,comma/becomes/comma/to/allow/commas/in/filenames.css + /pat?tern(is|regex)\.php$ + + + diff --git a/tests/Core/Ruleset/ProcessRulesetAutoExpandSniffsDirectoryTest.xml b/tests/Core/Ruleset/ProcessRulesetAutoExpandSniffsDirectoryTest.xml index 6968808664..579b9485d2 100644 --- a/tests/Core/Ruleset/ProcessRulesetAutoExpandSniffsDirectoryTest.xml +++ b/tests/Core/Ruleset/ProcessRulesetAutoExpandSniffsDirectoryTest.xml @@ -3,6 +3,8 @@ - + + + diff --git a/tests/Core/Ruleset/ProcessRulesetTest.php b/tests/Core/Ruleset/ProcessRulesetTest.php index d53889a88c..c18173b476 100644 --- a/tests/Core/Ruleset/ProcessRulesetTest.php +++ b/tests/Core/Ruleset/ProcessRulesetTest.php @@ -72,6 +72,7 @@ public function testAutoExpandSniffsDirectory() "$std.SetProperty.AllowedViaStdClass" => "$sniffDir\SetProperty\AllowedViaStdClassSniff", "$std.SetProperty.NotAllowedViaAttribute" => "$sniffDir\SetProperty\NotAllowedViaAttributeSniff", "$std.SetProperty.PropertyTypeHandling" => "$sniffDir\SetProperty\PropertyTypeHandlingSniff", + "$std.ValidSniffs.RegisterEmptyArray" => "$sniffDir\ValidSniffs\RegisterEmptyArraySniff", ]; // Sort the value to make the tests stable as different OSes will read directories diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml index 38c7e02221..802bd3c0a9 100644 --- a/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml +++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml @@ -5,6 +5,7 @@ + From a9b6fa09169de4640a527e574d046dcf6ea4e6cb Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 4 Oct 2024 15:23:00 -0300 Subject: [PATCH 863/874] Generic/InlineControlStructure: stop listening for T_SWITCH tokens There is no inline version of a `switch` in PHP and JS so there is no reason for this sniff to listen to `T_SWITCH` tokens. Before this change, the sniff would bail early on the line below as a switch always has a scope opener, so this change should not impact in any way the behavior of the sniff. https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/9a0c2546ea2fa7aac19881da7b655cc5f022bc10/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php#L71 The InlineControlStructure sniff started listening for `T_SWITCH` tokens since the commit that added it to PHPCS: https://github.com/PHPCSStandards/PHP_CodeSniffer/commit/ad96eb#diff-e1ea4eabd79d6324057bbf726a27074250478f87d92c11a3725a97f0afbd5513R50 Some of the sniff tests using the `T_SWITCH` token were added to protect against regressions for changes in the tokenizer. For those, dedicated tokenizer tests will be created in subsequent commits. Those commits will also update the related sniff tests to use different control structures other than `T_SWITCH` when appropriate. The modified JS test lost part of its value over time as now the sniff bails early if there is no opening parenthesis after the control structure. Ideally, it should be moved to a tokenizer test, but since there are no tests for the JS tokenizer and support will be dropped in PHPCS 4.0, I opted to simply use a control structure other than T_SWITCH. This test was originally added in b3f4f83. References: - PHP: https://www.php.net/manual/en/control-structures.switch.php - JS: https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html --- .../Sniffs/ControlStructures/InlineControlStructureSniff.php | 1 - .../Tests/ControlStructures/InlineControlStructureUnitTest.1.js | 2 +- .../ControlStructures/InlineControlStructureUnitTest.1.js.fixed | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php index ff1738328f..1efb15c7be 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -48,7 +48,6 @@ public function register() T_FOREACH, T_WHILE, T_DO, - T_SWITCH, T_FOR, ]; diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js index ca6dae13a0..763c1c1c1c 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js @@ -20,7 +20,7 @@ do { do i++; while (i < 5); -SomeClass.prototype.switch = function() { +SomeClass.prototype.for = function() { // do something }; diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js.fixed b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js.fixed index d410cfb122..050a406bba 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js.fixed +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js.fixed @@ -26,7 +26,7 @@ do { do { i++; } while (i < 5); -SomeClass.prototype.switch = function() { +SomeClass.prototype.for = function() { // do something }; From 4c92408c42aef9a0d756a5ca6abdbcbea10595a5 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 22 May 2024 11:47:12 -0300 Subject: [PATCH 864/874] Tests/Tokenizer: tests to ensure scope is set correctly for T_SWITCH This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. The original test was added in b24b96b, part of https://github.com/squizlabs/PHP_CodeSniffer/issues/497. b24b96b introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. It was added to ensure that Tokenizer::recurseScopeMap() would correctly add scope information to the `T_SWITCH` token when handling a `switch` that uses the alternative syntax. This commit also adds a test to ensure the scope is correctly set when using the normal switch syntax. This was not part of b24b96b, but it is relevant anyway, as no other tokenizer test covers this part. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in b24b96b became useless and thus was refactored to use a different control structure. The sniff test was kept as testing code that uses a control structure, and opening and closing PHP tags is an interesting case not covered in other tests. --- .../InlineControlStructureUnitTest.1.inc | 16 +-- ...InlineControlStructureUnitTest.1.inc.fixed | 16 +-- .../RecurseScopeMapSwitchTokenScopeTest.inc | 24 ++++ .../RecurseScopeMapSwitchTokenScopeTest.php | 113 ++++++++++++++++++ 4 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.inc create mode 100644 tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.php diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc index 739ba40a6d..11b4912153 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc @@ -79,14 +79,14 @@ if ($a) error): - case Shop_Customer :: ERROR_INVALID_GENDER: ?> - Ungültiges Geschlecht! - - Die eingetragene E-Mail-Adresse ist bereits registriert. - + Error one! + + Error two! +allowShopping !== true): if ($this->status != Shop_Cart :: OK): diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed index 9a89b0e387..7e2e628ae3 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed @@ -91,14 +91,14 @@ if ($a) { error): - case Shop_Customer :: ERROR_INVALID_GENDER: ?> - Ungültiges Geschlecht! - - Die eingetragene E-Mail-Adresse ist bereits registriert. - + Error one! + + Error two! +allowShopping !== true): if ($this->status != Shop_Cart :: OK): diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.inc b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.inc new file mode 100644 index 0000000000..682e1f46ee --- /dev/null +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.inc @@ -0,0 +1,24 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizers\Tokenizer; + +use PHP_CodeSniffer\Tests\Core\Tokenizers\AbstractTokenizerTestCase; + +final class RecurseScopeMapSwitchTokenScopeTest extends AbstractTokenizerTestCase +{ + + + /** + * Tests setting the scope for T_SWITCH token (normal and alternative syntax). + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param array $expectedTokens The expected token codes for the scope opener/closer. + * @param string|null $testCloserMarker Optional. The comment which prefaces the scope closer if different + * from the test marker. + * + * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/497#ref-commit-b24b96b + * + * @dataProvider dataSwitchScope + * @covers \PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap + * + * @return void + */ + public function testSwitchScope($testMarker, $expectedTokens, $testCloserMarker=null) + { + $tokens = $this->phpcsFile->getTokens(); + $switchIndex = $this->getTargetToken($testMarker, [T_SWITCH]); + $tokenArray = $tokens[$switchIndex]; + + $scopeCloserMarker = $testMarker; + if (isset($testCloserMarker) === true) { + $scopeCloserMarker = $testCloserMarker; + } + + $expectedScopeCondition = $switchIndex; + $expectedScopeOpener = $this->getTargetToken($testMarker, $expectedTokens['scope_opener']); + $expectedScopeCloser = $this->getTargetToken($scopeCloserMarker, $expectedTokens['scope_closer']); + + $this->assertArrayHasKey('scope_condition', $tokenArray, 'Scope condition not set'); + $this->assertSame( + $expectedScopeCondition, + $tokenArray['scope_condition'], + sprintf( + 'Scope condition not set correctly; expected T_SWITCH, found %s', + $tokens[$tokenArray['scope_condition']]['type'] + ) + ); + + $this->assertArrayHasKey('scope_opener', $tokenArray, 'Scope opener not set'); + $this->assertSame( + $expectedScopeOpener, + $tokenArray['scope_opener'], + sprintf( + 'Scope opener not set correctly; expected %s, found %s', + $tokens[$expectedScopeOpener]['type'], + $tokens[$tokenArray['scope_opener']]['type'] + ) + ); + + $this->assertArrayHasKey('scope_closer', $tokenArray, 'Scope closer not set'); + $this->assertSame( + $expectedScopeCloser, + $tokenArray['scope_closer'], + sprintf( + 'Scope closer not set correctly; expected %s, found %s', + $tokens[$expectedScopeCloser]['type'], + $tokens[$tokenArray['scope_closer']]['type'] + ) + ); + + }//end testSwitchScope() + + + /** + * Data provider. + * + * @see testSwitchScope() + * + * @return array>> + */ + public static function dataSwitchScope() + { + return [ + 'switch normal syntax' => [ + 'testMarker' => '/* testSwitchNormalSyntax */', + 'expectedTokens' => [ + 'scope_opener' => T_OPEN_CURLY_BRACKET, + 'scope_closer' => T_CLOSE_CURLY_BRACKET, + ], + ], + 'switch alternative syntax' => [ + 'testMarker' => '/* testSwitchAlternativeSyntax */', + 'expectedTokens' => [ + 'scope_opener' => T_COLON, + 'scope_closer' => T_ENDSWITCH, + ], + 'testCloserMarker' => '/* testSwitchAlternativeSyntaxEnd */', + ], + ]; + + }//end dataSwitchScope() + + +}//end class From b9809c7b16b686cea25de0d60e1d95fe6c7e17ae Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 26 Jul 2024 10:50:27 +0200 Subject: [PATCH 865/874] Tests/Tokenizer: tests for T_CASE and T_IF scope condition This commit copies, with some non-structural modifications, a sniff test to the tokenizer tests. Two new tokenizer tests are created as the result of this copy. One to ensure that the scope of `T_CASE` is correctly set when the case shares the scope closer with `T_SWITCH` (no `T_BREAK`). And another to ensure that the scope of `T_IF` is correctly set when there is a nested `T_SWITCH` and `T_CASE` without a `T_BREAK`. The original sniff test was added in fddc61a, which is part of https://github.com/squizlabs/PHP_CodeSniffer/issues/497. fddc61a introduced a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. The test was added to ensure that Tokenizer::recurseScopeMap() correctly adds scope information to the `T_CASE` token when it shares the closer with `T_SWITCH` and to `T_IF` when a nested `T_CASE` shares the scope closer with T_SWITCH`. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in fddc61a became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses nested alternative syntax control structures is still valid and is not covered in other tests. --- .../InlineControlStructureUnitTest.1.inc | 12 +-- ...InlineControlStructureUnitTest.1.inc.fixed | 12 +-- ...curseScopeMapCaseKeywordConditionsTest.inc | 7 ++ ...curseScopeMapCaseKeywordConditionsTest.php | 1 + ...RecurseScopeMapIfKeywordConditionsTest.inc | 13 ++++ ...RecurseScopeMapIfKeywordConditionsTest.php | 76 +++++++++++++++++++ 6 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 tests/Core/Tokenizers/Tokenizer/RecurseScopeMapIfKeywordConditionsTest.inc create mode 100644 tests/Core/Tokenizers/Tokenizer/RecurseScopeMapIfKeywordConditionsTest.php diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc index 11b4912153..e662111322 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc @@ -88,17 +88,17 @@ if ($error === ERROR_ONE): ?> -if ($this->allowShopping !== true): - if ($this->status != Shop_Cart :: OK): - switch ($this->status): - case Shop_Cart :: NOT_FOUND: - echo 'foo'; - endswitch; +if ($value): + if ($anotherValue): + foreach ($array as $element): + echo (function($element): string { return $element; } )($element); + endforeach; endif; else: echo 'foo'; endif; + // ELSE IF split over multiple lines (not inline) if ($test) { } else diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed index 7e2e628ae3..00c9d664fe 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed @@ -100,17 +100,17 @@ if ($error === ERROR_ONE): ?> -if ($this->allowShopping !== true): - if ($this->status != Shop_Cart :: OK): - switch ($this->status): - case Shop_Cart :: NOT_FOUND: - echo 'foo'; - endswitch; +if ($value): + if ($anotherValue): + foreach ($array as $element): + echo (function($element): string { return $element; } )($element); + endforeach; endif; else: echo 'foo'; endif; + // ELSE IF split over multiple lines (not inline) if ($test) { } else diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc index 13b87242e1..54a017b3d7 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc @@ -93,3 +93,10 @@ enum Foo: string { /* testKeywordAsEnumCaseNameShouldBeString7 */ case ARRAY = 'array'; } + +// Test for https://github.com/squizlabs/PHP_CodeSniffer/issues/497 +switch ($value): + /* testSwitchCaseScopeCloserSharedWithSwitch */ + case 1: + echo 'one'; +endswitch; diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php index 7fa4ba5567..321d04fcb8 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php @@ -106,6 +106,7 @@ public static function dataNotEnumCases() 'switch case with constant, keyword in mixed case' => ['/* testIsNotEnumCaseIsCaseInsensitive */'], 'switch case, body in curlies declares enum' => ['/* testCaseInSwitchWhenCreatingEnumInSwitch1 */'], 'switch case, body after semicolon declares enum' => ['/* testCaseInSwitchWhenCreatingEnumInSwitch2 */'], + 'switch case, shared closer with switch' => ['/* testSwitchCaseScopeCloserSharedWithSwitch */'], ]; }//end dataNotEnumCases() diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapIfKeywordConditionsTest.inc b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapIfKeywordConditionsTest.inc new file mode 100644 index 0000000000..e303c38500 --- /dev/null +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapIfKeywordConditionsTest.inc @@ -0,0 +1,13 @@ + + * @author Rodrigo Primo + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizers\Tokenizer; + +use PHP_CodeSniffer\Tests\Core\Tokenizers\AbstractTokenizerTestCase; + +final class RecurseScopeMapIfKeywordConditionsTest extends AbstractTokenizerTestCase +{ + + + /** + * Tests setting the scope for T_IF token with nested case statement missing break statement. + * + * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/497#ref-commit-fddc61a + * + * @covers \PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap + * + * @return void + */ + public function testIfElseWithNestedCaseMissingBreakSharedClosers() + { + + $tokens = $this->phpcsFile->getTokens(); + $ifTestMarker = '/* testIfElseWithNestedCaseMissingBreak */'; + $ifCloserTestMarker = '/* testIfElseWithNestedCaseMissingBreakCloser */'; + $ifTokenIndex = $this->getTargetToken($ifTestMarker, T_IF); + $tokenArray = $tokens[$ifTokenIndex]; + + $expectedScopeCondition = $ifTokenIndex; + $expectedScopeOpener = $this->getTargetToken($ifTestMarker, T_COLON); + $expectedScopeCloser = $this->getTargetToken($ifCloserTestMarker, T_ELSE); + + $this->assertArrayHasKey('scope_condition', $tokenArray, 'Scope condition not set'); + $this->assertSame( + $expectedScopeCondition, + $tokenArray['scope_condition'], + sprintf( + 'Scope condition not set correctly; expected T_IF, found %s', + $tokens[$tokenArray['scope_condition']]['type'] + ) + ); + + $this->assertArrayHasKey('scope_opener', $tokenArray, 'Scope opener not set'); + $this->assertSame( + $expectedScopeOpener, + $tokenArray['scope_opener'], + sprintf( + 'Scope opener not set correctly; expected %s, found %s', + $tokens[$expectedScopeOpener]['type'], + $tokens[$tokenArray['scope_opener']]['type'] + ) + ); + + $this->assertArrayHasKey('scope_closer', $tokenArray, 'Scope closer not set'); + $this->assertSame( + $expectedScopeCloser, + $tokenArray['scope_closer'], + sprintf( + 'Scope closer not set correctly; expected %s, found %s', + $tokens[$expectedScopeCloser]['type'], + $tokens[$tokenArray['scope_closer']]['type'] + ) + ); + + }//end testIfElseWithNestedCaseMissingBreakSharedClosers() + + +}//end class From 954677560104cd596bab1e4fc16bea2f76f7dd2f Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 12 Aug 2024 19:25:18 -0300 Subject: [PATCH 866/874] Tests/Tokenizer: scope opener is set correctly for T_SWITCH This commit copies, with some modifications, a sniff test to the tokenizer tests. It ensures that the scope opener is set correctly for T_SWITCH when there is a closure in the condition. This safeguards against regressions related to 30c618e, which fixed https://github .com/squizlabs/PHP_CodeSniffer/issues/543. 30c618e originally added a test to InlineControlStructureUnitTest.php as there were no Tokenizer tests back then. Since the InlineControlStructure sniff doesn't listen for the `T_SWITCH` token anymore (see baa4f65), the original test added in 30c618e became useless and thus was refactored to use a different control structure. This new version of the sniff test was kept as testing code that uses a closure in the condition is still an interesting case and is not covered in other tests. --- .../InlineControlStructureUnitTest.1.inc | 14 +++++------ ...InlineControlStructureUnitTest.1.inc.fixed | 15 +++++------ .../InlineControlStructureUnitTest.php | 1 + .../RecurseScopeMapSwitchTokenScopeTest.inc | 9 +++++++ .../RecurseScopeMapSwitchTokenScopeTest.php | 25 ++++++++++++++++--- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc index e662111322..c7b2a939b6 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc @@ -106,15 +106,15 @@ if ($test) { } else { } -switch($response = \Bar::baz('bat', function ($foo) { +if ((function () { return 'bar'; -})) { - case 1: - return 'test'; +})()) + echo 'one'; + + + + - case 2: - return 'other'; -} $stuff = [1,2,3]; foreach($stuff as $num) diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed index 00c9d664fe..c6099f4a89 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed @@ -118,16 +118,17 @@ if ($test) { } else { } -switch($response = \Bar::baz('bat', function ($foo) { +if ((function () { return 'bar'; -})) { - case 1: - return 'test'; - - case 2: - return 'other'; +})()) { + echo 'one'; } + + + + + $stuff = [1,2,3]; foreach($stuff as $num) { if ($num %2 ) { diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index afcaa3a335..19c78e0f96 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -48,6 +48,7 @@ public function getErrorList($testFile='') 62 => 1, 66 => 1, 78 => 1, + 109 => 1, 120 => 1, 128 => 1, 134 => 1, diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.inc b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.inc index 682e1f46ee..71ef02897a 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.inc +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.inc @@ -22,3 +22,12 @@ switch ($value): break; /* testSwitchAlternativeSyntaxEnd */ endswitch; + +// Test for https://github.com/squizlabs/PHP_CodeSniffer/issues/543 +/* testSwitchClosureWithinCondition */ +switch((function () { + return 'bar'; +})()) /* testSwitchClosureWithinConditionScopeOpener */ { + case 1: + return 'test'; +} diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.php b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.php index e80f7f5134..0977c0365c 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.php +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapSwitchTokenScopeTest.php @@ -20,6 +20,8 @@ final class RecurseScopeMapSwitchTokenScopeTest extends AbstractTokenizerTestCas * * @param string $testMarker The comment which prefaces the target token in the test file. * @param array $expectedTokens The expected token codes for the scope opener/closer. + * @param string|null $testOpenerMarker Optional. The comment which prefaces the scope opener if different + * from the test marker. * @param string|null $testCloserMarker Optional. The comment which prefaces the scope closer if different * from the test marker. * @@ -30,19 +32,24 @@ final class RecurseScopeMapSwitchTokenScopeTest extends AbstractTokenizerTestCas * * @return void */ - public function testSwitchScope($testMarker, $expectedTokens, $testCloserMarker=null) + public function testSwitchScope($testMarker, $expectedTokens, $testOpenerMarker=null, $testCloserMarker=null) { $tokens = $this->phpcsFile->getTokens(); $switchIndex = $this->getTargetToken($testMarker, [T_SWITCH]); $tokenArray = $tokens[$switchIndex]; + $scopeOpenerMarker = $testMarker; + if (isset($testOpenerMarker) === true) { + $scopeOpenerMarker = $testOpenerMarker; + } + $scopeCloserMarker = $testMarker; if (isset($testCloserMarker) === true) { $scopeCloserMarker = $testCloserMarker; } $expectedScopeCondition = $switchIndex; - $expectedScopeOpener = $this->getTargetToken($testMarker, $expectedTokens['scope_opener']); + $expectedScopeOpener = $this->getTargetToken($scopeOpenerMarker, $expectedTokens['scope_opener']); $expectedScopeCloser = $this->getTargetToken($scopeCloserMarker, $expectedTokens['scope_closer']); $this->assertArrayHasKey('scope_condition', $tokenArray, 'Scope condition not set'); @@ -90,21 +97,31 @@ public function testSwitchScope($testMarker, $expectedTokens, $testCloserMarker= public static function dataSwitchScope() { return [ - 'switch normal syntax' => [ + 'switch normal syntax' => [ 'testMarker' => '/* testSwitchNormalSyntax */', 'expectedTokens' => [ 'scope_opener' => T_OPEN_CURLY_BRACKET, 'scope_closer' => T_CLOSE_CURLY_BRACKET, ], ], - 'switch alternative syntax' => [ + 'switch alternative syntax' => [ 'testMarker' => '/* testSwitchAlternativeSyntax */', 'expectedTokens' => [ 'scope_opener' => T_COLON, 'scope_closer' => T_ENDSWITCH, ], + 'testOpenerMarker' => null, 'testCloserMarker' => '/* testSwitchAlternativeSyntaxEnd */', ], + 'switch with closure in the condition' => [ + 'testMarker' => '/* testSwitchClosureWithinCondition */', + 'expectedTokens' => [ + 'scope_opener' => T_OPEN_CURLY_BRACKET, + 'scope_closer' => T_CLOSE_CURLY_BRACKET, + ], + 'testOpenerMarker' => '/* testSwitchClosureWithinConditionScopeOpener */', + 'testCloserMarker' => '/* testSwitchClosureWithinConditionScopeOpener */', + ], ]; }//end dataSwitchScope() From 82fae8e57e10f6a7000daf53910394d109064736 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 12 Aug 2024 17:02:22 -0300 Subject: [PATCH 867/874] Tests/Tokenizer: expand `recurseScopeMap()` tests for the case keyword This commit expands the existing `Tokenizer::recurseScopeMap()` tests for the `case` keyword when used in a switch statement to check the value of the `scope_condition`, `scope_opener` and `scope_closer` indexes besides checking if they are set. This is needed for a new test case that will be added in a subsequent commit. --- ...curseScopeMapCaseKeywordConditionsTest.inc | 3 + ...curseScopeMapCaseKeywordConditionsTest.php | 120 ++++++++++++++++-- 2 files changed, 110 insertions(+), 13 deletions(-) diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc index 54a017b3d7..a4bb911997 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc @@ -62,6 +62,7 @@ switch (true) { case CONSTANT = 1: /* testIsNotEnumCaseIsCaseInsensitive */ cAsE CONSTANT: +/* testCaseConstantCloserMarker */ } switch ($x) { @@ -69,11 +70,13 @@ switch ($x) { case 'a': { enum Foo {} break; + /* testCaseInSwitchWhenCreatingEnumInSwitch1CloserMarker */ } /* testCaseInSwitchWhenCreatingEnumInSwitch2 */ case 'b'; enum Bar {} + /* testCaseInSwitchWhenCreatingEnumInSwitch2CloserMarker */ break; } diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php index 321d04fcb8..7144289147 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php @@ -66,25 +66,65 @@ public static function dataEnumCases() /** * Test that "case" that is not enum case is still tokenized as `T_CASE`. * - * @param string $testMarker The comment which prefaces the target token in the test file. + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param array $expectedTokens The expected token codes for the scope opener/closer. + * @param string|null $testCloserMarker Optional. The comment which prefaces the scope closer if different + * from the test marker. * * @dataProvider dataNotEnumCases * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap * * @return void */ - public function testNotEnumCases($testMarker) + public function testNotEnumCases($testMarker, $expectedTokens, $testCloserMarker=null) { $tokens = $this->phpcsFile->getTokens(); - $case = $this->getTargetToken($testMarker, [T_ENUM_CASE, T_CASE]); - $tokenArray = $tokens[$case]; + $caseIndex = $this->getTargetToken($testMarker, [T_ENUM_CASE, T_CASE]); + $tokenArray = $tokens[$caseIndex]; + + $scopeCloserMarker = $testMarker; + if (isset($testCloserMarker) === true) { + $scopeCloserMarker = $testCloserMarker; + } + + $expectedScopeCondition = $caseIndex; + $expectedScopeOpener = $this->getTargetToken($testMarker, $expectedTokens['scope_opener']); + $expectedScopeCloser = $this->getTargetToken($scopeCloserMarker, $expectedTokens['scope_closer']); // Make sure we're looking at the right token. $this->assertSame(T_CASE, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_CASE (code)'); $this->assertArrayHasKey('scope_condition', $tokenArray, 'Scope condition is not set'); + $this->assertSame( + $expectedScopeCondition, + $tokenArray['scope_condition'], + sprintf( + 'Scope condition not set correctly; expected T_CASE, found %s.', + $tokens[$tokenArray['scope_condition']]['type'] + ) + ); + $this->assertArrayHasKey('scope_opener', $tokenArray, 'Scope opener is not set'); + $this->assertSame( + $expectedScopeOpener, + $tokenArray['scope_opener'], + sprintf( + 'Scope opener not set correctly; expected %s, found %s.', + $tokens[$expectedScopeOpener]['type'], + $tokens[$tokenArray['scope_opener']]['type'] + ) + ); + $this->assertArrayHasKey('scope_closer', $tokenArray, 'Scope closer is not set'); + $this->assertSame( + $expectedScopeCloser, + $tokenArray['scope_closer'], + sprintf( + 'Scope closer not set correctly; expected %s, found %s.', + $tokens[$expectedScopeCloser]['type'], + $tokens[$tokenArray['scope_closer']]['type'] + ) + ); }//end testNotEnumCases() @@ -94,19 +134,73 @@ public function testNotEnumCases($testMarker) * * @see testNotEnumCases() * - * @return array> + * @return array>> */ public static function dataNotEnumCases() { return [ - 'switch case with constant, semicolon condition end' => ['/* testCaseWithSemicolonIsNotEnumCase */'], - 'switch case with constant, colon condition end' => ['/* testCaseWithConstantIsNotEnumCase */'], - 'switch case with constant, comparison' => ['/* testCaseWithConstantAndIdenticalIsNotEnumCase */'], - 'switch case with constant, assignment' => ['/* testCaseWithAssigmentToConstantIsNotEnumCase */'], - 'switch case with constant, keyword in mixed case' => ['/* testIsNotEnumCaseIsCaseInsensitive */'], - 'switch case, body in curlies declares enum' => ['/* testCaseInSwitchWhenCreatingEnumInSwitch1 */'], - 'switch case, body after semicolon declares enum' => ['/* testCaseInSwitchWhenCreatingEnumInSwitch2 */'], - 'switch case, shared closer with switch' => ['/* testSwitchCaseScopeCloserSharedWithSwitch */'], + 'switch case with constant, semicolon condition end' => [ + 'testMarker' => '/* testCaseWithSemicolonIsNotEnumCase */', + 'expectedTokens' => [ + 'scope_opener' => T_SEMICOLON, + 'scope_closer' => T_CLOSE_CURLY_BRACKET, + ], + ], + 'switch case with constant, colon condition end' => [ + 'testMarker' => '/* testCaseWithConstantIsNotEnumCase */', + 'expectedTokens' => [ + 'scope_opener' => T_COLON, + 'scope_closer' => T_CLOSE_CURLY_BRACKET, + ], + 'testCloserMarker' => '/* testCaseConstantCloserMarker */', + ], + 'switch case with constant, comparison' => [ + 'testMarker' => '/* testCaseWithConstantAndIdenticalIsNotEnumCase */', + 'expectedTokens' => [ + 'scope_opener' => T_COLON, + 'scope_closer' => T_CLOSE_CURLY_BRACKET, + ], + 'testCloserMarker' => '/* testCaseConstantCloserMarker */', + ], + 'switch case with constant, assignment' => [ + 'testMarker' => '/* testCaseWithAssigmentToConstantIsNotEnumCase */', + 'expectedTokens' => [ + 'scope_opener' => T_COLON, + 'scope_closer' => T_CLOSE_CURLY_BRACKET, + ], + 'testCloserMarker' => '/* testCaseConstantCloserMarker */', + ], + 'switch case with constant, keyword in mixed case' => [ + 'testMarker' => '/* testIsNotEnumCaseIsCaseInsensitive */', + 'expectedTokens' => [ + 'scope_opener' => T_COLON, + 'scope_closer' => T_CLOSE_CURLY_BRACKET, + ], + 'testCloserMarker' => '/* testCaseConstantCloserMarker */', + ], + 'switch case, body in curlies declares enum' => [ + 'testMarker' => '/* testCaseInSwitchWhenCreatingEnumInSwitch1 */', + 'expectedTokens' => [ + 'scope_opener' => T_OPEN_CURLY_BRACKET, + 'scope_closer' => T_CLOSE_CURLY_BRACKET, + ], + 'testCloserMarker' => '/* testCaseInSwitchWhenCreatingEnumInSwitch1CloserMarker */', + ], + 'switch case, body after semicolon declares enum' => [ + 'testMarker' => '/* testCaseInSwitchWhenCreatingEnumInSwitch2 */', + 'expectedTokens' => [ + 'scope_opener' => T_SEMICOLON, + 'scope_closer' => T_BREAK, + ], + 'testCloserMarker' => '/* testCaseInSwitchWhenCreatingEnumInSwitch2CloserMarker */', + ], + 'switch case, shared closer with switch' => [ + 'testMarker' => '/* testSwitchCaseScopeCloserSharedWithSwitch */', + 'expectedTokens' => [ + 'scope_opener' => T_COLON, + 'scope_closer' => T_ENDSWITCH, + ], + ], ]; }//end dataNotEnumCases() From 61b9e9b4ec2af6471eb7e56c18b2da931245b88c Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 13 Aug 2024 11:15:55 -0300 Subject: [PATCH 868/874] Tests/Tokenizer: test to ensure scope closer is set correctly for T_CASE This commit copies a sniff test from InlineControlStructureUnitTest.php to the `Tokenizer::recurseScopeMap()` tests for the case keyword. This test was added in b498dbe before the Tokenizer tests were created. It ensures that the scope for the `T_CASE` token is correctly set when there is an if/elseif/else with and without braces inside it. Note that this test currently does not fail even when the changes to the tokenizer applied in b498dbe are reverted. I'm assuming that a subsequent commit further improved the tokenizer and made the changes from b498dbe redundant, but I was not able to find the specific commit using `git bissect`. That being said, I was able to confirm that before b498dbe, the scope closer for the `T_CASE` token was incorrectly set to `T_RETURN` instead of `T_BREAK`. The original sniff test was kept without any modification as testing if/elseif/else with and without curly braces inside another control structure is still valid. --- ...curseScopeMapCaseKeywordConditionsTest.inc | 14 +++++++++++ ...curseScopeMapCaseKeywordConditionsTest.php | 23 ++++++++++++------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc index a4bb911997..6c71d80db0 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc @@ -103,3 +103,17 @@ switch ($value): case 1: echo 'one'; endswitch; + +// Test for https://github.com/squizlabs/PHP_CodeSniffer/issues/879 +switch ($type) { + /* testSwitchCaseNestedIfWithAndWithoutBraces */ + case 1: + if ($foo) { + return true; + } elseif ($baz) + return true; + else { + echo 'else'; + } + break; +} diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php index 7144289147..8b651c6d43 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php @@ -139,14 +139,14 @@ public function testNotEnumCases($testMarker, $expectedTokens, $testCloserMarker public static function dataNotEnumCases() { return [ - 'switch case with constant, semicolon condition end' => [ + 'switch case with constant, semicolon condition end' => [ 'testMarker' => '/* testCaseWithSemicolonIsNotEnumCase */', 'expectedTokens' => [ 'scope_opener' => T_SEMICOLON, 'scope_closer' => T_CLOSE_CURLY_BRACKET, ], ], - 'switch case with constant, colon condition end' => [ + 'switch case with constant, colon condition end' => [ 'testMarker' => '/* testCaseWithConstantIsNotEnumCase */', 'expectedTokens' => [ 'scope_opener' => T_COLON, @@ -154,7 +154,7 @@ public static function dataNotEnumCases() ], 'testCloserMarker' => '/* testCaseConstantCloserMarker */', ], - 'switch case with constant, comparison' => [ + 'switch case with constant, comparison' => [ 'testMarker' => '/* testCaseWithConstantAndIdenticalIsNotEnumCase */', 'expectedTokens' => [ 'scope_opener' => T_COLON, @@ -162,7 +162,7 @@ public static function dataNotEnumCases() ], 'testCloserMarker' => '/* testCaseConstantCloserMarker */', ], - 'switch case with constant, assignment' => [ + 'switch case with constant, assignment' => [ 'testMarker' => '/* testCaseWithAssigmentToConstantIsNotEnumCase */', 'expectedTokens' => [ 'scope_opener' => T_COLON, @@ -170,7 +170,7 @@ public static function dataNotEnumCases() ], 'testCloserMarker' => '/* testCaseConstantCloserMarker */', ], - 'switch case with constant, keyword in mixed case' => [ + 'switch case with constant, keyword in mixed case' => [ 'testMarker' => '/* testIsNotEnumCaseIsCaseInsensitive */', 'expectedTokens' => [ 'scope_opener' => T_COLON, @@ -178,7 +178,7 @@ public static function dataNotEnumCases() ], 'testCloserMarker' => '/* testCaseConstantCloserMarker */', ], - 'switch case, body in curlies declares enum' => [ + 'switch case, body in curlies declares enum' => [ 'testMarker' => '/* testCaseInSwitchWhenCreatingEnumInSwitch1 */', 'expectedTokens' => [ 'scope_opener' => T_OPEN_CURLY_BRACKET, @@ -186,7 +186,7 @@ public static function dataNotEnumCases() ], 'testCloserMarker' => '/* testCaseInSwitchWhenCreatingEnumInSwitch1CloserMarker */', ], - 'switch case, body after semicolon declares enum' => [ + 'switch case, body after semicolon declares enum' => [ 'testMarker' => '/* testCaseInSwitchWhenCreatingEnumInSwitch2 */', 'expectedTokens' => [ 'scope_opener' => T_SEMICOLON, @@ -194,13 +194,20 @@ public static function dataNotEnumCases() ], 'testCloserMarker' => '/* testCaseInSwitchWhenCreatingEnumInSwitch2CloserMarker */', ], - 'switch case, shared closer with switch' => [ + 'switch case, shared closer with switch' => [ 'testMarker' => '/* testSwitchCaseScopeCloserSharedWithSwitch */', 'expectedTokens' => [ 'scope_opener' => T_COLON, 'scope_closer' => T_ENDSWITCH, ], ], + 'switch case, nested inline if/elseif/else with and without braces' => [ + 'testMarker' => '/* testSwitchCaseNestedIfWithAndWithoutBraces */', + 'expectedTokens' => [ + 'scope_opener' => T_COLON, + 'scope_closer' => T_BREAK, + ], + ], ]; }//end dataNotEnumCases() From 105b4bec79443173d1a10a598614b1537cef42f7 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 12 Aug 2024 17:16:12 -0300 Subject: [PATCH 869/874] Tests/Tokenizer: test related to setting the scope for T_CASE This commit copies a sniff test from InlineControlStructureUnitTest.php to the Tokenizer::recurseScopeMap() tests for the `case` keyword. The copied test was added in 65ef053 before the Tokenizer tests were created. It ensures that the scope for the `T_CASE` token is correctly set when there is an inline control structure inside it with more than three lines. The original sniff test was modified to use `T_FOR` instead of `T_SWITCH`, but its purpose was not altered. The test is about adding braces to an `if` that returns a nested function call. --- .../InlineControlStructureUnitTest.1.inc | 20 +++++++++--------- ...InlineControlStructureUnitTest.1.inc.fixed | 21 ++++++++++--------- .../InlineControlStructureUnitTest.php | 3 ++- ...curseScopeMapCaseKeywordConditionsTest.inc | 13 ++++++++++++ ...curseScopeMapCaseKeywordConditionsTest.php | 7 +++++++ 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc index c7b2a939b6..ada26fb7ff 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc @@ -201,16 +201,16 @@ if (true) catch(Exception $e) { } -switch ($num) { - case 0: - if (1 > $num) - return bar( - baz( - "foobarbaz" - ) - ); - break; -} +for ($i = 0; $i <= 4; $i++) + if ($i % 2) + return bar( + baz( + "foobarbaz" + ) + ); + + + do { $i++; diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed index c6099f4a89..53c6f0952c 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed @@ -230,18 +230,19 @@ if (true) { } } -switch ($num) { - case 0: - if (1 > $num) { - return bar( - baz( - "foobarbaz" - ) - ); - } - break; +for ($i = 0; $i <= 4; $i++) { + if ($i % 2) { + return bar( + baz( + "foobarbaz" + ) + ); + } } + + + do { $i++; } diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index 19c78e0f96..22eeb075cc 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -70,7 +70,8 @@ public function getErrorList($testFile='') 191 => 1, 195 => 1, 198 => 1, - 206 => 1, + 204 => 1, + 205 => 1, 222 => 1, 232 => 1, 235 => 1, diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc index 6c71d80db0..8df21a6c35 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc @@ -117,3 +117,16 @@ switch ($type) { } break; } + +// Test for https://github.com/squizlabs/PHP_CodeSniffer/issues/1590 +switch ($num) { + /* testSwitchCaseNestedInlineIfWithMoreThanThreeLines */ + case 0: + if (1 > $num) + return bar( + baz( + "foobarbaz" + ) + ); + break; +} diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php index 8b651c6d43..a4f3c3f089 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php @@ -208,6 +208,13 @@ public static function dataNotEnumCases() 'scope_closer' => T_BREAK, ], ], + 'switch case, nested inline if' => [ + 'testMarker' => '/* testSwitchCaseNestedInlineIfWithMoreThanThreeLines */', + 'expectedTokens' => [ + 'scope_opener' => T_COLON, + 'scope_closer' => T_BREAK, + ], + ], ]; }//end dataNotEnumCases() From c06284d42e7b3a7bfbdd9b2161c594a92b4f9714 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 01:58:53 +0000 Subject: [PATCH 870/874] Squiz/FileComment: update year in test case fixed file --- .../Squiz/Tests/Commenting/FileCommentUnitTest.1.inc.fixed | 2 +- .../Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.inc.fixed b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.inc.fixed index f584c55276..dbf8865458 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.inc.fixed @@ -25,7 +25,7 @@ * @author * @copyright 1997 Squiz Pty Ltd (ABN 77 084 670 600) * @copyright 1994-1997 Squiz Pty Ltd (ABN 77 084 670 600) -* @copyright 2024 Squiz Pty Ltd (ABN 77 084 670 600) +* @copyright 2025 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://www.php.net/license/3_0.txt * @summary An unknown summary tag * diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed index c7f54ffdf9..44ff449ac3 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed @@ -25,7 +25,7 @@ * @author * @copyright 1997 Squiz Pty Ltd (ABN 77 084 670 600) * @copyright 1994-1997 Squiz Pty Ltd (ABN 77 084 670 600) -* @copyright 2024 Squiz Pty Ltd (ABN 77 084 670 600) +* @copyright 2025 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://www.php.net/license/3_0.txt * @summary An unknown summary tag * From 73e80893e783be9d88e274a1926b182f017e37a4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 10 Jan 2025 09:33:05 +0100 Subject: [PATCH 871/874] Tokenizer/PHP: prevent an "Undefined array key" notice during live coding During live coding or for code containing a parse error, it was possible for the tokenizer to run into an `Undefined array key "parenthesis_closer"` error when trying to verify arrow functions. As this error happens during the tokenization, this resulted in PHPCS silently not scanning the file - without even showing the error notice. Fixed now. Includes tests. --- src/Tokenizers/PHP.php | 7 ++- .../PHP/BackfillFnTokenParseErrorTest.inc | 5 +++ .../PHP/BackfillFnTokenParseErrorTest.php | 44 +++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/Core/Tokenizers/PHP/BackfillFnTokenParseErrorTest.inc create mode 100644 tests/Core/Tokenizers/PHP/BackfillFnTokenParseErrorTest.php diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 9c6c11e4c3..c6b8e29065 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -2817,7 +2817,10 @@ protected function processAdditional() } } - if (isset($this->tokens[$x]) === true && $this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) { + if (isset($this->tokens[$x]) === true + && $this->tokens[$x]['code'] === T_OPEN_PARENTHESIS + && isset($this->tokens[$x]['parenthesis_closer']) === true + ) { $ignore = Tokens::$emptyTokens; $ignore += [ T_ARRAY => T_ARRAY, @@ -2995,7 +2998,7 @@ protected function processAdditional() }//end if }//end if - // If after all that, the extra tokens are not set, this is not an arrow function. + // If after all that, the extra tokens are not set, this is not a (valid) arrow function. if (isset($this->tokens[$i]['scope_closer']) === false) { if (PHP_CODESNIFFER_VERBOSITY > 1) { $line = $this->tokens[$i]['line']; diff --git a/tests/Core/Tokenizers/PHP/BackfillFnTokenParseErrorTest.inc b/tests/Core/Tokenizers/PHP/BackfillFnTokenParseErrorTest.inc new file mode 100644 index 0000000000..ce247e991b --- /dev/null +++ b/tests/Core/Tokenizers/PHP/BackfillFnTokenParseErrorTest.inc @@ -0,0 +1,5 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizers\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizers\AbstractTokenizerTestCase; + +final class BackfillFnTokenParseErrorTest extends AbstractTokenizerTestCase +{ + + + /** + * Verify that un unfinished arrow function during live coding doesn't cause a "Undefined array key "parenthesis_closer"" error. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testUnfinishedArrowFunction() + { + $tokens = $this->phpcsFile->getTokens(); + + $token = $this->getTargetToken('/* testLiveCoding */', [T_STRING, T_FN], 'fn'); + $tokenArray = $tokens[$token]; + + $this->assertSame('T_STRING', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING'); + + $this->assertArrayNotHasKey('scope_condition', $tokenArray, 'Scope condition is set'); + $this->assertArrayNotHasKey('scope_opener', $tokenArray, 'Scope opener is set'); + $this->assertArrayNotHasKey('scope_closer', $tokenArray, 'Scope closer is set'); + $this->assertArrayNotHasKey('parenthesis_owner', $tokenArray, 'Parenthesis owner is set'); + $this->assertArrayNotHasKey('parenthesis_opener', $tokenArray, 'Parenthesis opener is set'); + $this->assertArrayNotHasKey('parenthesis_closer', $tokenArray, 'Parenthesis closer is set'); + + }//end testUnfinishedArrowFunction() + + +}//end class From d74714d330321fca93c5fc5493f8d7bb4cdcca14 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Sun, 22 Sep 2024 21:08:19 +0100 Subject: [PATCH 872/874] Fix fixer conflict: PSR12/Squiz.Functions.FunctionDeclarationArgumentSpacing This commit resolves the a fixer conflict between `Squiz.Functions.FunctionDeclarationArgumentSpacing` and `Squiz.WhiteSpace.SuperfluousWhitespace`. This is done by changing the logic within the `FunctionDeclarationArgumentSpacing` sniff to no longer look at (the length of) only one `T_WHITESPACE` token, but instead consider all `T_WHITESPACE` tokens between the type and parameter tokens, and validate on their content (not just length). As part of this, the error message has been changed slightly in some circumstances. The error code has not been changed. * When there are only space characters between the two tokens, the error message remains unchanged. * When there are tabs or newlines included between the two tokens, these are rendered as part of the error message. --- ...unctionDeclarationArgumentSpacingSniff.php | 34 +++++++++++++------ ...tionDeclarationArgumentSpacingUnitTest.inc | 4 +++ ...clarationArgumentSpacingUnitTest.inc.fixed | 2 ++ ...tionDeclarationArgumentSpacingUnitTest.php | 1 + 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php index 7357a507e0..11cdba8d2e 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php @@ -11,6 +11,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Common; use PHP_CodeSniffer\Util\Tokens; class FunctionDeclarationArgumentSpacingSniff implements Sniff @@ -235,26 +236,37 @@ public function processBracket($phpcsFile, $openBracket) if ($param['type_hint_token'] !== false) { $typeHintToken = $param['type_hint_end_token']; - $gap = 0; - if ($tokens[($typeHintToken + 1)]['code'] === T_WHITESPACE) { - $gap = $tokens[($typeHintToken + 1)]['length']; + $gap = ''; + $i = $typeHintToken; + while ($tokens[++$i]['code'] === T_WHITESPACE) { + $gap .= $tokens[$i]['content']; } - if ($gap !== 1) { + if ($gap !== ' ') { $error = 'Expected 1 space between type hint and argument "%s"; %s found'; $data = [ $param['name'], - $gap, ]; - $fix = $phpcsFile->addFixableError($error, $typeHintToken, 'SpacingAfterHint', $data); + if (trim($gap, ' ') === '') { + // Gap contains only space characters: report the number of spaces. + $data[] = strlen($gap); + } else { + // Gap contains more than just spaces: render these for better clarity. + $data[] = '"'.Common::prepareForOutput($gap).'"'; + } + + $fix = $phpcsFile->addFixableError($error, $typeHintToken, 'SpacingAfterHint', $data); if ($fix === true) { - if ($gap === 0) { - $phpcsFile->fixer->addContent($typeHintToken, ' '); - } else { - $phpcsFile->fixer->replaceToken(($typeHintToken + 1), ' '); + $phpcsFile->fixer->beginChangeset(); + $phpcsFile->fixer->addContent($typeHintToken, ' '); + + for ($i = ($typeHintToken + 1); $tokens[$i]['code'] === T_WHITESPACE; $i++) { + $phpcsFile->fixer->replaceToken($i, ''); } + + $phpcsFile->fixer->endChangeset(); } - } + }//end if }//end if $commaToken = false; diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc index 33564e2e0b..07a6d452f5 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc @@ -109,3 +109,7 @@ $a = function ($var1, $var2=false) use ( ) {}; fn ($a,$b = null) => $a($b); + +function multipleWhitespaceTokensAfterType(int + + $number) {} diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc.fixed index 68fb1c1c37..cb4265057c 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc.fixed @@ -109,3 +109,5 @@ $a = function ($var1, $var2=false) use ( ) {}; fn ($a, $b=null) => $a($b); + +function multipleWhitespaceTokensAfterType(int $number) {} diff --git a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php index 62ccfef2ec..391463bbea 100644 --- a/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php @@ -68,6 +68,7 @@ public function getErrorList() 106 => 1, 107 => 2, 111 => 3, + 113 => 1, ]; }//end getErrorList() From aebd84be8f7ab740cd00f8aaa361b3c9cc354255 Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sun, 12 Jan 2025 21:34:01 +0100 Subject: [PATCH 873/874] Squiz/FunctionSpacing: fixer is broken with doc comment on closing brace line (#784) The fixer in Squiz.WhiteSpace.FunctionSpacing gets confused when there is a doc comment on the closing brace line. Generally speaking this sniff doesn't care about other content on the same line as the function declaration. But in the case of a "trailing" docblock, this meant that the sniff was adding the new lines _within_ the doc block, which, in turn, meant it would still not see the "blank lines after" in the next loop, as the added lines would be seen as doc comment lines, not blank lines. Hence, the fixer conflict. Fixed now. --- .../Sniffs/WhiteSpace/FunctionSpacingSniff.php | 6 ++++++ .../Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc | 11 +++++++++++ .../WhiteSpace/FunctionSpacingUnitTest.1.inc.fixed | 14 ++++++++++++++ .../Tests/WhiteSpace/FunctionSpacingUnitTest.php | 1 + 4 files changed, 32 insertions(+) diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php index 01cbd647f7..c0cbed2268 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php @@ -149,6 +149,12 @@ public function process(File $phpcsFile, $stackPtr) // Allow for comments on the same line as the closer. for ($nextLineToken = ($closer + 1); $nextLineToken < $phpcsFile->numTokens; $nextLineToken++) { + // A doc comment belongs to the next statement and must not be on + // this line. + if ($tokens[$nextLineToken]['code'] === T_DOC_COMMENT_OPEN_TAG) { + break; + } + if ($tokens[$nextLineToken]['line'] !== $tokens[$closer]['line']) { break; } diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc index b03a0ed82c..581235e14c 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc @@ -582,3 +582,14 @@ echo 'this line belongs with the #3904 test'; function Foo() {} function bar($name){} echo 'this line belongs with the #3904 test'; + + +/** + * foo. + */ +function a() { +}/** + * foo. + */ +function b() { +} diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc.fixed b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc.fixed index 443824ca14..f1b979326a 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc.fixed +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc.fixed @@ -671,3 +671,17 @@ function Foo() {} function bar($name){} echo 'this line belongs with the #3904 test'; + + +/** + * foo. + */ +function a() { +} + + +/** + * foo. + */ +function b() { +} diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php index cc6d96d256..17c431ee4b 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php @@ -102,6 +102,7 @@ public function getErrorList($testFile='') 566 => 1, 580 => 2, 583 => 3, + 591 => 1, ]; case 'FunctionSpacingUnitTest.2.inc': From b7ebea1e8c70ed0cd0497fdbd38118208d611adb Mon Sep 17 00:00:00 2001 From: Jakub Trmota Date: Sun, 12 Jan 2025 22:00:06 +0100 Subject: [PATCH 874/874] Config: can use custom LocalFile object --- src/Config.php | 3 +++ src/Files/FileList.php | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index 2bcc78e6ec..ff28788764 100644 --- a/src/Config.php +++ b/src/Config.php @@ -52,6 +52,7 @@ * @property string $generator The documentation generator to use. * @property string $filter The filter to use for the run. * @property string[] $bootstrap One of more files to include before the run begins. + * @property string $localFile Custom LocalFile object to use in FileList. * @property int|string $reportWidth The maximum number of columns that reports should use for output. * Set to "auto" for have this value changed to the width of the terminal. * @property int $errorSeverity The minimum severity an error must have to be displayed. @@ -138,6 +139,7 @@ class Config 'generator' => null, 'filter' => null, 'bootstrap' => null, + 'localFile' => null, 'reports' => null, 'basepath' => null, 'reportWidth' => null, @@ -540,6 +542,7 @@ public function restoreDefaults() $this->generator = null; $this->filter = null; $this->bootstrap = []; + $this->localFile = null; $this->basepath = null; $this->reports = ['full' => null]; $this->reportWidth = 'auto'; diff --git a/src/Files/FileList.php b/src/Files/FileList.php index ab52e33888..70156fdcc4 100644 --- a/src/Files/FileList.php +++ b/src/Files/FileList.php @@ -17,6 +17,7 @@ use PHP_CodeSniffer\Autoload; use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Exceptions\DeepExitException; +use PHP_CodeSniffer\Exceptions\RuntimeException; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Util\Common; use RecursiveArrayIterator; @@ -194,7 +195,16 @@ public function current() { $path = key($this->files); if (isset($this->files[$path]) === false) { - $this->files[$path] = new LocalFile($path, $this->ruleset, $this->config); + if ($this->config->localFile === null) { + $this->files[$path] = new LocalFile($path, $this->ruleset, $this->config); + } else { + $localFileClass = $this->config->localFile; + if (is_a($localFileClass, '\PHP_CodeSniffer\Files\LocalFile', true) === false) { + throw new RuntimeException('Custom LocalFile class '.$localFileClass.' is not a subtype of PHP_CodeSniffer\Files\LocalFile.'); + } + + $this->files[$path] = new $localFileClass($path, $this->ruleset, $this->config); + } } return $this->files[$path];