From d1e1331defb50a68b811ca3183a0d4fc2a1e4892 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Fri, 31 May 2024 18:48:13 +0200 Subject: [PATCH] Bump all dependencies to current ones Explicit: - Moodle CS v3.4.7 - PHP Compatibility 96072c30 Implicit: - PHP CodeSniffer 3.10.1 - PHPCS Utils 1.0.12 --- composer.json | 4 +- composer.lock | 46 +- readme_moodle.txt | 9 +- thirdpartylibs.xml | 8 +- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 8 +- vendor/composer/autoload_static.php | 8 +- vendor/composer/installed.json | 50 +- vendor/composer/installed.php | 24 +- vendor/moodlehq/moodle-cs/composer.json | 4 +- .../moodle-cs/docs/ReleaseNewVersion.md | 34 + .../Commenting/ConstructorReturnSniff.php | 120 ++ .../Commenting/MissingDocblockSniff.php | 14 +- .../PHPUnit/ParentSetUpTearDownSniff.php | 237 +++ .../moodle-cs/moodle/Util/Attributes.php | 111 ++ ...RemovedImplicitlyNullableParamStandard.xml | 34 + ...vedOptionalBeforeRequiredParamStandard.xml | 60 + .../Sniffs/Classes/NewClassesSniff.php | 76 +- .../Classes/NewReadonlyClassesSniff.php | 49 +- .../Classes/NewTypedPropertiesSniff.php | 2 +- .../Sniffs/Classes/RemovedClassesSniff.php | 4 +- .../Constants/NewMagicClassConstantSniff.php | 6 + .../RemovedImplicitlyNullableParamSniff.php | 147 ++ ...emovedOptionalBeforeRequiredParamSniff.php | 151 +- .../Interfaces/InternalInterfacesSniff.php | 76 +- .../Sniffs/Interfaces/NewInterfacesSniff.php | 77 +- ...ewNumberFormatMultibyteSeparatorsSniff.php | 4 +- .../Sniffs/Syntax/NewArrayUnpackingSniff.php | 27 +- .../Syntax/NewFlexibleHeredocNowdocSniff.php | 2 +- .../php-compatibility/README.md | 4 +- .../php-compatibility/composer.json | 5 +- vendor/phpcsstandards/phpcsutils/CHANGELOG.md | 73 +- .../PHPCSUtils/BackCompat/BCFile.php | 30 +- .../PHPCSUtils/BackCompat/BCTokens.php | 2 +- .../TestUtils/UtilityMethodTestCase.php | 2 +- .../PHPCSUtils/Tokens/Collections.php | 50 +- .../phpcsutils/PHPCSUtils/Utils/Context.php | 2 +- .../PHPCSUtils/Utils/ControlStructures.php | 4 +- .../PHPCSUtils/Utils/FunctionDeclarations.php | 19 + .../PHPCSUtils/Utils/NamingConventions.php | 2 +- .../PHPCSUtils/Utils/PassedParameters.php | 7 +- .../PHPCSUtils/Utils/UseStatements.php | 8 +- vendor/phpcsstandards/phpcsutils/README.md | 6 +- .../phpcsstandards/phpcsutils/composer.json | 5 +- vendor/squizlabs/php_codesniffer/CHANGELOG.md | 1548 ++++++++++++----- vendor/squizlabs/php_codesniffer/README.md | 18 +- vendor/squizlabs/php_codesniffer/autoload.php | 4 +- .../squizlabs/php_codesniffer/composer.json | 3 + .../squizlabs/php_codesniffer/src/Config.php | 131 +- .../php_codesniffer/src/Files/File.php | 191 +- .../squizlabs/php_codesniffer/src/Fixer.php | 2 +- .../php_codesniffer/src/Reporter.php | 2 +- .../squizlabs/php_codesniffer/src/Ruleset.php | 13 +- .../EmptyPHPStatementStandard.xml | 6 +- .../Docs/Commenting/DocCommentStandard.xml | 269 +++ .../Sniffs/Arrays/ArrayIndentSniff.php | 14 +- .../Arrays/DisallowLongArraySyntaxSniff.php | 14 +- .../CodeAnalysis/EmptyPHPStatementSniff.php | 8 +- .../CodeAnalysis/JumbledIncrementerSniff.php | 10 +- .../DisallowYodaConditionsSniff.php | 27 +- .../InlineControlStructureSniff.php | 2 +- .../Sniffs/Debug/ClosureLinterSniff.php | 2 +- .../Generic/Sniffs/Debug/ESLintSniff.php | 2 +- .../Generic/Sniffs/Debug/JSHintSniff.php | 2 +- .../CallTimePassByReferenceSniff.php | 14 +- .../Generic/Sniffs/PHP/LowerCaseTypeSniff.php | 110 +- .../Tests/Arrays/ArrayIndentUnitTest.inc | 3 + .../Arrays/ArrayIndentUnitTest.inc.fixed | 3 + .../DisallowLongArraySyntaxUnitTest.1.inc | 9 +- ...isallowLongArraySyntaxUnitTest.1.inc.fixed | 7 +- .../DisallowLongArraySyntaxUnitTest.3.inc | 7 + .../DisallowLongArraySyntaxUnitTest.php | 4 + .../EmptyPHPStatementUnitTest.inc | 6 +- .../EmptyPHPStatementUnitTest.inc.fixed | 6 +- .../JumbledIncrementerUnitTest.1.inc | 89 + .../JumbledIncrementerUnitTest.2.inc | 8 + .../JumbledIncrementerUnitTest.3.inc | 6 + .../JumbledIncrementerUnitTest.4.inc | 8 + .../JumbledIncrementerUnitTest.inc | 25 - .../JumbledIncrementerUnitTest.php | 27 +- .../DisallowYodaConditionsUnitTest.inc | 12 + .../DisallowYodaConditionsUnitTest.php | 5 + .../InlineControlStructureUnitTest.1.inc | 4 + ...InlineControlStructureUnitTest.1.inc.fixed | 5 + .../InlineControlStructureUnitTest.js | 4 + .../InlineControlStructureUnitTest.js.fixed | 5 + .../InlineControlStructureUnitTest.php | 2 + .../Generic/Tests/Debug/ESLintUnitTest.php | 2 + ...tTest.inc => SpaceAfterCastUnitTest.1.inc} | 5 + ...xed => SpaceAfterCastUnitTest.1.inc.fixed} | 5 + .../Formatting/SpaceAfterCastUnitTest.2.inc | 3 + .../Formatting/SpaceAfterCastUnitTest.php | 93 +- ...itTest.inc => SpaceAfterNotUnitTest.1.inc} | 0 ...ixed => SpaceAfterNotUnitTest.1.inc.fixed} | 0 .../Formatting/SpaceAfterNotUnitTest.2.inc | 7 + .../Formatting/SpaceAfterNotUnitTest.php | 2 +- ... => CallTimePassByReferenceUnitTest.1.inc} | 27 + .../CallTimePassByReferenceUnitTest.2.inc | 7 + .../CallTimePassByReferenceUnitTest.3.inc | 7 + .../CallTimePassByReferenceUnitTest.php | 33 +- .../Tests/PHP/LowerCaseTypeUnitTest.inc | 14 + .../Tests/PHP/LowerCaseTypeUnitTest.inc.fixed | 14 + .../Tests/PHP/LowerCaseTypeUnitTest.php | 8 +- .../WhiteSpace/ScopeIndentUnitTest.1.inc | 35 + .../ScopeIndentUnitTest.1.inc.fixed | 35 + .../WhiteSpace/ScopeIndentUnitTest.2.inc | 35 + .../ScopeIndentUnitTest.2.inc.fixed | 35 + .../Tests/WhiteSpace/ScopeIndentUnitTest.php | 8 +- .../Functions/FunctionDeclarationSniff.php | 35 +- .../WhiteSpace/ScopeClosingBraceSniff.php | 23 +- ....inc => FunctionDeclarationUnitTest.1.inc} | 0 ...> FunctionDeclarationUnitTest.1.inc.fixed} | 0 .../FunctionDeclarationUnitTest.2.inc | 7 + .../Functions/FunctionDeclarationUnitTest.php | 15 +- .../WhiteSpace/ScopeClosingBraceUnitTest.inc | 6 + .../ScopeClosingBraceUnitTest.inc.fixed | 7 + .../WhiteSpace/ScopeClosingBraceUnitTest.php | 1 + .../WhiteSpace/ScopeIndentUnitTest.inc.fixed | 314 ++++ .../src/Standards/PSR12/ruleset.xml | 2 +- .../Sniffs/Classes/ClassDeclarationSniff.php | 13 +- .../Sniffs/Namespaces/UseDeclarationSniff.php | 4 +- .../Classes/ClassDeclarationUnitTest.inc | 34 + .../ClassDeclarationUnitTest.inc.fixed | 35 + .../Classes/ClassDeclarationUnitTest.php | 2 + .../FunctionClosingBraceSpaceStandard.xml | 73 + .../Sniffs/CSS/SemicolonSpacingSniff.php | 4 +- .../Classes/SelfMemberReferenceSniff.php | 2 +- .../ClosingDeclarationCommentSniff.php | 16 +- .../LongConditionClosingCommentSniff.php | 2 +- .../ForLoopDeclarationSniff.php | 4 +- .../Squiz/Sniffs/Debug/JSLintSniff.php | 2 +- .../Sniffs/Debug/JavaScriptLintSniff.php | 2 +- .../Sniffs/Strings/EchoedStringsSniff.php | 2 +- .../WhiteSpace/OperatorSpacingSniff.php | 36 +- .../WhiteSpace/SemicolonSpacingSniff.php | 2 +- ...> ClosingDeclarationCommentUnitTest.1.inc} | 38 + ...ingDeclarationCommentUnitTest.1.inc.fixed} | 32 + .../ClosingDeclarationCommentUnitTest.2.inc | 7 + .../ClosingDeclarationCommentUnitTest.3.inc | 7 + .../ClosingDeclarationCommentUnitTest.4.inc | 8 + ...singDeclarationCommentUnitTest.4.inc.fixed | 8 + .../ClosingDeclarationCommentUnitTest.5.inc | 11 + ...singDeclarationCommentUnitTest.5.inc.fixed | 11 + .../ClosingDeclarationCommentUnitTest.php | 61 +- ...t.inc => ForLoopDeclarationUnitTest.1.inc} | 5 +- ...=> ForLoopDeclarationUnitTest.1.inc.fixed} | 5 +- .../ForLoopDeclarationUnitTest.2.inc | 6 + .../ForLoopDeclarationUnitTest.3.inc | 6 + .../ForLoopDeclarationUnitTest.js | 2 +- .../ForLoopDeclarationUnitTest.js.fixed | 2 +- .../ForLoopDeclarationUnitTest.php | 7 +- .../WhiteSpace/OperatorSpacingUnitTest.1.inc | 27 +- .../OperatorSpacingUnitTest.1.inc.fixed | 25 +- .../WhiteSpace/OperatorSpacingUnitTest.3.inc | 6 + .../WhiteSpace/OperatorSpacingUnitTest.php | 6 + .../ScopeKeywordSpacingUnitTest.1.inc | 2 +- .../ScopeKeywordSpacingUnitTest.1.inc.fixed | 2 +- .../WhiteSpace/SemicolonSpacingUnitTest.inc | 4 +- .../SemicolonSpacingUnitTest.inc.fixed | 4 +- .../Zend/Sniffs/Debug/CodeAnalyzerSniff.php | 2 +- .../php_codesniffer/src/Tokenizers/CSS.php | 2 +- .../src/Tokenizers/Comment.php | 24 +- .../php_codesniffer/src/Tokenizers/JS.php | 2 +- .../php_codesniffer/src/Tokenizers/PHP.php | 204 ++- .../src/Tokenizers/Tokenizer.php | 2 +- .../php_codesniffer/src/Util/Common.php | 14 + .../php_codesniffer/src/Util/Help.php | 626 +++++++ .../php_codesniffer/src/Util/Tokens.php | 2 + .../Core/Config/SniffsExcludeArgsTest.php | 200 +++ .../Core/File/FindEndOfStatementTest.php | 37 + .../Core/File/FindStartOfStatementTest.inc | 46 +- .../Core/File/FindStartOfStatementTest.php | 337 +++- .../Core/File/GetMemberPropertiesTest.inc | 15 + .../Core/File/GetMemberPropertiesTest.php | 52 + .../Core/File/GetMethodParametersTest.inc | 17 + .../Core/File/GetMethodParametersTest.php | 157 +- .../Core/File/GetMethodPropertiesTest.inc | 31 + .../Core/File/GetMethodPropertiesTest.php | 235 +++ .../tests/Core/File/IsReferenceTest.inc | 6 + .../tests/Core/File/IsReferenceTest.php | 42 +- .../Tokenizer/Comment/CommentTestCase.php | 117 ++ .../Tokenizer/Comment/LiveCoding1Test.inc | 6 + .../Tokenizer/Comment/LiveCoding1Test.php | 69 + .../Tokenizer/Comment/LiveCoding2Test.inc | 5 + .../Tokenizer/Comment/LiveCoding2Test.php | 68 + .../Tokenizer/Comment/LiveCoding3Test.inc | 4 + .../Tokenizer/Comment/LiveCoding3Test.php | 62 + .../Tokenizer/Comment/LiveCoding4Test.inc | 7 + .../Tokenizer/Comment/LiveCoding4Test.php | 76 + .../Comment/MultiLineDocBlockTest.inc | 81 + .../Comment/MultiLineDocBlockTest.php | 439 +++++ .../PhpcsAnnotationsInDocBlockTest.inc | 116 ++ .../PhpcsAnnotationsInDocBlockTest.php | 637 +++++++ .../Comment/SingleLineDocBlockTest.inc | 26 + .../Comment/SingleLineDocBlockTest.php | 217 +++ .../OtherContextSensitiveKeywordsTest.inc | 67 - .../OtherContextSensitiveKeywordsTest.php | 283 --- .../AnonClassParenthesisOwnerTest.inc | 0 .../AnonClassParenthesisOwnerTest.php | 4 +- .../Tokenizer/{ => PHP}/ArrayKeywordTest.inc | 17 + .../Tokenizer/{ => PHP}/ArrayKeywordTest.php | 37 +- .../Tokenizer/{ => PHP}/AttributesTest.inc | 0 .../Tokenizer/{ => PHP}/AttributesTest.php | 4 +- .../Tokenizer/{ => PHP}/BackfillEnumTest.inc | 0 .../Tokenizer/{ => PHP}/BackfillEnumTest.php | 4 +- .../BackfillExplicitOctalNotationTest.inc | 0 .../BackfillExplicitOctalNotationTest.php | 6 +- .../{ => PHP}/BackfillFnTokenTest.inc | 30 + .../{ => PHP}/BackfillFnTokenTest.php | 225 ++- .../{ => PHP}/BackfillMatchTokenTest.inc | 0 .../{ => PHP}/BackfillMatchTokenTest.php | 3 +- .../BackfillNumericSeparatorTest.inc | 0 .../BackfillNumericSeparatorTest.php | 3 +- .../{ => PHP}/BackfillReadonlyTest.inc | 0 .../{ => PHP}/BackfillReadonlyTest.php | 4 +- .../Tokenizer/{ => PHP}/BitwiseOrTest.inc | 13 + .../Tokenizer/{ => PHP}/BitwiseOrTest.php | 43 +- .../ContextSensitiveKeywordsTest.inc | 7 + .../ContextSensitiveKeywordsTest.php | 8 +- .../Tokenizer/PHP/DNFTypesParseError1Test.inc | 17 + .../Tokenizer/PHP/DNFTypesParseError1Test.php | 69 + .../Tokenizer/PHP/DNFTypesParseError2Test.inc | 48 + .../Tokenizer/PHP/DNFTypesParseError2Test.php | 218 +++ .../tests/Core/Tokenizer/PHP/DNFTypesTest.inc | 193 ++ .../tests/Core/Tokenizer/PHP/DNFTypesTest.php | 450 +++++ .../{ => PHP}/DefaultKeywordTest.inc | 0 .../Core/Tokenizer/PHP/DefaultKeywordTest.php | 255 +++ .../Tokenizer/{ => PHP}/DoubleArrowTest.inc | 0 .../Tokenizer/{ => PHP}/DoubleArrowTest.php | 4 +- .../{ => PHP}/DoubleQuotedStringTest.inc | 0 .../{ => PHP}/DoubleQuotedStringTest.php | 4 +- .../Core/Tokenizer/{ => PHP}/EnumCaseTest.inc | 0 .../Core/Tokenizer/{ => PHP}/EnumCaseTest.php | 14 +- .../Core/Tokenizer/{ => PHP}/FinallyTest.inc | 0 .../Core/Tokenizer/{ => PHP}/FinallyTest.php | 4 +- .../Tokenizer/{ => PHP}/GotoLabelTest.inc | 0 .../Tokenizer/{ => PHP}/GotoLabelTest.php | 4 +- .../Tokenizer/{ => PHP}/HeredocStringTest.inc | 0 .../Tokenizer/{ => PHP}/HeredocStringTest.php | 4 +- .../NamedFunctionCallArgumentsTest.inc | 0 .../NamedFunctionCallArgumentsTest.php | 3 +- .../{ => PHP}/NullsafeObjectOperatorTest.inc | 0 .../{ => PHP}/NullsafeObjectOperatorTest.php | 3 +- .../PHP/OtherContextSensitiveKeywordsTest.inc | 247 +++ .../PHP/OtherContextSensitiveKeywordsTest.php | 721 ++++++++ .../{ => PHP}/ResolveSimpleTokenTest.inc | 0 .../{ => PHP}/ResolveSimpleTokenTest.php | 3 +- .../Tokenizer/{ => PHP}/ShortArrayTest.inc | 0 .../Tokenizer/{ => PHP}/ShortArrayTest.php | 4 +- .../{ => PHP}/StableCommentWhitespaceTest.inc | 0 .../{ => PHP}/StableCommentWhitespaceTest.php | 3 +- .../StableCommentWhitespaceWinTest.inc | 0 .../StableCommentWhitespaceWinTest.php | 3 +- .../{ => PHP}/TypeIntersectionTest.inc | 14 + .../{ => PHP}/TypeIntersectionTest.php | 47 +- .../{ => PHP}/TypedConstantsTest.inc | 24 + .../{ => PHP}/TypedConstantsTest.php | 161 +- .../UndoNamespacedNameSingleTokenTest.inc | 0 .../UndoNamespacedNameSingleTokenTest.php | 3 +- ...reateParenthesisNestingMapDNFTypesTest.inc | 185 ++ ...reateParenthesisNestingMapDNFTypesTest.php | 375 ++++ .../CreateTokenMapArrayParenthesesTest.inc | 58 + .../CreateTokenMapArrayParenthesesTest.php | 212 +++ .../HeredocNowdocCloserTest.inc | 0 .../HeredocNowdocCloserTest.php | 4 +- ...curseScopeMapCaseKeywordConditionsTest.inc | 95 + ...curseScopeMapCaseKeywordConditionsTest.php | 162 ++ ...seScopeMapDefaultKeywordConditionsTest.inc | 203 +++ ...eScopeMapDefaultKeywordConditionsTest.php} | 16 +- .../ScopeSettingWithNamespaceOperatorTest.inc | 0 .../ScopeSettingWithNamespaceOperatorTest.php | 4 +- .../tests/Core/Util/HelpTest.php | 725 ++++++++ .../tests/Core/Util/StripColorsTest.php | 96 + .../tests/Core/Util/SuggestTypeTest.php | 4 +- .../php_codesniffer/tests/TestSuite7.php | 2 +- 275 files changed, 13198 insertions(+), 1764 deletions(-) create mode 100644 vendor/moodlehq/moodle-cs/docs/ReleaseNewVersion.md create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/ConstructorReturnSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/ParentSetUpTearDownSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Util/Attributes.php create mode 100644 vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/FunctionDeclarations/RemovedImplicitlyNullableParamStandard.xml create mode 100644 vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/FunctionDeclarations/RemovedOptionalBeforeRequiredParamStandard.xml create mode 100644 vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/RemovedImplicitlyNullableParamSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/Commenting/DocCommentStandard.xml create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.3.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.1.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.3.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.4.inc delete mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.inc rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/{SpaceAfterCastUnitTest.inc => SpaceAfterCastUnitTest.1.inc} (94%) rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/{SpaceAfterCastUnitTest.inc.fixed => SpaceAfterCastUnitTest.1.inc.fixed} (94%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.2.inc rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/{SpaceAfterNotUnitTest.inc => SpaceAfterNotUnitTest.1.inc} (100%) rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/{SpaceAfterNotUnitTest.inc.fixed => SpaceAfterNotUnitTest.1.inc.fixed} (100%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.2.inc rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/{CallTimePassByReferenceUnitTest.inc => CallTimePassByReferenceUnitTest.1.inc} (57%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.3.inc rename vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/{FunctionDeclarationUnitTest.inc => FunctionDeclarationUnitTest.1.inc} (100%) rename vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/{FunctionDeclarationUnitTest.inc.fixed => FunctionDeclarationUnitTest.1.inc.fixed} (100%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Docs/WhiteSpace/FunctionClosingBraceSpaceStandard.xml rename vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/{ClosingDeclarationCommentUnitTest.inc => ClosingDeclarationCommentUnitTest.1.inc} (58%) rename vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/{ClosingDeclarationCommentUnitTest.inc.fixed => ClosingDeclarationCommentUnitTest.1.inc.fixed} (59%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.3.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.4.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.4.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.5.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.5.inc.fixed rename vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/{ForLoopDeclarationUnitTest.inc => ForLoopDeclarationUnitTest.1.inc} (95%) rename vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/{ForLoopDeclarationUnitTest.inc.fixed => ForLoopDeclarationUnitTest.1.inc.fixed} (95%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.3.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.3.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Util/Help.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Config/SniffsExcludeArgsTest.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/CommentTestCase.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding1Test.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding1Test.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding2Test.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding2Test.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding3Test.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding3Test.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding4Test.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding4Test.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/MultiLineDocBlockTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/MultiLineDocBlockTest.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/PhpcsAnnotationsInDocBlockTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/PhpcsAnnotationsInDocBlockTest.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/SingleLineDocBlockTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/SingleLineDocBlockTest.php delete mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc delete mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.php rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/AnonClassParenthesisOwnerTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/AnonClassParenthesisOwnerTest.php (98%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/ArrayKeywordTest.inc (63%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/ArrayKeywordTest.php (83%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/AttributesTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/AttributesTest.php (99%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillEnumTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillEnumTest.php (98%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillExplicitOctalNotationTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillExplicitOctalNotationTest.php (97%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillFnTokenTest.inc (81%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillFnTokenTest.php (84%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillMatchTokenTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillMatchTokenTest.php (99%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillNumericSeparatorTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillNumericSeparatorTest.php (99%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillReadonlyTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BackfillReadonlyTest.php (99%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BitwiseOrTest.inc (89%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/BitwiseOrTest.php (76%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/ContextSensitiveKeywordsTest.inc (97%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/ContextSensitiveKeywordsTest.php (98%) create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesParseError1Test.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesParseError1Test.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesParseError2Test.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesParseError2Test.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesTest.php rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/DefaultKeywordTest.inc (100%) create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DefaultKeywordTest.php rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/DoubleArrowTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/DoubleArrowTest.php (99%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/DoubleQuotedStringTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/DoubleQuotedStringTest.php (98%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/EnumCaseTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/EnumCaseTest.php (89%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/FinallyTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/FinallyTest.php (96%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/GotoLabelTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/GotoLabelTest.php (97%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/HeredocStringTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/HeredocStringTest.php (98%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/NamedFunctionCallArgumentsTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/NamedFunctionCallArgumentsTest.php (99%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/NullsafeObjectOperatorTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/NullsafeObjectOperatorTest.php (97%) create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/OtherContextSensitiveKeywordsTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/OtherContextSensitiveKeywordsTest.php rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/ResolveSimpleTokenTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/ResolveSimpleTokenTest.php (98%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/ShortArrayTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/ShortArrayTest.php (98%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/StableCommentWhitespaceTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/StableCommentWhitespaceTest.php (99%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/StableCommentWhitespaceWinTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/StableCommentWhitespaceWinTest.php (96%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/TypeIntersectionTest.inc (88%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/TypeIntersectionTest.php (74%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/TypedConstantsTest.inc (82%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/TypedConstantsTest.php (75%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/UndoNamespacedNameSingleTokenTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => PHP}/UndoNamespacedNameSingleTokenTest.php (99%) create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateTokenMapArrayParenthesesTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateTokenMapArrayParenthesesTest.php rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => Tokenizer}/HeredocNowdocCloserTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => Tokenizer}/HeredocNowdocCloserTest.php (96%) create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.inc rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{DefaultKeywordTest.php => Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php} (95%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => Tokenizer}/ScopeSettingWithNamespaceOperatorTest.inc (100%) rename vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/{ => Tokenizer}/ScopeSettingWithNamespaceOperatorTest.php (97%) create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Util/HelpTest.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Util/StripColorsTest.php diff --git a/composer.json b/composer.json index cbe8db21..de42e103 100644 --- a/composer.json +++ b/composer.json @@ -5,8 +5,8 @@ "license": "GPL-3.0-or-later", "require": { "php": ">=7.4", - "moodlehq/moodle-cs": "^v3.4.6", - "phpcompatibility/php-compatibility": "dev-develop#e5cd2e24" + "moodlehq/moodle-cs": "^v3.4.7", + "phpcompatibility/php-compatibility": "dev-develop#96072c30" }, "config": { "platform": { diff --git a/composer.lock b/composer.lock index 2c100d32..d97745b9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a04f685b76dc383abef9d8fd22fb316f", + "content-hash": "557c6dacc8e1efaa1f0ff81060ceddb6", "packages": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -86,25 +86,25 @@ }, { "name": "moodlehq/moodle-cs", - "version": "v3.4.6", + "version": "v3.4.7", "source": { "type": "git", "url": "https://github.com/moodlehq/moodle-cs.git", - "reference": "02a279ecbd9431172e8eeee5385d4f6ec57c957b" + "reference": "4f1bc63551da69675d9f5d17efbf35a458ca3da8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/moodlehq/moodle-cs/zipball/02a279ecbd9431172e8eeee5385d4f6ec57c957b", - "reference": "02a279ecbd9431172e8eeee5385d4f6ec57c957b", + "url": "https://api.github.com/repos/moodlehq/moodle-cs/zipball/4f1bc63551da69675d9f5d17efbf35a458ca3da8", + "reference": "4f1bc63551da69675d9f5d17efbf35a458ca3da8", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", "ext-json": "*", "php": ">=7.4.0", - "phpcompatibility/php-compatibility": "dev-develop#e5cd2e24", + "phpcompatibility/php-compatibility": "dev-develop#96072c30", "phpcsstandards/phpcsextra": "^1.2.1", - "squizlabs/php_codesniffer": "^3.9.0" + "squizlabs/php_codesniffer": "^3.10.1" }, "replace": { "moodlehq/moodle-local_codechecker": "3.1.0" @@ -152,7 +152,7 @@ "source": "https://github.com/moodlehq/moodle-cs", "wiki": "https://github.com/moodlehq/moodle-cs/wiki" }, - "time": "2024-04-03T07:22:20+00:00" + "time": "2024-05-31T16:28:39+00:00" }, { "name": "phpcompatibility/php-compatibility", @@ -160,12 +160,12 @@ "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "e5cd2e24" + "reference": "96072c30" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/e5cd2e24", - "reference": "e5cd2e24", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/96072c30", + "reference": "96072c30", "shasum": "" }, "require": { @@ -242,7 +242,7 @@ "type": "open_collective" } ], - "time": "2024-04-08T09:51:59+00:00" + "time": "2024-04-30T23:24:59+00:00" }, { "name": "phpcsstandards/phpcsextra", @@ -324,22 +324,22 @@ }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.10", + "version": "1.0.12", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544" + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/51609a5b89f928e0c463d6df80eb38eff1eaf544", - "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.9.0 || 4.0.x-dev@dev" + "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" }, "require-dev": { "ext-filter": "*", @@ -408,20 +408,20 @@ "type": "open_collective" } ], - "time": "2024-03-17T23:44:50+00:00" + "time": "2024-05-20T13:34:27+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.1", + "version": "3.10.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" + "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/8f90f7a53ce271935282967f53d0894f8f1ff877", + "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877", "shasum": "" }, "require": { @@ -488,7 +488,7 @@ "type": "open_collective" } ], - "time": "2024-03-31T21:03:09+00:00" + "time": "2024-05-22T21:24:41+00:00" } ], "packages-dev": [], diff --git a/readme_moodle.txt b/readme_moodle.txt index 117c1043..39f8ac0c 100644 --- a/readme_moodle.txt +++ b/readme_moodle.txt @@ -32,12 +32,9 @@ To update any component: 3. Switch to the lowest PHP version supported by the Moodle version required. 4. Run `composer install` (to install everything).a 5. Update `thirdpartylibs.xml` to annotate the new versions of the tools. -6. Remove `vendor/moodlehq/moodle-cs/moodle/Tests`. Note that this step - will be removed once https://github.com/moodlehq/moodle-cs/pull/69 - is released and we update to that version. -7. Commit changes with details about the tools updated. -8. Test, test, test. -9. Optionally, release. +6. Commit changes with details about the tools updated. +7. Test, test, test. +8. Optionally, release. At some point we may want to make the process above automated, so every time that a new moodle-cs package is released, everything above (1-8) happens automatically. diff --git a/thirdpartylibs.xml b/thirdpartylibs.xml index 725258a4..1f685c45 100644 --- a/thirdpartylibs.xml +++ b/thirdpartylibs.xml @@ -3,14 +3,14 @@ vendor/squizlabs/php_codesniffer PHP_CodeSniffer - 3.9.1 + 3.10.1 BSD 3-Clause vendor/phpcompatibility/php-compatibility PHP Compatibility Coding Standard - 10.0dev (e5cd2e24) + 10.0dev (96072c30) LGPL 3 @@ -24,14 +24,14 @@ vendor/phpcsstandards/phpcsutils A suite of utility functions for use with PHP_CodeSniffer - 1.0.10 + 1.0.12 LGPL 3 vendor/moodlehq/moodle-cs Moodle Coding Style - v3.4.6 + v3.4.7 GPL 3 diff --git a/vendor/autoload.php b/vendor/autoload.php index 4649b6de..c772c200 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInita04f685b76dc383abef9d8fd22fb316f::getLoader(); +return ComposerAutoloaderInit557c6dacc8e1efaa1f0ff81060ceddb6::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 50896cb4..5a444cb8 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInita04f685b76dc383abef9d8fd22fb316f +class ComposerAutoloaderInit557c6dacc8e1efaa1f0ff81060ceddb6 { private static $loader; @@ -24,12 +24,12 @@ public static function getLoader() require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInita04f685b76dc383abef9d8fd22fb316f', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit557c6dacc8e1efaa1f0ff81060ceddb6', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInita04f685b76dc383abef9d8fd22fb316f', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit557c6dacc8e1efaa1f0ff81060ceddb6', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInita04f685b76dc383abef9d8fd22fb316f::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit557c6dacc8e1efaa1f0ff81060ceddb6::getInitializer($loader)); $loader->register(true); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 75c46c4b..355deead 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInita04f685b76dc383abef9d8fd22fb316f +class ComposerStaticInit557c6dacc8e1efaa1f0ff81060ceddb6 { public static $prefixLengthsPsr4 = array ( 'P' => @@ -72,9 +72,9 @@ class ComposerStaticInita04f685b76dc383abef9d8fd22fb316f public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInita04f685b76dc383abef9d8fd22fb316f::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInita04f685b76dc383abef9d8fd22fb316f::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInita04f685b76dc383abef9d8fd22fb316f::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit557c6dacc8e1efaa1f0ff81060ceddb6::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit557c6dacc8e1efaa1f0ff81060ceddb6::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit557c6dacc8e1efaa1f0ff81060ceddb6::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 2d13f719..2a74772b 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -83,26 +83,26 @@ }, { "name": "moodlehq/moodle-cs", - "version": "v3.4.6", - "version_normalized": "3.4.6.0", + "version": "v3.4.7", + "version_normalized": "3.4.7.0", "source": { "type": "git", "url": "https://github.com/moodlehq/moodle-cs.git", - "reference": "02a279ecbd9431172e8eeee5385d4f6ec57c957b" + "reference": "4f1bc63551da69675d9f5d17efbf35a458ca3da8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/moodlehq/moodle-cs/zipball/02a279ecbd9431172e8eeee5385d4f6ec57c957b", - "reference": "02a279ecbd9431172e8eeee5385d4f6ec57c957b", + "url": "https://api.github.com/repos/moodlehq/moodle-cs/zipball/4f1bc63551da69675d9f5d17efbf35a458ca3da8", + "reference": "4f1bc63551da69675d9f5d17efbf35a458ca3da8", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", "ext-json": "*", "php": ">=7.4.0", - "phpcompatibility/php-compatibility": "dev-develop#e5cd2e24", + "phpcompatibility/php-compatibility": "dev-develop#96072c30", "phpcsstandards/phpcsextra": "^1.2.1", - "squizlabs/php_codesniffer": "^3.9.0" + "squizlabs/php_codesniffer": "^3.10.1" }, "replace": { "moodlehq/moodle-local_codechecker": "3.1.0" @@ -116,7 +116,7 @@ "sebastian/phpcpd": "^6.0", "thor-juhasz/phpunit-coverage-check": "^0.3.0" }, - "time": "2024-04-03T07:22:20+00:00", + "time": "2024-05-31T16:28:39+00:00", "type": "phpcodesniffer-standard", "installation-source": "dist", "autoload": { @@ -161,12 +161,12 @@ "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "e5cd2e24" + "reference": "96072c30" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/e5cd2e24", - "reference": "e5cd2e24", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/96072c30", + "reference": "96072c30", "shasum": "" }, "require": { @@ -188,7 +188,7 @@ "suggest": { "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, - "time": "2024-04-08T09:51:59+00:00", + "time": "2024-04-30T23:24:59+00:00", "default-branch": true, "type": "phpcodesniffer-standard", "extra": { @@ -330,23 +330,23 @@ }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.10", - "version_normalized": "1.0.10.0", + "version": "1.0.12", + "version_normalized": "1.0.12.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544" + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/51609a5b89f928e0c463d6df80eb38eff1eaf544", - "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.9.0 || 4.0.x-dev@dev" + "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" }, "require-dev": { "ext-filter": "*", @@ -355,7 +355,7 @@ "phpcsstandards/phpcsdevcs": "^1.1.6", "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" }, - "time": "2024-03-17T23:44:50+00:00", + "time": "2024-05-20T13:34:27+00:00", "type": "phpcodesniffer-standard", "extra": { "branch-alias": { @@ -421,17 +421,17 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.1", - "version_normalized": "3.9.1.0", + "version": "3.10.1", + "version_normalized": "3.10.1.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" + "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/8f90f7a53ce271935282967f53d0894f8f1ff877", + "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877", "shasum": "" }, "require": { @@ -443,7 +443,7 @@ "require-dev": { "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, - "time": "2024-03-31T21:03:09+00:00", + "time": "2024-05-22T21:24:41+00:00", "bin": [ "bin/phpcbf", "bin/phpcs" diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 74a94136..fd29dbe8 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'moodlehq/local_codechecker', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '170623f935acd324534d4cd2265c866e80a131f1', + 'reference' => '6317d1361ee40d2ebcdc40c36b40cfa9fb3f98a9', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -22,16 +22,16 @@ 'moodlehq/local_codechecker' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '170623f935acd324534d4cd2265c866e80a131f1', + 'reference' => '6317d1361ee40d2ebcdc40c36b40cfa9fb3f98a9', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false, ), 'moodlehq/moodle-cs' => array( - 'pretty_version' => 'v3.4.6', - 'version' => '3.4.6.0', - 'reference' => '02a279ecbd9431172e8eeee5385d4f6ec57c957b', + 'pretty_version' => 'v3.4.7', + 'version' => '3.4.7.0', + 'reference' => '4f1bc63551da69675d9f5d17efbf35a458ca3da8', 'type' => 'phpcodesniffer-standard', 'install_path' => __DIR__ . '/../moodlehq/moodle-cs', 'aliases' => array(), @@ -46,7 +46,7 @@ 'phpcompatibility/php-compatibility' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'e5cd2e24', + 'reference' => '96072c30', 'type' => 'phpcodesniffer-standard', 'install_path' => __DIR__ . '/../phpcompatibility/php-compatibility', 'aliases' => array( @@ -64,18 +64,18 @@ 'dev_requirement' => false, ), 'phpcsstandards/phpcsutils' => array( - 'pretty_version' => '1.0.10', - 'version' => '1.0.10.0', - 'reference' => '51609a5b89f928e0c463d6df80eb38eff1eaf544', + 'pretty_version' => '1.0.12', + 'version' => '1.0.12.0', + 'reference' => '87b233b00daf83fb70f40c9a28692be017ea7c6c', 'type' => 'phpcodesniffer-standard', 'install_path' => __DIR__ . '/../phpcsstandards/phpcsutils', 'aliases' => array(), 'dev_requirement' => false, ), 'squizlabs/php_codesniffer' => array( - 'pretty_version' => '3.9.1', - 'version' => '3.9.1.0', - 'reference' => '267a4405fff1d9c847134db3a3c92f1ab7f77909', + 'pretty_version' => '3.10.1', + 'version' => '3.10.1.0', + 'reference' => '8f90f7a53ce271935282967f53d0894f8f1ff877', 'type' => 'library', 'install_path' => __DIR__ . '/../squizlabs/php_codesniffer', 'aliases' => array(), diff --git a/vendor/moodlehq/moodle-cs/composer.json b/vendor/moodlehq/moodle-cs/composer.json index db93c2d4..d1aad44b 100644 --- a/vendor/moodlehq/moodle-cs/composer.json +++ b/vendor/moodlehq/moodle-cs/composer.json @@ -25,9 +25,9 @@ "php": ">=7.4.0", "ext-json": "*", "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", - "squizlabs/php_codesniffer": "^3.9.0", + "squizlabs/php_codesniffer": "^3.10.1", "phpcsstandards/phpcsextra": "^1.2.1", - "phpcompatibility/php-compatibility": "dev-develop#e5cd2e24" + "phpcompatibility/php-compatibility": "dev-develop#96072c30" }, "config": { "allow-plugins": { diff --git a/vendor/moodlehq/moodle-cs/docs/ReleaseNewVersion.md b/vendor/moodlehq/moodle-cs/docs/ReleaseNewVersion.md new file mode 100644 index 00000000..e1c0dfec --- /dev/null +++ b/vendor/moodlehq/moodle-cs/docs/ReleaseNewVersion.md @@ -0,0 +1,34 @@ +# Releasing a new version + +This is a guide on how to release a new version of this project. Remember that +when considering the version number to use, that this project follows +[Semantic Versioning](http://semver.org/), so bump the version number accordingly. + +Also, note that, for the logs, we follow the [Keep a CHANGELOG](https://keepachangelog.com) +format (sections order, lists, ...) as much as possible. + +Prior to tagging a release, ensure the following have been updated: + +* The `CHANGELOG.md` needs to be up-to-date. In addition, the _Unreleased_ section + needs to be updated with the version being released. Also update the _Unreleased_ + link at the bottom with the new version number and add the new link there. + +When all the changes above have been performed and triple-checked, +**create a commit** (*"Prepare for vX.Y.Z release"*) and +**push it straight upstream** to `main`. + +Once all code and commits are in place and verified, you need to tag a +release. Tag `main` branch `HEAD` and push using commands (don't forget the +leading "`v`"): + +```bash +$ git tag -a vX.Y.Z -m "Release version vX.Y.Z" +$ git push origin vX.Y.Z +``` + +When the tag is pushed, GitHub release workflow will be triggered. Verify it has worked +correctly by navigating at [Releases](https://github.com/moodlehq/moodle-cs/releases). + +While in that page, optionally, you can edit the release and add any content +to the description, though **it's not recommended** because that may lead to +double release notifications here and there. diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/ConstructorReturnSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/ConstructorReturnSniff.php new file mode 100644 index 00000000..594cc7b9 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/ConstructorReturnSniff.php @@ -0,0 +1,120 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting; + +use MoodleHQ\MoodleCS\moodle\Util\Docblocks; +use MoodleHQ\MoodleCS\moodle\Util\TokenUtil; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + +/** + * Checks that all files an classes have appropriate docs. + * + * @copyright 2024 Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class ConstructorReturnSniff implements Sniff +{ + /** + * Register for class tags. + */ + public function register() { + + return [ + T_CLASS, + ]; + } + + /** + * Processes php files and perform various checks with file. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position in the stack. + */ + public function process(File $phpcsFile, $stackPtr) { + $tokens = $phpcsFile->getTokens(); + $endClassPtr = $tokens[$stackPtr]['scope_closer']; + + while ( + ($methodPtr = $phpcsFile->findNext(T_FUNCTION, $stackPtr + 1, $endClassPtr)) !== false + ) { + $this->processClassMethod($phpcsFile, $methodPtr); + $stackPtr = $methodPtr; + } + } + + /** + * Processes the class method. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position in the stack. + */ + protected function processClassMethod(File $phpcsFile, int $stackPtr): void { + $objectName = TokenUtil::getObjectName($phpcsFile, $stackPtr); + if ($objectName !== '__constructor') { + // We only care about constructors. + return; + } + + // Get docblock. + $docblockPtr = Docblocks::getDocBlockPointer($phpcsFile, $stackPtr); + if ($docblockPtr === null) { + // No docblocks for this constructor. + return; + } + + $returnTokens = Docblocks::getMatchingDocTags($phpcsFile, $docblockPtr, '@return'); + if (count($returnTokens) === 0) { + // No @return tag in the docblock. + return; + } + + $fix = $phpcsFile->addFixableError( + 'Constructor should not have a return tag in the docblock', + $returnTokens[0], + 'ConstructorReturn' + ); + if ($fix) { + $tokens = $phpcsFile->getTokens(); + $phpcsFile->fixer->beginChangeset(); + + // Find the tokens at the start and end of the line. + $lineStart = $phpcsFile->findFirstOnLine(T_DOC_COMMENT_STAR, $returnTokens[0]); + if ($lineStart === false) { + $lineStart = $returnTokens[0]; + } + + $ptr = $phpcsFile->findNext(T_DOC_COMMENT_WHITESPACE, $lineStart); + for ($lineEnd = $lineStart; $lineEnd < $tokens[$docblockPtr]['comment_closer']; $lineEnd++) { + if ($tokens[$lineEnd]['line'] !== $tokens[$lineStart]['line']) { + break; + } + } + + if ($tokens[$lineEnd]['code'] === T_DOC_COMMENT_CLOSE_TAG) { + $lineEnd--; + } + + for ($ptr = $lineStart; $ptr <= $lineEnd; $ptr++) { + $phpcsFile->fixer->replaceToken($ptr, ''); + } + + $phpcsFile->fixer->endChangeset(); + } + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/MissingDocblockSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/MissingDocblockSniff.php index 4467a067..8999a59a 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/MissingDocblockSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/MissingDocblockSniff.php @@ -17,6 +17,7 @@ namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting; +use MoodleHQ\MoodleCS\moodle\Util\Attributes; use MoodleHQ\MoodleCS\moodle\Util\Docblocks; use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; use MoodleHQ\MoodleCS\moodle\Util\TokenUtil; @@ -183,6 +184,17 @@ protected function processFunctions(File $phpcsFile, int $stackPtr): void { foreach ($missingDocblocks as $typePtr => $extendsOrImplements) { $token = $tokens[$typePtr]; + if ($extendsOrImplements) { + $attributes = Attributes::getAttributePointers($phpcsFile, $typePtr); + foreach ($attributes as $attributePtr) { + $attribute = Attributes::getAttributeProperties($phpcsFile, $attributePtr); + if ($attribute['attribute_name'] === '\Override') { + // Skip methods that are marked as overrides. + continue 2; + } + } + } + $objectName = TokenUtil::getObjectName($phpcsFile, $typePtr); $objectType = TokenUtil::getObjectType($phpcsFile, $typePtr); @@ -195,8 +207,6 @@ protected function processFunctions(File $phpcsFile, int $stackPtr): void { [$objectType, $objectName] ); } - } elseif ($extendsOrImplements) { - $phpcsFile->addWarning('Missing docblock for %s %s', $typePtr, 'Missing', [$objectType, $objectName]); } else { $phpcsFile->addError('Missing docblock for %s %s', $typePtr, 'Missing', [$objectType, $objectName]); } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/ParentSetUpTearDownSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/ParentSetUpTearDownSniff.php new file mode 100644 index 00000000..b73c271a --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/ParentSetUpTearDownSniff.php @@ -0,0 +1,237 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit; + +use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + +/** + * Checks that a test file setUp and tearDown methods are always calling to parent. + * + * @copyright 2024 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class ParentSetUpTearDownSniff implements Sniff +{ + /** + * @var string[] Methods to verify that they are calling to parent (setup like). + */ + private static array $setUpMethods = [ + 'setUp', + 'setUpBeforeClass', + ]; + + /** + * @var string[] Methods to verify that they are calling to parent (teardown like). + */ + private static array $tearDownMethods = [ + 'tearDown', + 'tearDownAfterClass', + ]; + + /** + * Register for open tag (only process once per file). + */ + public function register(): array { + return [T_OPEN_TAG]; + } + + /** + * Processes php files and perform various checks with file. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position in the stack. + */ + public function process(File $phpcsFile, $stackPtr): void { + + // Before starting any check, let's look for various things. + + // If we aren't checking Moodle 4.5dev (405) and up, nothing to check. + // Make and exception for codechecker phpunit tests, so they are run always. + if (!MoodleUtil::meetsMinimumMoodleVersion($phpcsFile, 405) && !MoodleUtil::isUnitTestRunning()) { + return; // @codeCoverageIgnore + } + + // If the file is not a unit test file, nothing to check. + if (!MoodleUtil::isUnitTest($phpcsFile) && !MoodleUtil::isUnitTestRunning()) { + return; // @codeCoverageIgnore + } + + // We only want to do this once per file. + $prevopentag = $phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1); + if ($prevopentag !== false) { + return; // @codeCoverageIgnore + } + + // Get the file tokens, for ease of use. + $tokens = $phpcsFile->getTokens(); + + // These are the methods we are going to check. + $allMethods = array_merge(self::$setUpMethods, self::$tearDownMethods); + + // Iterate over all the classes (hopefully only one, but that's not this sniff problem). + $cStart = $stackPtr; + while ($cStart = $phpcsFile->findNext(T_CLASS, $cStart + 1)) { + // Only interested in classes that are unit test classes. + if (MoodleUtil::isUnitTestCaseClass($phpcsFile, $cStart) === false) { + continue; + } + + // Iterate over all the methods in the class. + $mStart = $cStart; + while ($mStart = $phpcsFile->findNext(T_FUNCTION, $mStart + 1, $tokens[$cStart]['scope_closer'])) { + $method = $phpcsFile->getDeclarationName($mStart); + // Only interested in setUp and tearDown methods. + if (!in_array($method, $allMethods)) { + continue; + } + + // Iterate over all the parent:: calls in the method. + $pStart = $mStart; + $correctParentCalls = []; + while ($pStart = $phpcsFile->findNext(T_PARENT, $pStart + 1, $tokens[$mStart]['scope_closer'])) { + // The next-next token should be the parent method being named. + $methodCall = $phpcsFile->findNext(T_STRING, $pStart + 1, $pStart + 3); + // If we are calling to an incorrect parent method, report it. No fixable. + if ( + $methodCall !== false && + $tokens[$methodCall]['content'] !== $method && + in_array($tokens[$methodCall]['content'], $allMethods) // Other parent calls may be correct. + ) { + $wrongMethod = $tokens[$methodCall]['content']; + // We are calling to incorrect parent method. + $phpcsFile->addError( + 'The %s() method in unit tests cannot call to parent::%s().', + $pStart, + 'Incorrect' . ucfirst($method), + [$method, $wrongMethod] + ); + } + + // If we are calling to the correct parent method, annotate it. + if ( + $methodCall !== false && + $tokens[$methodCall]['content'] === $method + ) { + $correctParentCalls[] = $pStart; + } + } + + // If there are multiple calls to correct parent, report it. Not fixable. + if (count($correctParentCalls) > 1) { + $phpcsFile->addError( + 'The %s() method in unit tests must call to parent::%s() only once.', + end($correctParentCalls), + 'Multiple' . ucfirst($method), + [$method, $method] + ); + } + + // If there are no calls to correct parent, report it. + if (count($correctParentCalls) === 0) { + // Unlikely case of empty method, report it and continue. Not fixable. + // Find the next thing that is not an empty token. + $ignore = \PHP_CodeSniffer\Util\Tokens::$emptyTokens; + + $nextValidStatement = $phpcsFile->findNext( + $ignore, + $tokens[$mStart]['scope_opener'] + 1, + $tokens[$mStart]['scope_closer'], + true + ); + if ($nextValidStatement === false) { + $phpcsFile->addError( + 'The %s() method in unit tests must not be empty', + $mStart, + 'Empty' . ucfirst($method), + [$method] + ); + + continue; + } + + // If the method is not empty, let's report the missing call. Fixable. + $fix = $phpcsFile->addFixableError( + 'The %s() method in unit tests must always call to parent::%s().', + $mStart, + 'Missing' . ucfirst($method), + [$method, $method] + ); + + if ($fix) { + // If the current method is a setUp one, let's add the call at the beginning. + if (in_array($method, self::$setUpMethods)) { + $phpcsFile->fixer->beginChangeset(); + $phpcsFile->fixer->addContent( + $this->findSetUpInsertionPoint($phpcsFile, $mStart), + "\n" . ' parent::' . $method . '();' + ); + $phpcsFile->fixer->endChangeset(); + } + + // If the current method is a tearDown one, let's add the call at the end. + if (in_array($method, self::$tearDownMethods)) { + $phpcsFile->fixer->beginChangeset(); + $phpcsFile->fixer->addContentBefore( + $tokens[$mStart]['scope_closer'] - 1, + ' parent::' . $method . '();' . "\n" + ); + $phpcsFile->fixer->endChangeset(); + } + } + } + } + } + } + + /** + * Find the best insertion point for parent::setUp calls. + * + * While it's technically correct to insert the parent::setUp call at the beginning of the method, + * it's better to insert it after some statements, like global or require/include ones. + * + * @param File $phpcsFile The file being scanned. + * @param int $mStart The position of the method. + * @return int The position where the parent::setUp method should be inserted. + */ + private function findSetUpInsertionPoint(File $phpcsFile, int $mStart): int { + // By default, we are going to insert it at the beginning. + $insertionPoint = $phpcsFile->getTokens()[$mStart]['scope_opener']; + + // Let's find the first token in the method that is not a global, require or include. + // Do it ignoring both whitespace and comments. + $tokens = $phpcsFile->getTokens(); + $mEnd = $tokens[$mStart]['scope_closer']; + + $skipTokens = [T_WHITESPACE, T_COMMENT]; + $allowedTokens = [T_GLOBAL, T_REQUIRE, T_REQUIRE_ONCE, T_INCLUDE, T_INCLUDE_ONCE]; + + while ($findPtr = $phpcsFile->findNext($skipTokens, $insertionPoint + 1, $mEnd, true)) { + // If we find a token that is not allowed, stop looking, insertion point determined. + if (!in_array($tokens[$findPtr]['code'], $allowedTokens)) { + break; + } + + // Arrived here, we can advance the insertion point until the end of the allowed statement. + $insertionPoint = $phpcsFile->findEndOfStatement($findPtr, [T_COMMA]); + } + + return $insertionPoint; + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Util/Attributes.php b/vendor/moodlehq/moodle-cs/moodle/Util/Attributes.php new file mode 100644 index 00000000..ef6ad71d --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Util/Attributes.php @@ -0,0 +1,111 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Util; + +use PHP_CodeSniffer\Files\File; +use PHPCSUtils\Utils\Context; +use PHPCSUtils\Utils\Namespaces; + +/** + * Utilities related to PHP Attributes. + * + * @copyright 2024 Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +abstract class Attributes +{ + /** + * Get the pointer for an Attribute on an Attributable object. + * + * @param File $phpcsFile + * @param int $stackPtr + * @return array + */ + public static function getAttributePointers( + File $phpcsFile, + int $stackPtr + ): array { + $tokens = $phpcsFile->getTokens(); + $attributes = []; + + $stopAt = [ + T_DOC_COMMENT_CLOSE_TAG, + T_CLOSE_CURLY_BRACKET, + T_OPEN_CURLY_BRACKET, + T_SEMICOLON, + ]; + + for ($attributePtr = $stackPtr; $attributePtr > 0; $attributePtr--) { + $token = $tokens[$attributePtr]; + // The phpcs parser places an attribute_opener and attribute_closer on every part of an attribute. + if (isset($token['attribute_opener'])) { + $attributePtr = $token['attribute_opener']; + $attributes[] = $attributePtr; + } + + if (in_array($token['code'], $stopAt)) { + break; + } + } + + return $attributes; + } + + /** + * Get the properties of an Attribute. + * + * Note: The attribute name is not currently qualified relative to the current namespace or any imported classes. + * + * @param File $phpcsFile + * @param int $stackPtr + * @return array|null + */ + public static function getAttributeProperties( + File $phpcsFile, + int $stackPtr + ): ?array { + $tokens = $phpcsFile->getTokens(); + if (!isset($tokens[$stackPtr]['attribute_opener'])) { + return null; + } + + $opener = $tokens[$stackPtr]['attribute_opener']; + $closer = $tokens[$stackPtr]['attribute_closer']; + + $properties = [ + 'attribute_opener' => $opener, + 'attribute_closer' => $closer, + 'attribute_name' => null, + ]; + + $stopAt = [ + T_OPEN_PARENTHESIS, + ]; + + for ($i = $opener + 1; $i < $closer; $i++) { + if (in_array($tokens[$i]['code'], $stopAt)) { + break; + } + $properties['attribute_name'] .= $tokens[$i]['content']; + } + + // TODO Get the qualified name. + + return $properties; + } +} diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/FunctionDeclarations/RemovedImplicitlyNullableParamStandard.xml b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/FunctionDeclarations/RemovedImplicitlyNullableParamStandard.xml new file mode 100644 index 00000000..2a51df39 --- /dev/null +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/FunctionDeclarations/RemovedImplicitlyNullableParamStandard.xml @@ -0,0 +1,34 @@ + + + + + + + + $a = null) {} +function noDefaultValue(Countable $a) {} + +// PHP 7.1+: using a nullable type. +function foo(?Countable $a = null) {} + +// PHP 8.0+: using a union type with null +// or the explicit mixed type. +function bar(mixed $a = null) {} +function baz(Countable|null $a = null) {} + ]]> + + + Countable $a = null) {} + ]]> + + + diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/FunctionDeclarations/RemovedOptionalBeforeRequiredParamStandard.xml b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/FunctionDeclarations/RemovedOptionalBeforeRequiredParamStandard.xml new file mode 100644 index 00000000..39adca1d --- /dev/null +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/FunctionDeclarations/RemovedOptionalBeforeRequiredParamStandard.xml @@ -0,0 +1,60 @@ + + + + + + + + $b = 0) {} + +function bar(string $a, int $b = 0) {} + +// Exception: non-nullable typed parameters +// with a default value of `null` are still +// allowed prior to PHP 8.4. +function nullDefault(Foo $a = null, $b) {} + ]]> + + + $a = 0, $b) {} + +function bar(string $a = 'foo', int $b) {} + +// Deprecated in 8.0, shows notice since 8.1. +function typed(?string $a = null, int $b) {} + +// Deprecated in 8.0, shows notice since 8.3. +function typed(string|null $a = null, int $b) {} + ]]> + + + + + + + + ?Countable $a, $b) {} + ]]> + + + Countable $a = null, $b) {} + ]]> + + + diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewClassesSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewClassesSniff.php index 549f20a8..0e58bbc9 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewClassesSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewClassesSniff.php @@ -20,6 +20,7 @@ use PHPCSUtils\Utils\ControlStructures; use PHPCSUtils\Utils\FunctionDeclarations; use PHPCSUtils\Utils\Scopes; +use PHPCSUtils\Utils\UseStatements; use PHPCSUtils\Utils\Variables; /** @@ -1095,6 +1096,29 @@ class NewClassesSniff extends Sniff ], ]; + /** + * Current file being scanned. + * + * @since 10.0.0 + * + * @var string + */ + private $currentFile = ''; + + /** + * Stores information about imported, namespaced classes with names which are also in use by PHP. + * + * When those classes are used, they do not point to the PHP classes, but to the + * namespaced, imported class and those usages should be ignored by the sniff. + * + * The array is indexed by unqualified class names in lower case. The value is always true. + * It is structured this way to utilize the isset() function for faster lookups. + * + * @since 10.0.0 + * + * @var array + */ + private $importedClasses = []; /** * Returns an array of tokens this test wants to listen for. @@ -1123,6 +1147,7 @@ public function register() $this->newClasses = \array_merge($this->newClasses, $this->newExceptions); $targets = [ + \T_USE, \T_NEW, \T_CLASS, \T_ANON_CLASS, @@ -1150,9 +1175,20 @@ public function register() */ public function process(File $phpcsFile, $stackPtr) { + $fileName = $phpcsFile->getFilename(); + if ($this->currentFile !== $fileName) { + // Reset the properties for each new file. + $this->currentFile = $fileName; + $this->importedClasses = []; + } + $tokens = $phpcsFile->getTokens(); switch ($tokens[$stackPtr]['code']) { + case \T_USE: + $this->processUseToken($phpcsFile, $stackPtr); + break; + case \T_VARIABLE: $this->processVariableToken($phpcsFile, $stackPtr); break; @@ -1315,12 +1351,12 @@ private function checkTypeDeclaration($phpcsFile, $stackPtr, $typeString) $type = \ltrim($type, '\\'); if ($type === '') { - return; + continue; } $typeLc = \strtolower($type); if (isset($this->newClasses[$typeLc]) === false) { - return; + continue; } $itemInfo = [ @@ -1373,6 +1409,38 @@ private function processCatchToken(File $phpcsFile, $stackPtr) } } + /** + * Processes this test for when a use token is encountered. + * + * - Save imported classes for later use. + * + * @since 10.0.0 + * + * @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 processUseToken(File $phpcsFile, $stackPtr) + { + if (!UseStatements::isImportUse($phpcsFile, $stackPtr)) { + return; + } + + $splitUseStatement = UseStatements::splitImportUseStatement($phpcsFile, $stackPtr); + + foreach ($splitUseStatement['name'] as $name => $fullyQualifiedName) { + $lowerFullyQualifiedName = strtolower($fullyQualifiedName); + + if (isset($this->newClasses[$lowerFullyQualifiedName])) { + continue; + } + + $this->importedClasses[strtolower($name)] = true; + } + } + /** * Handle the retrieval of relevant information and - if necessary - throwing of an @@ -1389,6 +1457,10 @@ private function processCatchToken(File $phpcsFile, $stackPtr) */ protected function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo) { + if (isset($this->importedClasses[$itemInfo['nameLc']])) { + return; + } + $itemArray = $this->newClasses[$itemInfo['nameLc']]; $versionInfo = $this->getVersionInfo($itemArray); diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewReadonlyClassesSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewReadonlyClassesSniff.php index c83488b5..3892b76f 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewReadonlyClassesSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewReadonlyClassesSniff.php @@ -13,16 +13,19 @@ use PHPCompatibility\Helpers\ScannedCode; use PHPCompatibility\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Utils\ObjectDeclarations; /** * Declaring classes as readonly is supported since PHP 8.2. * * PHP version 8.2 + * PHP version 8.3 * * @link https://wiki.php.net/rfc/readonly_classes * @link https://www.php.net/manual/en/migration82.new-features.php#migration82.new-features.core.readonly-classes * @link https://www.php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.readonly + * @link https://www.php.net/manual/en/migration83.new-features.php#migration83.new-features.core.readonly-modifier-improvements * * @since 10.0.0 */ @@ -38,7 +41,10 @@ final class NewReadonlyClassesSniff extends Sniff */ public function register() { - return [\T_CLASS]; + return [ + \T_CLASS, + \T_ANON_CLASS, + ]; } /** @@ -54,19 +60,38 @@ public function register() */ public function process(File $phpcsFile, $stackPtr) { - if (ScannedCode::shouldRunOnOrBelow('8.1') === false) { - return; - } + $tokens = $phpcsFile->getTokens(); + + if ($tokens[$stackPtr]['code'] === \T_CLASS) { + if (ScannedCode::shouldRunOnOrBelow('8.1') === false) { + return; + } + + $properties = ObjectDeclarations::getClassProperties($phpcsFile, $stackPtr); + if ($properties['is_readonly'] === false) { + return; + } - $properties = ObjectDeclarations::getClassProperties($phpcsFile, $stackPtr); - if ($properties['is_readonly'] === false) { - return; + $phpcsFile->addError( + 'Readonly classes are not supported in PHP 8.1 or earlier.', + $properties['readonly_token'], + 'Found' + ); } - $phpcsFile->addError( - 'Readonly classes are not supported in PHP 8.1 or earlier.', - $properties['readonly_token'], - 'Found' - ); + if ($tokens[$stackPtr]['code'] === \T_ANON_CLASS) { + if (ScannedCode::shouldRunOnOrBelow('8.2') === false) { + return; + } + + $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($tokens[$prevNonEmpty]['code'] === \T_READONLY) { + $phpcsFile->addError( + 'Readonly anonymous classes are not supported in PHP 8.2 or earlier.', + $prevNonEmpty, + 'AnonClass' + ); + } + } } } diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewTypedPropertiesSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewTypedPropertiesSniff.php index b9fcbef5..d3a1b5cc 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewTypedPropertiesSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/NewTypedPropertiesSniff.php @@ -162,7 +162,7 @@ public function process(File $phpcsFile, $stackPtr) $this->checkType($phpcsFile, $properties['type_token'], $properties); - $endOfStatement = $phpcsFile->findNext(\T_SEMICOLON, ($stackPtr + 1)); + $endOfStatement = $phpcsFile->findNext([\T_SEMICOLON, \T_CLOSE_TAG], ($stackPtr + 1)); if ($endOfStatement !== false) { // Don't throw the same error multiple times for multi-property declarations. return ($endOfStatement + 1); diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/RemovedClassesSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/RemovedClassesSniff.php index c9f9ddc5..3102af95 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/RemovedClassesSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Classes/RemovedClassesSniff.php @@ -423,12 +423,12 @@ private function checkTypeDeclaration($phpcsFile, $stackPtr, $typeString) $type = \ltrim($type, '\\'); if ($type === '') { - return; + continue; } $typeLc = \strtolower($type); if (isset($this->removedClasses[$typeLc]) === false) { - return; + continue; } $itemInfo = [ diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewMagicClassConstantSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewMagicClassConstantSniff.php index 20397dec..88bbc035 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewMagicClassConstantSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewMagicClassConstantSniff.php @@ -15,6 +15,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Tokens\Collections; +use PHPCSUtils\Utils\Context; /** * Detect usage of the magic `::class` constant introduced in PHP 5.5. @@ -73,6 +74,11 @@ public function process(File $phpcsFile, $stackPtr) return; } + if (Context::inAttribute($phpcsFile, $stackPtr) === true) { + // If the syntax is used within an attribute, it will be interpreted as a comment on PHP < 8.0, so not an issue. + return; + } + $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($nextToken !== false && $tokens[$nextToken]['code'] === \T_OPEN_PARENTHESIS) { // Function call or declaration for a function called "class". diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/RemovedImplicitlyNullableParamSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/RemovedImplicitlyNullableParamSniff.php new file mode 100644 index 00000000..dab6ee52 --- /dev/null +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/RemovedImplicitlyNullableParamSniff.php @@ -0,0 +1,147 @@ + + */ + private $allowedInDefault = [ + \T_NULL => \T_NULL, + ]; + + /** + * Returns an array of tokens this test wants to listen for. + * + * @since 10.0.0 + * + * @return array + */ + public function register() + { + $this->allowedInDefault += Tokens::$emptyTokens; + + return Collections::functionDeclarationTokens(); + } + + /** + * Processes this test, when one of its tokens is encountered. + * + * @since 10.0.0 + * + * @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) + { + if (ScannedCode::shouldRunOnOrAbove('8.4') === false) { + return; + } + + // Get all parameters from the function signature. + $parameters = FunctionDeclarations::getParameters($phpcsFile, $stackPtr); + if (empty($parameters)) { + return; + } + + $tokens = $phpcsFile->getTokens(); + + // Parenthesis closer will be defined, otherwise we'd have received an empty parameters array. + $closeParens = $tokens[$stackPtr]['parenthesis_closer']; + + foreach ($parameters as $key => $param) { + if (isset($param['property_visibility'])) { + /* + * Implicitly nullable parameters were never allowed for promoted properties + * and always resulted in a fatal error. Ignore as this is outside the scope of this sniff. + */ + continue; + } + + if (isset($param['default']) === false + || $param['type_hint'] === '' + || $param['type_hint_token'] === false + ) { + // If there is no default value or no type hint, there is no issue. + continue; + } + + if ($param['nullable_type'] === true + || $param['type_hint'] === 'null' + || $param['type_hint'] === 'mixed' + || $phpcsFile->findNext(\T_NULL, $param['type_hint_token'], ($param['type_hint_end_token'] + 1)) !== false + ) { + // Type is nullable, no issue. + continue; + } + + /* + * Non-nullable type, now check if the default value is `null`. + * + * We can ignore `null` when it is part of a constant expression or in new in initializers, + * as PHP does not regard parameters with that kind of default value as nullable and + * would throw a fatal when the function is called. This behaviour is not changed by the + * PHP 8.4 deprecation of implicitly nullable parameters, so those parameters should be + * ignored by this sniff. + * Also see: https://github.com/php/php-src/issues/13752 + */ + + // Determine the end of the parameter. + $paramEnd = ($param['comma_token'] === false) ? $closeParens : $param['comma_token']; + $hasNull = $phpcsFile->findNext(\T_NULL, $param['default_token'], $paramEnd); + $hasNonNull = $phpcsFile->findNext($this->allowedInDefault, $param['default_token'], $paramEnd, true); + if ($hasNull === false || $hasNonNull !== false) { + // No null default value, we're okay. + continue; + } + + $error = 'Implicitly marking a parameter as nullable is deprecated since PHP 8.4. Update the type to be explicitly nullable instead. Found implicitly nullable parameter: %s.'; + $code = 'Deprecated'; + $data = [$param['name']]; + + $phpcsFile->addWarning($error, $param['token'], $code, $data); + } + } +} diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/RemovedOptionalBeforeRequiredParamSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/RemovedOptionalBeforeRequiredParamSniff.php index 667c9eb9..8b4148f0 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/RemovedOptionalBeforeRequiredParamSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionDeclarations/RemovedOptionalBeforeRequiredParamSniff.php @@ -18,16 +18,31 @@ use PHPCSUtils\Utils\FunctionDeclarations; /** - * Declaring a required function parameter after an optional parameter is deprecated since PHP 8.0. + * Declaring an optional function parameter before a required parameter is deprecated since PHP 8.0. * * > Declaring a required parameter after an optional one is deprecated. As an * > exception, declaring a parameter of the form "Type $param = null" before * > a required one continues to be allowed, because this pattern was sometimes * > used to achieve nullable types in older PHP versions. * + * While deprecated since PHP 8.0, optional parameters with an explicitly nullable type + * and a null default value, and found before a required parameter, are only flagged since PHP 8.1. + * + * While deprecated since PHP 8.0, optional parameters with an union type which includes null + * and a null default value, and found before a required parameter, are only flagged since PHP 8.3. + * + * And as of PHP 8.4, parameters of the form "Type $param = null" before a required parameter are + * now also deprecated. + * * PHP version 8.0 + * PHP version 8.1 + * PHP version 8.3 + * PHP version 8.4 * * @link https://github.com/php/php-src/blob/69888c3ff1f2301ead8e37b23ff8481d475e29d2/UPGRADING#L145-L151 + * @link https://github.com/php/php-src/commit/c939bd2f10b41bced49eb5bf12d48c3cf64f984a + * @link https://github.com/php/php-src/commit/68ef3938f42aefa3881c268b12b3c0f1ecc5888d + * @link https://wiki.php.net/rfc/deprecate-implicitly-nullable-types * * @since 10.0.0 */ @@ -35,7 +50,42 @@ class RemovedOptionalBeforeRequiredParamSniff extends Sniff { /** - * Tokens allowed in the default value. + * Base message for the PHP 8.0 deprecation. + * + * @var string + */ + const PHP80_MSG = 'Declaring an optional parameter before a required parameter is deprecated since PHP 8.0.'; + + /** + * Base message for the PHP 8.1 deprecation. + * + * @var string + */ + const PHP81_MSG = 'Declaring an optional parameter with a nullable type before a required parameter is soft deprecated since PHP 8.0 and hard deprecated since PHP 8.1'; + + /** + * Base message for the PHP 8.3 deprecation. + * + * @var string + */ + const PHP83_MSG = 'Declaring an optional parameter with a null stand-alone type or a union type including null before a required parameter is soft deprecated since PHP 8.0 and hard deprecated since PHP 8.3'; + + /** + * Base message for the PHP 8.4 deprecation. + * + * @var string + */ + const PHP84_MSG = 'Declaring an optional parameter with a non-nullable type and a null default value before a required parameter is deprecated since PHP 8.4'; + + /** + * Message template for detailed information about the deprecation. + * + * @var string + */ + const MSG_DETAILS = ' Parameter %1$s is optional, while parameter %2$s is required. The %1$s parameter is implicitly treated as a required parameter.'; + + /** + * Tokens allowed in the default value (until PHP 8.4). * * This property will be enriched in the register() method. * @@ -84,12 +134,10 @@ public function process(File $phpcsFile, $stackPtr) return; } - $error = 'Declaring a required parameter after an optional one is deprecated since PHP 8.0. Parameter %s is optional, while parameter %s is required.'; - - $paramCount = \count($parameters); - $lastKey = ($paramCount - 1); - $firstOptional = null; + $requiredParam = null; + $parameters = \array_reverse($parameters); + // Walk the parameters in reverse order (from last to first). foreach ($parameters as $key => $param) { /* * Ignore variadic parameters, which are optional by nature. @@ -99,49 +147,70 @@ public function process(File $phpcsFile, $stackPtr) continue; } - // Handle optional parameters. - if (isset($param['default']) === true) { - if ($key === $lastKey) { - // This is the last parameter and it's optional, no further checking needed. - break; - } - - if (isset($firstOptional) === false) { - // Check if it's typed and has a null default value, in which case we can ignore it. - if ($param['type_hint'] !== '') { - $hasNull = $phpcsFile->findNext(\T_NULL, $param['default_token'], $param['comma_token']); - $hasNonNull = $phpcsFile->findNext( - $this->allowedInDefault, - $param['default_token'], - $param['comma_token'], - true - ); - - if ($hasNull !== false && $hasNonNull === false) { - continue; - } - } - - // Non-null default value. This is an optional param we need to take into account. - $firstOptional = $param['name']; - } - + if (isset($param['default']) === false) { + $requiredParam = $param['name']; continue; } - // Found a required parameter. - if (isset($firstOptional) === false) { - // No optional params found yet. + // Found an optional parameter. + if (isset($requiredParam) === false) { + // No required params found yet. continue; } - // Found a required parameter with an optional param before it. - $data = [ - $firstOptional, + // Okay, so we have an optional parameter before a required one. + // Note: as this will never be the _last_ parameter, we can be sure the 'comma_token' will be set to a token and not `false`. + $hasNull = $phpcsFile->findNext(\T_NULL, $param['default_token'], $param['comma_token']); + $hasNonNull = $phpcsFile->findNext($this->allowedInDefault, $param['default_token'], $param['comma_token'], true); + + // Check for union types which include null, mixed types and stand-alone null types. + $hasNullType = false; + if ($param['type_hint_token'] !== false) { + if ($param['type_hint'] === 'mixed' || $param['type_hint'] === 'null') { + $hasNullType = $param['type_hint_token']; + } else { + $hasNullType = $phpcsFile->findNext(\T_NULL, $param['type_hint_token'], ($param['type_hint_end_token'] + 1)); + } + } + + // Found an optional parameter with a required param after it. + $error = self::PHP80_MSG . self::MSG_DETAILS; + $code = 'Deprecated80'; + $data = [ $param['name'], + $requiredParam, ]; - $phpcsFile->addWarning($error, $param['token'], 'Deprecated', $data); + if ($hasNull !== false && $hasNonNull === false) { + if ($param['nullable_type'] === true) { + // Skip flagging the issue if the codebase doesn't need to run on PHP 8.1+. + if (ScannedCode::shouldRunOnOrAbove('8.1') === false) { + continue; + } + + $error = self::PHP81_MSG . self::MSG_DETAILS; + $code = 'Deprecated81'; + + } elseif ($hasNullType !== false) { + // Skip flagging the issue if the codebase doesn't need to run on PHP 8.3+. + if (ScannedCode::shouldRunOnOrAbove('8.3') === false) { + continue; + } + + $error = self::PHP83_MSG . self::MSG_DETAILS; + $code = 'Deprecated83'; + } elseif ($param['type_hint'] !== '') { + // Skip flagging the issue if the codebase doesn't need to run on PHP 8.4+. + if (ScannedCode::shouldRunOnOrAbove('8.4') === false) { + continue; + } + + $error = self::PHP84_MSG . self::MSG_DETAILS; + $code = 'Deprecated84'; + } + } + + $phpcsFile->addWarning($error, $param['token'], $code, $data); } } } diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/InternalInterfacesSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/InternalInterfacesSniff.php index d8503729..4455bb0a 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/InternalInterfacesSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/InternalInterfacesSniff.php @@ -15,6 +15,7 @@ use PHPCSUtils\Tokens\Collections; use PHPCSUtils\Utils\MessageHelper; use PHPCSUtils\Utils\ObjectDeclarations; +use PHPCSUtils\Utils\UseStatements; /** * Detect classes which implement PHP native interfaces intended only for PHP internal use. @@ -60,6 +61,30 @@ class InternalInterfacesSniff extends Sniff 'BackedEnum' => true, ]; + /** + * Current file being scanned. + * + * @since 10.0.0 + * + * @var string + */ + private $currentFile = ''; + + /** + * Stores information about imported, namespaced declarations with names which are also in use by PHP. + * + * When those declarations are used, they do not point to the PHP internal declarations, but to the + * namespaced, imported declarations and those usages should be ignored by the sniff. + * + * The array is indexed by unqualified declarations names in lower case. The value is always true. + * It is structured this way to utilize the isset() function for faster lookups. + * + * @since 10.0.0 + * + * @var array + */ + private $importedDeclarations = []; + /** * Returns an array of tokens this test wants to listen for. @@ -74,7 +99,7 @@ public function register() $this->internalInterfaces = \array_change_key_case($this->internalInterfaces, \CASE_LOWER); $this->cannotBeExtended = \array_change_key_case($this->cannotBeExtended, \CASE_LOWER); - return Collections::ooCanImplement() + [\T_INTERFACE => \T_INTERFACE]; + return Collections::ooCanImplement() + [\T_USE => \T_USE, \T_INTERFACE => \T_INTERFACE]; } /** @@ -90,7 +115,20 @@ public function register() */ public function process(File $phpcsFile, $stackPtr) { + $fileName = $phpcsFile->getFilename(); + if ($this->currentFile !== $fileName) { + // Reset the properties for each new file. + $this->currentFile = $fileName; + $this->importedDeclarations = []; + } + $tokens = $phpcsFile->getTokens(); + + if ($tokens[$stackPtr]['code'] === \T_USE) { + $this->processUseToken($phpcsFile, $stackPtr); + return; + } + if ($tokens[$stackPtr]['code'] === \T_INTERFACE) { $interfaces = ObjectDeclarations::findExtendedInterfaceNames($phpcsFile, $stackPtr); $targets = $this->cannotBeExtended; @@ -106,7 +144,7 @@ public function process(File $phpcsFile, $stackPtr) foreach ($interfaces as $interface) { $interface = \ltrim($interface, '\\'); $interfaceLc = \strtolower($interface); - if (isset($targets[$interfaceLc]) === true) { + if (isset($targets[$interfaceLc]) && ! isset($this->importedDeclarations[$interfaceLc])) { $error = 'The interface %s %s'; $errorCode = MessageHelper::stringToErrorCode($interfaceLc) . 'Found'; $data = [ @@ -118,4 +156,38 @@ public function process(File $phpcsFile, $stackPtr) } } } + + + /** + * Processes this test for when a use token is encountered. + * + * - Save imported declarations for later use. + * + * @since 10.0.0 + * + * @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 processUseToken(File $phpcsFile, $stackPtr) + { + if (!UseStatements::isImportUse($phpcsFile, $stackPtr)) { + return; + } + + $splitUseStatement = UseStatements::splitImportUseStatement($phpcsFile, $stackPtr); + + foreach ($splitUseStatement['name'] as $name => $fullyQualifiedName) { + $lowerFullyQualifiedName = strtolower($fullyQualifiedName); + + // If the imported declaration is imported from the internal namespace it will not be excluded. + if (isset($this->internalInterfaces[$lowerFullyQualifiedName])) { + continue; + } + + $this->importedDeclarations[strtolower($name)] = true; + } + } } diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/NewInterfacesSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/NewInterfacesSniff.php index 4b17d887..7cb49fd8 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/NewInterfacesSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Interfaces/NewInterfacesSniff.php @@ -21,6 +21,7 @@ use PHPCSUtils\Utils\MessageHelper; use PHPCSUtils\Utils\ObjectDeclarations; use PHPCSUtils\Utils\Scopes; +use PHPCSUtils\Utils\UseStatements; use PHPCSUtils\Utils\Variables; /** @@ -173,6 +174,30 @@ class NewInterfacesSniff extends Sniff ], ]; + /** + * Current file being scanned. + * + * @since 10.0.0 + * + * @var string + */ + private $currentFile = ''; + + /** + * Stores information about imported, namespaced declarations with names which are also in use by PHP. + * + * When those declarations are used, they do not point to the PHP internal declarations, but to the + * namespaced, imported declarations and those usages should be ignored by the sniff. + * + * The array is indexed by unqualified declarations names in lower case. The value is always true. + * It is structured this way to utilize the isset() function for faster lookups. + * + * @since 10.0.0 + * + * @var array + */ + private $importedDeclaration = []; + /** * Returns an array of tokens this test wants to listen for. * @@ -187,6 +212,7 @@ public function register() $this->unsupportedMethods = \array_change_key_case($this->unsupportedMethods, \CASE_LOWER); $targets = [ + \T_USE, \T_INTERFACE, \T_VARIABLE, \T_CATCH, @@ -212,9 +238,20 @@ public function register() */ public function process(File $phpcsFile, $stackPtr) { + $fileName = $phpcsFile->getFilename(); + if ($this->currentFile !== $fileName) { + // Reset the properties for each new file. + $this->currentFile = $fileName; + $this->importedDeclaration = []; + } + $tokens = $phpcsFile->getTokens(); switch ($tokens[$stackPtr]['code']) { + case \T_USE: + $this->processUseToken($phpcsFile, $stackPtr); + break; + case \T_INTERFACE: $this->processInterfaceToken($phpcsFile, $stackPtr); break; @@ -452,12 +489,12 @@ private function checkTypeDeclaration($phpcsFile, $stackPtr, $typeHint) $type = \ltrim($type, '\\'); if ($type === '') { - return; + continue; } $typeLc = \strtolower($type); if (isset($this->newInterfaces[$typeLc]) === false) { - return; + continue; } $itemInfo = [ @@ -510,6 +547,38 @@ private function processCatchToken(File $phpcsFile, $stackPtr) } } + /** + * Processes this test for when a use token is encountered. + * + * - Save imported declarations for later use. + * + * @since 10.0.0 + * + * @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 processUseToken(File $phpcsFile, $stackPtr) + { + if (!UseStatements::isImportUse($phpcsFile, $stackPtr)) { + return; + } + + $splitUseStatement = UseStatements::splitImportUseStatement($phpcsFile, $stackPtr); + + foreach ($splitUseStatement['name'] as $name => $fullyQualifiedName) { + $lowerFullyQualifiedName = strtolower($fullyQualifiedName); + + // If the imported declaration is imported from the internal namespace it will not be excluded. + if (isset($this->newInterfaces[$lowerFullyQualifiedName])) { + continue; + } + + $this->importedDeclaration[strtolower($name)] = true; + } + } /** * Handle the retrieval of relevant information and - if necessary - throwing of an @@ -526,6 +595,10 @@ private function processCatchToken(File $phpcsFile, $stackPtr) */ protected function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo) { + if (isset($this->importedDeclaration[$itemInfo['nameLc']])) { + return; + } + $itemArray = $this->newInterfaces[$itemInfo['nameLc']]; $versionInfo = $this->getVersionInfo($itemArray); diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewNumberFormatMultibyteSeparatorsSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewNumberFormatMultibyteSeparatorsSniff.php index 3ce60b79..69067c37 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewNumberFormatMultibyteSeparatorsSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/NewNumberFormatMultibyteSeparatorsSniff.php @@ -146,8 +146,8 @@ protected function examineParameter(File $phpcsFile, $param, $paramName) } } - if ($length === 1) { - // Single-byte, we're good. + if ($length <= 1) { + // Single-byte or empty string, we're good. return; } diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewArrayUnpackingSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewArrayUnpackingSniff.php index 04b93e8a..8093835b 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewArrayUnpackingSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewArrayUnpackingSniff.php @@ -14,7 +14,9 @@ use PHPCompatibility\Sniff; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Util\Tokens; +use PHPCSUtils\Tokens\Collections; use PHPCSUtils\Utils\Arrays; +use PHPCSUtils\Utils\Context; use PHPCSUtils\Utils\GetTokensAsString; /** @@ -30,19 +32,6 @@ class NewArrayUnpackingSniff extends Sniff { - /** - * Array target tokens. - * - * @since 10.0.0 - * - * @var array - */ - private $arrayTokens = [ - \T_ARRAY => \T_ARRAY, - \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY, - \T_OPEN_SQUARE_BRACKET => \T_OPEN_SQUARE_BRACKET, - ]; - /** * Returns an array of tokens this test wants to listen for. * @@ -52,7 +41,7 @@ class NewArrayUnpackingSniff extends Sniff */ public function register() { - return $this->arrayTokens; + return Collections::arrayOpenTokensBC(); } /** @@ -72,6 +61,11 @@ public function process(File $phpcsFile, $stackPtr) return; } + if (Context::inAttribute($phpcsFile, $stackPtr) === true) { + // If the syntax is used within an attribute, it will be interpreted as a comment on PHP < 8.0, so not an issue. + return; + } + /* * Determine the array opener & closer. */ @@ -90,8 +84,9 @@ public function process(File $phpcsFile, $stackPtr) $nestingLevel = \count($tokens[($opener + 1)]['nested_parenthesis']); } - $find = $this->arrayTokens; - $find[\T_ELLIPSIS] = \T_ELLIPSIS; + $find = Collections::arrayOpenTokensBC(); + $find[\T_ELLIPSIS] = \T_ELLIPSIS; + $find[\T_OPEN_CURLY_BRACKET] = \T_OPEN_CURLY_BRACKET; for ($i = $opener; $i < $closer;) { $i = $phpcsFile->findNext($find, ($i + 1), $closer); diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewFlexibleHeredocNowdocSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewFlexibleHeredocNowdocSniff.php index b3f68e2c..d175434b 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewFlexibleHeredocNowdocSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Syntax/NewFlexibleHeredocNowdocSniff.php @@ -183,7 +183,7 @@ protected function detectClosingMarkerInBody(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $error = 'The body of a heredoc/nowdoc can not contain the heredoc/nowdoc closing marker as text at the start of a line since PHP 7.3.'; - $errorCode = 'ClosingMarkerNoNewLine'; + $errorCode = 'CloserFoundInBody'; if (\PHP_VERSION_ID >= 70300) { $nextNonWhitespace = $phpcsFile->findNext(\T_WHITESPACE, ($stackPtr + 1), null, true, null, true); diff --git a/vendor/phpcompatibility/php-compatibility/README.md b/vendor/phpcompatibility/php-compatibility/README.md index db9be9b6..7359167c 100644 --- a/vendor/phpcompatibility/php-compatibility/README.md +++ b/vendor/phpcompatibility/php-compatibility/README.md @@ -43,13 +43,13 @@ Requirements ------- * PHP 5.4+ -* PHP CodeSniffer: 3.8.0+. +* PHP CodeSniffer: 3.9.0+. The sniffs are designed to give the same results regardless of which PHP version you are using to run PHP CodeSniffer. You should get consistent results independently of the PHP version used in your test environment, though for the best results it is recommended to run the sniffs on a recent PHP version in combination with a recent PHP_CodeSniffer version. As of version 8.0.0, the PHPCompatibility standard can also be used with PHP CodeSniffer 3.x. As of version 9.0.0, support for PHP CodeSniffer 1.5.x and low 2.x versions < 2.3.0 has been dropped. -As of version 10.0.0, support for PHP < 5.4 and PHP CodeSniffer < 3.8.0 has been dropped. +As of version 10.0.0, support for PHP < 5.4 and PHP CodeSniffer < 3.9.0 has been dropped. Thank you diff --git a/vendor/phpcompatibility/php-compatibility/composer.json b/vendor/phpcompatibility/php-compatibility/composer.json index e1b705df..8deba28c 100644 --- a/vendor/phpcompatibility/php-compatibility/composer.json +++ b/vendor/phpcompatibility/php-compatibility/composer.json @@ -28,7 +28,7 @@ }, "require": { "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.8.0", + "squizlabs/php_codesniffer": "^3.9.0", "phpcsstandards/phpcsutils": "^1.0.9" }, "require-dev": { @@ -48,7 +48,8 @@ "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true - } + }, + "lock": false }, "extra": { "branch-alias": { diff --git a/vendor/phpcsstandards/phpcsutils/CHANGELOG.md b/vendor/phpcsstandards/phpcsutils/CHANGELOG.md index 12cfc3e2..b9f163ff 100644 --- a/vendor/phpcsstandards/phpcsutils/CHANGELOG.md +++ b/vendor/phpcsstandards/phpcsutils/CHANGELOG.md @@ -9,6 +9,73 @@ This projects adheres to [Keep a CHANGELOG](https://keepachangelog.com/) and use _Nothing yet._ +## [1.0.12] - 2024-05-20 + +### Added + +#### PHPCS BackCompat + +* `BCFile::getMemberProperties()`: sync with PHPCS 3.10.0 - support for PHP 8.2 DNF types. [#604] +* `BCFile::getMethodProperties()`: sync with PHPCS 3.10.0 - support for PHP 8.2 DNF types. [#604] +* `BCFile::getMethodParameters()`: sync with PHPCS 3.10.0 - support for PHP 8.2 DNF types. [#604] + +#### Utils + +* `FunctionDeclarations::getParameters()`: support for PHP 8.2 DNF types. [#604] +* `FunctionDeclarations::getProperties()`: support for PHP 8.2 DNF types. [#604] +* `Variables::getMemberProperties()`: support for PHP 8.2 DNF types. [#604] + +### Changed + +#### Tokens + +* `Collections::parameterTypeTokens()`, `Collections::propertyTypeTokens()` and `Collections::returnTypeTokens()`: now include the new `T_TYPE_OPEN_PARENTHESIS` and `T_TYPE_CLOSE_PARENTHESIS` tokens for PHP 8.2 DNF type support. [#604] + +#### Utils + +* `ControlStructures::getCaughtExceptions()`: will now silently ignore parse errors in the code under scan which prevent the method from analyzing a `catch` statement. [#594] + The method will now return an empty array instead of throwing a `PHP_CodeSniffer\Exceptions\RuntimeException`. + +#### Other + +* Dropped support for [PHP_CodeSniffer] < 3.10.0. [#603] + Please ensure you run `composer update phpcsstandards/phpcsutils --with-dependencies` to benefit from this. +* Various housekeeping and documentation improvements. + +### Fixed + +#### Utils + +* `UseStatements::splitImportUseStatement()`: the values in the return array will now never include a leading backslash. [#590] + Previously the behaviour around import `use` statements declared with a leading backslash was undefined and the backslash would be included in the return value. + +[#590]: https://github.com/PHPCSStandards/PHPCSUtils/pull/590 +[#594]: https://github.com/PHPCSStandards/PHPCSUtils/pull/594 +[#603]: https://github.com/PHPCSStandards/PHPCSUtils/pull/603 +[#604]: https://github.com/PHPCSStandards/PHPCSUtils/pull/604 + + +## [1.0.11] - 2024-04-24 + +### Changed + +#### Other + +* Various housekeeping and documentation improvements. Includes a contribution from [@fredden]. + +### Fixed + +#### PHPCS BackCompat + +* `BCFile::getMethodProperties()`: small performance improvement & more defensive coding, in line with same fix in PHPCS 3.9.2. [#573] + +#### Utils + +* `FunctionDeclarations::getProperties()`: small performance improvement & more defensive coding, in line with same fix in PHPCS 3.9.2. [#573] + +[#573]: https://github.com/PHPCSStandards/PHPCSUtils/pull/573 + + ## [1.0.10] - 2024-03-18 ### Changed @@ -477,7 +544,7 @@ Please report any bugs/oversights you encounter! All properties have a replacement which should be used instead, in most cases this will be a method with the same name as the previously used property, | Deprecated | Replacement | PR | Remarks | -|---------------------------------------------------------------|------------------------------------------------------------------------------------------------------|----------------|------------------------------------------| +| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -------------- | ---------------------------------------- | | `Collections::$alternativeControlStructureSyntaxTokens` | `Collections::alternativeControlStructureSyntaxes()` | [#311] | Mind the change in the name! | | `Collections::$alternativeControlStructureSyntaxCloserTokens` | `Collections::alternativeControlStructureSyntaxClosers()` | [#311] | Mind the change in the name! | | `Collections::$arrayTokens` | `Collections::arrayTokens()` | [#311] | | @@ -510,7 +577,7 @@ All properties have a replacement which should be used instead, in most cases th Additionally, the following methods in the `Collections` class have been deprecated: | Deprecated | Replacement | PR | -|----------------------------------------------|--------------------------------------------|--------| +| -------------------------------------------- | ------------------------------------------ | ------ | | `Collections::arrowFunctionTokensBC()` | Use the `T_FN` token instead. | [#347] | | `Collections::functionDeclarationTokensBC()` | `Collections::functionDeclarationTokens()` | [#347] | | `Collections::parameterTypeTokensBC()` | `Collections::parameterTypeTokens()` | [#347] | @@ -984,6 +1051,8 @@ This initial alpha release contains the following utility classes: [Unreleased]: https://github.com/PHPCSStandards/PHPCSUtils/compare/stable...HEAD +[1.0.12]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.11...1.0.12 +[1.0.11]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.10...1.0.11 [1.0.10]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.9...1.0.10 [1.0.9]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.8...1.0.9 [1.0.8]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.7...1.0.8 diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCFile.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCFile.php index 14c6adf6..8c063439 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCFile.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCFile.php @@ -76,7 +76,7 @@ final class BCFile * * Changelog for the PHPCS native function: * - Introduced in PHPCS 0.0.5. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::getDeclarationName() Original source. * @see \PHPCSUtils\Utils\ObjectDeclarations::getName() PHPCSUtils native improved version. @@ -228,7 +228,9 @@ public static function getMethodParameters(File $phpcsFile, $stackPtr) // it's likely to be an array which might have arguments in it. This // could cause problems in our parsing below, so lets just skip to the // end of it. - if (isset($tokens[$i]['parenthesis_opener']) === true) { + if ($tokens[$i]['code'] !== T_TYPE_OPEN_PARENTHESIS + && isset($tokens[$i]['parenthesis_opener']) === true + ) { // Don't do this if it's the close parenthesis for the method. if ($i !== $tokens[$i]['parenthesis_closer']) { $i = ($tokens[$i]['parenthesis_closer'] + 1); @@ -324,6 +326,8 @@ public static function getMethodParameters(File $phpcsFile, $stackPtr) case T_NS_SEPARATOR: case T_TYPE_UNION: case T_TYPE_INTERSECTION: + case T_TYPE_OPEN_PARENTHESIS: + case T_TYPE_CLOSE_PARENTHESIS: case T_FALSE: case T_TRUE: case T_NULL: @@ -462,7 +466,7 @@ public static function getMethodParameters(File $phpcsFile, $stackPtr) * * Changelog for the PHPCS native function: * - Introduced in PHPCS 0.0.5. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::getMethodProperties() Original source. * @see \PHPCSUtils\Utils\FunctionDeclarations::getProperties() PHPCSUtils native improved version. @@ -507,7 +511,7 @@ public static function getMethodProperties(File $phpcsFile, $stackPtr) * * Changelog for the PHPCS native function: * - Introduced in PHPCS 0.0.5. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::getMemberProperties() Original source. * @see \PHPCSUtils\Utils\Variables::getMemberProperties() PHPCSUtils native improved version. @@ -545,7 +549,7 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr) * * Changelog for the PHPCS native function: * - Introduced in PHPCS 1.3.0. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::getClassProperties() Original source. * @see \PHPCSUtils\Utils\ObjectDeclarations::getClassProperties() PHPCSUtils native improved version. @@ -573,7 +577,7 @@ public static function getClassProperties(File $phpcsFile, $stackPtr) * * Changelog for the PHPCS native function: * - Introduced in PHPCS 0.0.5. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::isReference() Original source. * @see \PHPCSUtils\Utils\Operators::isReference() PHPCSUtils native improved version. @@ -599,7 +603,7 @@ public static function isReference(File $phpcsFile, $stackPtr) * * Changelog for the PHPCS native function: * - Introduced in PHPCS 0.0.5. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::getTokensAsString() Original source. * @see \PHPCSUtils\Utils\GetTokensAsString Related set of functions. @@ -628,7 +632,7 @@ public static function getTokensAsString(File $phpcsFile, $start, $length, $orig * * Changelog for the PHPCS native function: * - Introduced in PHPCS 2.1.0. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::findStartOfStatement() Original source. * @@ -652,7 +656,7 @@ public static function findStartOfStatement(File $phpcsFile, $start, $ignore = n * * Changelog for the PHPCS native function: * - Introduced in PHPCS 2.1.0. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::findEndOfStatement() Original source. * @@ -676,7 +680,7 @@ public static function findEndOfStatement(File $phpcsFile, $start, $ignore = nul * * Changelog for the PHPCS native function: * - Introduced in PHPCS 0.0.5. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::hasCondition() Original source. * @see \PHPCSUtils\Utils\Conditions::hasCondition() PHPCSUtils native alternative. @@ -701,7 +705,7 @@ public static function hasCondition(File $phpcsFile, $stackPtr, $types) * * Changelog for the PHPCS native function: * - Introduced in PHPCS 1.3.0. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::getCondition() Original source. * @see \PHPCSUtils\Utils\Conditions::getCondition() More versatile alternative. @@ -732,7 +736,7 @@ public static function getCondition(File $phpcsFile, $stackPtr, $type, $first = * * Changelog for the PHPCS native function: * - Introduced in PHPCS 1.2.0. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::findExtendedClassName() Original source. * @see \PHPCSUtils\Utils\ObjectDeclarations::findExtendedClassName() PHPCSUtils native improved version. @@ -757,7 +761,7 @@ public static function findExtendedClassName(File $phpcsFile, $stackPtr) * * Changelog for the PHPCS native function: * - Introduced in PHPCS 2.7.0. - * - The upstream method has received no significant updates since PHPCS 3.9.0. + * - The upstream method has received no significant updates since PHPCS 3.10.0. * * @see \PHP_CodeSniffer\Files\File::findImplementedInterfaceNames() Original source. * @see \PHPCSUtils\Utils\ObjectDeclarations::findImplementedInterfaceNames() PHPCSUtils native improved version. diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCTokens.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCTokens.php index dac8feb1..2d6a72fd 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCTokens.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCTokens.php @@ -74,7 +74,7 @@ final class BCTokens /** * Handle calls to (undeclared) methods for token arrays which haven't received any - * changes since PHPCS 3.9.0. + * changes since PHPCS 3.10.0. * * @since 1.0.0 * diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php index 55904857..8242002b 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php @@ -84,7 +84,7 @@ * * * * @return array * * / - * public function dataMyMethod() + * public static function dataMyMethod() * { * return array( * array('/* testTestCaseDescription * /', false), diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php index a842c9ec..3a40fdcd 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php @@ -400,14 +400,16 @@ final class Collections * @var array */ private static $parameterTypeTokens = [ - \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_TYPE_UNION => \T_TYPE_UNION, - \T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION, + \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_TYPE_UNION => \T_TYPE_UNION, + \T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION, + \T_TYPE_OPEN_PARENTHESIS => \T_TYPE_OPEN_PARENTHESIS, + \T_TYPE_CLOSE_PARENTHESIS => \T_TYPE_CLOSE_PARENTHESIS, ]; /** @@ -446,14 +448,16 @@ final class Collections * @var array */ private static $propertyTypeTokens = [ - \T_CALLABLE => \T_CALLABLE, // Not allowed in PHP, but in this list to allow for (flagging) code errors. - \T_SELF => \T_SELF, - \T_PARENT => \T_PARENT, - \T_FALSE => \T_FALSE, - \T_TRUE => \T_TRUE, - \T_NULL => \T_NULL, - \T_TYPE_UNION => \T_TYPE_UNION, - \T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION, + \T_CALLABLE => \T_CALLABLE, // Not allowed in PHP, but in this list to allow for flagging code errors. + \T_SELF => \T_SELF, + \T_PARENT => \T_PARENT, + \T_FALSE => \T_FALSE, + \T_TRUE => \T_TRUE, + \T_NULL => \T_NULL, + \T_TYPE_UNION => \T_TYPE_UNION, + \T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION, + \T_TYPE_OPEN_PARENTHESIS => \T_TYPE_OPEN_PARENTHESIS, + \T_TYPE_CLOSE_PARENTHESIS => \T_TYPE_CLOSE_PARENTHESIS, ]; /** @@ -464,12 +468,14 @@ final class Collections * @var array */ private static $returnTypeTokens = [ - \T_CALLABLE => \T_CALLABLE, - \T_FALSE => \T_FALSE, - \T_TRUE => \T_TRUE, - \T_NULL => \T_NULL, - \T_TYPE_UNION => \T_TYPE_UNION, - \T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION, + \T_CALLABLE => \T_CALLABLE, + \T_FALSE => \T_FALSE, + \T_TRUE => \T_TRUE, + \T_NULL => \T_NULL, + \T_TYPE_UNION => \T_TYPE_UNION, + \T_TYPE_INTERSECTION => \T_TYPE_INTERSECTION, + \T_TYPE_OPEN_PARENTHESIS => \T_TYPE_OPEN_PARENTHESIS, + \T_TYPE_CLOSE_PARENTHESIS => \T_TYPE_CLOSE_PARENTHESIS, ]; /** diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Context.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Context.php index c0f1f947..b488060c 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Context.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Context.php @@ -209,7 +209,7 @@ public static function inForCondition(File $phpcsFile, $stackPtr) if ($tokens[$i]['level'] !== $level || \count($tokens[$i]['nested_parenthesis']) !== $parens ) { - // Disregard semi-colons at lower nesting/condition levels. + // Disregard semicolons at lower nesting/condition levels. continue; } diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ControlStructures.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ControlStructures.php index b343c736..02bbf02c 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ControlStructures.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ControlStructures.php @@ -214,8 +214,6 @@ public static function isElseIf(File $phpcsFile, $stackPtr) * * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the specified `$stackPtr` is not of * type `T_CATCH` or doesn't exist. - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If no parenthesis opener or closer can be - * determined (parse error). */ public static function getCaughtExceptions(File $phpcsFile, $stackPtr) { @@ -228,7 +226,7 @@ public static function getCaughtExceptions(File $phpcsFile, $stackPtr) } if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) { - throw new RuntimeException('Parentheses opener/closer of the T_CATCH could not be determined'); + return []; } $opener = $tokens[$stackPtr]['parenthesis_opener']; diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/FunctionDeclarations.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/FunctionDeclarations.php index e24bcf27..353ffdb1 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/FunctionDeclarations.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/FunctionDeclarations.php @@ -270,6 +270,25 @@ public static function getProperties(File $phpcsFile, $stackPtr) break; } + if ($tokens[$i]['code'] === \T_USE) { + // Skip over closure use statements. + for ( + $j = ($i + 1); + $j < $phpcsFile->numTokens && isset(Tokens::$emptyTokens[$tokens[$j]['code']]) === true; + $j++ + ); + + if ($tokens[$j]['code'] === \T_OPEN_PARENTHESIS) { + if (isset($tokens[$j]['parenthesis_closer']) === false) { + // Live coding/parse error, stop parsing. + break; + } + + $i = $tokens[$j]['parenthesis_closer']; + continue; + } + } + if ($tokens[$i]['code'] === \T_NULLABLE) { $nullableReturnType = true; } diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php index 49554580..cec7a27f 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php @@ -111,6 +111,6 @@ public static function isEqual($nameA, $nameB) } // Comparing via strcasecmp will only compare ASCII letters case-insensitively. - return (strcasecmp($nameA, $nameB) === 0); + return (\strcasecmp($nameA, $nameB) === 0); } } diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php index 00c6311d..0d65b8e4 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php @@ -49,12 +49,11 @@ final class PassedParameters * * - If passed a `T_STRING`, `T_NAME_FULLY_QUALIFIED`, `T_NAME_RELATIVE`, `T_NAME_QUALIFIED`, * or `T_VARIABLE` stack pointer, it will treat it as a function call. - * If a `T_STRING` or `T_VARIABLE` which is *not* a function call is passed, the behaviour is - * undetermined. + * If a token which is *not* a function call is passed, the behaviour is undetermined. * - If passed a `T_ANON_CLASS` stack pointer, it will accept it as a class instantiation. * - If passed a `T_SELF`, `T_STATIC` or `T_PARENT` stack pointer, it will accept it as a - * class instantiation function call when used like `new self()` (with or without parenthesis). - * When these hierarchiecal keywords are not preceded by the `new` keyword, parenthesis + * class instantiation function call when used like `new self()` (with or without parentheses). + * When these hierarchiecal keywords are not preceded by the `new` keyword, parentheses * will be required for the token to be accepted. * - If passed a `T_ARRAY` or `T_OPEN_SHORT_ARRAY` stack pointer, it will detect * whether the array has values or is empty. diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/UseStatements.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/UseStatements.php index 3fdf9d66..6e29f5f8 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/UseStatements.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/UseStatements.php @@ -192,10 +192,6 @@ public static function splitImportUseStatement(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - if (isset($tokens[$stackPtr]) === false || $tokens[$stackPtr]['code'] !== \T_USE) { - throw new RuntimeException('$stackPtr must be of type T_USE'); - } - if (self::isImportUse($phpcsFile, $stackPtr) === false) { throw new RuntimeException('$stackPtr must be an import use statement'); } @@ -301,9 +297,9 @@ public static function splitImportUseStatement(File $phpcsFile, $stackPtr) case \T_COMMA: if ($name !== '') { if ($useGroup === true) { - $statements[$type][$alias] = $baseName . $name; + $statements[$type][$alias] = \ltrim($baseName, '\\') . $name; } else { - $statements[$type][$alias] = $name; + $statements[$type][$alias] = \ltrim($name, '\\'); } } diff --git a/vendor/phpcsstandards/phpcsutils/README.md b/vendor/phpcsstandards/phpcsutils/README.md index 60cfe41d..c971fe4e 100644 --- a/vendor/phpcsstandards/phpcsutils/README.md +++ b/vendor/phpcsstandards/phpcsutils/README.md @@ -46,7 +46,7 @@ Whether you need to split an `array` into the individual items, are trying to de Includes improved versions of the PHPCS native utility functions and plenty of new utility functions. -These functions are compatible with PHPCS 3.9.0 up to PHPCS `master`. +These functions are compatible with PHPCS 3.10.0 up to PHPCS `master`. ### A collection of static properties and methods for often-used token groups @@ -66,7 +66,7 @@ Supports PHPUnit 4.x up to 9.x. Normally to use the latest version of PHP_CodeSniffer native utility functions, you would have to raise the minimum requirements of your external PHPCS standard. -Now you won't have to anymore. This package allows you to use the latest version of those utility functions in all PHP_CodeSniffer versions from PHPCS 3.9.0 and up. +Now you won't have to anymore. This package allows you to use the latest version of those utility functions in all PHP_CodeSniffer versions from PHPCS 3.10.0 and up. ### Fully documented @@ -78,7 +78,7 @@ To see detailed information about all the available abstract sniffs, utility fun ## Minimum Requirements * PHP 5.4 or higher. -* [PHP_CodeSniffer] 3.9.0+. +* [PHP_CodeSniffer] 3.10.0+. * Recommended PHP extensions for optimal functionality: - PCRE with Unicode support (normally enabled by default) diff --git a/vendor/phpcsstandards/phpcsutils/composer.json b/vendor/phpcsstandards/phpcsutils/composer.json index 0fe11b88..80167bcb 100644 --- a/vendor/phpcsstandards/phpcsutils/composer.json +++ b/vendor/phpcsstandards/phpcsutils/composer.json @@ -24,7 +24,7 @@ }, "require" : { "php" : ">=5.4", - "squizlabs/php_codesniffer" : "^3.9.0 || 4.0.x-dev@dev", + "squizlabs/php_codesniffer" : "^3.10.0 || 4.0.x-dev@dev", "dealerdirect/phpcodesniffer-composer-installer" : "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0" }, "require-dev" : { @@ -86,6 +86,7 @@ "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true - } + }, + "lock": false } } diff --git a/vendor/squizlabs/php_codesniffer/CHANGELOG.md b/vendor/squizlabs/php_codesniffer/CHANGELOG.md index 15cf61f3..c2dc3f53 100644 --- a/vendor/squizlabs/php_codesniffer/CHANGELOG.md +++ b/vendor/squizlabs/php_codesniffer/CHANGELOG.md @@ -1,10 +1,146 @@ # Changelog + The file documents changes to the PHP_CodeSniffer project. ## [Unreleased] _Nothing yet._ +## [3.10.1] - 2024-05-22 + +### Added +- Documentation for the following sniffs: + - Generic.Commenting.DocComment + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. + +### Changed +- The following have received efficiency improvements: + - Type handling in the PHP Tokenizer + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Various housekeeping, including improvements to the tests and documentation. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for their contributions. + +### Fixed +- Fixed bug [#110], [#437], [#475]: `File::findStartOfStatement()`: the start of statement/expression determination for tokens in parentheses/short array brackets/others scopes, nested within match expressions, was incorrect in most cases. + The trickle down effect of the bug fixes made to the `File::findStartOfStatement()` method, is that the Generic.WhiteSpace.ScopeIndent and the PEAR.WhiteSpace.ScopeIndent sniffs should now be able to correctly determine and fix the indent for match expressions containing nested expressions. + These fixes also fix an issue with the `Squiz.Arrays.ArrayDeclaration` sniff and possibly other, unreported bugs. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#504]: The tokenizer could inadvertently mistake the last parameter in a function call using named arguments for a DNF type. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#508]: Tokenizer/PHP: extra hardening against handling parse errors in the type handling layer. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch + +[#110]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/110 +[#437]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/437 +[#475]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/475 +[#504]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/504 +[#508]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/508 + +## [3.10.0] - 2024-05-20 + +### Added +- Tokenizer support for PHP 8.2 Disjunctive Normal Form (DNF) types. [#3731][sq-3731], [#387], [#461] + - Includes new `T_TYPE_OPEN_PARENTHESIS` and `T_TYPE_CLOSE_PARENTHESIS` tokens to represent the parentheses in DNF types. + - These new tokens, like other parentheses, will have the `parenthesis_opener` and `parenthesis_closer` token array indexes set and the tokens between them will have the `nested_parenthesis` index. + - The `File::getMethodProperties()`, `File::getMethodParameters()` and `File::getMemberProperties()` methods now all support DNF types. [#471], [#472], [#473] + - Additionally, the following sniff has been updated to support DNF types: + - Generic.PHP.LowerCaseType [#478] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patches. +- Documentation for the following sniffs: + - Squiz.WhiteSpace.FunctionClosingBraceSpace + - Thanks to [Przemek Hernik][@przemekhernik] for the patch. + +### Changed +- The help screens have received a face-lift for improved usability and readability. [#447] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch and thanks to [Colin Stewart][@costdev], [Gary Jones][@GaryJones] and [@mbomb007] for reviewing. +- The Squiz.Commenting.ClosingDeclarationComment sniff will now also examine and flag closing comments for traits. [#442] + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- The following sniff(s) have efficiency improvements: + - Generic.Arrays.ArrayIndent + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- The autoloader will now always return a boolean value indicating whether it has loaded a class or not. [#479] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Various housekeeping, including improvements to the tests and documentation. + - Thanks to [Dan Wallis][@fredden], [Danny van der Sluijs][@DannyvdSluijs], [Rodrigo Primo][@rodrigoprimo] and [Juliette Reinders Folmer][@jrfnl] for their contributions. + +### Fixed +- Fixed bug [#466] : Generic.Functions.CallTimePassByReference was not flagging call-time pass-by-reference in class instantiations using the self/parent/static keywords. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Fixed bug [#494] : edge case bug in tokenization of an empty block comment. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#494] : edge case bug in tokenization of an empty single-line DocBlock. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#499] : Generic.ControlStructures.InlineControlStructure now handles statements with a comment between `else` and `if` correctly. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. + +[sq-3731]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3731 +[#387]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/387 +[#442]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/442 +[#447]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/447 +[#461]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/461 +[#466]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/466 +[#471]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/471 +[#472]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/472 +[#473]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/473 +[#478]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/478 +[#479]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/479 +[#494]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/494 +[#499]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/499 + +## [3.9.2] - 2024-04-24 + +### Changed +- The Generic.ControlStructures.DisallowYodaConditions sniff no longer listens for the null coalesce operator. [#458] + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Various housekeeping, including improvements to the tests and documentation. + - Thanks to [Dan Wallis][@fredden], [Rodrigo Primo][@rodrigoprimo] and [Juliette Reinders Folmer][@jrfnl] for their contributions. + +### Fixed +- Fixed bug [#381] : Squiz.Commenting.ClosingDeclarationComment could throw the wrong error when the close brace being examined is at the very end of a file. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Fixed bug [#385] : Generic.CodeAnalysis.JumbledIncrementer improved handling of parse errors/live coding. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Fixed bug [#394] : Generic.Functions.CallTimePassByReference was not flagging call-time pass-by-reference in anonymous class instantiations + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Fixed bug [#420] : PEAR.Functions.FunctionDeclaration could run into a blocking PHP notice while fixing code containing a parse error. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#421] : File::getMethodProperties() small performance improvement & more defensive coding. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#423] : PEAR.WhiteSpace.ScopeClosingBrace would have a fixer conflict with itself when a close tag was preceded by non-empty inline HTML. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#424] : PSR2.Classes.ClassDeclaration using namespace relative interface names in the extends/implements part of a class declaration would lead to a fixer conflict. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#427] : Squiz.Operators.OperatorSpacing would have a fixer conflict with itself when an operator was preceeded by a new line and the previous line ended in a comment. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#430] : Squiz.ControlStructures.ForLoopDeclaration: fixed potential undefined array index notice + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#431] : PSR2.Classes.ClassDeclaration will no longer try to auto-fix multi-line interface implements statements if these are interlaced with comments on their own line. This prevents a potential fixer conflict. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#453] : Arrow function tokenization was broken when the return type was a stand-alone `true` or `false`; or contained `true` or `false` as part of a union type. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch + +### Other +- [ESLint 9.0] has been released and changes the supported configuration file format. + The (deprecated) `Generic.Debug.ESLint` sniff only supports the "old" configuration file formats and when using the sniff to run ESLint, the `ESLINT_USE_FLAT_CONFIG=false` environment variable will need to be set when using ESLint >= 9.0. + For more information, see [#436]. + + +[ESLint 9.0]: https://eslint.org/blog/2024/04/eslint-v9.0.0-released/#flat-config-is-now-the-default-and-has-some-changes + +[#381]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/381 +[#385]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/385 +[#394]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/394 +[#420]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/420 +[#421]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/421 +[#423]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/423 +[#424]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/424 +[#427]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/427 +[#430]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/430 +[#431]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/431 +[#436]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/436 +[#453]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/453 +[#458]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/458 + ## [3.9.1] - 2024-03-31 ### Added @@ -223,7 +359,7 @@ _Nothing yet._ - PHIVE users may need to clear the PHIVE URL cache. - PHIVE users who don't use the package alias, but refer to the package URL, will need to update the URL from `https://squizlabs.github.io/PHP_CodeSniffer/phars/` to `https://phars.phpcodesniffer.com/phars/`. - Users who download the PHAR files using curl or wget, will need to update the download URL from `https://squizlabs.github.io/PHP_CodeSniffer/[phpcs|phpcbf].phar` or `https://github.com/squizlabs/PHP_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. + - 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. @@ -271,7 +407,7 @@ _Nothing yet._ - 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) + - 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/bc302dd977877a22c5e60d42a2f6b7d9e9192dab) - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Changed @@ -284,7 +420,7 @@ _Nothing yet._ - 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 @@ -379,7 +515,7 @@ _Nothing yet._ - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug [#3785][sq-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][sq-3787] : PEAR/Squiz/[MultiLine]FunctionDeclaration: allow for PHP 8.1 new in initializers +- Fixed bug [#3787][sq-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][sq-3789] : Incorrect tokenization for ternary operator with `match` inside of it - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -465,6 +601,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-3913]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3913 ## [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 @@ -508,9 +645,10 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-3666]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3666 [sq-3668]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3668 [sq-3672]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3672 -[sq-3694]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3694 +[sq-3694]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3694 ## [3.7.1] - 2022-06-18 + ### Fixed - Fixed bug [#3609][sq-3609] : Methods/constants with name empty/isset/unset are always reported as error - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -518,6 +656,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-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 - This new syntax has been backfilled for PHP versions less than 8.1 @@ -591,6 +730,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-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 - Thanks to [Thiemo Kreuz][@thiemowmde] for the patch @@ -629,6 +769,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-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 - Previously, only slash-style and block-style comments could be used to do things like disable errors @@ -729,6 +870,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-3445]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3445 ## [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 @@ -824,7 +966,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - The default remains at "private", so all methods are checked - 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 + - 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][@VincentLanglet] for the patch @@ -904,11 +1046,13 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-3284]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3284 ## [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 @@ -987,6 +1131,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-3135]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3135 ## [3.5.6] - 2020-08-10 + ### Added - Added support for PHP 8.0 magic constant dereferencing - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -1032,6 +1177,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-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 - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -1074,6 +1220,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2895]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2895 ## [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][@jrfnl] for the patch @@ -1151,6 +1298,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2843]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2843 ## [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 @@ -1218,6 +1366,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2702]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2702 ## [3.5.2] - 2019-10-28 + ### Changed - Generic.ControlStructures.DisallowYodaConditions now returns less false positives - False positives were being returned for array comparisons, or when performing some function calls @@ -1245,6 +1394,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2673]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2673 ## [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 @@ -1289,6 +1439,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2641]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2641 ## [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 @@ -1359,7 +1510,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 + - 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 @@ -1483,6 +1634,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2608]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2608 ## [3.4.2] - 2019-04-11 + ### Changed - Squiz.Arrays.ArrayDeclaration now has improved handling of syntax errors @@ -1511,6 +1663,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2467]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2467 ## [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 @@ -1579,7 +1732,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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][@jrfnl] for the patch -- Zend.Files.ClosingTag no longer adds a semi-colon during fixing of a file that only contains a comment +- Zend.Files.ClosingTag no longer adds a semicolon during fixing of a file that only contains a comment - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Zend.NamingConventions.ValidVariableName now supports variables inside anonymous classes correctly - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -1605,6 +1758,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2431]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2431 ## [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 @@ -1792,6 +1946,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2297]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2297 ## [2.9.2] - 2018-11-08 + ### Changed - PHPCS should now run under PHP 7.3 without deprecation warnings - Thanks to [Nick Wilde][@NickDickinsonWilde] for the patch @@ -1803,11 +1958,8 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug [#1890][sq-1890] : Incorrect Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose error between catch and finally statements -[sq-1496]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1496 -[sq-1549]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1549 -[sq-1890]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1890 - ## [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 @@ -1837,7 +1989,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug [#2127][sq-2127] : File::findExtendedClassName() doesn't support nested classes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#2138][sq-2138] : Tokenizer detects wrong token for php ::class feature with spaces +- Fixed bug [#2138][sq-2138] : Tokenizer detects wrong token for PHP ::class feature with spaces - Fixed bug [#2143][sq-2143] : PSR2.Namespaces.UseDeclaration does not properly fix "use function" and "use const" statements - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch - Fixed bug [#2144][sq-2144] : Squiz.Arrays.ArrayDeclaration does incorrect align calculation in array with cyrillic keys @@ -1856,6 +2008,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2151]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2151 ## [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][@photodude] and [Juliette Reinders Folmer][@jrfnl] for helping to remove all HHVM exceptions from the core @@ -1877,7 +2030,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 + - Setting the `php_path` config var will still override this value as normal - 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 @@ -1928,6 +2081,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2095]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2095 ## [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 @@ -1994,8 +2148,8 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- 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 @@ -2161,6 +2315,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-2027]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2027 ## [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 @@ -2227,11 +2382,13 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1901]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1901 ## [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][sq-1781]) - Generic.Functions.OpeningFunctionBraceKernighanRitchie no longer complains when the open brace is followed by a close tag @@ -2247,6 +2404,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1782]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1782 ## [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 @@ -2362,7 +2520,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed bug [#1757][sq-1757] : Unknown type hint "object" in Squiz.Commenting.FunctionComment - Fixed bug [#1758][sq-1758] : PHPCS gets stuck creating file list when processing circular symlinks - Fixed bug [#1761][sq-1761] : Generic.WhiteSpace.ScopeIndent error on multi-line function call with static closure argument -- Fixed bug [#1762][sq-1762] : Generic.WhiteSpace.Disallow[Space/Tab]Indent not inspecting content before open tag +- Fixed bug [#1762][sq-1762] : `Generic.WhiteSpace.Disallow[Space/Tab]Indent` not inspecting content before open tag - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Fixed bug [#1769][sq-1769] : Custom "define" function triggers a warning about declaring new symbols - Fixed bug [#1776][sq-1776] : Squiz.Scope.StaticThisUsage incorrectly looking inside anon classes @@ -2387,6 +2545,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1777]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1777 ## [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 @@ -2428,13 +2587,14 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1702]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1702 ## [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 + - 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][@jrfnl] for the patch - A phpcs.xml or phpcs.xml.dist file now takes precedence over the default_standard config setting @@ -2514,6 +2674,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1640]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1640 ## [3.0.2] - 2017-07-18 + ### Changed - The code report now gracefully handles tokenizer exceptions - The phpcs and phpcbf scripts are now the only places that exit() in the code @@ -2558,6 +2719,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1560]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1560 ## [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 @@ -2596,7 +2758,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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][sq-1442] : T_NULLABLE detection not working for nullable parameters and return type hints in some cases -- Fixed bug [#1447][sq-1447] : Running the unit tests with a phpunit config file breaks the test suite +- Fixed bug [#1447][sq-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][sq-1449] : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -2611,7 +2773,6 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed bug [#1501][sq-1501] : Interactive mode is broken - Fixed bug [#1504][sq-1504] : PSR2.Namespaces.UseDeclaration hangs fixing use statement with no trailing code -[sq-1442]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1442 [sq-1447]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1447 [sq-1449]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1449 [sq-1450]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1450 @@ -2624,6 +2785,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1504]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1504 ## [2.9.1] - 2017-05-22 + ### Fixed - Fixed bug [#1442][sq-1442] : T_NULLABLE detection not working for nullable parameters and return type hints in some cases - Fixed bug [#1448][sq-1448] : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace @@ -2633,6 +2795,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1448]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1448 ## [3.0.0] - 2017-05-04 + ### Changed - Added an --ignore-annotations command line argument to ignore all @codingStandards annotations in code comments (request [#811][sq-811]) - This allows you to force errors to be shown that would otherwise be ignored by code comments @@ -2660,6 +2823,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1129]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1129 ## [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 @@ -2696,6 +2860,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1334]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1334 ## [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 @@ -2726,6 +2891,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1270]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1270 ## [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][sq-1186]) @@ -2742,6 +2908,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1208]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1208 ## [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 @@ -2763,6 +2930,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-699]: https://github.com/squizlabs/PHP_CodeSniffer/issues/699 ## [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][sq-530]) @@ -2785,7 +2953,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 + - 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 @@ -2850,6 +3018,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-930]: https://github.com/squizlabs/PHP_CodeSniffer/issues/930 ## [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 @@ -2905,6 +3074,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1432]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1432 ## [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 @@ -2958,6 +3128,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1369]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1369 ## [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 @@ -3040,6 +3211,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1304]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1304 ## [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 @@ -3092,6 +3264,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1224]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1224 ## [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 if you have a generated list of files to check that would be too long for the command line @@ -3141,11 +3314,11 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Improved the formatting of the end brace when auto fixing InlineControlStructure errors (request [#1121][sq-1121]) - Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine fix no longer leaves blank line after brace (request [#1085][sq-1085]) - Generic UpperCaseConstantNameSniff now allows lowercase namespaces in constant definitions - - Thanks to [Daniel Schniepp][@dschniepp] 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) + - 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][@ofbeaton] for the patch @@ -3153,7 +3326,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed bug [#985][sq-985] : Duplicate class definition detection generates false-positives in media queries - Thanks to [Raphael Horber][@rhorber] for the patch - Fixed bug [#1014][sq-1014] : Squiz VariableCommentSniff doesn't always detect a missing comment -- Fixed bug [#1066][sq-1066] : Undefined index: quiet in CLI.php during unit test run with -v command line arg +- Fixed bug [#1066][sq-1066] : Undefined index: quiet in `CLI.php` during unit test run with `-v` command line arg - Fixed bug [#1072][sq-1072] : Squiz.SelfMemberReference.NotUsed not detected if leading namespace separator is used - Fixed bug [#1089][sq-1089] : Rulesets cannot be loaded if the path contains urlencoded characters - Fixed bug [#1091][sq-1091] : PEAR and Squiz FunctionComment sniffs throw errors for some invalid @param line formats @@ -3192,6 +3365,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1124]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1124 ## [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][sq-904]) - Accepts the same sniff codes as the --sniffs command line argument, but provides the opposite functionality @@ -3244,6 +3418,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [pear-21050]: https://pear.php.net/bugs/bug.php?id=21050 ## [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 @@ -3293,6 +3468,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-1025]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1025 ## [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][sq-847]) - This change only applies to paths within ARG tags, used to set CLI arguments @@ -3311,7 +3487,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 + - You can still manually set `php_path` to use a specific binary for testing - 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][sq-878]) @@ -3358,7 +3534,6 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed bug [#938][sq-938] : CallTimePassByReferenceSniff ignores functions with return value [sq-542]: https://github.com/squizlabs/PHP_CodeSniffer/issues/542 -[sq-698]: https://github.com/squizlabs/PHP_CodeSniffer/issues/698 [sq-791]: https://github.com/squizlabs/PHP_CodeSniffer/issues/791 [sq-847]: https://github.com/squizlabs/PHP_CodeSniffer/issues/847 [sq-872]: https://github.com/squizlabs/PHP_CodeSniffer/issues/872 @@ -3383,6 +3558,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-938]: https://github.com/squizlabs/PHP_CodeSniffer/issues/938 ## [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 @@ -3390,7 +3566,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Generic LowerCaseKeyword now ensures array type hints are lowercase as well - 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 +- PHP_CodesSniffer now includes the composer `autoload.php` file, if there is one - Thanks to [Klaus Purer][@klausi] for the patch - Added error Squiz.Commenting.FunctionComment.ScalarTypeHintMissing for PHP7 only (request [#858][sq-858]) - These errors were previously reported as Squiz.Commenting.FunctionComment.TypeHintMissing on PHP7 @@ -3456,6 +3632,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [pear-21011]: https://pear.php.net/bugs/bug.php?id=21011 ## [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][sq-626]) - PHPCS will now use a phpcs.xml file even if files are specified on the command line @@ -3499,6 +3676,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-813]: https://github.com/squizlabs/PHP_CodeSniffer/issues/813 ## [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 @@ -3583,6 +3761,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-782]: https://github.com/squizlabs/PHP_CodeSniffer/issues/782 ## [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 @@ -3636,6 +3815,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-689]: https://github.com/squizlabs/PHP_CodeSniffer/issues/689 ## [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][@klausi] for the patch @@ -3652,7 +3832,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed bug [#584][sq-584] : Squiz.Arrays.ArrayDeclaration sniff gives incorrect NoComma error for multiline string values - Fixed bug [#589][sq-589] : PEAR.Functions.FunctionCallSignature sniff not checking all function calls -- Fixed bug [#592][sq-592] : USE statement tokenising can sometimes result in mismatched scopes +- Fixed bug [#592][sq-592] : USE statement tokenizing can sometimes result in mismatched scopes - Fixed bug [#594][sq-594] : Tokenizer issue on closure that returns by reference - Fixed bug [#595][sq-595] : Colons in CSS selectors within media queries throw false positives - Thanks to [Klaus Purer][@klausi] for the patch @@ -3683,6 +3863,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-621]: https://github.com/squizlabs/PHP_CodeSniffer/issues/621 ## [2.3.2] - 2015-04-29 + ### Changed - The error message for PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase is now clearer (request [#579][sq-579]) @@ -3701,6 +3882,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-579]: https://github.com/squizlabs/PHP_CodeSniffer/issues/579 ## [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 @@ -3749,9 +3931,10 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-564]: https://github.com/squizlabs/PHP_CodeSniffer/issues/564 ## [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][sq-486]) -- Abstract classes inside the Sniffs directory are now ignored even if they are named [Name]Sniff.php (request [#476][sq-476]) +- Abstract classes inside the Sniffs directory are now ignored even if they are named `[Name]Sniff.php` (request [#476][sq-476]) - 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 @@ -3796,7 +3979,6 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Generic ScopeIndentSniff may now report fewer errors for closures, but perform the same fixes - Fixed bug [#502][sq-502] : PSR1 SideEffectsSniff sees declare() statements as side effects -[sq-263]: https://github.com/squizlabs/PHP_CodeSniffer/issues/263 [sq-415]: https://github.com/squizlabs/PHP_CodeSniffer/issues/415 [sq-432]: https://github.com/squizlabs/PHP_CodeSniffer/issues/432 [sq-453]: https://github.com/squizlabs/PHP_CodeSniffer/issues/453 @@ -3817,6 +3999,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-502]: https://github.com/squizlabs/PHP_CodeSniffer/issues/502 ## [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 @@ -3908,6 +4091,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [pear-20482]: https://pear.php.net/bugs/bug.php?id=20482 ## [2.1.0] - 2014-12-18 + ### Changed - Time and memory output is now shown if progress information is also shown (request [#335][sq-335]) - A tilde can now be used to reference a user's home directory in a path to a standard (request [#353][sq-353]) @@ -3921,12 +4105,12 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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][sq-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 + - 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 +- 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][sq-324] and request [#369][sq-369] @@ -3975,6 +4159,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [pear-20196]: https://pear.php.net/bugs/bug.php?id=20196 ## [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 @@ -4008,11 +4193,11 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed bug [#320][sq-320] : Code sniffer indentation issue - Fixed bug [#333][sq-333] : Nested ternary operators causing problems -[sq-311]: https://github.com/squizlabs/PHP_CodeSniffer/issues/311 [sq-320]: https://github.com/squizlabs/PHP_CodeSniffer/issues/320 [sq-333]: https://github.com/squizlabs/PHP_CodeSniffer/issues/333 ## [1.5.6] - 2014-12-05 + ### Changed - JS tokenizer now detects xor statements correctly - The --config-show command now pretty-prints the config values @@ -4033,13 +4218,10 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed bug [#310][sq-310] : Variadics not recognized by tokenizer - Fixed bug [#311][sq-311] : Suppression of function prototype breaks checking of lines within function -[sq-280]: https://github.com/squizlabs/PHP_CodeSniffer/issues/280 -[sq-306]: https://github.com/squizlabs/PHP_CodeSniffer/issues/306 -[sq-308]: https://github.com/squizlabs/PHP_CodeSniffer/issues/308 -[sq-310]: https://github.com/squizlabs/PHP_CodeSniffer/issues/310 [sq-311]: https://github.com/squizlabs/PHP_CodeSniffer/issues/311 ## [2.0.0RC4] - 2014-11-07 + ### Changed - JS tokenizer now detects xor statements correctly - Improved detection of properties and objects in the JS tokenizer @@ -4082,6 +4264,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-310]: https://github.com/squizlabs/PHP_CodeSniffer/issues/310 ## [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 @@ -4110,6 +4293,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-285]: https://github.com/squizlabs/PHP_CodeSniffer/issues/285 ## [2.0.0RC2] - 2014-09-26 + ### Changed - Minified JS and CSS files are now detected and skipped (fixes bug [#252][sq-252] and bug [#19899][pear-19899]) - A warning will be added to the file so it can be found in the report and ignored in the future @@ -4121,7 +4305,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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" + - property `name="[property]" type="array" value="foo=>bar,baz=>qux"` - Generic ForbiddenFunctionsSniff now has a public property called forbiddenFunctions (request [#263][sq-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 @@ -4170,20 +4354,15 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed bug [#20402][pear-20402] : SVN pre-commit hook fails due to unknown argument error [sq-243]: https://github.com/squizlabs/PHP_CodeSniffer/issues/243 -[sq-248]: https://github.com/squizlabs/PHP_CodeSniffer/issues/248 [sq-252]: https://github.com/squizlabs/PHP_CodeSniffer/issues/252 [sq-262]: https://github.com/squizlabs/PHP_CodeSniffer/issues/262 [sq-263]: https://github.com/squizlabs/PHP_CodeSniffer/issues/263 -[sq-265]: https://github.com/squizlabs/PHP_CodeSniffer/pull/265 [pear-19899]: https://pear.php.net/bugs/bug.php?id=19899 -[pear-20323]: https://pear.php.net/bugs/bug.php?id=20323 -[pear-20373]: https://pear.php.net/bugs/bug.php?id=20373 [pear-20377]: https://pear.php.net/bugs/bug.php?id=20377 -[pear-20378]: https://pear.php.net/bugs/bug.php?id=20378 -[pear-20381]: https://pear.php.net/bugs/bug.php?id=20381 [pear-20402]: https://pear.php.net/bugs/bug.php?id=20402 ## [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 @@ -4211,13 +4390,13 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [sq-248]: https://github.com/squizlabs/PHP_CodeSniffer/issues/248 [sq-265]: https://github.com/squizlabs/PHP_CodeSniffer/pull/265 -[pear-20323]: https://pear.php.net/bugs/bug.php?id=20323 [pear-20373]: https://pear.php.net/bugs/bug.php?id=20373 [pear-20378]: https://pear.php.net/bugs/bug.php?id=20378 [pear-20381]: https://pear.php.net/bugs/bug.php?id=20381 [pear-20386]: https://pear.php.net/bugs/bug.php?id=20386 ## [2.0.0RC1] - 2014-08-06 + ### Changed - PHPCBF will now fix incorrect newline characters in a file - PHPCBF now exits cleanly when there are no errors to fix @@ -4286,24 +4465,13 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed bug [#20346][pear-20346] : Fixer endless loop with Squiz.CSS sniffs - Fixed bug [#20355][pear-20355] : No sniffs are registered with PHAR on Windows -[pear-20234]: https://pear.php.net/bugs/bug.php?id=20234 [pear-20261]: https://pear.php.net/bugs/bug.php?id=20261 -[pear-20268]: https://pear.php.net/bugs/bug.php?id=20268 -[pear-20296]: https://pear.php.net/bugs/bug.php?id=20296 [pear-20297]: https://pear.php.net/bugs/bug.php?id=20297 -[pear-20299]: https://pear.php.net/bugs/bug.php?id=20299 -[pear-20307]: https://pear.php.net/bugs/bug.php?id=20307 -[pear-20308]: https://pear.php.net/bugs/bug.php?id=20308 -[pear-20309]: https://pear.php.net/bugs/bug.php?id=20309 -[pear-20310]: https://pear.php.net/bugs/bug.php?id=20310 -[pear-20313]: https://pear.php.net/bugs/bug.php?id=20313 -[pear-20314]: https://pear.php.net/bugs/bug.php?id=20314 -[pear-20322]: https://pear.php.net/bugs/bug.php?id=20322 -[pear-20323]: https://pear.php.net/bugs/bug.php?id=20323 [pear-20346]: https://pear.php.net/bugs/bug.php?id=20346 [pear-20355]: https://pear.php.net/bugs/bug.php?id=20355 ## [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 @@ -4350,6 +4518,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [pear-20323]: https://pear.php.net/bugs/bug.php?id=20323 ## [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 @@ -4399,20 +4568,10 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed bug [#20248][pear-20248] : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope - Fixed bug [#20252][pear-20252] : Unitialized string offset when package name starts with underscore -[pear-20200]: https://pear.php.net/bugs/bug.php?id=20200 -[pear-20204]: https://pear.php.net/bugs/bug.php?id=20204 -[pear-20208]: https://pear.php.net/bugs/bug.php?id=20208 -[pear-20213]: https://pear.php.net/bugs/bug.php?id=20213 -[pear-20225]: https://pear.php.net/bugs/bug.php?id=20225 -[pear-20230]: https://pear.php.net/bugs/bug.php?id=20230 [pear-20234]: https://pear.php.net/bugs/bug.php?id=20234 -[pear-20240]: https://pear.php.net/bugs/bug.php?id=20240 -[pear-20241]: https://pear.php.net/bugs/bug.php?id=20241 -[pear-20247]: https://pear.php.net/bugs/bug.php?id=20247 -[pear-20248]: https://pear.php.net/bugs/bug.php?id=20248 -[pear-20252]: https://pear.php.net/bugs/bug.php?id=20252 ## [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 @@ -4454,6 +4613,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [pear-20252]: https://pear.php.net/bugs/bug.php?id=20252 ## [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 @@ -4461,11 +4621,11 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 + - 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 + - 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 now 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 @@ -4505,6 +4665,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 @@ -4549,8 +4710,9 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [pear-20190]: https://pear.php.net/bugs/bug.php?id=20190 ## [1.5.1] - 2013-12-12 + ### Changed -- Config values can now be set at runtime using the command line argument [--runtime-set key value] +- 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][@wimg] for the patch - Config values can now be set in ruleset files @@ -4573,12 +4735,12 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Gaetan Rousseau][@Naelyth] for the patch - Fixed bug [#20139][pear-20139] : No report file generated on success -[pear-20100]: https://pear.php.net/bugs/bug.php?id=20100 [pear-20136]: https://pear.php.net/bugs/bug.php?id=20136 [pear-20138]: https://pear.php.net/bugs/bug.php?id=20138 [pear-20139]: https://pear.php.net/bugs/bug.php?id=20139 ## [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 @@ -4602,7 +4764,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed bug [#20093][pear-20093] : Bug with ternary operator token -- Fixed bug [#20097][pear-20097] : CLI.php throws error in php 5.2 +- Fixed bug [#20097][pear-20097] : `CLI.php` throws error in PHP 5.2 - Fixed bug [#20100][pear-20100] : incorrect Function mysql() has been deprecated report - Fixed bug [#20119][pear-20119] : PHP warning: invalid argument to str_repeat() in SVN blame report with -s - Fixed bug [#20123][pear-20123] : PSR2 complains about an empty second statement in for-loop @@ -4612,14 +4774,9 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [pear-20090]: https://pear.php.net/bugs/bug.php?id=20090 [pear-20091]: https://pear.php.net/bugs/bug.php?id=20091 [pear-20093]: https://pear.php.net/bugs/bug.php?id=20093 -[pear-20097]: https://pear.php.net/bugs/bug.php?id=20097 -[pear-20100]: https://pear.php.net/bugs/bug.php?id=20100 -[pear-20119]: https://pear.php.net/bugs/bug.php?id=20119 -[pear-20123]: https://pear.php.net/bugs/bug.php?id=20123 -[pear-20131]: https://pear.php.net/bugs/bug.php?id=20131 -[pear-20133]: https://pear.php.net/bugs/bug.php?id=20133 ## [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: @@ -4636,14 +4793,22 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Maksim Kochkin][@ksimka] 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 +- Fixed bug [#20097][pear-20097] : `CLI.php` throws error in PHP 5.2 +- Fixed bug [#20100][pear-20100] : incorrect Function mysql() has been deprecated report +- Fixed bug [#20119][pear-20119] : PHP warning: invalid argument to str_repeat() in SVN blame report with -s +- Fixed bug [#20123][pear-20123] : PSR2 complains about an empty second statement in for-loop +- Fixed bug [#20131][pear-20131] : PHP errors in svnblame report, if there are files not under version control +- Fixed bug [#20133][pear-20133] : Allow "HG: hg_id" as value for @version tag + +[pear-20097]: https://pear.php.net/bugs/bug.php?id=20097 +[pear-20100]: https://pear.php.net/bugs/bug.php?id=20100 +[pear-20119]: https://pear.php.net/bugs/bug.php?id=20119 +[pear-20123]: https://pear.php.net/bugs/bug.php?id=20123 +[pear-20131]: https://pear.php.net/bugs/bug.php?id=20131 +[pear-20133]: https://pear.php.net/bugs/bug.php?id=20133 ## [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 @@ -4656,7 +4821,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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) +- Version information is now printed when installed via composer or run from a Git clone (request [#20050][pear-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 @@ -4693,22 +4858,25 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#20026][pear-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 +- Fixed bug [#20029][pear-20029] : ForbiddenFunction sniff incorrectly recognizes methods in USE clauses +- Fixed bug [#20043][pear-20043] : Mis-interpretation of Foo::class +- Fixed bug [#20044][pear-20044] : PSR1 camelCase check does not ignore leading underscores +- Fixed bug [#20045][pear-20045] : Errors about indentation for closures with multi-line 'use' in functions +- Fixed bug [#20051][pear-20051] : Undefined index: scope_opener / scope_closer - Thanks to [Anthon Pang][@robocoder] for the patch +[pear-20051]: https://pear.php.net/bugs/bug.php?id=20051 + ## [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][@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) +- Version information is now printed when installed via composer or run from a Git clone (request [#20050][pear-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][@sjlangley] for the patch @@ -4742,14 +4910,22 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#20026][pear-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 [#20029][pear-20029] : ForbiddenFunction sniff incorrectly recognizes methods in USE clauses +- Fixed bug [#20043][pear-20043] : Mis-interpretation of Foo::class +- Fixed bug [#20044][pear-20044] : PSR1 camelCase check does not ignore leading underscores +- Fixed bug [#20045][pear-20045] : Errors about indentation for closures with multi-line 'use' in functions + +[pear-20026]: https://pear.php.net/bugs/bug.php?id=20026 +[pear-20029]: https://pear.php.net/bugs/bug.php?id=20029 +[pear-20043]: https://pear.php.net/bugs/bug.php?id=20043 +[pear-20044]: https://pear.php.net/bugs/bug.php?id=20044 +[pear-20045]: https://pear.php.net/bugs/bug.php?id=20045 +[pear-20050]: https://pear.php.net/bugs/bug.php?id=20050 ## [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][@jeffslofish] for the contribution @@ -4798,23 +4974,26 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Arnout Boks][@aboks] for the patch ### Fixed -- Fixed bug #19811 : Comments not ignored in all cases in AbstractPatternSniff +- Fixed bug [#19811][pear-19811] : Comments not ignored in all cases in AbstractPatternSniff - 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 +- Fixed bug [#19892][pear-19892] : ELSE with no braces causes incorrect SWITCH break statement indentation error +- Fixed bug [#19897][pear-19897] : Indenting warnings in templates not consistent +- Fixed bug [#19908][pear-19908] : PEAR MultiLineCondition Does Not Apply elseif +- Fixed bug [#19930][pear-19930] : option --report-file generate an empty file +- Fixed bug [#19935][pear-19935] : notify-send reports do not vanish in gnome-shell - 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 -- 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 +- Fixed bug [#19944][pear-19944] : docblock squiz sniff "return void" trips over return in lambda function +- Fixed bug [#19953][pear-19953] : PSR2 - Spaces before interface name for abstract class +- Fixed bug [#19956][pear-19956] : phpcs warns for Type Hint missing Resource +- Fixed bug [#19957][pear-19957] : Does not understand trait method aliasing +- Fixed bug [#19968][pear-19968] : Permission denied on excluded directory +- Fixed bug [#19969][pear-19969] : Sniffs with namespace not recognized in reports +- Fixed bug [#19997][pear-19997] : Class names incorrectly detected as constants + +[pear-19930]: https://pear.php.net/bugs/bug.php?id=19930 ## [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][@jeffslofish] for the contribution @@ -4859,39 +5038,54 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Arnout Boks][@aboks] for the patch ### Fixed -- Fixed bug #19811 : Comments not ignored in all cases in AbstractPatternSniff +- Fixed bug [#19811][pear-19811] : Comments not ignored in all cases in AbstractPatternSniff - 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 +- Fixed bug [#19892][pear-19892] : ELSE with no braces causes incorrect SWITCH break statement indentation error +- Fixed bug [#19897][pear-19897] : Indenting warnings in templates not consistent +- Fixed bug [#19908][pear-19908] : PEAR MultiLineCondition Does Not Apply elseif +- Fixed bug [#19913][pear-19913] : Running phpcs in interactive mode causes warnings - Thanks to [Harald Franndorfer][pear-gemineye] for the patch -- Fixed bug #19935 : notify-send reports do not vanish in gnome-shell +- Fixed bug [#19935][pear-19935] : notify-send reports do not vanish in gnome-shell - 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 -- 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 +- Fixed bug [#19944][pear-19944] : docblock squiz sniff "return void" trips over return in lambda function +- Fixed bug [#19953][pear-19953] : PSR2 - Spaces before interface name for abstract class +- Fixed bug [#19956][pear-19956] : phpcs warns for Type Hint missing Resource +- Fixed bug [#19957][pear-19957] : Does not understand trait method aliasing +- Fixed bug [#19968][pear-19968] : Permission denied on excluded directory +- Fixed bug [#19969][pear-19969] : Sniffs with namespace not recognized in reports +- Fixed bug [#19997][pear-19997] : Class names incorrectly detected as constants + +[pear-19811]: https://pear.php.net/bugs/bug.php?id=19811 +[pear-19892]: https://pear.php.net/bugs/bug.php?id=19892 +[pear-19897]: https://pear.php.net/bugs/bug.php?id=19897 +[pear-19908]: https://pear.php.net/bugs/bug.php?id=19908 +[pear-19913]: https://pear.php.net/bugs/bug.php?id=19913 +[pear-19935]: https://pear.php.net/bugs/bug.php?id=19935 +[pear-19944]: https://pear.php.net/bugs/bug.php?id=19944 +[pear-19953]: https://pear.php.net/bugs/bug.php?id=19953 +[pear-19956]: https://pear.php.net/bugs/bug.php?id=19956 +[pear-19957]: https://pear.php.net/bugs/bug.php?id=19957 +[pear-19968]: https://pear.php.net/bugs/bug.php?id=19968 +[pear-19969]: https://pear.php.net/bugs/bug.php?id=19969 +[pear-19997]: https://pear.php.net/bugs/bug.php?id=19997 ## [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) +- You can now pass multiple coding standards on the command line, comma separated (request [#19144][pear-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) +- You can now exclude directories or whole standards in a ruleset XML file (request [#19731][pear-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) +- Added Generic SAPIUsageSniff to ensure the `PHP_SAPI` constant is used instead of `php_sapi_name()` (request [#19863][pear-19863]) +- Squiz FunctionSpacingSniff now has a setting to specify how many lines there should between functions (request [#19843][pear-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 @@ -4915,18 +5109,22 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#19819][pear-19819] : Freeze with syntax error in use statement +- Fixed bug [#19820][pear-19820] : Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff +- Fixed bug [#19859][pear-19859] : CodeSniffer::setIgnorePatterns API changed +- Fixed bug [#19871][pear-19871] : findExtendedClassName doesn't return FQCN on namespaced classes +- Fixed bug [#19879][pear-19879] : bitwise and operator interpreted as reference by value + +[pear-19144]: https://pear.php.net/bugs/bug.php?id=19144 +[pear-19731]: https://pear.php.net/bugs/bug.php?id=19731 ## [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) +- Added Generic SAPIUsageSniff to ensure the `PHP_SAPI` constant is used instead of `php_sapi_name()` (request [#19863][pear-19863]) +- Squiz FunctionSpacingSniff now has a setting to specify how many lines there should between functions (request [#19843][pear-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 @@ -4950,22 +5148,32 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#19819][pear-19819] : Freeze with syntax error in use statement +- Fixed bug [#19820][pear-19820] : Wrong message level in Generic_Sniffs_CodeAnalysis_EmptyStatementSniff +- Fixed bug [#19859][pear-19859] : CodeSniffer::setIgnorePatterns API changed +- Fixed bug [#19871][pear-19871] : findExtendedClassName doesn't return FQCN on namespaced classes +- Fixed bug [#19879][pear-19879] : bitwise and operator interpreted as reference by value + +[pear-19819]: https://pear.php.net/bugs/bug.php?id=19819 +[pear-19820]: https://pear.php.net/bugs/bug.php?id=19820 +[pear-19843]: https://pear.php.net/bugs/bug.php?id=19843 +[pear-19859]: https://pear.php.net/bugs/bug.php?id=19859 +[pear-19863]: https://pear.php.net/bugs/bug.php?id=19863 +[pear-19871]: https://pear.php.net/bugs/bug.php?id=19871 +[pear-19879]: https://pear.php.net/bugs/bug.php?id=19879 ## [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 + - 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][@becoded] for the patch @@ -4973,7 +5181,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Set full command to run CSSLint using phpcs --config-set csslint_path /path/to/csslint - 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 + - Fixes bug [#19732][pear-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][@index0h] for the patch - Generic EndFileNewlineSniff now supports JS and CSS files @@ -4989,17 +5197,29 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#19755][pear-19755] : Token of T_CLASS type has no scope_opener and scope_closer keys +- Fixed bug [#19759][pear-19759] : Squiz.PHP.NonExecutableCode fails for return function()... +- Fixed bug [#19763][pear-19763] : Use statements for traits not recognised correctly for PSR2 code style +- Fixed bug [#19764][pear-19764] : Instead of for traits throws uppercase constant name errors +- Fixed bug [#19772][pear-19772] : PSR2_Sniffs_Namespaces_UseDeclarationSniff does not properly recognize last use +- Fixed bug [#19775][pear-19775] : False positive in NonExecutableCode sniff when not using curly braces +- Fixed bug [#19782][pear-19782] : Invalid found size functions in loop when using object operator +- Fixed bug [#19799][pear-19799] : config folder is not created automatically +- Fixed bug [#19804][pear-19804] : JS Tokenizer wrong /**/ parsing + +[pear-19732]: https://pear.php.net/bugs/bug.php?id=19732 +[pear-19755]: https://pear.php.net/bugs/bug.php?id=19755 +[pear-19759]: https://pear.php.net/bugs/bug.php?id=19759 +[pear-19763]: https://pear.php.net/bugs/bug.php?id=19763 +[pear-19764]: https://pear.php.net/bugs/bug.php?id=19764 +[pear-19772]: https://pear.php.net/bugs/bug.php?id=19772 +[pear-19775]: https://pear.php.net/bugs/bug.php?id=19775 +[pear-19782]: https://pear.php.net/bugs/bug.php?id=19782 +[pear-19799]: https://pear.php.net/bugs/bug.php?id=19799 +[pear-19804]: https://pear.php.net/bugs/bug.php?id=19804 ## [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 @@ -5015,14 +5235,19 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Andy Grunwald][@andygrunwald] 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 { +- Fixed bug [#19699][pear-19699] : Generic.Files.LineLength giving false positives when tab-width is used +- Fixed bug [#19726][pear-19726] : Wrong number of spaces expected after instanceof static +- Fixed bug [#19727][pear-19727] : PSR2: no error reported when using } elseif { + +[pear-19699]: https://pear.php.net/bugs/bug.php?id=19699 +[pear-19726]: https://pear.php.net/bugs/bug.php?id=19726 +[pear-19727]: https://pear.php.net/bugs/bug.php?id=19727 ## [1.4.2] - 2012-11-09 + ### Changed - PHP_CodeSniffer can now be installed using Composer - - Require squizlabs/php_codesniffer in your composer.json file + - Require `squizlabs/php_codesniffer` in your `composer.json` file - 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 @@ -5038,20 +5263,26 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed gitblame report not working on Windows - 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 +- Fixed bug [#19691][pear-19691] : SubversionPropertiesSniff fails to find missing properties - 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 +- Fixed bug [#19692][pear-19692] : DisallowMultipleAssignments is triggered by a closure +- Fixed bug [#19693][pear-19693] : exclude-patterns no longer work on specific messages +- Fixed bug [#19694][pear-19694] : Squiz.PHP.LowercasePHPFunctions incorrectly matches return by ref functions + +[pear-19691]: https://pear.php.net/bugs/bug.php?id=19691 +[pear-19692]: https://pear.php.net/bugs/bug.php?id=19692 +[pear-19693]: https://pear.php.net/bugs/bug.php?id=19693 +[pear-19694]: https://pear.php.net/bugs/bug.php?id=19694 ## [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) + - e.g., `^tests/*` - 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 + - Fixes bug [#19666][pear-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 @@ -5082,23 +5313,33 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#19616][pear-19616] : Nested switches cause false error in PSR2 +- Fixed bug [#19629][pear-19629] : PSR2 error for inline comments on multi-line argument lists +- Fixed bug [#19644][pear-19644] : Alternative syntax, e.g. if/endif triggers Inline Control Structure error +- Fixed bug [#19655][pear-19655] : Closures reporting as multi-line when they are not +- Fixed bug [#19675][pear-19675] : Improper indent of nested anonymous function bodies in a call +- Fixed bug [#19685][pear-19685] : PSR2 catch-22 with empty third statement in for loop +- Fixed bug [#19687][pear-19687] : Anonymous functions inside arrays marked as indented incorrectly in PSR2 + +[pear-19616]: https://pear.php.net/bugs/bug.php?id=19616 +[pear-19629]: https://pear.php.net/bugs/bug.php?id=19629 +[pear-19644]: https://pear.php.net/bugs/bug.php?id=19644 +[pear-19655]: https://pear.php.net/bugs/bug.php?id=19655 +[pear-19666]: https://pear.php.net/bugs/bug.php?id=19666 +[pear-19675]: https://pear.php.net/bugs/bug.php?id=19675 +[pear-19685]: https://pear.php.net/bugs/bug.php?id=19685 +[pear-19687]: https://pear.php.net/bugs/bug.php?id=19687 ## [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 + - Explain a standard by using the `-e` and `--standard=[standard]` command line arguments + - E.g., `phpcs -e --standard=Squiz` - Thanks to [Ben Selby][@benmatselby] for the idea - Added report to show results using notify-send - Use --report=notifysend to generate the report @@ -5114,13 +5355,19 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#17908][pear-17908] : CodeSniffer does not recognise optional @params - 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 +- Fixed bug [#19538][pear-19538] : Function indentation code sniffer checks inside short arrays +- Fixed bug [#19565][pear-19565] : Non-Executable Code Sniff Broken for Case Statements with both return and break +- Fixed bug [#19612][pear-19612] : Invalid @package suggestion + +[pear-17908]: https://pear.php.net/bugs/bug.php?id=17908 +[pear-19538]: https://pear.php.net/bugs/bug.php?id=19538 +[pear-19565]: https://pear.php.net/bugs/bug.php?id=19565 +[pear-19612]: https://pear.php.net/bugs/bug.php?id=19612 ## [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 @@ -5146,12 +5393,18 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#19502][pear-19502] : Generic.Files.LineEndingsSniff fails if no new-lines in file +- Fixed bug [#19508][pear-19508] : switch+return: Closing brace indented incorrectly +- Fixed bug [#19532][pear-19532] : The PSR-2 standard don't recognize Null in class names +- Fixed bug [#19546][pear-19546] : Error thrown for __call() method in traits + +[pear-19502]: https://pear.php.net/bugs/bug.php?id=19502 +[pear-19508]: https://pear.php.net/bugs/bug.php?id=19508 +[pear-19532]: https://pear.php.net/bugs/bug.php?id=19532 +[pear-19546]: https://pear.php.net/bugs/bug.php?id=19546 ## [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 @@ -5171,21 +5424,33 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#18651][pear-18651] : PHPUnit Test cases for custom standards are not working on Windows +- Fixed bug [#19416][pear-19416] : Shorthand arrays cause bracket spacing errors +- Fixed bug [#19421][pear-19421] : phpcs doesn't recognize ${x} as equivalent to $x +- Fixed bug [#19428][pear-19428] : PHPCS Report "hgblame" doesn't support windows paths - 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 +- Fixed bug [#19448][pear-19448] : Problem with detecting remote standards +- Fixed bug [#19463][pear-19463] : Anonymous functions incorrectly being flagged by NonExecutableCodeSniff +- Fixed bug [#19469][pear-19469] : PHP_CodeSniffer_File::getMemberProperties() sets wrong scope +- Fixed bug [#19471][pear-19471] : phpcs on Windows, when using Zend standard, doesn't catch problems - Thanks to [Ivan Habunek][@ihabunek] for the patch -- Fixed bug #19478 : Incorrect indent detection in PEAR standard +- Fixed bug [#19478][pear-19478] : Incorrect indent detection in PEAR standard - Thanks to [Shane Auckland][@shanethehat] for the patch -- Fixed bug #19483 : Blame Reports fail with space in directory name +- Fixed bug [#19483][pear-19483] : Blame Reports fail with space in directory name + +[pear-18651]: https://pear.php.net/bugs/bug.php?id=18651 +[pear-19416]: https://pear.php.net/bugs/bug.php?id=19416 +[pear-19421]: https://pear.php.net/bugs/bug.php?id=19421 +[pear-19428]: https://pear.php.net/bugs/bug.php?id=19428 +[pear-19448]: https://pear.php.net/bugs/bug.php?id=19448 +[pear-19463]: https://pear.php.net/bugs/bug.php?id=19463 +[pear-19469]: https://pear.php.net/bugs/bug.php?id=19469 +[pear-19471]: https://pear.php.net/bugs/bug.php?id=19471 +[pear-19478]: https://pear.php.net/bugs/bug.php?id=19478 +[pear-19483]: https://pear.php.net/bugs/bug.php?id=19483 ## [1.3.4] - 2012-05-17 + ### Changed - Added missing package.xml entries for new Generic FixmeSniff - Thanks to [Jaroslav Hanslík][@kukulich] for the patch @@ -5196,8 +5461,8 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - In particular, allows the Drupal CS to work without needing to symlink it into the PHPCS install - 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) + - For example: `ref="../MyStandard/Sniffs/Commenting/DisallowHashCommentsSniff.php"` +- Symlinked standards now work correctly, allowing aliasing of installed standards (request [#19417][pear-19417]) - 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 @@ -5214,26 +5479,41 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed an issue in Generic UpperCaseConstantNameSniff where errors were incorrectly reported on goto statements - 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 + - 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 +- Fixed bug [#19290][pear-19290] : Generic indent sniffer fails for anonymous functions +- Fixed bug [#19324][pear-19324] : Setting show_warnings configuration option does not work +- Fixed bug [#19354][pear-19354] : Not recognizing references passed to method +- Fixed bug [#19361][pear-19361] : CSS tokenizer generates errors when PHP embedded in CSS file +- Fixed bug [#19374][pear-19374] : HEREDOC/NOWDOC Indentation problems +- Fixed bug [#19381][pear-19381] : traits and indentations in traits are not handled properly +- Fixed bug [#19394][pear-19394] : Notice in NonExecutableCodeSniff +- Fixed bug [#19402][pear-19402] : Syntax error when executing phpcs on Windows with parens in PHP path - Thanks to [Tom Klingenberg][@ktomk] for the patch -- Fixed bug #19411 : magic method error on __construct() +- Fixed bug [#19411][pear-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 +- Fixed bug [#19412][pear-19412] : Incorrect error about assigning objects to variables when inside inline IF +- Fixed bug [#19413][pear-19413] : PHP_CodeSniffer thinks I haven't used a parameter when I have +- Fixed bug [#19414][pear-19414] : PHP_CodeSniffer seems to not track variables correctly in heredocs + +[pear-19290]: https://pear.php.net/bugs/bug.php?id=19290 +[pear-19324]: https://pear.php.net/bugs/bug.php?id=19324 +[pear-19354]: https://pear.php.net/bugs/bug.php?id=19354 +[pear-19361]: https://pear.php.net/bugs/bug.php?id=19361 +[pear-19374]: https://pear.php.net/bugs/bug.php?id=19374 +[pear-19381]: https://pear.php.net/bugs/bug.php?id=19381 +[pear-19394]: https://pear.php.net/bugs/bug.php?id=19394 +[pear-19402]: https://pear.php.net/bugs/bug.php?id=19402 +[pear-19411]: https://pear.php.net/bugs/bug.php?id=19411 +[pear-19412]: https://pear.php.net/bugs/bug.php?id=19412 +[pear-19413]: https://pear.php.net/bugs/bug.php?id=19413 +[pear-19414]: https://pear.php.net/bugs/bug.php?id=19414 +[pear-19417]: https://pear.php.net/bugs/bug.php?id=19417 ## [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][@illusori] for the contribution @@ -5244,25 +5524,37 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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) +- PHP_CodeSniffer_File::getTokensAsString() now detects incorrect length value (request [#19313][pear-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 +- Fixed bug [#19114][pear-19114] : CodeSniffer checks extension even for single file +- Fixed bug [#19171][pear-19171] : Show sniff codes option is ignored by some report types - Thanks to [Dominic Scheirlinck][@dominics] for the patch -- Fixed bug #19188 : Lots of PHP Notices when analyzing the Symfony framework +- Fixed bug [#19188][pear-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 + - Second issue was notices caused by bug [#19137][pear-19137] +- Fixed bug [#19208][pear-19208] : UpperCaseConstantName reports class members - Was also a problem with LowerCaseConstantName as well -- Fixed bug #19256 : T_DOC_COMMENT in CSS files breaks ClassDefinitionNameSpacingSniff +- Fixed bug [#19256][pear-19256] : T_DOC_COMMENT in CSS files breaks ClassDefinitionNameSpacingSniff - 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 +- Fixed bug [#19264][pear-19264] : Squiz.PHP.NonExecutableCode does not handle RETURN in CASE without BREAK +- Fixed bug [#19270][pear-19270] : DuplicateClassName does not handle namespaces correctly +- Fixed bug [#19283][pear-19283] : CSS @media rules cause false positives - Thanks to [Klaus Purer][@klausi] for the patch +[pear-19114]: https://pear.php.net/bugs/bug.php?id=19114 +[pear-19137]: https://pear.php.net/bugs/bug.php?id=19137 +[pear-19171]: https://pear.php.net/bugs/bug.php?id=19171 +[pear-19188]: https://pear.php.net/bugs/bug.php?id=19188 +[pear-19208]: https://pear.php.net/bugs/bug.php?id=19208 +[pear-19256]: https://pear.php.net/bugs/bug.php?id=19256 +[pear-19264]: https://pear.php.net/bugs/bug.php?id=19264 +[pear-19270]: https://pear.php.net/bugs/bug.php?id=19270 +[pear-19283]: https://pear.php.net/bugs/bug.php?id=19283 +[pear-19313]: https://pear.php.net/bugs/bug.php?id=19313 + ## [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 @@ -5281,36 +5573,42 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed unit tests not running under Windows - 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" +- Fixed bug [#18964][pear-18964] : "$stackPtr must be of type T_VARIABLE" on heredocs and nowdocs +- Fixed bug [#18973][pear-18973] : phpcs is looking for variables in a nowdoc +- Fixed bug [#18974][pear-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 +- Fixed bug [#18975][pear-18975] : "Closing parenthesis must be on a line by itself" also causes indentation error + +[pear-18964]: https://pear.php.net/bugs/bug.php?id=18964 +[pear-18973]: https://pear.php.net/bugs/bug.php?id=18973 +[pear-18974]: https://pear.php.net/bugs/bug.php?id=18974 +[pear-18975]: https://pear.php.net/bugs/bug.php?id=18975 ## 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) +- All report file command line arguments now work with relative paths (request [#17240][pear-17240]) +- The extensions command line argument now supports multi-part file extensions (request [#17227][pear-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][@benmatselby] for the patch -- Added T_BACKTICK token type to make detection of backticks easier (request #18799) +- Added T_BACKTICK token type to make detection of backticks easier (request [#18799][pear-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) +- Namespaces are now recognised as scope openers, although they do not require braces (request [#18043][pear-18043]) +- Added new ByteOrderMarkSniff to Generic standard (request [#18194][pear-18194]) - Throws an error if a byte order mark is found in any PHP file - 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) +- PHP_Timer output is no longer included in reports when being written to a file (request [#18252][pear-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 +- Generic DeprecatedFunctionSniff now reports functions as deprecated and not simply forbidden (request [#18288][pear-18288]) +- PHPCS now accepts file contents from STDIN (request [#18447][pear-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) +- PHP_CodeSniffer_Exception no longer extends PEAR_Exception (request [#18483][pear-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) +- PEAR FileCommentSniff now allows GIT IDs in the version tag (request [#14874][pear-14874]) - AbstractVariableSniff now supports heredocs - Also includes some variable detection fixes - Thanks to [Sam Graham][@illusori] for the patch @@ -5319,42 +5617,73 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 + - Fixes bug [#18933][pear-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 + - Should fix bug [#18949][pear-18949] : Call to private method from static +- Fixed bug [#18465][pear-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 +- Fixed bug [#18543][pear-18543] : CSS Tokenizer deletes too many # +- Fixed bug [#18624][pear-18624] : @throws namespace problem - 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 +- Fixed bug [#18628][pear-18628] : Generic.Files.LineLength gives incorrect results with Windows line-endings +- Fixed bug [#18633][pear-18633] : CSS Tokenizer doesn't replace T_LIST tokens inside some styles +- Fixed bug [#18657][pear-18657] : anonymous functions wrongly indented +- Fixed bug [#18670][pear-18670] : UpperCaseConstantNameSniff fails on dynamic retrieval of class constant +- Fixed bug [#18709][pear-18709] : Code sniffer sniffs file even if it's in --ignore - Thanks to [Artem Lopata][@biozshock] for the patch -- Fixed bug #18762 : Incorrect handling of define and constant in UpperCaseConstantNameSniff +- Fixed bug [#18762][pear-18762] : Incorrect handling of define and constant in UpperCaseConstantNameSniff - 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 +- Fixed bug [#18769][pear-18769] : CSS Tokenizer doesn't replace T_BREAK tokens inside some styles +- Fixed bug [#18835][pear-18835] : Unreachable errors of inline returns of closure functions - Thanks to [Patrick Schmidt][pear-woellchen] for the patch -- Fixed bug #18839 : Fix miscount of warnings in AbstractSniffUnitTest.php +- Fixed bug [#18839][pear-18839] : Fix miscount of warnings in `AbstractSniffUnitTest.php` - Thanks to [Sam Graham][@illusori] for the patch -- Fixed bug #18844 : Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff with empty body +- Fixed bug [#18844][pear-18844] : Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff with empty body - 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 +- Fixed bug [#18847][pear-18847] : Running Squiz_Sniffs_Classes_ClassDeclarationSniff results in PHP notice +- Fixed bug [#18868][pear-18868] : jslint+rhino: errors/warnings not detected - Thanks to [Christian Weiske][@cweiske] for the patch -- Fixed bug #18879 : phpcs-svn-pre-commit requires escapeshellarg +- Fixed bug [#18879][pear-18879] : phpcs-svn-pre-commit requires escapeshellarg - Thanks to [Bjorn Katuin][pear-bjorn] for the patch -- Fixed bug #18951 : weird behaviour with closures and multi-line use () params +- Fixed bug [#18951][pear-18951] : weird behaviour with closures and multi-line use () params + +[pear-14874]: https://pear.php.net/bugs/bug.php?id=14874 +[pear-17227]: https://pear.php.net/bugs/bug.php?id=17227 +[pear-17240]: https://pear.php.net/bugs/bug.php?id=17240 +[pear-18043]: https://pear.php.net/bugs/bug.php?id=18043 +[pear-18194]: https://pear.php.net/bugs/bug.php?id=18194 +[pear-18252]: https://pear.php.net/bugs/bug.php?id=18252 +[pear-18288]: https://pear.php.net/bugs/bug.php?id=18288 +[pear-18447]: https://pear.php.net/bugs/bug.php?id=18447 +[pear-18465]: https://pear.php.net/bugs/bug.php?id=18465 +[pear-18483]: https://pear.php.net/bugs/bug.php?id=18483 +[pear-18543]: https://pear.php.net/bugs/bug.php?id=18543 +[pear-18624]: https://pear.php.net/bugs/bug.php?id=18624 +[pear-18628]: https://pear.php.net/bugs/bug.php?id=18628 +[pear-18633]: https://pear.php.net/bugs/bug.php?id=18633 +[pear-18657]: https://pear.php.net/bugs/bug.php?id=18657 +[pear-18670]: https://pear.php.net/bugs/bug.php?id=18670 +[pear-18709]: https://pear.php.net/bugs/bug.php?id=18709 +[pear-18762]: https://pear.php.net/bugs/bug.php?id=18762 +[pear-18769]: https://pear.php.net/bugs/bug.php?id=18769 +[pear-18799]: https://pear.php.net/bugs/bug.php?id=18799 +[pear-18835]: https://pear.php.net/bugs/bug.php?id=18835 +[pear-18839]: https://pear.php.net/bugs/bug.php?id=18839 +[pear-18844]: https://pear.php.net/bugs/bug.php?id=18844 +[pear-18847]: https://pear.php.net/bugs/bug.php?id=18847 +[pear-18868]: https://pear.php.net/bugs/bug.php?id=18868 +[pear-18879]: https://pear.php.net/bugs/bug.php?id=18879 +[pear-18933]: https://pear.php.net/bugs/bug.php?id=18933 +[pear-18949]: https://pear.php.net/bugs/bug.php?id=18949 +[pear-18951]: https://pear.php.net/bugs/bug.php?id=18951 ## 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 @@ -5363,26 +5692,37 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#18200][pear-18200] : Using custom named ruleset file as standard no longer works +- Fixed bug [#18196][pear-18196] : PEAR MultiLineCondition.SpaceBeforeOpenBrace not consistent with newline chars +- Fixed bug [#18204][pear-18204] : FunctionCommentThrowTag picks wrong exception type when throwing function call +- Fixed bug [#18222][pear-18222] : Add __invoke method to PEAR standard +- Fixed bug [#18235][pear-18235] : Invalid error generation in Squiz.Commenting.FunctionCommentThrowTag +- Fixed bug [#18250][pear-18250] : --standard with relative path skips Standards' "implicit" sniffs +- Fixed bug [#18274][pear-18274] : Multi-line IF and function call indent rules conflict +- Fixed bug [#18282][pear-18282] : Squiz doesn't handle final keyword before function comments - Thanks to [Dave Perrett][pear-recurser] for the patch -- Fixed bug #18336 : Function isUnderscoreName gives php notices +- Fixed bug [#18336][pear-18336] : Function isUnderscoreName gives PHP notices + +[pear-18196]: https://pear.php.net/bugs/bug.php?id=18196 +[pear-18200]: https://pear.php.net/bugs/bug.php?id=18200 +[pear-18204]: https://pear.php.net/bugs/bug.php?id=18204 +[pear-18222]: https://pear.php.net/bugs/bug.php?id=18222 +[pear-18235]: https://pear.php.net/bugs/bug.php?id=18235 +[pear-18250]: https://pear.php.net/bugs/bug.php?id=18250 +[pear-18274]: https://pear.php.net/bugs/bug.php?id=18274 +[pear-18282]: https://pear.php.net/bugs/bug.php?id=18282 +[pear-18336]: https://pear.php.net/bugs/bug.php?id=18336 ## 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 ... +- You can now print multiple reports for each run and print each to the screen or a file (request [#12434][pear-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][pear-17244]) + - Usage is: `phpcs -d memory_limit=32M -d ...` - 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 @@ -5390,22 +5730,22 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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) +- You can now add exclude rules for individual sniffs or error messages (request [#17903][pear-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 XML and CSV reports now include the severity of the error (request [#18165][pear-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 FileLengthSniff now uses iconv_strlen to check line length if an encoding is specified (request [#14237][pear-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 + - Fixes bug [#17611][pear-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 @@ -5421,74 +5761,111 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#17693][pear-17693] : issue with pre-commit hook script with filenames that start with v +- Fixed bug [#17860][pear-17860] : isReference function fails with references in array - Thanks to [Lincoln Maskey][pear-ljmaskey] for the patch -- Fixed bug #17902 : Cannot run tests when tests are symlinked into tests dir +- Fixed bug [#17902][pear-17902] : Cannot run tests when tests are symlinked into tests dir - Thanks to [Matt Button][@BRMatt] for the patch -- Fixed bug #17928 : Improve error message for Generic_Sniffs_PHP_UpperCaseConstantSniff +- Fixed bug [#17928][pear-17928] : Improve error message for Generic_Sniffs_PHP_UpperCaseConstantSniff - 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 +- Fixed bug [#18039][pear-18039] : JS Tokenizer crash when ] is last character in file +- Fixed bug [#18047][pear-18047] : Incorrect handling of namespace aliases as constants - 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 +- Fixed bug [#18072][pear-18072] : Impossible to exclude path from processing when symlinked +- Fixed bug [#18073][pear-18073] : Squiz.PHP.NonExecutableCode fault +- Fixed bug [#18117][pear-18117] : PEAR coding standard: Method constructor not sniffed as a function +- Fixed bug [#18135][pear-18135] : Generic FunctionCallArgumentSpacingSniff reports function declaration errors +- Fixed bug [#18140][pear-18140] : Generic scope indent in exact mode: strange expected/found values for switch +- Fixed bug [#18145][pear-18145] : Sniffs are not loaded for custom ruleset file - 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 +- Fixed bug [#18152][pear-18152] : While and do-while with AbstractPatternSniff +- Fixed bug [#18191][pear-18191] : Squiz.PHP.LowercasePHPFunctions does not work with new Date() +- Fixed bug [#18193][pear-18193] : CodeSniffer doesn't reconize CR (\r) line endings + +[pear-12434]: https://pear.php.net/bugs/bug.php?id=12434 +[pear-14237]: https://pear.php.net/bugs/bug.php?id=14237 +[pear-17244]: https://pear.php.net/bugs/bug.php?id=17244 +[pear-17611]: https://pear.php.net/bugs/bug.php?id=17611 +[pear-17693]: https://pear.php.net/bugs/bug.php?id=17693 +[pear-17860]: https://pear.php.net/bugs/bug.php?id=17860 +[pear-17902]: https://pear.php.net/bugs/bug.php?id=17902 +[pear-17903]: https://pear.php.net/bugs/bug.php?id=17903 +[pear-17928]: https://pear.php.net/bugs/bug.php?id=17928 +[pear-18039]: https://pear.php.net/bugs/bug.php?id=18039 +[pear-18047]: https://pear.php.net/bugs/bug.php?id=18047 +[pear-18072]: https://pear.php.net/bugs/bug.php?id=18072 +[pear-18073]: https://pear.php.net/bugs/bug.php?id=18073 +[pear-18117]: https://pear.php.net/bugs/bug.php?id=18117 +[pear-18135]: https://pear.php.net/bugs/bug.php?id=18135 +[pear-18140]: https://pear.php.net/bugs/bug.php?id=18140 +[pear-18145]: https://pear.php.net/bugs/bug.php?id=18145 +[pear-18152]: https://pear.php.net/bugs/bug.php?id=18152 +[pear-18165]: https://pear.php.net/bugs/bug.php?id=18165 +[pear-18191]: https://pear.php.net/bugs/bug.php?id=18191 +[pear-18193]: https://pear.php.net/bugs/bug.php?id=18193 ## 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) +- Added exclude pattern support to ruleset.xml file so you can specify ignore patterns in a standard (request [#17683][pear-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) + - 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][pear-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) +- The SVN and GIT blame reports now also show percentage of reported errors per author (request [#17606][pear-17606]) - 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) +- Generic SubversionPropertiesSniff now allows properties to have NULL values (request [#17682][pear-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) +- Generic UpperCaseConstantName Sniff now longer complains about the PHPUnit_MAIN_METHOD constant (request [#17798][pear-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 +- Fixed bug [#17092][pear-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 +- Fixed bug [#17629][pear-17629] : PHP_CodeSniffer_Tokens::$booleanOperators missing T_LOGICAL_XOR - 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 -- Fixed bug #17742 : EmbeddedPhpSniff reacts negatively to file without closing php tag -- Fixed bug #17823 : Notice: Please no longer include PHPUnit/Framework.php +- Fixed bug [#17699][pear-17699] : Fatal error generating code coverage with PHPUnit 5.3.0RC1 +- Fixed bug [#17718][pear-17718] : Namespace 'use' statement: used global class name is recognized as constant +- Fixed bug [#17734][pear-17734] : Generic SubversionPropertiesSniff complains on non SVN files +- Fixed bug [#17742][pear-17742] : EmbeddedPhpSniff reacts negatively to file without closing PHP tag +- Fixed bug [#17823][pear-17823] : Notice: Please no longer include `PHPUnit/Framework.php` + +[pear-17092]: https://pear.php.net/bugs/bug.php?id=17092 +[pear-17467]: https://pear.php.net/bugs/bug.php?id=17467 +[pear-17606]: https://pear.php.net/bugs/bug.php?id=17606 +[pear-17629]: https://pear.php.net/bugs/bug.php?id=17629 +[pear-17682]: https://pear.php.net/bugs/bug.php?id=17682 +[pear-17683]: https://pear.php.net/bugs/bug.php?id=17683 +[pear-17699]: https://pear.php.net/bugs/bug.php?id=17699 +[pear-17718]: https://pear.php.net/bugs/bug.php?id=17718 +[pear-17734]: https://pear.php.net/bugs/bug.php?id=17734 +[pear-17742]: https://pear.php.net/bugs/bug.php?id=17742 +[pear-17798]: https://pear.php.net/bugs/bug.php?id=17798 +[pear-17823]: https://pear.php.net/bugs/bug.php?id=17823 ## 1.3.0a1 - 2010-07-15 + ### Changed -- All CodingStandard.php files have been replaced by ruleset.xml files +- 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][@benmatselby] for the patch -- A new token type T_DOLLAR has been added to allow you to sniff for variable variables (feature request #17095) +- A new token type T_DOLLAR has been added to allow you to sniff for variable variables (feature request [#17095][pear-17095]) - Thanks to [Ian Young][pear-youngian] for the patch -- JS tokenizer now supports T_POWER (^) and T_MOD_EQUAL (%=) tokens (feature request #17441) +- JS tokenizer now supports T_POWER (^) and T_MOD_EQUAL (%=) tokens (feature request [#17441][pear-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) +- Added Generic DeprecatedFunctionsSniff to warn about the use of deprecated functions (feature request [#16694][pear-16694]) - 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 @@ -5506,22 +5883,38 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#17048][pear-17048] : False positive in Squiz_WhiteSpace_ScopeKeywordSpacingSniff +- Fixed bug [#17054][pear-17054] : phpcs more strict than PEAR CS regarding function parameter spacing +- Fixed bug [#17096][pear-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 +- Fixed bug [#17144][pear-17144] : Deprecated: Function eregi() is deprecated +- Fixed bug [#17236][pear-17236] : PHP Warning due to token_get_all() in DoubleQuoteUsageSniff +- Fixed bug [#17243][pear-17243] : Alternate Switch Syntax causes endless loop of Notices in SwitchDeclaration +- Fixed bug [#17313][pear-17313] : Bug with switch case structure +- Fixed bug [#17331][pear-17331] : Possible parse error: interfaces may not include member vars +- Fixed bug [#17337][pear-17337] : CSS tokenizer fails on quotes urls +- Fixed bug [#17420][pear-17420] : Uncaught exception when comment before function brace +- Fixed bug [#17503][pear-17503] : closures formatting is not supported + +[pear-16694]: https://pear.php.net/bugs/bug.php?id=16694 +[pear-17048]: https://pear.php.net/bugs/bug.php?id=17048 +[pear-17054]: https://pear.php.net/bugs/bug.php?id=17054 +[pear-17095]: https://pear.php.net/bugs/bug.php?id=17095 +[pear-17096]: https://pear.php.net/bugs/bug.php?id=17096 +[pear-17144]: https://pear.php.net/bugs/bug.php?id=17144 +[pear-17236]: https://pear.php.net/bugs/bug.php?id=17236 +[pear-17243]: https://pear.php.net/bugs/bug.php?id=17243 +[pear-17313]: https://pear.php.net/bugs/bug.php?id=17313 +[pear-17331]: https://pear.php.net/bugs/bug.php?id=17331 +[pear-17337]: https://pear.php.net/bugs/bug.php?id=17337 +[pear-17420]: https://pear.php.net/bugs/bug.php?id=17420 +[pear-17441]: https://pear.php.net/bugs/bug.php?id=17441 +[pear-17503]: https://pear.php.net/bugs/bug.php?id=17503 ## 1.2.2 - 2010-01-27 + ### Changed -- The core PHP_CodeSniffer_File methods now understand the concept of closures (feature request #16866) +- The core PHP_CodeSniffer_File methods now understand the concept of closures (feature request [#16866][pear-16866]) - 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 @@ -5560,7 +5953,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 + - It is now 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 @@ -5572,22 +5965,36 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#16740][pear-16740] : False positives for heredoc strings and unused parameter sniff +- Fixed bug [#16794][pear-16794] : ValidLogicalOperatorsSniff doesn't report operators not in lowercase +- Fixed bug [#16804][pear-16804] : Report filename is shortened too much +- Fixed bug [#16821][pear-16821] : Bug in Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff - 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 +- Fixed bug [#16836][pear-16836] : Notice raised when using semicolon to open case +- Fixed bug [#16855][pear-16855] : Generic standard sniffs incorrectly for define() method +- Fixed bug [#16865][pear-16865] : Two bugs in Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff - 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 +- Fixed bug [#16902][pear-16902] : Inline If Declaration bug +- Fixed bug [#16960][pear-16960] : False positive for late static binding in Squiz/ScopeKeywordSpacingSniff - 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 +- Fixed bug [#16976][pear-16976] : The phpcs attempts to process symbolic links that don't resolve to files +- Fixed bug [#17017][pear-17017] : Including one file in the files sniffed alters errors reported for another file + +[pear-16740]: https://pear.php.net/bugs/bug.php?id=16740 +[pear-16794]: https://pear.php.net/bugs/bug.php?id=16794 +[pear-16804]: https://pear.php.net/bugs/bug.php?id=16804 +[pear-16821]: https://pear.php.net/bugs/bug.php?id=16821 +[pear-16836]: https://pear.php.net/bugs/bug.php?id=16836 +[pear-16855]: https://pear.php.net/bugs/bug.php?id=16855 +[pear-16865]: https://pear.php.net/bugs/bug.php?id=16865 +[pear-16866]: https://pear.php.net/bugs/bug.php?id=16866 +[pear-16902]: https://pear.php.net/bugs/bug.php?id=16902 +[pear-16960]: https://pear.php.net/bugs/bug.php?id=16960 +[pear-16976]: https://pear.php.net/bugs/bug.php?id=16976 +[pear-17017]: https://pear.php.net/bugs/bug.php?id=17017 ## 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 @@ -5596,10 +6003,10 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 + - Reports won't 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 + - If you put it in the first two lines the file won't 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 @@ -5624,25 +6031,41 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#16530][pear-16530] : ScopeIndentSniff reports false positive +- Fixed bug [#16533][pear-16533] : Duplicate errors and warnings +- Fixed bug [#16563][pear-16563] : Check file extensions problem in phpcs-svn-pre-commit - 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 +- Fixed bug [#16592][pear-16592] : Object operator indentation incorrect when first operator is on a new line +- Fixed bug [#16641][pear-16641] : Notice output +- Fixed bug [#16682][pear-16682] : Squiz_Sniffs_Strings_DoubleQuoteUsageSniff reports string "\0" as invalid +- Fixed bug [#16683][pear-16683] : Typing error in PHP_CodeSniffer_CommentParser_AbstractParser +- Fixed bug [#16684][pear-16684] : Bug in Squiz_Sniffs_PHP_NonExecutableCodeSniff +- Fixed bug [#16692][pear-16692] : Spaces in paths in Squiz_Sniffs_Debug_JavaScriptLintSniff - 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 +- Fixed bug [#16696][pear-16696] : Spelling error in MultiLineConditionSniff +- Fixed bug [#16697][pear-16697] : MultiLineConditionSniff incorrect result with inline IF +- Fixed bug [#16698][pear-16698] : Notice in JavaScript Tokenizer +- Fixed bug [#16736][pear-16736] : Multi-files sniffs aren't processed when FILE is a single directory - Thanks to [Alexey Shein][pear-conf] for the patch -- Fixed bug #16792 : Bug in Generic_Sniffs_PHP_ForbiddenFunctionsSniff +- Fixed bug [#16792][pear-16792] : Bug in Generic_Sniffs_PHP_ForbiddenFunctionsSniff + +[pear-16530]: https://pear.php.net/bugs/bug.php?id=16530 +[pear-16533]: https://pear.php.net/bugs/bug.php?id=16533 +[pear-16563]: https://pear.php.net/bugs/bug.php?id=16563 +[pear-16592]: https://pear.php.net/bugs/bug.php?id=16592 +[pear-16641]: https://pear.php.net/bugs/bug.php?id=16641 +[pear-16682]: https://pear.php.net/bugs/bug.php?id=16682 +[pear-16683]: https://pear.php.net/bugs/bug.php?id=16683 +[pear-16684]: https://pear.php.net/bugs/bug.php?id=16684 +[pear-16692]: https://pear.php.net/bugs/bug.php?id=16692 +[pear-16696]: https://pear.php.net/bugs/bug.php?id=16696 +[pear-16697]: https://pear.php.net/bugs/bug.php?id=16697 +[pear-16698]: https://pear.php.net/bugs/bug.php?id=16698 +[pear-16736]: https://pear.php.net/bugs/bug.php?id=16736 +[pear-16792]: https://pear.php.net/bugs/bug.php?id=16792 ## 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 @@ -5651,34 +6074,55 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#16424][pear-16424] : SubversionPropertiesSniff print PHP Warning +- Fixed bug [#16450][pear-16450] : Constant `PHP_CODESNIFFER_VERBOSITY` already defined (unit tests) +- Fixed bug [#16453][pear-16453] : function declaration long line splitted error +- Fixed bug [#16482][pear-16482] : phpcs-svn-pre-commit ignores extensions parameter + +[pear-16424]: https://pear.php.net/bugs/bug.php?id=16424 +[pear-16450]: https://pear.php.net/bugs/bug.php?id=16450 +[pear-16453]: https://pear.php.net/bugs/bug.php?id=16453 +[pear-16482]: https://pear.php.net/bugs/bug.php?id=16482 ## 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) +- You can now use @codingStandardsIgnoreStart and @...End comments to suppress messages (feature request [#14002][pear-14002]) +- A warning is now included for files without any code when short_open_tag is set to Off (feature request [#12952][pear-12952]) +- You can now use relative paths to your custom standards with the --standard cmd line arg (feature request [#14967][pear-14967]) +- You can now override magic methods and functions in PEAR ValidFunctionNameSniff (feature request [#15830][pear-15830]) - MySource IncludeSystemSniff now recognises widget action classes - MySource IncludeSystemSniff now knows about unit test classes and changes rules accordingly +[pear-12952]: https://pear.php.net/bugs/bug.php?id=12952 +[pear-14002]: https://pear.php.net/bugs/bug.php?id=14002 +[pear-14967]: https://pear.php.net/bugs/bug.php?id=14967 +[pear-15830]: https://pear.php.net/bugs/bug.php?id=15830 + ## 1.2.0RC2 - 2009-05-25 + ### Changed -- Test suite can now be run using the full path to AllTests.php (feature request #16179) +- Test suite can now be run using the full path to `AllTests.php` (feature request [#16179][pear-16179]) ### Fixed -- Fixed bug #15980 : PHP_CodeSniffer change php current directory +- Fixed bug [#15980][pear-15980] : PHP_CodeSniffer change PHP current directory - 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 -- Fixed bug #16170 : Undefined Offset -1 in MultiLineConditionSniff.php on line 68 -- Fixed bug #16175 : Bug in Squiz-IncrementDecrementUsageSniff +- Fixed bug [#16001][pear-16001] : Notice triggered +- Fixed bug [#16054][pear-16054] : phpcs-svn-pre-commit not showing any errors +- Fixed bug [#16071][pear-16071] : Fatal error: Uncaught PHP_CodeSniffer_Exception +- Fixed bug [#16170][pear-16170] : Undefined Offset -1 in `MultiLineConditionSniff.php` on line 68 +- Fixed bug [#16175][pear-16175] : Bug in Squiz-IncrementDecrementUsageSniff + +[pear-15980]: https://pear.php.net/bugs/bug.php?id=15980 +[pear-16001]: https://pear.php.net/bugs/bug.php?id=16001 +[pear-16054]: https://pear.php.net/bugs/bug.php?id=16054 +[pear-16071]: https://pear.php.net/bugs/bug.php?id=16071 +[pear-16170]: https://pear.php.net/bugs/bug.php?id=16170 +[pear-16175]: https://pear.php.net/bugs/bug.php?id=16175 +[pear-16179]: https://pear.php.net/bugs/bug.php?id=16179 ## 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 @@ -5695,23 +6139,32 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#15383][pear-15383] : Uncaught PHP_CodeSniffer_Exception +- Fixed bug [#15408][pear-15408] : An unexpected exception has been caught: Undefined offset: 2 +- Fixed bug [#15519][pear-15519] : Uncaught PHP_CodeSniffer_Exception +- Fixed bug [#15624][pear-15624] : Pre-commit hook fails with PHP errors +- Fixed bug [#15661][pear-15661] : Uncaught PHP_CodeSniffer_Exception +- Fixed bug [#15722][pear-15722] : "declare(encoding = 'utf-8');" leads to "Missing file doc comment" +- Fixed bug [#15910][pear-15910] : Object operator indention not calculated correctly + +[pear-15383]: https://pear.php.net/bugs/bug.php?id=15383 +[pear-15408]: https://pear.php.net/bugs/bug.php?id=15408 +[pear-15519]: https://pear.php.net/bugs/bug.php?id=15519 +[pear-15624]: https://pear.php.net/bugs/bug.php?id=15624 +[pear-15661]: https://pear.php.net/bugs/bug.php?id=15661 +[pear-15722]: https://pear.php.net/bugs/bug.php?id=15722 +[pear-15910]: https://pear.php.net/bugs/bug.php?id=15910 ## 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) +- Reports can now be written to a file using the --report-file command line argument (feature request [#14953][pear-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) +- The CheckStyle, CSV and XML reports now include a source for each error and warning (feature request [#13242][pear-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 @@ -5786,7 +6239,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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) +- Zend standard now uses OpeningFunctionBraceBsdAllmanSniff (feature request [#14647][pear-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 @@ -5799,21 +6252,36 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#14409][pear-14409] : Output of warnings to log file +- Fixed bug [#14520][pear-14520] : Notice: Undefined offset: 1 in `CodeSniffer/File.php` on line +- Fixed bug [#14637][pear-14637] : Call to processUnknownArguments() misses second parameter $pos - 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 +- Fixed bug [#14889][pear-14889] : Lack of clarity: licence or license +- Fixed bug [#15008][pear-15008] : Nested Parentheses in Control Structure Sniffs +- Fixed bug [#15091][pear-15091] : pre-commit hook attempts to sniff folders - Thanks to [Bruce Weirdan][pear-weirdan] for the patch -- Fixed bug #15124 : AbstractParser.php uses deprecated split() function +- Fixed bug [#15124][pear-15124] : `AbstractParser.php` uses deprecated `split()` function - 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 +- Fixed bug [#15188][pear-15188] : PHPCS vs HEREDOC strings +- Fixed bug [#15231][pear-15231] : Notice: Uninitialized string offset: 0 in `FileCommentSniff.php` on line 555 +- Fixed bug [#15336][pear-15336] : Notice: Undefined offset: 2 in `CodeSniffer/File.php` on line + +[pear-13242]: https://pear.php.net/bugs/bug.php?id=13242 +[pear-14409]: https://pear.php.net/bugs/bug.php?id=14409 +[pear-14520]: https://pear.php.net/bugs/bug.php?id=14520 +[pear-14637]: https://pear.php.net/bugs/bug.php?id=14637 +[pear-14647]: https://pear.php.net/bugs/bug.php?id=14647 +[pear-14889]: https://pear.php.net/bugs/bug.php?id=14889 +[pear-14953]: https://pear.php.net/bugs/bug.php?id=14953 +[pear-15008]: https://pear.php.net/bugs/bug.php?id=15008 +[pear-15091]: https://pear.php.net/bugs/bug.php?id=15091 +[pear-15124]: https://pear.php.net/bugs/bug.php?id=15124 +[pear-15188]: https://pear.php.net/bugs/bug.php?id=15188 +[pear-15231]: https://pear.php.net/bugs/bug.php?id=15231 +[pear-15336]: https://pear.php.net/bugs/bug.php?id=15336 ## 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 @@ -5822,14 +6290,15 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#14077][pear-14077] : Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a class member +- Fixed bug [#14168][pear-14168] : Global Function -> Static Method and __autoload() +- Fixed bug [#14238][pear-14238] : Line length not checked at last line of a file +- Fixed bug [#14249][pear-14249] : wrong detection of scope_opener +- Fixed bug [#14250][pear-14250] : ArrayDeclarationSniff emit warnings at malformed array +- Fixed bug [#14251][pear-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 @@ -5838,33 +6307,46 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#14077][pear-14077] : Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a class member +- Fixed bug [#14168][pear-14168] : Global Function -> Static Method and __autoload() +- Fixed bug [#14238][pear-14238] : Line length not checked at last line of a file +- Fixed bug [#14249][pear-14249] : wrong detection of scope_opener +- Fixed bug [#14250][pear-14250] : ArrayDeclarationSniff emit warnings at malformed array +- Fixed bug [#14251][pear-14251] : --extensions option doesn't work + +[pear-14077]: https://pear.php.net/bugs/bug.php?id=14077 +[pear-14168]: https://pear.php.net/bugs/bug.php?id=14168 +[pear-14238]: https://pear.php.net/bugs/bug.php?id=14238 +[pear-14249]: https://pear.php.net/bugs/bug.php?id=14249 +[pear-14250]: https://pear.php.net/bugs/bug.php?id=14250 +[pear-14251]: https://pear.php.net/bugs/bug.php?id=14251 ## 1.1.0RC2 - 2008-06-13 + ### Changed -- Permission denied errors now stop script execution but still display current errors (feature request #14076) +- Permission denied errors now stop script execution but still display current errors (feature request [#14076][pear-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 +- Fixed bug [#13921][pear-13921] : js parsing fails for comments on last line of file +- Fixed bug [#13922][pear-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 +[pear-13921]: https://pear.php.net/bugs/bug.php?id=13921 +[pear-13922]: https://pear.php.net/bugs/bug.php?id=13922 +[pear-14076]: https://pear.php.net/bugs/bug.php?id=14076 + ## 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) +- phpcs now exits with status 2 if the tokenizer extension has been disabled (feature request [#13269][pear-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 @@ -5886,7 +6368,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 DoubleQuoteUsageSniff now supports \x \f and \v (feature request [#13365][pear-13365]) - Squiz ComparisonOperatorUsageSniff now supports JS files - Squiz ControlSignatureSniff now supports JS files - Squiz ForLoopDeclarationSniff now supports JS files @@ -5912,35 +6394,53 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#13062][pear-13062] : Interface comments aren't handled in PEAR standard - 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 -- 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 +- Fixed bug [#13119][pear-13119] : PHP minimum requirement need to be fix +- Fixed bug [#13156][pear-13156] : Bug in Squiz_Sniffs_PHP_NonExecutableCodeSniff +- Fixed bug [#13158][pear-13158] : Strange behaviour in AbstractPatternSniff +- Fixed bug [#13169][pear-13169] : Undefined variables +- Fixed bug [#13178][pear-13178] : Catch exception in `File.php` +- Fixed bug [#13254][pear-13254] : Notices output in checkstyle report causes XML issues +- Fixed bug [#13446][pear-13446] : crash with src of phpMyAdmin - Thanks to [Manuel Pichler][@manuelpichler] for the path +[pear-13062]: https://pear.php.net/bugs/bug.php?id=13062 +[pear-13119]: https://pear.php.net/bugs/bug.php?id=13119 +[pear-13156]: https://pear.php.net/bugs/bug.php?id=13156 +[pear-13158]: https://pear.php.net/bugs/bug.php?id=13158 +[pear-13169]: https://pear.php.net/bugs/bug.php?id=13169 +[pear-13178]: https://pear.php.net/bugs/bug.php?id=13178 +[pear-13254]: https://pear.php.net/bugs/bug.php?id=13254 +[pear-13269]: https://pear.php.net/bugs/bug.php?id=13269 +[pear-13365]: https://pear.php.net/bugs/bug.php?id=13365 +[pear-13446]: https://pear.php.net/bugs/bug.php?id=13446 + ## 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) +- Removed "function" from error messages for Generic function brace sniffs (feature request [#13820][pear-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() +- Fixed bug [#13827][pear-13827] : AbstractVariableSniff throws "undefined index" +- Fixed bug [#13846][pear-13846] : Bug in Squiz.NonExecutableCodeSniff +- Fixed bug [#13849][pear-13849] : infinite loop in PHP_CodeSniffer_File::findNext() + +[pear-13820]: https://pear.php.net/bugs/bug.php?id=13820 +[pear-13827]: https://pear.php.net/bugs/bug.php?id=13827 +[pear-13846]: https://pear.php.net/bugs/bug.php?id=13846 +[pear-13849]: https://pear.php.net/bugs/bug.php?id=13849 ## 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 @@ -5959,24 +6459,32 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#12767][pear-12767] : Cant run phpcs from dir with PEAR subdir +- Fixed bug [#12773][pear-12773] : Reserved variables are not detected in strings - 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 +- Fixed bug [#12832][pear-12832] : Tab to space conversion does not work +- Fixed bug [#12888][pear-12888] : extra space indentation = Notice: Uninitialized string offset... +- Fixed bug [#12909][pear-12909] : Default generateDocs function does not work under linux - Thanks to [Paul Smith][pear-thing2b] for the patch -- Fixed bug #12957 : PHP 5.3 magic method __callStatic +- Fixed bug [#12957][pear-12957] : PHP 5.3 magic method __callStatic - Thanks to [Manuel Pichler][@manuelpichler] for the patch +[pear-12767]: https://pear.php.net/bugs/bug.php?id=12767 +[pear-12773]: https://pear.php.net/bugs/bug.php?id=12773 +[pear-12832]: https://pear.php.net/bugs/bug.php?id=12832 +[pear-12888]: https://pear.php.net/bugs/bug.php?id=12888 +[pear-12909]: https://pear.php.net/bugs/bug.php?id=12909 +[pear-12957]: https://pear.php.net/bugs/bug.php?id=12957 + ## 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) +- You can now specify the full path to a coding standard on the command line (feature request [#11886][pear-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 + - 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) +- Modified the scope map to keep checking after 3 lines for some tokens (feature request [#12561][pear-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 @@ -5993,21 +6501,28 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - MySource IncludeSystemSniff no longer throws errors for the Util package ### Fixed -- Fixed bug #12621 : "space after AS" check is wrong +- Fixed bug [#12621][pear-12621] : "space after AS" check is wrong - Thanks to [Satoshi Oikawa][pear-renoiv] for the patch -- Fixed bug #12645 : error message is wrong +- Fixed bug [#12645][pear-12645] : error message is wrong - Thanks to [Satoshi Oikawa][pear-renoiv] for the patch -- Fixed bug #12651 : Increment/Decrement Operators Usage at -1 +- Fixed bug [#12651][pear-12651] : Increment/Decrement Operators Usage at -1 + +[pear-11886]: https://pear.php.net/bugs/bug.php?id=11886 +[pear-12561]: https://pear.php.net/bugs/bug.php?id=12561 +[pear-12621]: https://pear.php.net/bugs/bug.php?id=12621 +[pear-12645]: https://pear.php.net/bugs/bug.php?id=12645 +[pear-12651]: https://pear.php.net/bugs/bug.php?id=12651 ## 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 + - Run: phpcs `--config-set report_format [format]` +- Improved performance by optimising the way the scope map is created during tokenizing - 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 @@ -6020,14 +6535,21 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#12455][pear-12455] : CodeSniffer treats content inside heredoc as PHP code +- Fixed bug [#12471][pear-12471] : Checkstyle report is broken +- Fixed bug [#12476][pear-12476] : PHP4 destructors are reported as error +- Fixed bug [#12513][pear-12513] : Checkstyle XML messages need to be utf8_encode()d - Thanks to [Sebastian Bergmann][@sebastianbergmann] for the patch. -- Fixed bug #12517 : getNewlineAfter() and dos files +- Fixed bug [#12517][pear-12517] : getNewlineAfter() and dos files + +[pear-12455]: https://pear.php.net/bugs/bug.php?id=12455 +[pear-12471]: https://pear.php.net/bugs/bug.php?id=12471 +[pear-12476]: https://pear.php.net/bugs/bug.php?id=12476 +[pear-12513]: https://pear.php.net/bugs/bug.php?id=12513 +[pear-12517]: https://pear.php.net/bugs/bug.php?id=12517 ## 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 @@ -6036,14 +6558,14 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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) +- Improved overall performance by optimising tokenizing and next/prev methods (feature request [#12421][pear-12421]) - 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) +- Added @subpackage support to file and class comment sniffs in PEAR standard (feature request [#12382][pear-12382]) - 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) +- An error is now displayed if you use a PHP version less than 5.1.0 (feature request [#12380][pear-12380]) - Thanks to [Carsten Wiedmann][pear-cwiedmann] for the patch -- phpcs now exits with status 2 if it receives invalid input (feature request #12380) +- phpcs now exits with status 2 if it receives invalid input (feature request [#12380][pear-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 @@ -6054,11 +6576,18 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#12368][pear-12368] : Autoloader cannot be found due to include_path override - Thanks to [Richard Quadling][pear-rquadling] for the patch -- Fixed bug #12378 : equal sign alignments problem with while() +- Fixed bug [#12378][pear-12378] : equal sign alignments problem with while() + +[pear-12368]: https://pear.php.net/bugs/bug.php?id=12368 +[pear-12378]: https://pear.php.net/bugs/bug.php?id=12378 +[pear-12380]: https://pear.php.net/bugs/bug.php?id=12380 +[pear-12382]: https://pear.php.net/bugs/bug.php?id=12382 +[pear-12421]: https://pear.php.net/bugs/bug.php?id=12421 ## 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 @@ -6104,14 +6633,18 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#12316][pear-12316] : PEAR is no longer the default standard +- Fixed bug [#12321][pear-12321] : wrong detection of missing function docblock + +[pear-12316]: https://pear.php.net/bugs/bug.php?id=12316 +[pear-12321]: https://pear.php.net/bugs/bug.php?id=12321 ## 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] + - 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 @@ -6119,46 +6652,55 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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) +- Added new XML report format; --report=xml (feature request [#11535][pear-11535]) - 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 new command line argument --ignore to specify a list of files to skip (feature request [#11556][pear-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 +- 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) +- Added new Generic DisallowTabIndentSniff to throw errors if tabs are used for indentation (feature request [#11738][pear-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 MultipleStatementAlignmentSniff has new private var to set a padding size limit (feature request [#11555][pear-11555]) +- Generic MultipleStatementAlignmentSniff can now handle assignments that span multiple lines (feature request [#11561][pear-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) +- Comment sniff errors about incorrect tag orders are now more descriptive (feature request [#11693][pear-11693]) ### Fixed -- Fixed bug #11473 : Invalid CamelCaps name when numbers used in names +- Fixed bug [#11473][pear-11473] : Invalid CamelCaps name when numbers used in names + +[pear-11473]: https://pear.php.net/bugs/bug.php?id=11473 +[pear-11535]: https://pear.php.net/bugs/bug.php?id=11535 +[pear-11555]: https://pear.php.net/bugs/bug.php?id=11555 +[pear-11556]: https://pear.php.net/bugs/bug.php?id=11556 +[pear-11561]: https://pear.php.net/bugs/bug.php?id=11561 +[pear-11693]: https://pear.php.net/bugs/bug.php?id=11693 +[pear-11738]: https://pear.php.net/bugs/bug.php?id=11738 ## 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 - +- 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) +- Coding standard classes can now specify a list of sniffs to exclude as well as include (feature request [#11056][pear-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) +- SVN tags now allowed in PEAR file doc blocks (feature request [#11038][pear-11038]) - Thanks to [Torsten Roehr][pear-troehr] for the patch -- Private methods in commenting sniffs and comment parser are now protected (feature request #11087) +- Private methods in commenting sniffs and comment parser are now protected (feature request [#11087][pear-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 @@ -6182,36 +6724,53 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Added Squiz CastSpacingSniff to ensure cast statements don't contain whitespace - Errors no longer thrown when checking 0 length files with verbosity on ### Fixed -- Fixed bug #11105 : getIncludedSniffs() not working anymore +- Fixed bug [#11105][pear-11105] : getIncludedSniffs() not working anymore - Thanks to [Blair Robertson][pear-adviva] for the patch -- Fixed bug #11120 : Uninitialized string offset in AbstractParser.php on line 200 +- Fixed bug [#11120][pear-11120] : Uninitialized string offset in `AbstractParser.php` on line 200 + +[pear-11038]: https://pear.php.net/bugs/bug.php?id=11038 +[pear-11056]: https://pear.php.net/bugs/bug.php?id=11056 +[pear-11087]: https://pear.php.net/bugs/bug.php?id=11087 +[pear-11105]: https://pear.php.net/bugs/bug.php?id=11105 +[pear-11120]: https://pear.php.net/bugs/bug.php?id=11120 ## 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) +- Now using PHP_EOL instead of hard-coded \n so output looks good on Windows (feature request [#10761][pear-10761]) - 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) +- phpcs now exits with status 0 (no errors) or 1 (errors found) (feature request [#10348][pear-10348]) +- Added new -l command line argument to stop recursion into directories (feature request [#10979][pear-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 +- Fixed bug [#10757][pear-10757] : Error in ControlSignatureSniff +- Fixed bugs [#10751][pear-10751], [#10777][pear-10777] : Sniffer class paths handled incorrectly in Windows - 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 +- Fixed bug [#10961][pear-10961] : Error "Last parameter comment requires a blank newline after it" thrown +- Fixed bug [#10983][pear-10983] : phpcs outputs notices when checking invalid PHP +- Fixed bug [#10980][pear-10980] : Incorrect warnings for equals sign + +[pear-10348]: https://pear.php.net/bugs/bug.php?id=10348 +[pear-10751]: https://pear.php.net/bugs/bug.php?id=10751 +[pear-10757]: https://pear.php.net/bugs/bug.php?id=10757 +[pear-10761]: https://pear.php.net/bugs/bug.php?id=10761 +[pear-10777]: https://pear.php.net/bugs/bug.php?id=10777 +[pear-10961]: https://pear.php.net/bugs/bug.php?id=10961 +[pear-10979]: https://pear.php.net/bugs/bug.php?id=10979 +[pear-10980]: https://pear.php.net/bugs/bug.php?id=10980 +[pear-10983]: https://pear.php.net/bugs/bug.php?id=10983 ## 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 @@ -6231,7 +6790,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 if @throws tags don't 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 @@ -6239,6 +6798,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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) @@ -6253,9 +6813,12 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#9844][pear-9844] : throw new Exception(\n accidentally reported as error but it ain't + +[pear-9844]: https://pear.php.net/bugs/bug.php?id=9844 ## 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 @@ -6277,14 +6840,20 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Fixed bug [#9274][pear-9274] : nested_parenthesis element not set for open and close parenthesis tokens +- Fixed bug [#9411][pear-9411] : too few pattern characters cause incorrect error report + +[pear-9411]: https://pear.php.net/bugs/bug.php?id=9411 ## 0.2.1 - 2006-11-09 + ### Fixed -- Fixed bug #9274 : nested_parenthesis element not set for open and close parenthesis tokens +- Fixed bug [#9274][pear-9274] : nested_parenthesis element not set for open and close parenthesis tokens + +[pear-9274]: https://pear.php.net/bugs/bug.php?id=9274 ## 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 @@ -6303,13 +6872,20 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### 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 +- Fixed bug [#8834][pear-8834] : Massive memory consumption +- Fixed bug [#8836][pear-8836] : path case issues in package.xml +- Fixed bug [#8843][pear-8843] : confusion on nested switch() +- Fixed bug [#8841][pear-8841] : comments taken as whitespace +- Fixed bug [#8884][pear-8884] : another problem with nested switch() statements + +[pear-8834]: https://pear.php.net/bugs/bug.php?id=8834 +[pear-8836]: https://pear.php.net/bugs/bug.php?id=8836 +[pear-8841]: https://pear.php.net/bugs/bug.php?id=8841 +[pear-8843]: https://pear.php.net/bugs/bug.php?id=8843 +[pear-8884]: https://pear.php.net/bugs/bug.php?id=8884 ## 0.1.1 - 2006-09-25 + ### Changed - Added unit tests for all PEAR sniffs - Exception class now extends from PEAR_Exception @@ -6318,16 +6894,19 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- 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 +- 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 @@ -6346,6 +6925,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 @@ -6357,11 +6937,12 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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 +- Much faster tokenizing 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 @@ -6371,9 +6952,10 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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) +- Switches can now be specified together (e.g. `phpcs -nv`) as well as separately (`phpcs -n -v`) ## 0.0.1 - 2006-07-19 + ### Added - Initial preview release @@ -6382,6 +6964,9 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo --> [Unreleased]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/master...HEAD +[3.10.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.10.0...3.10.1 +[3.10.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.9.2...3.10.0 +[3.9.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.9.1...3.9.2 [3.9.1]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.9.0...3.9.1 [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 @@ -6518,6 +7103,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@cixtor]: https://github.com/cixtor [@claylo]: https://github.com/claylo [@codebymikey]: https://github.com/codebymikey +[@costdev]: https://github.com/costdev [@covex-nn]: https://github.com/covex-nn [@cweiske]: https://github.com/cweiske [@Daimona]: https://github.com/Daimona @@ -6616,6 +7202,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@michaelbutler]: https://github.com/michaelbutler [@michalbundyra]: https://github.com/michalbundyra [@Morerice]: https://github.com/Morerice +[@mbomb007]: https://github.com/mbomb007 [@morozov]: https://github.com/morozov [@mrkrstphr]: https://github.com/mrkrstphr [@mythril]: https://github.com/mythril @@ -6634,6 +7221,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@pfrenssen]: https://github.com/pfrenssen [@phil-davis]: https://github.com/phil-davis [@photodude]: https://github.com/photodude +[@przemekhernik]: https://github.com/przemekhernik [@r3nat]: https://github.com/r3nat [@raul338]: https://github.com/raul338 [@realmfoo]: https://github.com/realmfoo diff --git a/vendor/squizlabs/php_codesniffer/README.md b/vendor/squizlabs/php_codesniffer/README.md index d375015b..0e9cde36 100644 --- a/vendor/squizlabs/php_codesniffer/README.md +++ b/vendor/squizlabs/php_codesniffer/README.md @@ -1,16 +1,17 @@ -PHP_CodeSniffer -===================================================== +# PHP_CodeSniffer @@ -47,7 +48,7 @@ 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`. +fingerprint `689D AD77 8FF0 8760 E046 228B A978 2203 05CD 5C32`. ### Composer If you use Composer, you can install PHP_CodeSniffer system-wide with the following command: @@ -71,17 +72,19 @@ You will then be able to run PHP_CodeSniffer from the vendor bin directory: ./vendor/bin/phpcs -h ./vendor/bin/phpcbf -h ``` + ### Phive If you use Phive, you can install PHP_CodeSniffer as a project tool using the following commands: ```bash -phive install --trust-gpg-keys 95DE904AB800754A11D80B605E6DDE998AB73B8E phpcs -phive install --trust-gpg-keys 95DE904AB800754A11D80B605E6DDE998AB73B8E phpcbf +phive install --trust-gpg-keys 689DAD778FF08760E046228BA978220305CD5C32 phpcs +phive install --trust-gpg-keys 689DAD778FF08760E046228BA978220305CD5C32 phpcbf ``` You will then be able to run PHP_CodeSniffer from the `tools` directory: ```bash ./tools/phpcs -h ./tools/phpcbf -h ``` + ### Git Clone You can also download the PHP_CodeSniffer source and run the `phpcs` and `phpcbf` commands directly from the Git clone: ```bash @@ -90,6 +93,7 @@ cd PHP_CodeSniffer php bin/phpcs -h php bin/phpcbf -h ``` + ## Getting Started The default coding standard used by PHP_CodeSniffer is the PEAR coding standard. To check a file against the PEAR coding standard, simply specify the file's location: diff --git a/vendor/squizlabs/php_codesniffer/autoload.php b/vendor/squizlabs/php_codesniffer/autoload.php index d7d655e8..5dd13873 100644 --- a/vendor/squizlabs/php_codesniffer/autoload.php +++ b/vendor/squizlabs/php_codesniffer/autoload.php @@ -73,7 +73,7 @@ public static function load($class) // Make sure we don't try to load any of Composer's classes // while the autoloader is being setup. if (strpos($class, 'Composer\\') === 0) { - return; + return false; } if (strpos(__DIR__, 'phar://') !== 0 @@ -298,7 +298,7 @@ public static function getLoadedClassName($path) * * @param string $class The name of the class. * - * @throws \Exception If the class name has not been loaded + * @throws \Exception If the class name has not been loaded. * @return string */ public static function getLoadedFileName($class) diff --git a/vendor/squizlabs/php_codesniffer/composer.json b/vendor/squizlabs/php_codesniffer/composer.json index ae7c7604..28cdb07b 100644 --- a/vendor/squizlabs/php_codesniffer/composer.json +++ b/vendor/squizlabs/php_codesniffer/composer.json @@ -42,6 +42,9 @@ "bin/phpcbf", "bin/phpcs" ], + "config": { + "lock": false + }, "extra": { "branch-alias": { "dev-master": "3.x-dev" diff --git a/vendor/squizlabs/php_codesniffer/src/Config.php b/vendor/squizlabs/php_codesniffer/src/Config.php index e512d33f..7dc0b818 100644 --- a/vendor/squizlabs/php_codesniffer/src/Config.php +++ b/vendor/squizlabs/php_codesniffer/src/Config.php @@ -17,6 +17,7 @@ use PHP_CodeSniffer\Exceptions\DeepExitException; use PHP_CodeSniffer\Exceptions\RuntimeException; use PHP_CodeSniffer\Util\Common; +use PHP_CodeSniffer\Util\Help; use PHP_CodeSniffer\Util\Standards; /** @@ -84,7 +85,7 @@ class Config * * @var string */ - const VERSION = '3.9.1'; + const VERSION = '3.10.1'; /** * Package stability; either stable, beta or alpha. @@ -1395,71 +1396,21 @@ public function printShortUsage($return=false) */ public function printPHPCSUsage() { - echo 'Usage: phpcs [-nwlsaepqvi] [-d key[=value]] [--colors] [--no-colors]'.PHP_EOL; - echo ' [--cache[=]] [--no-cache] [--tab-width=]'.PHP_EOL; - echo ' [--report=] [--report-file=] [--report-=]'.PHP_EOL; - echo ' [--report-width=] [--basepath=] [--bootstrap=]'.PHP_EOL; - echo ' [--severity=] [--error-severity=] [--warning-severity=]'.PHP_EOL; - echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL; - echo ' [--standard=] [--sniffs=] [--exclude=]'.PHP_EOL; - echo ' [--encoding=] [--parallel=] [--generator=]'.PHP_EOL; - echo ' [--extensions=] [--ignore=] [--ignore-annotations]'.PHP_EOL; - echo ' [--stdin-path=] [--file-list=] [--filter=] - ...'.PHP_EOL; - echo PHP_EOL; - echo ' - Check STDIN instead of local files and directories'.PHP_EOL; - 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 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; - echo ' -q Quiet mode; disables progress and verbose output'.PHP_EOL; - echo ' -m Stop error messages from being recorded'.PHP_EOL; - echo ' (saves a lot of memory, but stops many reports from being used)'.PHP_EOL; - echo ' -v Print processed files'.PHP_EOL; - echo ' -vv Print ruleset and token output'.PHP_EOL; - echo ' -vvv Print sniff processing information'.PHP_EOL; - echo ' -i Show a list of installed coding standards'.PHP_EOL; - echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL; - echo PHP_EOL; - echo ' --help Print this help message'.PHP_EOL; - echo ' --version Print version information'.PHP_EOL; - echo ' --colors Use colors in output'.PHP_EOL; - echo ' --no-colors Do not use colors in output (this is the default)'.PHP_EOL; - echo ' --cache Cache results between runs'.PHP_EOL; - echo ' --no-cache Do not cache results between runs (this is the default)'.PHP_EOL; - echo ' --ignore-annotations Ignore all phpcs: annotations in code comments'.PHP_EOL; - echo PHP_EOL; - echo ' Use a specific file for caching (uses a temporary file by default)'.PHP_EOL; - echo ' A path to strip from the front of file paths inside reports'.PHP_EOL; - echo ' A comma separated list of files to run before processing begins'.PHP_EOL; - echo ' The encoding of the files being checked (default is utf-8)'.PHP_EOL; - echo ' A comma separated list of file extensions to check'.PHP_EOL; - echo ' The type of the file can be specified using: ext/type'.PHP_EOL; - echo ' e.g., module/php,es/js'.PHP_EOL; - echo ' One or more files and/or directories to check'.PHP_EOL; - echo ' A file containing a list of files and/or directories to check (one per line)'.PHP_EOL; - echo ' Use either the "GitModified" or "GitStaged" filter,'.PHP_EOL; - echo ' or specify the path to a custom filter class'.PHP_EOL; - echo ' Use either the "HTML", "Markdown" or "Text" generator'.PHP_EOL; - echo ' (forces documentation generation instead of checking)'.PHP_EOL; - echo ' A comma separated list of patterns to ignore files and directories'.PHP_EOL; - 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", "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; - echo ' or set to "auto" to use current screen width, where supported'.PHP_EOL; - echo ' The minimum severity required to display an error or warning'.PHP_EOL; - echo ' A comma separated list of sniff codes to include or exclude from checking'.PHP_EOL; - echo ' (all sniffs must be part of the specified standard)'.PHP_EOL; - echo ' The name or path of the coding standard to use'.PHP_EOL; - echo ' If processing STDIN, the file path that STDIN will be processed as'.PHP_EOL; - echo ' The number of spaces each tab represents'.PHP_EOL; + $longOptions = explode(',', Help::DEFAULT_LONG_OPTIONS); + $longOptions[] = 'cache'; + $longOptions[] = 'no-cache'; + $longOptions[] = 'report'; + $longOptions[] = 'report-file'; + $longOptions[] = 'report-report'; + $longOptions[] = 'config-explain'; + $longOptions[] = 'config-set'; + $longOptions[] = 'config-delete'; + $longOptions[] = 'config-show'; + $longOptions[] = 'generator'; + + $shortOptions = Help::DEFAULT_SHORT_OPTIONS.'aems'; + + (new Help($this, $longOptions, $shortOptions))->display(); }//end printPHPCSUsage() @@ -1471,49 +1422,11 @@ public function printPHPCSUsage() */ public function printPHPCBFUsage() { - echo 'Usage: phpcbf [-nwli] [-d key[=value]] [--ignore-annotations] [--bootstrap=]'.PHP_EOL; - echo ' [--standard=] [--sniffs=] [--exclude=] [--suffix=]'.PHP_EOL; - echo ' [--severity=] [--error-severity=] [--warning-severity=]'.PHP_EOL; - echo ' [--tab-width=] [--encoding=] [--parallel=]'.PHP_EOL; - echo ' [--basepath=] [--extensions=] [--ignore=]'.PHP_EOL; - echo ' [--stdin-path=] [--file-list=] [--filter=] - ...'.PHP_EOL; - echo PHP_EOL; - echo ' - Fix STDIN instead of local files and directories'.PHP_EOL; - echo ' -n Do not fix warnings (shortcut for --warning-severity=0)'.PHP_EOL; - echo ' -w Fix both warnings and errors (on by default)'.PHP_EOL; - echo ' -l Local directory only, no recursion'.PHP_EOL; - echo ' -p Show progress of the run'.PHP_EOL; - echo ' -q Quiet mode; disables progress and verbose output'.PHP_EOL; - echo ' -v Print processed files'.PHP_EOL; - echo ' -vv Print ruleset and token output'.PHP_EOL; - echo ' -vvv Print sniff processing information'.PHP_EOL; - echo ' -i Show a list of installed coding standards'.PHP_EOL; - echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL; - echo PHP_EOL; - echo ' --help Print this help message'.PHP_EOL; - echo ' --version Print version information'.PHP_EOL; - echo ' --ignore-annotations Ignore all phpcs: annotations in code comments'.PHP_EOL; - echo PHP_EOL; - echo ' A path to strip from the front of file paths inside reports'.PHP_EOL; - echo ' A comma separated list of files to run before processing begins'.PHP_EOL; - echo ' The encoding of the files being fixed (default is utf-8)'.PHP_EOL; - echo ' A comma separated list of file extensions to fix'.PHP_EOL; - echo ' The type of the file can be specified using: ext/type'.PHP_EOL; - echo ' e.g., module/php,es/js'.PHP_EOL; - echo ' One or more files and/or directories to fix'.PHP_EOL; - echo ' A file containing a list of files and/or directories to fix (one per line)'.PHP_EOL; - echo ' Use either the "GitModified" or "GitStaged" filter,'.PHP_EOL; - echo ' or specify the path to a custom filter class'.PHP_EOL; - echo ' A comma separated list of patterns to ignore files and directories'.PHP_EOL; - echo ' How many files should be fixed simultaneously (default is 1)'.PHP_EOL; - echo ' The minimum severity required to fix an error or warning'.PHP_EOL; - echo ' A comma separated list of sniff codes to include or exclude from fixing'.PHP_EOL; - echo ' (all sniffs must be part of the specified standard)'.PHP_EOL; - echo ' The name or path of the coding standard to use'.PHP_EOL; - echo ' If processing STDIN, the file path that STDIN will be processed as'.PHP_EOL; - echo ' Write modified files to a filename using this suffix'.PHP_EOL; - echo ' ("diff" and "patch" are not used in this mode)'.PHP_EOL; - echo ' The number of spaces each tab represents'.PHP_EOL; + $longOptions = explode(',', Help::DEFAULT_LONG_OPTIONS); + $longOptions[] = 'suffix'; + $shortOptions = Help::DEFAULT_SHORT_OPTIONS; + + (new Help($this, $longOptions, $shortOptions))->display(); }//end printPHPCBFUsage() diff --git a/vendor/squizlabs/php_codesniffer/src/Files/File.php b/vendor/squizlabs/php_codesniffer/src/Files/File.php index ab3cc290..3e1409c5 100644 --- a/vendor/squizlabs/php_codesniffer/src/Files/File.php +++ b/vendor/squizlabs/php_codesniffer/src/Files/File.php @@ -1419,7 +1419,9 @@ public function getMethodParameters($stackPtr) // it's likely to be an array which might have arguments in it. This // could cause problems in our parsing below, so lets just skip to the // end of it. - if (isset($this->tokens[$i]['parenthesis_opener']) === true) { + if ($this->tokens[$i]['code'] !== T_TYPE_OPEN_PARENTHESIS + && isset($this->tokens[$i]['parenthesis_opener']) === true + ) { // Don't do this if it's the close parenthesis for the method. if ($i !== $this->tokens[$i]['parenthesis_closer']) { $i = $this->tokens[$i]['parenthesis_closer']; @@ -1513,6 +1515,8 @@ public function getMethodParameters($stackPtr) case T_NS_SEPARATOR: case T_TYPE_UNION: case T_TYPE_INTERSECTION: + case T_TYPE_OPEN_PARENTHESIS: + case T_TYPE_CLOSE_PARENTHESIS: case T_FALSE: case T_TRUE: case T_NULL: @@ -1735,18 +1739,20 @@ public function getMethodProperties($stackPtr) } $valid = [ - T_STRING => T_STRING, - T_CALLABLE => T_CALLABLE, - T_SELF => T_SELF, - T_PARENT => T_PARENT, - T_STATIC => T_STATIC, - T_FALSE => T_FALSE, - T_TRUE => T_TRUE, - T_NULL => T_NULL, - T_NAMESPACE => T_NAMESPACE, - T_NS_SEPARATOR => T_NS_SEPARATOR, - T_TYPE_UNION => T_TYPE_UNION, - T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, + T_STRING => T_STRING, + T_CALLABLE => T_CALLABLE, + T_SELF => T_SELF, + T_PARENT => T_PARENT, + T_STATIC => T_STATIC, + T_FALSE => T_FALSE, + T_TRUE => T_TRUE, + T_NULL => T_NULL, + T_NAMESPACE => T_NAMESPACE, + T_NS_SEPARATOR => T_NS_SEPARATOR, + T_TYPE_UNION => T_TYPE_UNION, + T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, + T_TYPE_OPEN_PARENTHESIS => T_TYPE_OPEN_PARENTHESIS, + T_TYPE_CLOSE_PARENTHESIS => T_TYPE_CLOSE_PARENTHESIS, ]; for ($i = $this->tokens[$stackPtr]['parenthesis_closer']; $i < $this->numTokens; $i++) { @@ -1757,6 +1763,20 @@ public function getMethodProperties($stackPtr) break; } + if ($this->tokens[$i]['code'] === T_USE) { + // Skip over closure use statements. + for ($j = ($i + 1); $j < $this->numTokens && isset(Tokens::$emptyTokens[$this->tokens[$j]['code']]) === true; $j++); + if ($this->tokens[$j]['code'] === T_OPEN_PARENTHESIS) { + if (isset($this->tokens[$j]['parenthesis_closer']) === false) { + // Live coding/parse error, stop parsing. + break; + } + + $i = $this->tokens[$j]['parenthesis_closer']; + continue; + } + } + if ($this->tokens[$i]['code'] === T_NULLABLE) { $nullableReturnType = true; } @@ -1938,17 +1958,19 @@ public function getMemberProperties($stackPtr) if ($i < $stackPtr) { // We've found a type. $valid = [ - T_STRING => T_STRING, - 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_NAMESPACE => T_NAMESPACE, - T_NS_SEPARATOR => T_NS_SEPARATOR, - T_TYPE_UNION => T_TYPE_UNION, - T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, + T_STRING => T_STRING, + 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_NAMESPACE => T_NAMESPACE, + T_NS_SEPARATOR => T_NS_SEPARATOR, + T_TYPE_UNION => T_TYPE_UNION, + T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, + T_TYPE_OPEN_PARENTHESIS => T_TYPE_OPEN_PARENTHESIS, + T_TYPE_CLOSE_PARENTHESIS => T_TYPE_CLOSE_PARENTHESIS, ]; for ($i; $i < $stackPtr; $i++) { @@ -2246,7 +2268,7 @@ public function getTokensAsString($start, $length, $origContent=false) * be returned. * @param bool $local If true, tokens outside the current statement * will not be checked. IE. checking will stop - * at the previous semi-colon found. + * at the previous semicolon found. * * @return int|false * @see findNext() @@ -2327,7 +2349,7 @@ public function findPrevious( * be returned. * @param bool $local If true, tokens outside the current statement * will not be checked. i.e., checking will stop - * at the next semi-colon found. + * at the next semicolon found. * * @return int|false * @see findPrevious() @@ -2413,51 +2435,88 @@ public function findStartOfStatement($start, $ignore=null) // If the start token is inside the case part of a match expression, // find the start of the condition. If it's in the statement part, find // the token that comes after the match arrow. - $matchExpression = $this->getCondition($start, T_MATCH); - if ($matchExpression !== false) { - for ($prevMatch = $start; $prevMatch > $this->tokens[$matchExpression]['scope_opener']; $prevMatch--) { - if ($prevMatch !== $start - && ($this->tokens[$prevMatch]['code'] === T_MATCH_ARROW - || $this->tokens[$prevMatch]['code'] === T_COMMA) - ) { - break; - } + if (empty($this->tokens[$start]['conditions']) === false) { + $conditions = $this->tokens[$start]['conditions']; + $lastConditionOwner = end($conditions); + $matchExpression = key($conditions); + + if ($lastConditionOwner === T_MATCH + // Check if the $start token is at the same parentheses nesting level as the match token. + && ((empty($this->tokens[$matchExpression]['nested_parenthesis']) === true + && empty($this->tokens[$start]['nested_parenthesis']) === true) + || ((empty($this->tokens[$matchExpression]['nested_parenthesis']) === false + && empty($this->tokens[$start]['nested_parenthesis']) === false) + && $this->tokens[$matchExpression]['nested_parenthesis'] === $this->tokens[$start]['nested_parenthesis'])) + ) { + // Walk back to the previous match arrow (if it exists). + $lastComma = null; + $inNestedExpression = false; + for ($prevMatch = $start; $prevMatch > $this->tokens[$matchExpression]['scope_opener']; $prevMatch--) { + if ($prevMatch !== $start && $this->tokens[$prevMatch]['code'] === T_MATCH_ARROW) { + break; + } - // Skip nested statements. - if (isset($this->tokens[$prevMatch]['bracket_opener']) === true - && $prevMatch === $this->tokens[$prevMatch]['bracket_closer'] - ) { - $prevMatch = $this->tokens[$prevMatch]['bracket_opener']; - } else if (isset($this->tokens[$prevMatch]['parenthesis_opener']) === true - && $prevMatch === $this->tokens[$prevMatch]['parenthesis_closer'] - ) { - $prevMatch = $this->tokens[$prevMatch]['parenthesis_opener']; - } - } + if ($prevMatch !== $start && $this->tokens[$prevMatch]['code'] === T_COMMA) { + $lastComma = $prevMatch; + continue; + } - if ($prevMatch <= $this->tokens[$matchExpression]['scope_opener']) { - // We're before the arrow in the first case. - $next = $this->findNext(Tokens::$emptyTokens, ($this->tokens[$matchExpression]['scope_opener'] + 1), null, true); - if ($next === false) { - return $start; - } + // Skip nested statements. + if (isset($this->tokens[$prevMatch]['bracket_opener']) === true + && $prevMatch === $this->tokens[$prevMatch]['bracket_closer'] + ) { + $prevMatch = $this->tokens[$prevMatch]['bracket_opener']; + continue; + } - return $next; - } + if (isset($this->tokens[$prevMatch]['parenthesis_opener']) === true + && $prevMatch === $this->tokens[$prevMatch]['parenthesis_closer'] + ) { + $prevMatch = $this->tokens[$prevMatch]['parenthesis_opener']; + continue; + } - if ($this->tokens[$prevMatch]['code'] === T_COMMA) { - // We're before the arrow, but not in the first case. - $prevMatchArrow = $this->findPrevious(T_MATCH_ARROW, ($prevMatch - 1), $this->tokens[$matchExpression]['scope_opener']); - if ($prevMatchArrow === false) { - // We're before the arrow in the first case. - $next = $this->findNext(Tokens::$emptyTokens, ($this->tokens[$matchExpression]['scope_opener'] + 1), null, true); - return $next; - } + // Stop if we're _within_ a nested short array statement, which may contain comma's too. + // No need to deal with parentheses, those are handled above via the `nested_parenthesis` checks. + if (isset($this->tokens[$prevMatch]['bracket_opener']) === true + && $this->tokens[$prevMatch]['bracket_closer'] > $start + ) { + $inNestedExpression = true; + break; + } + }//end for + + if ($inNestedExpression === false) { + // $prevMatch will now either be the scope opener or a match arrow. + // If it is the scope opener, go the first non-empty token after. $start will have been part of the first condition. + if ($prevMatch <= $this->tokens[$matchExpression]['scope_opener']) { + // We're before the arrow in the first case. + $next = $this->findNext(Tokens::$emptyTokens, ($this->tokens[$matchExpression]['scope_opener'] + 1), null, true); + if ($next === false) { + // Shouldn't be possible. + return $start; + } - $end = $this->findEndOfStatement($prevMatchArrow); - $next = $this->findNext(Tokens::$emptyTokens, ($end + 1), null, true); - return $next; - } + return $next; + } + + // Okay, so we found a match arrow. + // If $start was part of the "next" condition, the last comma will be set. + // Otherwise, $start must have been part of a return expression. + if (isset($lastComma) === true && $lastComma > $prevMatch) { + $prevMatch = $lastComma; + } + + // In both cases, go to the first non-empty token after. + $next = $this->findNext(Tokens::$emptyTokens, ($prevMatch + 1), null, true); + if ($next === false) { + // Shouldn't be possible. + return $start; + } + + return $next; + }//end if + }//end if }//end if $lastNotEmpty = $start; diff --git a/vendor/squizlabs/php_codesniffer/src/Fixer.php b/vendor/squizlabs/php_codesniffer/src/Fixer.php index b3e93335..b429825f 100644 --- a/vendor/squizlabs/php_codesniffer/src/Fixer.php +++ b/vendor/squizlabs/php_codesniffer/src/Fixer.php @@ -228,7 +228,7 @@ public function fixFile() * * @return string * - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException when the diff command fails. + * @throws \PHP_CodeSniffer\Exceptions\RuntimeException When the diff command fails. */ public function generateDiff($filePath=null, $colors=true) { diff --git a/vendor/squizlabs/php_codesniffer/src/Reporter.php b/vendor/squizlabs/php_codesniffer/src/Reporter.php index 3e3da321..288a78e6 100644 --- a/vendor/squizlabs/php_codesniffer/src/Reporter.php +++ b/vendor/squizlabs/php_codesniffer/src/Reporter.php @@ -236,7 +236,7 @@ public function printReport($report) ob_end_clean(); if ($this->config->colors !== true || $reportFile !== null) { - $generatedReport = preg_replace('`\033\[[0-9;]+m`', '', $generatedReport); + $generatedReport = Common::stripColors($generatedReport); } if ($reportFile !== null) { diff --git a/vendor/squizlabs/php_codesniffer/src/Ruleset.php b/vendor/squizlabs/php_codesniffer/src/Ruleset.php index e4f240c5..baa0f32c 100644 --- a/vendor/squizlabs/php_codesniffer/src/Ruleset.php +++ b/vendor/squizlabs/php_codesniffer/src/Ruleset.php @@ -414,11 +414,7 @@ public function showSniffDeprecations() $sniffCode = substr($sniffCode, 0, ($maxMessageWidth - 3)).'...'; } - $message = '- '.$sniffCode.PHP_EOL; - if ($this->config->colors === true) { - $message = '- '."\033[36m".$sniffCode."\033[0m".PHP_EOL; - } - + $message = '- '."\033[36m".$sniffCode."\033[0m".PHP_EOL; $maxActualWidth = max($maxActualWidth, strlen($sniffCode)); // Normalize new line characters in custom message. @@ -451,8 +447,13 @@ public function showSniffDeprecations() echo $summaryLine.PHP_EOL; } + $messages = implode(PHP_EOL, $messages); + if ($this->config->colors === false) { + $messages = Common::stripColors($messages); + } + echo str_repeat('-', min(($maxActualWidth + 4), $reportWidth)).PHP_EOL; - echo implode(PHP_EOL, $messages); + echo $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; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/CodeAnalysis/EmptyPHPStatementStandard.xml b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/CodeAnalysis/EmptyPHPStatementStandard.xml index 5652f657..6b96c825 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/CodeAnalysis/EmptyPHPStatementStandard.xml +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/CodeAnalysis/EmptyPHPStatementStandard.xml @@ -20,11 +20,11 @@ - + ; if (true) { @@ -32,7 +32,7 @@ if (true) { } ]]> - + ;;; if (true) { diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/Commenting/DocCommentStandard.xml b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/Commenting/DocCommentStandard.xml new file mode 100644 index 00000000..bbeb4f69 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/Commenting/DocCommentStandard.xml @@ -0,0 +1,269 @@ + + + + + + + + + + Some content. + */ + ]]> + + + + */ + ]]> + + + + + + + + /** + * Short description. + */ + ]]> + + + /** Short description. */ + ]]> + + + + + + + + Short description. + */ + ]]> + + + @return int + */ + +/** + * + * Short description. + */ + ]]> + + + + + + + + Short description. + * + * Long description. + */ + ]]> + + + short description. + * + * long description. + */ + ]]> + + + + + + + + * + * Long description. + * + * @param int $foo + */ + ]]> + + + * + * + + * Long description. + * @param int $foo + */ + ]]> + + + + + + + + * @param int $foo + * @param string $bar + */ + ]]> + + + * + * @param string $bar + */ + ]]> + + + + + + + + * @param int $foo + * + * @since 3.4.8 + * @deprecated 6.0.0 + */ + ]]> + + + * @param int $foo + * @since 3.4.8 + * @deprecated 6.0.0 + */ + ]]> + + + + + + + + 0.5.0 + * @deprecated 1.0.0 + */ + ]]> + + + 0.5.0 + * @deprecated 1.0.0 + */ + ]]> + + + + + + + + @param string $foo + * + * @return void + */ + ]]> + + + @param string $bar + */ + ]]> + + + + + + + + + */ + ]]> + + + * + */ + ]]> + + + diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php index 87da8f3c..b6e3d37d 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php @@ -62,7 +62,6 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array // Determine how far indented the entire array declaration should be. $ignore = Tokens::$emptyTokens; $ignore[] = T_DOUBLE_ARROW; - $ignore[] = T_COMMA; $prev = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true); $start = $phpcsFile->findStartOfStatement($prev); $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $start, true); @@ -152,7 +151,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array $error = 'Closing brace of array declaration must be on a new line'; $fix = $phpcsFile->addFixableError($error, $arrayEnd, 'CloseBraceNotNewLine'); if ($fix === true) { - $padding = $phpcsFile->eolChar.str_repeat(' ', $expectedIndent); + $padding = $phpcsFile->eolChar.str_repeat(' ', $startIndent); $phpcsFile->fixer->addContentBefore($arrayEnd, $padding); } @@ -160,20 +159,19 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array } // The close brace must be indented one stop less. - $expectedIndent -= $this->indent; - $foundIndent = ($tokens[$arrayEnd]['column'] - 1); - if ($foundIndent === $expectedIndent) { + $foundIndent = ($tokens[$arrayEnd]['column'] - 1); + if ($foundIndent === $startIndent) { return; } $pluralizeSpace = 's'; - if ($expectedIndent === 1) { + if ($startIndent === 1) { $pluralizeSpace = ''; } $error = 'Array close brace not indented correctly; expected %s space%s but found %s'; $data = [ - $expectedIndent, + $startIndent, $pluralizeSpace, $foundIndent, ]; @@ -182,7 +180,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array return; } - $padding = str_repeat(' ', $expectedIndent); + $padding = str_repeat(' ', $startIndent); if ($foundIndent === 0) { $phpcsFile->fixer->addContentBefore($arrayEnd, $padding); } else { diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php index 58d26325..6854945a 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php @@ -45,9 +45,7 @@ public function process(File $phpcsFile, $stackPtr) $error = 'Short array syntax must be used to define arrays'; - if (isset($tokens[$stackPtr]['parenthesis_opener']) === false - || isset($tokens[$stackPtr]['parenthesis_closer']) === false - ) { + if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) { // Live coding/parse error, just show the error, don't try and fix it. $phpcsFile->addError($error, $stackPtr, 'Found'); return; @@ -61,13 +59,9 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->beginChangeset(); - if ($opener === null) { - $phpcsFile->fixer->replaceToken($stackPtr, '[]'); - } else { - $phpcsFile->fixer->replaceToken($stackPtr, ''); - $phpcsFile->fixer->replaceToken($opener, '['); - $phpcsFile->fixer->replaceToken($closer, ']'); - } + $phpcsFile->fixer->replaceToken($stackPtr, ''); + $phpcsFile->fixer->replaceToken($opener, '['); + $phpcsFile->fixer->replaceToken($closer, ']'); $phpcsFile->fixer->endChangeset(); } diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php index 3ebfccc0..4ecf6303 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php @@ -2,7 +2,7 @@ /** * Checks against empty PHP statements. * - * - Check against two semi-colons with no executable code in between. + * - Check against two semicolons with no executable code in between. * - Check against an empty PHP open - close tag combination. * * @author Juliette Reinders Folmer @@ -76,7 +76,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - // Else, it's something like `if (foo) {};` and the semi-colon is not needed. + // Else, it's something like `if (foo) {};` and the semicolon is not needed. } if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { @@ -91,7 +91,7 @@ public function process(File $phpcsFile, $stackPtr) } $fix = $phpcsFile->addFixableWarning( - 'Empty PHP statement detected: superfluous semi-colon.', + 'Empty PHP statement detected: superfluous semicolon.', $stackPtr, 'SemicolonWithoutCodeDetected' ); @@ -101,7 +101,7 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$prevNonEmpty]['code'] === T_OPEN_TAG || $tokens[$prevNonEmpty]['code'] === T_OPEN_TAG_WITH_ECHO ) { - // Check for superfluous whitespace after the semi-colon which will be + // Check for superfluous whitespace after the semicolon which will be // removed as the `findIncrementers($tokens, $token); // Skip if empty. @@ -88,8 +88,8 @@ public function process(File $phpcsFile, $stackPtr) $diff = array_intersect($outer, $inner); if (count($diff) !== 0) { - $error = 'Loop incrementor (%s) jumbling with inner loop'; - $data = [join(', ', $diff)]; + $error = 'Loop incrementer (%s) jumbling with inner loop'; + $data = [implode(', ', $diff)]; $phpcsFile->addWarning($error, $stackPtr, 'Found', $data); } } @@ -101,14 +101,14 @@ public function process(File $phpcsFile, $stackPtr) * Get all used variables in the incrementer part of a for statement. * * @param array $tokens Array with all code sniffer tokens. - * @param array $token Current for loop token + * @param array $token Current for loop token. * * @return string[] List of all found incrementer variables. */ protected function findIncrementers(array $tokens, array $token) { // Skip invalid statement. - if (isset($token['parenthesis_opener']) === false) { + if (isset($token['parenthesis_opener'], $token['parenthesis_closer']) === false) { return []; } diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php index d82931cb..3dc7795b 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php @@ -25,7 +25,10 @@ class DisallowYodaConditionsSniff implements Sniff */ public function register() { - return Tokens::$comparisonTokens; + $tokens = Tokens::$comparisonTokens; + unset($tokens[T_COALESCE]); + + return $tokens; }//end register() @@ -54,9 +57,7 @@ public function process(File $phpcsFile, $stackPtr) T_CONSTANT_ENCAPSED_STRING, ]; - if ($previousIndex === false - || in_array($tokens[$previousIndex]['code'], $relevantTokens, true) === false - ) { + if (in_array($tokens[$previousIndex]['code'], $relevantTokens, true) === false) { return; } @@ -68,9 +69,6 @@ public function process(File $phpcsFile, $stackPtr) } $prevIndex = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($previousIndex - 1), null, true); - if ($prevIndex === false) { - return; - } if (in_array($tokens[$prevIndex]['code'], Tokens::$arithmeticTokens, true) === true) { return; @@ -82,16 +80,15 @@ public function process(File $phpcsFile, $stackPtr) // Is it a parenthesis. if ($tokens[$previousIndex]['code'] === T_CLOSE_PARENTHESIS) { - // Check what exists inside the parenthesis. - $closeParenthesisIndex = $phpcsFile->findPrevious( + $beforeOpeningParenthesisIndex = $phpcsFile->findPrevious( Tokens::$emptyTokens, ($tokens[$previousIndex]['parenthesis_opener'] - 1), null, true ); - if ($closeParenthesisIndex === false || $tokens[$closeParenthesisIndex]['code'] !== T_ARRAY) { - if ($tokens[$closeParenthesisIndex]['code'] === T_STRING) { + if ($beforeOpeningParenthesisIndex === false || $tokens[$beforeOpeningParenthesisIndex]['code'] !== T_ARRAY) { + if ($tokens[$beforeOpeningParenthesisIndex]['code'] === T_STRING) { return; } @@ -107,14 +104,14 @@ public function process(File $phpcsFile, $stackPtr) return; } - // If there is nothing inside the parenthesis, it it not a Yoda. + // If there is nothing inside the parenthesis, it is not a Yoda condition. $opener = $tokens[$previousIndex]['parenthesis_opener']; $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($previousIndex - 1), ($opener + 1), true); if ($prev === false) { return; } - } else if ($tokens[$closeParenthesisIndex]['code'] === T_ARRAY - && $this->isArrayStatic($phpcsFile, $closeParenthesisIndex) === false + } else if ($tokens[$beforeOpeningParenthesisIndex]['code'] === T_ARRAY + && $this->isArrayStatic($phpcsFile, $beforeOpeningParenthesisIndex) === false ) { return; }//end if @@ -141,7 +138,6 @@ public function isArrayStatic(File $phpcsFile, $arrayToken) { $tokens = $phpcsFile->getTokens(); - $arrayEnd = null; if ($tokens[$arrayToken]['code'] === T_OPEN_SHORT_ARRAY) { $start = $arrayToken; $end = $tokens[$arrayToken]['bracket_closer']; @@ -149,6 +145,7 @@ public function isArrayStatic(File $phpcsFile, $arrayToken) $start = $tokens[$arrayToken]['parenthesis_opener']; $end = $tokens[$arrayToken]['parenthesis_closer']; } else { + // Shouldn't be possible but may happen if external sniffs are using this method. return true; } diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php index 41efffa4..bc4a916d 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -75,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr) // Ignore the ELSE in ELSE IF. We'll process the IF part later. if ($tokens[$stackPtr]['code'] === T_ELSE) { - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($tokens[$next]['code'] === T_IF) { return; } diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php index c0b584c3..637bf41e 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php @@ -63,7 +63,7 @@ public function register() * the token was found. * * @return int - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jslint.js could not be run + * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jslint.js could not be run. */ public function process(File $phpcsFile, $stackPtr) { diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php index 65faed99..1c6b0e3f 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php @@ -54,7 +54,7 @@ public function register() * the token was found. * * @return int - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jshint.js could not be run + * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jshint.js could not be run. */ public function process(File $phpcsFile, $stackPtr) { diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php index f65c9a77..ae8264eb 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php @@ -48,7 +48,7 @@ public function register() * the token was found. * * @return int - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jshint.js could not be run + * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jshint.js could not be run. */ public function process(File $phpcsFile, $stackPtr) { diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php index d97c0f79..76c4a630 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php @@ -27,6 +27,10 @@ public function register() return [ T_STRING, T_VARIABLE, + T_ANON_CLASS, + T_PARENT, + T_SELF, + T_STATIC, ]; }//end register() @@ -50,12 +54,12 @@ public function process(File $phpcsFile, $stackPtr) $prev = $phpcsFile->findPrevious($findTokens, ($stackPtr - 1), null, true); - // Skip tokens that are the names of functions or classes + // Skip tokens that are the names of functions // within their definitions. For example: function myFunction... // "myFunction" is T_STRING but we should skip because it is not a // function or method *call*. $prevCode = $tokens[$prev]['code']; - if ($prevCode === T_FUNCTION || $prevCode === T_CLASS) { + if ($prevCode === T_FUNCTION) { return; } @@ -69,7 +73,7 @@ public function process(File $phpcsFile, $stackPtr) true ); - if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { + if ($openBracket === false || $tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { return; } @@ -86,10 +90,6 @@ public function process(File $phpcsFile, $stackPtr) ]; while (($nextSeparator = $phpcsFile->findNext($find, ($nextSeparator + 1), $closeBracket)) !== false) { - if (isset($tokens[$nextSeparator]['nested_parenthesis']) === false) { - continue; - } - if ($tokens[$nextSeparator]['code'] === T_OPEN_SHORT_ARRAY) { $nextSeparator = $tokens[$nextSeparator]['bracket_closer']; continue; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php index 7fb3b858..1b085853 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php @@ -132,31 +132,11 @@ public function process(File $phpcsFile, $stackPtr) 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) { + if ($startOfType !== $endOfType) { + // Multi-token type. $this->processUnionType( $phpcsFile, $startOfType, @@ -164,8 +144,11 @@ public function process(File $phpcsFile, $stackPtr) $error, $errorCode ); - } else if (isset($this->phpTypes[strtolower($type)]) === true) { - $this->processType($phpcsFile, $startOfType, $type, $error, $errorCode); + } else { + $type = $tokens[$startOfType]['content']; + if (isset($this->phpTypes[strtolower($type)]) === true) { + $this->processType($phpcsFile, $startOfType, $type, $error, $errorCode); + } } }//end if @@ -195,9 +178,8 @@ public function process(File $phpcsFile, $stackPtr) $error = 'PHP property type declarations must be lowercase; expected "%s" but found "%s"'; $errorCode = 'PropertyTypeFound'; - if (strpos($type, '&') !== false) { - // Intersection types don't support simple types. - } else if (strpos($type, '|') !== false) { + if ($props['type_token'] !== $props['type_end_token']) { + // Multi-token type. $this->processUnionType( $phpcsFile, $props['type_token'], @@ -227,9 +209,8 @@ public function process(File $phpcsFile, $stackPtr) $error = 'PHP return type declarations must be lowercase; expected "%s" but found "%s"'; $errorCode = 'ReturnTypeFound'; - if (strpos($returnType, '&') !== false) { - // Intersection types don't support simple types. - } else if (strpos($returnType, '|') !== false) { + if ($props['return_type_token'] !== $props['return_type_end_token']) { + // Multi-token type. $this->processUnionType( $phpcsFile, $props['return_type_token'], @@ -259,9 +240,8 @@ public function process(File $phpcsFile, $stackPtr) $error = 'PHP parameter type declarations must be lowercase; expected "%s" but found "%s"'; $errorCode = 'ParamTypeFound'; - if (strpos($typeHint, '&') !== false) { - // Intersection types don't support simple types. - } else if (strpos($typeHint, '|') !== false) { + if ($param['type_hint_token'] !== $param['type_hint_end_token']) { + // Multi-token type. $this->processUnionType( $phpcsFile, $param['type_hint_token'], @@ -279,7 +259,9 @@ public function process(File $phpcsFile, $stackPtr) /** - * Processes a union type declaration. + * Processes a multi-token type declaration. + * + * {@internal The method name is superseded by the reality, but changing it would be a BC-break.} * * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * @param int $typeDeclStart The position of the start of the type token. @@ -291,37 +273,51 @@ public function process(File $phpcsFile, $stackPtr) */ protected function processUnionType(File $phpcsFile, $typeDeclStart, $typeDeclEnd, $error, $errorCode) { - $tokens = $phpcsFile->getTokens(); - $current = $typeDeclStart; - - do { - $endOfType = $phpcsFile->findNext(T_TYPE_UNION, $current, $typeDeclEnd); - if ($endOfType === false) { - // This must be the last type in the union. - $endOfType = ($typeDeclEnd + 1); - } + $tokens = $phpcsFile->getTokens(); + $typeTokenCount = 0; + $typeStart = null; + $type = ''; - $hasNsSep = $phpcsFile->findNext(T_NS_SEPARATOR, $current, $endOfType); - if ($hasNsSep !== false) { - // Multi-token class based type. Ignore. - $current = ($endOfType + 1); + for ($i = $typeDeclStart; $i <= $typeDeclEnd; $i++) { + if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) { continue; } - // Type consisting of a single token. - $startOfType = $phpcsFile->findNext(Tokens::$emptyTokens, $current, $endOfType, true); - if ($startOfType === false) { - // Parse error. - return; + if ($tokens[$i]['code'] === T_TYPE_UNION + || $tokens[$i]['code'] === T_TYPE_INTERSECTION + || $tokens[$i]['code'] === T_TYPE_OPEN_PARENTHESIS + || $tokens[$i]['code'] === T_TYPE_CLOSE_PARENTHESIS + ) { + if ($typeTokenCount === 1 + && $type !== '' + && isset($this->phpTypes[strtolower($type)]) === true + ) { + $this->processType($phpcsFile, $typeStart, $type, $error, $errorCode); + } + + // Reset for the next type in the type string. + $typeTokenCount = 0; + $typeStart = null; + $type = ''; + + continue; } - $type = $tokens[$startOfType]['content']; - if (isset($this->phpTypes[strtolower($type)]) === true) { - $this->processType($phpcsFile, $startOfType, $type, $error, $errorCode); + if (isset($typeStart) === false) { + $typeStart = $i; } - $current = ($endOfType + 1); - } while ($current <= $typeDeclEnd); + ++$typeTokenCount; + $type .= $tokens[$i]['content']; + }//end for + + // Handle type at end of type string. + if ($typeTokenCount === 1 + && $type !== '' + && isset($this->phpTypes[strtolower($type)]) === true + ) { + $this->processType($phpcsFile, $typeStart, $type, $error, $errorCode); + } }//end processUnionType() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc index 6f418ca1..06ebca78 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc @@ -149,3 +149,6 @@ $var = [ ]; // phpcs:set Generic.Arrays.ArrayIndent indent 4 + +$array = [1, +]; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed index 1ea8dd1e..03f508db 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed @@ -150,3 +150,6 @@ $var = [ ]; // phpcs:set Generic.Arrays.ArrayIndent indent 4 + +$array = [1, +]; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc index 60c2ef96..6855f02c 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc @@ -3,14 +3,13 @@ $var = array(); $var = [1,2,3]; $var = array(1,2,3); echo $var[1]; -$foo = array($var[1],$var[2]); +$foo = ARRAY($var[1],$var[2]); $foo = array( 1, 2, 3 ); $var = array/*comment*/(1,2,3); -$var = array; function foo(array $array) {} @@ -26,3 +25,9 @@ array_map( static fn (array $value): array => array_filter($value), [] ); + +class Foo { + function array() {} +} + +$obj->array( 1, 2, 3 ); diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc.fixed index e37971f2..5e993068 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc.fixed @@ -10,7 +10,6 @@ $foo = [ 3 ]; $var = /*comment*/[1,2,3]; -$var = array; function foo(array $array) {} @@ -26,3 +25,9 @@ array_map( static fn (array $value): array => array_filter($value), [] ); + +class Foo { + function array() {} +} + +$obj->array( 1, 2, 3 ); diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.3.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.3.inc new file mode 100644 index 00000000..68020bdc --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.3.inc @@ -0,0 +1,7 @@ + 1, 9 => 1, ]; + case 'DisallowLongArraySyntaxUnitTest.3.inc': + return [ + 7 => 1, + ]; default: return []; }//end switch diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.inc index 464b0e3d..080dda93 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.inc @@ -1,7 +1,7 @@ " /> 3; $same++) { + + } + } +} + +for ($i = 0; $i < 20; $i++) { + for ($j = 0; $j < 5; $j += 2) { + for ($k = 0; $k > 3; $k++) { + + } + } +} + +for ($i = 0; $i < 20; $i++) { + for ($same = 0; $same < 5; $same += 2) { + for ($k = 0; $k > 3; $same++) { + + } + } +} + +for (; $i < 10; $i++) { + for ($j = 0;; $j++) { + if ($j > 5) { + break; + } + for (;; $k++) { + if ($k > 5) { + break; + } + } + } +} + +for (; $same < 10; $same++) { + for ($j = 0;; $same++) { + if ($j > 5) { + break; + } + for (;; $same++) { + if ($k > 5) { + break; + } + } + } +} + +for ($i = 0; $i < 20; $i++) : + for ($j = 0; $j < 5; $j += 2) : + endfor; +endfor; + +for ($same = 0; $same < 20; $same++) : + for ($j = 0; $j < 5; $same += 2) : + endfor; +endfor; + +// Sniff bails early when there is no incrementor in the third expression of the outer for loop. +for ($same = 0; $same < 10;) { + ++$same; + for ($j = 0; $j < 5; $same++) {} +} + +for ($i = 1, $same = 0; $i <= 10; $i++, $same++) { + for ($same = 0, $k = 0; $k < 5; $same++, $k++) {} +} + +for ($i = 20; $i > 0; $i--) { + for ($j = 5; $j > 0; $j -= 2) { + for ($k = 3; $k > 0; $k--) {} + } +} + +for ($same = 20; $same > 0; $same--) { + for ($j = 5; $j > 0; $same -= 2) { + for ($k = 3; $k > 0; $same--) {} + } +} + +for ($i = 0; $i < 20; $i++); + +for ($same = 0; $same < 20; $same++) { + for ($j = 0; $j < 20; $same++); +} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.2.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.2.inc new file mode 100644 index 00000000..2324427b --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.2.inc @@ -0,0 +1,8 @@ + 3; $i++) { - - } - } -} - -for ($i = 0; $i < 20; $i++) { - for ($j = 0; $j < 5; $j += 2) { - for ($k = 0; $k > 3; $k++) { - - } - } -} - -for ($i = 0; $i < 20; $i++) { - for ($j = 0; $j < 5; $j += 2) { - for ($k = 0; $k > 3; $j++) { - - } - } -} \ No newline at end of file diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php index b3f65f15..0060efe6 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/JumbledIncrementerUnitTest.php @@ -41,15 +41,30 @@ 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 => 2, - 4 => 1, - 20 => 1, - ]; + switch ($testFile) { + case 'JumbledIncrementerUnitTest.1.inc': + return [ + 3 => 2, + 4 => 1, + 20 => 1, + 40 => 2, + 41 => 1, + 58 => 1, + 69 => 1, + 79 => 2, + 80 => 1, + 87 => 1, + ]; + + default: + return []; + } }//end getWarningList() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.inc index ce458d84..27053c4d 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.inc @@ -173,3 +173,15 @@ echo match ($text) { 'foo' => 10 === $y, 10 === $y => 'bar', }; + +1 ?? $nullCoalescingShouldNotTriggerSniff; + +1 + 2 === $sniffBailsArithmeticToken; + +'string' . 'concat' === $sniffBailsStringConcatToken; + +1 != $value; +1 <> $value; +1 >= $value; +1 <= $value; +1 <=> $value; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php index 52fc370a..64a487d5 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/DisallowYodaConditionsUnitTest.php @@ -67,6 +67,11 @@ public function getErrorList() 167 => 1, 173 => 1, 174 => 1, + 183 => 1, + 184 => 1, + 185 => 1, + 186 => 1, + 187 => 1, ]; }//end getErrorList() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc index fb4a7380..739ba40a 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc @@ -272,3 +272,7 @@ function testFinally() } finally { } } + +if ($something) { + echo 'hello'; +} else /* comment */ if ($somethingElse) echo 'hi'; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed index d80a3265..9a89b0e3 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.inc.fixed @@ -307,3 +307,8 @@ function testFinally() } } } + +if ($something) { + echo 'hello'; +} else /* comment */ if ($somethingElse) { echo 'hi'; +} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js index 4d3b1e8a..ca6dae13 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js @@ -29,3 +29,7 @@ if ($("#myid").rotationDegrees()=='90') if ($("#myid").rotationDegrees()=='90') $foo = {'transform': 'rotate(90deg)'}; + +if (something) { + alert('hello'); +} else /* comment */ if (somethingElse) alert('hi'); diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js.fixed index 8f0c413e..d410cfb1 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.js.fixed @@ -37,3 +37,8 @@ if ($("#myid").rotationDegrees()=='90') { if ($("#myid").rotationDegrees()=='90') { $foo = {'transform': 'rotate(90deg)'}; } + +if (something) { + alert('hello'); +} else /* comment */ if (somethingElse) { alert('hi'); +} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index 44f1d747..5d42d112 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -78,6 +78,7 @@ public function getErrorList($testFile='') 242 => 1, 260 => 1, 269 => 1, + 278 => 1, ]; case 'InlineControlStructureUnitTest.js': @@ -90,6 +91,7 @@ public function getErrorList($testFile='') 21 => 1, 27 => 1, 30 => 1, + 35 => 1, ]; default: diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php index 824beae4..e035c208 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php @@ -52,6 +52,8 @@ protected function setUpPrerequisites() $cwd = getcwd(); file_put_contents($cwd.'/.eslintrc.json', self::ESLINT_CONFIG); + putenv('ESLINT_USE_FLAT_CONFIG=false'); + }//end setUpPrerequisites() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.1.inc similarity index 94% rename from vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc rename to vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.1.inc index 70ecd98a..a4b0a07f 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.1.inc @@ -93,3 +93,8 @@ $var = (int) $var1 + (bool) $var2; // phpcs:set Generic.Formatting.SpaceAfterCast ignoreNewlines false // phpcs:set Generic.Formatting.SpaceAfterCast spacing 1 + +$var = (boolean)/* comment */ $var2; + +$var = ( int )$spacesInsideParenthesis; +$var = ( int )$tabsInsideParenthesis; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.1.inc.fixed similarity index 94% rename from vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc.fixed rename to vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.1.inc.fixed index f9b2a592..fd2b920d 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.1.inc.fixed @@ -90,3 +90,8 @@ $var = (int) $var1 + (bool)$var2; // phpcs:set Generic.Formatting.SpaceAfterCast ignoreNewlines false // phpcs:set Generic.Formatting.SpaceAfterCast spacing 1 + +$var = (boolean)/* comment */ $var2; + +$var = ( int ) $spacesInsideParenthesis; +$var = ( int ) $tabsInsideParenthesis; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.2.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.2.inc new file mode 100644 index 00000000..7e947a26 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.2.inc @@ -0,0 +1,3 @@ + */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 4 => 1, - 5 => 1, - 8 => 1, - 9 => 1, - 12 => 1, - 13 => 1, - 16 => 1, - 17 => 1, - 20 => 1, - 21 => 1, - 24 => 1, - 25 => 1, - 28 => 1, - 29 => 1, - 32 => 1, - 33 => 1, - 36 => 1, - 37 => 1, - 40 => 1, - 41 => 1, - 44 => 1, - 45 => 1, - 51 => 1, - 53 => 1, - 55 => 1, - 58 => 1, - 64 => 1, - 72 => 1, - 73 => 1, - 75 => 1, - 76 => 1, - 78 => 1, - 82 => 1, - 84 => 1, - 85 => 1, - 86 => 1, - 88 => 1, - 93 => 1, - ]; + switch ($testFile) { + case 'SpaceAfterCastUnitTest.1.inc': + return [ + 4 => 1, + 5 => 1, + 8 => 1, + 9 => 1, + 12 => 1, + 13 => 1, + 16 => 1, + 17 => 1, + 20 => 1, + 21 => 1, + 24 => 1, + 25 => 1, + 28 => 1, + 29 => 1, + 32 => 1, + 33 => 1, + 36 => 1, + 37 => 1, + 40 => 1, + 41 => 1, + 44 => 1, + 45 => 1, + 51 => 1, + 53 => 1, + 55 => 1, + 58 => 1, + 64 => 1, + 72 => 1, + 73 => 1, + 75 => 1, + 76 => 1, + 78 => 1, + 82 => 1, + 84 => 1, + 85 => 1, + 86 => 1, + 88 => 1, + 93 => 1, + 97 => 1, + 99 => 1, + 100 => 1, + ]; + + default: + return []; + }//end switch }//end getErrorList() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.1.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.inc rename to vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.1.inc diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.1.inc.fixed similarity index 100% rename from vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.inc.fixed rename to vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.1.inc.fixed diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.2.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.2.inc new file mode 100644 index 00000000..2d6fa80a --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.2.inc @@ -0,0 +1,7 @@ + 2, 4 => 2, diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.1.inc similarity index 57% rename from vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc rename to vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.1.inc index 3fa33649..9360680c 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.1.inc @@ -37,3 +37,30 @@ myfunc(MY_CONST&$myvar); efg( true == &$b ); efg( true === &$b ); + +foo($a, bar(&$b)); +foo($a, array(&$b)); + +enum Foo {} +interface Foo {} +trait Foo {} + +$instance = new $var($a); +$instance = new MyClass($a); +$instance = new $var(&$a); +$instance = new MyClass(&$a); + +$anon = new class($a) {}; +$anon = new class(&$a) {}; + +class Foo extends Bar { + function myMethod() { + $a = new static($var); + $b = new self($var); + $c = new parent($var); + + $d = new static(&$var); + $e = new self(&$var); + $f = new parent(&$var); + } +} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.2.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.2.inc new file mode 100644 index 00000000..769c5d61 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.2.inc @@ -0,0 +1,7 @@ + */ - public function getErrorList() + public function getErrorList($testFile='CallTimePassByReferenceUnitTest.1.inc') { - return [ - 9 => 1, - 12 => 1, - 15 => 1, - 18 => 2, - 23 => 1, - 30 => 1, - ]; + switch ($testFile) { + case 'CallTimePassByReferenceUnitTest.1.inc': + return [ + 9 => 1, + 12 => 1, + 15 => 1, + 18 => 2, + 23 => 1, + 30 => 1, + 41 => 1, + 50 => 1, + 51 => 1, + 54 => 1, + 62 => 1, + 63 => 1, + 64 => 1, + ]; + + default: + return []; + }//end switch }//end getErrorList() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc index 6674970e..fb5b1fd5 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc @@ -125,6 +125,20 @@ enum TypedEnumConstants { public const sTRing | aRRaY | FaLSe FOURTH = 'fourth'; } +class DNFTypes { + const (Parent&Something)|Float CONST_NAME = 1.5; + + public readonly TRUE|(\A&B) $prop; + + function DNFParamTypes ( + null|(\Package\ClassName&\Package\Other_Class)|INT $DNFinMiddle, + (\Package\ClassName&\Package\Other_Class)|ARRAY $parensAtStart, + False|(\Package\ClassName&\Package\Other_Class) $parentAtEnd, + ) {} + + function DNFReturnTypes ($var): object|(Self&\Package\Other_Class)|sTRINg|false {} +} + // Intentional error, should be ignored by the sniff. interface PropertiesNotAllowed { public $notAllowed; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed index 59e4af83..10be06b0 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed @@ -125,6 +125,20 @@ enum TypedEnumConstants { public const string | array | false FOURTH = 'fourth'; } +class DNFTypes { + const (parent&Something)|float CONST_NAME = 1.5; + + public readonly true|(\A&B) $prop; + + function DNFParamTypes ( + null|(\Package\ClassName&\Package\Other_Class)|int $DNFinMiddle, + (\Package\ClassName&\Package\Other_Class)|array $parensAtStart, + false|(\Package\ClassName&\Package\Other_Class) $parentAtEnd, + ) {} + + function DNFReturnTypes ($var): object|(self&\Package\Other_Class)|string|false {} +} + // Intentional error, should be ignored by the sniff. interface PropertiesNotAllowed { public $notAllowed; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php index c5cfbb18..26219328 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php @@ -87,6 +87,12 @@ public function getErrorList() 123 => 2, 124 => 3, 125 => 3, + 129 => 2, + 131 => 1, + 134 => 1, + 135 => 1, + 136 => 1, + 139 => 2, ]; }//end getErrorList() @@ -103,7 +109,7 @@ public function getErrorList() public function getWarningList() { // Warning from getMemberProperties() about parse error. - return [130 => 1]; + return [144 => 1]; }//end getWarningList() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc index 4061aff5..bab866e0 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc @@ -1579,6 +1579,41 @@ foo(function ($foo) { ]; }); +// Issue #110. +echo match (1) { + 0 => match (2) { + 2 => match (3) { + 3 => 3, + default => -1, + }, + }, + 1 => match (2) { + 1 => match (3) { + 3 => 3, + default => -1, + }, + 2 => match (3) { + 3 => 3, + default => -1, + }, + }, +}; + +// Issue #437. +match (true) { + default => [ + 'unrelated' => '', + 'example' => array_filter( + array_map( + function () { + return null; + }, + [] + ) + ) + ] +}; + /* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */ ?> diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed index 7b5efea3..dbbfa71c 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed @@ -1579,6 +1579,41 @@ foo(function ($foo) { ]; }); +// Issue #110. +echo match (1) { + 0 => match (2) { + 2 => match (3) { + 3 => 3, + default => -1, + }, + }, + 1 => match (2) { + 1 => match (3) { + 3 => 3, + default => -1, + }, + 2 => match (3) { + 3 => 3, + default => -1, + }, + }, +}; + +// Issue #437. +match (true) { + default => [ + 'unrelated' => '', + 'example' => array_filter( + array_map( + function () { + return null; + }, + [] + ) + ) + ] +}; + /* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */ ?> diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc index e7253141..de344f9f 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc @@ -1579,6 +1579,41 @@ foo(function ($foo) { ]; }); +// Issue #110. +echo match (1) { + 0 => match (2) { + 2 => match (3) { + 3 => 3, + default => -1, + }, + }, + 1 => match (2) { + 1 => match (3) { + 3 => 3, + default => -1, + }, + 2 => match (3) { + 3 => 3, + default => -1, + }, + }, +}; + +// Issue #437. +match (true) { + default => [ + 'unrelated' => '', + 'example' => array_filter( + array_map( + function () { + return null; + }, + [] + ) + ) + ] +}; + /* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */ ?> diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed index 57caa291..3cf7fb61 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed @@ -1579,6 +1579,41 @@ foo(function ($foo) { ]; }); +// Issue #110. +echo match (1) { + 0 => match (2) { + 2 => match (3) { + 3 => 3, + default => -1, + }, + }, + 1 => match (2) { + 1 => match (3) { + 3 => 3, + default => -1, + }, + 2 => match (3) { + 3 => 3, + default => -1, + }, + }, +}; + +// Issue #437. +match (true) { + default => [ + 'unrelated' => '', + 'example' => array_filter( + array_map( + function () { + return null; + }, + [] + ) + ) + ] +}; + /* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */ ?> diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index 2533b434..bb1a5d0e 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -192,10 +192,10 @@ public function getErrorList($testFile='') 1527 => 1, 1529 => 1, 1530 => 1, - 1590 => 1, - 1591 => 1, - 1592 => 1, - 1593 => 1, + 1625 => 1, + 1626 => 1, + 1627 => 1, + 1628 => 1, ]; }//end getErrorList() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index 548565f1..1d0745b9 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -104,8 +104,9 @@ public function process(File $phpcsFile, $stackPtr) // and the opening parenthesis. // Unfinished closures are tokenized as T_FUNCTION however, and can be excluded // by checking for the scope_opener. + $methodProps = $phpcsFile->getMethodProperties($stackPtr); if ($tokens[$stackPtr]['code'] === T_FUNCTION - && (isset($tokens[$stackPtr]['scope_opener']) === true || $phpcsFile->getMethodProperties($stackPtr)['has_body'] === false) + && (isset($tokens[$stackPtr]['scope_opener']) === true || $methodProps['has_body'] === false) ) { if ($tokens[($openBracket - 1)]['content'] === $phpcsFile->eolChar) { $spaces = 'newline'; @@ -125,25 +126,27 @@ public function process(File $phpcsFile, $stackPtr) } // Must be no space before semicolon in abstract/interface methods. - if ($phpcsFile->getMethodProperties($stackPtr)['has_body'] === false) { + if ($methodProps['has_body'] === false) { $end = $phpcsFile->findNext(T_SEMICOLON, $closeBracket); - if ($tokens[($end - 1)]['content'] === $phpcsFile->eolChar) { - $spaces = 'newline'; - } else if ($tokens[($end - 1)]['code'] === T_WHITESPACE) { - $spaces = $tokens[($end - 1)]['length']; - } else { - $spaces = 0; - } + if ($end !== false) { + if ($tokens[($end - 1)]['content'] === $phpcsFile->eolChar) { + $spaces = 'newline'; + } else if ($tokens[($end - 1)]['code'] === T_WHITESPACE) { + $spaces = $tokens[($end - 1)]['length']; + } else { + $spaces = 0; + } - if ($spaces !== 0) { - $error = 'Expected 0 spaces before semicolon; %s found'; - $data = [$spaces]; - $fix = $phpcsFile->addFixableError($error, $end, 'SpaceBeforeSemicolon', $data); - if ($fix === true) { - $phpcsFile->fixer->replaceToken(($end - 1), ''); + if ($spaces !== 0) { + $error = 'Expected 0 spaces before semicolon; %s found'; + $data = [$spaces]; + $fix = $phpcsFile->addFixableError($error, $end, 'SpaceBeforeSemicolon', $data); + if ($fix === true) { + $phpcsFile->fixer->replaceToken(($end - 1), ''); + } } } - } + }//end if }//end if // Must be one space before and after USE keyword for closures. diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index dd395324..cb8e46d5 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -93,16 +93,19 @@ public function process(File $phpcsFile, $stackPtr) } // Check that the closing brace is on it's own line. - $lastContent = $phpcsFile->findPrevious( - [ - T_WHITESPACE, - T_INLINE_HTML, - T_OPEN_TAG, - ], - ($scopeEnd - 1), - $scopeStart, - true - ); + for ($lastContent = ($scopeEnd - 1); $lastContent > $scopeStart; $lastContent--) { + if ($tokens[$lastContent]['code'] === T_WHITESPACE || $tokens[$lastContent]['code'] === T_OPEN_TAG) { + continue; + } + + if ($tokens[$lastContent]['code'] === T_INLINE_HTML + && ltrim($tokens[$lastContent]['content']) === '' + ) { + continue; + } + + break; + } if ($tokens[$lastContent]['line'] === $tokens[$scopeEnd]['line']) { $error = 'Closing brace must be on a line by itself'; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.1.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc rename to vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.1.inc diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.1.inc.fixed similarity index 100% rename from vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed rename to vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.1.inc.fixed diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.2.inc b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.2.inc new file mode 100644 index 00000000..719f703b --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.2.inc @@ -0,0 +1,7 @@ + 1, 4 => 1, 5 => 1, @@ -108,8 +109,9 @@ public function getErrorList($testFile='') 483 => 1, 490 => 2, ]; - } else { - $errors = [ + + case 'FunctionDeclarationUnitTest.js': + return [ 3 => 1, 4 => 1, 5 => 1, @@ -121,9 +123,10 @@ public function getErrorList($testFile='') 41 => 1, 48 => 1, ]; - }//end if - return $errors; + default: + return []; + }//end switch }//end getErrorList() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc index 3f900679..a97aca76 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc @@ -162,3 +162,9 @@ enum Suits {} enum Cards { } + +?> + + +
+
+ + +
+
1, 160 => 1, 164 => 1, + 170 => 1, ]; }//end getErrorList() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc.fixed new file mode 100644 index 00000000..c6b827e7 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc.fixed @@ -0,0 +1,314 @@ +hello(); // error here + } + + function hello() // error here + { // no error here as brackets can be put anywhere in the pear standard + echo 'hello'; + } + + function hello2() + { + if (TRUE) { // error here + echo 'hello'; // no error here as its more than 4 spaces. + } else { + echo 'bye'; // error here + } + + while (TRUE) { + echo 'hello'; // error here + } + + do { // error here + echo 'hello'; // error here + } while (TRUE); + } + + function hello3() + { + switch ($hello) { + case 'hello': + break; + } + } + +} + +?> +
+
+
+validate()) {
+    $safe = $form->getSubmitValues();
+}
+?>
+
+open(); // error here + } + + public function open() + { + // Some inline stuff that shouldn't error + if (TRUE) echo 'hello'; + foreach ($tokens as $token) echo $token; + } + + /** + * This is a comment 1. + * This is a comment 2. + * This is a comment 3. + * This is a comment 4. + */ + public function close() + { + // All ok. + if (TRUE) { + if (TRUE) { + } else if (FALSE) { + foreach ($tokens as $token) { + switch ($token) { + case '1': + case '2': + if (true) { + if (false) { + if (false) { + if (false) { + echo 'hello'; + } + } + } + } + break; + case '5': + break; + } + do { + while (true) { + foreach ($tokens as $token) { + for ($i = 0; $i < $token; $i++) { + echo 'hello'; + } + } + } + } while (true); + } + } + } + } + + /* + This is another c style comment 1. + This is another c style comment 2. + This is another c style comment 3. + This is another c style comment 4. + This is another c style comment 5. + */ + + /* + * + * + * + */ + + /** + */ + + /* + This comment has a newline in it. + + */ + + public function read() + { + echo 'hello'; + + // no errors below. + $array = array( + 'this', + 'that' => array( + 'hello', + 'hello again' => array( + 'hello', + ), + ), + ); + } +} + +abstract class Test3 +{ + public function parse() + { + + foreach ($t as $ndx => $token) { + if (is_array($token)) { + echo 'here'; + } else { + $ts[] = array("token" => $token, "value" => ''); + + $last = count($ts) - 1; + + switch ($token) { + case '(': + + if ($last >= 3 && + $ts[0]['token'] != T_CLASS && + $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && + $ts[$last - 3]['token'] == T_VARIABLE ) { + + + if (true) { + echo 'hello'; + } + } + array_push($braces, $token); + break; + } + } + } + } +} + +function test() +{ + $o = << - + diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php index 22cf2abc..3325459a 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php @@ -314,7 +314,8 @@ public function processOpen(File $phpcsFile, $stackPtr) if ($checkingImplements === true && $multiLineImplements === true && ($tokens[($className - 1)]['code'] !== T_NS_SEPARATOR - || $tokens[($className - 2)]['code'] !== T_STRING) + || ($tokens[($className - 2)]['code'] !== T_STRING + && $tokens[($className - 2)]['code'] !== T_NAMESPACE)) ) { $prev = $phpcsFile->findPrevious( [ @@ -348,7 +349,10 @@ public function processOpen(File $phpcsFile, $stackPtr) $phpcsFile->fixer->addNewline($prev); $phpcsFile->fixer->endChangeset(); } - } else if ($tokens[$prev]['line'] !== ($tokens[$className]['line'] - 1)) { + } else if ((isset(Tokens::$commentTokens[$tokens[$prev]['code']]) === false + && $tokens[$prev]['line'] !== ($tokens[$className]['line'] - 1)) + || $tokens[$prev]['line'] === $tokens[$className]['line'] + ) { if ($keywordTokenType === T_EXTENDS) { $error = 'Only one interface may be specified per line in a multi-line extends declaration'; $fix = $phpcsFile->addFixableError($error, $className, 'ExtendsInterfaceSameLine'); @@ -397,9 +401,10 @@ public function processOpen(File $phpcsFile, $stackPtr) } }//end if } else if ($tokens[($className - 1)]['code'] !== T_NS_SEPARATOR - || $tokens[($className - 2)]['code'] !== T_STRING + || ($tokens[($className - 2)]['code'] !== T_STRING + && $tokens[($className - 2)]['code'] !== T_NAMESPACE) ) { - // Not part of a longer fully qualified class name. + // Not part of a longer fully qualified or namespace relative class name. if ($tokens[($className - 1)]['code'] === T_COMMA || ($tokens[($className - 1)]['code'] === T_NS_SEPARATOR && $tokens[($className - 2)]['code'] === T_COMMA) diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php index 1882fd97..39c69c8b 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php @@ -152,10 +152,10 @@ public function process(File $phpcsFile, $stackPtr) } } while ($next !== false); - // Remove closing curly,semi-colon and any whitespace between last child and closing curly. + // Remove closing curly, semicolon and any whitespace between last child and closing curly. $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($closingCurly + 1), null, true); if ($next === false || $tokens[$next]['code'] !== T_SEMICOLON) { - // Parse error, forgotten semi-colon. + // Parse error, forgotten semicolon. $next = $closingCurly; } diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc index 303846b7..144eef8f 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc @@ -282,3 +282,37 @@ readonly class ReadonlyClassWithComment { } + +// Safeguard against fixer conflict when there are namespace relative interface names in extends. +interface FooBar extends namespace\BarFoo +{ +} + +// Safeguard against fixer conflict when there are namespace relative interface names in a multi-line implements. +class BarFoo implements + namespace\BarFoo +{ +} + +// Safeguard that the sniff ignores comments between interface names in a multiline implements. +class ClassWithMultiLineImplementsAndIgnoreAnnotation implements + SomeInterface, + // phpcs:disable Stnd.Cat.Sniff -- For reasons. + + \AnotherInterface +{ +} + +class ClassWithMultiLineImplementsAndComment implements + SomeInterface, + // Comment. + +AnotherInterface +{ +} + +class ClassWithMultiLineImplementsAndCommentOnSameLineAsInterfaceName implements + SomeInterface, + /* Comment. */ AnotherInterface +{ +} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed index 78dbbbb4..84123ca5 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.inc.fixed @@ -270,3 +270,38 @@ readonly class ReadonlyClassWithComment { } + +// Safeguard against fixer conflict when there are namespace relative interface names in extends. +interface FooBar extends namespace\BarFoo +{ +} + +// Safeguard against fixer conflict when there are namespace relative interface names in a multi-line implements. +class BarFoo implements + namespace\BarFoo +{ +} + +// Safeguard that the sniff ignores comments between interface names in a multiline implements. +class ClassWithMultiLineImplementsAndIgnoreAnnotation implements + SomeInterface, + // phpcs:disable Stnd.Cat.Sniff -- For reasons. + + \AnotherInterface +{ +} + +class ClassWithMultiLineImplementsAndComment implements + SomeInterface, + // Comment. + + AnotherInterface +{ +} + +class ClassWithMultiLineImplementsAndCommentOnSameLineAsInterfaceName implements + SomeInterface, + /* Comment. */ + AnotherInterface +{ +} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php b/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php index b74d811c..ef97be46 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Classes/ClassDeclarationUnitTest.php @@ -76,6 +76,8 @@ public function getErrorList() 273 => 1, 276 => 1, 282 => 1, + 310 => 1, + 316 => 1, ]; }//end getErrorList() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Docs/WhiteSpace/FunctionClosingBraceSpaceStandard.xml b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Docs/WhiteSpace/FunctionClosingBraceSpaceStandard.xml new file mode 100644 index 00000000..ccbdfa21 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Docs/WhiteSpace/FunctionClosingBraceSpaceStandard.xml @@ -0,0 +1,73 @@ + + + + + + + { + +} +]]> + + + {} +]]> + + + + + + + + + { + } + +} +]]> + + + {} + +} +]]> + + + + + + + + + { + } + +} +]]> + + + { + + } + +} +]]> + + + diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php index d51431bf..9030468b 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -73,7 +73,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - // There is a semi-colon, so now find the last token in the statement. + // There is a semicolon, so now find the last token in the statement. $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($endOfThisStatement - 1), null, true); $found = $tokens[($endOfThisStatement - 1)]['length']; if ($tokens[$prevNonEmpty]['line'] !== $tokens[$endOfThisStatement]['line']) { diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php index 407d3dae..ff1cd830 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php @@ -182,7 +182,7 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) /** * Returns the declaration names for classes/interfaces/functions with a namespace. * - * @param array $tokens Token stack for this file + * @param array $tokens Token stack for this file. * @param int $stackPtr The position where the namespace building will start. * * @return string diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php index afc7ac07..44bd4388 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -24,10 +24,11 @@ class ClosingDeclarationCommentSniff implements Sniff public function register() { return [ - T_FUNCTION, T_CLASS, - T_INTERFACE, T_ENUM, + T_FUNCTION, + T_INTERFACE, + T_TRAIT, ]; }//end register() @@ -72,6 +73,8 @@ public function process(File $phpcsFile, $stackPtr) $comment = '//end class'; } else if ($tokens[$stackPtr]['code'] === T_INTERFACE) { $comment = '//end interface'; + } else if ($tokens[$stackPtr]['code'] === T_TRAIT) { + $comment = '//end trait'; } else { $comment = '//end enum'; }//end if @@ -85,15 +88,10 @@ public function process(File $phpcsFile, $stackPtr) $closingBracket = $tokens[$stackPtr]['scope_closer']; - if ($closingBracket === null) { - // Possible inline structure. Other tests will handle it. - return; - } - $data = [$comment]; if (isset($tokens[($closingBracket + 1)]) === false || $tokens[($closingBracket + 1)]['code'] !== T_COMMENT) { $next = $phpcsFile->findNext(T_WHITESPACE, ($closingBracket + 1), null, true); - if (rtrim($tokens[$next]['content']) === $comment) { + if ($next !== false && rtrim($tokens[$next]['content']) === $comment) { // The comment isn't really missing; it is just in the wrong place. $fix = $phpcsFile->addFixableError('Expected %s directly after closing brace', $closingBracket, 'Misplaced', $data); if ($fix === true) { diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php index 439fc38a..7c06e429 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php @@ -156,7 +156,7 @@ public function process(File $phpcsFile, $stackPtr) } if ($startCondition['code'] === T_MATCH) { - // Move the stackPtr to after the semi-colon/comma if there is one. + // Move the stackPtr to after the semicolon/comma if there is one. $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); if ($nextToken !== false && ($tokens[$nextToken]['code'] === T_SEMICOLON diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php index e5e4e66f..38313e16 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php @@ -76,8 +76,8 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $openingBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr); - if ($openingBracket === false) { - $error = 'Possible parse error: no opening parenthesis for FOR keyword'; + if ($openingBracket === false || isset($tokens[$openingBracket]['parenthesis_closer']) === false) { + $error = 'Possible parse error: no opening/closing parenthesis for FOR keyword'; $phpcsFile->addWarning($error, $stackPtr, 'NoOpenBracket'); return; } diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php index 52bff6cc..652391f1 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php @@ -47,7 +47,7 @@ public function register() * the token was found. * * @return int - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jslint.js could not be run + * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jslint.js could not be run. */ public function process(File $phpcsFile, $stackPtr) { diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php index 89b704fe..031b2e39 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php @@ -67,7 +67,7 @@ public function process(File $phpcsFile, $stackPtr) // provide useful error reporting. if ($retval === 2 || $retval === 4) { if (is_array($output) === true) { - $msg = join('\n', $output); + $msg = implode('\n', $output); } throw new RuntimeException("Failed invoking JavaScript Lint, retval was [$retval], output was [$msg]"); diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php index c167d024..ec516a99 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php @@ -51,7 +51,7 @@ public function process(File $phpcsFile, $stackPtr) $end = $phpcsFile->findNext([T_SEMICOLON, T_CLOSE_TAG], $stackPtr, null, false); - // If the token before the semi-colon is not a closing parenthesis, then we are not concerned. + // If the token before the semicolon is not a closing parenthesis, then we are not concerned. $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($end - 1), null, true); if ($tokens[$prev]['code'] !== T_CLOSE_PARENTHESIS) { $phpcsFile->recordMetric($stackPtr, 'Brackets around echoed strings', 'no'); diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php index 97007fc4..2a87978a 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php @@ -238,7 +238,8 @@ public function process(File $phpcsFile, $stackPtr) ) { // Throw an error for assignments only if enabled using the sniff property // because other standards allow multiple spaces to align assignments. - if ($tokens[($stackPtr - 2)]['line'] !== $tokens[$stackPtr]['line']) { + $prevNonWhitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); + if ($tokens[$prevNonWhitespace]['line'] !== $tokens[$stackPtr]['line']) { $found = 'newline'; } else { $found = $tokens[($stackPtr - 1)]['length']; @@ -253,20 +254,29 @@ public function process(File $phpcsFile, $stackPtr) $operator, $found, ]; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBefore', $data); - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); - if ($found === 'newline') { - $i = ($stackPtr - 2); - while ($tokens[$i]['code'] === T_WHITESPACE) { - $phpcsFile->fixer->replaceToken($i, ''); - $i--; + + if (isset(Tokens::$commentTokens[$tokens[$prevNonWhitespace]['code']]) === true) { + // Throw a non-fixable error if the token on the previous line is a comment token, + // as in that case it's not for the sniff to decide where the comment should be moved to + // and it would get us into unfixable situations as the new line char is included + // in the contents of the comment token. + $phpcsFile->addError($error, $stackPtr, 'SpacingBefore', $data); + } else { + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBefore', $data); + if ($fix === true) { + $phpcsFile->fixer->beginChangeset(); + if ($found === 'newline') { + $i = ($stackPtr - 2); + while ($tokens[$i]['code'] === T_WHITESPACE) { + $phpcsFile->fixer->replaceToken($i, ''); + $i--; + } } - } - $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' '); - $phpcsFile->fixer->endChangeset(); - } + $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' '); + $phpcsFile->fixer->endChangeset(); + } + }//end if }//end if }//end if diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php index e10c5cee..dbf719d2 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php @@ -59,7 +59,7 @@ public function process(File $phpcsFile, $stackPtr) $nonSpace = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 2), null, true); - // Detect whether this is a semi-colon for a condition in a `for()` control structure. + // Detect whether this is a semicolon for a condition in a `for()` control structure. $forCondition = false; if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { $nestedParens = $tokens[$stackPtr]['nested_parenthesis']; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.1.inc similarity index 58% rename from vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc rename to vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.1.inc index 1a57149b..560370bf 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.1.inc @@ -84,3 +84,41 @@ enum MissingClosingComment { enum HasClosingComment { }//end enum + +function misplacedClosingCommentWhitespace() { +} //end misplacedClosingCommentWhitespace() + +function misplacedClosingCommentMultipleNewlines() { +} + + +//end misplacedClosingCommentMultipleNewlines() + +function missingClosingComment() { +} + +function commentHasMoreIndentationThanFunction() { +} + //end commentHasMoreIndentationThanFunction() + +class Foo { + function commentHasLessIndentationThanFunction() { + } + //end commentHasLessIndentationThanFunction() + + function misplacedClosingCommentWithIndentation() { + } + //end misplacedClosingCommentWithIndentation() +}//end class + +// Anonymous classes don't need end comments. +$anon = new class {}; + +// Arrow functions don't need end comments. +$arrow = fn($a) => $a; + +trait TestTrait { +}//end trait + +trait TestTrait { +} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.1.inc.fixed similarity index 59% rename from vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed rename to vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.1.inc.fixed index 4515c41a..8c690145 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.1.inc.fixed @@ -83,3 +83,35 @@ enum MissingClosingComment { enum HasClosingComment { }//end enum + +function misplacedClosingCommentWhitespace() { +}//end misplacedClosingCommentWhitespace() + +function misplacedClosingCommentMultipleNewlines() { +}//end misplacedClosingCommentMultipleNewlines() + +function missingClosingComment() { +}//end missingClosingComment() + +function commentHasMoreIndentationThanFunction() { +}//end commentHasMoreIndentationThanFunction() + +class Foo { + function commentHasLessIndentationThanFunction() { + }//end commentHasLessIndentationThanFunction() + + function misplacedClosingCommentWithIndentation() { + }//end misplacedClosingCommentWithIndentation() +}//end class + +// Anonymous classes don't need end comments. +$anon = new class {}; + +// Arrow functions don't need end comments. +$arrow = fn($a) => $a; + +trait TestTrait { +}//end trait + +trait TestTrait { +}//end trait diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.2.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.2.inc new file mode 100644 index 00000000..25913dd8 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.2.inc @@ -0,0 +1,7 @@ + */ - public function getErrorList() + public function getErrorList($testFile='') { - return [ - 13 => 1, - 17 => 1, - 31 => 1, - 41 => 1, - 59 => 1, - 63 => 1, - 67 => 1, - 79 => 1, - 83 => 1, - ]; + switch ($testFile) { + case 'ClosingDeclarationCommentUnitTest.1.inc': + return [ + 13 => 1, + 17 => 1, + 31 => 1, + 41 => 1, + 59 => 1, + 63 => 1, + 67 => 1, + 79 => 1, + 83 => 1, + 89 => 1, + 92 => 1, + 98 => 1, + 101 => 1, + 106 => 1, + 110 => 1, + 124 => 1, + ]; + + case 'ClosingDeclarationCommentUnitTest.4.inc': + return [8 => 1]; + + case 'ClosingDeclarationCommentUnitTest.5.inc': + return [11 => 1]; + + default: + return []; + }//end switch }//end getErrorList() @@ -51,11 +72,23 @@ 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 [71 => 1]; + switch ($testFile) { + case 'ClosingDeclarationCommentUnitTest.1.inc': + return [71 => 1]; + + case 'ClosingDeclarationCommentUnitTest.2.inc': + case 'ClosingDeclarationCommentUnitTest.3.inc': + return [7 => 1]; + + default: + return []; + } }//end getWarningList() diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.inc similarity index 95% rename from vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc rename to vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.inc index 5022e74c..d10bd980 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.inc @@ -111,7 +111,7 @@ for ( // phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 0 // phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 0 -// Test with semi-colon not belonging to for. +// Test with semicolon not belonging to for. for ($i = function() { return $this->i ; }; $i < function() { return $this->max; }; $i++) {} for ($i = function() { return $this->i; }; $i < function() { return $this->max; } ; $i++) {} @@ -124,6 +124,3 @@ for ( // body here } // phpcs:set Squiz.ControlStructures.ForLoopDeclaration ignoreNewlines false - -// This test has to be the last one in the file! Intentional parse error check. -for diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.inc.fixed similarity index 95% rename from vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc.fixed rename to vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.inc.fixed index 6a1e7634..85214c03 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.inc.fixed @@ -77,7 +77,7 @@ for ( $i = 0; $i < 10; $i++ ) {} // phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 0 // phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 0 -// Test with semi-colon not belonging to for. +// Test with semicolon not belonging to for. for ($i = function() { return $this->i ; }; $i < function() { return $this->max; }; $i++) {} for ($i = function() { return $this->i; }; $i < function() { return $this->max; }; $i++) {} @@ -90,6 +90,3 @@ for ( // body here } // phpcs:set Squiz.ControlStructures.ForLoopDeclaration ignoreNewlines false - -// This test has to be the last one in the file! Intentional parse error check. -for diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.2.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.2.inc new file mode 100644 index 00000000..a327cced --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.2.inc @@ -0,0 +1,6 @@ + 2, 11 => 2, @@ -121,8 +121,9 @@ public function getErrorList($testFile='') public function getWarningList($testFile='') { switch ($testFile) { - case 'ForLoopDeclarationUnitTest.inc': - return [129 => 1]; + case 'ForLoopDeclarationUnitTest.2.inc': + case 'ForLoopDeclarationUnitTest.3.inc': + return [6 => 1]; case 'ForLoopDeclarationUnitTest.js': return [125 => 1]; diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc index 765e7ab7..29acf308 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc @@ -483,5 +483,28 @@ match ($a) { default => -3, }; -/* Intentional parse error. This has to be the last test in the file. */ -$a = 10 + +$foo = $var + ? 10 + : true; + +// Safeguard that a non-fixable error is thrown when there is a new line before the operator, +// but the last non-whitespace token before the operator is a comment token. +$foo = $var // Comment + ? false /* Comment */ + : true; + +$foo = $var // phpcs: ignore Stnd.Cat.Sniff -- for reasons. + + + ? $something /** + * Don't ask, but someone might have a docblock between the lines. It's valid PHP after all. + */ + + + : true; + +// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreNewlines true +$foo = $var // Comment + ? false // Comment + : true; +// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreNewlines false diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc.fixed index ada77fa8..5c94e365 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc.fixed @@ -477,5 +477,26 @@ match ($a) { default => -3, }; -/* Intentional parse error. This has to be the last test in the file. */ -$a = 10 + +$foo = $var ? 10 : true; + +// Safeguard that a non-fixable error is thrown when there is a new line before the operator, +// but the last non-whitespace token before the operator is a comment token. +$foo = $var // Comment + ? false /* Comment */ + : true; + +$foo = $var // phpcs: ignore Stnd.Cat.Sniff -- for reasons. + + + ? $something /** + * Don't ask, but someone might have a docblock between the lines. It's valid PHP after all. + */ + + + : true; + +// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreNewlines true +$foo = $var // Comment + ? false // Comment + : true; +// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreNewlines false diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.3.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.3.inc new file mode 100644 index 00000000..8d6cf19e --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.3.inc @@ -0,0 +1,6 @@ + 2, 266 => 2, 271 => 2, + 487 => 1, + 488 => 1, + 493 => 1, + 494 => 1, + 499 => 1, + 504 => 1, ]; case 'OperatorSpacingUnitTest.js': diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc index 49eaa2b6..1d3ccebc 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc @@ -77,7 +77,7 @@ class MyOtherClass $varQ = 'string', $varR = 123; - // Intentionally missing a semi-colon for testing. + // Intentionally missing a semicolon for testing. public $varS, $varT diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed index 4c116c76..d4e8a39e 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.1.inc.fixed @@ -72,7 +72,7 @@ class MyOtherClass $varQ = 'string', $varR = 123; - // Intentionally missing a semi-colon for testing. + // Intentionally missing a semicolon for testing. public $varS, $varT diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc index 393f4845..60f87e5b 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc @@ -18,14 +18,14 @@ $sum = $a /* + $b + $c */ ; /* - * Test that the sniff does *not* throw incorrect errors for semi-colons in + * Test that the sniff does *not* throw incorrect errors for semicolons in * "empty" parts of a `for` control structure. */ for ($i = 1; ; $i++) {} for ( ; $ptr >= 0; $ptr-- ) {} for ( ; ; ) {} -// But it should when the semi-colon in a `for` follows a comment (but shouldn't move the semi-colon). +// But it should when the semicolon in a `for` follows a comment (but shouldn't move the semicolon). for ( /* Deliberately left empty. */ ; $ptr >= 0; $ptr-- ) {} for ( $i = 1 ; /* Deliberately left empty. */ ; $i++ ) {} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc.fixed b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc.fixed index 0d06324d..b4dc0f13 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc.fixed +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc.fixed @@ -18,14 +18,14 @@ $sum = $a; /* + $b + $c */ /* - * Test that the sniff does *not* throw incorrect errors for semi-colons in + * Test that the sniff does *not* throw incorrect errors for semicolons in * "empty" parts of a `for` control structure. */ for ($i = 1; ; $i++) {} for ( ; $ptr >= 0; $ptr-- ) {} for ( ; ; ) {} -// But it should when the semi-colon in a `for` follows a comment (but shouldn't move the semi-colon). +// But it should when the semicolon in a `for` follows a comment (but shouldn't move the semicolon). for ( /* Deliberately left empty. */; $ptr >= 0; $ptr-- ) {} for ( $i = 1; /* Deliberately left empty. */; $i++ ) {} diff --git a/vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php b/vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php index 5470ae4b..454f665a 100644 --- a/vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php +++ b/vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php @@ -69,7 +69,7 @@ public function process(File $phpcsFile, $stackPtr) // provide useful error reporting. if (is_numeric($exitCode) === true && $exitCode > 0) { if (is_array($output) === true) { - $msg = join('\n', $output); + $msg = implode('\n', $output); } throw new RuntimeException("Failed invoking ZendCodeAnalyzer, exitcode was [$exitCode], retval was [$retval], output was [$msg]"); diff --git a/vendor/squizlabs/php_codesniffer/src/Tokenizers/CSS.php b/vendor/squizlabs/php_codesniffer/src/Tokenizers/CSS.php index d3f71b37..36631ddc 100644 --- a/vendor/squizlabs/php_codesniffer/src/Tokenizers/CSS.php +++ b/vendor/squizlabs/php_codesniffer/src/Tokenizers/CSS.php @@ -22,7 +22,7 @@ class CSS extends PHP * * Pre-checks the content to see if it looks minified. * - * @param string $content The content to tokenize, + * @param string $content The content to tokenize. * @param \PHP_CodeSniffer\Config $config The config data for the run. * @param string $eolChar The EOL char used in the content. * diff --git a/vendor/squizlabs/php_codesniffer/src/Tokenizers/Comment.php b/vendor/squizlabs/php_codesniffer/src/Tokenizers/Comment.php index 335e296c..b7c6e374 100644 --- a/vendor/squizlabs/php_codesniffer/src/Tokenizers/Comment.php +++ b/vendor/squizlabs/php_codesniffer/src/Tokenizers/Comment.php @@ -25,7 +25,7 @@ class Comment * @param string $eolChar The EOL character to use for splitting strings. * @param int $stackPtr The position of the first token in the file. * - * @return array + * @return array>> */ public function tokenizeString($string, $eolChar, $stackPtr) { @@ -41,9 +41,16 @@ public function tokenizeString($string, $eolChar, $stackPtr) extra star when they are used for function and class comments. */ - $char = ($numChars - strlen(ltrim($string, '/*'))); - $openTag = substr($string, 0, $char); - $string = ltrim($string, '/*'); + $char = ($numChars - strlen(ltrim($string, '/*'))); + $lastChars = substr($string, -2); + if ($char === $numChars && $lastChars === '*/') { + // Edge case: docblock without whitespace or contents. + $openTag = substr($string, 0, -2); + $string = $lastChars; + } else { + $openTag = substr($string, 0, $char); + $string = ltrim($string, '/*'); + } $tokens[$stackPtr] = [ 'content' => $openTag, @@ -74,6 +81,7 @@ public function tokenizeString($string, $eolChar, $stackPtr) ]; if ($closeTag['content'] === false) { + // In PHP < 8.0 substr() can return `false` instead of always returning a string. $closeTag['content'] = ''; } @@ -171,7 +179,7 @@ public function tokenizeString($string, $eolChar, $stackPtr) * @param int $start The position in the string to start processing. * @param int $end The position in the string to end processing. * - * @return array + * @return array> */ private function processLine($string, $eolChar, $start, $end) { @@ -246,7 +254,7 @@ private function processLine($string, $eolChar, $start, $end) * @param int $start The position in the string to start processing. * @param int $end The position in the string to end processing. * - * @return array|null + * @return array|null */ private function collectWhitespace($string, $start, $end) { @@ -263,14 +271,12 @@ private function collectWhitespace($string, $start, $end) return null; } - $token = [ + return [ 'content' => $space, 'code' => T_DOC_COMMENT_WHITESPACE, 'type' => 'T_DOC_COMMENT_WHITESPACE', ]; - return $token; - }//end collectWhitespace() diff --git a/vendor/squizlabs/php_codesniffer/src/Tokenizers/JS.php b/vendor/squizlabs/php_codesniffer/src/Tokenizers/JS.php index cb7bd3c1..3d1162eb 100644 --- a/vendor/squizlabs/php_codesniffer/src/Tokenizers/JS.php +++ b/vendor/squizlabs/php_codesniffer/src/Tokenizers/JS.php @@ -251,7 +251,7 @@ class JS extends Tokenizer * * Pre-checks the content to see if it looks minified. * - * @param string $content The content to tokenize, + * @param string $content The content to tokenize. * @param \PHP_CodeSniffer\Config $config The config data for the run. * @param string $eolChar The EOL char used in the content. * diff --git a/vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php b/vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php index 6e3ebdb6..a773ddfa 100644 --- a/vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php +++ b/vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php @@ -464,6 +464,8 @@ class PHP extends Tokenizer T_CLOSE_SHORT_ARRAY => 1, T_TYPE_UNION => 1, T_TYPE_INTERSECTION => 1, + T_TYPE_OPEN_PARENTHESIS => 1, + T_TYPE_CLOSE_PARENTHESIS => 1, ]; /** @@ -747,6 +749,9 @@ protected function tokenize($string) /* Special case for `static` used as a function name, i.e. `static()`. + + Note: this may incorrectly change the static keyword directly before a DNF property type. + If so, this will be caught and corrected for in the additional processing. */ if ($tokenIsArray === true @@ -781,7 +786,7 @@ protected function tokenize($string) if ($tokenIsArray === true && ($token[0] === T_DOC_COMMENT - || ($token[0] === T_COMMENT && strpos($token[1], '/**') === 0)) + || ($token[0] === T_COMMENT && strpos($token[1], '/**') === 0 && $token[1] !== '/**/')) ) { $commentTokens = $commentTokenizer->tokenizeString($token[1], $this->eolChar, $newStackPtr); foreach ($commentTokens as $commentToken) { @@ -2597,7 +2602,9 @@ protected function processAdditional() $this->createAttributesNestingMap(); - $numTokens = count($this->tokens); + $numTokens = count($this->tokens); + $lastSeenTypeToken = $numTokens; + for ($i = ($numTokens - 1); $i >= 0; $i--) { // Check for any unset scope conditions due to alternate IF/ENDIF syntax. if (isset($this->tokens[$i]['scope_opener']) === true @@ -2712,19 +2719,23 @@ protected function processAdditional() if (isset($this->tokens[$x]) === true && $this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) { $ignore = Tokens::$emptyTokens; $ignore += [ - T_ARRAY => T_ARRAY, - T_CALLABLE => T_CALLABLE, - T_COLON => T_COLON, - T_NAMESPACE => T_NAMESPACE, - T_NS_SEPARATOR => T_NS_SEPARATOR, - T_NULL => T_NULL, - T_NULLABLE => T_NULLABLE, - T_PARENT => T_PARENT, - T_SELF => T_SELF, - T_STATIC => T_STATIC, - T_STRING => T_STRING, - T_TYPE_UNION => T_TYPE_UNION, - T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, + T_ARRAY => T_ARRAY, + T_CALLABLE => T_CALLABLE, + T_COLON => T_COLON, + T_NAMESPACE => T_NAMESPACE, + T_NS_SEPARATOR => T_NS_SEPARATOR, + T_NULL => T_NULL, + T_TRUE => T_TRUE, + T_FALSE => T_FALSE, + T_NULLABLE => T_NULLABLE, + T_PARENT => T_PARENT, + T_SELF => T_SELF, + T_STATIC => T_STATIC, + T_STRING => T_STRING, + T_TYPE_UNION => T_TYPE_UNION, + T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, + T_TYPE_OPEN_PARENTHESIS => T_TYPE_OPEN_PARENTHESIS, + T_TYPE_CLOSE_PARENTHESIS => T_TYPE_CLOSE_PARENTHESIS, ]; $closer = $this->tokens[$x]['parenthesis_closer']; @@ -3027,10 +3038,20 @@ protected function processAdditional() continue; } else if ($this->tokens[$i]['code'] === T_BITWISE_OR || $this->tokens[$i]['code'] === T_BITWISE_AND + || $this->tokens[$i]['code'] === T_CLOSE_PARENTHESIS ) { + if ($lastSeenTypeToken < $i) { + // We've already examined this code to check if it is a type declaration and concluded it wasn't. + // No need to do it again. + continue; + } + /* Convert "|" to T_TYPE_UNION or leave as T_BITWISE_OR. Convert "&" to T_TYPE_INTERSECTION or leave as T_BITWISE_AND. + Convert "(" and ")" to T_TYPE_(OPEN|CLOSE)_PARENTHESIS or leave as T_(OPEN|CLOSE)_PARENTHESIS. + + All type related tokens will be converted in one go as soon as this section is hit. */ $allowed = [ @@ -3046,8 +3067,8 @@ protected function processAdditional() T_NS_SEPARATOR => T_NS_SEPARATOR, ]; - $suspectedType = null; - $typeTokenCount = 0; + $suspectedType = null; + $typeTokenCountAfter = 0; for ($x = ($i + 1); $x < $numTokens; $x++) { if (isset(Tokens::$emptyTokens[$this->tokens[$x]['code']]) === true) { @@ -3055,11 +3076,13 @@ protected function processAdditional() } if (isset($allowed[$this->tokens[$x]['code']]) === true) { - ++$typeTokenCount; + ++$typeTokenCountAfter; continue; } - if ($typeTokenCount > 0 + if (($typeTokenCountAfter > 0 + || ($this->tokens[$i]['code'] === T_CLOSE_PARENTHESIS + && isset($this->tokens[$i]['parenthesis_owner']) === false)) && ($this->tokens[$x]['code'] === T_BITWISE_AND || $this->tokens[$x]['code'] === T_ELLIPSIS) ) { @@ -3090,6 +3113,7 @@ protected function processAdditional() && $this->tokens[$this->tokens[$x]['scope_condition']]['code'] === T_FUNCTION ) { $suspectedType = 'return'; + break; } if ($this->tokens[$x]['code'] === T_EQUAL) { @@ -3101,8 +3125,12 @@ protected function processAdditional() break; }//end for - if ($typeTokenCount === 0 || isset($suspectedType) === false) { - // Definitely not a union or intersection type, move on. + if (($typeTokenCountAfter === 0 + && ($this->tokens[$i]['code'] !== T_CLOSE_PARENTHESIS + || isset($this->tokens[$i]['parenthesis_owner']) === true)) + || isset($suspectedType) === false + ) { + // Definitely not a union, intersection or DNF type, move on. continue; } @@ -3110,22 +3138,79 @@ protected function processAdditional() unset($allowed[T_STATIC]); } - $typeTokenCount = 0; - $typeOperators = [$i]; - $confirmed = false; + $typeTokenCountBefore = 0; + $typeOperators = [$i]; + $parenthesesCount = 0; + $confirmed = false; + $maybeNullable = null; + + if ($this->tokens[$i]['code'] === T_OPEN_PARENTHESIS || $this->tokens[$i]['code'] === T_CLOSE_PARENTHESIS) { + ++$parenthesesCount; + } for ($x = ($i - 1); $x >= 0; $x--) { if (isset(Tokens::$emptyTokens[$this->tokens[$x]['code']]) === true) { continue; } + if ($suspectedType === 'property or parameter' + && $this->tokens[$x]['code'] === T_STRING + && strtolower($this->tokens[$x]['content']) === 'static' + ) { + // Static keyword followed directly by an open parenthesis for a DNF type. + // This token should be T_STATIC and was incorrectly identified as a function call before. + $this->tokens[$x]['code'] = T_STATIC; + $this->tokens[$x]['type'] = 'T_STATIC'; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $line = $this->tokens[$x]['line']; + echo "\t* token $x on line $line changed back from T_STRING to T_STATIC".PHP_EOL; + } + } + + if ($suspectedType === 'property or parameter' + && $this->tokens[$x]['code'] === T_OPEN_PARENTHESIS + ) { + // We need to prevent the open parenthesis for a function/fn declaration from being retokenized + // to T_TYPE_OPEN_PARENTHESIS if this is the first parameter in the declaration. + if (isset($this->tokens[$x]['parenthesis_owner']) === true + && $this->tokens[$this->tokens[$x]['parenthesis_owner']]['code'] === T_FUNCTION + ) { + $confirmed = true; + break; + } else { + // This may still be an arrow function which hasn't been handled yet. + for ($y = ($x - 1); $y > 0; $y--) { + if (isset(Tokens::$emptyTokens[$this->tokens[$y]['code']]) === false + && $this->tokens[$y]['code'] !== T_BITWISE_AND + ) { + // Non-whitespace content. + break; + } + } + + if ($this->tokens[$y]['code'] === T_FN) { + $confirmed = true; + break; + } + } + }//end if + if (isset($allowed[$this->tokens[$x]['code']]) === true) { - ++$typeTokenCount; + ++$typeTokenCountBefore; continue; } - // Union and intersection types can't use the nullable operator, but be tolerant to parse errors. - if ($typeTokenCount > 0 && $this->tokens[$x]['code'] === T_NULLABLE) { + // Union, intersection and DNF types can't use the nullable operator, but be tolerant to parse errors. + if (($typeTokenCountBefore > 0 + || ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS && isset($this->tokens[$x]['parenthesis_owner']) === false)) + && ($this->tokens[$x]['code'] === T_NULLABLE + || $this->tokens[$x]['code'] === T_INLINE_THEN) + ) { + if ($this->tokens[$x]['code'] === T_INLINE_THEN) { + $maybeNullable = $x; + } + continue; } @@ -3134,8 +3219,24 @@ protected function processAdditional() continue; } + if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS || $this->tokens[$x]['code'] === T_CLOSE_PARENTHESIS) { + ++$parenthesesCount; + $typeOperators[] = $x; + continue; + } + if ($suspectedType === 'return' && $this->tokens[$x]['code'] === T_COLON) { - $confirmed = true; + // Make sure this is not the colon from a parameter name. + for ($y = ($x - 1); $y > 0; $y--) { + if (isset(Tokens::$emptyTokens[$this->tokens[$y]['code']]) === false) { + break; + } + } + + if ($this->tokens[$y]['code'] !== T_PARAM_NAME) { + $confirmed = true; + } + break; } @@ -3157,6 +3258,9 @@ protected function processAdditional() break; }//end for + // Remember the last token we examined as part of the (non-)"type declaration". + $lastSeenTypeToken = $x; + if ($confirmed === false && $suspectedType === 'property or parameter' && isset($this->tokens[$i]['nested_parenthesis']) === true @@ -3201,8 +3305,8 @@ protected function processAdditional() unset($parens, $last); }//end if - if ($confirmed === false) { - // Not a union or intersection type after all, move on. + if ($confirmed === false || ($parenthesesCount % 2) !== 0) { + // Not a (valid) union, intersection or DNF type after all, move on. continue; } @@ -3215,7 +3319,7 @@ protected function processAdditional() $line = $this->tokens[$x]['line']; echo "\t* token $x on line $line changed from T_BITWISE_OR to T_TYPE_UNION".PHP_EOL; } - } else { + } else if ($this->tokens[$x]['code'] === T_BITWISE_AND) { $this->tokens[$x]['code'] = T_TYPE_INTERSECTION; $this->tokens[$x]['type'] = 'T_TYPE_INTERSECTION'; @@ -3223,6 +3327,32 @@ protected function processAdditional() $line = $this->tokens[$x]['line']; echo "\t* token $x on line $line changed from T_BITWISE_AND to T_TYPE_INTERSECTION".PHP_EOL; } + } else if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) { + $this->tokens[$x]['code'] = T_TYPE_OPEN_PARENTHESIS; + $this->tokens[$x]['type'] = 'T_TYPE_OPEN_PARENTHESIS'; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $line = $this->tokens[$x]['line']; + echo "\t* token $x on line $line changed from T_OPEN_PARENTHESIS to T_TYPE_OPEN_PARENTHESIS".PHP_EOL; + } + } else if ($this->tokens[$x]['code'] === T_CLOSE_PARENTHESIS) { + $this->tokens[$x]['code'] = T_TYPE_CLOSE_PARENTHESIS; + $this->tokens[$x]['type'] = 'T_TYPE_CLOSE_PARENTHESIS'; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $line = $this->tokens[$x]['line']; + echo "\t* token $x on line $line changed from T_CLOSE_PARENTHESIS to T_TYPE_CLOSE_PARENTHESIS".PHP_EOL; + } + }//end if + }//end foreach + + if (isset($maybeNullable) === true) { + $this->tokens[$maybeNullable]['code'] = T_NULLABLE; + $this->tokens[$maybeNullable]['type'] = 'T_NULLABLE'; + + if (PHP_CODESNIFFER_VERBOSITY > 1) { + $line = $this->tokens[$maybeNullable]['line']; + echo "\t* token $maybeNullable on line $line changed from T_INLINE_THEN to T_NULLABLE".PHP_EOL; } } @@ -3609,10 +3739,10 @@ public static function resolveSimpleToken($token) * Finds a "closer" token (closing parenthesis or square bracket for example) * Handle parenthesis balancing while searching for closing token * - * @param array $tokens The list of tokens to iterate searching the closing token (as returned by token_get_all) - * @param int $start The starting position - * @param string|string[] $openerTokens The opening character - * @param string $closerChar The closing character + * @param array $tokens The list of tokens to iterate searching the closing token (as returned by token_get_all). + * @param int $start The starting position. + * @param string|string[] $openerTokens The opening character. + * @param string $closerChar The closing character. * * @return int|null The position of the closing token, if found. NULL otherwise. */ @@ -3646,8 +3776,8 @@ private function findCloser(array &$tokens, $start, $openerTokens, $closerChar) * PHP 8 attributes parser for PHP < 8 * Handles single-line and multiline attributes. * - * @param array $tokens The original array of tokens (as returned by token_get_all) - * @param int $stackPtr The current position in token array + * @param array $tokens The original array of tokens (as returned by token_get_all). + * @param int $stackPtr The current position in token array. * * @return array|null The array of parsed attribute tokens */ diff --git a/vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php b/vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php index 0857428c..ba41f8da 100644 --- a/vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php +++ b/vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php @@ -76,7 +76,7 @@ abstract class Tokenizer /** * Initialise and run the tokenizer. * - * @param string $content The content to tokenize, + * @param string $content The content to tokenize. * @param \PHP_CodeSniffer\Config | null $config The config data for the run. * @param string $eolChar The EOL char used in the content. * diff --git a/vendor/squizlabs/php_codesniffer/src/Util/Common.php b/vendor/squizlabs/php_codesniffer/src/Util/Common.php index bc6cd268..63a76ce2 100644 --- a/vendor/squizlabs/php_codesniffer/src/Util/Common.php +++ b/vendor/squizlabs/php_codesniffer/src/Util/Common.php @@ -312,6 +312,20 @@ public static function prepareForOutput($content, $exclude=[]) }//end prepareForOutput() + /** + * Strip colors from a text for output to screen. + * + * @param string $text The text to process. + * + * @return string + */ + public static function stripColors($text) + { + return preg_replace('`\033\[[0-9;]+m`', '', $text); + + }//end stripColors() + + /** * Returns true if the specified string is in the camel caps format. * diff --git a/vendor/squizlabs/php_codesniffer/src/Util/Help.php b/vendor/squizlabs/php_codesniffer/src/Util/Help.php new file mode 100644 index 00000000..a7602b7d --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/src/Util/Help.php @@ -0,0 +1,626 @@ + + * @copyright 2024 Juliette Reinders Folmer. All rights reserved. + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Util; + +use InvalidArgumentException; +use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Util\Common; + +final class Help +{ + + + /** + * Short options which are available for both the `phpcs` as well as the `phpcbf` command. + * + * @var string + */ + const DEFAULT_SHORT_OPTIONS = '-hilnpqvw'; + + /** + * Long options which are available for both the `phpcs` as well as the `phpcbf` command. + * + * {@internal This should be a constant array, but those aren't supported until PHP 5.6.} + * + * @var string Comma-separated list of the option names. + */ + const DEFAULT_LONG_OPTIONS = 'basepath,bootstrap,colors,encoding,error-severity,exclude,extensions,file,file-list,filter,ignore,ignore-annotations,no-colors,parallel,php-ini,report-width,runtime-set,severity,sniffs,standard,stdin-path,tab-width,version,vv,vvv,warning-severity'; + + /** + * Minimum screen width. + * + * The help info needs room to display, so this is the minimum acceptable width. + * + * @var integer + */ + const MIN_WIDTH = 60; + + /** + * Indent option lines. + * + * @var string + */ + const INDENT = ' '; + + /** + * Gutter spacing for between the option argument info and the option description. + * + * @var string + */ + const GUTTER = ' '; + + /** + * The current PHPCS Configuration. + * + * @var \PHP_CodeSniffer\Config + */ + private $config; + + /** + * The options which should be shown for this help screen. + * + * @var array + */ + private $requestedOptions = []; + + /** + * Active options per category (after filtering). + * + * @var array>> + */ + private $activeOptions = []; + + /** + * Width of the indent for option lines. + * + * @var integer + */ + private $indentWidth = 0; + + /** + * Width of the gutter spacing. + * + * @var integer + */ + private $gutterWidth = 0; + + /** + * Width of longest option argument info entry. + * + * @var integer + */ + private $maxOptionNameLength = 0; + + + /** + * Constructor. + * + * @param \PHP_CodeSniffer\Config $config Configuration object. + * @param array $longOptions The long options which should be shown. + * @param string $shortOptions The short options which should be shown. + * + * @throws \InvalidArgumentException When $shortOptions is not a string. + */ + public function __construct(Config $config, array $longOptions, $shortOptions='') + { + if (is_string($shortOptions) === false) { + throw new InvalidArgumentException('The $shortOptions parameter must be a string'); + } + + $this->config = $config; + $this->requestedOptions = array_merge($longOptions, str_split($shortOptions)); + + $this->filterOptions(); + + $this->indentWidth = strlen(self::INDENT); + $this->gutterWidth = strlen(self::GUTTER); + + $this->setMaxOptionNameLength(); + + }//end __construct() + + + /** + * Display the help info. + * + * @return void + */ + public function display() + { + $this->printUsage(); + $this->printCategories(); + + }//end display() + + + /** + * Filter the available options based on the requested options. + * + * @return void + */ + private function filterOptions() + { + $filteredOptions = $this->getAllOptions(); + + foreach ($filteredOptions as $category => $options) { + // Initial state set to "true" to prevent a spacer at the start of an array. + $lastWasSpacer = true; + $spacerCount = 0; + + foreach ($options as $name => $option) { + if ($lastWasSpacer !== true && strpos($name, 'blank-line') === 0) { + ++$spacerCount; + $lastWasSpacer = true; + continue; + } + + if (in_array($name, $this->requestedOptions, true) === false) { + unset($filteredOptions[$category][$name]); + continue; + } + + $lastWasSpacer = false; + } + + // Make sure the final array doesn't contain a spacer at the end. + if (empty($filteredOptions[$category]) === false) { + end($filteredOptions[$category]); + $key = key($filteredOptions[$category]); + if (strpos($key, 'blank-line') === 0) { + unset($filteredOptions[$category][$key]); + --$spacerCount; + } + } + + // Remove categories now left empty. + if (empty($filteredOptions[$category]) === true || count($filteredOptions[$category]) === $spacerCount) { + unset($filteredOptions[$category]); + } + }//end foreach + + $this->activeOptions = $filteredOptions; + + }//end filterOptions() + + + /** + * Determine the length of the longest option argument and store it. + * + * @return void + */ + private function setMaxOptionNameLength() + { + $lengths = []; + foreach ($this->activeOptions as $category => $options) { + foreach ($options as $option) { + if (isset($option['argument']) === false) { + continue; + } + + $lengths[] = strlen($option['argument']); + } + } + + if (empty($lengths) === false) { + $this->maxOptionNameLength = max($lengths); + } + + }//end setMaxOptionNameLength() + + + /** + * Get the maximum width which can be used to display the help info. + * + * Independently of user preference/auto-determined width of the current screen, + * a minimum width is needed to display information, so don't allow this to get too low. + * + * @return int + */ + private function getMaxWidth() + { + return max(self::MIN_WIDTH, $this->config->reportWidth); + + }//end getMaxWidth() + + + /** + * Get the maximum width for the text in the option description column. + * + * @return int + */ + private function getDescriptionColumnWidth() + { + return ($this->getMaxWidth() - $this->maxOptionNameLength - $this->indentWidth - $this->gutterWidth); + + }//end getDescriptionColumnWidth() + + + /** + * Get the length of the indentation needed for follow up lines when the description does not fit on one line. + * + * @return int + */ + private function getDescriptionFollowupLineIndentLength() + { + return ($this->maxOptionNameLength + $this->indentWidth + $this->gutterWidth); + + }//end getDescriptionFollowupLineIndentLength() + + + /** + * Print basic usage information to the screen. + * + * @return void + */ + private function printUsage() + { + $command = 'phpcs'; + if (defined('PHP_CODESNIFFER_CBF') === true && PHP_CODESNIFFER_CBF === true) { + // @codeCoverageIgnore + $command = 'phpcbf'; + } + + $this->printCategoryHeader('Usage'); + + echo self::INDENT.$command.' [options] '.PHP_EOL; + + }//end printUsage() + + + /** + * Print details of all the requested options to the screen, sorted by category. + * + * @return void + */ + private function printCategories() + { + foreach ($this->activeOptions as $category => $options) { + $this->printCategoryHeader($category); + $this->printCategoryOptions($options); + } + + }//end printCategories() + + + /** + * Print a category header. + * + * @param string $header The header text. + * + * @return void + */ + private function printCategoryHeader($header) + { + $header .= ':'; + if ($this->config->colors === true) { + $header = "\033[33m{$header}\033[0m"; + } + + echo PHP_EOL.$header.PHP_EOL; + + }//end printCategoryHeader() + + + /** + * Print the options for a category. + * + * @param array> $options The options to display. + * + * @return void + */ + private function printCategoryOptions(array $options) + { + $maxDescriptionWidth = $this->getDescriptionColumnWidth(); + $maxTextWidth = ($this->getMaxWidth() - $this->indentWidth); + $secondLineIndent = str_repeat(' ', $this->getDescriptionFollowupLineIndentLength()); + + $output = ''; + foreach ($options as $option) { + if (isset($option['spacer']) === true) { + $output .= PHP_EOL; + } + + if (isset($option['text']) === true) { + $text = wordwrap($option['text'], $maxTextWidth, "\n"); + $output .= self::INDENT.implode(PHP_EOL.self::INDENT, explode("\n", $text)).PHP_EOL; + } + + if (isset($option['argument'], $option['description']) === true) { + $argument = str_pad($option['argument'], $this->maxOptionNameLength); + $argument = $this->colorizeVariableInput($argument); + $output .= self::INDENT."\033[32m{$argument}\033[0m"; + $output .= self::GUTTER; + + $description = wordwrap($option['description'], $maxDescriptionWidth, "\n"); + $output .= implode(PHP_EOL.$secondLineIndent, explode("\n", $description)).PHP_EOL; + } + } + + if ($this->config->colors === false) { + $output = Common::stripColors($output); + } + + echo $output; + + }//end printCategoryOptions() + + + /** + * Colorize "variable" input in the option argument info. + * + * For the purposes of this method, "variable" input is text between <> brackets. + * The regex allows for multiple tags and nested tags. + * + * @param string $text The text to process. + * + * @return string + */ + private function colorizeVariableInput($text) + { + return preg_replace('`(<(?:(?>[^<>]+)|(?R))*>)`', "\033[36m".'$1'."\033[32m", $text); + + }//end colorizeVariableInput() + + + /** + * Retrieve the help details for all supported CLI arguments per category. + * + * @return array>> + */ + private function getAllOptions() + { + $options = []; + + // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- Readability is more important. + $options['Scan targets'] = [ + 'file' => [ + 'argument' => '', + 'description' => 'One or more files and/or directories to check, space separated.', + ], + '-' => [ + 'argument' => '-', + 'description' => 'Check STDIN instead of local files and directories.', + ], + 'stdin-path' => [ + 'argument' => '--stdin-path=', + 'description' => 'If processing STDIN, the file path that STDIN will be processed as.', + ], + 'file-list' => [ + 'argument' => '--file-list=', + 'description' => 'Check the files and/or directories which are defined in the file to which the path is provided (one per line).', + ], + 'filter' => [ + 'argument' => '--filter=', + 'description' => 'Check based on a predefined file filter. Use either the "GitModified" or "GitStaged" filter, or specify the path to a custom filter class.', + ], + 'ignore' => [ + 'argument' => '--ignore=', + 'description' => 'Ignore files based on a comma-separated list of patterns matching files and/or directories.', + ], + 'extensions' => [ + 'argument' => '--extensions=', + 'description' => 'Check files with the specified file extensions (comma-separated list). Defaults to php,inc/php,js,css.'."\n" + .'The type of the file can be specified using: ext/type; e.g. module/php,es/js.', + ], + 'l' => [ + 'argument' => '-l', + 'description' => 'Check local directory only, no recursion.', + ], + ]; + + $options['Rule Selection Options'] = [ + 'standard' => [ + 'argument' => '--standard=', + 'description' => 'The name of, or the path to, the coding standard to use. Can be a comma-separated list specifying multiple standards. If no standard is specified, PHP_CodeSniffer will look for a [.]phpcs.xml[.dist] custom ruleset file in the current directory and those above it.', + ], + 'sniffs' => [ + 'argument' => '--sniffs=', + 'description' => 'A comma-separated list of sniff codes to limit the scan to. All sniffs must be part of the standard in use.', + ], + 'exclude' => [ + 'argument' => '--exclude=', + 'description' => 'A comma-separated list of sniff codes to exclude from the scan. All sniffs must be part of the standard in use.', + ], + 'blank-line' => ['spacer' => ''], + + 'i' => [ + 'argument' => '-i', + 'description' => 'Show a list of installed coding standards.', + ], + 'e' => [ + 'argument' => '-e', + 'description' => 'Explain a standard by showing the names of all the sniffs it includes.', + ], + 'generator' => [ + 'argument' => '--generator=', + 'description' => 'Show documentation for a standard. Use either the "HTML", "Markdown" or "Text" generator.', + ], + ]; + + $options['Run Options'] = [ + 'a' => [ + 'argument' => '-a', + 'description' => 'Run in interactive mode, pausing after each file.', + ], + 'bootstrap' => [ + 'argument' => '--bootstrap=', + 'description' => 'Run the specified file(s) before processing begins. A list of files can be provided, separated by commas.', + ], + 'cache' => [ + 'argument' => '--cache[=]', + 'description' => 'Cache results between runs. Optionally, can be provided to use a specific file for caching. Otherwise, a temporary file is used.', + ], + 'no-cache' => [ + 'argument' => '--no-cache', + 'description' => 'Do not cache results between runs (default).', + ], + 'parallel' => [ + 'argument' => '--parallel=', + 'description' => 'The number of files to be checked simultaneously. Defaults to 1 (no parallel processing).'."\n" + .'If enabled, this option only takes effect if the PHP PCNTL (Process Control) extension is available.', + ], + 'suffix' => [ + 'argument' => '--suffix=', + 'description' => 'Write modified files to a filename using this suffix ("diff" and "patch" are not used in this mode).', + ], + 'blank-line' => ['spacer' => ''], + + 'php-ini' => [ + 'argument' => '-d ', + 'description' => 'Set the [key] php.ini value to [value] or set to [true] if value is omitted.'."\n" + .'Note: only php.ini settings which can be changed at runtime are supported.', + ], + ]; + + $options['Reporting Options'] = [ + 'report' => [ + 'argument' => '--report=', + 'description' => 'Print either the "full", "xml", "checkstyle", "csv", "json", "junit", "emacs", "source", "summary", "diff", "svnblame", "gitblame", "hgblame", "notifysend" or "performance" report or specify the path to a custom report class. By default, the "full" report is displayed.', + ], + 'report-file' => [ + 'argument' => '--report-file=', + 'description' => 'Write the report to the specified file path.', + ], + 'report-report' => [ + 'argument' => '--report-=', + 'description' => 'Write the report specified in to the specified file path.', + ], + 'report-width' => [ + 'argument' => '--report-width=', + 'description' => 'How many columns wide screen reports should be. Set to "auto" to use current screen width, where supported.', + ], + 'basepath' => [ + 'argument' => '--basepath=', + 'description' => 'Strip a path from the front of file paths inside reports.', + ], + 'blank-line-1' => ['spacer' => ''], + + 'w' => [ + 'argument' => '-w', + 'description' => 'Include both warnings and errors (default).', + ], + 'n' => [ + 'argument' => '-n', + 'description' => 'Do not include warnings. Shortcut for "--warning-severity=0".', + ], + 'severity' => [ + 'argument' => '--severity=', + 'description' => 'The minimum severity required to display an error or warning. Defaults to 5.', + ], + 'error-severity' => [ + 'argument' => '--error-severity=', + 'description' => 'The minimum severity required to display an error. Defaults to 5.', + ], + 'warning-severity' => [ + 'argument' => '--warning-severity=', + 'description' => 'The minimum severity required to display a warning. Defaults to 5.', + ], + 'blank-line-2' => ['spacer' => ''], + + 's' => [ + 'argument' => '-s', + 'description' => 'Show sniff error codes in all reports.', + ], + 'ignore-annotations' => [ + 'argument' => '--ignore-annotations', + 'description' => 'Ignore all "phpcs:..." annotations in code comments.', + ], + 'colors' => [ + 'argument' => '--colors', + 'description' => 'Use colors in screen output.', + ], + 'no-colors' => [ + 'argument' => '--no-colors', + 'description' => 'Do not use colors in screen output (default).', + ], + 'p' => [ + 'argument' => '-p', + 'description' => 'Show progress of the run.', + ], + 'q' => [ + 'argument' => '-q', + 'description' => 'Quiet mode; disables progress and verbose output.', + ], + 'm' => [ + 'argument' => '-m', + 'description' => 'Stop error messages from being recorded. This saves a lot of memory but stops many reports from being used.', + ], + ]; + + $options['Configuration Options'] = [ + 'encoding' => [ + 'argument' => '--encoding=', + 'description' => 'The encoding of the files being checked. Defaults to "utf-8".', + ], + 'tab-width' => [ + 'argument' => '--tab-width=', + 'description' => 'The number of spaces each tab represents.', + ], + 'blank-line' => ['spacer' => ''], + + 'config-explain' => [ + 'text' => 'Default values for a selection of options can be stored in a user-specific CodeSniffer.conf configuration file.'."\n" + .'This applies to the following options: "default_standard", "report_format", "tab_width", "encoding", "severity", "error_severity", "warning_severity", "show_warnings", "report_width", "show_progress", "quiet", "colors", "cache", "parallel".', + ], + 'config-show' => [ + 'argument' => '--config-show', + 'description' => 'Show the configuration options which are currently stored in the applicable CodeSniffer.conf file.', + ], + 'config-set' => [ + 'argument' => '--config-set ', + 'description' => 'Save a configuration option to the CodeSniffer.conf file.', + ], + 'config-delete' => [ + 'argument' => '--config-delete ', + 'description' => 'Delete a configuration option from the CodeSniffer.conf file.', + ], + 'runtime-set' => [ + 'argument' => '--runtime-set ', + 'description' => 'Set a configuration option to be applied to the current scan run only.', + ], + ]; + + $options['Miscellaneous Options'] = [ + 'h' => [ + 'argument' => '-h, -?, --help', + 'description' => 'Print this help message.', + ], + 'version' => [ + 'argument' => '--version', + 'description' => 'Print version information.', + ], + 'v' => [ + 'argument' => '-v', + 'description' => 'Verbose output: Print processed files.', + ], + 'vv' => [ + 'argument' => '-vv', + 'description' => 'Verbose output: Print ruleset and token output.', + ], + 'vvv' => [ + 'argument' => '-vvv', + 'description' => 'Verbose output: Print sniff processing information.', + ], + ]; + // phpcs:enable + + return $options; + + }//end getAllOptions() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/src/Util/Tokens.php b/vendor/squizlabs/php_codesniffer/src/Util/Tokens.php index ab70e783..5ec913df 100644 --- a/vendor/squizlabs/php_codesniffer/src/Util/Tokens.php +++ b/vendor/squizlabs/php_codesniffer/src/Util/Tokens.php @@ -82,6 +82,8 @@ define('T_ATTRIBUTE_END', 'PHPCS_T_ATTRIBUTE_END'); define('T_ENUM_CASE', 'PHPCS_T_ENUM_CASE'); define('T_TYPE_INTERSECTION', 'PHPCS_T_TYPE_INTERSECTION'); +define('T_TYPE_OPEN_PARENTHESIS', 'PHPCS_T_TYPE_OPEN_PARENTHESIS'); +define('T_TYPE_CLOSE_PARENTHESIS', 'PHPCS_T_TYPE_CLOSE_PARENTHESIS'); // Some PHP 5.5 tokens, replicated for lower versions. if (defined('T_FINALLY') === false) { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Config/SniffsExcludeArgsTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Config/SniffsExcludeArgsTest.php new file mode 100644 index 00000000..4eedb624 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Config/SniffsExcludeArgsTest.php @@ -0,0 +1,200 @@ + + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Config; + +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHPUnit\Framework\TestCase; + +/** + * Tests for the \PHP_CodeSniffer\Config --sniffs and --exclude arguments. + * + * @covers \PHP_CodeSniffer\Config::processLongArgument + */ +final class SniffsExcludeArgsTest extends TestCase +{ + + + /** + * Ensure that the expected error message is returned for invalid arguments. + * + * @param string $argument 'sniffs' or 'exclude'. + * @param string $value List of sniffs to include / exclude. + * @param string $message Expected error message text. + * + * @return void + * @dataProvider dataInvalidSniffs + */ + public function testInvalid($argument, $value, $message) + { + $exception = 'PHP_CodeSniffer\Exceptions\DeepExitException'; + + if (method_exists($this, 'expectException') === true) { + // PHPUnit 5+. + $this->expectException($exception); + $this->expectExceptionMessage($message); + } else { + // PHPUnit 4. + $this->setExpectedException($exception, $message); + } + + new ConfigDouble(["--$argument=$value"]); + + }//end testInvalid() + + + /** + * Data provider for testInvalid(). + * + * @see self::testInvalid() + * @return array> + */ + public static function dataInvalidSniffs() + { + $arguments = [ + 'sniffs', + 'exclude', + ]; + $data = []; + + $messageTemplate = 'ERROR: The specified sniff code "%s" is invalid'.PHP_EOL.PHP_EOL; + + foreach ($arguments as $argument) { + // An empty string is not a valid sniff. + $data[$argument.'; empty string'] = [ + 'argument' => $argument, + 'value' => '', + 'message' => sprintf($messageTemplate, ''), + ]; + + // A standard is not a valid sniff. + $data[$argument.'; standard'] = [ + 'argument' => $argument, + 'value' => 'Standard', + 'message' => sprintf($messageTemplate, 'Standard'), + ]; + + // A category is not a valid sniff. + $data[$argument.'; category'] = [ + 'argument' => $argument, + 'value' => 'Standard.Category', + 'message' => sprintf($messageTemplate, 'Standard.Category'), + ]; + + // An error-code is not a valid sniff. + $data[$argument.'; error-code'] = [ + 'argument' => $argument, + 'value' => 'Standard.Category', + 'message' => sprintf($messageTemplate, 'Standard.Category'), + ]; + + // Only the first error is reported. + $data[$argument.'; two errors'] = [ + 'argument' => $argument, + 'value' => 'StandardOne,StandardTwo', + 'message' => sprintf($messageTemplate, 'StandardOne'), + ]; + $data[$argument.'; valid followed by invalid'] = [ + 'argument' => $argument, + 'value' => 'StandardOne.Category.Sniff,StandardTwo.Category', + 'message' => sprintf($messageTemplate, 'StandardTwo.Category'), + ]; + }//end foreach + + return $data; + + }//end dataInvalidSniffs() + + + /** + * Ensure that the valid data does not throw an exception, and the value is stored. + * + * @param string $argument 'sniffs' or 'exclude'. + * @param string $value List of sniffs to include or exclude. + * + * @return void + * @dataProvider dataValidSniffs + */ + public function testValid($argument, $value) + { + $config = new ConfigDouble(["--$argument=$value"]); + + $this->assertSame(explode(',', $value), $config->$argument); + + }//end testValid() + + + /** + * Data provider for testValid(). + * + * @see self::testValid() + * @return array> + */ + public static function dataValidSniffs() + { + $arguments = [ + 'sniffs', + 'exclude', + ]; + $data = []; + + foreach ($arguments as $argument) { + $data[$argument.'; one valid sniff'] = [ + 'argument' => $argument, + 'value' => 'Standard.Category.Sniff', + ]; + $data[$argument.'; two valid sniffs'] = [ + 'argument' => $argument, + 'value' => 'StandardOne.Category.Sniff,StandardTwo.Category.Sniff', + ]; + } + + return $data; + + }//end dataValidSniffs() + + + /** + * Ensure that only the first argument is processed and others are ignored. + * + * @param string $argument 'sniffs' or 'exclude'. + * + * @return void + * @dataProvider dataOnlySetOnce + */ + public function testOnlySetOnce($argument) + { + $config = new ConfigDouble( + [ + "--$argument=StandardOne.Category.Sniff", + "--$argument=StandardTwo.Category.Sniff", + "--$argument=Standard.AnotherCategory.Sniff", + ] + ); + + $this->assertSame(['StandardOne.Category.Sniff'], $config->$argument); + + }//end testOnlySetOnce() + + + /** + * Data provider for testOnlySetOnce(). + * + * @return array> + */ + public static function dataOnlySetOnce() + { + return [ + 'sniffs' => ['sniffs'], + 'exclude' => ['exclude'], + ]; + + }//end dataOnlySetOnce() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/FindEndOfStatementTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/File/FindEndOfStatementTest.php index ba04cd59..be8f458a 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/FindEndOfStatementTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/FindEndOfStatementTest.php @@ -10,6 +10,7 @@ namespace PHP_CodeSniffer\Tests\Core\File; use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +use PHP_CodeSniffer\Util\Tokens; /** * Tests for the \PHP_CodeSniffer\Files\File::findEndOfStatement method. @@ -20,6 +21,42 @@ final class FindEndOfStatementTest extends AbstractMethodUnitTest { + /** + * Test that end of statement is NEVER before the "current" token. + * + * @return void + */ + public function testEndIsNeverLessThanCurrentToken() + { + $tokens = self::$phpcsFile->getTokens(); + $errors = []; + + for ($i = 0; $i < self::$phpcsFile->numTokens; $i++) { + if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) { + continue; + } + + $end = self::$phpcsFile->findEndOfStatement($i); + + // Collect all the errors. + if ($end < $i) { + $errors[] = sprintf( + 'End of statement for token %1$d (%2$s: %3$s) on line %4$d is %5$d (%6$s), which is less than %1$d', + $i, + $tokens[$i]['type'], + $tokens[$i]['content'], + $tokens[$i]['line'], + $end, + $tokens[$end]['type'] + ); + } + } + + $this->assertSame([], $errors); + + }//end testEndIsNeverLessThanCurrentToken() + + /** * Test a simple assignment. * diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/FindStartOfStatementTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/File/FindStartOfStatementTest.inc index 148d8103..574b9861 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/FindStartOfStatementTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/FindStartOfStatementTest.inc @@ -14,7 +14,7 @@ while(true) {} $a = 1; /* testClosureAssignment */ -$a = function($b=false;){}; +$a = function($b=false){}; /* testHeredocFunctionArg */ myFunction(<< fn() => return 1, - 'b' => fn() => return 1, + 'a' => fn() => 1, + 'b' => fn() => 1, ]; /* testStaticArrowFunction */ @@ -139,11 +139,11 @@ switch ($foo) { /* testInsideCaseStatement */ $var = doSomething(); /* testInsideCaseBreakStatement */ - break 2; + break 1; case 2: /* testInsideCaseContinueStatement */ - continue 2; + continue 1; case 3: /* testInsideCaseReturnStatement */ @@ -162,3 +162,39 @@ switch ($foo) { /* testInsideDefaultContinueStatement */ continue $var; } + +match ($var) { + true => + /* test437ClosureDeclaration */ + function ($var) { + /* test437EchoNestedWithinClosureWithinMatch */ + echo $var, 'text', PHP_EOL; + }, + default => false +}; + +match ($var) { + /* test437NestedLongArrayWithinMatch */ + 'a' => array( 1, 2.5, $var), + /* test437NestedFunctionCallWithinMatch */ + 'b' => functionCall( 11, $var, 50.50), + /* test437NestedArrowFunctionWithinMatch */ + 'c' => fn($p1, /* test437FnSecondParamWithinMatch */ $p2) => $p1 + $p2, + default => false +}; + +callMe($paramA, match ($var) { + /* test437NestedLongArrayWithinNestedMatch */ + 'a' => array( 1, 2.5, $var), + /* test437NestedFunctionCallWithinNestedMatch */ + 'b' => functionCall( 11, $var, 50.50), + /* test437NestedArrowFunctionWithinNestedMatch */ + 'c' => fn($p1, /* test437FnSecondParamWithinNestedMatch */ $p2) => $p1 + $p2, + default => false +}); + +match ($var) { + /* test437NestedShortArrayWithinMatch */ + 'a' => [ 1, 2.5, $var], + default => false +}; diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/FindStartOfStatementTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/File/FindStartOfStatementTest.php index c674a602..a814d8c1 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/FindStartOfStatementTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/FindStartOfStatementTest.php @@ -12,6 +12,7 @@ namespace PHP_CodeSniffer\Tests\Core\File; use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +use PHP_CodeSniffer\Util\Tokens; /** * Tests for the \PHP_CodeSniffer\Files\File:findStartOfStatement method. @@ -22,6 +23,42 @@ final class FindStartOfStatementTest extends AbstractMethodUnitTest { + /** + * Test that start of statement is NEVER beyond the "current" token. + * + * @return void + */ + public function testStartIsNeverMoreThanCurrentToken() + { + $tokens = self::$phpcsFile->getTokens(); + $errors = []; + + for ($i = 0; $i < self::$phpcsFile->numTokens; $i++) { + if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) { + continue; + } + + $start = self::$phpcsFile->findStartOfStatement($i); + + // Collect all the errors. + if ($start > $i) { + $errors[] = sprintf( + 'Start of statement for token %1$d (%2$s: %3$s) on line %4$d is %5$d (%6$s), which is more than %1$d', + $i, + $tokens[$i]['type'], + $tokens[$i]['content'], + $tokens[$i]['line'], + $start, + $tokens[$start]['type'] + ); + } + } + + $this->assertSame([], $errors); + + }//end testStartIsNeverMoreThanCurrentToken() + + /** * Test a simple assignment. * @@ -92,7 +129,7 @@ public function testClosureAssignment() $start = $this->getTargetToken('/* testClosureAssignment */', T_CLOSE_CURLY_BRACKET); $found = self::$phpcsFile->findStartOfStatement($start); - $this->assertSame(($start - 12), $found); + $this->assertSame(($start - 11), $found); }//end testClosureAssignment() @@ -224,7 +261,7 @@ public function testArrowFunctionArrayValue() $start = $this->getTargetToken('/* testArrowFunctionArrayValue */', T_COMMA); $found = self::$phpcsFile->findStartOfStatement($start); - $this->assertSame(($start - 9), $found); + $this->assertSame(($start - 7), $found); }//end testArrowFunctionArrayValue() @@ -637,4 +674,300 @@ public static function dataFindStartInsideSwitchCaseDefaultStatements() }//end dataFindStartInsideSwitchCaseDefaultStatements() + /** + * Test finding the start of a statement inside a closed scope nested within a match expressions. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int|string $target The token to search for after the test marker. + * @param int|string $expectedTarget Token code of the expected start of statement stack pointer. + * + * @link https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/437 + * + * @dataProvider dataFindStartInsideClosedScopeNestedWithinMatch + * + * @return void + */ + public function testFindStartInsideClosedScopeNestedWithinMatch($testMarker, $target, $expectedTarget) + { + $testToken = $this->getTargetToken($testMarker, $target); + $expected = $this->getTargetToken($testMarker, $expectedTarget); + + $found = self::$phpcsFile->findStartOfStatement($testToken); + + $this->assertSame($expected, $found); + + }//end testFindStartInsideClosedScopeNestedWithinMatch() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataFindStartInsideClosedScopeNestedWithinMatch() + { + return [ + // These were already working correctly. + 'Closure function keyword should be start of closure - closure keyword' => [ + 'testMarker' => '/* test437ClosureDeclaration */', + 'targets' => T_CLOSURE, + 'expectedTarget' => T_CLOSURE, + ], + 'Open curly is a statement/expression opener - open curly' => [ + 'testMarker' => '/* test437ClosureDeclaration */', + 'targets' => T_OPEN_CURLY_BRACKET, + 'expectedTarget' => T_OPEN_CURLY_BRACKET, + ], + + 'Echo should be start for expression - echo keyword' => [ + 'testMarker' => '/* test437EchoNestedWithinClosureWithinMatch */', + 'targets' => T_ECHO, + 'expectedTarget' => T_ECHO, + ], + 'Echo should be start for expression - variable' => [ + 'testMarker' => '/* test437EchoNestedWithinClosureWithinMatch */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_ECHO, + ], + 'Echo should be start for expression - comma' => [ + 'testMarker' => '/* test437EchoNestedWithinClosureWithinMatch */', + 'targets' => T_COMMA, + 'expectedTarget' => T_ECHO, + ], + + // These were not working correctly and would previously return the close curly of the match expression. + 'First token after comma in echo expression should be start for expression - text string' => [ + 'testMarker' => '/* test437EchoNestedWithinClosureWithinMatch */', + 'targets' => T_CONSTANT_ENCAPSED_STRING, + 'expectedTarget' => T_CONSTANT_ENCAPSED_STRING, + ], + 'First token after comma in echo expression - PHP_EOL constant' => [ + 'testMarker' => '/* test437EchoNestedWithinClosureWithinMatch */', + 'targets' => T_STRING, + 'expectedTarget' => T_STRING, + ], + 'First token after comma in echo expression - semicolon' => [ + 'testMarker' => '/* test437EchoNestedWithinClosureWithinMatch */', + 'targets' => T_SEMICOLON, + 'expectedTarget' => T_STRING, + ], + ]; + + }//end dataFindStartInsideClosedScopeNestedWithinMatch() + + + /** + * Test finding the start of a statement for a token within a set of parentheses within a match expressions. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int|string $target The token to search for after the test marker. + * @param int|string $expectedTarget Token code of the expected start of statement stack pointer. + * + * @link https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/437 + * + * @dataProvider dataFindStartInsideParenthesesNestedWithinMatch + * + * @return void + */ + public function testFindStartInsideParenthesesNestedWithinMatch($testMarker, $target, $expectedTarget) + { + $testToken = $this->getTargetToken($testMarker, $target); + $expected = $this->getTargetToken($testMarker, $expectedTarget); + + $found = self::$phpcsFile->findStartOfStatement($testToken); + + $this->assertSame($expected, $found); + + }//end testFindStartInsideParenthesesNestedWithinMatch() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataFindStartInsideParenthesesNestedWithinMatch() + { + return [ + 'Array item itself should be start for first array item' => [ + 'testMarker' => '/* test437NestedLongArrayWithinMatch */', + 'targets' => T_LNUMBER, + 'expectedTarget' => T_LNUMBER, + ], + 'Array item itself should be start for second array item' => [ + 'testMarker' => '/* test437NestedLongArrayWithinMatch */', + 'targets' => T_DNUMBER, + 'expectedTarget' => T_DNUMBER, + ], + 'Array item itself should be start for third array item' => [ + 'testMarker' => '/* test437NestedLongArrayWithinMatch */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_VARIABLE, + ], + + 'Parameter itself should be start for first param passed to function call' => [ + 'testMarker' => '/* test437NestedFunctionCallWithinMatch */', + 'targets' => T_LNUMBER, + 'expectedTarget' => T_LNUMBER, + ], + 'Parameter itself should be start for second param passed to function call' => [ + 'testMarker' => '/* test437NestedFunctionCallWithinMatch */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_VARIABLE, + ], + 'Parameter itself should be start for third param passed to function call' => [ + 'testMarker' => '/* test437NestedFunctionCallWithinMatch */', + 'targets' => T_DNUMBER, + 'expectedTarget' => T_DNUMBER, + ], + + 'Parameter itself should be start for first param declared in arrow function' => [ + 'testMarker' => '/* test437NestedArrowFunctionWithinMatch */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_VARIABLE, + ], + 'Parameter itself should be start for second param declared in arrow function' => [ + 'testMarker' => '/* test437FnSecondParamWithinMatch */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_VARIABLE, + ], + ]; + + }//end dataFindStartInsideParenthesesNestedWithinMatch() + + + /** + * Test finding the start of a statement for a token within a set of parentheses within a match expressions, + * which itself is nested within parentheses. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int|string $target The token to search for after the test marker. + * @param int|string $expectedTarget Token code of the expected start of statement stack pointer. + * + * @link https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/437 + * + * @dataProvider dataFindStartInsideParenthesesNestedWithinNestedMatch + * + * @return void + */ + public function testFindStartInsideParenthesesNestedWithinNestedMatch($testMarker, $target, $expectedTarget) + { + $testToken = $this->getTargetToken($testMarker, $target); + $expected = $this->getTargetToken($testMarker, $expectedTarget); + + $found = self::$phpcsFile->findStartOfStatement($testToken); + + $this->assertSame($expected, $found); + + }//end testFindStartInsideParenthesesNestedWithinNestedMatch() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataFindStartInsideParenthesesNestedWithinNestedMatch() + { + return [ + 'Array item itself should be start for first array item' => [ + 'testMarker' => '/* test437NestedLongArrayWithinNestedMatch */', + 'targets' => T_LNUMBER, + 'expectedTarget' => T_LNUMBER, + ], + 'Array item itself should be start for second array item' => [ + 'testMarker' => '/* test437NestedLongArrayWithinNestedMatch */', + 'targets' => T_DNUMBER, + 'expectedTarget' => T_DNUMBER, + ], + 'Array item itself should be start for third array item' => [ + 'testMarker' => '/* test437NestedLongArrayWithinNestedMatch */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_VARIABLE, + ], + + 'Parameter itself should be start for first param passed to function call' => [ + 'testMarker' => '/* test437NestedFunctionCallWithinNestedMatch */', + 'targets' => T_LNUMBER, + 'expectedTarget' => T_LNUMBER, + ], + 'Parameter itself should be start for second param passed to function call' => [ + 'testMarker' => '/* test437NestedFunctionCallWithinNestedMatch */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_VARIABLE, + ], + 'Parameter itself should be start for third param passed to function call' => [ + 'testMarker' => '/* test437NestedFunctionCallWithinNestedMatch */', + 'targets' => T_DNUMBER, + 'expectedTarget' => T_DNUMBER, + ], + + 'Parameter itself should be start for first param declared in arrow function' => [ + 'testMarker' => '/* test437NestedArrowFunctionWithinNestedMatch */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_VARIABLE, + ], + 'Parameter itself should be start for second param declared in arrow function' => [ + 'testMarker' => '/* test437FnSecondParamWithinNestedMatch */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_VARIABLE, + ], + ]; + + }//end dataFindStartInsideParenthesesNestedWithinNestedMatch() + + + /** + * Test finding the start of a statement for a token within a short array within a match expressions. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * @param int|string $target The token to search for after the test marker. + * @param int|string $expectedTarget Token code of the expected start of statement stack pointer. + * + * @link https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/437 + * + * @dataProvider dataFindStartInsideShortArrayNestedWithinMatch + * + * @return void + */ + public function testFindStartInsideShortArrayNestedWithinMatch($testMarker, $target, $expectedTarget) + { + $testToken = $this->getTargetToken($testMarker, $target); + $expected = $this->getTargetToken($testMarker, $expectedTarget); + + $found = self::$phpcsFile->findStartOfStatement($testToken); + + $this->assertSame($expected, $found); + + }//end testFindStartInsideShortArrayNestedWithinMatch() + + + /** + * Data provider. + * + * @return array> + */ + public static function dataFindStartInsideShortArrayNestedWithinMatch() + { + return [ + 'Array item itself should be start for first array item' => [ + 'testMarker' => '/* test437NestedShortArrayWithinMatch */', + 'targets' => T_LNUMBER, + 'expectedTarget' => T_LNUMBER, + ], + 'Array item itself should be start for second array item' => [ + 'testMarker' => '/* test437NestedShortArrayWithinMatch */', + 'targets' => T_DNUMBER, + 'expectedTarget' => T_DNUMBER, + ], + 'Array item itself should be start for third array item' => [ + 'testMarker' => '/* test437NestedShortArrayWithinMatch */', + 'targets' => T_VARIABLE, + 'expectedTarget' => T_VARIABLE, + ], + ]; + + }//end dataFindStartInsideShortArrayNestedWithinMatch() + + }//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.inc index f69a685e..51466208 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.inc @@ -339,3 +339,18 @@ class WhitespaceAndCommentsInTypes { /* testIntersectionTypeWithWhitespaceAndComment */ public \Foo /*comment*/ & Bar $hasWhitespaceAndComment; } + +trait DNFTypes { + /* testPHP82DNFTypeStatic */ + public static (Foo&\Bar)|bool $propA; + + /* testPHP82DNFTypeReadonlyA */ + protected readonly float|(Partially\Qualified&Traversable) $propB; + + /* testPHP82DNFTypeReadonlyB */ + private readonly (namespace\Foo&Bar)|string $propC; + + /* testPHP82DNFTypeIllegalNullable */ + // Intentional fatal error - nullable operator cannot be combined with DNF. + var ?(A&\Pck\B)|bool $propD; +} diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.php index 5f2c4cdf..e100b762 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.php @@ -1075,6 +1075,58 @@ public static function dataGetMemberProperties() ], ], + 'php8.2-dnf-with-static' => [ + 'identifier' => '/* testPHP82DNFTypeStatic */', + 'expected' => [ + 'scope' => 'public', + 'scope_specified' => true, + 'is_static' => true, + 'is_readonly' => false, + 'type' => '(Foo&\Bar)|bool', + 'type_token' => -9, + 'type_end_token' => -2, + 'nullable_type' => false, + ], + ], + 'php8.2-dnf-with-readonly-1' => [ + 'identifier' => '/* testPHP82DNFTypeReadonlyA */', + 'expected' => [ + 'scope' => 'protected', + 'scope_specified' => true, + 'is_static' => false, + 'is_readonly' => true, + 'type' => 'float|(Partially\Qualified&Traversable)', + 'type_token' => -10, + 'type_end_token' => -2, + 'nullable_type' => false, + ], + ], + 'php8.2-dnf-with-readonly-2' => [ + 'identifier' => '/* testPHP82DNFTypeReadonlyB */', + 'expected' => [ + 'scope' => 'private', + 'scope_specified' => true, + 'is_static' => false, + 'is_readonly' => true, + 'type' => '(namespace\Foo&Bar)|string', + 'type_token' => -10, + 'type_end_token' => -2, + 'nullable_type' => false, + ], + ], + 'php8.2-dnf-with-illegal-nullable' => [ + 'identifier' => '/* testPHP82DNFTypeIllegalNullable */', + 'expected' => [ + 'scope' => 'public', + 'scope_specified' => false, + 'is_static' => false, + 'is_readonly' => false, + 'type' => '?(A&\Pck\B)|bool', + 'type_token' => -11, + 'type_end_token' => -2, + 'nullable_type' => true, + ], + ], ]; }//end dataGetMemberProperties() diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.inc index f6f3cd9e..1f72ccfa 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.inc @@ -280,6 +280,23 @@ function newInInitializers( \Package\TypeB $newToo = new \Package\TypeB(10, 'string'), ) {} +/* testPHP82DNFTypes */ +function dnfTypes( + #[MyAttribute] + false|(Foo&Bar)|true $obj1, + (\Boo&\Pck\Bar)|(Boo&Baz) $obj2 = new Boo() +) {} + +/* testPHP82DNFTypesWithSpreadOperatorAndReference */ +function dnfInGlobalFunctionWithSpreadAndReference((Countable&MeMe)|iterable &$paramA, true|(Foo&Bar) ...$paramB) {} + +/* testPHP82DNFTypesIllegalNullable */ +// Intentional fatal error - nullable operator cannot be combined with DNF. +$dnf_closure = function (? ( MyClassA & /*comment*/ \Package\MyClassB & \Package\MyClassC ) $var): void {}; + +/* testPHP82DNFTypesInArrow */ +$dnf_arrow = fn((Hi&Ho)|FALSE &...$range): string => $a; + /* testFunctionCallFnPHPCS353-354 */ $value = $obj->fn(true); diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.php index 83419dde..f8e7b22e 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.php @@ -2450,7 +2450,7 @@ public function testPHP8IntersectionTypes() /** - * Verify recognition of PHP8 intersection type declaration when the variable + * Verify recognition of PHP8.1 intersection type declaration when the variable * has either a spread operator or a reference. * * @return void @@ -2702,6 +2702,161 @@ public function testPHP81NewInInitializers() }//end testPHP81NewInInitializers() + /** + * Verify recognition of 8.2 DNF parameter type declarations. + * + * @return void + */ + public function testPHP82DNFTypes() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 21, + 'name' => '$obj1', + 'content' => '#[MyAttribute] + false|(Foo&Bar)|true $obj1', + 'has_attributes' => true, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => 'false|(Foo&Bar)|true', + 'type_hint_token' => 11, + 'type_hint_end_token' => 19, + 'nullable_type' => false, + 'comma_token' => 22, + ]; + $expected[1] = [ + 'token' => 41, + 'name' => '$obj2', + 'content' => '(\Boo&\Pck\Bar)|(Boo&Baz) $obj2 = new Boo()', + 'default' => 'new Boo()', + 'default_token' => 45, + 'default_equal_token' => 43, + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '(\Boo&\Pck\Bar)|(Boo&Baz)', + 'type_hint_token' => 25, + 'type_hint_end_token' => 39, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP82DNFTypes() + + + /** + * Verify recognition of PHP 8.2 DNF parameter type declarations when the variable + * has either a spread operator or a reference. + * + * @return void + */ + public function testPHP82DNFTypesWithSpreadOperatorAndReference() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 13, + 'name' => '$paramA', + 'content' => '(Countable&MeMe)|iterable &$paramA', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 12, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '(Countable&MeMe)|iterable', + 'type_hint_token' => 4, + 'type_hint_end_token' => 10, + 'nullable_type' => false, + 'comma_token' => 14, + ]; + $expected[1] = [ + 'token' => 25, + 'name' => '$paramB', + 'content' => 'true|(Foo&Bar) ...$paramB', + 'has_attributes' => false, + 'pass_by_reference' => false, + 'reference_token' => false, + 'variable_length' => true, + 'variadic_token' => 24, + 'type_hint' => 'true|(Foo&Bar)', + 'type_hint_token' => 16, + 'type_hint_end_token' => 22, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP82DNFTypesWithSpreadOperatorAndReference() + + + /** + * Verify recognition of PHP 8.2 DNF parameter type declarations using the nullability operator (not allowed). + * + * @return void + */ + public function testPHP82DNFTypesIllegalNullable() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 27, + 'name' => '$var', + 'content' => '? ( MyClassA & /*comment*/ \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' => 5, + 'type_hint_end_token' => 25, + 'nullable_type' => true, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP82DNFTypesIllegalNullable() + + + /** + * Verify recognition of PHP 8.2 DNF parameter type declarations in an arrow function. + * + * @return void + */ + public function testPHP82DNFTypesInArrow() + { + // Offsets are relative to the T_FUNCTION token. + $expected = []; + $expected[0] = [ + 'token' => 12, + 'name' => '$range', + 'content' => '(Hi&Ho)|FALSE &...$range', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 10, + 'variable_length' => true, + 'variadic_token' => 11, + 'type_hint' => '(Hi&Ho)|FALSE', + 'type_hint_token' => 2, + 'type_hint_end_token' => 8, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP82DNFTypesInArrow() + + /** * Verify handling of a closure. * diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.inc index 24d8cc69..7f572f66 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.inc @@ -170,6 +170,25 @@ function pseudoTypeTrue(): ?true {} // 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 {} +/* testPHP82DNFType */ +function hasDNFType() : bool|(Foo&Bar)|string {} + +abstract class AbstractClass { + /* testPHP82DNFTypeAbstractMethod */ + abstract protected function abstractMethodDNFType() : float|(Foo&Bar); +} + +/* testPHP82DNFTypeIllegalNullable */ +// Intentional fatal error - nullable operator cannot be combined with DNF. +function illegalNullableDNF(): ?(A&\Pck\B)|bool {} + +/* testPHP82DNFTypeClosure */ +$closure = function() : object|(namespace\Foo&Countable) {}; + +/* testPHP82DNFTypeFn */ +// Intentional fatal error - void type cannot be combined with DNF. +$arrow = fn() : null|(Partially\Qualified&Traversable)|void => do_something(); + /* testNotAFunction */ return true; @@ -190,6 +209,18 @@ $value = $obj->fn(true); /* testFunctionDeclarationNestedInTernaryPHPCS2975 */ return (!$a ? [ new class { public function b(): c {} } ] : []); +/* testClosureWithUseNoReturnType */ +$closure = function () use($a) /*comment*/ {}; + +/* testClosureWithUseNoReturnTypeIllegalUseProp */ +$closure = function () use ($this->prop){}; + +/* testClosureWithUseWithReturnType */ +$closure = function () use /*comment*/ ($a): Type {}; + +/* testClosureWithUseMultiParamWithReturnType */ +$closure = function () use ($a, &$b, $c, $d, $e, $f, $g): ?array {}; + /* testArrowFunctionLiveCoding */ // Intentional parse error. This has to be the last test in the file. $fn = fn diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.php index 85a36bb2..273ff4b2 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.php @@ -1187,6 +1187,136 @@ public function testPHP82PseudoTypeFalseAndTrue() }//end testPHP82PseudoTypeFalseAndTrue() + /** + * Verify recognition of PHP 8.2 DNF return type declaration. + * + * @return void + */ + public function testPHP82DNFType() + { + // Offsets are relative to the T_FUNCTION token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'bool|(Foo&Bar)|string', + 'return_type_token' => 8, + 'return_type_end_token' => 16, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP82DNFType() + + + /** + * Verify recognition of PHP 8.2 DNF return type declaration on an abstract method. + * + * @return void + */ + public function testPHP82DNFTypeAbstractMethod() + { + // Offsets are relative to the T_FUNCTION token. + $expected = [ + 'scope' => 'protected', + 'scope_specified' => true, + 'return_type' => 'float|(Foo&Bar)', + 'return_type_token' => 8, + 'return_type_end_token' => 14, + 'nullable_return_type' => false, + 'is_abstract' => true, + 'is_final' => false, + 'is_static' => false, + 'has_body' => false, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP82DNFTypeAbstractMethod() + + + /** + * Verify recognition of PHP 8.2 DNF return type declaration with illegal nullability. + * + * @return void + */ + public function testPHP82DNFTypeIllegalNullable() + { + // Offsets are relative to the T_FUNCTION token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '?(A&\Pck\B)|bool', + 'return_type_token' => 8, + 'return_type_end_token' => 17, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP82DNFTypeIllegalNullable() + + + /** + * Verify recognition of PHP 8.2 DNF return type declaration on a closure. + * + * @return void + */ + public function testPHP82DNFTypeClosure() + { + // Offsets are relative to the T_CLOSURE token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'object|(namespace\Foo&Countable)', + 'return_type_token' => 6, + 'return_type_end_token' => 14, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP82DNFTypeClosure() + + + /** + * Verify recognition of PHP 8.2 DNF return type declaration on an arrow function. + * + * @return void + */ + public function testPHP82DNFTypeFn() + { + // Offsets are relative to the T_FN token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'null|(Partially\Qualified&Traversable)|void', + 'return_type_token' => 6, + 'return_type_end_token' => 16, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testPHP82DNFTypeFn() + + /** * Test for incorrect tokenization of array return type declarations in PHPCS < 2.8.0. * @@ -1297,6 +1427,111 @@ public function testFunctionDeclarationNestedInTernaryPHPCS2975() }//end testFunctionDeclarationNestedInTernaryPHPCS2975() + /** + * Test handling of closure declarations with a use variable import without a return type declaration. + * + * @return void + */ + public function testClosureWithUseNoReturnType() + { + // Offsets are relative to the T_CLOSURE token. + $expected = [ + '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); + + }//end testClosureWithUseNoReturnType() + + + /** + * Test handling of closure declarations with an illegal use variable for a property import (not allowed in PHP) + * without a return type declaration. + * + * @return void + */ + public function testClosureWithUseNoReturnTypeIllegalUseProp() + { + // Offsets are relative to the T_CLOSURE token. + $expected = [ + '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); + + }//end testClosureWithUseNoReturnTypeIllegalUseProp() + + + /** + * Test handling of closure declarations with a use variable import with a return type declaration. + * + * @return void + */ + public function testClosureWithUseWithReturnType() + { + // Offsets are relative to the T_CLOSURE token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => 'Type', + 'return_type_token' => 14, + 'return_type_end_token' => 14, + 'nullable_return_type' => false, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testClosureWithUseWithReturnType() + + + /** + * Test handling of closure declarations with a use variable import with a return type declaration. + * + * @return void + */ + public function testClosureWithUseMultiParamWithReturnType() + { + // Offsets are relative to the T_CLOSURE token. + $expected = [ + 'scope' => 'public', + 'scope_specified' => false, + 'return_type' => '?array', + 'return_type_token' => 32, + 'return_type_end_token' => 32, + 'nullable_return_type' => true, + 'is_abstract' => false, + 'is_final' => false, + 'is_static' => false, + 'has_body' => true, + ]; + + $this->getMethodPropertiesTestHelper('/* '.__FUNCTION__.' */', $expected); + + }//end testClosureWithUseMultiParamWithReturnType() + + /** * Test helper. * diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/IsReferenceTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/File/IsReferenceTest.inc index d371d6ef..05af8390 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/IsReferenceTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/IsReferenceTest.inc @@ -201,6 +201,12 @@ $closure = function &($param) use ($value) {}; /* testBitwiseAndArrowFunctionInDefault */ $fn = fn( $one = E_NOTICE & E_STRICT) => 1; +/* testIntersectionIsNotReference */ +function intersect(Foo&Bar $param) {} + +/* testDNFTypeIsNotReference */ +$fn = fn((Foo&\Bar)|null /* testParamPassByReference */ &$param) => $param; + /* testTokenizerIssue1284PHPCSlt280A */ if ($foo) {} [&$a, /* testTokenizerIssue1284PHPCSlt280B */ &$b] = $c; diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/File/IsReferenceTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/File/IsReferenceTest.php index 62eb6003..5b977de7 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/File/IsReferenceTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/File/IsReferenceTest.php @@ -23,16 +23,50 @@ final class IsReferenceTest extends AbstractMethodUnitTest /** * Test that false is returned when a non-"bitwise and" token is passed. * + * @param string $testMarker Comment which precedes the test case. + * @param array $targetTokens Type of tokens to look for. + * + * @dataProvider dataNotBitwiseAndToken + * * @return void */ - public function testNotBitwiseAndToken() + public function testNotBitwiseAndToken($testMarker, $targetTokens) { - $target = $this->getTargetToken('/* testBitwiseAndA */', T_STRING); + $targetTokens[] = T_BITWISE_AND; + + $target = $this->getTargetToken($testMarker, $targetTokens); $this->assertFalse(self::$phpcsFile->isReference($target)); }//end testNotBitwiseAndToken() + /** + * Data provider. + * + * @see testNotBitwiseAndToken() + * + * @return array>> + */ + public static function dataNotBitwiseAndToken() + { + return [ + 'Not ampersand token at all' => [ + 'testMarker' => '/* testBitwiseAndA */', + 'targetTokens' => [T_STRING], + ], + 'ampersand in intersection type' => [ + 'testMarker' => '/* testIntersectionIsNotReference */', + 'targetTokens' => [T_TYPE_INTERSECTION], + ], + 'ampersand in DNF type' => [ + 'testMarker' => '/* testDNFTypeIsNotReference */', + 'targetTokens' => [T_TYPE_INTERSECTION], + ], + ]; + + }//end dataNotBitwiseAndToken() + + /** * Test correctly identifying whether a "bitwise and" token is a reference or not. * @@ -338,6 +372,10 @@ public static function dataIsReference() 'testMarker' => '/* testBitwiseAndArrowFunctionInDefault */', 'expected' => false, ], + 'reference: param pass by ref in arrow function' => [ + 'testMarker' => '/* testParamPassByReference */', + 'expected' => true, + ], 'issue-1284-short-list-directly-after-close-curly-control-structure' => [ 'testMarker' => '/* testTokenizerIssue1284PHPCSlt280A */', 'expected' => true, diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/CommentTestCase.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/CommentTestCase.php new file mode 100644 index 00000000..0dbd9771 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/CommentTestCase.php @@ -0,0 +1,117 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Comment; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; +use PHP_CodeSniffer\Util\Tokens; + +/** + * Base class for testing DocBlock comment tokenization. + * + * @covers PHP_CodeSniffer\Tokenizers\Comment + */ +abstract class CommentTestCase extends AbstractTokenizerTestCase +{ + + + /** + * Test whether the docblock opener and closer have the expected extra keys. + * + * @param string $marker The comment prefacing the target token. + * @param int $closerOffset The offset of the closer from the opener. + * @param array $expectedTags The expected tags offsets array. + * + * @dataProvider dataDocblockOpenerCloser + * + * @return void + */ + public function testDocblockOpenerCloser($marker, $closerOffset, $expectedTags) + { + $tokens = $this->phpcsFile->getTokens(); + $target = $this->getTargetToken($marker, [T_DOC_COMMENT_OPEN_TAG]); + + $opener = $tokens[$target]; + + $this->assertArrayHasKey('comment_closer', $opener, 'Comment opener: comment_closer index is not set'); + $this->assertArrayHasKey('comment_tags', $opener, 'Comment opener: comment_tags index is not set'); + + $expectedCloser = ($target + $closerOffset); + $this->assertSame($expectedCloser, $opener['comment_closer'], 'Comment opener: comment_closer not set to the expected stack pointer'); + + // Update the tags expectations. + foreach ($expectedTags as $i => $ptr) { + $expectedTags[$i] += $target; + } + + $this->assertSame($expectedTags, $opener['comment_tags'], 'Comment opener: recorded tags do not match expected tags'); + + $closer = $tokens[$opener['comment_closer']]; + + $this->assertArrayHasKey('comment_opener', $closer, 'Comment closer: comment_opener index is not set'); + $this->assertSame($target, $closer['comment_opener'], 'Comment closer: comment_opener not set to the expected stack pointer'); + + }//end testDocblockOpenerCloser() + + + /** + * Data provider. + * + * @see testDocblockOpenerCloser() + * + * @return array>> + */ + abstract public static function dataDocblockOpenerCloser(); + + + /** + * 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 and their contents to expect. + * + * @return void + */ + protected function checkTokenSequence($startPtr, array $expectedSequence) + { + $tokens = $this->phpcsFile->getTokens(); + + $sequenceKey = 0; + $sequenceCount = count($expectedSequence); + + for ($i = $startPtr; $sequenceKey < $sequenceCount; $i++, $sequenceKey++) { + $currentItem = $expectedSequence[$sequenceKey]; + $expectedCode = key($currentItem); + $expectedType = Tokens::tokenName($expectedCode); + $expectedContent = current($currentItem); + $errorMsgSuffix = PHP_EOL.'(StackPtr: '.$i.' | Position in sequence: '.$sequenceKey.' | Expected: '.$expectedType.')'; + + $this->assertSame( + $expectedCode, + $tokens[$i]['code'], + 'Token tokenized as '.Tokens::tokenName($tokens[$i]['code']).', not '.$expectedType.' (code)'.$errorMsgSuffix + ); + + $this->assertSame( + $expectedType, + $tokens[$i]['type'], + 'Token tokenized as '.$tokens[$i]['type'].', not '.$expectedType.' (type)'.$errorMsgSuffix + ); + + $this->assertSame( + $expectedContent, + $tokens[$i]['content'], + 'Token content did not match expectations'.$errorMsgSuffix + ); + }//end for + + }//end checkTokenSequence() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding1Test.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding1Test.inc new file mode 100644 index 00000000..a43c7d9b --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding1Test.inc @@ -0,0 +1,6 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Comment; + +/** + * Tests that unclosed docblocks during live coding are handled correctly. + * + * @covers PHP_CodeSniffer\Tokenizers\Comment + */ +final class LiveCoding1Test extends CommentTestCase +{ + + + /** + * Data provider. + * + * @see testDocblockOpenerCloser() + * + * @return array>> + */ + public static function dataDocblockOpenerCloser() + { + return [ + 'live coding: unclosed docblock, no blank line at end of file' => [ + 'marker' => '/* testLiveCoding */', + 'closerOffset' => 8, + 'expectedTags' => [], + ], + ]; + + }//end dataDocblockOpenerCloser() + + + /** + * Verify tokenization of the DocBlock. + * + * @phpcs:disable Squiz.Arrays.ArrayDeclaration.SpaceBeforeDoubleArrow -- Readability is better with alignment. + * + * @return void + */ + public function testLiveCoding() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Unclosed docblock, live coding.... with no blank line at end of file.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testLiveCoding() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding2Test.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding2Test.inc new file mode 100644 index 00000000..b113645b --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding2Test.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\Tokenizer\Comment; + +/** + * Tests that unclosed docblocks during live coding are handled correctly. + * + * @covers PHP_CodeSniffer\Tokenizers\Comment + */ +final class LiveCoding2Test extends CommentTestCase +{ + + + /** + * Data provider. + * + * @see testDocblockOpenerCloser() + * + * @return array>> + */ + public static function dataDocblockOpenerCloser() + { + return [ + 'live coding: unclosed docblock with blank line at end of file' => [ + 'marker' => '/* testLiveCoding */', + 'closerOffset' => 7, + 'expectedTags' => [], + ], + ]; + + }//end dataDocblockOpenerCloser() + + + /** + * Verify tokenization of the DocBlock. + * + * @phpcs:disable Squiz.Arrays.ArrayDeclaration.SpaceBeforeDoubleArrow -- Readability is better with alignment. + * + * @return void + */ + public function testLiveCoding() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Unclosed docblock, live coding.... with a blank line at end of file.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_CLOSE_TAG => ''], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testLiveCoding() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding3Test.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding3Test.inc new file mode 100644 index 00000000..9b81a434 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding3Test.inc @@ -0,0 +1,4 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Comment; + +/** + * Tests that unclosed docblocks during live coding are handled correctly. + * + * @covers PHP_CodeSniffer\Tokenizers\Comment + */ +final class LiveCoding3Test extends CommentTestCase +{ + + + /** + * Data provider. + * + * @see testDocblockOpenerCloser() + * + * @return array>> + */ + public static function dataDocblockOpenerCloser() + { + return [ + 'live coding: unclosed docblock, no contents, no blank line at end of file' => [ + 'marker' => '/* testLiveCoding */', + 'closerOffset' => 1, + 'expectedTags' => [], + ], + ]; + + }//end dataDocblockOpenerCloser() + + + /** + * Verify tokenization of the DocBlock. + * + * @phpcs:disable Squiz.Arrays.ArrayDeclaration.SpaceBeforeDoubleArrow -- Readability is better with alignment. + * + * @return void + */ + public function testLiveCoding() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_CLOSE_TAG => ''], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testLiveCoding() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding4Test.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding4Test.inc new file mode 100644 index 00000000..1561e715 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/LiveCoding4Test.inc @@ -0,0 +1,7 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Comment; + +/** + * Tests that unclosed docblocks during live coding are handled correctly. + * + * @covers PHP_CodeSniffer\Tokenizers\Comment + */ +final class LiveCoding4Test extends CommentTestCase +{ + + + /** + * Data provider. + * + * @see testDocblockOpenerCloser() + * + * @return array>> + */ + public static function dataDocblockOpenerCloser() + { + return [ + 'live coding: unclosed docblock, trailing whitespace on last line, no blank line at end of file' => [ + 'marker' => '/* testLiveCoding */', + 'closerOffset' => 15, + 'expectedTags' => [], + ], + ]; + + }//end dataDocblockOpenerCloser() + + + /** + * Verify tokenization of the DocBlock. + * + * @phpcs:disable Squiz.Arrays.ArrayDeclaration.SpaceBeforeDoubleArrow -- Readability is better with alignment. + * + * @return void + */ + public function testLiveCoding() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'The last line of this test must have trailing whitespace.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'So, be careful when saving this file!'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => ''], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testLiveCoding() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/MultiLineDocBlockTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/MultiLineDocBlockTest.inc new file mode 100644 index 00000000..f33afcd6 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/MultiLineDocBlockTest.inc @@ -0,0 +1,81 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Comment; + +/** + * Tests that multiline docblocks are tokenized correctly. + * + * @covers PHP_CodeSniffer\Tokenizers\Comment + */ +final class MultiLineDocBlockTest extends CommentTestCase +{ + + + /** + * Data provider. + * + * @see testDocblockOpenerCloser() + * + * @return array>> + */ + public static function dataDocblockOpenerCloser() + { + return [ + 'Multi line docblock: no contents' => [ + 'marker' => '/* testEmptyDocblock */', + 'closerOffset' => 3, + 'expectedTags' => [], + ], + 'Multi line docblock: variety of text and tags' => [ + 'marker' => '/* testMultilineDocblock */', + 'closerOffset' => 95, + // phpcs:ignore Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed + 'expectedTags' => [21, 29, 36, 46, 56, 63, 73, 80, 90], + ], + 'Multi line docblock: no leading stars' => [ + 'marker' => '/* testMultilineDocblockNoStars */', + 'closerOffset' => 32, + // phpcs:ignore Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed + 'expectedTags' => [10, 16, 21, 27], + ], + 'Multi line docblock: indented' => [ + 'marker' => '/* testMultilineDocblockIndented */', + 'closerOffset' => 60, + // phpcs:ignore Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed + 'expectedTags' => [21, 28, 38, 45, 55], + ], + 'Multi line docblock: opener not on own line' => [ + 'marker' => '/* testMultilineDocblockOpenerNotOnOwnLine */', + 'closerOffset' => 10, + 'expectedTags' => [], + ], + 'Multi line docblock: closer not on own line' => [ + 'marker' => '/* testMultilineDocblockCloserNotOnOwnLine */', + 'closerOffset' => 11, + 'expectedTags' => [], + ], + 'Multi line docblock: stars not aligned' => [ + 'marker' => '/* testMultilineDocblockStarsNotAligned */', + 'closerOffset' => 26, + 'expectedTags' => [], + ], + ]; + + }//end dataDocblockOpenerCloser() + + + /** + * Verify tokenization of an empty, multi-line DocBlock. + * + * @phpcs:disable Squiz.Arrays.ArrayDeclaration.SpaceBeforeDoubleArrow -- Readability is better with alignment. + * + * @return void + */ + public function testEmptyDocblock() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testEmptyDocblock() + + + /** + * Verify tokenization of a multi-line DocBlock containing all possible tokens. + * + * @return void + */ + public function testMultilineDocblock() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'This is a multi-line docblock.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'With blank lines, stars, tags, and tag descriptions.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@tagWithoutDescription'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@since'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => '10.3'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@deprecated'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => '11.5'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@requires'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'PHP 7.1 -- PHPUnit tag.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@tag-with-dashes-is-suppported'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Description.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@tag_with_underscores'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Description.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@param'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'string $p1 Description 1.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@param'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'int|false $p2 Description 2.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@return'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'void'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultilineDocblock() + + + /** + * Verify tokenization of a multi-line DocBlock with extra starts for the opener/closer and no stars on the lines between. + * + * @return void + */ + public function testMultilineDocblockNoStars() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/****'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'This is a multi-line docblock, but the lines are not marked with stars.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Then again, the opener and closer have an abundance of stars.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@since'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => '10.3'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@param'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'string $p1 Description 1.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@param'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'int|false $p2 Description 2.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@return'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'void'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '**/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultilineDocblockNoStars() + + + /** + * Verify tokenization of a multi-line, indented DocBlock. + * + * @return void + */ + public function testMultilineDocblockIndented() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'This is a multi-line indented docblock.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'With blank lines, stars, tags, and tag descriptions.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@since'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => '10.3'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@deprecated'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => '11.5'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@param'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'string $p1 Description 1.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@param'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'int|false $p2 Description 2.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@return'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'void'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultilineDocblockIndented() + + + /** + * Verify tokenization of a multi-line DocBlock, where the opener is not on its own line. + * + * @return void + */ + public function testMultilineDocblockOpenerNotOnOwnLine() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Start of description'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'description continued.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultilineDocblockOpenerNotOnOwnLine() + + + /** + * Verify tokenization of a multi-line DocBlock, where the closer is not on its own line. + * + * @return void + */ + public function testMultilineDocblockCloserNotOnOwnLine() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Start of description'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'description continued. '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultilineDocblockCloserNotOnOwnLine() + + + /** + * Verify tokenization of a multi-line DocBlock with inconsistent indentation. + * + * @return void + */ + public function testMultilineDocblockStarsNotAligned() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Start of description.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Line below this is missing a star.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Text'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Star indented.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Closer indented.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultilineDocblockStarsNotAligned() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/PhpcsAnnotationsInDocBlockTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/PhpcsAnnotationsInDocBlockTest.inc new file mode 100644 index 00000000..d74f68d2 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/PhpcsAnnotationsInDocBlockTest.inc @@ -0,0 +1,116 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Comment; + +/** + * Tests that PHPCS native annotations in docblocks are tokenized correctly. + * + * @covers PHP_CodeSniffer\Tokenizers\Comment + */ +final class PhpcsAnnotationsInDocBlockTest extends CommentTestCase +{ + + + /** + * Data provider. + * + * @see testDocblockOpenerCloser() + * + * @return array>> + */ + public static function dataDocblockOpenerCloser() + { + return [ + 'Single-line: @phpcs:ignoreFile annotation' => [ + 'marker' => '/* testSingleLineDocIgnoreFileAnnotation */', + 'closerOffset' => 3, + 'expectedTags' => [], + ], + 'Single-line: @phpcs:ignore annotation' => [ + 'marker' => '/* testSingleLineDocIgnoreAnnotation */', + 'closerOffset' => 3, + 'expectedTags' => [], + ], + 'Single-line: @phpcs:disable annotation' => [ + 'marker' => '/* testSingleLineDocDisableAnnotation */', + 'closerOffset' => 3, + 'expectedTags' => [], + ], + 'Single-line: @phpcs:enable annotation; no whitespace' => [ + 'marker' => '/* testSingleLineDocEnableAnnotationNoWhitespace */', + 'closerOffset' => 2, + 'expectedTags' => [], + ], + + 'Multi-line: @phpcs:ignoreFile at the start' => [ + 'marker' => '/* testMultiLineDocIgnoreFileAnnotationAtStart */', + 'closerOffset' => 13, + 'expectedTags' => [], + ], + 'Multi-line: @phpcs:ignore at the start' => [ + 'marker' => '/* testMultiLineDocIgnoreAnnotationAtStart */', + 'closerOffset' => 13, + 'expectedTags' => [10], + ], + 'Multi-line: @phpcs:disable at the start' => [ + 'marker' => '/* testMultiLineDocDisableAnnotationAtStart */', + 'closerOffset' => 13, + 'expectedTags' => [], + ], + 'Multi-line: @phpcs:enable at the start' => [ + 'marker' => '/* testMultiLineDocEnableAnnotationAtStart */', + 'closerOffset' => 18, + 'expectedTags' => [13], + ], + + 'Multi-line: @phpcs:ignoreFile in the middle' => [ + 'marker' => '/* testMultiLineDocIgnoreFileAnnotationInMiddle */', + 'closerOffset' => 21, + 'expectedTags' => [], + ], + 'Multi-line: @phpcs:ignore in the middle' => [ + 'marker' => '/* testMultiLineDocIgnoreAnnotationInMiddle */', + 'closerOffset' => 23, + 'expectedTags' => [5], + ], + 'Multi-line: @phpcs:disable in the middle' => [ + 'marker' => '/* testMultiLineDocDisableAnnotationInMiddle */', + 'closerOffset' => 26, + 'expectedTags' => [21], + ], + 'Multi-line: @phpcs:enable in the middle' => [ + 'marker' => '/* testMultiLineDocEnableAnnotationInMiddle */', + 'closerOffset' => 24, + 'expectedTags' => [21], + ], + + 'Multi-line: @phpcs:ignoreFile at the end' => [ + 'marker' => '/* testMultiLineDocIgnoreFileAnnotationAtEnd */', + 'closerOffset' => 16, + 'expectedTags' => [5], + ], + 'Multi-line: @phpcs:ignore at the end' => [ + 'marker' => '/* testMultiLineDocIgnoreAnnotationAtEnd */', + 'closerOffset' => 16, + 'expectedTags' => [], + ], + 'Multi-line: @phpcs:disable at the end' => [ + 'marker' => '/* testMultiLineDocDisableAnnotationAtEnd */', + 'closerOffset' => 18, + 'expectedTags' => [5], + ], + 'Multi-line: @phpcs:enable at the end' => [ + 'marker' => '/* testMultiLineDocEnableAnnotationAtEnd */', + 'closerOffset' => 16, + 'expectedTags' => [], + ], + ]; + + }//end dataDocblockOpenerCloser() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS ignoreFile annotation. + * + * @phpcs:disable Squiz.Arrays.ArrayDeclaration.SpaceBeforeDoubleArrow -- Readability is better with alignment. + * + * @return void + */ + public function testSingleLineDocIgnoreFileAnnotation() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_IGNORE_FILE => '@phpcs:ignoreFile '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testSingleLineDocIgnoreFileAnnotation() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS ignore annotation. + * + * @return void + */ + public function testSingleLineDocIgnoreAnnotation() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_IGNORE => '@phpcs:ignore Stnd.Cat.SniffName -- With reason '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testSingleLineDocIgnoreAnnotation() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS disable annotation. + * + * @return void + */ + public function testSingleLineDocDisableAnnotation() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_DISABLE => '@phpcs:disable Stnd.Cat.SniffName,Stnd.Other '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testSingleLineDocDisableAnnotation() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS enable annotation. + * + * @return void + */ + public function testSingleLineDocEnableAnnotationNoWhitespace() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_PHPCS_ENABLE => '@phpcs:enable Stnd.Cat.SniffName'], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testSingleLineDocEnableAnnotationNoWhitespace() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS ignoreFile annotation at the start. + * + * @return void + */ + public function testMultiLineDocIgnoreFileAnnotationAtStart() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_IGNORE_FILE => '@phpcs:ignoreFile'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Something.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocIgnoreFileAnnotationAtStart() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS ignore annotation at the start. + * + * @return void + */ + public function testMultiLineDocIgnoreAnnotationAtStart() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_IGNORE => '@phpcs:ignore Stnd.Cat.SniffName'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@tag'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocIgnoreAnnotationAtStart() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS disable annotation at the start. + * + * @return void + */ + public function testMultiLineDocDisableAnnotationAtStart() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_DISABLE => '@phpcs:disable Stnd.Cat.SniffName -- Ensure PHPCS annotations are also retokenized correctly.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Something.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocDisableAnnotationAtStart() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS enable annotation at the start. + * + * @return void + */ + public function testMultiLineDocEnableAnnotationAtStart() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_ENABLE => '@phpcs:enable Stnd.Cat,Stnd.Other'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@tag'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'With description.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocEnableAnnotationAtStart() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS ignoreFile annotation in the middle. + * + * @return void + */ + public function testMultiLineDocIgnoreFileAnnotationInMiddle() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Check tokenization of PHPCS annotations within docblocks.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_IGNORE_FILE => '@phpcs:ignoreFile'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Something.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocIgnoreFileAnnotationInMiddle() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS ignore annotation in the middle. + * + * @return void + */ + public function testMultiLineDocIgnoreAnnotationInMiddle() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@tagBefore'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'With Description'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_IGNORE => '@phpcs:ignore Stnd.Cat.SniffName'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Something.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocIgnoreAnnotationInMiddle() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS disable annotation in the middle. + * + * @return void + */ + public function testMultiLineDocDisableAnnotationInMiddle() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Check tokenization of PHPCS annotations within docblocks.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_DISABLE => '@phpcs:disable Stnd.Cat.SniffName -- Ensure PHPCS annotations are also retokenized correctly.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@tagAfter'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'With Description'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocDisableAnnotationInMiddle() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS enable annotation in the middle. + * + * @return void + */ + public function testMultiLineDocEnableAnnotationInMiddle() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Check tokenization of PHPCS annotations within docblocks.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_ENABLE => '@phpcs:enable Stnd.Cat,Stnd.Other'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@tagAfter'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocEnableAnnotationInMiddle() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS ignoreFile annotation at the end. + * + * @return void + */ + public function testMultiLineDocIgnoreFileAnnotationAtEnd() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@tagBefore'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_IGNORE_FILE => '@phpcs:ignoreFile'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocIgnoreFileAnnotationAtEnd() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS ignore annotation at the end. + * + * @return void + */ + public function testMultiLineDocIgnoreAnnotationAtEnd() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Check tokenization of PHPCS annotations within docblocks.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_IGNORE => '@phpcs:ignore Stnd.Cat.SniffName'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocIgnoreAnnotationAtEnd() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS disable annotation at the end. + * + * @return void + */ + public function testMultiLineDocDisableAnnotationAtEnd() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@tagBefore'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'With Description.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_DISABLE => '@phpcs:disable Stnd.Cat.SniffName -- Ensure PHPCS annotations are also retokenized correctly.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocDisableAnnotationAtEnd() + + + /** + * Verify tokenization of a single line DocBlock containing a PHPCS enable annotation at the end. + * + * @return void + */ + public function testMultiLineDocEnableAnnotationAtEnd() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Check tokenization of PHPCS annotations within docblocks.'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STAR => '*'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_PHPCS_ENABLE => '@phpcs:enable Stnd.Cat,Stnd.Other'], + [T_DOC_COMMENT_WHITESPACE => "\n"], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testMultiLineDocEnableAnnotationAtEnd() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/SingleLineDocBlockTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/SingleLineDocBlockTest.inc new file mode 100644 index 00000000..88b05ea4 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Comment/SingleLineDocBlockTest.inc @@ -0,0 +1,26 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Comment; + +/** + * Tests that single line docblocks are tokenized correctly. + * + * @covers PHP_CodeSniffer\Tokenizers\Comment + */ +final class SingleLineDocBlockTest extends CommentTestCase +{ + + + /** + * Data provider. + * + * @see testDocblockOpenerCloser() + * + * @return array>> + */ + public static function dataDocblockOpenerCloser() + { + return [ + 'Single line docblock: empty, no whitespace' => [ + 'marker' => '/* testEmptyDocblockNoWhiteSpace */', + 'closerOffset' => 1, + 'expectedTags' => [], + ], + 'Single line docblock: only whitespace' => [ + 'marker' => '/* testEmptyDocblockWithWhiteSpace */', + 'closerOffset' => 2, + 'expectedTags' => [], + ], + 'Single line docblock: just text' => [ + 'marker' => '/* testSingleLineDocblockNoTag */', + 'closerOffset' => 3, + 'expectedTags' => [], + ], + 'Single line docblock: @var type before name' => [ + 'marker' => '/* testSingleLineDocblockWithTag1 */', + 'closerOffset' => 5, + 'expectedTags' => [2], + ], + 'Single line docblock: @var name before type' => [ + 'marker' => '/* testSingleLineDocblockWithTag2 */', + 'closerOffset' => 5, + 'expectedTags' => [2], + ], + 'Single line docblock: @see with description' => [ + 'marker' => '/* testSingleLineDocblockWithTag3 */', + 'closerOffset' => 5, + 'expectedTags' => [2], + ], + ]; + + }//end dataDocblockOpenerCloser() + + + /** + * Verify an empty block comment is tokenized as T_COMMENT, not as a docblock. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * + * @return void + */ + public function testEmptyBlockCommentNoWhiteSpace() + { + $expectedSequence = [ + [T_COMMENT => '/**/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', [T_COMMENT, T_DOC_COMMENT_OPEN_TAG]); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testEmptyBlockCommentNoWhiteSpace() + + + /** + * Verify tokenization of an empty, single line DocBlock without whitespace between the opener and closer. + * + * @phpcs:disable Squiz.Arrays.ArrayDeclaration.SpaceBeforeDoubleArrow -- Readability is better with alignment. + * + * @return void + */ + public function testEmptyDocblockNoWhiteSpace() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testEmptyDocblockNoWhiteSpace() + + + /** + * Verify tokenization of an empty, single line DocBlock. + * + * @return void + */ + public function testEmptyDocblockWithWhiteSpace() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testEmptyDocblockWithWhiteSpace() + + + /** + * Verify tokenization of a single line DocBlock. + * + * @return void + */ + public function testSingleLineDocblockNoTag() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Just some text '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testSingleLineDocblockNoTag() + + + /** + * Verify tokenization of a single line DocBlock with a tag. + * + * @return void + */ + public function testSingleLineDocblockWithTag1() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@var'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => '\SomeClass[] $var '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testSingleLineDocblockWithTag1() + + + /** + * Verify tokenization of a single line DocBlock with a tag. + * + * @return void + */ + public function testSingleLineDocblockWithTag2() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@var'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => '$var \SomeClass[] '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testSingleLineDocblockWithTag2() + + + /** + * Verify tokenization of a single line DocBlock with a tag. + * + * @return void + */ + public function testSingleLineDocblockWithTag3() + { + $expectedSequence = [ + [T_DOC_COMMENT_OPEN_TAG => '/**'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_TAG => '@see'], + [T_DOC_COMMENT_WHITESPACE => ' '], + [T_DOC_COMMENT_STRING => 'Something::Else '], + [T_DOC_COMMENT_CLOSE_TAG => '*/'], + ]; + + $target = $this->getTargetToken('/* '.__FUNCTION__.' */', T_DOC_COMMENT_OPEN_TAG); + + $this->checkTokenSequence($target, $expectedSequence); + + }//end testSingleLineDocblockWithTag3() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc deleted file mode 100644 index 4f153859..00000000 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 */'], - - '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() - - - /** - * 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', - ], - - '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() - - -}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/AnonClassParenthesisOwnerTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/AnonClassParenthesisOwnerTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/AnonClassParenthesisOwnerTest.php similarity index 98% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/AnonClassParenthesisOwnerTest.php index 79eb742e..5277dade 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/AnonClassParenthesisOwnerTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class AnonClassParenthesisOwnerTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ArrayKeywordTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ArrayKeywordTest.inc similarity index 63% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ArrayKeywordTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ArrayKeywordTest.inc index ce211bda..6d8adfcb 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ArrayKeywordTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ArrayKeywordTest.inc @@ -39,3 +39,20 @@ class Bar { /* testOOPropertyType */ protected array $property; } + +class DNFTypes { + /* testOOConstDNFType */ + const (A&B)|array|(C&D) NAME = []; + + /* testOOPropertyDNFType */ + protected (A&B)|ARRAY|null $property; + + /* testFunctionDeclarationParamDNFType */ + public function name(null|array|(A&B) $param) { + /* testClosureDeclarationParamDNFType */ + $cl = function ( array|(A&B) $param) {}; + + /* testArrowDeclarationReturnDNFType */ + $arrow = fn($a): (A&B)|Array => new $a; + } +} diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ArrayKeywordTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ArrayKeywordTest.php similarity index 83% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ArrayKeywordTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ArrayKeywordTest.php index f81706c3..37528d6d 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ArrayKeywordTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ArrayKeywordTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class ArrayKeywordTest extends AbstractTokenizerTestCase { @@ -21,7 +23,6 @@ final class ArrayKeywordTest extends AbstractTokenizerTestCase * * @dataProvider dataArrayKeyword * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createTokenMap * * @return void */ @@ -35,10 +36,6 @@ public function testArrayKeyword($testMarker, $testContent='array') $this->assertSame(T_ARRAY, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_ARRAY (code)'); $this->assertSame('T_ARRAY', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_ARRAY (type)'); - $this->assertArrayHasKey('parenthesis_owner', $tokenArray, 'Parenthesis owner is not set'); - $this->assertArrayHasKey('parenthesis_opener', $tokenArray, 'Parenthesis opener is not set'); - $this->assertArrayHasKey('parenthesis_closer', $tokenArray, 'Parenthesis closer is not set'); - }//end testArrayKeyword() @@ -84,7 +81,6 @@ public static function dataArrayKeyword() * * @dataProvider dataArrayType * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createTokenMap * * @return void */ @@ -98,10 +94,6 @@ public function testArrayType($testMarker, $testContent='array') $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)'); - $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 testArrayType() @@ -131,6 +123,24 @@ public static function dataArrayType() 'OO property type' => [ 'testMarker' => '/* testOOPropertyType */', ], + + 'OO constant DNF type' => [ + 'testMarker' => '/* testOOConstDNFType */', + ], + 'OO property DNF type' => [ + 'testMarker' => '/* testOOPropertyDNFType */', + 'testContent' => 'ARRAY', + ], + 'function param DNF type' => [ + 'testMarker' => '/* testFunctionDeclarationParamDNFType */', + ], + 'closure param DNF type' => [ + 'testMarker' => '/* testClosureDeclarationParamDNFType */', + ], + 'arrow return DNF type' => [ + 'testMarker' => '/* testArrowDeclarationReturnDNFType */', + 'testContent' => 'Array', + ], ]; }//end dataArrayType() @@ -145,7 +155,6 @@ public static function dataArrayType() * * @dataProvider dataNotArrayKeyword * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createTokenMap * * @return void */ @@ -159,10 +168,6 @@ public function testNotArrayKeyword($testMarker, $testContent='array') $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)'); - $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 testNotArrayKeyword() diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AttributesTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/AttributesTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AttributesTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/AttributesTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AttributesTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/AttributesTest.php similarity index 99% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AttributesTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/AttributesTest.php index 764a9bef..24b7f079 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AttributesTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/AttributesTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class AttributesTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillEnumTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillEnumTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillEnumTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillEnumTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillEnumTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillEnumTest.php similarity index 98% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillEnumTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillEnumTest.php index 3ce48f65..d97a90b8 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillEnumTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillEnumTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class BackfillEnumTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillExplicitOctalNotationTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillExplicitOctalNotationTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillExplicitOctalNotationTest.php similarity index 97% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillExplicitOctalNotationTest.php index 609a54c0..64c82be3 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillExplicitOctalNotationTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class BackfillExplicitOctalNotationTest extends AbstractTokenizerTestCase { @@ -17,7 +19,7 @@ final class BackfillExplicitOctalNotationTest extends AbstractTokenizerTestCase * Test that explicitly-defined octal values are tokenized as a single number and not as a number and a string. * * @param string $marker The comment which prefaces the target token in the test file. - * @param string $value The expected content of the token + * @param string $value The expected content of the token. * @param int|string $nextToken The expected next token. * @param string $nextContent The expected content of the next token. * diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillFnTokenTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillFnTokenTest.inc similarity index 81% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillFnTokenTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillFnTokenTest.inc index 13f165b7..cbb7b63b 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillFnTokenTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillFnTokenTest.inc @@ -92,12 +92,42 @@ fn(array $a) : array => $a; /* testStaticReturnType */ fn(array $a) : static => $a; +/* testFalseReturnType */ +fn(array $a) : false => $a; + +/* testTrueReturnType */ +fn(array $a) : True => $a; + +/* testNullReturnType */ +fn(array $a) : null => $a; + /* testUnionParamType */ $arrowWithUnionParam = fn(int|float $param) : SomeClass => new SomeClass($param); /* testUnionReturnType */ $arrowWithUnionReturn = fn($param) : int|float => $param | 10; +/* testUnionReturnTypeWithTrue */ +$arrowWithUnionReturn = fn($param) : int|true => $param | 10; + +/* testUnionReturnTypeWithFalse */ +$arrowWithUnionReturn = fn($param) : string|FALSE => $param | 10; + +/* testIntersectionParamType */ +$arrowWithUnionParam = fn(Traversable&Countable $param) : int => (new SomeClass($param))->getValue(); + +/* testIntersectionReturnType */ +$arrowWithUnionReturn = fn($param) : \MyFoo&SomeInterface => new SomeClass($param); + +/* testDNFParamType */ +$arrowWithUnionParam = fn((Traversable&Countable)|null $param) : SomeClass => new SomeClass($param) ?? null; + +/* testDNFReturnType */ +$arrowWithUnionReturn = fn($param) : false|(\MyFoo&SomeInterface) => new \MyFoo($param) ?? false; + +/* testDNFParamTypeWithReturnByRef */ +$arrowWithParamReturnByRef = fn &((A&B)|null $param) => $param * 10; + /* testTernary */ $fn = fn($a) => $a ? /* testTernaryThen */ fn() : string => 'a' : /* testTernaryElse */ fn() : string => 'b'; diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillFnTokenTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillFnTokenTest.php similarity index 84% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillFnTokenTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillFnTokenTest.php index 8245b187..2632337a 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillFnTokenTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillFnTokenTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class BackfillFnTokenTest extends AbstractTokenizerTestCase { @@ -16,21 +18,43 @@ final class BackfillFnTokenTest extends AbstractTokenizerTestCase /** * Test simple arrow functions. * - * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * @param string $testMarker The comment prefacing the target token. + * + * @dataProvider dataSimple + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional * * @return void */ - public function testSimple() + public function testSimple($testMarker) { - foreach (['/* testStandard */', '/* testMixedCase */'] as $comment) { - $token = $this->getTargetToken($comment, T_FN); - $this->backfillHelper($token); - $this->scopePositionTestHelper($token, 5, 12); - } + $token = $this->getTargetToken($testMarker, T_FN); + $this->backfillHelper($token); + $this->scopePositionTestHelper($token, 5, 12); }//end testSimple() + /** + * Data provider. + * + * @see testSimple() + * + * @return array> + */ + public static function dataSimple() + { + return [ + 'standard' => [ + 'testMarker' => '/* testStandard */', + ], + 'mixed case' => [ + 'testMarker' => '/* testMixedCase */', + ], + ]; + + }//end dataSimple() + + /** * Test whitespace inside arrow function definitions. * @@ -370,44 +394,63 @@ public function testNamespaceOperatorInTypes() /** - * Test arrow functions that use self/parent/callable/array/static return types. + * Test arrow functions that use keyword return types. * - * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * @param string $testMarker The comment prefacing the target token. + * + * @dataProvider dataKeywordReturnTypes + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional * * @return void */ - public function testKeywordReturnTypes() + public function testKeywordReturnTypes($testMarker) { $tokens = $this->phpcsFile->getTokens(); - $testMarkers = [ - 'Self', - 'Parent', - 'Callable', - 'Array', - 'Static', - ]; - - foreach ($testMarkers as $marker) { - $token = $this->getTargetToken('/* test'.$marker.'ReturnType */', T_FN); - $this->backfillHelper($token); - - $expectedScopeOpener = ($token + 11); - $expectedScopeCloser = ($token + 14); + $token = $this->getTargetToken($testMarker, T_FN); + $this->backfillHelper($token); + $this->scopePositionTestHelper($token, 11, 14); - $this->assertSame($expectedScopeOpener, $tokens[$token]['scope_opener'], "Scope opener is not the arrow token (for $marker)"); - $this->assertSame($expectedScopeCloser, $tokens[$token]['scope_closer'], "Scope closer is not the semicolon token(for $marker)"); + }//end testKeywordReturnTypes() - $opener = $tokens[$token]['scope_opener']; - $this->assertSame($expectedScopeOpener, $tokens[$opener]['scope_opener'], "Opener scope opener is not the arrow token(for $marker)"); - $this->assertSame($expectedScopeCloser, $tokens[$opener]['scope_closer'], "Opener scope closer is not the semicolon token(for $marker)"); - $closer = $tokens[$token]['scope_closer']; - $this->assertSame($expectedScopeOpener, $tokens[$closer]['scope_opener'], "Closer scope opener is not the arrow token(for $marker)"); - $this->assertSame($expectedScopeCloser, $tokens[$closer]['scope_closer'], "Closer scope closer is not the semicolon token(for $marker)"); - } + /** + * Data provider. + * + * @see testKeywordReturnTypes() + * + * @return array> + */ + public static function dataKeywordReturnTypes() + { + return [ + 'self' => [ + 'testMarker' => '/* testSelfReturnType */', + ], + 'parent' => [ + 'testMarker' => '/* testParentReturnType */', + ], + 'callable' => [ + 'testMarker' => '/* testCallableReturnType */', + ], + 'array' => [ + 'testMarker' => '/* testArrayReturnType */', + ], + 'static' => [ + 'testMarker' => '/* testStaticReturnType */', + ], + 'false' => [ + 'testMarker' => '/* testFalseReturnType */', + ], + 'true' => [ + 'testMarker' => '/* testTrueReturnType */', + ], + 'null' => [ + 'testMarker' => '/* testNullReturnType */', + ], + ]; - }//end testKeywordReturnTypes() + }//end dataKeywordReturnTypes() /** @@ -442,6 +485,118 @@ public function testUnionReturnType() }//end testUnionReturnType() + /** + * Test arrow function with a union return type. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testUnionReturnTypeWithTrue() + { + $token = $this->getTargetToken('/* testUnionReturnTypeWithTrue */', T_FN); + $this->backfillHelper($token); + $this->scopePositionTestHelper($token, 11, 18); + + }//end testUnionReturnTypeWithTrue() + + + /** + * Test arrow function with a union return type. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testUnionReturnTypeWithFalse() + { + $token = $this->getTargetToken('/* testUnionReturnTypeWithFalse */', T_FN); + $this->backfillHelper($token); + $this->scopePositionTestHelper($token, 11, 18); + + }//end testUnionReturnTypeWithFalse() + + + /** + * Test arrow function with an intersection parameter type. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testIntersectionParamType() + { + $token = $this->getTargetToken('/* testIntersectionParamType */', T_FN); + $this->backfillHelper($token); + $this->scopePositionTestHelper($token, 13, 27); + + }//end testIntersectionParamType() + + + /** + * Test arrow function with an intersection return type. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testIntersectionReturnType() + { + $token = $this->getTargetToken('/* testIntersectionReturnType */', T_FN); + $this->backfillHelper($token); + $this->scopePositionTestHelper($token, 12, 20); + + }//end testIntersectionReturnType() + + + /** + * Test arrow function with a DNF parameter type. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testDNFParamType() + { + $token = $this->getTargetToken('/* testDNFParamType */', T_FN); + $this->backfillHelper($token); + $this->scopePositionTestHelper($token, 17, 29); + + }//end testDNFParamType() + + + /** + * Test arrow function with a DNF return type. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testDNFReturnType() + { + $token = $this->getTargetToken('/* testDNFReturnType */', T_FN); + $this->backfillHelper($token); + $this->scopePositionTestHelper($token, 16, 29); + + }//end testDNFReturnType() + + + /** + * Test arrow function which returns by reference with a DNF parameter type. + * + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testDNFParamTypeWithReturnByRef() + { + $token = $this->getTargetToken('/* testDNFParamTypeWithReturnByRef */', T_FN); + $this->backfillHelper($token); + $this->scopePositionTestHelper($token, 15, 22); + + }//end testDNFParamTypeWithReturnByRef() + + /** * Test arrow functions used in ternary operators. * diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillMatchTokenTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillMatchTokenTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillMatchTokenTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillMatchTokenTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillMatchTokenTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillMatchTokenTest.php similarity index 99% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillMatchTokenTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillMatchTokenTest.php index 9f7df354..42076c04 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillMatchTokenTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillMatchTokenTest.php @@ -8,8 +8,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; use PHP_CodeSniffer\Util\Tokens; final class BackfillMatchTokenTest extends AbstractTokenizerTestCase diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillNumericSeparatorTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillNumericSeparatorTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillNumericSeparatorTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillNumericSeparatorTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillNumericSeparatorTest.php similarity index 99% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillNumericSeparatorTest.php index b27dd8a0..53146730 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillNumericSeparatorTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillNumericSeparatorTest.php @@ -7,8 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; use PHP_CodeSniffer\Util\Tokens; final class BackfillNumericSeparatorTest extends AbstractTokenizerTestCase diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillReadonlyTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillReadonlyTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillReadonlyTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillReadonlyTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillReadonlyTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillReadonlyTest.php similarity index 99% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillReadonlyTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillReadonlyTest.php index 0befb47b..7756afaf 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BackfillReadonlyTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BackfillReadonlyTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class BackfillReadonlyTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BitwiseOrTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BitwiseOrTest.inc similarity index 89% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BitwiseOrTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BitwiseOrTest.inc index 5afc1e5b..54ff5082 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BitwiseOrTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BitwiseOrTest.inc @@ -121,6 +121,19 @@ function globalFunctionWithSpreadAndReference( string|int ...$paramB ) {} +$dnfTypes = new class { + /* testTypeUnionConstantTypeUnionBeforeDNF */ + const Foo|(A&B) UNION_BEFORE = /* testBitwiseOrOOConstDefaultValueDNF */ Foo|(A&B); + + /* testTypeUnionPropertyTypeUnionAfterDNF */ + protected (\FQN&namespace\Relative)|Partially\Qualified $union_after = /* testBitwiseOrPropertyDefaultValueDNF */ (A&B)|Foo; + + public function unionBeforeAndAfter( + /* testTypeUnionParamUnionBeforeAndAfterDNF */ + string|(Stringable&\Countable)|int $param = /* testBitwiseOrParamDefaultValueDNF */ ( CONST_A & CONST_B) | CONST_C + ): /* testTypeUnionReturnTypeUnionAfterDNF */ (A&B)|null {} +}; + /* testTypeUnionClosureParamIllegalNullable */ $closureWithParamType = function (?string|null $string) {}; diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BitwiseOrTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BitwiseOrTest.php similarity index 76% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BitwiseOrTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BitwiseOrTest.php index 8e3e264f..0648d613 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/BitwiseOrTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/BitwiseOrTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class BitwiseOrTest extends AbstractTokenizerTestCase { @@ -45,22 +47,25 @@ public function testBitwiseOr($testMarker) 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 */'], - '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 */'], + '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 */'], + 'in closure parameter default value' => ['/* testBitwiseOrClosureParamDefault */'], + 'in OO constant default value DNF-like' => ['/* testBitwiseOrOOConstDefaultValueDNF */'], + 'in property default value DNF-like' => ['/* testBitwiseOrPropertyDefaultValueDNF */'], + 'in method parameter default value DNF-like' => ['/* testBitwiseOrParamDefaultValueDNF */'], + '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() @@ -135,6 +140,10 @@ public static function dataTypeUnion() 'return type for method with fully qualified names' => ['/* testTypeUnionReturnFullyQualified */'], 'type for function parameter with reference' => ['/* testTypeUnionWithReference */'], 'type for function parameter with spread operator' => ['/* testTypeUnionWithSpreadOperator */'], + 'DNF type for OO constant, union before DNF' => ['/* testTypeUnionConstantTypeUnionBeforeDNF */'], + 'DNF type for property, union after DNF' => ['/* testTypeUnionPropertyTypeUnionAfterDNF */'], + 'DNF type for function param, union before and after DNF' => ['/* testTypeUnionParamUnionBeforeAndAfterDNF */'], + 'DNF type for function return, union after DNF with null' => ['/* testTypeUnionReturnTypeUnionAfterDNF */'], 'type for closure parameter with illegal nullable' => ['/* testTypeUnionClosureParamIllegalNullable */'], 'return type for closure' => ['/* testTypeUnionClosureReturn */'], 'type for arrow function parameter' => ['/* testTypeUnionArrowParam */'], diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ContextSensitiveKeywordsTest.inc similarity index 97% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ContextSensitiveKeywordsTest.inc index 2d471285..2825f26e 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ContextSensitiveKeywordsTest.inc @@ -235,3 +235,10 @@ $obj-> /* testKeywordAsMethodCallNameShouldBeStringStatic */ static(); $function = /* testStaticIsKeywordBeforeClosure */ static function(/* testStaticIsKeywordWhenParamType */ static $param) {}; $arrow = /* testStaticIsKeywordBeforeArrow */ static fn(): /* testStaticIsKeywordWhenReturnType */ static => 10; + +/* testKeywordAsFunctionCallNameShouldBeStringStaticDNFLookaLike */ +$obj->static((CONST_A&CONST_B)|CONST_C | $var); + +class DNF { + public /* testStaticIsKeywordPropertyModifierBeforeDNF */ static (DN&F)|null $dnfProp; +} diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ContextSensitiveKeywordsTest.php similarity index 98% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ContextSensitiveKeywordsTest.php index 51c54538..57eb3495 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ContextSensitiveKeywordsTest.php @@ -7,8 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; use PHP_CodeSniffer\Util\Tokens; final class ContextSensitiveKeywordsTest extends AbstractTokenizerTestCase @@ -135,6 +136,7 @@ public static function dataStrings() 'function call: static' => ['/* testKeywordAsFunctionCallNameShouldBeStringStatic */'], 'method call: static' => ['/* testKeywordAsMethodCallNameShouldBeStringStatic */'], + 'method call: static with dnf look a like param' => ['/* testKeywordAsFunctionCallNameShouldBeStringStaticDNFLookaLike */'], ]; }//end dataStrings() @@ -534,6 +536,10 @@ public static function dataKeywords() 'testMarker' => '/* testStaticIsKeywordWhenReturnType */', 'expectedTokenType' => 'T_STATIC', ], + 'static: property modifier before DNF' => [ + 'testMarker' => '/* testStaticIsKeywordPropertyModifierBeforeDNF */', + 'expectedTokenType' => 'T_STATIC', + ], ]; }//end dataKeywords() diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesParseError1Test.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesParseError1Test.inc new file mode 100644 index 00000000..a6cf511c --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesParseError1Test.inc @@ -0,0 +1,17 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; + +final class DNFTypesParseError1Test extends AbstractTokenizerTestCase +{ + + + /** + * Document handling for a DNF type / parse error where the last significant type specific token is an open parenthesis. + * + * @param string $testMarker The comment prefacing the target token. + * + * @dataProvider dataBrokenDNFTypeCantEndOnOpenParenthesis + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testBrokenDNFTypeCantEndOnOpenParenthesis($testMarker) + { + $tokens = $this->phpcsFile->getTokens(); + + $openPtr = $this->getTargetToken($testMarker, [T_OPEN_PARENTHESIS, T_TYPE_OPEN_PARENTHESIS], '('); + $token = $tokens[$openPtr]; + + // Verify that the open parenthesis is tokenized as a normal parenthesis. + $this->assertSame(T_OPEN_PARENTHESIS, $token['code'], 'Token tokenized as '.$token['type'].', not T_OPEN_PARENTHESIS (code)'); + $this->assertSame('T_OPEN_PARENTHESIS', $token['type'], 'Token tokenized as '.$token['type'].', not T_OPEN_PARENTHESIS (type)'); + + // Verify that the type union is still tokenized as T_BITWISE_OR as the type declaration + // is not recognized as a valid type declaration. + $unionPtr = $this->getTargetToken($testMarker, [T_BITWISE_OR, T_TYPE_UNION], '|'); + $token = $tokens[$unionPtr]; + + $this->assertSame(T_BITWISE_OR, $token['code'], 'Token tokenized as '.$token['type'].', not T_BITWISE_OR (code)'); + $this->assertSame('T_BITWISE_OR', $token['type'], 'Token tokenized as '.$token['type'].', not T_BITWISE_OR (type)'); + + }//end testBrokenDNFTypeCantEndOnOpenParenthesis() + + + /** + * Data provider. + * + * @see testBrokenDNFTypeCantEndOnOpenParenthesis() + * + * @return array> + */ + public static function dataBrokenDNFTypeCantEndOnOpenParenthesis() + { + return [ + 'OO const type' => ['/* testBrokenConstDNFTypeEndOnOpenParenthesis */'], + 'OO property type' => ['/* testBrokenPropertyDNFTypeEndOnOpenParenthesis */'], + 'Parameter type' => ['/* testBrokenParamDNFTypeEndOnOpenParenthesis */'], + 'Return type' => ['/* testBrokenReturnDNFTypeEndOnOpenParenthesis */'], + ]; + + }//end dataBrokenDNFTypeCantEndOnOpenParenthesis() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesParseError2Test.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesParseError2Test.inc new file mode 100644 index 00000000..79297582 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesParseError2Test.inc @@ -0,0 +1,48 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; +use PHP_CodeSniffer\Util\Tokens; + +final class DNFTypesParseError2Test extends AbstractTokenizerTestCase +{ + + + /** + * Document handling for a DNF type / parse error where the type declaration contains an unmatched parenthesis. + * + * @param string $testMarker The comment prefacing the target token. + * + * @dataProvider dataBrokenDNFTypeParensShouldAlwaysBeAPairMissingCloseParens + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testBrokenDNFTypeParensShouldAlwaysBeAPairMissingCloseParens($testMarker) + { + $tokens = $this->phpcsFile->getTokens(); + + // Verify that the type union is still tokenized as T_BITWISE_OR as the type declaration + // is not recognized as a valid type declaration. + $unionPtr = $this->getTargetToken($testMarker, [T_BITWISE_OR, T_TYPE_UNION], '|'); + $token = $tokens[$unionPtr]; + + $this->assertSame(T_BITWISE_OR, $token['code'], 'Token tokenized as '.$token['type'].', not T_BITWISE_OR (code)'); + $this->assertSame('T_BITWISE_OR', $token['type'], 'Token tokenized as '.$token['type'].', not T_BITWISE_OR (type)'); + + // Verify that the unmatched open parenthesis is tokenized as a normal parenthesis. + $openPtr = $this->getTargetToken($testMarker, [T_OPEN_PARENTHESIS, T_TYPE_OPEN_PARENTHESIS], '('); + $token = $tokens[$openPtr]; + + $this->assertSame(T_OPEN_PARENTHESIS, $token['code'], 'Token tokenized as '.$token['type'].', not T_OPEN_PARENTHESIS (code)'); + $this->assertSame('T_OPEN_PARENTHESIS', $token['type'], 'Token tokenized as '.$token['type'].', not T_OPEN_PARENTHESIS (type)'); + + // Verify that the type intersection is still tokenized as T_BITWISE_AND as the type declaration + // is not recognized as a valid type declaration. + $intersectPtr = $this->getTargetToken($testMarker, [T_BITWISE_AND, T_TYPE_INTERSECTION], '&'); + $token = $tokens[$intersectPtr]; + + $this->assertSame(T_BITWISE_AND, $token['code'], 'Token tokenized as '.$token['type'].', not T_BITWISE_AND (code)'); + $this->assertSame('T_BITWISE_AND', $token['type'], 'Token tokenized as '.$token['type'].', not T_BITWISE_AND (type)'); + + }//end testBrokenDNFTypeParensShouldAlwaysBeAPairMissingCloseParens() + + + /** + * Data provider. + * + * @see testBrokenDNFTypeParensShouldAlwaysBeAPairMissingCloseParens() + * + * @return array> + */ + public static function dataBrokenDNFTypeParensShouldAlwaysBeAPairMissingCloseParens() + { + return [ + 'OO const type' => ['/* testBrokenConstDNFTypeParensMissingClose */'], + 'OO property type' => ['/* testBrokenPropertyDNFTypeParensMissingClose */'], + 'Parameter type' => ['/* testBrokenParamDNFTypeParensMissingClose */'], + 'Return type' => ['/* testBrokenReturnDNFTypeParensMissingClose */'], + ]; + + }//end dataBrokenDNFTypeParensShouldAlwaysBeAPairMissingCloseParens() + + + /** + * Document handling for a DNF type / parse error where the type declaration contains an unmatched parenthesis. + * + * @param string $testMarker The comment prefacing the target token. + * + * @dataProvider dataBrokenDNFTypeParensShouldAlwaysBeAPairMissingOpenParens + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testBrokenDNFTypeParensShouldAlwaysBeAPairMissingOpenParens($testMarker) + { + $tokens = $this->phpcsFile->getTokens(); + + // Verify that the type union is still tokenized as T_BITWISE_OR as the type declaration + // is not recognized as a valid type declaration. + $unionPtr = $this->getTargetToken($testMarker, [T_BITWISE_OR, T_TYPE_UNION], '|'); + $token = $tokens[$unionPtr]; + + $this->assertSame(T_BITWISE_OR, $token['code'], 'Token tokenized as '.$token['type'].', not T_BITWISE_OR (code)'); + $this->assertSame('T_BITWISE_OR', $token['type'], 'Token tokenized as '.$token['type'].', not T_BITWISE_OR (type)'); + + // Verify that the unmatched open parenthesis is tokenized as a normal parenthesis. + $closePtr = $this->getTargetToken($testMarker, [T_CLOSE_PARENTHESIS, T_TYPE_CLOSE_PARENTHESIS], ')'); + $token = $tokens[$closePtr]; + + $this->assertSame(T_CLOSE_PARENTHESIS, $token['code'], 'Token tokenized as '.$token['type'].', not T_CLOSE_PARENTHESIS (code)'); + $this->assertSame('T_CLOSE_PARENTHESIS', $token['type'], 'Token tokenized as '.$token['type'].', not T_CLOSE_PARENTHESIS (type)'); + + // Verify that the type intersection is still tokenized as T_BITWISE_AND as the type declaration + // is not recognized as a valid type declaration. + $intersectPtr = $this->getTargetToken($testMarker, [T_BITWISE_AND, T_TYPE_INTERSECTION], '&'); + $token = $tokens[$intersectPtr]; + + $this->assertSame(T_BITWISE_AND, $token['code'], 'Token tokenized as '.$token['type'].', not T_BITWISE_AND (code)'); + $this->assertSame('T_BITWISE_AND', $token['type'], 'Token tokenized as '.$token['type'].', not T_BITWISE_AND (type)'); + + }//end testBrokenDNFTypeParensShouldAlwaysBeAPairMissingOpenParens() + + + /** + * Data provider. + * + * @see testBrokenDNFTypeParensShouldAlwaysBeAPairMissingOpenParens() + * + * @return array> + */ + public static function dataBrokenDNFTypeParensShouldAlwaysBeAPairMissingOpenParens() + { + return [ + 'OO const type' => ['/* testBrokenConstDNFTypeParensMissingOpen */'], + 'OO property type' => ['/* testBrokenPropertyDNFTypeParensMissingOpen */'], + 'Parameter type' => ['/* testBrokenParamDNFTypeParensMissingOpen */'], + 'Return type' => ['/* testBrokenReturnDNFTypeParensMissingOpen */'], + ]; + + }//end dataBrokenDNFTypeParensShouldAlwaysBeAPairMissingOpenParens() + + + /** + * Document handling for a DNF type / parse error where the type declaration contains an unmatched parenthesis, + * but also contains a set of matched parentheses. + * + * @param string $testMarker The comment prefacing the target token. + * + * @dataProvider dataBrokenDNFTypeParensShouldAlwaysBeAPairMatchedAndUnmatched + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testBrokenDNFTypeParensShouldAlwaysBeAPairMatchedAndUnmatched($testMarker) + { + $tokens = $this->phpcsFile->getTokens(); + $startPtr = $this->getTargetToken($testMarker, [T_OPEN_PARENTHESIS, T_TYPE_OPEN_PARENTHESIS], '('); + + for ($i = $startPtr; $i < $this->phpcsFile->numTokens; $i++) { + if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) { + continue; + } + + if ($tokens[$i]['code'] === T_EQUAL + || $tokens[$i]['code'] === T_VARIABLE + || $tokens[$i]['code'] === T_OPEN_CURLY_BRACKET + ) { + // Reached the end of the type. + break; + } + + $errorPrefix = 'Token tokenized as '.$tokens[$i]['type']; + + // Verify that type tokens have not been retokenized to `T_TYPE_*` tokens for broken type declarations. + switch ($tokens[$i]['content']) { + case '|': + $this->assertSame(T_BITWISE_OR, $tokens[$i]['code'], $errorPrefix.', not T_BITWISE_OR (code)'); + $this->assertSame('T_BITWISE_OR', $tokens[$i]['type'], $errorPrefix.', not T_BITWISE_OR (type)'); + break; + + case '&': + $this->assertSame(T_BITWISE_AND, $tokens[$i]['code'], $errorPrefix.', not T_BITWISE_AND (code)'); + $this->assertSame('T_BITWISE_AND', $tokens[$i]['type'], $errorPrefix.', not T_BITWISE_AND (type)'); + break; + + case '(': + // Verify that the open parenthesis is tokenized as a normal parenthesis. + $this->assertSame(T_OPEN_PARENTHESIS, $tokens[$i]['code'], $errorPrefix.', not T_OPEN_PARENTHESIS (code)'); + $this->assertSame('T_OPEN_PARENTHESIS', $tokens[$i]['type'], $errorPrefix.', not T_OPEN_PARENTHESIS (type)'); + break; + + case ')': + $this->assertSame(T_CLOSE_PARENTHESIS, $tokens[$i]['code'], $errorPrefix.', not T_CLOSE_PARENTHESIS (code)'); + $this->assertSame('T_CLOSE_PARENTHESIS', $tokens[$i]['type'], $errorPrefix.', not T_CLOSE_PARENTHESIS (type)'); + break; + + default: + break; + }//end switch + }//end for + + }//end testBrokenDNFTypeParensShouldAlwaysBeAPairMatchedAndUnmatched() + + + /** + * Data provider. + * + * @see testBrokenDNFTypeParensShouldAlwaysBeAPairMatchedAndUnmatched() + * + * @return array> + */ + public static function dataBrokenDNFTypeParensShouldAlwaysBeAPairMatchedAndUnmatched() + { + return [ + 'OO const type - missing one close parenthesis' => ['/* testBrokenConstDNFTypeParensMissingOneClose */'], + 'OO property type - missing one open parenthesis' => ['/* testBrokenPropertyDNFTypeParensMissingOneOpen */'], + 'Parameter type - missing one close parenthesis' => ['/* testBrokenParamDNFTypeParensMissingOneClose */'], + 'Return type - missing one open parenthesis' => ['/* testBrokenReturnDNFTypeParensMissingOneOpen */'], + ]; + + }//end dataBrokenDNFTypeParensShouldAlwaysBeAPairMatchedAndUnmatched() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesTest.inc new file mode 100644 index 00000000..f509c4f3 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesTest.inc @@ -0,0 +1,193 @@ + 10 ) {} + +/* testParensOwnerFor */ +for ($i =0; $i < /* testParensNoOwnerInForCondition */ ( CONST_A & CONST_B ); $i++ ); + +/* testParensOwnerMatch */ +$match = match(CONST_A & CONST_B) { + default => $a, +}; + +/* testParensOwnerArray */ +$array = array ( + 'text', + \CONST_A & \Fully\Qualified\CONST_B, + /* testParensNoOwnerFunctionCallWithAmpersandInCallable */ + do_something($a, /* testParensOwnerArrowFn */ fn($b) => $a & $b, $c), +); + +/* testParensOwnerListWithRefVars */ +list(&$a, &$b) = $array; + +/* testParensNoOwnerFunctionCallwithDNFLookALikeParam */ +$obj->static((CONST_A&CONST_B)|CONST_C | $var); + +/* testParensNoOwnerFunctionCallWithDNFLookALikeNamedParamPlain */ +callMe(label: false); + +/* testParensNoOwnerFunctionCallWithDNFLookALikeNamedParamUnion */ +callMe(label: CONST_A | CONST_B); + +/* testParensNoOwnerFunctionCallWithDNFLookALikeNamedParamIntersect */ +callMe(label: CONST_A & CONST_B); + +/* + * DNF parentheses. + */ + +abstract class DNFTypes { + /* testDNFTypeOOConstUnqualifiedClasses */ + public const (A&B)|D UNQUALIFIED = new Foo; + + /* testDNFTypeOOConstReverseModifierOrder */ + protected final const int|(Foo&Bar)|float MODIFIERS_REVERSED /* testParensNoOwnerOOConstDefaultValue */ = (E_WARNING & E_NOTICE) | E_DEPRECATED; + + const + /* testDNFTypeOOConstMulti1 */ + (A&B) | + /* testDNFTypeOOConstMulti2 */ + (C&D) | // phpcs:ignore Stnd.Cat.Sniff + /* testDNFTypeOOConstMulti3 */ + (Y&D) + | null MULTI_DNF = null; + + /* testDNFTypeOOConstNamespaceRelative */ + final protected const (namespace\Sub\NameA&namespace\Sub\NameB)|namespace\Sub\NameC NAMESPACE_RELATIVE = new namespace\Sub\NameB; + + /* testDNFTypeOOConstPartiallyQualified */ + const Partially\Qualified\NameC|(Partially\Qualified\NameA&Partially\Qualified\NameB) PARTIALLY_QUALIFIED = new Partially\Qualified\NameA; + + /* testDNFTypeOOConstFullyQualified */ + const (\Fully\Qualified\NameA&\Fully\Qualified\NameB)|\Fully\Qualified\NameC FULLY_QUALIFIED = new \Fully\Qualified\NameB(); + + /* testDNFTypePropertyUnqualifiedClasses */ + public static (Foo&Bar)|array $obj; + + /* testDNFTypePropertyReverseModifierOrder */ + static protected string|(A&B)|int $dnf /* testParensNoOwnerPropertyDefaultValue1 */ = ( E_WARNING & E_NOTICE ) | /* testParensNoOwnerPropertyDefaultValue2 */ (E_ALL & E_DEPRECATED); + + private + /* testDNFTypePropertyMultiNamespaceRelative */ + (namespace\Sub\NameA&namespace\Sub\NameB) | + /* testDNFTypePropertyMultiPartiallyQualified */ + (Partially\Qualified\NameA&Partially\Qualified\NameB) | // phpcs:ignore Stnd.Cat.Sniff + false + /* testDNFTypePropertyMultiFullyQualified */ + | (\Fully\Qualified\NameA&\Fully\Qualified\NameB) $multiDnf; + + /* testDNFTypePropertyWithReadOnlyKeyword1 */ + protected readonly (A&B) | /* testDNFTypePropertyWithReadOnlyKeyword2 */ (C&D) $readonly; + + /* testDNFTypePropertyWithStaticAndReadOnlyKeywords */ + static readonly (A&B&C)|array $staticReadonly; + + /* testDNFTypePropertyWithOnlyStaticKeyword */ + static (A&B&C)|true $onlyStaticModified; + + public function paramTypes( + /* testDNFTypeParam1WithAttribute */ + #[MyAttribute] + (\Foo&Bar)|int|float $paramA /* testParensNoOwnerParamDefaultValue */ = SOMETHING | (CONSTANT_A & CONSTANT_B), + + /* testDNFTypeParam2 */ + (Foo&\Bar) /* testDNFTypeParam3 */ |(Baz&Fop) &...$paramB, + ) { + /* testParensNoOwnerInReturnValue1 */ + return ( + /* testParensNoOwnerInReturnValue2 */ + ($a1 & $b1) | + /* testParensNoOwnerInReturnValue3 */ + ($a2 & $b2) + ) + $c; + } + + public function identifierNames( + /* testDNFTypeParamNamespaceRelative */ + (namespace\Sub\NameA&namespace\Sub\NameB)|false $paramA, + /* testDNFTypeParamPartiallyQualified */ + Partially\Qualified\NameC|(Partially\Qualified\NameA&Partially\Qualified\NameB) $paramB, + /* testDNFTypeParamFullyQualified */ + name|(\Fully\Qualified\NameA&\Fully\Qualified\NameB) $paramC, + ) {} + + public function __construct( + /* testDNFTypeConstructorPropertyPromotion1 */ + public (A&B)| /* testDNFTypeConstructorPropertyPromotion2 */ (A&D) $property + ) {} + + public function returnType()/* testDNFTypeReturnType1 */ : A|(B&D)|/* testDNFTypeReturnType2 */(B&W)|null {} + + abstract public function abstractMethod(): /* testDNFTypeAbstractMethodReturnType1 */ (X&Y) /* testDNFTypeAbstractMethodReturnType2 */ |(W&Z); + + public function identifierNamesReturnRelative( + ) : /* testDNFTypeReturnTypeNamespaceRelative */ (namespace\Sub\NameA&namespace\Sub\NameB)|namespace\Sub\NameC {} + + public function identifierNamesReturnPQ( + ) : /* testDNFTypeReturnPartiallyQualified */Partially\Qualified\NameA|(Partially\Qualified\NameB&Partially\Qualified\NameC) {} + + // Illegal type: segments which are strict subsets of others are disallowed, but that's not the concern of the tokenizer. + public function identifierNamesReturnFQ( + ) /* testDNFTypeReturnFullyQualified */ : (\Fully\Qualified\NameA&\Fully\Qualified\NameB)|\Fully\Qualified\NameB {} +} + +function globalFunctionWithSpreadAndReference( + /* testDNFTypeWithReference */ + float|(B&A) &$paramA, + /* testDNFTypeWithSpreadOperator */ + string|(B&D) ...$paramB +) {} + + +$closureWithParamType = function ( /* testDNFTypeClosureParamIllegalNullable */ ?(A&B)|bool $string) {}; + +/* testParensOwnerClosureAmpersandInDefaultValue */ +$closureWithReturnType = function ($string = NONSENSE & FAKE) /* testDNFTypeClosureReturn */ : (\Package\MyA&PackageB)|null {}; + +/* testParensOwnerArrowDNFUsedWithin */ +$arrowWithParamType = fn ( + /* testDNFTypeArrowParam */ + int|(A&B&C)|array $param, + /* testParensNoOwnerAmpersandInDefaultValue */ ?int $int = (CONSTA & CONSTB )| CONST_C +) + /* testParensNoOwnerInArrowReturnExpression */ + => ($param & $foo ) | $int; + +$arrowWithReturnType = fn ($param) : /* testDNFTypeArrowReturnType */ int|(A&B) => $param * 10; + +$arrowWithParamReturnByRef = fn &( + /* testDNFTypeArrowParamWithReturnByRef */ + (A&B)|null $param +) => $param * 10; + +function InvalidSyntaxes( + /* testDNFTypeParamIllegalUnnecessaryParens */ + (A&B) $parensNotNeeded, + + /* testDNFTypeParamIllegalIntersectUnionReversed */ + A&(B|D) $onlyIntersectAllowedWithinParensAndUnionOutside, + + /* testDNFTypeParamIllegalNestedParens */ + A|(B&(D|W)|null) $nestedParensNotAllowed, +) {} diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesTest.php new file mode 100644 index 00000000..9d7e395b --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DNFTypesTest.php @@ -0,0 +1,450 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; +use PHP_CodeSniffer\Util\Tokens; + +final class DNFTypesTest extends AbstractTokenizerTestCase +{ + + + /** + * Test that parentheses when **not** used in a type declaration are correctly tokenized. + * + * @param string $testMarker The comment prefacing the target token. + * @param bool $skipCheckInside Optional. Skip checking correct token type inside the parentheses. + * Use judiciously for combined normal + DNF tests only. + * + * @dataProvider dataNormalParentheses + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testNormalParentheses($testMarker, $skipCheckInside=false) + { + $tokens = $this->phpcsFile->getTokens(); + + $openPtr = $this->getTargetToken($testMarker, [T_OPEN_PARENTHESIS, T_TYPE_OPEN_PARENTHESIS]); + $opener = $tokens[$openPtr]; + + $this->assertSame('(', $opener['content'], 'Content of type open parenthesis is not "("'); + $this->assertSame(T_OPEN_PARENTHESIS, $opener['code'], 'Token tokenized as '.$opener['type'].', not T_OPEN_PARENTHESIS (code)'); + $this->assertSame('T_OPEN_PARENTHESIS', $opener['type'], 'Token tokenized as '.$opener['type'].', not T_OPEN_PARENTHESIS (type)'); + + $closePtr = $opener['parenthesis_closer']; + $closer = $tokens[$closePtr]; + + $this->assertSame(')', $closer['content'], 'Content of type close parenthesis is not ")"'); + $this->assertSame(T_CLOSE_PARENTHESIS, $closer['code'], 'Token tokenized as '.$closer['type'].', not T_CLOSE_PARENTHESIS (code)'); + $this->assertSame('T_CLOSE_PARENTHESIS', $closer['type'], 'Token tokenized as '.$closer['type'].', not T_CLOSE_PARENTHESIS (type)'); + + if ($skipCheckInside === false) { + for ($i = ($openPtr + 1); $i < $closePtr; $i++) { + // If there are ampersands, make sure these are tokenized as bitwise and. + if ($tokens[$i]['content'] === '&') { + $this->assertSame(T_BITWISE_AND, $tokens[$i]['code'], 'Token tokenized as '.$tokens[$i]['type'].', not T_BITWISE_AND (code)'); + $this->assertSame('T_BITWISE_AND', $tokens[$i]['type'], 'Token tokenized as '.$tokens[$i]['type'].', not T_BITWISE_AND (type)'); + } + + // If there are pipes, make sure these are tokenized as bitwise or. + if ($tokens[$i]['content'] === '|') { + $this->assertSame(T_BITWISE_OR, $tokens[$i]['code'], 'Token tokenized as '.$tokens[$i]['type'].', not T_BITWISE_OR (code)'); + $this->assertSame('T_BITWISE_OR', $tokens[$i]['type'], 'Token tokenized as '.$tokens[$i]['type'].', not T_BITWISE_OR (type)'); + } + } + } + + $before = $this->phpcsFile->findPrevious(Tokens::$emptyTokens, ($openPtr - 1), null, true); + if ($before !== false && $tokens[$before]['content'] === '|') { + $this->assertSame( + T_BITWISE_OR, + $tokens[$before]['code'], + 'Token before tokenized as '.$tokens[$before]['type'].', not T_BITWISE_OR (code)' + ); + $this->assertSame( + 'T_BITWISE_OR', + $tokens[$before]['type'], + 'Token before tokenized as '.$tokens[$before]['type'].', not T_BITWISE_OR (type)' + ); + } + + $after = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($closePtr + 1), null, true); + if ($after !== false && $tokens[$after]['content'] === '|') { + $this->assertSame( + T_BITWISE_OR, + $tokens[$after]['code'], + 'Token after tokenized as '.$tokens[$after]['type'].', not T_BITWISE_OR (code)' + ); + $this->assertSame( + 'T_BITWISE_OR', + $tokens[$after]['type'], + 'Token after tokenized as '.$tokens[$after]['type'].', not T_BITWISE_OR (type)' + ); + } + + }//end testNormalParentheses() + + + /** + * Data provider. + * + * @see testNormalParentheses() + * + * @return array> + */ + public static function dataNormalParentheses() + { + // "Owner" offsets are relative to the open parenthesis. + return [ + 'parens without owner' => [ + 'testMarker' => '/* testParensNoOwner */', + ], + 'parens without owner in ternary then' => [ + 'testMarker' => '/* testParensNoOwnerInTernary */', + ], + 'parens without owner in short ternary' => [ + 'testMarker' => '/* testParensNoOwnerInShortTernary */', + ], + 'parens with owner: function; & in default value' => [ + 'testMarker' => '/* testParensOwnerFunctionAmpersandInDefaultValue */', + ], + 'parens with owner: closure; param declared by & ref' => [ + 'testMarker' => '/* testParensOwnerClosureAmpersandParamRef */', + ], + 'parens with owner: if' => [ + 'testMarker' => '/* testParensOwnerIf */', + ], + 'parens without owner in if condition' => [ + 'testMarker' => '/* testParensNoOwnerInIfCondition */', + ], + 'parens with owner: for' => [ + 'testMarker' => '/* testParensOwnerFor */', + ], + 'parens without owner in for condition' => [ + 'testMarker' => '/* testParensNoOwnerInForCondition */', + ], + 'parens with owner: match' => [ + 'testMarker' => '/* testParensOwnerMatch */', + ], + 'parens with owner: array' => [ + 'testMarker' => '/* testParensOwnerArray */', + ], + 'parens without owner in array; function call with & in callable' => [ + 'testMarker' => '/* testParensNoOwnerFunctionCallWithAmpersandInCallable */', + ], + 'parens with owner: fn; & in return value' => [ + 'testMarker' => '/* testParensOwnerArrowFn */', + ], + 'parens with owner: list with reference vars' => [ + 'testMarker' => '/* testParensOwnerListWithRefVars */', + ], + 'parens without owner, function call with DNF look-a-like param' => [ + 'testMarker' => '/* testParensNoOwnerFunctionCallwithDNFLookALikeParam */', + ], + 'parens without owner, function call, named param' => [ + 'testMarker' => '/* testParensNoOwnerFunctionCallWithDNFLookALikeNamedParamPlain */', + ], + 'parens without owner, function call, named param + bitwise or' => [ + 'testMarker' => '/* testParensNoOwnerFunctionCallWithDNFLookALikeNamedParamUnion */', + ], + 'parens without owner, function call, named param + bitwise and' => [ + 'testMarker' => '/* testParensNoOwnerFunctionCallWithDNFLookALikeNamedParamIntersect */', + ], + + 'parens without owner in OO const default value' => [ + 'testMarker' => '/* testParensNoOwnerOOConstDefaultValue */', + ], + 'parens without owner in property default 1' => [ + 'testMarker' => '/* testParensNoOwnerPropertyDefaultValue1 */', + ], + 'parens without owner in property default 2' => [ + 'testMarker' => '/* testParensNoOwnerPropertyDefaultValue2 */', + ], + 'parens without owner in param default value' => [ + 'testMarker' => '/* testParensNoOwnerParamDefaultValue */', + ], + 'parens without owner in return statement 1' => [ + 'testMarker' => '/* testParensNoOwnerInReturnValue1 */', + ], + 'parens without owner in return statement 2' => [ + 'testMarker' => '/* testParensNoOwnerInReturnValue2 */', + ], + 'parens without owner in return statement 3' => [ + 'testMarker' => '/* testParensNoOwnerInReturnValue3 */', + ], + 'parens with owner: closure; & in default value' => [ + 'testMarker' => '/* testParensOwnerClosureAmpersandInDefaultValue */', + ], + 'parens with owner: fn; dnf used within' => [ + 'testMarker' => '/* testParensOwnerArrowDNFUsedWithin */', + 'skipCheckInside' => true, + ], + 'parens without owner: default value for param in arrow function' => [ + 'testMarker' => '/* testParensNoOwnerAmpersandInDefaultValue */', + ], + 'parens without owner in arrow function return expression' => [ + 'testMarker' => '/* testParensNoOwnerInArrowReturnExpression */', + ], + ]; + + }//end dataNormalParentheses() + + + /** + * Test that parentheses when used in a DNF type declaration are correctly tokenized. + * + * Includes verifying that: + * - the tokens between the parentheses all have a "nested_parenthesis" key. + * - all ampersands between the parentheses are tokenized as T_TYPE_INTERSECTION. + * + * @param string $testMarker The comment prefacing the target token. + * + * @dataProvider dataDNFTypeParentheses + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testDNFTypeParentheses($testMarker) + { + $tokens = $this->phpcsFile->getTokens(); + + $openPtr = $this->getTargetToken($testMarker, [T_OPEN_PARENTHESIS, T_TYPE_OPEN_PARENTHESIS]); + $opener = $tokens[$openPtr]; + + $this->assertSame('(', $opener['content'], 'Content of type open parenthesis is not "("'); + $this->assertSame(T_TYPE_OPEN_PARENTHESIS, $opener['code'], 'Token tokenized as '.$opener['type'].', not T_TYPE_OPEN_PARENTHESIS (code)'); + $this->assertSame('T_TYPE_OPEN_PARENTHESIS', $opener['type'], 'Token tokenized as '.$opener['type'].', not T_TYPE_OPEN_PARENTHESIS (type)'); + + $closePtr = $opener['parenthesis_closer']; + $closer = $tokens[$closePtr]; + + $this->assertSame(')', $closer['content'], 'Content of type close parenthesis is not ")"'); + $this->assertSame(T_TYPE_CLOSE_PARENTHESIS, $closer['code'], 'Token tokenized as '.$closer['type'].', not T_TYPE_CLOSE_PARENTHESIS (code)'); + $this->assertSame('T_TYPE_CLOSE_PARENTHESIS', $closer['type'], 'Token tokenized as '.$closer['type'].', not T_TYPE_CLOSE_PARENTHESIS (type)'); + + $intersectionCount = 0; + for ($i = ($openPtr + 1); $i < $closePtr; $i++) { + if ($tokens[$i]['content'] === '&') { + $this->assertSame( + T_TYPE_INTERSECTION, + $tokens[$i]['code'], + 'Token tokenized as '.$tokens[$i]['type'].', not T_TYPE_INTERSECTION (code)' + ); + $this->assertSame( + 'T_TYPE_INTERSECTION', + $tokens[$i]['type'], + 'Token tokenized as '.$tokens[$i]['type'].', not T_TYPE_INTERSECTION (type)' + ); + ++$intersectionCount; + } + + // Not valid, but that's irrelevant for the tokenization. + if ($tokens[$i]['content'] === '|') { + $this->assertSame(T_TYPE_UNION, $tokens[$i]['code'], 'Token tokenized as '.$tokens[$i]['type'].', not T_TYPE_UNION (code)'); + $this->assertSame('T_TYPE_UNION', $tokens[$i]['type'], 'Token tokenized as '.$tokens[$i]['type'].', not T_TYPE_UNION (type)'); + + // For the purposes of this test, presume it was intended as an intersection. + ++$intersectionCount; + } + }//end for + + $this->assertGreaterThanOrEqual(1, $intersectionCount, 'Did not find an intersection "&" between the DNF type parentheses'); + + $before = $this->phpcsFile->findPrevious(Tokens::$emptyTokens, ($openPtr - 1), null, true); + if ($before !== false && $tokens[$before]['content'] === '|') { + $this->assertSame( + T_TYPE_UNION, + $tokens[$before]['code'], + 'Token before tokenized as '.$tokens[$before]['type'].', not T_TYPE_UNION (code)' + ); + $this->assertSame( + 'T_TYPE_UNION', + $tokens[$before]['type'], + 'Token before tokenized as '.$tokens[$before]['type'].', not T_TYPE_UNION (type)' + ); + } + + // Invalid, but that's not relevant for the tokenization. + if ($before !== false && $tokens[$before]['content'] === '?') { + $this->assertSame( + T_NULLABLE, + $tokens[$before]['code'], + 'Token before tokenized as '.$tokens[$before]['type'].', not T_NULLABLE (code)' + ); + $this->assertSame( + 'T_NULLABLE', + $tokens[$before]['type'], + 'Token before tokenized as '.$tokens[$before]['type'].', not T_NULLABLE (type)' + ); + } + + $after = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($closePtr + 1), null, true); + if ($after !== false && $tokens[$after]['content'] === '|') { + $this->assertSame( + T_TYPE_UNION, + $tokens[$after]['code'], + 'Token after tokenized as '.$tokens[$after]['type'].', not T_TYPE_UNION (code)' + ); + $this->assertSame( + 'T_TYPE_UNION', + $tokens[$after]['type'], + 'Token after tokenized as '.$tokens[$after]['type'].', not T_TYPE_UNION (type)' + ); + } + + }//end testDNFTypeParentheses() + + + /** + * Data provider. + * + * @see testDNFTypeParentheses() + * + * @return array> + */ + public static function dataDNFTypeParentheses() + { + return [ + 'OO const type: unqualified classes' => [ + 'testMarker' => '/* testDNFTypeOOConstUnqualifiedClasses */', + ], + 'OO const type: modifiers in reverse order' => [ + 'testMarker' => '/* testDNFTypeOOConstReverseModifierOrder */', + ], + 'OO const type: multi-dnf part 1' => [ + 'testMarker' => '/* testDNFTypeOOConstMulti1 */', + ], + 'OO const type: multi-dnf part 2' => [ + 'testMarker' => '/* testDNFTypeOOConstMulti2 */', + ], + 'OO const type: multi-dnf part 3' => [ + 'testMarker' => '/* testDNFTypeOOConstMulti3 */', + ], + 'OO const type: namespace relative classes' => [ + 'testMarker' => '/* testDNFTypeOOConstNamespaceRelative */', + ], + 'OO const type: partially qualified classes' => [ + 'testMarker' => '/* testDNFTypeOOConstPartiallyQualified */', + ], + 'OO const type: fully qualified classes' => [ + 'testMarker' => '/* testDNFTypeOOConstFullyQualified */', + ], + + 'OO property type: unqualified classes' => [ + 'testMarker' => '/* testDNFTypePropertyUnqualifiedClasses */', + ], + 'OO property type: modifiers in reverse order' => [ + 'testMarker' => '/* testDNFTypePropertyReverseModifierOrder */', + ], + 'OO property type: multi-dnf namespace relative classes' => [ + 'testMarker' => '/* testDNFTypePropertyMultiNamespaceRelative */', + ], + 'OO property type: multi-dnf partially qualified classes' => [ + 'testMarker' => '/* testDNFTypePropertyMultiPartiallyQualified */', + ], + 'OO property type: multi-dnf fully qualified classes' => [ + 'testMarker' => '/* testDNFTypePropertyMultiFullyQualified */', + ], + + 'OO property type: multi-dnf with readonly keyword 1' => [ + 'testMarker' => '/* testDNFTypePropertyWithReadOnlyKeyword1 */', + ], + 'OO property type: multi-dnf with readonly keyword 2' => [ + 'testMarker' => '/* testDNFTypePropertyWithReadOnlyKeyword2 */', + ], + 'OO property type: with static and readonly keywords' => [ + 'testMarker' => '/* testDNFTypePropertyWithStaticAndReadOnlyKeywords */', + ], + 'OO property type: with only static keyword' => [ + 'testMarker' => '/* testDNFTypePropertyWithOnlyStaticKeyword */', + ], + 'OO method param type: first param' => [ + 'testMarker' => '/* testDNFTypeParam1WithAttribute */', + ], + 'OO method param type: second param, first DNF' => [ + 'testMarker' => '/* testDNFTypeParam2 */', + ], + 'OO method param type: second param, second DNF' => [ + 'testMarker' => '/* testDNFTypeParam3 */', + ], + 'OO method param type: namespace relative classes' => [ + 'testMarker' => '/* testDNFTypeParamNamespaceRelative */', + ], + 'OO method param type: partially qualified classes' => [ + 'testMarker' => '/* testDNFTypeParamPartiallyQualified */', + ], + 'OO method param type: fully qualified classes' => [ + 'testMarker' => '/* testDNFTypeParamFullyQualified */', + ], + 'Constructor property promotion with multi DNF 1' => [ + 'testMarker' => '/* testDNFTypeConstructorPropertyPromotion1 */', + ], + 'Constructor property promotion with multi DNF 2' => [ + 'testMarker' => '/* testDNFTypeConstructorPropertyPromotion2 */', + ], + 'OO method return type: multi DNF 1' => [ + 'testMarker' => '/* testDNFTypeReturnType1 */', + ], + 'OO method return type: multi DNF 2' => [ + 'testMarker' => '/* testDNFTypeReturnType2 */', + ], + 'OO abstract method return type: multi DNF 1' => [ + 'testMarker' => '/* testDNFTypeAbstractMethodReturnType1 */', + ], + 'OO abstract method return type: multi DNF 2' => [ + 'testMarker' => '/* testDNFTypeAbstractMethodReturnType2 */', + ], + 'OO method return type: namespace relative classes' => [ + 'testMarker' => '/* testDNFTypeReturnTypeNamespaceRelative */', + ], + 'OO method return type: partially qualified classes' => [ + 'testMarker' => '/* testDNFTypeReturnPartiallyQualified */', + ], + 'OO method return type: fully qualified classes' => [ + 'testMarker' => '/* testDNFTypeReturnFullyQualified */', + ], + 'function param type: with reference' => [ + 'testMarker' => '/* testDNFTypeWithReference */', + ], + 'function param type: with spread' => [ + 'testMarker' => '/* testDNFTypeWithSpreadOperator */', + ], + 'closure param type: with illegal nullable' => [ + 'testMarker' => '/* testDNFTypeClosureParamIllegalNullable */', + ], + 'closure return type' => [ + 'testMarker' => '/* testDNFTypeClosureReturn */', + ], + 'arrow function param type' => [ + 'testMarker' => '/* testDNFTypeArrowParam */', + ], + 'arrow function return type' => [ + 'testMarker' => '/* testDNFTypeArrowReturnType */', + ], + 'arrow function param type with return by ref' => [ + 'testMarker' => '/* testDNFTypeArrowParamWithReturnByRef */', + ], + + 'illegal syntax: unnecessary parentheses (no union)' => [ + 'testMarker' => '/* testDNFTypeParamIllegalUnnecessaryParens */', + ], + 'illegal syntax: union within parentheses, intersect outside' => [ + 'testMarker' => '/* testDNFTypeParamIllegalIntersectUnionReversed */', + ], + 'illegal syntax: nested parentheses' => [ + 'testMarker' => '/* testDNFTypeParamIllegalNestedParens */', + ], + ]; + + }//end dataDNFTypeParentheses() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DefaultKeywordTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DefaultKeywordTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DefaultKeywordTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DefaultKeywordTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DefaultKeywordTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DefaultKeywordTest.php new file mode 100644 index 00000000..c32d3375 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DefaultKeywordTest.php @@ -0,0 +1,255 @@ + + * @copyright 2020-2021 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\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; + +final class DefaultKeywordTest extends AbstractTokenizerTestCase +{ + + + /** + * Test the retokenization of the `default` keyword for match structure to `T_MATCH_DEFAULT`. + * + * Note: Cases and default structures within a match structure do *NOT* get case/default scope + * conditions, in contrast to case and default structures in switch control structures. + * + * @param string $testMarker The comment prefacing the target token. + * @param string $testContent The token content to look for. + * + * @dataProvider dataMatchDefault + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * + * @return void + */ + public function testMatchDefault($testMarker, $testContent='default') + { + $tokens = $this->phpcsFile->getTokens(); + + $token = $this->getTargetToken($testMarker, [T_MATCH_DEFAULT, T_DEFAULT, T_STRING], $testContent); + $tokenArray = $tokens[$token]; + + $this->assertSame(T_MATCH_DEFAULT, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_MATCH_DEFAULT (code)'); + $this->assertSame('T_MATCH_DEFAULT', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_MATCH_DEFAULT (type)'); + + }//end testMatchDefault() + + + /** + * Data provider. + * + * @see testMatchDefault() + * + * @return array> + */ + public static function dataMatchDefault() + { + return [ + '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' => [ + 'testMarker' => '/* testMatchDefaultWithNestedLongArrayWithClassConstantKey */', + 'testContent' => 'DEFAULT', + ], + 'match_default_with_nested_long_array_and_default_key_2' => [ + 'testMarker' => '/* testMatchDefaultWithNestedLongArrayWithClassConstantKeyLevelDown */', + 'testContent' => 'DEFAULT', + ], + 'match_default_with_nested_short_array_and_default_key' => [ + 'testMarker' => '/* testMatchDefaultWithNestedShortArrayWithClassConstantKey */', + 'testContent' => 'DEFAULT', + ], + 'match_default_with_nested_short_array_and_default_key_2' => [ + 'testMarker' => '/* testMatchDefaultWithNestedShortArrayWithClassConstantKeyLevelDown */', + 'testContent' => 'DEFAULT', + ], + 'match_default_in_long_array' => [ + 'testMarker' => '/* testMatchDefaultNestedInLongArray */', + 'testContent' => 'DEFAULT', + ], + 'match_default_in_short_array' => [ + 'testMarker' => '/* testMatchDefaultNestedInShortArray */', + 'testContent' => 'DEFAULT', + ], + ]; + + }//end dataMatchDefault() + + + /** + * Verify that the retokenization of `T_DEFAULT` tokens in match constructs, doesn't negatively + * impact the tokenization of `T_DEFAULT` tokens in switch control structures. + * + * @param string $testMarker The comment prefacing the target token. + * @param string $testContent The token content to look for. + * + * @dataProvider dataSwitchDefault + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * + * @return void + */ + public function testSwitchDefault($testMarker, $testContent='default') + { + $tokens = $this->phpcsFile->getTokens(); + + $token = $this->getTargetToken($testMarker, [T_MATCH_DEFAULT, T_DEFAULT, T_STRING], $testContent); + $tokenArray = $tokens[$token]; + + $this->assertSame(T_DEFAULT, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_DEFAULT (code)'); + $this->assertSame('T_DEFAULT', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_DEFAULT (type)'); + + }//end testSwitchDefault() + + + /** + * Data provider. + * + * @see testSwitchDefault() + * + * @return array> + */ + public static function dataSwitchDefault() + { + return [ + 'simple_switch_default' => [ + 'testMarker' => '/* testSimpleSwitchDefault */', + ], + 'simple_switch_default_with_curlies' => [ + 'testMarker' => '/* testSimpleSwitchDefaultWithCurlies */', + ], + 'switch_default_toplevel' => [ + 'testMarker' => '/* testSwitchDefault */', + ], + 'switch_default_nested_in_match_case' => [ + 'testMarker' => '/* testSwitchDefaultNestedInMatchCase */', + ], + 'switch_default_nested_in_match_default' => [ + 'testMarker' => '/* testSwitchDefaultNestedInMatchDefault */', + ], + ]; + + }//end dataSwitchDefault() + + + /** + * Verify that the retokenization of `T_DEFAULT` tokens in match constructs, doesn't negatively + * impact the tokenization of `T_STRING` tokens with the contents 'default' which aren't in + * actual fact the default keyword. + * + * @param string $testMarker The comment prefacing the target token. + * @param string $testContent The token content to look for. + * + * @dataProvider dataNotDefaultKeyword + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * + * @return void + */ + public function testNotDefaultKeyword($testMarker, $testContent='DEFAULT') + { + $tokens = $this->phpcsFile->getTokens(); + + $token = $this->getTargetToken($testMarker, [T_MATCH_DEFAULT, T_DEFAULT, T_STRING], $testContent); + $tokenArray = $tokens[$token]; + + $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 testNotDefaultKeyword() + + + /** + * Data provider. + * + * @see testNotDefaultKeyword() + * + * @return array> + */ + public static function dataNotDefaultKeyword() + { + return [ + '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' => [ + 'testMarker' => '/* testMethodDeclaration */', + 'testContent' => 'default', + ], + ]; + + }//end dataNotDefaultKeyword() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DoubleArrowTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DoubleArrowTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DoubleArrowTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DoubleArrowTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DoubleArrowTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DoubleArrowTest.php similarity index 99% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DoubleArrowTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DoubleArrowTest.php index 768ff65d..2d050d25 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DoubleArrowTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DoubleArrowTest.php @@ -9,7 +9,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class DoubleArrowTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DoubleQuotedStringTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DoubleQuotedStringTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DoubleQuotedStringTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DoubleQuotedStringTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DoubleQuotedStringTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DoubleQuotedStringTest.php similarity index 98% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DoubleQuotedStringTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DoubleQuotedStringTest.php index 83ba0aab..6fb3643f 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DoubleQuotedStringTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/DoubleQuotedStringTest.php @@ -8,7 +8,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class DoubleQuotedStringTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/EnumCaseTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/EnumCaseTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/EnumCaseTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/EnumCaseTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/EnumCaseTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/EnumCaseTest.php similarity index 89% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/EnumCaseTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/EnumCaseTest.php index f5b68507..f80e19dc 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/EnumCaseTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/EnumCaseTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class EnumCaseTest extends AbstractTokenizerTestCase { @@ -20,7 +22,6 @@ final class EnumCaseTest extends AbstractTokenizerTestCase * * @dataProvider dataEnumCases * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap * * @return void */ @@ -33,10 +34,6 @@ public function testEnumCases($testMarker) $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->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() @@ -69,7 +66,6 @@ public static function dataEnumCases() * * @dataProvider dataNotEnumCases * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize - * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap * * @return void */ @@ -82,10 +78,6 @@ public function testNotEnumCases($testMarker) $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', $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() diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/FinallyTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/FinallyTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/FinallyTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/FinallyTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/FinallyTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/FinallyTest.php similarity index 96% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/FinallyTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/FinallyTest.php index a73ac57e..d74c781a 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/FinallyTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/FinallyTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class FinallyTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/GotoLabelTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/GotoLabelTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/GotoLabelTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/GotoLabelTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/GotoLabelTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/GotoLabelTest.php similarity index 97% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/GotoLabelTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/GotoLabelTest.php index 6917e939..8e6a5f5c 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/GotoLabelTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/GotoLabelTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class GotoLabelTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/HeredocStringTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/HeredocStringTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/HeredocStringTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/HeredocStringTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/HeredocStringTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/HeredocStringTest.php similarity index 98% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/HeredocStringTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/HeredocStringTest.php index da3f361b..75f64d47 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/HeredocStringTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/HeredocStringTest.php @@ -8,7 +8,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class HeredocStringTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/NamedFunctionCallArgumentsTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/NamedFunctionCallArgumentsTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/NamedFunctionCallArgumentsTest.php similarity index 99% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/NamedFunctionCallArgumentsTest.php index 058129f5..14d0c6da 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/NamedFunctionCallArgumentsTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/NamedFunctionCallArgumentsTest.php @@ -7,8 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; use PHP_CodeSniffer\Util\Tokens; final class NamedFunctionCallArgumentsTest extends AbstractTokenizerTestCase diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/NullsafeObjectOperatorTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/NullsafeObjectOperatorTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/NullsafeObjectOperatorTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/NullsafeObjectOperatorTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/NullsafeObjectOperatorTest.php similarity index 97% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/NullsafeObjectOperatorTest.php index f97ff697..95bfc154 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/NullsafeObjectOperatorTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/NullsafeObjectOperatorTest.php @@ -7,8 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; use PHP_CodeSniffer\Util\Tokens; final class NullsafeObjectOperatorTest extends AbstractTokenizerTestCase diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/OtherContextSensitiveKeywordsTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/OtherContextSensitiveKeywordsTest.inc new file mode 100644 index 00000000..ef89caae --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/OtherContextSensitiveKeywordsTest.inc @@ -0,0 +1,247 @@ + $param->get(); + } +} diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/OtherContextSensitiveKeywordsTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/OtherContextSensitiveKeywordsTest.php new file mode 100644 index 00000000..3eff0e96 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/OtherContextSensitiveKeywordsTest.php @@ -0,0 +1,721 @@ + + * @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\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; + +/** + * 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 */'], + + '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() + + + /** + * 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', + ], + + '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', + ], + + 'false: first in union type for OO constant declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsConstUnionTypeFirst */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: first in union type for OO constant declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsConstUnionTypeFirst */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: first in union type for OO constant declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsConstUnionTypeFirst */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: first in union type for OO constant declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsConstUnionTypeFirst */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: first in union type for OO constant declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsConstUnionTypeFirst */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: middle in union type for OO constant declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsConstUnionTypeMiddle */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: middle in union type for OO constant declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsConstUnionTypeMiddle */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: middle in union type for OO constant declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsConstUnionTypeMiddle */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: middle in union type for OO constant declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsConstUnionTypeMiddle */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: middle in union type for OO constant declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsConstUnionTypeMiddle */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: last in union type for OO constant declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsConstUnionTypeLast */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: last in union type for OO constant declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsConstUnionTypeLast */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: last in union type for OO constant declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsConstUnionTypeLast */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: last in union type for OO constant declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsConstUnionTypeLast */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: last in union type for OO constant declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsConstUnionTypeLast */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: first in union type for property declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsPropertyUnionTypeFirst */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: first in union type for property declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsPropertyUnionTypeFirst */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: first in union type for property declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsPropertyUnionTypeFirst */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: first in union type for property declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsPropertyUnionTypeFirst */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: first in union type for property declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsPropertyUnionTypeFirst */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: middle in union type for property declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsPropertyUnionTypeMiddle */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: middle in union type for property declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsPropertyUnionTypeMiddle */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: middle in union type for property declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsPropertyUnionTypeMiddle */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: middle in union type for property declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsPropertyUnionTypeMiddle */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: middle in union type for property declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsPropertyUnionTypeMiddle */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: last in union type for property declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsPropertyUnionTypeLast */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: last in union type for property declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsPropertyUnionTypeLast */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: last in union type for property declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsPropertyUnionTypeLast */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: last in union type for property declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsPropertyUnionTypeLast */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: last in union type for property declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsPropertyUnionTypeLast */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: first in union type for param declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsParamUnionTypeFirst */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: first in union type for param declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsParamUnionTypeFirst */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: first in union type for param declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsParamUnionTypeFirst */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: first in union type for param declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsParamUnionTypeFirst */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: first in union type for param declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsParamUnionTypeFirst */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: middle in union type for param declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsParamUnionTypeMiddle */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: middle in union type for param declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsParamUnionTypeMiddle */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: middle in union type for param declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsParamUnionTypeMiddle */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: middle in union type for param declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsParamUnionTypeMiddle */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: middle in union type for param declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsParamUnionTypeMiddle */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: last in union type for param declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsParamUnionTypeLast */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: last in union type for param declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsParamUnionTypeLast */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: last in union type for param declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsParamUnionTypeLast */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: last in union type for param declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsParamUnionTypeLast */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: last in union type for param declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsParamUnionTypeLast */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: first in union type for return declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsReturnUnionTypeFirst */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: first in union type for return declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsReturnUnionTypeFirst */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: first in union type for return declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsReturnUnionTypeFirst */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: first in union type for return declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsReturnUnionTypeFirst */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: first in union type for return declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsReturnUnionTypeFirst */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: middle in union type for return declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsReturnUnionTypeMiddle */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: middle in union type for return declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsReturnUnionTypeMiddle */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: middle in union type for return declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsReturnUnionTypeMiddle */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: middle in union type for return declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsReturnUnionTypeMiddle */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: middle in union type for return declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsReturnUnionTypeMiddle */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: last in union type for return declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsReturnUnionTypeLast */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: last in union type for return declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsReturnUnionTypeLast */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: last in union type for return declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsReturnUnionTypeLast */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: last in union type for return declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsReturnUnionTypeLast */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: last in union type for return declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsReturnUnionTypeLast */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'self: first in intersection type for OO constant declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsConstIntersectionTypeFirst */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: first in intersection type for OO constant declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsConstIntersectionTypeFirst */', + 'expectedTokenType' => 'T_PARENT', + ], + 'self: middle in intersection type for OO constant declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsConstIntersectionTypeMiddle */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: middle in intersection type for OO constant declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsConstIntersectionTypeMiddle */', + 'expectedTokenType' => 'T_PARENT', + ], + 'self: last in intersection type for OO constant declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsConstIntersectionTypeLast */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: last in intersection type for OO constant declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsConstIntersectionTypeLast */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'self: first in intersection type for property declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsPropertyIntersectionTypeFirst */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: first in intersection type for property declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsPropertyIntersectionTypeFirst */', + 'expectedTokenType' => 'T_PARENT', + ], + 'self: middle in intersection type for property declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsPropertyIntersectionTypeMiddle */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: middle in intersection type for property declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsPropertyIntersectionTypeMiddle */', + 'expectedTokenType' => 'T_PARENT', + ], + 'self: last in intersection type for property declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsPropertyIntersectionTypeLast */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: last in intersection type for property declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsPropertyIntersectionTypeLast */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'self: first in intersection type for param declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsParamIntersectionTypeFirst */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: first in intersection type for param declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsParamIntersectionTypeFirst */', + 'expectedTokenType' => 'T_PARENT', + ], + 'self: middle in intersection type for param declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsParamIntersectionTypeMiddle */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: middle in intersection type for param declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsParamIntersectionTypeMiddle */', + 'expectedTokenType' => 'T_PARENT', + ], + 'self: last in intersection type for param declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsParamIntersectionTypeLast */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: last in intersection type for param declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsParamIntersectionTypeLast */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'self: first in intersection type for return declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsReturnIntersectionTypeFirst */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: first in intersection type for return declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsReturnIntersectionTypeFirst */', + 'expectedTokenType' => 'T_PARENT', + ], + 'self: middle in intersection type for return declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsReturnIntersectionTypeMiddle */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: middle in intersection type for return declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsReturnIntersectionTypeMiddle */', + 'expectedTokenType' => 'T_PARENT', + ], + 'self: last in intersection type for return declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsReturnIntersectionTypeLast */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: last in intersection type for return declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsReturnIntersectionTypeLast */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: DNF type in OO constant declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsConstDNFType */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: DNF type in OO constant declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsConstDNFType */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: DNF type in OO constant declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsConstDNFType */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: DNF type in OO constant declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsConstDNFType */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: DNF type in OO constant declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsConstDNFType */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: DNF type in property declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsConstDNFType */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: DNF type in property declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsConstDNFType */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: DNF type in property declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsConstDNFType */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: DNF type in property declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsConstDNFType */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: DNF type in property declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsConstDNFType */', + 'expectedTokenType' => 'T_PARENT', + ], + + 'false: DNF type in function param declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsParamDNFType */', + 'expectedTokenType' => 'T_FALSE', + ], + 'false: DNF type in function return declaration' => [ + 'testMarker' => '/* testFalseIsKeywordAsReturnDNFType */', + 'expectedTokenType' => 'T_FALSE', + ], + 'true: DNF type in function param declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsParamDNFType */', + 'expectedTokenType' => 'T_TRUE', + ], + 'true: DNF type in function return declaration' => [ + 'testMarker' => '/* testTrueIsKeywordAsReturnDNFType */', + 'expectedTokenType' => 'T_TRUE', + ], + 'null: DNF type in function param declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsParamDNFType */', + 'expectedTokenType' => 'T_NULL', + ], + 'null: DNF type in function return declaration' => [ + 'testMarker' => '/* testNullIsKeywordAsReturnDNFType */', + 'expectedTokenType' => 'T_NULL', + ], + 'self: DNF type in function param declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsParamDNFType */', + 'expectedTokenType' => 'T_SELF', + ], + 'self: DNF type in function return declaration' => [ + 'testMarker' => '/* testSelfIsKeywordAsReturnDNFType */', + 'expectedTokenType' => 'T_SELF', + ], + 'parent: DNF type in function param declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsParamDNFType */', + 'expectedTokenType' => 'T_PARENT', + ], + 'parent: DNF type in function return declaration' => [ + 'testMarker' => '/* testParentIsKeywordAsReturnDNFType */', + 'expectedTokenType' => 'T_PARENT', + ], + + ]; + + }//end dataKeywords() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ResolveSimpleTokenTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ResolveSimpleTokenTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ResolveSimpleTokenTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ResolveSimpleTokenTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ResolveSimpleTokenTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ResolveSimpleTokenTest.php similarity index 98% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ResolveSimpleTokenTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ResolveSimpleTokenTest.php index 706b1fe3..4045f775 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ResolveSimpleTokenTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ResolveSimpleTokenTest.php @@ -7,8 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; use PHP_CodeSniffer\Util\Tokens; /** diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ShortArrayTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ShortArrayTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ShortArrayTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ShortArrayTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ShortArrayTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ShortArrayTest.php similarity index 98% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ShortArrayTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ShortArrayTest.php index 18952386..06e76621 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ShortArrayTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/ShortArrayTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class ShortArrayTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/StableCommentWhitespaceTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/StableCommentWhitespaceTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/StableCommentWhitespaceTest.php similarity index 99% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/StableCommentWhitespaceTest.php index b3b19c6b..6a58ccbb 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/StableCommentWhitespaceTest.php @@ -13,8 +13,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; use PHP_CodeSniffer\Util\Tokens; final class StableCommentWhitespaceTest extends AbstractTokenizerTestCase diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/StableCommentWhitespaceWinTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/StableCommentWhitespaceWinTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/StableCommentWhitespaceWinTest.php similarity index 96% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/StableCommentWhitespaceWinTest.php index fdb7e257..44abe1d1 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/StableCommentWhitespaceWinTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/StableCommentWhitespaceWinTest.php @@ -10,8 +10,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; use PHP_CodeSniffer\Util\Tokens; final class StableCommentWhitespaceWinTest extends AbstractTokenizerTestCase diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypeIntersectionTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypeIntersectionTest.inc similarity index 88% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypeIntersectionTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypeIntersectionTest.inc index d9a68db3..53177a53 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypeIntersectionTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypeIntersectionTest.inc @@ -109,6 +109,20 @@ function globalFunctionWithSpreadAndReference( Foo&Bar ...$paramB ) {} + +$dnfTypes = new class { + /* testTypeIntersectionConstantTypeUnionBeforeDNF */ + const Foo|(A&B) UNION_BEFORE = /* testBitwiseAndOOConstDefaultValueDNF */ Foo|(A&B); + + /* testTypeIntersectionPropertyTypeUnionAfterDNF */ + protected (\FQN&namespace\Relative)|Partially\Qualified $union_after = /* testBitwiseAndPropertyDefaultValueDNF */ (A&B)|Foo; + + public function unionBeforeAndAfter( + /* testTypeIntersectionParamUnionBeforeAndAfterDNF */ + string|(Stringable&\Countable)|int $param = /* testBitwiseAndParamDefaultValueDNF */ ( CONST_A & CONST_B) | CONST_C + ): /* testTypeIntersectionReturnTypeUnionAfterDNF */ (A&B)|null {} +}; + /* testTypeIntersectionClosureParamIllegalNullable */ $closureWithParamType = function (?Foo&Bar $string) {}; diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypeIntersectionTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypeIntersectionTest.php similarity index 74% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypeIntersectionTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypeIntersectionTest.php index c719850c..99c96edc 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypeIntersectionTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypeIntersectionTest.php @@ -8,7 +8,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class TypeIntersectionTest extends AbstractTokenizerTestCase { @@ -46,24 +48,27 @@ public function testBitwiseAnd($testMarker) 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 */'], - '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 */'], + '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 */'], + 'in return statement' => ['/* testBitwiseAnd4 */'], + 'reference for function parameter' => ['/* testBitwiseAnd5 */'], + 'in OO constant default value DNF-like' => ['/* testBitwiseAndOOConstDefaultValueDNF */'], + 'in property default value DNF-like' => ['/* testBitwiseAndPropertyDefaultValueDNF */'], + 'in method parameter default value DNF-like' => ['/* testBitwiseAndParamDefaultValueDNF */'], + '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() @@ -134,6 +139,10 @@ public static function dataTypeIntersection() 'return type for method with fully qualified names' => ['/* testTypeIntersectionReturnFullyQualified */'], 'type for function parameter with reference' => ['/* testTypeIntersectionWithReference */'], 'type for function parameter with spread operator' => ['/* testTypeIntersectionWithSpreadOperator */'], + 'DNF type for OO constant, union before DNF' => ['/* testTypeIntersectionConstantTypeUnionBeforeDNF */'], + 'DNF type for property, union after DNF' => ['/* testTypeIntersectionPropertyTypeUnionAfterDNF */'], + 'DNF type for function param, union before and after DNF' => ['/* testTypeIntersectionParamUnionBeforeAndAfterDNF */'], + 'DNF type for function return, union after DNF with null' => ['/* testTypeIntersectionReturnTypeUnionAfterDNF */'], 'type for closure parameter with illegal nullable' => ['/* testTypeIntersectionClosureParamIllegalNullable */'], 'return type for closure' => ['/* testTypeIntersectionClosureReturn */'], 'type for arrow function parameter' => ['/* testTypeIntersectionArrowParam */'], diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypedConstantsTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypedConstantsTest.inc similarity index 82% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypedConstantsTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypedConstantsTest.inc index a6883139..4c6212b7 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypedConstantsTest.inc +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypedConstantsTest.inc @@ -130,3 +130,27 @@ enum EnumWithIntersectionTypedConstants { /* testEnumConstTypedIntersectFullyQualifiedPartiallyQualified */ const \Fully\Qualified&Partially\Qualified UNION_FQN_PARTIAL = new Partial\Qualified; } + +$anonClassWithDNFTypes = new class() extends Something { + /* testAnonClassConstDNFTypeNullAfter */ + const (A&B)|null DNF_OR_NULL_1 = null; + /* testAnonClassConstDNFTypeNullBefore */ + public final const NULL|(A&B) DNF_OR_NULL_2 = null; + /* testAnonClassConstDNFTypeFalseBefore */ + final const false|(C&D) DNF_OR_FALSE = false; + /* testAnonClassConstDNFTypeTrueAfter */ + private final const ( F & G ) | true DNF_OR_ARRAY = true; + /* testAnonClassConstDNFTypeTrueBeforeFalseAfter */ + public const TRUE|(SplBool&Stringable)|FALSE DNF_OR_BOOL = true; + /* testAnonClassConstDNFTypeArrayAfter */ + final protected const (Traversable&Countable)|array DNF_OR_ARRAY_1 = []; + /* testAnonClassConstDNFTypeArrayBefore */ + private const array /*comment*/ | ( Traversable /*comment*/ & Countable ) DNF_OR_ARRAY_2 = new MyClass; + /* testAnonClassConstDNFTypeInvalidNullable */ + const ? (Invalid&Fatal)|NullableNotAllowed DNF = null; + + /* testAnonClassConstDNFTypeFQNRelativePartiallyQualified */ + const (\FQN&namespace\Relative)|Partially\Qualified DNF_CLASSNAME = MyClass::getInstance(); + /* testAnonClassConstDNFTypeParentSelfStatic */ + const (parent&self)|static DNF_PARENT = parent::getInstance(); +}; diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypedConstantsTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypedConstantsTest.php similarity index 75% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypedConstantsTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypedConstantsTest.php index 0c4a9b61..60c21b9d 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypedConstantsTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/TypedConstantsTest.php @@ -12,8 +12,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; use PHP_CodeSniffer\Util\Tokens; final class TypedConstantsTest extends AbstractTokenizerTestCase @@ -109,14 +110,16 @@ public static function 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. + * @param string $testMarker The comment prefacing the target token. + * @param array $sequence The expected token sequence. * * @dataProvider dataTypedConstant * @dataProvider dataNullableTypedConstant * @dataProvider dataUnionTypedConstant * @dataProvider dataIntersectionTypedConstant + * @dataProvider dataDNFTypedConstant * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional * * @return void */ @@ -149,7 +152,7 @@ public function testTypedConstant($testMarker, array $sequence) * * @see testTypedConstant() * - * @return array> + * @return array>> */ public static function dataTypedConstant() { @@ -512,4 +515,154 @@ public static function dataIntersectionTypedConstant() }//end dataIntersectionTypedConstant() + /** + * Data provider. + * + * @see testTypedConstant() + * + * @return array> + */ + public static function dataDNFTypedConstant() + { + $data = [ + 'DNF type: null after' => [ + 'testMarker' => '/* testAnonClassConstDNFTypeNullAfter */', + 'sequence' => [ + T_TYPE_OPEN_PARENTHESIS, + T_STRING, + T_TYPE_INTERSECTION, + T_STRING, + T_TYPE_CLOSE_PARENTHESIS, + T_TYPE_UNION, + T_NULL, + ], + ], + 'DNF type: null before' => [ + 'testMarker' => '/* testAnonClassConstDNFTypeNullBefore */', + 'sequence' => [ + T_NULL, + T_TYPE_UNION, + T_TYPE_OPEN_PARENTHESIS, + T_STRING, + T_TYPE_INTERSECTION, + T_STRING, + T_TYPE_CLOSE_PARENTHESIS, + ], + ], + 'DNF type: false before' => [ + 'testMarker' => '/* testAnonClassConstDNFTypeFalseBefore */', + 'sequence' => [ + T_FALSE, + T_TYPE_UNION, + T_TYPE_OPEN_PARENTHESIS, + T_STRING, + T_TYPE_INTERSECTION, + T_STRING, + T_TYPE_CLOSE_PARENTHESIS, + ], + ], + 'DNF type: true after' => [ + 'testMarker' => '/* testAnonClassConstDNFTypeTrueAfter */', + 'sequence' => [ + T_TYPE_OPEN_PARENTHESIS, + T_STRING, + T_TYPE_INTERSECTION, + T_STRING, + T_TYPE_CLOSE_PARENTHESIS, + T_TYPE_UNION, + T_TRUE, + ], + ], + 'DNF type: true before, false after' => [ + 'testMarker' => '/* testAnonClassConstDNFTypeTrueBeforeFalseAfter */', + 'sequence' => [ + T_TRUE, + T_TYPE_UNION, + T_TYPE_OPEN_PARENTHESIS, + T_STRING, + T_TYPE_INTERSECTION, + T_STRING, + T_TYPE_CLOSE_PARENTHESIS, + T_TYPE_UNION, + T_FALSE, + ], + ], + 'DNF type: array after' => [ + 'testMarker' => '/* testAnonClassConstDNFTypeArrayAfter */', + 'sequence' => [ + T_TYPE_OPEN_PARENTHESIS, + T_STRING, + T_TYPE_INTERSECTION, + T_STRING, + T_TYPE_CLOSE_PARENTHESIS, + T_TYPE_UNION, + T_STRING, + ], + ], + 'DNF type: array before' => [ + 'testMarker' => '/* testAnonClassConstDNFTypeArrayBefore */', + 'sequence' => [ + T_STRING, + T_TYPE_UNION, + T_TYPE_OPEN_PARENTHESIS, + T_STRING, + T_TYPE_INTERSECTION, + T_STRING, + T_TYPE_CLOSE_PARENTHESIS, + ], + ], + 'DNF type: invalid nullable DNF' => [ + 'testMarker' => '/* testAnonClassConstDNFTypeInvalidNullable */', + 'sequence' => [ + T_NULLABLE, + T_TYPE_OPEN_PARENTHESIS, + T_STRING, + T_TYPE_INTERSECTION, + T_STRING, + T_TYPE_CLOSE_PARENTHESIS, + T_TYPE_UNION, + T_STRING, + ], + ], + 'DNF type: FQN/namespace relative/partially qualified names' => [ + 'testMarker' => '/* testAnonClassConstDNFTypeFQNRelativePartiallyQualified */', + 'sequence' => [ + T_TYPE_OPEN_PARENTHESIS, + T_NS_SEPARATOR, + T_STRING, + T_TYPE_INTERSECTION, + T_NAMESPACE, + T_NS_SEPARATOR, + T_STRING, + T_TYPE_CLOSE_PARENTHESIS, + T_TYPE_UNION, + T_STRING, + T_NS_SEPARATOR, + T_STRING, + ], + ], + 'DNF type: invalid self/parent/static' => [ + 'testMarker' => '/* testAnonClassConstDNFTypeParentSelfStatic */', + 'sequence' => [ + T_TYPE_OPEN_PARENTHESIS, + T_PARENT, + T_TYPE_INTERSECTION, + T_SELF, + T_TYPE_CLOSE_PARENTHESIS, + T_TYPE_UNION, + 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 dataDNFTypedConstant() + + }//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/UndoNamespacedNameSingleTokenTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/UndoNamespacedNameSingleTokenTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/UndoNamespacedNameSingleTokenTest.php similarity index 99% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/UndoNamespacedNameSingleTokenTest.php index 9e1038dc..18e22757 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/UndoNamespacedNameSingleTokenTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/UndoNamespacedNameSingleTokenTest.php @@ -17,8 +17,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\PHP; +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; use PHP_CodeSniffer\Util\Tokens; final class UndoNamespacedNameSingleTokenTest extends AbstractTokenizerTestCase diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.inc new file mode 100644 index 00000000..89031bd1 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.inc @@ -0,0 +1,185 @@ + 10 ) {} + +/* testParensOwnerFor */ +for ($i =0; $i < /* testParensNoOwnerInForCondition */ ( CONST_A & CONST_B ); $i++ ); + +/* testParensOwnerMatch */ +$match = match(CONST_A & CONST_B) { + default => $a, +}; + +/* testParensOwnerArray */ +$array = array ( + 'text', + \CONST_A & \Fully\Qualified\CONST_B, + /* testParensNoOwnerFunctionCallWithAmpersandInCallable */ + do_something($a, /* testParensOwnerArrowFn */ fn($b) => $a & $b, $c), +); + +/* testParensOwnerListWithRefVars */ +list(&$a, &$b) = $array; + +/* testParensNoOwnerFunctionCallwithDNFLookALikeParam */ +$obj->static((CONST_A&CONST_B)|CONST_C | $var); + + +/* + * DNF parentheses. + */ + +abstract class DNFTypes { + /* testDNFTypeOOConstUnqualifiedClasses */ + public const (A&B)|D UNQUALIFIED = new Foo; + + /* testDNFTypeOOConstReverseModifierOrder */ + protected final const int|(Foo&Bar)|float MODIFIERS_REVERSED /* testParensNoOwnerOOConstDefaultValue */ = (E_WARNING & E_NOTICE) | E_DEPRECATED; + + const + /* testDNFTypeOOConstMulti1 */ + (A&B) | + /* testDNFTypeOOConstMulti2 */ + (C&D) | // phpcs:ignore Stnd.Cat.Sniff + /* testDNFTypeOOConstMulti3 */ + (Y&D) + | null MULTI_DNF = null; + + /* testDNFTypeOOConstNamespaceRelative */ + final protected const (namespace\Sub\NameA&namespace\Sub\NameB)|namespace\Sub\NameC NAMESPACE_RELATIVE = new namespace\Sub\NameB; + + /* testDNFTypeOOConstPartiallyQualified */ + const Partially\Qualified\NameC|(Partially\Qualified\NameA&Partially\Qualified\NameB) PARTIALLY_QUALIFIED = new Partially\Qualified\NameA; + + /* testDNFTypeOOConstFullyQualified */ + const (\Fully\Qualified\NameA&\Fully\Qualified\NameB)|\Fully\Qualified\NameC FULLY_QUALIFIED = new \Fully\Qualified\NameB(); + + /* testDNFTypePropertyUnqualifiedClasses */ + public static (Foo&Bar)|array $obj; + + /* testDNFTypePropertyReverseModifierOrder */ + static protected string|(A&B)|int $dnf /* testParensNoOwnerPropertyDefaultValue1 */ = ( E_WARNING & E_NOTICE ) | /* testParensNoOwnerPropertyDefaultValue2 */ (E_ALL & E_DEPRECATED); + + private + /* testDNFTypePropertyMultiNamespaceRelative */ + (namespace\Sub\NameA&namespace\Sub\NameB) | + /* testDNFTypePropertyMultiPartiallyQualified */ + (Partially\Qualified\NameA&Partially\Qualified\NameB) | // phpcs:ignore Stnd.Cat.Sniff + false + /* testDNFTypePropertyMultiFullyQualified */ + | (\Fully\Qualified\NameA&\Fully\Qualified\NameB) $multiDnf; + + /* testDNFTypePropertyWithReadOnlyKeyword1 */ + protected readonly (A&B) | /* testDNFTypePropertyWithReadOnlyKeyword2 */ (C&D) $readonly; + + /* testDNFTypePropertyWithStaticAndReadOnlyKeywords */ + static readonly (A&B&C)|array $staticReadonly; + + /* testDNFTypePropertyWithOnlyStaticKeyword */ + static (A&B&C)|true $onlyStaticModified; + + public function paramTypes( + /* testDNFTypeParam1WithAttribute */ + #[MyAttribute] + (\Foo&Bar)|int|float $paramA /* testParensNoOwnerParamDefaultValue */ = SOMETHING | (CONSTANT_A & CONSTANT_B), + + /* testDNFTypeParam2 */ + (Foo&\Bar) /* testDNFTypeParam3 */ |(Baz&Fop) &...$paramB, + ) { + /* testParensNoOwnerInReturnValue1 */ + return ( + /* testParensNoOwnerInReturnValue2 */ + ($a1 & $b1) | + /* testParensNoOwnerInReturnValue3 */ + ($a2 & $b2) + ) + $c; + } + + public function identifierNames( + /* testDNFTypeParamNamespaceRelative */ + (namespace\Sub\NameA&namespace\Sub\NameB)|false $paramA, + /* testDNFTypeParamPartiallyQualified */ + Partially\Qualified\NameC|(Partially\Qualified\NameA&Partially\Qualified\NameB) $paramB, + /* testDNFTypeParamFullyQualified */ + name|(\Fully\Qualified\NameA&\Fully\Qualified\NameB) $paramC, + ) {} + + public function __construct( + /* testDNFTypeConstructorPropertyPromotion1 */ + public (A&B)| /* testDNFTypeConstructorPropertyPromotion2 */ (A&D) $property + ) {} + + public function returnType()/* testDNFTypeReturnType1 */ : A|(B&D)|/* testDNFTypeReturnType2 */(B&W)|null {} + + abstract public function abstractMethod(): /* testDNFTypeAbstractMethodReturnType1 */ (X&Y) /* testDNFTypeAbstractMethodReturnType2 */ |(W&Z); + + public function identifierNamesReturnRelative( + ) : /* testDNFTypeReturnTypeNamespaceRelative */ (namespace\Sub\NameA&namespace\Sub\NameB)|namespace\Sub\NameC {} + + public function identifierNamesReturnPQ( + ) : /* testDNFTypeReturnPartiallyQualified */Partially\Qualified\NameA|(Partially\Qualified\NameB&Partially\Qualified\NameC) {} + + // Illegal type: segments which are strict subsets of others are disallowed, but that's not the concern of the tokenizer. + public function identifierNamesReturnFQ( + ) /* testDNFTypeReturnFullyQualified */ : (\Fully\Qualified\NameA&\Fully\Qualified\NameB)|\Fully\Qualified\NameB {} +} + +function globalFunctionWithSpreadAndReference( + /* testDNFTypeWithReference */ + float|(B&A) &$paramA, + /* testDNFTypeWithSpreadOperator */ + string|(B&D) ...$paramB +) {} + + +$closureWithParamType = function ( /* testDNFTypeClosureParamIllegalNullable */ ?(A&B)|bool $string) {}; + +/* testParensOwnerClosureAmpersandInDefaultValue */ +$closureWithReturnType = function ($string = NONSENSE & FAKE) /* testDNFTypeClosureReturn */ : (\Package\MyA&PackageB)|null {}; + +/* testParensOwnerArrowDNFUsedWithin */ +$arrowWithParamType = fn ( + /* testDNFTypeArrowParam */ + int|(A&B&C)|array $param, + /* testParensNoOwnerAmpersandInDefaultValue */ ?int $int = (CONSTA & CONSTB )| CONST_C +) + /* testParensNoOwnerInArrowReturnExpression */ + => ($param & $foo ) | $int; + +$arrowWithReturnType = fn ($param) : /* testDNFTypeArrowReturnType */ int|(A&B) => $param * 10; + +$arrowWithParamReturnByRef = fn &( + /* testDNFTypeArrowParamWithReturnByRef */ + (A&B)|null $param +) => $param * 10; + +function InvalidSyntaxes( + /* testDNFTypeParamIllegalUnnecessaryParens */ + (A&B) $parensNotNeeded, + + /* testDNFTypeParamIllegalIntersectUnionReversed */ + A&(B|D) $onlyIntersectAllowedWithinParensAndUnionOutside, + + /* testDNFTypeParamIllegalNestedParens */ + A|(B&(D|W)|null) $nestedParensNotAllowed, +) {} diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.php new file mode 100644 index 00000000..7198690d --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateParenthesisNestingMapDNFTypesTest.php @@ -0,0 +1,375 @@ + + * @copyright 2024 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Tokenizer; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; + +final class CreateParenthesisNestingMapDNFTypesTest extends AbstractTokenizerTestCase +{ + + + /** + * Test that parentheses when **not** used in a type declaration are correctly tokenized. + * + * @param string $testMarker The comment prefacing the target token. + * @param int|false $owner Optional. The parentheses owner or false when no parentheses owner is expected. + * + * @dataProvider dataNormalParentheses + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createParenthesisNestingMap + * + * @return void + */ + public function testNormalParentheses($testMarker, $owner=false) + { + $tokens = $this->phpcsFile->getTokens(); + + $openPtr = $this->getTargetToken($testMarker, [T_OPEN_PARENTHESIS, T_TYPE_OPEN_PARENTHESIS]); + $opener = $tokens[$openPtr]; + + // Make sure we're looking at the right token. + $this->assertSame(T_OPEN_PARENTHESIS, $opener['code'], 'Token tokenized as '.$opener['type'].', not T_OPEN_PARENTHESIS (code)'); + + if ($owner !== false) { + $this->assertArrayHasKey('parenthesis_owner', $opener, 'Parenthesis owner is not set'); + $this->assertSame(($openPtr + $owner), $opener['parenthesis_owner'], 'Opener parenthesis owner is not the expected token'); + } else { + $this->assertArrayNotHasKey('parenthesis_owner', $opener, 'Parenthesis owner is set'); + } + + $this->assertArrayHasKey('parenthesis_opener', $opener, 'Parenthesis opener is not set'); + $this->assertArrayHasKey('parenthesis_closer', $opener, 'Parenthesis closer is not set'); + $this->assertSame($openPtr, $opener['parenthesis_opener'], 'Parenthesis opener is not the expected token'); + + $closePtr = $opener['parenthesis_closer']; + $closer = $tokens[$closePtr]; + + // Make sure we're looking at the right token. + $this->assertSame(T_CLOSE_PARENTHESIS, $closer['code'], 'Token tokenized as '.$closer['type'].', not T_CLOSE_PARENTHESIS (code)'); + + if ($owner !== false) { + $this->assertArrayHasKey('parenthesis_owner', $closer, 'Parenthesis owner is not set'); + $this->assertSame(($openPtr + $owner), $closer['parenthesis_owner'], 'Closer parenthesis owner is not the expected token'); + } else { + $this->assertArrayNotHasKey('parenthesis_owner', $closer, 'Parenthesis owner is set'); + } + + $this->assertArrayHasKey('parenthesis_opener', $closer, 'Parenthesis opener is not set'); + $this->assertArrayHasKey('parenthesis_closer', $closer, 'Parenthesis closer is not set'); + $this->assertSame($closePtr, $closer['parenthesis_closer'], 'Parenthesis closer is not the expected token'); + + for ($i = ($openPtr + 1); $i < $closePtr; $i++) { + $this->assertArrayHasKey('nested_parenthesis', $tokens[$i], "Nested parenthesis key not set on token $i ({$tokens[$i]['type']})"); + $this->assertArrayHasKey($openPtr, $tokens[$i]['nested_parenthesis'], 'Nested parenthesis is missing target parentheses set'); + $this->assertSame($closePtr, $tokens[$i]['nested_parenthesis'][$openPtr], 'Nested parenthesis closer not set correctly'); + } + + }//end testNormalParentheses() + + + /** + * Data provider. + * + * @see testNormalParentheses() + * + * @return array> + */ + public static function dataNormalParentheses() + { + // "Owner" offsets are relative to the open parenthesis. + return [ + 'parens without owner' => [ + 'testMarker' => '/* testParensNoOwner */', + ], + 'parens without owner in ternary then' => [ + 'testMarker' => '/* testParensNoOwnerInTernary */', + ], + 'parens without owner in short ternary' => [ + 'testMarker' => '/* testParensNoOwnerInShortTernary */', + ], + 'parens with owner: function; & in default value' => [ + 'testMarker' => '/* testParensOwnerFunctionAmpersandInDefaultValue */', + 'owner' => -3, + ], + 'parens with owner: closure; param declared by & ref' => [ + 'testMarker' => '/* testParensOwnerClosureAmpersandParamRef */', + 'owner' => -1, + ], + 'parens with owner: if' => [ + 'testMarker' => '/* testParensOwnerIf */', + 'owner' => -2, + ], + 'parens without owner in if condition' => [ + 'testMarker' => '/* testParensNoOwnerInIfCondition */', + ], + 'parens with owner: for' => [ + 'testMarker' => '/* testParensOwnerFor */', + 'owner' => -2, + ], + 'parens without owner in for condition' => [ + 'testMarker' => '/* testParensNoOwnerInForCondition */', + ], + 'parens with owner: match' => [ + 'testMarker' => '/* testParensOwnerMatch */', + 'owner' => -1, + ], + 'parens with owner: array' => [ + 'testMarker' => '/* testParensOwnerArray */', + 'owner' => -2, + ], + 'parens without owner in array; function call with & in callable' => [ + 'testMarker' => '/* testParensNoOwnerFunctionCallWithAmpersandInCallable */', + ], + 'parens with owner: fn; & in return value' => [ + 'testMarker' => '/* testParensOwnerArrowFn */', + 'owner' => -1, + ], + 'parens with owner: list with reference vars' => [ + 'testMarker' => '/* testParensOwnerListWithRefVars */', + 'owner' => -1, + ], + 'parens without owner, function call with DNF look-a-like param' => [ + 'testMarker' => '/* testParensNoOwnerFunctionCallwithDNFLookALikeParam */', + ], + + 'parens without owner in OO const default value' => [ + 'testMarker' => '/* testParensNoOwnerOOConstDefaultValue */', + ], + 'parens without owner in property default 1' => [ + 'testMarker' => '/* testParensNoOwnerPropertyDefaultValue1 */', + ], + 'parens without owner in property default 2' => [ + 'testMarker' => '/* testParensNoOwnerPropertyDefaultValue2 */', + ], + 'parens without owner in param default value' => [ + 'testMarker' => '/* testParensNoOwnerParamDefaultValue */', + ], + 'parens without owner in return statement 1' => [ + 'testMarker' => '/* testParensNoOwnerInReturnValue1 */', + ], + 'parens without owner in return statement 2' => [ + 'testMarker' => '/* testParensNoOwnerInReturnValue2 */', + ], + 'parens without owner in return statement 3' => [ + 'testMarker' => '/* testParensNoOwnerInReturnValue3 */', + ], + 'parens with owner: closure; & in default value' => [ + 'testMarker' => '/* testParensOwnerClosureAmpersandInDefaultValue */', + 'owner' => -2, + ], + 'parens with owner: fn; dnf used within' => [ + 'testMarker' => '/* testParensOwnerArrowDNFUsedWithin */', + 'owner' => -2, + ], + 'parens without owner: default value for param in arrow function' => [ + 'testMarker' => '/* testParensNoOwnerAmpersandInDefaultValue */', + ], + 'parens without owner in arrow function return expression' => [ + 'testMarker' => '/* testParensNoOwnerInArrowReturnExpression */', + ], + ]; + + }//end dataNormalParentheses() + + + /** + * Test that parentheses when used in a DNF type declaration are correctly tokenized. + * + * Includes verifying that: + * - the tokens between the parentheses all have a "nested_parenthesis" key. + * - all ampersands between the parentheses are tokenized as T_TYPE_INTERSECTION. + * + * @param string $testMarker The comment prefacing the target token. + * + * @dataProvider dataDNFTypeParentheses + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createParenthesisNestingMap + * + * @return void + */ + public function testDNFTypeParentheses($testMarker) + { + $tokens = $this->phpcsFile->getTokens(); + + $openPtr = $this->getTargetToken($testMarker, [T_OPEN_PARENTHESIS, T_TYPE_OPEN_PARENTHESIS]); + $opener = $tokens[$openPtr]; + + // Make sure we're looking at the right token. + $this->assertSame(T_TYPE_OPEN_PARENTHESIS, $opener['code'], 'Token tokenized as '.$opener['type'].', not T_TYPE_OPEN_PARENTHESIS (code)'); + + $this->assertArrayNotHasKey('parenthesis_owner', $opener, 'Parenthesis owner is set'); + $this->assertArrayHasKey('parenthesis_opener', $opener, 'Parenthesis opener is not set'); + $this->assertArrayHasKey('parenthesis_closer', $opener, 'Parenthesis closer is not set'); + $this->assertSame($openPtr, $opener['parenthesis_opener'], 'Parenthesis opener is not the expected token'); + + $closePtr = $opener['parenthesis_closer']; + $closer = $tokens[$closePtr]; + + // Make sure we're looking at the right token. + $this->assertSame(T_TYPE_CLOSE_PARENTHESIS, $closer['code'], 'Token tokenized as '.$closer['type'].', not T_TYPE_CLOSE_PARENTHESIS (code)'); + + $this->assertArrayNotHasKey('parenthesis_owner', $closer, 'Parenthesis owner is set'); + $this->assertArrayHasKey('parenthesis_opener', $closer, 'Parenthesis opener is not set'); + $this->assertArrayHasKey('parenthesis_closer', $closer, 'Parenthesis closer is not set'); + $this->assertSame($closePtr, $closer['parenthesis_closer'], 'Parenthesis closer is not the expected token'); + + $intersectionCount = 0; + for ($i = ($openPtr + 1); $i < $closePtr; $i++) { + $this->assertArrayHasKey('nested_parenthesis', $tokens[$i], "Nested parenthesis key not set on token $i ({$tokens[$i]['type']})"); + $this->assertArrayHasKey($openPtr, $tokens[$i]['nested_parenthesis'], 'Nested parenthesis is missing target parentheses set'); + $this->assertSame($closePtr, $tokens[$i]['nested_parenthesis'][$openPtr], 'Nested parenthesis closer not set correctly'); + }//end for + + }//end testDNFTypeParentheses() + + + /** + * Data provider. + * + * @see testDNFTypeParentheses() + * + * @return array> + */ + public static function dataDNFTypeParentheses() + { + return [ + 'OO const type: unqualified classes' => [ + 'testMarker' => '/* testDNFTypeOOConstUnqualifiedClasses */', + ], + 'OO const type: modifiers in reverse order' => [ + 'testMarker' => '/* testDNFTypeOOConstReverseModifierOrder */', + ], + 'OO const type: multi-dnf part 1' => [ + 'testMarker' => '/* testDNFTypeOOConstMulti1 */', + ], + 'OO const type: multi-dnf part 2' => [ + 'testMarker' => '/* testDNFTypeOOConstMulti2 */', + ], + 'OO const type: multi-dnf part 3' => [ + 'testMarker' => '/* testDNFTypeOOConstMulti3 */', + ], + 'OO const type: namespace relative classes' => [ + 'testMarker' => '/* testDNFTypeOOConstNamespaceRelative */', + ], + 'OO const type: partially qualified classes' => [ + 'testMarker' => '/* testDNFTypeOOConstPartiallyQualified */', + ], + 'OO const type: fully qualified classes' => [ + 'testMarker' => '/* testDNFTypeOOConstFullyQualified */', + ], + + 'OO property type: unqualified classes' => [ + 'testMarker' => '/* testDNFTypePropertyUnqualifiedClasses */', + ], + 'OO property type: modifiers in reverse order' => [ + 'testMarker' => '/* testDNFTypePropertyReverseModifierOrder */', + ], + 'OO property type: multi-dnf namespace relative classes' => [ + 'testMarker' => '/* testDNFTypePropertyMultiNamespaceRelative */', + ], + 'OO property type: multi-dnf partially qualified classes' => [ + 'testMarker' => '/* testDNFTypePropertyMultiPartiallyQualified */', + ], + 'OO property type: multi-dnf fully qualified classes' => [ + 'testMarker' => '/* testDNFTypePropertyMultiFullyQualified */', + ], + + 'OO property type: multi-dnf with readonly keyword 1' => [ + 'testMarker' => '/* testDNFTypePropertyWithReadOnlyKeyword1 */', + ], + 'OO property type: multi-dnf with readonly keyword 2' => [ + 'testMarker' => '/* testDNFTypePropertyWithReadOnlyKeyword2 */', + ], + 'OO property type: with static and readonly keywords' => [ + 'testMarker' => '/* testDNFTypePropertyWithStaticAndReadOnlyKeywords */', + ], + 'OO property type: with only static keyword' => [ + 'testMarker' => '/* testDNFTypePropertyWithOnlyStaticKeyword */', + ], + 'OO method param type: first param' => [ + 'testMarker' => '/* testDNFTypeParam1WithAttribute */', + ], + 'OO method param type: second param, first DNF' => [ + 'testMarker' => '/* testDNFTypeParam2 */', + ], + 'OO method param type: second param, second DNF' => [ + 'testMarker' => '/* testDNFTypeParam3 */', + ], + 'OO method param type: namespace relative classes' => [ + 'testMarker' => '/* testDNFTypeParamNamespaceRelative */', + ], + 'OO method param type: partially qualified classes' => [ + 'testMarker' => '/* testDNFTypeParamPartiallyQualified */', + ], + 'OO method param type: fully qualified classes' => [ + 'testMarker' => '/* testDNFTypeParamFullyQualified */', + ], + 'Constructor property promotion with multi DNF 1' => [ + 'testMarker' => '/* testDNFTypeConstructorPropertyPromotion1 */', + ], + 'Constructor property promotion with multi DNF 2' => [ + 'testMarker' => '/* testDNFTypeConstructorPropertyPromotion2 */', + ], + 'OO method return type: multi DNF 1' => [ + 'testMarker' => '/* testDNFTypeReturnType1 */', + ], + 'OO method return type: multi DNF 2' => [ + 'testMarker' => '/* testDNFTypeReturnType2 */', + ], + 'OO abstract method return type: multi DNF 1' => [ + 'testMarker' => '/* testDNFTypeAbstractMethodReturnType1 */', + ], + 'OO abstract method return type: multi DNF 2' => [ + 'testMarker' => '/* testDNFTypeAbstractMethodReturnType2 */', + ], + 'OO method return type: namespace relative classes' => [ + 'testMarker' => '/* testDNFTypeReturnTypeNamespaceRelative */', + ], + 'OO method return type: partially qualified classes' => [ + 'testMarker' => '/* testDNFTypeReturnPartiallyQualified */', + ], + 'OO method return type: fully qualified classes' => [ + 'testMarker' => '/* testDNFTypeReturnFullyQualified */', + ], + 'function param type: with reference' => [ + 'testMarker' => '/* testDNFTypeWithReference */', + ], + 'function param type: with spread' => [ + 'testMarker' => '/* testDNFTypeWithSpreadOperator */', + ], + 'closure param type: with illegal nullable' => [ + 'testMarker' => '/* testDNFTypeClosureParamIllegalNullable */', + ], + 'closure return type' => [ + 'testMarker' => '/* testDNFTypeClosureReturn */', + ], + 'arrow function param type' => [ + 'testMarker' => '/* testDNFTypeArrowParam */', + ], + 'arrow function return type' => [ + 'testMarker' => '/* testDNFTypeArrowReturnType */', + ], + 'arrow function param type with return by ref' => [ + 'testMarker' => '/* testDNFTypeArrowParamWithReturnByRef */', + ], + + 'illegal syntax: unnecessary parentheses (no union)' => [ + 'testMarker' => '/* testDNFTypeParamIllegalUnnecessaryParens */', + ], + 'illegal syntax: union within parentheses, intersect outside' => [ + 'testMarker' => '/* testDNFTypeParamIllegalIntersectUnionReversed */', + ], + 'illegal syntax: nested parentheses' => [ + 'testMarker' => '/* testDNFTypeParamIllegalNestedParens */', + ], + ]; + + }//end dataDNFTypeParentheses() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateTokenMapArrayParenthesesTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateTokenMapArrayParenthesesTest.inc new file mode 100644 index 00000000..6d8adfcb --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateTokenMapArrayParenthesesTest.inc @@ -0,0 +1,58 @@ + 10); + +/* testArrayWithComment */ +$var = Array /*comment*/ (1 => 10); + +/* testNestingArray */ +$var = array( + /* testNestedArray */ + array( + 'key' => 'value', + + /* testClosureReturnType */ + 'closure' => function($a) use($global) : Array {}, + ), +); + +/* testFunctionDeclarationParamType */ +function typedParam(array $a) {} + +/* testFunctionDeclarationReturnType */ +function returnType($a) : int|array|null {} + +class Bar { + /* testClassConst */ + const ARRAY = []; + + /* testClassMethod */ + public function array() {} + + /* testOOConstType */ + const array /* testTypedOOConstName */ ARRAY = /* testOOConstDefault */ array(); + + /* testOOPropertyType */ + protected array $property; +} + +class DNFTypes { + /* testOOConstDNFType */ + const (A&B)|array|(C&D) NAME = []; + + /* testOOPropertyDNFType */ + protected (A&B)|ARRAY|null $property; + + /* testFunctionDeclarationParamDNFType */ + public function name(null|array|(A&B) $param) { + /* testClosureDeclarationParamDNFType */ + $cl = function ( array|(A&B) $param) {}; + + /* testArrowDeclarationReturnDNFType */ + $arrow = fn($a): (A&B)|Array => new $a; + } +} diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateTokenMapArrayParenthesesTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateTokenMapArrayParenthesesTest.php new file mode 100644 index 00000000..e362448c --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/CreateTokenMapArrayParenthesesTest.php @@ -0,0 +1,212 @@ + + * @copyright 2021 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\Tokenizer; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; + +final class CreateTokenMapArrayParenthesesTest extends AbstractTokenizerTestCase +{ + + + /** + * Test that the array keyword is correctly tokenized as `T_ARRAY`. + * + * @param string $testMarker The comment prefacing the target token. + * @param string $testContent Optional. The token content to look for. + * + * @dataProvider dataArrayKeyword + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createTokenMap + * + * @return void + */ + public function testArrayKeyword($testMarker, $testContent='array') + { + $tokens = $this->phpcsFile->getTokens(); + + $token = $this->getTargetToken($testMarker, [T_ARRAY, T_STRING], $testContent); + $tokenArray = $tokens[$token]; + + // Make sure we're looking at the right token. + $this->assertSame(T_ARRAY, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_ARRAY (code)'); + + $this->assertArrayHasKey('parenthesis_owner', $tokenArray, 'Parenthesis owner is not set'); + $this->assertArrayHasKey('parenthesis_opener', $tokenArray, 'Parenthesis opener is not set'); + $this->assertArrayHasKey('parenthesis_closer', $tokenArray, 'Parenthesis closer is not set'); + + }//end testArrayKeyword() + + + /** + * Data provider. + * + * @see testArrayKeyword() + * + * @return array> + */ + public static function dataArrayKeyword() + { + return [ + 'empty array' => [ + 'testMarker' => '/* testEmptyArray */', + ], + 'array with space before parenthesis' => [ + 'testMarker' => '/* testArrayWithSpace */', + ], + 'array with comment before parenthesis' => [ + 'testMarker' => '/* testArrayWithComment */', + 'testContent' => 'Array', + ], + 'nested: outer array' => [ + 'testMarker' => '/* testNestingArray */', + ], + 'nested: inner array' => [ + 'testMarker' => '/* testNestedArray */', + ], + 'OO constant default value' => [ + 'testMarker' => '/* testOOConstDefault */', + ], + ]; + + }//end dataArrayKeyword() + + + /** + * Test that the array keyword when used in a type declaration is correctly tokenized as `T_STRING`. + * + * @param string $testMarker The comment prefacing the target token. + * @param string $testContent Optional. The token content to look for. + * + * @dataProvider dataArrayType + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createTokenMap + * + * @return void + */ + public function testArrayType($testMarker, $testContent='array') + { + $tokens = $this->phpcsFile->getTokens(); + + $token = $this->getTargetToken($testMarker, [T_ARRAY, T_STRING], $testContent); + $tokenArray = $tokens[$token]; + + // Make sure we're looking at the right token. + $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); + + $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 testArrayType() + + + /** + * Data provider. + * + * @see testArrayType() + * + * @return array> + */ + public static function dataArrayType() + { + return [ + 'closure return type' => [ + 'testMarker' => '/* testClosureReturnType */', + 'testContent' => 'Array', + ], + 'function param type' => [ + 'testMarker' => '/* testFunctionDeclarationParamType */', + ], + 'function union return type' => [ + 'testMarker' => '/* testFunctionDeclarationReturnType */', + ], + 'OO constant type' => [ + 'testMarker' => '/* testOOConstType */', + ], + 'OO property type' => [ + 'testMarker' => '/* testOOPropertyType */', + ], + + 'OO constant DNF type' => [ + 'testMarker' => '/* testOOConstDNFType */', + ], + 'OO property DNF type' => [ + 'testMarker' => '/* testOOPropertyDNFType */', + 'testContent' => 'ARRAY', + ], + 'function param DNF type' => [ + 'testMarker' => '/* testFunctionDeclarationParamDNFType */', + ], + 'closure param DNF type' => [ + 'testMarker' => '/* testClosureDeclarationParamDNFType */', + ], + 'arrow return DNF type' => [ + 'testMarker' => '/* testArrowDeclarationReturnDNFType */', + 'testContent' => 'Array', + ], + ]; + + }//end dataArrayType() + + + /** + * Verify that the retokenization of `T_ARRAY` tokens to `T_STRING` is handled correctly + * for tokens with the contents 'array' which aren't in actual fact the array keyword. + * + * @param string $testMarker The comment prefacing the target token. + * @param string $testContent The token content to look for. + * + * @dataProvider dataNotArrayKeyword + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createTokenMap + * + * @return void + */ + public function testNotArrayKeyword($testMarker, $testContent='array') + { + $tokens = $this->phpcsFile->getTokens(); + + $token = $this->getTargetToken($testMarker, [T_ARRAY, T_STRING], $testContent); + $tokenArray = $tokens[$token]; + + // Make sure we're looking at the right token. + $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); + + $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 testNotArrayKeyword() + + + /** + * Data provider. + * + * @see testNotArrayKeyword() + * + * @return array> + */ + public static function dataNotArrayKeyword() + { + return [ + 'class-constant-name' => [ + 'testMarker' => '/* testClassConst */', + 'testContent' => 'ARRAY', + ], + 'class-method-name' => [ + 'testMarker' => '/* testClassMethod */', + ], + 'class-constant-name-after-type' => [ + 'testMarker' => '/* testTypedOOConstName */', + 'testContent' => 'ARRAY', + ], + ]; + + }//end dataNotArrayKeyword() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/HeredocNowdocCloserTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/HeredocNowdocCloserTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/HeredocNowdocCloserTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/HeredocNowdocCloserTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/HeredocNowdocCloserTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/HeredocNowdocCloserTest.php similarity index 96% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/HeredocNowdocCloserTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/HeredocNowdocCloserTest.php index d43768f0..a2357db8 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/HeredocNowdocCloserTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/HeredocNowdocCloserTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Tokenizer; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; /** * Heredoc/nowdoc closer token test. diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc new file mode 100644 index 00000000..13b87242 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc @@ -0,0 +1,95 @@ + + * @copyright 2021 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\Tokenizer; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; + +final class RecurseScopeMapCaseKeywordConditionsTest extends AbstractTokenizerTestCase +{ + + + /** + * Test that the enum "case" is converted to T_ENUM_CASE. + * + * @param string $testMarker The comment which prefaces the target token in the test file. + * + * @dataProvider dataEnumCases + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap + * + * @return void + */ + public function testEnumCases($testMarker) + { + $tokens = $this->phpcsFile->getTokens(); + $enumCase = $this->getTargetToken($testMarker, [T_ENUM_CASE, T_CASE]); + $tokenArray = $tokens[$enumCase]; + + // Make sure we're looking at the right token. + $this->assertSame(T_ENUM_CASE, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_ENUM_CASE (code)'); + + $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() + + + /** + * Data provider. + * + * @see testEnumCases() + * + * @return array> + */ + public static function dataEnumCases() + { + return [ + '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() + + + /** + * 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. + * + * @dataProvider dataNotEnumCases + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap + * + * @return void + */ + public function testNotEnumCases($testMarker) + { + $tokens = $this->phpcsFile->getTokens(); + $case = $this->getTargetToken($testMarker, [T_ENUM_CASE, T_CASE]); + $tokenArray = $tokens[$case]; + + // 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->assertArrayHasKey('scope_opener', $tokenArray, 'Scope opener is not set'); + $this->assertArrayHasKey('scope_closer', $tokenArray, 'Scope closer is not set'); + + }//end testNotEnumCases() + + + /** + * Data provider. + * + * @see testNotEnumCases() + * + * @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 */'], + ]; + + }//end dataNotEnumCases() + + + /** + * 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. + * + * @dataProvider dataKeywordAsEnumCaseNameShouldBeString + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap + * + * @return void + */ + public function testKeywordAsEnumCaseNameShouldBeString($testMarker) + { + $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]; + + // Make sure we're looking at the right token. + $this->assertSame(T_STRING, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_STRING (code)'); + + $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 testKeywordAsEnumCaseNameShouldBeString() + + + /** + * Data provider. + * + * @see testKeywordAsEnumCaseNameShouldBeString() + * + * @return array> + */ + public static function dataKeywordAsEnumCaseNameShouldBeString() + { + return [ + '"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() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.inc new file mode 100644 index 00000000..648149d2 --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.inc @@ -0,0 +1,203 @@ + 1, + 2 => 2, + /* testSimpleMatchDefault */ + default => 'default', + }; +} + +function switchWithDefault($i) { + switch ($i) { + case 1: + return 1; + case 2: + return 2; + /* testSimpleSwitchDefault */ + default: + return 'default'; + } +} + +function switchWithDefaultAndCurlies($i) { + switch ($i) { + case 1: + return 1; + case 2: + return 2; + /* testSimpleSwitchDefaultWithCurlies */ + default: { + return 'default'; + } + } +} + +function matchWithDefaultInSwitch() { + switch ($something) { + case 'foo': + $var = [1, 2, 3]; + $var = match ($i) { + 1 => 1, + /* testMatchDefaultNestedInSwitchCase1 */ + default => 'default', + }; + continue; + + case 'bar' : + $i = callMe($a, $b); + return match ($i) { + 1 => 1, + /* testMatchDefaultNestedInSwitchCase2 */ + default => 'default', + }; + + /* testSwitchDefault */ + default; + echo 'something', match ($i) { + 1, => 1, + /* testMatchDefaultNestedInSwitchDefault */ + default, => 'default', + }; + break; + } +} + +function switchWithDefaultInMatch() { + $x = match ($y) { + 5, 8 => function($z) { + switch($z) { + case 'a'; + $var = [1, 2, 3]; + return 'a'; + /* testSwitchDefaultNestedInMatchCase */ + default: + $var = [1, 2, 3]; + return 'default1'; + } + }, + /* testMatchDefault */ + default => function($z) { + switch($z) { + case 'a': + $i = callMe($a, $b); + return 'b'; + /* testSwitchDefaultNestedInMatchDefault */ + default: + $i = callMe($a, $b); + return 'default2'; + } + } + }; +} + +function shortArrayWithConstantKey() { + $arr = [ + /* testClassConstantAsShortArrayKey */ + SomeClass::DEFAULT => 1, + /* testClassPropertyAsShortArrayKey */ + SomeClass->DEFAULT => 1, + /* testNamespacedConstantAsShortArrayKey */ + // Intentional parse error PHP < 8.0. Reserved keyword used as namespaced constant. + SomeNamespace\DEFAULT => 1, + /* testFQNGlobalConstantAsShortArrayKey */ + // Intentional parse error in PHP < 8.0. Reserved keyword used as global constant. + \DEFAULT => 1, + ]; +} + +function longArrayWithConstantKey() { + $arr = array( + /* testClassConstantAsLongArrayKey */ + SomeClass::DEFAULT => 1, + ); +} + +function yieldWithConstantKey() { + /* testClassConstantAsYieldKey */ + yield SomeClass::DEFAULT => 1; +} + +function longArrayWithConstantKeyNestedInMatch() { + return match($x) { + /* testMatchDefaultWithNestedLongArrayWithClassConstantKey */ + DEFAULT => array( + /* testClassConstantAsLongArrayKeyNestedInMatch */ + SomeClass::DEFAULT => match($x) { + /* testMatchDefaultWithNestedLongArrayWithClassConstantKeyLevelDown */ + DEFAULT => array( + /* testClassConstantAsLongArrayKeyNestedInMatchLevelDown */ + SomeClass::DEFAULT => 1, + ), + }, + ), + }; +} + +function shortArrayWithConstantKeyNestedInMatch() { + return match($x) { + /* testMatchDefaultWithNestedShortArrayWithClassConstantKey */ + DEFAULT => [ + /* testClassConstantAsShortArrayKeyNestedInMatch */ + SomeClass::DEFAULT => match($x) { + /* testMatchDefaultWithNestedShortArrayWithClassConstantKeyLevelDown */ + DEFAULT => [ + /* testClassConstantAsShortArrayKeyNestedInMatchLevelDown */ + SomeClass::DEFAULT => 1, + ], + }, + ], + }; +} + + +function longArrayWithConstantKeyWithNestedMatch() { + return array( + /* testClassConstantAsLongArrayKeyWithNestedMatch */ + SomeClass::DEFAULT => match($x) { + /* testMatchDefaultNestedInLongArray */ + DEFAULT => 'foo' + }, + ); +} + +function shortArrayWithConstantKeyWithNestedMatch() { + return [ + /* testClassConstantAsShortArrayKeyWithNestedMatch */ + SomeClass::DEFAULT => match($x) { + /* testMatchDefaultNestedInShortArray */ + DEFAULT => 'foo' + }, + ]; +} + +function switchWithConstantNonDefault($i) { + switch ($i) { + /* testClassConstantInSwitchCase */ + case SomeClass::DEFAULT: + return 1; + + /* testClassPropertyInSwitchCase */ + case SomeClass->DEFAULT: + return 2; + + /* testNamespacedConstantInSwitchCase */ + // Intentional parse error PHP < 8.0. Reserved keyword used as constant. + case SomeNamespace\DEFAULT: + return 2; + + /* testNamespaceRelativeConstantInSwitchCase */ + // Intentional parse error PHP < 8.0. Reserved keyword used as global constant. + case namespace\DEFAULT: + return 2; + } +} + +class Foo { + /* testClassConstant */ + const DEFAULT = 'foo'; + + /* testMethodDeclaration */ + public function default() {} +} diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DefaultKeywordTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php similarity index 95% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DefaultKeywordTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php index cee3d263..fb3a76af 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/DefaultKeywordTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php @@ -8,9 +8,11 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Tokenizer; -final class DefaultKeywordTest extends AbstractTokenizerTestCase +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; + +final class RecurseScopeMapDefaultKeywordConditionsTest extends AbstractTokenizerTestCase { @@ -24,7 +26,6 @@ final class DefaultKeywordTest extends AbstractTokenizerTestCase * @param string $testContent The token content to look for. * * @dataProvider dataMatchDefault - * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap * * @return void @@ -36,8 +37,8 @@ public function testMatchDefault($testMarker, $testContent='default') $token = $this->getTargetToken($testMarker, [T_MATCH_DEFAULT, T_DEFAULT, T_STRING], $testContent); $tokenArray = $tokens[$token]; + // Make sure we're looking at the right token. $this->assertSame(T_MATCH_DEFAULT, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_MATCH_DEFAULT (code)'); - $this->assertSame('T_MATCH_DEFAULT', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_MATCH_DEFAULT (type)'); $this->assertArrayNotHasKey('scope_condition', $tokenArray, 'Scope condition is set'); $this->assertArrayNotHasKey('scope_opener', $tokenArray, 'Scope opener is set'); @@ -128,8 +129,8 @@ public function testSwitchDefault($testMarker, $openerOffset, $closerOffset, $co $expectedScopeOpener = ($token + $openerOffset); $expectedScopeCloser = ($token + $closerOffset); + // Make sure we're looking at the right token. $this->assertSame(T_DEFAULT, $tokenArray['code'], 'Token tokenized as '.$tokenArray['type'].', not T_DEFAULT (code)'); - $this->assertSame('T_DEFAULT', $tokenArray['type'], 'Token tokenized as '.$tokenArray['type'].', not T_DEFAULT (type)'); $this->assertArrayHasKey('scope_condition', $tokenArray, 'Scope condition is not set'); $this->assertArrayHasKey('scope_opener', $tokenArray, 'Scope opener is not set'); @@ -226,7 +227,7 @@ public static function dataSwitchDefault() * @param string $testContent The token content to look for. * * @dataProvider dataNotDefaultKeyword - * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap * * @return void */ @@ -237,8 +238,8 @@ public function testNotDefaultKeyword($testMarker, $testContent='DEFAULT') $token = $this->getTargetToken($testMarker, [T_MATCH_DEFAULT, T_DEFAULT, T_STRING], $testContent); $tokenArray = $tokens[$token]; + // Make sure we're looking at the right token. $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)'); $this->assertArrayNotHasKey('scope_condition', $tokenArray, 'Scope condition is set'); $this->assertArrayNotHasKey('scope_opener', $tokenArray, 'Scope opener is set'); @@ -325,7 +326,6 @@ public static 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 diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.inc b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/ScopeSettingWithNamespaceOperatorTest.inc similarity index 100% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.inc rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/ScopeSettingWithNamespaceOperatorTest.inc diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php similarity index 97% rename from vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php rename to vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php index 5359b728..dba98cdb 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/Tokenizer/ScopeSettingWithNamespaceOperatorTest.php @@ -7,7 +7,9 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -namespace PHP_CodeSniffer\Tests\Core\Tokenizer; +namespace PHP_CodeSniffer\Tests\Core\Tokenizer\Tokenizer; + +use PHP_CodeSniffer\Tests\Core\Tokenizer\AbstractTokenizerTestCase; final class ScopeSettingWithNamespaceOperatorTest extends AbstractTokenizerTestCase { diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Util/HelpTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Util/HelpTest.php new file mode 100644 index 00000000..c8ef301c --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Util/HelpTest.php @@ -0,0 +1,725 @@ + + * @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\Util; + +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHP_CodeSniffer\Util\Help; +use PHPUnit\Framework\TestCase; +use ReflectionMethod; +use ReflectionProperty; + +/** + * Test the Help class. + * + * @covers \PHP_CodeSniffer\Util\Help + */ +final class HelpTest extends TestCase +{ + + + /** + * QA check: verify that the category names are at most the minimum screen width + * and that option argument names are always at most half the length of the minimum screen width. + * + * If this test would start failing, either wrapping of argument info would need to be implemented + * or the minimum screen width needs to be upped. + * + * @coversNothing + * + * @return void + */ + public function testQaArgumentNamesAreWithinAcceptableBounds() + { + $help = new Help(new ConfigDouble(), []); + + $reflMethod = new ReflectionMethod($help, 'getAllOptions'); + $reflMethod->setAccessible(true); + $allOptions = $reflMethod->invoke($help); + $reflMethod->setAccessible(false); + + $this->assertGreaterThan(0, count($allOptions), 'No categories found'); + + $minScreenWidth = Help::MIN_WIDTH; + $maxArgWidth = ($minScreenWidth / 2); + + foreach ($allOptions as $category => $options) { + $this->assertLessThanOrEqual( + Help::MIN_WIDTH, + strlen($category), + "Category name $category is longer than the minimum screen width of $minScreenWidth" + ); + + foreach ($options as $option) { + if (isset($option['argument']) === false) { + continue; + } + + $this->assertLessThanOrEqual( + $maxArgWidth, + strlen($option['argument']), + "Option name {$option['argument']} is longer than the half the minimum screen width of $minScreenWidth" + ); + } + } + + }//end testQaArgumentNamesAreWithinAcceptableBounds() + + + /** + * QA check: verify that each option only contains a spacer, text or argument + description combo. + * + * @coversNothing + * + * @return void + */ + public function testQaValidCategoryOptionDefinitions() + { + $help = new Help(new ConfigDouble(), []); + + $reflMethod = new ReflectionMethod($help, 'getAllOptions'); + $reflMethod->setAccessible(true); + $allOptions = $reflMethod->invoke($help); + $reflMethod->setAccessible(false); + + $this->assertGreaterThan(0, count($allOptions), 'No categories found'); + + foreach ($allOptions as $category => $options) { + $this->assertGreaterThan(0, count($options), "No options found in category $category"); + + foreach ($options as $name => $option) { + if (isset($option['spacer']) === true) { + $this->assertStringStartsWith('blank-line', $name, 'The name for spacer items should start with "blank-line"'); + } + + $this->assertFalse( + isset($option['spacer'], $option['text']), + "Option $name: spacer and text should not be combined in one option" + ); + $this->assertFalse( + isset($option['spacer'], $option['argument']), + "Option $name: spacer and argument should not be combined in one option" + ); + $this->assertFalse( + isset($option['spacer'], $option['description']), + "Option $name: spacer and description should not be combined in one option" + ); + $this->assertFalse( + isset($option['text'], $option['argument']), + "Option $name: text and argument should not be combined in one option" + ); + $this->assertFalse( + isset($option['text'], $option['description']), + "Option $name: text and description should not be combined in one option" + ); + + if (isset($option['argument']) === true) { + $this->assertArrayHasKey( + 'description', + $option, + "Option $name: an argument should always be accompanied by a description" + ); + } + + if (isset($option['description']) === true) { + $this->assertArrayHasKey( + 'argument', + $option, + "Option $name: a description should always be accompanied by an argument" + ); + } + }//end foreach + }//end foreach + + }//end testQaValidCategoryOptionDefinitions() + + + /** + * Test receiving an expected exception when the shortOptions parameter is not passed a string value. + * + * @return void + */ + public function testConstructorInvalidArgumentException() + { + $exception = 'InvalidArgumentException'; + $message = 'The $shortOptions parameter must be a string'; + + if (method_exists($this, 'expectException') === true) { + // PHPUnit 5+. + $this->expectException($exception); + $this->expectExceptionMessage($message); + } else { + // PHPUnit 4. + $this->setExpectedException($exception, $message); + } + + new Help(new ConfigDouble(), [], []); + + }//end testConstructorInvalidArgumentException() + + + /** + * Test filtering of the options by requested options. + * + * Tests that: + * - Options not explicitly requested are removed. + * - Short options passed via the longOptions array are still respected. + * - A category gets removed if all options are removed, even if the category still has spacers. + * + * @param array $longOptions The long options which should be displayed. + * @param string $shortOptions The short options which should be displayed. + * @param array $expected The categories expected after filtering with the number + * of expected help items per category. + * + * @dataProvider dataOptionFiltering + * + * @return void + */ + public function testOptionFiltering($longOptions, $shortOptions, $expected) + { + $help = new Help(new ConfigDouble(), $longOptions, $shortOptions); + + $reflProperty = new ReflectionProperty($help, 'activeOptions'); + $reflProperty->setAccessible(true); + $activeOptions = $reflProperty->getValue($help); + $reflProperty->setAccessible(false); + + // Simplify the value to make it comparible. + foreach ($activeOptions as $category => $options) { + $activeOptions[$category] = count($options); + } + + $this->assertSame($expected, $activeOptions, 'Option count per category does not match'); + + }//end testOptionFiltering() + + + /** + * Data provider. + * + * @return array|array>> + */ + public static function dataOptionFiltering() + { + $allLongOptions = explode(',', Help::DEFAULT_LONG_OPTIONS); + $allLongOptions[] = 'cache'; + $allLongOptions[] = 'no-cache'; + $allLongOptions[] = 'report'; + $allLongOptions[] = 'report-file'; + $allLongOptions[] = 'report-report'; + $allLongOptions[] = 'runtime-set'; + $allLongOptions[] = 'config-explain'; + $allLongOptions[] = 'config-set'; + $allLongOptions[] = 'config-delete'; + $allLongOptions[] = 'config-show'; + $allLongOptions[] = 'generator'; + $allLongOptions[] = 'suffix'; + + $allShortOptions = Help::DEFAULT_SHORT_OPTIONS.'saem'; + + return [ + 'No options' => [ + 'longOptions' => [], + 'shortOptions' => '', + 'expected' => [], + ], + 'Invalid options have no influence' => [ + 'longOptions' => [ + 'doesnotexist', + 'invalid', + ], + 'shortOptions' => 'bjrz', + 'expected' => [], + ], + 'Short options passed as long options works fine' => [ + 'longOptions' => [ + 's', + 'suffix', + 'a', + 'e', + 'colors', + ], + 'shortOptions' => '', + 'expected' => [ + 'Rule Selection Options' => 1, + 'Run Options' => 2, + 'Reporting Options' => 2, + ], + ], + 'All options' => [ + 'longOptions' => $allLongOptions, + 'shortOptions' => $allShortOptions, + 'expected' => [ + 'Scan targets' => 8, + 'Rule Selection Options' => 7, + 'Run Options' => 8, + 'Reporting Options' => 19, + 'Configuration Options' => 8, + 'Miscellaneous Options' => 5, + ], + ], + 'Default options only' => [ + 'longOptions' => explode(',', Help::DEFAULT_LONG_OPTIONS), + 'shortOptions' => Help::DEFAULT_SHORT_OPTIONS, + 'expected' => [ + 'Scan targets' => 8, + 'Rule Selection Options' => 5, + 'Run Options' => 4, + 'Reporting Options' => 14, + 'Configuration Options' => 4, + 'Miscellaneous Options' => 5, + ], + ], + 'Only one category' => [ + 'longOptions' => [ + 'file', + 'stdin-path', + 'file-list', + 'filter', + 'ignore', + 'extensions', + ], + 'shortOptions' => '-l', + 'expected' => [ + 'Scan targets' => 8, + ], + ], + 'All except one category' => [ + 'longOptions' => array_diff($allLongOptions, ['version', 'vv', 'vvv']), + 'shortOptions' => str_replace(['h', 'v'], '', $allShortOptions), + 'expected' => [ + 'Scan targets' => 8, + 'Rule Selection Options' => 7, + 'Run Options' => 8, + 'Reporting Options' => 19, + 'Configuration Options' => 8, + ], + ], + ]; + + }//end dataOptionFiltering() + + + /** + * Test filtering of the options by requested options does not leave stray spacers at the start + * or end of a category and that a category does not contain two consecutive spacers. + * + * {@internal Careful! This test may need updates to still test what it is supposed to test + * if/when the defined options in Help::getAllOptions() change.} + * + * @param array $longOptions The long options which should be displayed. + * @param string $shortOptions The short options which should be displayed. + * + * @dataProvider dataOptionFilteringSpacerHandling + * + * @return void + */ + public function testOptionFilteringSpacerHandling($longOptions, $shortOptions) + { + $help = new Help(new ConfigDouble(), $longOptions, $shortOptions); + + $reflProperty = new ReflectionProperty($help, 'activeOptions'); + $reflProperty->setAccessible(true); + $activeOptions = $reflProperty->getValue($help); + $reflProperty->setAccessible(false); + + $this->assertNotEmpty($activeOptions, 'Active options is empty, test is invalid'); + + foreach ($activeOptions as $options) { + $first = reset($options); + $this->assertArrayNotHasKey('spacer', $first, 'Found spacer at start of category'); + + $last = end($options); + $this->assertArrayNotHasKey('spacer', $last, 'Found spacer at end of category'); + + $previousWasSpacer = false; + foreach ($options as $option) { + $this->assertFalse((isset($option['spacer']) && $previousWasSpacer === true), 'Consecutive spacers found'); + $previousWasSpacer = isset($option['spacer']); + } + } + + }//end testOptionFilteringSpacerHandling() + + + /** + * Data provider. + * + * @return array>> + */ + public static function dataOptionFilteringSpacerHandling() + { + return [ + 'No spacer at start of category' => [ + 'longOptions' => ['generator'], + 'shortOptions' => 'ie', + ], + 'No spacer at end of category' => [ + 'longOptions' => [ + 'encoding', + 'tab-width', + ], + 'shortOptions' => '', + ], + 'No consecutive spacers within category' => [ + 'longOptions' => [ + 'report', + 'report-file', + 'report-report', + 'report-width', + 'basepath', + 'ignore-annotations', + 'colors', + 'no-colors', + ], + 'shortOptions' => 'spqm', + ], + ]; + + }//end dataOptionFilteringSpacerHandling() + + + /** + * 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. + * + * @dataProvider dataDisplayUsage + * + * @return void + */ + public function testDisplayUsage($cliArgs, $expectedRegex) + { + $help = new Help(new ConfigDouble($cliArgs), []); + + $this->expectOutputRegex($expectedRegex); + + $help->display(); + + }//end testDisplayUsage() + + + /** + * Data provider. + * + * @return array>> + */ + public static function dataDisplayUsage() + { + return [ + 'Usage without colors' => [ + 'cliArgs' => ['--no-colors'], + 'expectedRegex' => '`^\s*Usage:\s+phpc(bf|s) \[options\] \\s+$`', + ], + 'Usage with colors' => [ + 'cliArgs' => ['--colors'], + 'expectedRegex' => '`^\s*\\033\[33mUsage:\\033\[0m\s+phpc(bf|s) \[options\] \\s+$`', + ], + ]; + + }//end dataDisplayUsage() + + + /** + * Test the column width calculations. + * + * This tests the following aspects: + * 1. That the report width is never less than Help::MIN_WIDTH, even when a smaller width is passed. + * 2. That the first column width is calculated correctly and is based on the longest argument. + * 3. That the word wrapping of the description respects the maximum report width. + * 4. That if the description is being wrapped, the indent for the second line is calculated correctly. + * + * @param int $reportWidth Report width for the test. + * @param array $longOptions The long options which should be displayed. + * @param string $expectedOutput Expected output. + * + * @dataProvider dataReportWidthCalculations + * + * @return void + */ + public function testReportWidthCalculations($reportWidth, $longOptions, $expectedOutput) + { + $config = new ConfigDouble(["--report-width=$reportWidth", '--no-colors']); + $help = new Help($config, $longOptions); + + $reflMethod = new ReflectionMethod($help, 'printCategories'); + $reflMethod->setAccessible(true); + $reflMethod->invoke($help); + $reflMethod->setAccessible(false); + + $this->expectOutputString($expectedOutput); + + }//end testReportWidthCalculations() + + + /** + * Data provider. + * + * @return array>> + */ + public static function dataReportWidthCalculations() + { + $longOptions = [ + 'e', + 'generator', + ]; + + // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- Test readability is more important. + return [ + 'Report width small: 40; forces report width to minimum width of 60' => [ + 'reportWidth' => 40, + 'longOptions' => $longOptions, + 'expectedOutput' => PHP_EOL.'Rule Selection Options:'.PHP_EOL + .' -e Explain a standard by showing the'.PHP_EOL + .' names of all the sniffs it'.PHP_EOL + .' includes.'.PHP_EOL + .' --generator= Show documentation for a standard.'.PHP_EOL + .' Use either the "HTML", "Markdown"'.PHP_EOL + .' or "Text" generator.'.PHP_EOL, + ], + 'Report width is minimum: 60 (= self::MIN_WIDTH)' => [ + 'reportWidth' => Help::MIN_WIDTH, + 'longOptions' => $longOptions, + 'expectedOutput' => PHP_EOL.'Rule Selection Options:'.PHP_EOL + .' -e Explain a standard by showing the'.PHP_EOL + .' names of all the sniffs it'.PHP_EOL + .' includes.'.PHP_EOL + .' --generator= Show documentation for a standard.'.PHP_EOL + .' Use either the "HTML", "Markdown"'.PHP_EOL + .' or "Text" generator.'.PHP_EOL, + ], + 'Report width matches length for one line, not the other: 96; only one should wrap' => [ + 'reportWidth' => 96, + 'longOptions' => $longOptions, + 'expectedOutput' => PHP_EOL.'Rule Selection Options:'.PHP_EOL + .' -e Explain a standard by showing the names of all the sniffs it includes.'.PHP_EOL + .' --generator= Show documentation for a standard. Use either the "HTML", "Markdown"'.PHP_EOL + .' or "Text" generator.'.PHP_EOL, + ], + 'Report width matches longest line: 119; the messages should not wrap and there should be no stray new line at the end' => [ + 'reportWidth' => 119, + 'longOptions' => $longOptions, + 'expectedOutput' => PHP_EOL.'Rule Selection Options:'.PHP_EOL + .' -e Explain a standard by showing the names of all the sniffs it includes.'.PHP_EOL + .' --generator= Show documentation for a standard. Use either the "HTML", "Markdown" or "Text" generator.'.PHP_EOL, + ], + ]; + // phpcs:enable + + }//end dataReportWidthCalculations() + + + /** + * Verify that variable elements in an argument specification get colorized correctly. + * + * @param string $input String to colorize. + * @param string $expected Expected function output. + * + * @dataProvider dataColorizeVariableInput + * + * @return void + */ + public function testColorizeVariableInput($input, $expected) + { + $help = new Help(new ConfigDouble(), []); + + $reflMethod = new ReflectionMethod($help, 'colorizeVariableInput'); + $reflMethod->setAccessible(true); + $result = $reflMethod->invoke($help, $input); + $reflMethod->setAccessible(false); + + $this->assertSame($expected, $result); + + }//end testColorizeVariableInput() + + + /** + * Data provider. + * + * @return array>> + */ + public static function dataColorizeVariableInput() + { + return [ + 'Empty string' => [ + 'input' => '', + 'expected' => '', + ], + 'String without variable element(s)' => [ + 'input' => 'This is text', + 'expected' => 'This is text', + ], + 'String with variable element' => [ + 'input' => 'This text', + 'expected' => "This \033[36m\033[32m text", + ], + 'String with multiple variable elements' => [ + 'input' => ' is ', + 'expected' => "\033[36m\033[32m is \033[36m\033[32m", + ], + 'String with unclosed variable element' => [ + 'input' => 'This 'This [ + 'input' => ' text>', + 'expected' => "\033[36m text>\033[32m", + ], + 'String with nested elements and surrounding text' => [ + 'input' => 'Start text> end', + 'expected' => "Start \033[36m text>\033[32m end", + ], + ]; + + }//end dataColorizeVariableInput() + + + /** + * Test the various option types within a category get displayed correctly. + * + * @param array> $input The options to print. + * @param array $expectedRegex Regexes to validate expected output. + * + * @dataProvider dataPrintCategoryOptions + * + * @return void + */ + public function testPrintCategoryOptionsNoColor($input, $expectedRegex) + { + $config = new ConfigDouble(['--no-colors']); + $help = new Help($config, []); + + $reflProperty = new ReflectionProperty($help, 'activeOptions'); + $reflProperty->setAccessible(true); + $reflProperty->setValue($help, ['cat' => $input]); + $reflProperty->setAccessible(false); + + $reflMethod = new ReflectionMethod($help, 'setMaxOptionNameLength'); + $reflMethod->setAccessible(true); + $reflMethod->invoke($help); + $reflMethod->setAccessible(false); + + $reflMethod = new ReflectionMethod($help, 'printCategoryOptions'); + $reflMethod->setAccessible(true); + $reflMethod->invoke($help, $input); + $reflMethod->setAccessible(false); + + $this->expectOutputRegex($expectedRegex['no-color']); + + }//end testPrintCategoryOptionsNoColor() + + + /** + * Test the various option types within a category get displayed correctly. + * + * @param array> $input The options to print. + * @param array $expectedRegex Regexes to validate expected output. + * + * @dataProvider dataPrintCategoryOptions + * + * @return void + */ + public function testPrintCategoryOptionsColor($input, $expectedRegex) + { + $config = new ConfigDouble(['--colors']); + $help = new Help($config, []); + + $reflProperty = new ReflectionProperty($help, 'activeOptions'); + $reflProperty->setAccessible(true); + $reflProperty->setValue($help, ['cat' => $input]); + $reflProperty->setAccessible(false); + + $reflMethod = new ReflectionMethod($help, 'setMaxOptionNameLength'); + $reflMethod->setAccessible(true); + $reflMethod->invoke($help); + $reflMethod->setAccessible(false); + + $reflMethod = new ReflectionMethod($help, 'printCategoryOptions'); + $reflMethod->setAccessible(true); + $reflMethod->invoke($help, $input); + $reflMethod->setAccessible(false); + + $this->expectOutputRegex($expectedRegex['color']); + + }//end testPrintCategoryOptionsColor() + + + /** + * Data provider. + * + * @return array>|array>> + */ + public static function dataPrintCategoryOptions() + { + $indentLength = strlen(Help::INDENT); + $gutterLength = strlen(Help::GUTTER); + + // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- Test readability is more important. + // phpcs:disable Generic.Strings.UnnecessaryStringConcat.Found -- Test readability is more important. + return [ + 'Input: arg, spacer, arg; new lines in description get preserved' => [ + 'input' => [ + 'short-option' => [ + 'argument' => '-a', + 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + ], + 'blank-line' => [ + 'spacer' => '', + ], + 'long-option-multi-line-description' => [ + 'argument' => '--something=', + 'description' => 'Proin sit amet malesuada libero, finibus bibendum tortor. Nulla vitae quam nec orci finibus pharetra.' + ."\n".'Nam eget blandit dui.', + ], + ], + 'expectedRegex' => [ + 'no-color' => '`^ {'.$indentLength.'}-a {15} {'.$gutterLength.'}Lorem ipsum dolor sit amet, consectetur adipiscing elit\.\R' + .'\R' + .' {'.$indentLength.'}--something= {'.$gutterLength.'}Proin sit amet malesuada libero, finibus bibendum tortor\.\R' + .' {'.($indentLength + 17).'} {'.$gutterLength.'}Nulla vitae quam nec orci finibus pharetra\.\R' + .' {'.($indentLength + 17).'} {'.$gutterLength.'}Nam eget blandit dui\.\R$`', + 'color' => '`^ {'.$indentLength.'}\\033\[32m-a {15}\\033\[0m {'.$gutterLength.'}Lorem ipsum dolor sit amet, consectetur adipiscing elit\.\R' + .'\R' + .' {'.$indentLength.'}\\033\[32m--something=\\033\[36m\\033\[32m\\033\[0m {'.$gutterLength.'}Proin sit amet malesuada libero, finibus bibendum tortor\.\R' + .' {'.($indentLength + 17).'} {'.$gutterLength.'}Nulla vitae quam nec orci finibus pharetra\.\R' + .' {'.($indentLength + 17).'} {'.$gutterLength.'}Nam eget blandit dui\.\R$`', + ], + ], + 'Input: text, arg, text; multi-line text gets wrapped' => [ + 'input' => [ + 'single-line-text' => [ + 'text' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + ], + 'argument-description' => [ + 'argument' => '--something', + 'description' => 'Fusce dapibus sodales est eu sodales.', + ], + 'multi-line-text-gets-wrapped' => [ + 'text' => 'Maecenas vulputate ligula vel feugiat finibus. Mauris sem dui, pretium in turpis auctor, consectetur ultrices lorem.', + ], + ], + 'expectedRegex' => [ + 'no-color' => '`^ {'.$indentLength.'}Lorem ipsum dolor sit amet, consectetur adipiscing elit\.\R' + .' {'.$indentLength.'}--something {'.$gutterLength.'}Fusce dapibus sodales est eu sodales\.\R' + .' {'.$indentLength.'}Maecenas vulputate ligula vel feugiat finibus. Mauris sem dui, pretium in\R' + .' {'.$indentLength.'}turpis auctor, consectetur ultrices lorem\.\R$`', + 'color' => '`^ {'.$indentLength.'}Lorem ipsum dolor sit amet, consectetur adipiscing elit\.\R' + .' {'.$indentLength.'}\\033\[32m--something\\033\[0m {'.$gutterLength.'}Fusce dapibus sodales est eu sodales\.\R' + .' {'.$indentLength.'}Maecenas vulputate ligula vel feugiat finibus. Mauris sem dui, pretium in\R' + .' {'.$indentLength.'}turpis auctor, consectetur ultrices lorem\.\R$`', + ], + ], + ]; + // phpcs:enable + + }//end dataPrintCategoryOptions() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Util/StripColorsTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Util/StripColorsTest.php new file mode 100644 index 00000000..46ea11be --- /dev/null +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Util/StripColorsTest.php @@ -0,0 +1,96 @@ + + * @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\Util; + +use PHP_CodeSniffer\Util\Common; +use PHPUnit\Framework\TestCase; + +/** + * Tests for the \PHP_CodeSniffer\Util\Sniffs\Common::stripColors() method. + * + * @covers \PHP_CodeSniffer\Util\Common::stripColors + */ +final class StripColorsTest extends TestCase +{ + + + /** + * Test stripping color codes from a text. + * + * @param string $text The text provided. + * @param string $expected Expected function output. + * + * @dataProvider dataStripColors + * + * @return void + */ + public function testStripColors($text, $expected) + { + $this->assertSame($expected, Common::stripColors($text)); + + }//end testStripColors() + + + /** + * Data provider. + * + * @see testStripColors() + * + * @return array> + */ + public static function dataStripColors() + { + return [ + 'Text is empty' => [ + 'text' => '', + 'expected' => '', + ], + 'Text enclosed in color code' => [ + 'text' => "\033[36mSome text\033[0m", + 'expected' => 'Some text', + ], + 'Text containing color code' => [ + 'text' => "Some text \033[33mSome other text", + 'expected' => 'Some text Some other text', + ], + 'Text enclosed in color code, bold' => [ + 'text' => "\033[1;32mSome text\033[0m", + 'expected' => 'Some text', + ], + 'Text enclosed in color code, with escaped text' => [ + 'text' => "\033[30;1m\\n\033[0m", + 'expected' => '\n', + ], + 'Text enclosed in color code, bold, dark, italic' => [ + 'text' => "\033[1;2;3mtext\033[0m", + 'expected' => 'text', + ], + 'Text enclosed in color code, foreground color' => [ + 'text' => "\033[38;5;255mtext\033[0m", + 'expected' => 'text', + ], + 'Text enclosed in color code, foreground color and background color' => [ + 'text' => "\033[38;5;200;48;5;255mtext\033[0m", + 'expected' => 'text', + ], + 'Multiline text containing multiple color codes' => [ + 'text' => "First \033[36mSecond\033[0m +Third \033[1;2;3mFourth +Next line\033[0m Last", + 'expected' => 'First Second +Third Fourth +Next line Last', + ], + ]; + + }//end dataStripColors() + + +}//end class diff --git a/vendor/squizlabs/php_codesniffer/tests/Core/Util/SuggestTypeTest.php b/vendor/squizlabs/php_codesniffer/tests/Core/Util/SuggestTypeTest.php index 48790a88..88da1cd5 100644 --- a/vendor/squizlabs/php_codesniffer/tests/Core/Util/SuggestTypeTest.php +++ b/vendor/squizlabs/php_codesniffer/tests/Core/Util/SuggestTypeTest.php @@ -1,6 +1,6 @@ * @copyright 2019 Juliette Reinders Folmer. All rights reserved. @@ -13,7 +13,7 @@ use PHPUnit\Framework\TestCase; /** - * Tests for the \PHP_CodeSniffer\Util\Sniffs\Comments::suggestType() method. + * Tests for the \PHP_CodeSniffer\Util\Sniffs\Common::suggestType() method. * * @covers \PHP_CodeSniffer\Util\Common::suggestType */ diff --git a/vendor/squizlabs/php_codesniffer/tests/TestSuite7.php b/vendor/squizlabs/php_codesniffer/tests/TestSuite7.php index 1b651519..ad0947c5 100644 --- a/vendor/squizlabs/php_codesniffer/tests/TestSuite7.php +++ b/vendor/squizlabs/php_codesniffer/tests/TestSuite7.php @@ -19,7 +19,7 @@ class TestSuite extends PHPUnit_TestSuite /** * Runs the tests and collects their result in a TestResult. * - * @param \PHPUnit\Framework\TestResult $result A test result. + * @param \PHPUnit\Framework\TestResult|null $result A test result. * * @return \PHPUnit\Framework\TestResult */