From 9434b82b7fc418b31c0e68685026534fac2e1d99 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Wed, 10 Apr 2024 14:24:39 +0200 Subject: [PATCH] WIP: Bump all dependencies to current ones - Moodle CS v3.4.6 - PHP Compatibility e5cd2e24 --- composer.json | 4 +- composer.lock | 50 +- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 8 +- vendor/composer/autoload_static.php | 8 +- vendor/composer/installed.json | 70 +- vendor/composer/installed.php | 24 +- vendor/moodlehq/moodle-cs/LICENSE | 8 +- vendor/moodlehq/moodle-cs/composer.json | 6 +- .../Sniffs/Commenting/CategorySniff.php | 81 + .../Commenting/DocblockDescriptionSniff.php | 108 + .../Commenting/FileExpectedTagsSniff.php | 160 + .../Sniffs/Commenting/InlineCommentSniff.php | 117 +- .../Commenting/MissingDocblockSniff.php | 261 ++ .../moodle/Sniffs/Commenting/PackageSniff.php | 198 ++ .../Sniffs/Commenting/TodoCommentSniff.php | 4 +- .../Sniffs/Commenting/ValidTagsSniff.php | 135 + .../Commenting/VariableCommentSniff.php | 211 ++ .../ControlSignatureSniff.php | 18 +- .../Sniffs/Files/BoilerplateCommentSniff.php | 43 +- .../Sniffs/Files/LangFilesOrderingSniff.php | 335 ++ .../moodle/Sniffs/Files/LineLengthSniff.php | 15 +- .../Sniffs/Files/MoodleInternalSniff.php | 124 +- .../moodle/Sniffs/Files/RequireLoginSniff.php | 42 +- .../Methods/MethodDeclarationSpacingSniff.php | 170 + .../Namespaces/NamespaceStatementSniff.php | 13 +- .../ValidFunctionNameSniff.php | 42 +- .../ValidVariableNameSniff.php | 51 +- .../Sniffs/PHP/DeprecatedFunctionsSniff.php | 22 +- .../Sniffs/PHP/ForbiddenFunctionsSniff.php | 14 +- .../Sniffs/PHP/ForbiddenGlobalUseSniff.php | 39 +- .../Sniffs/PHP/ForbiddenTokensSniff.php | 26 +- .../moodle/Sniffs/PHP/IncludingFileSniff.php | 22 +- .../moodle/Sniffs/PHP/MemberVarScopeSniff.php | 17 +- .../Sniffs/PHPUnit/TestCaseCoversSniff.php | 146 +- .../Sniffs/PHPUnit/TestCaseNamesSniff.php | 104 +- .../Sniffs/PHPUnit/TestCaseProviderSniff.php | 28 +- .../Sniffs/PHPUnit/TestCasesAbstractSniff.php | 87 + .../Sniffs/PHPUnit/TestClassesFinalSniff.php | 124 + .../Sniffs/PHPUnit/TestReturnTypeSniff.php | 14 +- .../Sniffs/Strings/ForbiddenStringsSniff.php | 41 +- .../WhiteSpace/SpaceAfterCommaSniff.php | 13 +- .../WhiteSpace/WhiteSpaceInStringsSniff.php | 24 +- .../moodle-cs/moodle/Util/Docblocks.php | 379 +++ .../moodle-cs/moodle/Util/MoodleUtil.php | 189 +- .../moodle-cs/moodle/Util/TokenUtil.php | 107 + .../moodle-cs/moodle/Util/TypeUtil.php | 164 + .../moodlehq/moodle-cs/moodle/Util/apis.json | 272 ++ vendor/moodlehq/moodle-cs/moodle/ruleset.xml | 4 + vendor/moodlehq/moodle-cs/phpcs.xml.dist | 46 + .../php-compatibility/CHANGELOG.md | 2 +- .../AbstractFunctionCallParameterSniff.php | 2 +- .../RemovedLdapConnectSignaturesStandard.xml | 45 +- .../Sniffs/Constants/NewConstantsSniff.php | 36 +- .../Constants/RemovedConstantsSniff.php | 16 +- .../Sniffs/FunctionUse/NewFunctionsSniff.php | 20 - ...ionalToRequiredFunctionParametersSniff.php | 10 + .../RemovedFunctionParametersSniff.php | 49 + .../FunctionUse/RemovedFunctionsSniff.php | 11 + .../RemovedLdapConnectSignaturesSniff.php | 33 + .../ForbiddenThisUseContextsSniff.php | 6 + .../php-compatibility/README.md | 20 +- .../php-compatibility/composer.json | 4 +- vendor/phpcsstandards/phpcsutils/CHANGELOG.md | 29 + .../PHPCSUtils/BackCompat/BCFile.php | 119 +- .../PHPCSUtils/BackCompat/BCTokens.php | 2 +- .../PHPCSUtils/BackCompat/Helper.php | 11 +- .../Internal/IsShortArrayOrList.php | 24 +- .../Internal/IsShortArrayOrListWithCache.php | 2 +- .../TestUtils/UtilityMethodTestCase.php | 15 +- .../PHPCSUtils/Tokens/Collections.php | 3 +- .../PHPCSUtils/Utils/NamingConventions.php | 13 +- .../PHPCSUtils/Utils/ObjectDeclarations.php | 12 +- .../PHPCSUtils/Utils/PassedParameters.php | 26 +- vendor/phpcsstandards/phpcsutils/README.md | 6 +- .../phpcsstandards/phpcsutils/composer.json | 2 +- vendor/squizlabs/php_codesniffer/CHANGELOG.md | 2821 +++++++++++------ vendor/squizlabs/php_codesniffer/README.md | 2 +- vendor/squizlabs/php_codesniffer/autoload.php | 9 +- vendor/squizlabs/php_codesniffer/bin/phpcbf | 6 +- vendor/squizlabs/php_codesniffer/bin/phpcs | 6 +- .../squizlabs/php_codesniffer/src/Config.php | 45 +- .../src/Exceptions/DeepExitException.php | 4 +- .../src/Exceptions/RuntimeException.php | 4 +- .../src/Exceptions/TokenizerException.php | 4 +- .../php_codesniffer/src/Files/DummyFile.php | 2 +- .../php_codesniffer/src/Files/File.php | 41 +- .../php_codesniffer/src/Files/FileList.php | 22 +- .../php_codesniffer/src/Files/LocalFile.php | 2 +- .../src/Filters/ExactMatch.php | 80 +- .../php_codesniffer/src/Filters/Filter.php | 13 +- .../src/Filters/GitModified.php | 44 +- .../php_codesniffer/src/Filters/GitStaged.php | 44 +- .../squizlabs/php_codesniffer/src/Fixer.php | 54 +- .../src/Generators/Generator.php | 10 +- .../php_codesniffer/src/Generators/HTML.php | 12 +- .../src/Generators/Markdown.php | 10 +- .../php_codesniffer/src/Generators/Text.php | 10 +- .../php_codesniffer/src/Reports/Cbf.php | 4 +- .../src/Reports/Checkstyle.php | 3 +- .../php_codesniffer/src/Reports/Code.php | 10 +- .../php_codesniffer/src/Reports/Full.php | 4 +- .../php_codesniffer/src/Reports/Junit.php | 3 +- .../php_codesniffer/src/Reports/Summary.php | 4 +- .../php_codesniffer/src/Reports/Xml.php | 3 +- .../squizlabs/php_codesniffer/src/Ruleset.php | 227 +- .../squizlabs/php_codesniffer/src/Runner.php | 33 +- .../src/Sniffs/AbstractPatternSniff.php | 4 +- .../src/Sniffs/AbstractScopeSniff.php | 8 +- .../src/Sniffs/AbstractVariableSniff.php | 10 +- .../src/Sniffs/DeprecatedSniff.php | 63 + .../php_codesniffer/src/Sniffs/Sniff.php | 2 +- ...licitBooleanOperatorPrecedenceStandard.xml | 44 + .../Formatting/NoSpaceAfterCastStandard.xml | 2 +- .../Formatting/SpaceAfterCastStandard.xml | 2 +- .../DisallowRequestSuperglobalStandard.xml | 2 +- .../Docs/PHP/RequireStrictTypesStandard.xml | 38 + .../IncrementDecrementSpacingStandard.xml | 26 + .../ForLoopWithTestFunctionCallSniff.php | 4 +- ...ExplicitBooleanOperatorPrecedenceSniff.php | 119 + .../UnusedFunctionParameterSniff.php | 23 +- .../UselessOverridingMethodSniff.php | 34 +- .../InlineControlStructureSniff.php | 2 +- .../Generic/Sniffs/Debug/CSSLintSniff.php | 8 +- .../Sniffs/Debug/ClosureLinterSniff.php | 8 +- .../Generic/Sniffs/Debug/ESLintSniff.php | 10 +- .../Generic/Sniffs/Debug/JSHintSniff.php | 6 +- .../Sniffs/Files/ByteOrderMarkSniff.php | 8 +- .../Sniffs/Files/EndFileNewlineSniff.php | 2 +- .../Sniffs/Files/EndFileNoNewlineSniff.php | 2 +- .../Sniffs/Files/ExecutableFileSniff.php | 2 +- .../Generic/Sniffs/Files/LineEndingsSniff.php | 6 +- .../Generic/Sniffs/Files/LineLengthSniff.php | 2 +- .../Sniffs/Files/LowercasedFilenameSniff.php | 4 +- .../UpperCaseConstantNameSniff.php | 12 +- .../Sniffs/PHP/DeprecatedFunctionsSniff.php | 4 +- .../Sniffs/PHP/LowerCaseConstantSniff.php | 16 + .../Generic/Sniffs/PHP/LowerCaseTypeSniff.php | 74 +- .../Generic/Sniffs/PHP/SyntaxSniff.php | 2 +- .../VersionControl/GitMergeConflictSniff.php | 2 +- .../SubversionPropertiesSniff.php | 4 +- .../ArbitraryParenthesesSpacingSniff.php | 3 +- .../WhiteSpace/DisallowSpaceIndentSniff.php | 2 +- .../WhiteSpace/DisallowTabIndentSniff.php | 2 +- .../IncrementDecrementSpacingSniff.php | 2 +- .../Tests/Arrays/ArrayIndentUnitTest.php | 2 +- .../DisallowLongArraySyntaxUnitTest.php | 2 +- .../DisallowShortArraySyntaxUnitTest.php | 2 +- .../Classes/DuplicateClassNameUnitTest.php | 2 +- .../Classes/OpeningBraceSameLineUnitTest.php | 2 +- .../AssignmentInConditionUnitTest.php | 2 +- .../EmptyPHPStatementUnitTest.php | 2 +- .../CodeAnalysis/EmptyStatementUnitTest.php | 2 +- .../ForLoopShouldBeWhileLoopUnitTest.php | 2 +- .../ForLoopWithTestFunctionCallUnitTest.1.inc | 95 + .../ForLoopWithTestFunctionCallUnitTest.2.inc | 5 + .../ForLoopWithTestFunctionCallUnitTest.3.inc | 6 + .../ForLoopWithTestFunctionCallUnitTest.inc | 15 - .../ForLoopWithTestFunctionCallUnitTest.php | 31 +- .../JumbledIncrementerUnitTest.php | 2 +- ...licitBooleanOperatorPrecedenceUnitTest.inc | 131 + ...licitBooleanOperatorPrecedenceUnitTest.php | 91 + .../UnconditionalIfStatementUnitTest.php | 2 +- ...=> UnnecessaryFinalModifierUnitTest.1.inc} | 22 + .../UnnecessaryFinalModifierUnitTest.2.inc | 5 + .../UnnecessaryFinalModifierUnitTest.php | 29 +- ... => UnusedFunctionParameterUnitTest.1.inc} | 23 + .../UnusedFunctionParameterUnitTest.2.inc | 5 + .../UnusedFunctionParameterUnitTest.3.inc | 5 + .../UnusedFunctionParameterUnitTest.php | 47 +- .../UselessOverridingMethodUnitTest.1.inc | 150 + .../UselessOverridingMethodUnitTest.2.inc | 7 + .../UselessOverridingMethodUnitTest.3.inc | 10 + .../UselessOverridingMethodUnitTest.4.inc | 10 + .../UselessOverridingMethodUnitTest.5.inc | 10 + .../UselessOverridingMethodUnitTest.6.inc | 10 + .../UselessOverridingMethodUnitTest.inc | 25 - .../UselessOverridingMethodUnitTest.php | 27 +- ...tUnitTest.inc => DocCommentUnitTest.1.inc} | 10 +- ...c.fixed => DocCommentUnitTest.1.inc.fixed} | 10 +- ...entUnitTest.js => DocCommentUnitTest.1.js} | 20 + ...js.fixed => DocCommentUnitTest.1.js.fixed} | 20 + .../Tests/Commenting/DocCommentUnitTest.2.inc | 6 + .../Tests/Commenting/DocCommentUnitTest.2.js | 4 + .../Tests/Commenting/DocCommentUnitTest.php | 113 +- .../Tests/Commenting/FixmeUnitTest.php | 2 +- .../Generic/Tests/Commenting/TodoUnitTest.php | 2 +- .../DisallowYodaConditionsUnitTest.php | 2 +- .../InlineControlStructureUnitTest.php | 2 +- .../Generic/Tests/Debug/CSSLintUnitTest.php | 2 +- .../Tests/Debug/ClosureLinterUnitTest.php | 2 +- .../Generic/Tests/Debug/ESLintUnitTest.php | 2 +- .../Generic/Tests/Debug/JSHintUnitTest.php | 2 +- .../Tests/Files/ByteOrderMarkUnitTest.1.inc | 4 + .../Tests/Files/ByteOrderMarkUnitTest.2.inc | 3 + .../Tests/Files/ByteOrderMarkUnitTest.3.inc | 1 + .../Tests/Files/ByteOrderMarkUnitTest.4.inc | Bin 0 -> 208 bytes .../Tests/Files/ByteOrderMarkUnitTest.5.inc | Bin 0 -> 202 bytes .../Tests/Files/ByteOrderMarkUnitTest.inc | 3 - .../Tests/Files/ByteOrderMarkUnitTest.php | 16 +- .../Tests/Files/EndFileNewlineUnitTest.php | 2 +- .../Tests/Files/EndFileNoNewlineUnitTest.php | 2 +- .../Tests/Files/ExecutableFileUnitTest.php | 2 +- .../Tests/Files/InlineHTMLUnitTest.6.inc | 2 +- .../Tests/Files/InlineHTMLUnitTest.7.inc | 2 +- .../Tests/Files/InlineHTMLUnitTest.php | 2 +- .../Tests/Files/LineEndingsUnitTest.php | 2 +- .../Tests/Files/LineLengthUnitTest.php | 2 +- .../Files/LowercasedFilenameUnitTest.php | 2 +- .../Tests/Files/OneClassPerFileUnitTest.php | 2 +- .../Files/OneInterfacePerFileUnitTest.php | 2 +- .../OneObjectStructurePerFileUnitTest.php | 2 +- .../Tests/Files/OneTraitPerFileUnitTest.php | 2 +- .../DisallowMultipleStatementsUnitTest.php | 2 +- .../MultipleStatementAlignmentUnitTest.php | 2 +- .../Formatting/NoSpaceAfterCastUnitTest.php | 2 +- .../Formatting/SpaceAfterCastUnitTest.php | 2 +- .../Formatting/SpaceAfterNotUnitTest.php | 2 +- .../Formatting/SpaceBeforeCastUnitTest.php | 2 +- .../CallTimePassByReferenceUnitTest.php | 2 +- .../FunctionCallArgumentSpacingUnitTest.php | 2 +- .../OpeningFunctionBraceBsdAllmanUnitTest.php | 2 +- ...gFunctionBraceKernighanRitchieUnitTest.php | 2 +- .../Metrics/CyclomaticComplexityUnitTest.php | 2 +- .../Tests/Metrics/NestingLevelUnitTest.php | 2 +- .../AbstractClassNamePrefixUnitTest.php | 2 +- .../CamelCapsFunctionNameUnitTest.php | 2 +- .../ConstructorNameUnitTest.php | 2 +- .../InterfaceNameSuffixUnitTest.php | 2 +- .../TraitNameSuffixUnitTest.php | 2 +- .../UpperCaseConstantNameUnitTest.inc | 10 + .../UpperCaseConstantNameUnitTest.php | 4 +- .../Tests/PHP/BacktickOperatorUnitTest.php | 2 +- ...CharacterBeforePHPOpeningTagUnitTest.3.inc | 2 +- .../CharacterBeforePHPOpeningTagUnitTest.php | 2 +- .../Tests/PHP/ClosingPHPTagUnitTest.php | 2 +- .../Tests/PHP/DeprecatedFunctionsUnitTest.php | 2 +- .../DisallowAlternativePHPTagsUnitTest.php | 2 +- .../DisallowRequestSuperglobalUnitTest.php | 2 +- .../PHP/DisallowShortOpenTagUnitTest.php | 2 +- .../Tests/PHP/DiscourageGotoUnitTest.php | 2 +- .../Tests/PHP/ForbiddenFunctionsUnitTest.php | 2 +- .../Tests/PHP/LowerCaseConstantUnitTest.inc | 8 + .../PHP/LowerCaseConstantUnitTest.inc.fixed | 8 + .../Tests/PHP/LowerCaseConstantUnitTest.php | 4 +- .../Tests/PHP/LowerCaseKeywordUnitTest.php | 2 +- .../Tests/PHP/LowerCaseTypeUnitTest.inc | 30 + .../Tests/PHP/LowerCaseTypeUnitTest.inc.fixed | 30 + .../Tests/PHP/LowerCaseTypeUnitTest.php | 102 +- .../Tests/PHP/NoSilencedErrorsUnitTest.php | 2 +- .../Tests/PHP/RequireStrictTypesUnitTest.php | 2 +- .../Generic/Tests/PHP/SAPIUsageUnitTest.php | 2 +- .../Generic/Tests/PHP/SyntaxUnitTest.php | 2 +- .../Tests/PHP/UpperCaseConstantUnitTest.php | 2 +- .../UnnecessaryStringConcatUnitTest.php | 2 +- .../GitMergeConflictUnitTest.php | 2 +- .../SubversionPropertiesUnitTest.php | 2 +- .../ArbitraryParenthesesSpacingUnitTest.1.inc | 10 + ...raryParenthesesSpacingUnitTest.1.inc.fixed | 10 + .../ArbitraryParenthesesSpacingUnitTest.php | 2 +- .../DisallowSpaceIndentUnitTest.php | 2 +- .../WhiteSpace/DisallowTabIndentUnitTest.php | 4 +- .../IncrementDecrementSpacingUnitTest.inc | 6 + ...ncrementDecrementSpacingUnitTest.inc.fixed | 5 + .../IncrementDecrementSpacingUnitTest.php | 4 +- .../LanguageConstructSpacingUnitTest.php | 2 +- .../Tests/WhiteSpace/ScopeIndentUnitTest.php | 2 +- .../SpreadOperatorSpacingAfterUnitTest.php | 2 +- .../Sniffs/CSS/BrowserSpecificStylesSniff.php | 2 + .../Channels/DisallowSelfActionsSniff.php | 2 + .../Sniffs/Channels/IncludeOwnSystemSniff.php | 2 + .../Sniffs/Channels/IncludeSystemSniff.php | 2 + .../Sniffs/Channels/UnusedSystemSniff.php | 2 + .../Commenting/FunctionCommentSniff.php | 2 + .../MySource/Sniffs/Debug/DebugCodeSniff.php | 2 + .../Sniffs/Debug/FirebugConsoleSniff.php | 2 + .../Sniffs/Objects/AssignThisSniff.php | 2 + .../Objects/CreateWidgetTypeCallbackSniff.php | 2 + .../Sniffs/Objects/DisallowNewWidgetSniff.php | 2 + .../Sniffs/PHP/AjaxNullComparisonSniff.php | 2 + .../Sniffs/PHP/EvalObjectFactorySniff.php | 2 + .../Sniffs/PHP/GetRequestDataSniff.php | 2 + .../Sniffs/PHP/ReturnFunctionValueSniff.php | 2 + .../Sniffs/Strings/JoinStringsSniff.php | 2 + .../CSS/BrowserSpecificStylesUnitTest.php | 2 +- .../Channels/DisallowSelfActionsUnitTest.php | 2 +- .../Tests/Channels/IncludeSystemUnitTest.php | 2 +- .../Tests/Channels/UnusedSystemUnitTest.php | 2 +- .../Commenting/FunctionCommentUnitTest.php | 2 +- .../Tests/Debug/DebugCodeUnitTest.php | 2 +- .../Tests/Debug/FirebugConsoleUnitTest.php | 2 +- .../Tests/Objects/AssignThisUnitTest.php | 2 +- .../CreateWidgetTypeCallbackUnitTest.php | 2 +- .../Objects/DisallowNewWidgetUnitTest.php | 2 +- .../Tests/PHP/AjaxNullComparisonUnitTest.php | 2 +- .../Tests/PHP/EvalObjectFactoryUnitTest.php | 2 +- .../Tests/PHP/GetRequestDataUnitTest.php | 2 +- .../Tests/PHP/ReturnFunctionValueUnitTest.php | 2 +- .../Tests/Strings/JoinStringsUnitTest.php | 2 +- .../Sniffs/Commenting/FileCommentSniff.php | 10 +- .../Commenting/FunctionCommentSniff.php | 8 +- .../Classes/ClassDeclarationUnitTest.php | 2 +- .../Tests/Commenting/ClassCommentUnitTest.php | 2 +- .../Tests/Commenting/FileCommentUnitTest.php | 2 +- .../Commenting/FunctionCommentUnitTest.php | 2 +- .../Commenting/InlineCommentUnitTest.php | 2 +- .../ControlSignatureUnitTest.php | 2 +- .../MultiLineConditionUnitTest.php | 2 +- .../Tests/Files/IncludingFileUnitTest.php | 2 +- .../MultiLineAssignmentUnitTest.php | 2 +- .../FunctionCallSignatureUnitTest.php | 2 +- .../Functions/FunctionDeclarationUnitTest.php | 2 +- .../Functions/ValidDefaultValueUnitTest.php | 2 +- .../ValidClassNameUnitTest.php | 2 +- .../ValidFunctionNameUnitTest.php | 2 +- .../ValidVariableNameUnitTest.php | 2 +- .../ObjectOperatorIndentUnitTest.php | 2 +- .../WhiteSpace/ScopeClosingBraceUnitTest.php | 2 +- .../Tests/WhiteSpace/ScopeIndentUnitTest.php | 2 +- .../PSR1/Sniffs/Files/SideEffectsSniff.php | 2 +- .../Classes/ClassDeclarationUnitTest.php | 2 +- .../PSR1/Tests/Files/SideEffectsUnitTest.php | 2 +- .../Methods/CamelCapsMethodNameUnitTest.php | 2 +- .../ControlStructureSpacingStandard.xml | 124 + .../Docs/Files/ImportStatementStandard.xml | 33 + .../NullableTypeDeclarationStandard.xml | 8 +- .../ReturnTypeDeclarationStandard.xml | 41 + .../Properties/ConstantVisibilityStandard.xml | 27 + .../Classes/AnonClassDeclarationSniff.php | 2 +- .../Classes/ClassInstantiationSniff.php | 15 +- .../Sniffs/Files/DeclareStatementSniff.php | 6 + .../Sniffs/Operators/OperatorSpacingSniff.php | 18 +- .../Classes/AnonClassDeclarationUnitTest.inc | 6 + .../AnonClassDeclarationUnitTest.inc.fixed | 5 + .../Classes/AnonClassDeclarationUnitTest.php | 4 +- .../Classes/ClassInstantiationUnitTest.inc | 4 + .../ClassInstantiationUnitTest.inc.fixed | 4 + .../Classes/ClassInstantiationUnitTest.php | 2 +- .../Tests/Classes/ClosingBraceUnitTest.php | 2 +- .../Classes/OpeningBraceSpaceUnitTest.php | 2 +- .../BooleanOperatorPlacementUnitTest.php | 2 +- .../ControlStructureSpacingUnitTest.php | 2 +- ...est.inc => DeclareStatementUnitTest.1.inc} | 0 ...d => DeclareStatementUnitTest.1.inc.fixed} | 0 .../Files/DeclareStatementUnitTest.2.inc | 3 + .../Tests/Files/DeclareStatementUnitTest.php | 61 +- .../PSR12/Tests/Files/FileHeaderUnitTest.php | 2 +- .../Tests/Files/ImportStatementUnitTest.php | 2 +- .../PSR12/Tests/Files/OpenTagUnitTest.php | 2 +- .../NullableTypeDeclarationUnitTest.php | 2 +- .../ReturnTypeDeclarationUnitTest.php | 2 +- .../ShortFormTypeKeywordsUnitTest.php | 2 +- .../CompoundNamespaceDepthUnitTest.php | 2 +- ...Test.inc => OperatorSpacingUnitTest.1.inc} | 2 + ...ed => OperatorSpacingUnitTest.1.inc.fixed} | 2 + .../Operators/OperatorSpacingUnitTest.2.inc | 3 + .../Operators/OperatorSpacingUnitTest.php | 55 +- .../Properties/ConstantVisibilityUnitTest.php | 2 +- .../Tests/Traits/UseDeclarationUnitTest.php | 2 +- .../Sniffs/Classes/ClassDeclarationSniff.php | 75 +- .../Classes/PropertyDeclarationSniff.php | 3 +- .../PSR2/Sniffs/Files/EndFileNewlineSniff.php | 6 +- .../Classes/ClassDeclarationUnitTest.inc | 25 + .../ClassDeclarationUnitTest.inc.fixed | 23 + .../Classes/ClassDeclarationUnitTest.php | 7 +- .../Classes/PropertyDeclarationUnitTest.php | 2 +- .../ControlStructureSpacingUnitTest.php | 2 +- .../ElseIfDeclarationUnitTest.php | 2 +- .../SwitchDeclarationUnitTest.php | 2 +- .../PSR2/Tests/Files/ClosingTagUnitTest.php | 2 +- .../Tests/Files/EndFileNewlineUnitTest.php | 2 +- .../Methods/FunctionCallSignatureUnitTest.php | 2 +- .../Methods/FunctionClosingBraceUnitTest.php | 2 +- .../Methods/MethodDeclarationUnitTest.php | 2 +- .../NamespaceDeclarationUnitTest.php | 2 +- .../Namespaces/UseDeclarationUnitTest.17.inc | 2 +- .../Namespaces/UseDeclarationUnitTest.php | 2 +- .../Arrays/ArrayBracketSpacingStandard.xml | 4 +- .../LowercaseClassKeywordsStandard.xml | 4 +- .../Classes/SelfMemberReferenceStandard.xml | 12 +- .../DocCommentAlignmentStandard.xml | 8 +- .../FunctionCommentThrowTagStandard.xml | 4 +- .../ForEachLoopDeclarationStandard.xml | 8 +- .../ForLoopDeclarationStandard.xml | 12 +- .../LowercaseDeclarationStandard.xml | 4 +- .../FunctionDuplicateArgumentStandard.xml | 4 +- .../LowercaseFunctionKeywordsStandard.xml | 4 +- .../Docs/Scope/StaticThisUsageStandard.xml | 4 +- .../Docs/Strings/EchoedStringsStandard.xml | 4 +- .../Docs/WhiteSpace/CastSpacingStandard.xml | 4 +- .../FunctionOpeningBraceStandard.xml | 8 +- .../LanguageConstructSpacingStandard.xml | 4 +- .../WhiteSpace/MemberVarSpacingStandard.xml | 91 + .../ObjectOperatorSpacingStandard.xml | 4 +- .../WhiteSpace/ScopeClosingBraceStandard.xml | 59 + .../ScopeKeywordSpacingStandard.xml | 4 +- .../WhiteSpace/SemicolonSpacingStandard.xml | 4 +- .../SuperfluousWhitespaceStandard.xml | 98 + .../Sniffs/Arrays/ArrayDeclarationSniff.php | 6 +- .../ClassDefinitionClosingBraceSpaceSniff.php | 2 + .../CSS/ClassDefinitionNameSpacingSniff.php | 2 + .../ClassDefinitionOpeningBraceSpaceSniff.php | 2 + .../Squiz/Sniffs/CSS/ColonSpacingSniff.php | 2 + .../Sniffs/CSS/ColourDefinitionSniff.php | 2 + .../DisallowMultipleStyleDefinitionsSniff.php | 2 + .../CSS/DuplicateClassDefinitionSniff.php | 2 + .../CSS/DuplicateStyleDefinitionSniff.php | 2 + .../Sniffs/CSS/EmptyClassDefinitionSniff.php | 2 + .../Sniffs/CSS/EmptyStyleDefinitionSniff.php | 2 + .../Squiz/Sniffs/CSS/ForbiddenStylesSniff.php | 2 + .../Squiz/Sniffs/CSS/IndentationSniff.php | 2 + .../CSS/LowercaseStyleDefinitionSniff.php | 2 + .../Squiz/Sniffs/CSS/MissingColonSniff.php | 2 + .../Squiz/Sniffs/CSS/NamedColoursSniff.php | 2 + .../Squiz/Sniffs/CSS/OpacitySniff.php | 2 + .../Sniffs/CSS/SemicolonSpacingSniff.php | 2 + .../Squiz/Sniffs/CSS/ShorthandSizeSniff.php | 2 + .../Sniffs/Classes/DuplicatePropertySniff.php | 2 + .../ClosingDeclarationCommentSniff.php | 2 +- .../Sniffs/Commenting/FileCommentSniff.php | 10 +- .../Commenting/FunctionCommentSniff.php | 5 +- .../Squiz/Sniffs/Debug/JSLintSniff.php | 6 +- .../Sniffs/Debug/JavaScriptLintSniff.php | 6 +- .../Squiz/Sniffs/Files/FileExtensionSniff.php | 2 +- .../DisallowObjectStringIndexSniff.php | 2 + .../Sniffs/Objects/ObjectMemberCommaSniff.php | 2 + .../IncrementDecrementUsageSniff.php | 20 +- .../Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 242 +- .../Squiz/Sniffs/PHP/InnerFunctionsSniff.php | 2 +- .../Sniffs/PHP/NonExecutableCodeSniff.php | 2 +- .../LanguageConstructSpacingSniff.php | 2 + .../WhiteSpace/MemberVarSpacingSniff.php | 4 +- .../WhiteSpace/OperatorSpacingSniff.php | 27 +- .../WhiteSpace/PropertyLabelSpacingSniff.php | 2 + .../Arrays/ArrayBracketSpacingUnitTest.php | 2 +- .../Arrays/ArrayDeclarationUnitTest.1.inc | 12 + .../ArrayDeclarationUnitTest.1.inc.fixed | 15 + .../Arrays/ArrayDeclarationUnitTest.2.inc | 12 + .../ArrayDeclarationUnitTest.2.inc.fixed | 15 + .../Tests/Arrays/ArrayDeclarationUnitTest.php | 6 +- ...assDefinitionClosingBraceSpaceUnitTest.php | 2 +- .../ClassDefinitionNameSpacingUnitTest.php | 2 +- ...assDefinitionOpeningBraceSpaceUnitTest.php | 2 +- .../Squiz/Tests/CSS/ColonSpacingUnitTest.php | 2 +- .../Tests/CSS/ColourDefinitionUnitTest.php | 2 +- ...sallowMultipleStyleDefinitionsUnitTest.php | 2 +- .../CSS/DuplicateClassDefinitionUnitTest.php | 2 +- .../CSS/DuplicateStyleDefinitionUnitTest.php | 2 +- .../CSS/EmptyClassDefinitionUnitTest.php | 2 +- .../CSS/EmptyStyleDefinitionUnitTest.php | 2 +- .../Tests/CSS/ForbiddenStylesUnitTest.php | 2 +- .../Squiz/Tests/CSS/IndentationUnitTest.php | 2 +- .../CSS/LowercaseStyleDefinitionUnitTest.php | 2 +- .../Squiz/Tests/CSS/MissingColonUnitTest.php | 2 +- .../Squiz/Tests/CSS/NamedColoursUnitTest.php | 2 +- .../Squiz/Tests/CSS/OpacityUnitTest.php | 2 +- .../Tests/CSS/SemicolonSpacingUnitTest.php | 2 +- .../Squiz/Tests/CSS/ShorthandSizeUnitTest.php | 2 +- .../Classes/ClassDeclarationUnitTest.php | 2 +- .../Tests/Classes/ClassFileNameUnitTest.php | 2 +- .../Classes/DuplicatePropertyUnitTest.php | 2 +- .../LowercaseClassKeywordsUnitTest.inc | 2 + .../LowercaseClassKeywordsUnitTest.inc.fixed | 2 + .../LowercaseClassKeywordsUnitTest.php | 3 +- .../Classes/SelfMemberReferenceUnitTest.php | 2 +- .../Tests/Classes/ValidClassNameUnitTest.php | 2 +- .../Tests/Commenting/BlockCommentUnitTest.php | 2 +- .../Tests/Commenting/ClassCommentUnitTest.php | 2 +- ...losingDeclarationCommentUnitTest.inc.fixed | 85 + .../ClosingDeclarationCommentUnitTest.php | 2 +- .../DocCommentAlignmentUnitTest.php | 2 +- .../Commenting/EmptyCatchCommentUnitTest.php | 2 +- .../Tests/Commenting/FileCommentUnitTest.php | 2 +- .../FunctionCommentThrowTagUnitTest.php | 2 +- .../Commenting/FunctionCommentUnitTest.inc | 24 + .../FunctionCommentUnitTest.inc.fixed | 24 + .../Commenting/FunctionCommentUnitTest.php | 10 +- .../Commenting/InlineCommentUnitTest.php | 2 +- .../LongConditionClosingCommentUnitTest.php | 2 +- .../PostStatementCommentUnitTest.php | 2 +- .../Commenting/VariableCommentUnitTest.php | 2 +- .../ControlSignatureUnitTest.php | 2 +- .../ElseIfDeclarationUnitTest.php | 2 +- .../ForEachLoopDeclarationUnitTest.php | 2 +- .../ForLoopDeclarationUnitTest.php | 2 +- .../InlineIfDeclarationUnitTest.php | 2 +- .../LowercaseDeclarationUnitTest.php | 2 +- .../SwitchDeclarationUnitTest.php | 2 +- .../Squiz/Tests/Debug/JSLintUnitTest.php | 2 +- .../Tests/Debug/JavaScriptLintUnitTest.php | 2 +- .../Tests/Files/FileExtensionUnitTest.php | 2 +- .../Formatting/OperatorBracketUnitTest.php | 2 +- ...tionDeclarationArgumentSpacingUnitTest.php | 2 +- .../Functions/FunctionDeclarationUnitTest.php | 2 +- .../FunctionDuplicateArgumentUnitTest.php | 2 +- .../Functions/GlobalFunctionUnitTest.php | 2 +- .../LowercaseFunctionKeywordsUnitTest.php | 2 +- .../MultiLineFunctionDeclarationUnitTest.php | 2 +- .../ValidFunctionNameUnitTest.php | 2 +- .../ValidVariableNameUnitTest.php | 2 +- .../DisallowObjectStringIndexUnitTest.php | 2 +- .../Objects/ObjectInstantiationUnitTest.php | 2 +- .../Objects/ObjectMemberCommaUnitTest.php | 2 +- .../ComparisonOperatorUsageUnitTest.php | 2 +- .../IncrementDecrementUsageUnitTest.inc | 14 + .../IncrementDecrementUsageUnitTest.php | 10 +- .../ValidLogicalOperatorsUnitTest.php | 2 +- .../Tests/PHP/CommentedOutCodeUnitTest.php | 2 +- .../PHP/DisallowBooleanStatementUnitTest.php | 2 +- .../DisallowComparisonAssignmentUnitTest.php | 2 +- .../Tests/PHP/DisallowInlineIfUnitTest.php | 2 +- .../DisallowMultipleAssignmentsUnitTest.php | 2 +- .../DisallowSizeFunctionsInLoopsUnitTest.php | 2 +- .../PHP/DiscouragedFunctionsUnitTest.php | 2 +- .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc | 271 ++ .../Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed | 283 ++ .../Tests/PHP/EmbeddedPhpUnitTest.10.inc | 16 + .../Tests/PHP/EmbeddedPhpUnitTest.11.inc | 14 + .../Tests/PHP/EmbeddedPhpUnitTest.12.inc | 12 + .../PHP/EmbeddedPhpUnitTest.12.inc.fixed | 10 + .../Tests/PHP/EmbeddedPhpUnitTest.13.inc | 12 + .../PHP/EmbeddedPhpUnitTest.13.inc.fixed | 10 + .../Tests/PHP/EmbeddedPhpUnitTest.14.inc | 8 + .../Tests/PHP/EmbeddedPhpUnitTest.15.inc | 9 + .../Tests/PHP/EmbeddedPhpUnitTest.16.inc | 8 + .../Tests/PHP/EmbeddedPhpUnitTest.17.inc | 8 + .../Tests/PHP/EmbeddedPhpUnitTest.18.inc | 15 + .../PHP/EmbeddedPhpUnitTest.18.inc.fixed | 13 + .../Tests/PHP/EmbeddedPhpUnitTest.19.inc | 17 + .../PHP/EmbeddedPhpUnitTest.19.inc.fixed | 15 + .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc | 7 + .../Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed | 7 + .../Tests/PHP/EmbeddedPhpUnitTest.20.inc | 15 + .../PHP/EmbeddedPhpUnitTest.20.inc.fixed | 16 + .../Tests/PHP/EmbeddedPhpUnitTest.21.inc | 15 + .../PHP/EmbeddedPhpUnitTest.21.inc.fixed | 16 + .../Tests/PHP/EmbeddedPhpUnitTest.22.inc | 30 + .../PHP/EmbeddedPhpUnitTest.22.inc.fixed | 31 + .../Tests/PHP/EmbeddedPhpUnitTest.23.inc | 23 + .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.3.inc | 123 + .../Tests/PHP/EmbeddedPhpUnitTest.3.inc.fixed | 132 + .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.4.inc | 7 + .../Tests/PHP/EmbeddedPhpUnitTest.4.inc.fixed | 7 + .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.5.inc | 48 + .../Tests/PHP/EmbeddedPhpUnitTest.5.inc.fixed | 39 + .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.6.inc | 8 + .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.7.inc | 8 + .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.8.inc | 10 + .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.9.inc | 10 + .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc | 119 - .../Tests/PHP/EmbeddedPhpUnitTest.inc.fixed | 119 - .../Squiz/Tests/PHP/EmbeddedPhpUnitTest.php | 198 +- .../Squiz/Tests/PHP/EvalUnitTest.php | 2 +- .../Squiz/Tests/PHP/GlobalKeywordUnitTest.php | 2 +- .../Squiz/Tests/PHP/HeredocUnitTest.php | 2 +- .../Tests/PHP/InnerFunctionsUnitTest.php | 2 +- .../PHP/LowercasePHPFunctionsUnitTest.php | 2 +- .../Tests/PHP/NonExecutableCodeUnitTest.php | 2 +- .../Tests/Scope/MemberVarScopeUnitTest.php | 2 +- .../Squiz/Tests/Scope/MethodScopeUnitTest.php | 2 +- .../Tests/Scope/StaticThisUsageUnitTest.php | 2 +- .../Strings/ConcatenationSpacingUnitTest.php | 2 +- .../Strings/DoubleQuoteUsageUnitTest.php | 2 +- .../Tests/Strings/EchoedStringsUnitTest.php | 2 +- .../Tests/WhiteSpace/CastSpacingUnitTest.php | 2 +- .../ControlStructureSpacingUnitTest.php | 2 +- .../FunctionClosingBraceSpaceUnitTest.php | 2 +- .../FunctionOpeningBraceSpaceUnitTest.php | 2 +- .../WhiteSpace/FunctionSpacingUnitTest.php | 2 +- .../LanguageConstructSpacingUnitTest.php | 2 +- .../LogicalOperatorSpacingUnitTest.php | 2 +- .../WhiteSpace/MemberVarSpacingUnitTest.php | 2 +- .../ObjectOperatorSpacingUnitTest.php | 2 +- ...Test.inc => OperatorSpacingUnitTest.1.inc} | 0 ...ed => OperatorSpacingUnitTest.1.inc.fixed} | 0 .../WhiteSpace/OperatorSpacingUnitTest.2.inc | 3 + .../WhiteSpace/OperatorSpacingUnitTest.php | 4 +- .../PropertyLabelSpacingUnitTest.php | 2 +- .../WhiteSpace/ScopeClosingBraceUnitTest.php | 2 +- .../ScopeKeywordSpacingUnitTest.1.inc | 8 + .../ScopeKeywordSpacingUnitTest.1.inc.fixed | 8 + .../ScopeKeywordSpacingUnitTest.php | 4 +- .../WhiteSpace/SemicolonSpacingUnitTest.php | 2 +- .../SuperfluousWhitespaceUnitTest.php | 2 +- .../Zend/Sniffs/Debug/CodeAnalyzerSniff.php | 6 +- .../Zend/Sniffs/Files/ClosingTagSniff.php | 4 +- .../ValidVariableNameSniff.php | 2 +- .../Zend/Tests/Debug/CodeAnalyzerUnitTest.php | 2 +- .../Zend/Tests/Files/ClosingTagUnitTest.php | 2 +- .../ValidVariableNameUnitTest.php | 2 +- .../src/Tokenizers/Comment.php | 10 +- .../php_codesniffer/src/Tokenizers/PHP.php | 243 +- .../src/Tokenizers/Tokenizer.php | 33 +- .../php_codesniffer/src/Util/Cache.php | 12 +- .../php_codesniffer/src/Util/Common.php | 4 +- .../php_codesniffer/src/Util/Standards.php | 5 +- .../php_codesniffer/tests/ConfigDouble.php | 196 ++ .../tests/Core/AbstractMethodUnitTest.php | 86 +- .../php_codesniffer/tests/Core/AllTests.php | 2 +- .../Autoloader/DetermineLoadedClassTest.php | 2 +- .../tests/Core/Config/ReportWidthTest.php | 12 +- .../tests/Core/ErrorSuppressionTest.php | 180 +- .../Core/File/FindEndOfStatementTest.php | 2 +- .../Core/File/FindExtendedClassNameTest.php | 4 +- .../FindImplementedInterfaceNamesTest.php | 24 +- .../Core/File/FindStartOfStatementTest.php | 2 +- .../Core/File/GetClassPropertiesTest.php | 14 +- .../tests/Core/File/GetConditionTest.php | 2 +- .../Core/File/GetDeclarationNameJSTest.php | 2 +- .../Core/File/GetDeclarationNameTest.php | 2 +- .../Core/File/GetMemberPropertiesTest.php | 6 +- .../GetMethodParametersParseError1Test.php | 2 +- .../GetMethodParametersParseError2Test.php | 2 +- .../Core/File/GetMethodParametersTest.php | 14 +- .../Core/File/GetMethodPropertiesTest.inc | 5 + .../Core/File/GetMethodPropertiesTest.php | 28 +- .../tests/Core/File/GetTokensAsStringTest.php | 6 +- .../tests/Core/File/IsReferenceTest.inc | 2 +- .../tests/Core/File/IsReferenceTest.php | 10 +- .../Core/Filters/AbstractFilterTestCase.php | 12 +- .../tests/Core/Filters/Filter/AcceptTest.php | 6 +- .../tests/Core/Filters/GitModifiedTest.php | 20 +- .../tests/Core/Filters/GitStagedTest.php | 20 +- .../GenerateDiffTest-BlankLinesAtEnd.diff | 10 + .../GenerateDiffTest-BlankLinesAtEnd.inc | 11 + .../GenerateDiffTest-BlankLinesAtStart.diff | 9 + .../GenerateDiffTest-BlankLinesAtStart.inc | 10 + .../Fixtures/GenerateDiffTest-LineAdded.diff | 8 + .../Fixtures/GenerateDiffTest-LineAdded.inc | 6 + .../GenerateDiffTest-LineRemoved.diff | 8 + .../Fixtures/GenerateDiffTest-LineRemoved.inc | 8 + .../Fixtures/GenerateDiffTest-NoDiff.diff | 0 .../Fixtures/GenerateDiffTest-NoDiff.inc | 7 + ...GenerateDiffTest-NoTrailingWhitespace.diff | 9 + .../GenerateDiffTest-NoTrailingWhitespace.inc | 7 + .../GenerateDiffTest-TabsToSpaces.diff | 9 + .../GenerateDiffTest-TabsToSpaces.inc | 7 + .../GenerateDiffTest-VarNameChanged.diff | 12 + .../GenerateDiffTest-VarNameChanged.inc | 7 + .../GenerateDiffTest-WhiteSpaceAtEnd.diff | 8 + .../GenerateDiffTest-WhiteSpaceAtEnd.inc | 7 + .../GenerateDiffTest-WhiteSpaceAtStart.diff | 8 + .../GenerateDiffTest-WhiteSpaceAtStart.inc | 7 + .../GenerateDiffTest-WindowsLineEndings.inc | 7 + .../Core/Fixer/Fixtures/GenerateDiffTest.inc | 7 + .../tests/Core/Fixer/GenerateDiffTest.php | 226 ++ .../Core/Ruleset/ExplainCustomRulesetTest.xml | 10 + .../Core/Ruleset/ExplainSingleSniffTest.xml | 6 + .../tests/Core/Ruleset/ExplainTest.php | 204 +- .../Deprecated/WithLongReplacementSniff.php | 41 + ...eplacementContainingLinuxNewlinesSniff.php | 45 + ...WithReplacementContainingNewlinesSniff.php | 45 + .../Deprecated/WithReplacementSniff.php | 41 + .../Deprecated/WithoutReplacementSniff.php | 41 + .../EmptyDeprecationVersionSniff.php | 41 + .../EmptyRemovalVersionSniff.php | 41 + .../InvalidDeprecationMessageSniff.php | 42 + .../InvalidDeprecationVersionSniff.php | 41 + .../InvalidRemovalVersionSniff.php | 41 + .../AllowedAsDeclaredSniff.php} | 4 +- .../AllowedViaMagicMethodSniff.php} | 4 +- .../AllowedViaStdClassSniff.php} | 4 +- .../NotAllowedViaAttributeSniff.php} | 4 +- .../tests/Core/Ruleset/Fixtures/ruleset.xml | 4 + .../RuleInclusionAbsoluteLinuxTest.php | 6 +- .../RuleInclusionAbsoluteWindowsTest.php | 6 +- .../tests/Core/Ruleset/RuleInclusionTest.php | 96 +- .../tests/Core/Ruleset/RuleInclusionTest.xml | 2 +- .../SetPropertyAllowedAsDeclaredTest.xml | 2 +- .../SetPropertyAllowedViaMagicMethodTest.xml | 2 +- .../SetPropertyAllowedViaStdClassTest.xml | 2 +- .../SetPropertyNotAllowedViaAttributeTest.xml | 2 +- .../Core/Ruleset/SetSniffPropertyTest.php | 88 +- ...eprecationsEmptyDeprecationVersionTest.xml | 8 + ...iffDeprecationsEmptyRemovalVersionTest.xml | 8 + ...recationsInvalidDeprecationMessageTest.xml | 8 + ...recationsInvalidDeprecationVersionTest.xml | 8 + ...fDeprecationsInvalidRemovalVersionTest.xml | 8 + .../ShowSniffDeprecationsOrderTest.xml | 10 + .../ShowSniffDeprecationsReportWidthTest.xml | 8 + .../Ruleset/ShowSniffDeprecationsTest.php | 510 +++ .../Ruleset/ShowSniffDeprecationsTest.xml | 10 + .../Core/Sniffs/AbstractArraySniffTest.php | 2 +- .../Tokenizer/AbstractTokenizerTestCase.php | 126 + .../AnonClassParenthesisOwnerTest.inc | 10 + .../AnonClassParenthesisOwnerTest.php | 40 +- .../tests/Core/Tokenizer/ArrayKeywordTest.inc | 10 +- .../tests/Core/Tokenizer/ArrayKeywordTest.php | 77 +- .../tests/Core/Tokenizer/AttributesTest.php | 220 +- .../tests/Core/Tokenizer/BackfillEnumTest.inc | 4 - .../tests/Core/Tokenizer/BackfillEnumTest.php | 219 +- .../BackfillExplicitOctalNotationTest.php | 30 +- .../Core/Tokenizer/BackfillFnTokenTest.php | 144 +- .../Core/Tokenizer/BackfillMatchTokenTest.php | 349 +- .../BackfillNumericSeparatorTest.php | 255 +- .../Core/Tokenizer/BackfillReadonlyTest.inc | 15 +- .../Core/Tokenizer/BackfillReadonlyTest.php | 319 +- .../tests/Core/Tokenizer/BitwiseOrTest.inc | 36 +- .../tests/Core/Tokenizer/BitwiseOrTest.php | 143 +- .../ContextSensitiveKeywordsTest.inc | 49 +- .../ContextSensitiveKeywordsTest.php | 777 +++-- .../Core/Tokenizer/DefaultKeywordTest.php | 178 +- .../tests/Core/Tokenizer/DoubleArrowTest.php | 22 +- .../Core/Tokenizer/DoubleQuotedStringTest.php | 58 +- .../tests/Core/Tokenizer/EnumCaseTest.php | 95 +- .../tests/Core/Tokenizer/FinallyTest.php | 42 +- .../tests/Core/Tokenizer/GotoLabelTest.php | 95 +- .../Tokenizer/HeredocNowdocCloserTest.php | 64 +- .../Core/Tokenizer/HeredocStringTest.php | 58 +- .../NamedFunctionCallArgumentsTest.inc | 6 +- .../NamedFunctionCallArgumentsTest.php | 364 ++- .../Tokenizer/NullsafeObjectOperatorTest.php | 45 +- .../OtherContextSensitiveKeywordsTest.inc | 67 + .../OtherContextSensitiveKeywordsTest.php | 283 ++ .../Core/Tokenizer/ResolveSimpleTokenTest.inc | 51 + .../Core/Tokenizer/ResolveSimpleTokenTest.php | 432 +++ .../ScopeSettingWithNamespaceOperatorTest.php | 60 +- .../tests/Core/Tokenizer/ShortArrayTest.php | 46 +- .../Tokenizer/StableCommentWhitespaceTest.php | 205 +- .../StableCommentWhitespaceWinTest.php | 115 +- .../Core/Tokenizer/TypeIntersectionTest.inc | 36 +- .../Core/Tokenizer/TypeIntersectionTest.php | 135 +- .../Core/Tokenizer/TypedConstantsTest.inc | 132 + .../Core/Tokenizer/TypedConstantsTest.php | 515 +++ .../UndoNamespacedNameSingleTokenTest.inc | 2 +- .../UndoNamespacedNameSingleTokenTest.php | 296 +- .../tests/Core/Util/IsCamelCapsTest.php | 2 +- .../tests/Core/Util/SuggestTypeTest.php | 8 +- .../php_codesniffer/tests/FileList.php | 16 +- .../tests/Standards/AbstractSniffUnitTest.php | 26 +- .../tests/Standards/AllSniffs.php | 8 +- .../php_codesniffer/tests/TestSuite.php | 2 +- .../php_codesniffer/tests/TestSuite7.php | 4 +- .../php_codesniffer/tests/bootstrap.php | 6 +- 734 files changed, 17371 insertions(+), 5533 deletions(-) create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/CategorySniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/DocblockDescriptionSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/FileExpectedTagsSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/MissingDocblockSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/PackageSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/ValidTagsSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/VariableCommentSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/LangFilesOrderingSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/Methods/MethodDeclarationSpacingSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCasesAbstractSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestClassesFinalSniff.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Util/Docblocks.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Util/TokenUtil.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Util/TypeUtil.php create mode 100644 vendor/moodlehq/moodle-cs/moodle/Util/apis.json create mode 100644 vendor/moodlehq/moodle-cs/phpcs.xml.dist create mode 100644 vendor/squizlabs/php_codesniffer/src/Sniffs/DeprecatedSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceStandard.xml create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/PHP/RequireStrictTypesStandard.xml create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/WhiteSpace/IncrementDecrementSpacingStandard.xml create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.1.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.3.inc delete mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/ForLoopWithTestFunctionCallUnitTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceUnitTest.php rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/{UnnecessaryFinalModifierUnitTest.inc => UnnecessaryFinalModifierUnitTest.1.inc} (54%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.2.inc rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/{UnusedFunctionParameterUnitTest.inc => UnusedFunctionParameterUnitTest.1.inc} (90%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.3.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.1.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.3.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.4.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.5.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.6.inc delete mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UselessOverridingMethodUnitTest.inc rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/{DocCommentUnitTest.inc => DocCommentUnitTest.1.inc} (98%) rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/{DocCommentUnitTest.inc.fixed => DocCommentUnitTest.1.inc.fixed} (98%) rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/{DocCommentUnitTest.js => DocCommentUnitTest.1.js} (95%) rename vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/{DocCommentUnitTest.js.fixed => DocCommentUnitTest.1.js.fixed} (95%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.2.js create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.1.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.3.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.4.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.5.inc delete mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Files/ImportStatementStandard.xml create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Functions/ReturnTypeDeclarationStandard.xml create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Properties/ConstantVisibilityStandard.xml rename vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Files/{DeclareStatementUnitTest.inc => DeclareStatementUnitTest.1.inc} (100%) rename vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Files/{DeclareStatementUnitTest.inc.fixed => DeclareStatementUnitTest.1.inc.fixed} (100%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Files/DeclareStatementUnitTest.2.inc rename vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Operators/{OperatorSpacingUnitTest.inc => OperatorSpacingUnitTest.1.inc} (98%) rename vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Operators/{OperatorSpacingUnitTest.inc.fixed => OperatorSpacingUnitTest.1.inc.fixed} (98%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Docs/WhiteSpace/MemberVarSpacingStandard.xml create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Docs/WhiteSpace/ScopeClosingBraceStandard.xml create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Docs/WhiteSpace/SuperfluousWhitespaceStandard.xml create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.1.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.10.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.11.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.12.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.12.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.13.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.13.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.14.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.15.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.16.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.17.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.18.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.19.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.2.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.20.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.21.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.22.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.22.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.23.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.3.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.3.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.4.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.4.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.5.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.5.inc.fixed create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.6.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.7.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.8.inc create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.9.inc delete mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc delete mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed rename vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/{OperatorSpacingUnitTest.inc => OperatorSpacingUnitTest.1.inc} (100%) rename vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/{OperatorSpacingUnitTest.inc.fixed => OperatorSpacingUnitTest.1.inc.fixed} (100%) create mode 100644 vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.2.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/ConfigDouble.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-BlankLinesAtEnd.diff create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-BlankLinesAtEnd.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-BlankLinesAtStart.diff create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-BlankLinesAtStart.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-LineAdded.diff create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-LineAdded.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-LineRemoved.diff create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-LineRemoved.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-NoDiff.diff create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-NoDiff.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-NoTrailingWhitespace.diff create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-NoTrailingWhitespace.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-TabsToSpaces.diff create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-TabsToSpaces.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-VarNameChanged.diff create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-VarNameChanged.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-WhiteSpaceAtEnd.diff create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-WhiteSpaceAtEnd.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-WhiteSpaceAtStart.diff create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-WhiteSpaceAtStart.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest-WindowsLineEndings.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/Fixtures/GenerateDiffTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Fixer/GenerateDiffTest.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ExplainCustomRulesetTest.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ExplainSingleSniffTest.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithLongReplacementSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithReplacementSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/Deprecated/WithoutReplacementSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php rename vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/{Category/SetPropertyAllowedAsDeclaredSniff.php => SetProperty/AllowedAsDeclaredSniff.php} (81%) rename vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/{Category/SetPropertyAllowedViaMagicMethodSniff.php => SetProperty/AllowedViaMagicMethodSniff.php} (86%) rename vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/{Category/SetPropertyAllowedViaStdClassSniff.php => SetProperty/AllowedViaStdClassSniff.php} (76%) rename vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/Sniffs/{Category/SetPropertyNotAllowedViaAttributeSniff.php => SetProperty/NotAllowedViaAttributeSniff.php} (80%) create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/Fixtures/ruleset.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ShowSniffDeprecationsEmptyDeprecationVersionTest.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ShowSniffDeprecationsEmptyRemovalVersionTest.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationMessageTest.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ShowSniffDeprecationsInvalidDeprecationVersionTest.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ShowSniffDeprecationsInvalidRemovalVersionTest.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ShowSniffDeprecationsTest.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/AbstractTokenizerTestCase.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/OtherContextSensitiveKeywordsTest.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ResolveSimpleTokenTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/ResolveSimpleTokenTest.php create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypedConstantsTest.inc create mode 100644 vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/TypedConstantsTest.php diff --git a/composer.json b/composer.json index 7e8c4700..cbe8db21 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.3.14", - "phpcompatibility/php-compatibility": "dev-develop#306cd263" + "moodlehq/moodle-cs": "^v3.4.6", + "phpcompatibility/php-compatibility": "dev-develop#e5cd2e24" }, "config": { "platform": { diff --git a/composer.lock b/composer.lock index 703eb2e8..2c100d32 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": "566c53d515b70941ece9e3c0cae8be12", + "content-hash": "a04f685b76dc383abef9d8fd22fb316f", "packages": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -86,23 +86,25 @@ }, { "name": "moodlehq/moodle-cs", - "version": "v3.3.15", + "version": "v3.4.6", "source": { "type": "git", "url": "https://github.com/moodlehq/moodle-cs.git", - "reference": "3a95fd8402231bfbac4e55301ed151518f2043c3" + "reference": "02a279ecbd9431172e8eeee5385d4f6ec57c957b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/moodlehq/moodle-cs/zipball/3a95fd8402231bfbac4e55301ed151518f2043c3", - "reference": "3a95fd8402231bfbac4e55301ed151518f2043c3", + "url": "https://api.github.com/repos/moodlehq/moodle-cs/zipball/02a279ecbd9431172e8eeee5385d4f6ec57c957b", + "reference": "02a279ecbd9431172e8eeee5385d4f6ec57c957b", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", - "phpcompatibility/php-compatibility": "dev-develop#306cd263", + "ext-json": "*", + "php": ">=7.4.0", + "phpcompatibility/php-compatibility": "dev-develop#e5cd2e24", "phpcsstandards/phpcsextra": "^1.2.1", - "squizlabs/php_codesniffer": "^3.8.1" + "squizlabs/php_codesniffer": "^3.9.0" }, "replace": { "moodlehq/moodle-local_codechecker": "3.1.0" @@ -150,7 +152,7 @@ "source": "https://github.com/moodlehq/moodle-cs", "wiki": "https://github.com/moodlehq/moodle-cs/wiki" }, - "time": "2024-02-15T18:18:01+00:00" + "time": "2024-04-03T07:22:20+00:00" }, { "name": "phpcompatibility/php-compatibility", @@ -158,18 +160,18 @@ "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "306cd263" + "reference": "e5cd2e24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/306cd263", - "reference": "306cd263", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/e5cd2e24", + "reference": "e5cd2e24", "shasum": "" }, "require": { "php": ">=5.4", "phpcsstandards/phpcsutils": "^1.0.9", - "squizlabs/php_codesniffer": "^3.8.0" + "squizlabs/php_codesniffer": "^3.9.0" }, "replace": { "wimg/php-compatibility": "*" @@ -240,7 +242,7 @@ "type": "open_collective" } ], - "time": "2024-02-12T16:57:44+00:00" + "time": "2024-04-08T09:51:59+00:00" }, { "name": "phpcsstandards/phpcsextra", @@ -322,22 +324,22 @@ }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.9", + "version": "1.0.10", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "908247bc65010c7b7541a9551e002db12e9dae70" + "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/908247bc65010c7b7541a9551e002db12e9dae70", - "reference": "908247bc65010c7b7541a9551e002db12e9dae70", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/51609a5b89f928e0c463d6df80eb38eff1eaf544", + "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544", "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.8.0 || 4.0.x-dev@dev" + "squizlabs/php_codesniffer": "^3.9.0 || 4.0.x-dev@dev" }, "require-dev": { "ext-filter": "*", @@ -406,20 +408,20 @@ "type": "open_collective" } ], - "time": "2023-12-08T14:50:00+00:00" + "time": "2024-03-17T23:44:50+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.0", + "version": "3.9.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", "shasum": "" }, "require": { @@ -486,7 +488,7 @@ "type": "open_collective" } ], - "time": "2024-02-16T15:06:51+00:00" + "time": "2024-03-31T21:03:09+00:00" } ], "packages-dev": [], diff --git a/vendor/autoload.php b/vendor/autoload.php index 008f6210..4649b6de 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit04850f493c5607268a216c743489db99::getLoader(); +return ComposerAutoloaderInita04f685b76dc383abef9d8fd22fb316f::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 6d8cd7b4..50896cb4 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit04850f493c5607268a216c743489db99 +class ComposerAutoloaderInita04f685b76dc383abef9d8fd22fb316f { private static $loader; @@ -24,12 +24,12 @@ public static function getLoader() require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInit04850f493c5607268a216c743489db99', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInita04f685b76dc383abef9d8fd22fb316f', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit04850f493c5607268a216c743489db99', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInita04f685b76dc383abef9d8fd22fb316f', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit04850f493c5607268a216c743489db99::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInita04f685b76dc383abef9d8fd22fb316f::getInitializer($loader)); $loader->register(true); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index bced0c6d..75c46c4b 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit04850f493c5607268a216c743489db99 +class ComposerStaticInita04f685b76dc383abef9d8fd22fb316f { public static $prefixLengthsPsr4 = array ( 'P' => @@ -72,9 +72,9 @@ class ComposerStaticInit04850f493c5607268a216c743489db99 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit04850f493c5607268a216c743489db99::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit04850f493c5607268a216c743489db99::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit04850f493c5607268a216c743489db99::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInita04f685b76dc383abef9d8fd22fb316f::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInita04f685b76dc383abef9d8fd22fb316f::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInita04f685b76dc383abef9d8fd22fb316f::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 6008784a..2d13f719 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -83,24 +83,26 @@ }, { "name": "moodlehq/moodle-cs", - "version": "v3.3.14", - "version_normalized": "3.3.14.0", + "version": "v3.4.6", + "version_normalized": "3.4.6.0", "source": { "type": "git", "url": "https://github.com/moodlehq/moodle-cs.git", - "reference": "7e12e69578d5bcd3440f83b5936187227231a9ab" + "reference": "02a279ecbd9431172e8eeee5385d4f6ec57c957b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/moodlehq/moodle-cs/zipball/7e12e69578d5bcd3440f83b5936187227231a9ab", - "reference": "7e12e69578d5bcd3440f83b5936187227231a9ab", + "url": "https://api.github.com/repos/moodlehq/moodle-cs/zipball/02a279ecbd9431172e8eeee5385d4f6ec57c957b", + "reference": "02a279ecbd9431172e8eeee5385d4f6ec57c957b", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", - "phpcompatibility/php-compatibility": "dev-develop#306cd263", + "ext-json": "*", + "php": ">=7.4.0", + "phpcompatibility/php-compatibility": "dev-develop#e5cd2e24", "phpcsstandards/phpcsextra": "^1.2.1", - "squizlabs/php_codesniffer": "^3.8.1" + "squizlabs/php_codesniffer": "^3.9.0" }, "replace": { "moodlehq/moodle-local_codechecker": "3.1.0" @@ -114,7 +116,7 @@ "sebastian/phpcpd": "^6.0", "thor-juhasz/phpunit-coverage-check": "^0.3.0" }, - "time": "2024-01-26T15:37:12+00:00", + "time": "2024-04-03T07:22:20+00:00", "type": "phpcodesniffer-standard", "installation-source": "dist", "autoload": { @@ -159,18 +161,18 @@ "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "306cd263" + "reference": "e5cd2e24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/306cd263", - "reference": "306cd263", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/e5cd2e24", + "reference": "e5cd2e24", "shasum": "" }, "require": { "php": ">=5.4", - "phpcsstandards/phpcsutils": "^1.0.5", - "squizlabs/php_codesniffer": "^3.7.1" + "phpcsstandards/phpcsutils": "^1.0.9", + "squizlabs/php_codesniffer": "^3.9.0" }, "replace": { "wimg/php-compatibility": "*" @@ -186,7 +188,7 @@ "suggest": { "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, - "time": "2023-12-04T17:28:03+00:00", + "time": "2024-04-08T09:51:59+00:00", "default-branch": true, "type": "phpcodesniffer-standard", "extra": { @@ -229,6 +231,20 @@ "security": "https://github.com/PHPCompatibility/PHPCompatibility/security/policy", "source": "https://github.com/PHPCompatibility/PHPCompatibility" }, + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], "install-path": "../phpcompatibility/php-compatibility" }, { @@ -314,23 +330,23 @@ }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.9", - "version_normalized": "1.0.9.0", + "version": "1.0.10", + "version_normalized": "1.0.10.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "908247bc65010c7b7541a9551e002db12e9dae70" + "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/908247bc65010c7b7541a9551e002db12e9dae70", - "reference": "908247bc65010c7b7541a9551e002db12e9dae70", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/51609a5b89f928e0c463d6df80eb38eff1eaf544", + "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544", "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.8.0 || 4.0.x-dev@dev" + "squizlabs/php_codesniffer": "^3.9.0 || 4.0.x-dev@dev" }, "require-dev": { "ext-filter": "*", @@ -339,7 +355,7 @@ "phpcsstandards/phpcsdevcs": "^1.1.6", "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" }, - "time": "2023-12-08T14:50:00+00:00", + "time": "2024-03-17T23:44:50+00:00", "type": "phpcodesniffer-standard", "extra": { "branch-alias": { @@ -405,17 +421,17 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.8.1", - "version_normalized": "3.8.1.0", + "version": "3.9.1", + "version_normalized": "3.9.1.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", - "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", "shasum": "" }, "require": { @@ -427,7 +443,7 @@ "require-dev": { "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, - "time": "2024-01-11T20:47:48+00:00", + "time": "2024-03-31T21:03:09+00:00", "bin": [ "bin/phpcbf", "bin/phpcs" diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index b48aeba1..74a94136 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' => '8be89339db4982e9f884f12087dd9e6837a05e6a', + 'reference' => '170623f935acd324534d4cd2265c866e80a131f1', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -22,16 +22,16 @@ 'moodlehq/local_codechecker' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '8be89339db4982e9f884f12087dd9e6837a05e6a', + 'reference' => '170623f935acd324534d4cd2265c866e80a131f1', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false, ), 'moodlehq/moodle-cs' => array( - 'pretty_version' => 'v3.3.14', - 'version' => '3.3.14.0', - 'reference' => '7e12e69578d5bcd3440f83b5936187227231a9ab', + 'pretty_version' => 'v3.4.6', + 'version' => '3.4.6.0', + 'reference' => '02a279ecbd9431172e8eeee5385d4f6ec57c957b', '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' => '306cd263', + 'reference' => 'e5cd2e24', '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.9', - 'version' => '1.0.9.0', - 'reference' => '908247bc65010c7b7541a9551e002db12e9dae70', + 'pretty_version' => '1.0.10', + 'version' => '1.0.10.0', + 'reference' => '51609a5b89f928e0c463d6df80eb38eff1eaf544', 'type' => 'phpcodesniffer-standard', 'install_path' => __DIR__ . '/../phpcsstandards/phpcsutils', 'aliases' => array(), 'dev_requirement' => false, ), 'squizlabs/php_codesniffer' => array( - 'pretty_version' => '3.8.1', - 'version' => '3.8.1.0', - 'reference' => '14f5fff1e64118595db5408e946f3a22c75807f7', + 'pretty_version' => '3.9.1', + 'version' => '3.9.1.0', + 'reference' => '267a4405fff1d9c847134db3a3c92f1ab7f77909', 'type' => 'library', 'install_path' => __DIR__ . '/../squizlabs/php_codesniffer', 'aliases' => array(), diff --git a/vendor/moodlehq/moodle-cs/LICENSE b/vendor/moodlehq/moodle-cs/LICENSE index 94a9ed02..e6000869 100644 --- a/vendor/moodlehq/moodle-cs/LICENSE +++ b/vendor/moodlehq/moodle-cs/LICENSE @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. diff --git a/vendor/moodlehq/moodle-cs/composer.json b/vendor/moodlehq/moodle-cs/composer.json index 1cd3a027..db93c2d4 100644 --- a/vendor/moodlehq/moodle-cs/composer.json +++ b/vendor/moodlehq/moodle-cs/composer.json @@ -22,10 +22,12 @@ } ], "require": { + "php": ">=7.4.0", + "ext-json": "*", "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", - "squizlabs/php_codesniffer": "^3.8.1", + "squizlabs/php_codesniffer": "^3.9.0", "phpcsstandards/phpcsextra": "^1.2.1", - "phpcompatibility/php-compatibility": "dev-develop#306cd263" + "phpcompatibility/php-compatibility": "dev-develop#e5cd2e24" }, "config": { "allow-plugins": { diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/CategorySniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/CategorySniff.php new file mode 100644 index 00000000..f8dbfd1d --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/CategorySniff.php @@ -0,0 +1,81 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting; + +use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; +use MoodleHQ\MoodleCS\moodle\Util\Docblocks; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Files\File; + +/** + * Checks that all test classes and global functions have appropriate @package tags. + * + * @copyright 2024 Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class CategorySniff implements Sniff +{ + /** + * Register for open tag (only process once per file). + */ + public function register() { + return [ + T_DOC_COMMENT_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) { + $docPtr = Docblocks::getDocBlockPointer($phpcsFile, $stackPtr); + if (empty($docPtr)) { + // It should not be possible to reach this line. It is a safety check. + return; // @codeCoverageIgnore + } + + $categoryTokens = Docblocks::getMatchingDocTags($phpcsFile, $docPtr, '@category'); + if (empty($categoryTokens)) { + return; + } + + $tokens = $phpcsFile->getTokens(); + $docblock = $tokens[$docPtr]; + $apis = MoodleUtil::getMoodleApis($phpcsFile); + + foreach ($categoryTokens as $tokenPtr) { + $categoryValuePtr = $phpcsFile->findNext( + T_DOC_COMMENT_STRING, + $tokenPtr, + $docblock['comment_closer'] + ); + $categoryValue = $tokens[$categoryValuePtr]['content']; + if (!in_array($categoryValue, $apis)) { + $phpcsFile->addError( + 'Invalid @category tag value "%s".', + $categoryValuePtr, + 'Invalid', + [$categoryValue] + ); + } + } + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/DocblockDescriptionSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/DocblockDescriptionSniff.php new file mode 100644 index 00000000..74028ea7 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/DocblockDescriptionSniff.php @@ -0,0 +1,108 @@ +. + +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; +use PHP_CodeSniffer\Util\Tokens; + +/** + * Checks that all docblocks for a main scope have a simple description. + * + * This is typically a one-line description. + * + * @copyright 2024 Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class DocblockDescriptionSniff implements Sniff +{ + /** + * Register for open tag (only process once per file). + */ + public function register() { + 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) { + $tokens = $phpcsFile->getTokens(); + $toCheck = []; + + $docblockPtr = Docblocks::getDocBlockPointer($phpcsFile, $stackPtr); + if ($docblockPtr !== null) { + $toCheck[$stackPtr] = $docblockPtr; + } + $find = Tokens::$ooScopeTokens; + $find[T_FUNCTION] = T_FUNCTION; + + $typePtr = $stackPtr + 1; + while ($typePtr = $phpcsFile->findNext($find, $typePtr + 1)) { + $docblockPtr = Docblocks::getDocBlockPointer($phpcsFile, $typePtr); + if ($docblockPtr === null) { + // Other sniffs check for missing blocks. Not my job. + continue; + } + + $toCheck[$typePtr] = $docblockPtr; + } + + foreach ($toCheck as $typePtr => $docblockPtr) { + $docblock = $tokens[$docblockPtr]; + if (count($docblock['comment_tags'])) { + $stopAt = reset($docblock['comment_tags']); + } else { + $stopAt = $docblock['comment_closer']; + } + $faultAtLine = $tokens[$stopAt]['line']; + + $deprecatedTagPtrs = Docblocks::getMatchingDocTags($phpcsFile, $docblockPtr, '@deprecated'); + if (count($deprecatedTagPtrs) > 0) { + // Skip if the docblock contains a @deprecated tag. + continue; + } + + // Skip to the next T_DOC_COMMENT_STAR line. We do not accept single line docblocks. + $docblockLinePtr = $docblockPtr; + while ($docblockLinePtr = $phpcsFile->findNext(T_DOC_COMMENT_STAR, $docblockLinePtr + 1, $stopAt)) { + if ($tokens[$docblockLinePtr]['line'] !== $faultAtLine) { + continue 2; + } + break; + } + + $objectName = TokenUtil::getObjectName($phpcsFile, $typePtr); + $objectType = TokenUtil::getObjectType($phpcsFile, $typePtr); + + $phpcsFile->addError( + 'No one-line description found in phpdocs for docblock of %s %s', + $typePtr, + 'Missing', + [$objectType, $objectName] + ); + } + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/FileExpectedTagsSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/FileExpectedTagsSniff.php new file mode 100644 index 00000000..9a09241f --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/FileExpectedTagsSniff.php @@ -0,0 +1,160 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting; + +use MoodleHQ\MoodleCS\moodle\Util\Docblocks; +use MoodleHQ\MoodleCS\moodle\Util\TokenUtil; +use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Files\File; +use PHPCSUtils\Tokens\Collections; + +/** + * Checks that a file has appropriate tags in either the file, or single artefact block. + * + * @copyright 2024 Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class FileExpectedTagsSniff implements Sniff +{ + /** + * The regular expression used to match the expected license. + * + * Note that the regular expression is applied using preg_quote to escape as required. + * + * Note that, if the regular expression is the empty string, + * then this Sniff will do nothing. + * + * Example values: + * - Empty string or null: No check is done. + * '' + * - The GNU GPL v3 or later license with either http or https license text + * '@https?://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later@': + * + * @var null|string + */ + public ?string $preferredLicenseRegex = '@https?://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later@'; + + /** + * Register for open tag (only process once per file). + */ + public function register() { + 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) { + // Get the stack pointer for the file-level docblock. + $stackPtr = Docblocks::getDocBlockPointer($phpcsFile, $stackPtr); + if ($stackPtr === null) { + // There is no file-level docblock. + + if (TokenUtil::countGlobalScopesInFile($phpcsFile) > 1) { + // There are more than one item in the global scope. + // Only accept the file docblock. + return; + } else { + // There is only one item in the global scope. + // We can accept the file docblock or the item docblock. + $stackPtr = $phpcsFile->findNext(Collections::closedScopes(), 0); + } + } + + $this->processFileCopyright($phpcsFile, $stackPtr); + $this->processFileLicense($phpcsFile, $stackPtr); + } + + /** + * Process the file docblock and check for the presence of a @copyright tag. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position in the stack. + */ + private function processFileCopyright(File $phpcsFile, $stackPtr): void { + $docPtr = Docblocks::getDocBlockPointer($phpcsFile, $stackPtr); + $copyrightTokens = Docblocks::getMatchingDocTags($phpcsFile, $docPtr, '@copyright'); + if (empty($copyrightTokens)) { + if (empty($docPtr)) { + $docPtr = $stackPtr; + } + + $phpcsFile->addError( + 'Missing @copyright tag', + $docPtr, + 'CopyrightTagMissing' + ); + return; + } + } + + /** + * Process the file docblock and check for the presence of a @license tag. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position in the stack. + */ + private function processFileLicense(File $phpcsFile, $stackPtr): void { + $tokens = $phpcsFile->getTokens(); + $docPtr = Docblocks::getDocBlockPointer($phpcsFile, $stackPtr); + $foundTokens = Docblocks::getMatchingDocTags($phpcsFile, $docPtr, '@license'); + if (empty($foundTokens)) { + if ($docPtr) { + $phpcsFile->addError( + 'Missing @license tag', + $docPtr, + 'LicenseTagMissing' + ); + } else { + $phpcsFile->addError( + 'Missing @license tag', + $stackPtr, + 'LicenseTagMissing' + ); + } + return; + } + + // If specified, get the regular expression from the config. + if (($regex = Config::getConfigData('moodleLicenseRegex')) !== null) { + $this->preferredLicenseRegex = $regex; + } + + if ($this->preferredLicenseRegex === '') { + return; + } + + $licensePtr = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $foundTokens[0]); + $license = $tokens[$licensePtr]['content']; + + if (!preg_match($this->preferredLicenseRegex, $license)) { + $phpcsFile->addWarning( + 'Invalid @license tag. Value "%s" does not match expected format', + $licensePtr, + 'LicenseTagInvalid', + [$license] + ); + } + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/InlineCommentSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/InlineCommentSniff.php index 9f478906..84115c19 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/InlineCommentSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/InlineCommentSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Verifies that inline comments conform to their coding standards. @@ -20,9 +21,8 @@ * Based on {@see PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\InlineCommentSniff} * with some customizations to suit our very personal rules. * - * @package local_codechecker - * @copyright 2012 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2012 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** @@ -35,14 +35,12 @@ namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; -class InlineCommentSniff implements Sniff { - +class InlineCommentSniff implements Sniff +{ /** * A list of tokenizers this sniff supports. * @@ -64,9 +62,7 @@ public function register() { T_COMMENT, T_DOC_COMMENT_OPEN_TAG, ]; - - }//end register() - + } /** * Processes this test, when one of its tokens is encountered. @@ -111,18 +107,32 @@ public function process(File $phpcsFile, $stackPtr) { T_REQUIRE_ONCE, ]; + if ($tokens[$nextToken]['code'] === T_ATTRIBUTE) { + // If the next token is an attribute, find the next non-attribute token. + // Note: It is possible for the next token to be another attribute, so we need to loop. + do { + $token = $tokens[$nextToken]; + $nextToken = $phpcsFile->findNext( + Tokens::$emptyTokens, + ($token['attribute_closer'] + 1), + null, + true + ); + } while ($tokens[$nextToken]['code'] === T_ATTRIBUTE); + } + if (in_array($tokens[$nextToken]['code'], $ignore, true) === true) { return; } // Allow phpdoc block before "return new class extends" expressions, // we use those anon classes in places like coverage.php files. - if ($this->is_return_new_class_extends($phpcsFile, $stackPtr)) { + if ($this->isReturnNewClassExtends($phpcsFile, $stackPtr)) { return; } // Allow phpdoc before define() token (see CONTRIB-4150). - if ($tokens[$nextToken]['code'] == T_STRING and $tokens[$nextToken]['content'] == 'define') { + if ($tokens[$nextToken]['code'] == T_STRING && $tokens[$nextToken]['content'] == 'define') { return; } @@ -134,10 +144,11 @@ public function process(File $phpcsFile, $stackPtr) { $ignore[] = T_STRING; $ignore[] = T_OBJECT_OPERATOR; $nextToken = $phpcsFile->findNext($ignore, ($nextToken + 1), null, true); - if ($tokens[$nextToken]['code'] === T_FUNCTION - || $tokens[$nextToken]['code'] === T_CLOSURE - || $tokens[$nextToken]['code'] === T_OBJECT - || $tokens[$nextToken]['code'] === T_PROTOTYPE + if ( + $tokens[$nextToken]['code'] === T_FUNCTION || + $tokens[$nextToken]['code'] === T_CLOSURE || + $tokens[$nextToken]['code'] === T_OBJECT || + $tokens[$nextToken]['code'] === T_PROTOTYPE ) { return; } @@ -162,8 +173,10 @@ public function process(File $phpcsFile, $stackPtr) { true ); // Is it a @var tag in the comment? - if ($tokens[$nextToken]['code'] === T_DOC_COMMENT_TAG && - $tokens[$nextToken]['content'] == '@var') { + if ( + $tokens[$nextToken]['code'] === T_DOC_COMMENT_TAG && + $tokens[$nextToken]['content'] == '@var' + ) { $nextToken = $phpcsFile->findNext( T_DOC_COMMENT_WHITESPACE, ($nextToken + 1), @@ -207,10 +220,10 @@ public function process(File $phpcsFile, $stackPtr) { if (!$nextToken) { // Not valid type-hinting, specialised error. $error = 'Inline doc block type-hinting for \'%s\' does not match next list() variables'; - $data = array($foundvar); + $data = [$foundvar]; $phpcsFile->addError($error, $stackPtr, 'TypeHintingList', $data); } - } else if ($tokens[$nextToken]['code'] === T_FOREACH) { + } elseif ($tokens[$nextToken]['code'] === T_FOREACH) { // Let's look within the foreach if the variable appear after the 'as' token. $astoken = $phpcsFile->findNext( T_AS, @@ -223,13 +236,13 @@ public function process(File $phpcsFile, $stackPtr) { if ($tokens[$variabletoken]['content'] !== $foundvar) { // Not valid type-hinting, specialised error. $error = 'Inline doc block type-hinting for \'%s\' does not match next foreach() as variable'; - $data = array($foundvar, $tokens[$nextToken]['content']); + $data = [$foundvar, $tokens[$nextToken]['content']]; $phpcsFile->addError($error, $stackPtr, 'TypeHintingForeach', $data); } - } else if ($tokens[$nextToken]['content'] !== $foundvar) { + } elseif ($tokens[$nextToken]['content'] !== $foundvar) { // Not valid type-hinting, specialised error. $error = 'Inline doc block type-hinting for \'%s\' does not match next code line \'%s...\''; - $data = array($foundvar, $tokens[$nextToken]['content']); + $data = [$foundvar, $tokens[$nextToken]['content']]; $phpcsFile->addError($error, $stackPtr, 'TypeHintingMatch', $data); } return; // Have finished. @@ -241,7 +254,7 @@ public function process(File $phpcsFile, $stackPtr) { $error = 'Inline doc block comments are not allowed; use "// Comment." instead'; $phpcsFile->addError($error, $stackPtr, 'DocBlock'); } - }//end if + } if ($tokens[$stackPtr]['content'][0] === '#') { $error = 'Perl-style comments are not allowed; use "// Comment." instead'; @@ -261,8 +274,9 @@ public function process(File $phpcsFile, $stackPtr) { } // Special case for JS files. - if ($tokens[$previousContent]['code'] === T_COMMA - || $tokens[$previousContent]['code'] === T_SEMICOLON + if ( + $tokens[$previousContent]['code'] === T_COMMA || + $tokens[$previousContent]['code'] === T_SEMICOLON ) { $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($previousContent - 1), null, true); if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) { @@ -287,14 +301,14 @@ public function process(File $phpcsFile, $stackPtr) { $error = 'Comment separators are not allowed to contain other chars buy hyphens (-). Found: (%s)'; // Basic clean dupes for notification. $wrongcharsfound = implode(array_keys(array_flip(preg_split('//', $wrongcharsfound, -1, PREG_SPLIT_NO_EMPTY)))); - $data = array($wrongcharsfound); + $data = [$wrongcharsfound]; $phpcsFile->addWarning($error, $stackPtr, 'IncorrectCommentSeparator', $data); } // Verify length between 20 and 120. $hyphencount = strlen($matches[1] . $matches[2] . $matches[3]); - if ($hyphencount < 20 or $hyphencount > 120) { + if ($hyphencount < 20 || $hyphencount > 120) { $error = 'Comment separators length must contain 20-120 chars, %s found'; - $phpcsFile->addWarning($error, $stackPtr, 'WrongCommentSeparatorLength', array($hyphencount)); + $phpcsFile->addWarning($error, $stackPtr, 'WrongCommentSeparatorLength', [$hyphencount]); } // Verify it's the first token in the line. $prevToken = $phpcsFile->findPrevious( @@ -303,9 +317,9 @@ public function process(File $phpcsFile, $stackPtr) { null, true ); - if (!empty($prevToken) and $tokens[$prevToken]['line'] == $tokens[$stackPtr]['line']) { + if (!empty($prevToken) && $tokens[$prevToken]['line'] == $tokens[$stackPtr]['line']) { $error = 'Comment separators must be the unique text in the line, code found before'; - $phpcsFile->addWarning($error, $stackPtr, 'WrongCommentCodeFoundBefore', array()); + $phpcsFile->addWarning($error, $stackPtr, 'WrongCommentCodeFoundBefore', []); } // Don't want to continue processing the comment separator. return; @@ -335,7 +349,7 @@ public function process(File $phpcsFile, $stackPtr) { $commentTokens[] = $nextComment; $lastComment = $nextComment; - }//end while + } $commentText = ''; foreach ($commentTokens as $lastCommentToken) { @@ -346,7 +360,7 @@ public function process(File $phpcsFile, $stackPtr) { if ($slashCount > 2) { $error = '%s slashes comments are not allowed; use "// Comment." instead'; - $data = array($slashCount); + $data = [$slashCount]; $phpcsFile->addError($error, $lastCommentToken, 'WrongStyle', $data); } @@ -379,14 +393,14 @@ public function process(File $phpcsFile, $stackPtr) { $comment, ]; $fix = $phpcsFile->addFixableError($error, $lastCommentToken, 'TabBefore', $data); - } else if ($spaceCount === 0) { + } elseif ($spaceCount === 0) { $error = 'No space found before comment text; expected "// %s" but found "%s"'; $data = [ substr($comment, $slashCount), $comment, ]; $fix = $phpcsFile->addFixableError($error, $lastCommentToken, 'NoSpaceBefore', $data); - } else if ($spaceCount > 1) { + } elseif ($spaceCount > 1) { $error = 'Expected 1 space before comment text but found %s; use block comment if you need indentation'; $data = [ $spaceCount, @@ -394,15 +408,15 @@ public function process(File $phpcsFile, $stackPtr) { $comment, ]; $fix = $phpcsFile->addFixableError($error, $lastCommentToken, 'SpacingBefore', $data); - }//end if + } if ($fix === true) { - $newComment = '// '.ltrim($tokens[$lastCommentToken]['content'], "/\t "); + $newComment = '// ' . ltrim($tokens[$lastCommentToken]['content'], "/\t "); $phpcsFile->fixer->replaceToken($lastCommentToken, $newComment); } $commentText .= trim(substr($tokens[$lastCommentToken]['content'], $slashCount)); - }//end foreach + } if ($commentText === '') { $error = 'Blank comments are not allowed'; @@ -440,7 +454,7 @@ public function process(File $phpcsFile, $stackPtr) { $error = 'Inline comments must end in %s'; $ender = ''; foreach ($acceptedClosers as $closerName => $symbol) { - $ender .= ' '.$closerName.','; + $ender .= ' ' . $closerName . ','; } $ender = trim($ender, ' ,'); @@ -486,8 +500,11 @@ public function process(File $phpcsFile, $stackPtr) { $type = end($conditions); $conditionPtr = key($conditions); - if (($type === T_FUNCTION || $type === T_CLOSURE) - && $tokens[$conditionPtr]['scope_closer'] === $next + if ( + ( + $type === T_FUNCTION || + $type === T_CLOSURE + ) && $tokens[$conditionPtr]['scope_closer'] === $next ) { $errorCode = 'SpacingAfterAtFunctionEnd'; } @@ -498,7 +515,7 @@ public function process(File $phpcsFile, $stackPtr) { if ($tokens[$i]['code'] !== T_WHITESPACE) { return ($lastCommentToken + 1); } - } else if ($tokens[$i]['line'] > ($tokens[$lastCommentToken]['line'] + 1)) { + } elseif ($tokens[$i]['line'] > ($tokens[$lastCommentToken]['line'] + 1)) { break; } } @@ -517,11 +534,10 @@ public function process(File $phpcsFile, $stackPtr) { $phpcsFile->fixer->endChangeset(); } - }//end if + } return ($lastCommentToken + 1); - - }//end process() + } /** * This looks if there is a valid "return new class extends" expression allowed to have phpdoc block. @@ -530,7 +546,7 @@ public function process(File $phpcsFile, $stackPtr) { * @param int $pointer The position in the stack. * @return bool true if is an allowed to have phpdoc block return new class code. */ - protected function is_return_new_class_extends(File $file, $pointer) { + protected function isReturnNewClassExtends(File $file, $pointer) { $ignoredtokens = Tokens::$emptyTokens; @@ -562,6 +578,5 @@ protected function is_return_new_class_extends(File $file, $pointer) { // Found a valid "return new class extends" expression, phpdoc block allowed. return true; - }// end is_return_new_class_extends() - -}//end class + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/MissingDocblockSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/MissingDocblockSniff.php new file mode 100644 index 00000000..4467a067 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/MissingDocblockSniff.php @@ -0,0 +1,261 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting; + +use MoodleHQ\MoodleCS\moodle\Util\Docblocks; +use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; +use MoodleHQ\MoodleCS\moodle\Util\TokenUtil; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; +use PHPCSUtils\Tokens\Collections; +use PHPCSUtils\Utils\ObjectDeclarations; + +/** + * 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 MissingDocblockSniff implements Sniff +{ + /** @var array A list of standard method names used in unit test files */ + protected array $phpunitStandardMethodNames = [ + 'setUp', + 'tearDown', + 'setUpBeforeClass', + 'tearDownAfterClass', + ]; + + /** + * Register for open tag (only process once per file). + */ + public function register() { + 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) { + $this->processScopes($phpcsFile, $stackPtr); + $this->processFunctions($phpcsFile, $stackPtr); + $this->processConstants($phpcsFile, $stackPtr); + } + + protected function processScopes(File $phpcsFile, int $stackPtr): void { + $tokens = $phpcsFile->getTokens(); + + // Each class, interface, trait, and enum must have a docblock. + // If a file has one class, interface, trait, or enum, the file docblock is optional. + // Otherwise, the file docblock is required. + + $artifactCount = 0; + $missingDocblocks = []; + $find = Tokens::$ooScopeTokens; + $find[] = T_FUNCTION; + + $typePtr = $stackPtr + 1; + while ($typePtr = $phpcsFile->findNext($find, $typePtr + 1)) { + $token = $tokens[$typePtr]; + if ($token['code'] === T_FUNCTION && !empty($token['conditions'])) { + // Skip methods of classes, traits and interfaces. + continue; + } + $artifactCount++; + + if ($token['code'] === T_FUNCTION) { + // Skip functions. They are handled separately. + continue; + } + + if (!Docblocks::getDocBlockPointer($phpcsFile, $typePtr)) { + $missingDocblocks[] = $typePtr; + } + } + + if ($artifactCount !== 1) { + // See if there is a file docblock. + $fileblock = Docblocks::getDocBlockPointer($phpcsFile, $stackPtr); + + if ($fileblock === null) { + $objectName = TokenUtil::getObjectName($phpcsFile, $stackPtr); + $phpcsFile->addError('Missing docblock for file %s', $stackPtr, 'Missing', [$objectName]); + } + } + + foreach ($missingDocblocks as $typePtr) { + $token = $tokens[$typePtr]; + $objectName = TokenUtil::getObjectName($phpcsFile, $typePtr); + $objectType = TokenUtil::getObjectType($phpcsFile, $typePtr); + + $phpcsFile->addError('Missing docblock for %s %s', $typePtr, 'Missing', [$objectType, $objectName]); + } + + if ($artifactCount === 1) { + // Only one artifact. + // No need for file docblock. + return; + } + } + + /** + * Process functions. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position in the stack. + */ + protected function processFunctions(File $phpcsFile, int $stackPtr): void { + // Missing docblocks for unit tests are treated as warnings. + $isUnitTestFile = MoodleUtil::isUnitTest($phpcsFile); + + $tokens = $phpcsFile->getTokens(); + + $missingDocblocks = []; + $knownClasses = []; + + $typePtr = $stackPtr + 1; + while ($typePtr = $phpcsFile->findNext(T_FUNCTION, $typePtr + 1)) { + $token = $tokens[$typePtr]; + $extendsOrImplements = false; + + if ($isUnitTestFile) { + if (in_array(TokenUtil::getObjectName($phpcsFile, $typePtr), $this->phpunitStandardMethodNames)) { + // Skip standard PHPUnit methods. + continue; + } + } + + if (count($token['conditions']) > 0) { + // This method has conditions (a Class, Interface, Trait, etc.). + // Check if that container extends or implements anything. + foreach ($token['conditions'] as $condition => $conditionCode) { + if ($conditionCode === T_USE) { + // Skip any method inside a USE. + continue 2; + } + if (!array_key_exists($condition, $knownClasses)) { + $extendsOrImplements = $extendsOrImplements || ObjectDeclarations::findExtendedClassName( + $phpcsFile, + $condition + ); + $extendsOrImplements = $extendsOrImplements || ObjectDeclarations::findImplementedInterfaceNames( + $phpcsFile, + $condition + ); + $extendsOrImplements = $extendsOrImplements || ObjectDeclarations::findExtendedInterfaceNames( + $phpcsFile, + $condition + ); + $knownClasses[$condition] = $extendsOrImplements; + } + $extendsOrImplements = $extendsOrImplements || $knownClasses[$condition]; + if ($extendsOrImplements) { + break; + } + } + } + + if (!Docblocks::getDocBlockPointer($phpcsFile, $typePtr)) { + $missingDocblocks[$typePtr] = $extendsOrImplements; + } + } + + foreach ($missingDocblocks as $typePtr => $extendsOrImplements) { + $token = $tokens[$typePtr]; + $objectName = TokenUtil::getObjectName($phpcsFile, $typePtr); + $objectType = TokenUtil::getObjectType($phpcsFile, $typePtr); + + if ($isUnitTestFile) { + if (substr($objectName, 0, 5) !== 'test_') { + $phpcsFile->addWarning( + 'Missing docblock for %s %s in testcase', + $typePtr, + 'MissingTestcaseMethodDescription', + [$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]); + } + } + } + + /** + * Process constants. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position in the stack. + */ + protected function processConstants(File $phpcsFile, int $stackPtr): void { + $tokens = $phpcsFile->getTokens(); + + $typePtr = $stackPtr + 1; + while ($typePtr = $phpcsFile->findNext(T_CONST, $typePtr + 1)) { + $token = $tokens[$typePtr]; + $containerName = null; + + if (count($token['conditions']) > 0) { + foreach ($token['conditions'] as $conditionPtr => $conditionCode) { + // Skip any constant inside a USE. + if ($conditionCode === T_USE) { + continue 2; + } + if (in_array($conditionCode, Collections::closedScopes())) { + $containerName = TokenUtil::getObjectName($phpcsFile, $conditionPtr); + } + } + } + + if (Docblocks::getDocBlockPointer($phpcsFile, $typePtr)) { + // This is documented. + continue; + } + + // Get the constant name + // We have to find the equals and step back from there. + // PHP 8.3 introduces the concept of typed constants but both the type and name are presented as T_STRING + $equalPtr = $phpcsFile->findNext(T_EQUAL, $typePtr + 1); + $namePtr = $phpcsFile->findPrevious(T_STRING, $equalPtr - 1, $typePtr); + $objectName = $tokens[$namePtr]['content']; + + if ($containerName) { + $phpcsFile->addError( + 'Missing docblock for constant %s::%s', + $typePtr, + 'Missing', + [$containerName, $objectName] + ); + } else { + $phpcsFile->addError( + 'Missing docblock for constant %s', + $typePtr, + 'Missing', + [$objectName] + ); + } + } + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/PackageSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/PackageSniff.php new file mode 100644 index 00000000..ab15b577 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/PackageSniff.php @@ -0,0 +1,198 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting; + +use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; +use MoodleHQ\MoodleCS\moodle\Util\Docblocks; +use MoodleHQ\MoodleCS\moodle\Util\TokenUtil; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Files\File; + +/** + * Checks that all test classes and global functions have appropriate @package tags. + * + * @copyright 2024 Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class PackageSniff implements Sniff +{ + /** + * Register for open tag (only process once per file). + */ + public function register() { + 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) { + $tokens = $phpcsFile->getTokens(); + + $docPtr = Docblocks::getDocBlockPointer($phpcsFile, $stackPtr); + if ($docPtr) { + $filePackageFound = $this->checkDocblock( + $phpcsFile, + $stackPtr, + $docPtr + ); + if ($filePackageFound) { + return; + } + } + + $find = [ + T_CLASS, + T_FUNCTION, + T_TRAIT, + T_INTERFACE, + ]; + $typePtr = $stackPtr + 1; + while ($typePtr = $phpcsFile->findNext($find, $typePtr + 1)) { + $token = $tokens[$typePtr]; + if ($token['code'] === T_FUNCTION && !empty($token['conditions'])) { + // Skip methods of classes, traits and interfaces. + continue; + } + + $docPtr = Docblocks::getDocBlockPointer($phpcsFile, $typePtr); + + if ($docPtr === null) { + continue; + } + + $this->checkDocblock($phpcsFile, $typePtr, $docPtr); + } + } + + /** + * Check the docblock for a @package tag. + * + * @param File $phpcsFile + * @param int $stackPtr + * @param array $docblock + * @return bool Whether any package tag was found, whether or not it was correct + */ + protected function checkDocblock( + File $phpcsFile, + int $stackPtr, + int $docPtr + ): bool { + $expectedPackage = MoodleUtil::getMoodleComponent($phpcsFile, true); + + // Nothing to do if we have been unable to determine the package + // (all the following checks rely on this value). + if ($expectedPackage === null) { + return false; + } + + $tokens = $phpcsFile->getTokens(); + $objectName = TokenUtil::getObjectName($phpcsFile, $stackPtr); + $objectType = TokenUtil::getObjectType($phpcsFile, $stackPtr); + $docblock = $tokens[$docPtr]; + + $packageTokens = Docblocks::getMatchingDocTags($phpcsFile, $docPtr, '@package'); + if (empty($packageTokens)) { + $fix = $phpcsFile->addFixableError( + 'DocBlock missing a @package tag for %s %s. Expected @package %s', + $stackPtr, + 'Missing', + [$objectType, $objectName, $expectedPackage] + ); + + if ($fix) { + $phpcsFile->fixer->beginChangeset(); + $phpcsFile->fixer->addContentBefore($docblock['comment_closer'], '* @package ' . $expectedPackage . PHP_EOL . ' '); + $phpcsFile->fixer->endChangeset(); + } + + return false; + } + + if (count($packageTokens) > 1) { + $fix = $phpcsFile->addFixableError( + 'More than one @package tag found in %s %s.', + $stackPtr, + 'Multiple', + [$objectType, $objectName] + ); + + if ($fix) { + $phpcsFile->fixer->beginChangeset(); + $validTokenFound = false; + + foreach ($packageTokens as $i => $packageToken) { + $packageValuePtr = $phpcsFile->findNext( + T_DOC_COMMENT_STRING, + $packageToken, + $docblock['comment_closer'] + ); + $packageValue = $tokens[$packageValuePtr]['content']; + if (!$validTokenFound && $packageValue === $expectedPackage) { + $validTokenFound = true; + continue; + } + $lineNo = $tokens[$packageToken]['line']; + foreach (array_keys(MoodleUtil::getTokensOnLine($phpcsFile, $lineNo)) as $lineToken) { + $phpcsFile->fixer->replaceToken($lineToken, ''); + } + } + if (!$validTokenFound) { + $phpcsFile->fixer->addContentBefore($packageTokens[0], ' * @package ' . $expectedPackage . PHP_EOL); + } + $phpcsFile->fixer->endChangeset(); + } + return true; + } + + $packageToken = reset($packageTokens); + + // Check the value of the package tag. + $packageValuePtr = $phpcsFile->findNext( + T_DOC_COMMENT_STRING, + $packageToken, + $docblock['comment_closer'] + ); + $packageValue = $tokens[$packageValuePtr]['content']; + + // Compare to expected value. + if ($packageValue === $expectedPackage) { + return true; + } + + $fix = $phpcsFile->addFixableError( + 'Incorrect @package tag for %s %s. Expected %s, found %s.', + $packageToken, + 'Incorrect', + [$objectType, $objectName, $expectedPackage, $packageValue] + ); + + if ($fix) { + $phpcsFile->fixer->beginChangeset(); + $phpcsFile->fixer->replaceToken($packageValuePtr, $expectedPackage); + $phpcsFile->fixer->endChangeset(); + } + + return true; + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/TodoCommentSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/TodoCommentSniff.php index c756d3bc..26595662 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/TodoCommentSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/TodoCommentSniff.php @@ -27,8 +27,6 @@ namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; @@ -57,7 +55,7 @@ class TodoCommentSniff implements Sniff /** * Returns an array of tokens this Sniff wants to listen for. * - * @return array + * @return int[]|string[] */ public function register(): array { return [T_COMMENT, T_DOC_COMMENT_TAG]; diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/ValidTagsSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/ValidTagsSniff.php new file mode 100644 index 00000000..dc64cfd8 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/ValidTagsSniff.php @@ -0,0 +1,135 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting; + +use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; +use MoodleHQ\MoodleCS\moodle\Util\Docblocks; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Files\File; + +/** + * Checks that valid docblock tags are in use. + * + * @copyright 2024 Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class ValidTagsSniff implements Sniff +{ + /** + * Register for open tag (only process once per file). + */ + public function register() { + 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) { + $tokens = $phpcsFile->getTokens(); + + while ($docPtr = $phpcsFile->findNext(T_DOC_COMMENT_OPEN_TAG, $stackPtr)) { + $docblock = $tokens[$docPtr]; + foreach ($docblock['comment_tags'] as $tagPtr) { + $tagName = ltrim($tokens[$tagPtr]['content'], '@'); + if (!Docblocks::isValidTag($phpcsFile, $tagPtr)) { + if (Docblocks::shouldRemoveTag($tagName)) { + $fix = $phpcsFile->addFixableError( + 'Invalid docblock tag "@%s" is not supported.', + $tagPtr, + 'Invalid', + [$tagName] + ); + if ($fix) { + $phpcsFile->fixer->beginChangeset(); + foreach ($this->getTokensOnTokenLine($phpcsFile, $tagPtr) as $tokenPtr) { + $phpcsFile->fixer->replaceToken($tokenPtr, ''); + } + $phpcsFile->fixer->endChangeset(); + } + } elseif ($renameTo = Docblocks::getRenameTag($tagName)) { + $fix = $phpcsFile->addFixableError( + 'Incorrect docblock tag "@%s". Should be "@%s".', + $tagPtr, + 'Invalid', + [$tagName, $renameTo] + ); + if ($fix) { + $phpcsFile->fixer->beginChangeset(); + $phpcsFile->fixer->replaceToken($tagPtr, "@{$renameTo}"); + $phpcsFile->fixer->endChangeset(); + } + } else { + $phpcsFile->addError( + 'Invalid docblock tag "@%s".', + $tagPtr, + 'Invalid', + [$tagName] + ); + } + } elseif (!Docblocks::isRecommendedTag($tagName)) { + // The tag is valid, but not recommended. + $phpcsFile->addWarning( + 'Docblock tag "@%s" is not recommended.', + $tagPtr, + 'Invalid', + [$tagName] + ); + } + } + $stackPtr = $docPtr + 1; + } + } + + /** + * Get the tokens on the same line as the given token. + * + * @param File $phpcsFile + * @param int $ptr + * @return int[] + */ + protected function getTokensOnTokenLine(File $phpcsFile, int $ptr): array { + $tokens = $phpcsFile->getTokens(); + $line = $tokens[$ptr]['line']; + $lineTokens = []; + for ($i = $ptr; $i >= 0; $i--) { + if ($tokens[$i]['line'] === $line) { + array_unshift($lineTokens, $i); + continue; + } + break; + } + + $lineTokens[] = $ptr; + + for ($i = $ptr; $i < count($tokens); $i++) { + if ($tokens[$i]['line'] === $line) { + $lineTokens[] = $i; + continue; + } + break; + } + + return $lineTokens; + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/VariableCommentSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/VariableCommentSniff.php new file mode 100644 index 00000000..fc05cf6c --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Commenting/VariableCommentSniff.php @@ -0,0 +1,211 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting; + +use MoodleHQ\MoodleCS\moodle\Util\TypeUtil; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\AbstractVariableSniff; +use PHPCSUtils\Tokens\Collections; +use PHPCSUtils\Utils\ObjectDeclarations; + +/** + * Parses and verifies the variable doc comment. + * + * The Sniff is based upon the Squiz Labs version, but it has been modified to accept int, rather than integer. + * + * @author Greg Sherwood + * @author Andrew Lyons + * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ +class VariableCommentSniff extends AbstractVariableSniff +{ + /** + * Called to process class member vars. + * + * @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 processMemberVar(File $phpcsFile, $stackPtr) { + $tokens = $phpcsFile->getTokens(); + + $ignore = [ + T_WHITESPACE => T_WHITESPACE, + T_NULLABLE => T_NULLABLE, + ] + + Collections::propertyModifierKeywords() + + Collections::parameterTypeTokens(); + + for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) { + if (isset($ignore[$tokens[$commentEnd]['code']]) === true) { + continue; + } + + if ( + $tokens[$commentEnd]['code'] === T_ATTRIBUTE_END + && isset($tokens[$commentEnd]['attribute_opener']) === true + ) { + $commentEnd = $tokens[$commentEnd]['attribute_opener']; + continue; + } + + break; + } + + if ( + $commentEnd === false + || ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG + && $tokens[$commentEnd]['code'] !== T_COMMENT) + ) { + $phpcsFile->addError('Missing member variable doc comment', $stackPtr, 'Missing'); + return; + } + + if ($tokens[$commentEnd]['code'] === T_COMMENT) { + $phpcsFile->addError('You must use "/**" style comments for a member variable comment', $stackPtr, 'WrongStyle'); + return; + } + + $commentStart = $tokens[$commentEnd]['comment_opener']; + + $foundVar = null; + foreach ($tokens[$commentStart]['comment_tags'] as $tag) { + if ($tokens[$tag]['content'] === '@var') { + if ($foundVar !== null) { + $error = 'Only one @var tag is allowed in a member variable comment'; + $phpcsFile->addError($error, $tag, 'DuplicateVar'); + } else { + $foundVar = $tag; + } + } elseif ($tokens[$tag]['content'] === '@see') { + // Make sure the tag isn't empty. + $string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $tag, $commentEnd); + if ($string === false || $tokens[$string]['line'] !== $tokens[$tag]['line']) { + $error = 'Content missing for @see tag in member variable comment'; + $phpcsFile->addError($error, $tag, 'EmptySees'); + } + } else { + $error = '%s tag is not allowed in member variable comment'; + $data = [$tokens[$tag]['content']]; + $phpcsFile->addWarning($error, $tag, 'TagNotAllowed', $data); + } + } + + // The @var tag is the only one we require. + if ($foundVar === null) { + $error = 'Missing @var tag in member variable comment'; + $phpcsFile->addError($error, $commentEnd, 'MissingVar'); + return; + } + + $firstTag = $tokens[$commentStart]['comment_tags'][0]; + if ($foundVar !== null && $tokens[$firstTag]['content'] !== '@var') { + $error = 'The @var tag must be the first tag in a member variable comment'; + $phpcsFile->addError($error, $foundVar, 'VarOrder'); + } + + // Make sure the tag isn't empty and has the correct padding. + $string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $foundVar, $commentEnd); + if ($string === false || $tokens[$string]['line'] !== $tokens[$foundVar]['line']) { + $error = 'Content missing for @var tag in member variable comment'; + $phpcsFile->addError($error, $foundVar, 'EmptyVar'); + return; + } + + // Support both a var type and a description. + preg_match('`^((?:\|?(?:array\([^\)]*\)|[\\\\a-z0-9\[\]]+))*)( .*)?`i', $tokens[($foundVar + 2)]['content'], $varParts); + $varType = $varParts[1]; + + $suggestedType = TypeUtil::getValidatedType($phpcsFile, $string, $varType); + if ($varType !== $suggestedType) { + $error = 'Expected "%s" but found "%s" for @var tag in member variable comment'; + $data = [ + $suggestedType, + $varType, + ]; + + $fix = $phpcsFile->addFixableError($error, $foundVar, 'IncorrectVarType', $data); + if ($fix === true) { + $replacement = $suggestedType; + if (empty($varParts[2]) === false) { + $replacement .= $varParts[2]; + } + + $phpcsFile->fixer->replaceToken(($foundVar + 2), $replacement); + unset($replacement); + } + } + } + + /** + * Processes normal variables within a method. + * + * @param File $file The file where this token was found. + * @param int $stackptr The position where the token was found. + * + * @return void + */ + protected function processVariable(File $phpcsFile, $stackPtr) { + // Find the method that this variable is declared in. + $methodPtr = $phpcsFile->findPrevious(T_FUNCTION, $stackPtr); + if ($methodPtr === false) { + // Not in a method. + return; // @codeCoverageIgnore + } + + $methodName = ObjectDeclarations::getName($phpcsFile, $methodPtr); + if ($methodName !== '__construct') { + // Not in a constructor. + return; + } + + $method = $phpcsFile->getTokens()[$methodPtr]; + if ($method['parenthesis_opener'] < $stackPtr && $method['parenthesis_closer'] > $stackPtr) { + // Only apply to properties declared in the constructor. + // Constructor Promoted Properties canbe detected by a visbility keyword. + // These can be found, amongst others like READONLY in Collections::propertyModifierKeywords(). + // When searching, only look back to the previous arg (comma), or the opening parenthesis. + $lookBackTo = max( + $method['parenthesis_opener'], + $phpcsFile->findPrevious(T_COMMA, $stackPtr) + ); + $modifierPtr = $phpcsFile->findPrevious( + Collections::propertyModifierKeywords(), + $stackPtr, + $lookBackTo + ); + if ($modifierPtr === false) { + // No modifier found, so not a promoted property. + return; + } + + // This is a promoted property. Handle it in the same way as other properties. + $this->processMemberVar($phpcsFile, $stackPtr); + return; + } + } + + /** + * @codeCoverageIgnore + */ + protected function processVariableInString(File $phpcsFile, $stackPtr) { + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/ControlStructures/ControlSignatureSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/ControlStructures/ControlSignatureSniff.php index e0f84d5a..1d8031f0 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Verifies that control statements conform to their coding standards. * * Based on {@link Squiz_Sniffs_ControlStructures_ControlSignatureSniff}. * - * @package local_codechecker * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\ControlStructures; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Sniffs\AbstractPatternSniff; use PHP_CodeSniffer\Files\File; -class ControlSignatureSniff extends AbstractPatternSniff { - +class ControlSignatureSniff extends AbstractPatternSniff +{ public function __construct() { parent::__construct(true); } @@ -40,7 +38,7 @@ public function __construct() { /** @var array A list of tokenizers this sniff supports. */ protected function getPatterns() { - return array( + return [ 'try {EOL...} catch (...) {EOL', 'do {EOL...} while (...);EOL', 'while (...) {EOL', @@ -49,6 +47,6 @@ protected function getPatterns() { 'foreach (...) {EOL', '} else if (...) {EOL', '} else {EOL', - ); + ]; } } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/BoilerplateCommentSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/BoilerplateCommentSniff.php index fd27a370..57efe20b 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/BoilerplateCommentSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/BoilerplateCommentSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Checks that each file contains the standard GPL comment. * - * @package local_codechecker * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\Files; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Util\Tokens; -class BoilerplateCommentSniff implements Sniff { - protected static $comment = array( +class BoilerplateCommentSniff implements Sniff +{ + protected static $comment = [ "// This file is part of", "//", "// Moodle is free software: you can redistribute it and/or modify", @@ -46,9 +45,9 @@ class BoilerplateCommentSniff implements Sniff { "//", "// You should have received a copy of the GNU General Public License", "// along with Moodle. If not, see .", - ); + ]; public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; } public function process(File $file, $stackptr) { @@ -75,7 +74,7 @@ public function process(File $file, $stackptr) { // Note that the opening PHP tag includes one newline. $numnewlines = 0; for ($i = $stackptr + 1; $i <= $stackptr + 5; ++$i) { - if ($tokens[$i]['code'] == T_WHITESPACE && $tokens[$i]['content'] == "\n") { + if (isset($tokens[$i]) && $tokens[$i]['code'] == T_WHITESPACE && $tokens[$i]['content'] == "\n") { $numnewlines++; } else { break; @@ -83,8 +82,11 @@ public function process(File $file, $stackptr) { } if ($numnewlines > 0) { - $file->addError('The opening addError( + 'The opening addError('Line %s of the opening comment must start "%s".', - $tokenptr, 'WrongLine', array($lineindex + 1, $line)); + if ( + $tokens[$tokenptr]['code'] != T_COMMENT || + !preg_match($regex, $tokens[$tokenptr]['content']) + ) { + $file->addError( + 'Line %s of the opening comment must start "%s".', + $tokenptr, + 'WrongLine', + [$lineindex + 1, $line] + ); } } } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/LangFilesOrderingSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/LangFilesOrderingSniff.php new file mode 100644 index 00000000..a2dc5778 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/LangFilesOrderingSniff.php @@ -0,0 +1,335 @@ +. + +/** + * This sniff verifies that lang files are sorted alphabetically by string key. + * + * @copyright 2024 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\Files; + +use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + +class LangFilesOrderingSniff implements Sniff +{ + /** + * @var string|null The previous string that has been processed. + * + * We use this variable to compare the current string with the previous one. And decide + * if the current string is a duplicate or if it's out of order. + */ + protected ?string $previousString = null; + + /** + * @var int pointer to the token where we should stop fixing the file (defaults to last token). + * + * When we find a comment that is not a "Deprecated since Moodle" one, we will stop fixing the file. + */ + protected int $stopFixingPtr = 999999999; + + /** + * @var array An array which keys are all the known strings, grouped, and the values are the start and end pointers to them. + * + * We use this array to, accurately, know where to move every string on each fixing iteration. + */ + protected array $strings = []; + + public function register(): array { + return [T_OPEN_TAG]; // We are going to process the whole file, finding all the strings and comments within it. + } + + public function process(File $phpcsFile, $stackPtr): void { + // If the file is not a lang file, return. + if (!MoodleUtil::isLangFile($phpcsFile)) { + return; + } + + // Only for Moodle 4.4dev (404) and up. + // Make and exception for unit tests, so they are run always. + if (!MoodleUtil::meetsMinimumMoodleVersion($phpcsFile, 404) && !MoodleUtil::isUnitTestRunning()) { + return; // @codeCoverageIgnore + } + + // Get the file tokens, for ease of use. + $tokens = $phpcsFile->getTokens(); + + // Ensure that we start from scratch on each file and pass. + $this->previousString = null; + $this->stopFixingPtr = 999999999; + $this->strings = []; + + // Let's find the first variable and start the process. + $currentPtr = $phpcsFile->findNext(T_VARIABLE, $stackPtr + 1); + if ($currentPtr === false) { + return; // No strings found, nothing to do. + } + + // It's time to iterate over all the strings and comments till the end of the file. + // We'll go accumulating all the strings by group, with their start and end pointers as values. + $currentGroup = 'main'; // The default group to start with, we'll change it each time we find a new section. + do { + // Let's manage comments first (so we know if we are changing the current group). + + // Correct comments are in new line and begin with "// Deprecated since ". + if ( + $tokens[$currentPtr]['code'] === T_COMMENT && + strpos($tokens[$currentPtr]['content'], '// Deprecated since ') === 0 && + $tokens[$currentPtr - 1]['content'] === "\n" + ) { + $currentGroup = trim($tokens[$currentPtr]['content']); + } + + // If we find a comment that is not the standard one, we will stop fixing the file here. And error. + if ( + $tokens[$currentPtr]['code'] === T_COMMENT && + strpos($tokens[$currentPtr]['content'], '// Deprecated since ') === false + ) { + $phpcsFile->addWarning( + 'Unexpected comment found. Auto-fixing will not work after this comment', + $currentPtr, + 'UnexpectedComment' + ); + if ($this->stopFixingPtr > $currentPtr) { + $this->stopFixingPtr = $currentPtr; // Update the stop fixing pointer. + } + } + + if ($tokens[$currentPtr]['code'] === T_COMMENT) { + continue; // We are done for comment tokens. + } + + // Arrived here, all the tokens are variables, so we don't need to check for that. + + // If the name of the variable is not "$string", error. + if ($tokens[$currentPtr]['content'] !== '$string') { + $phpcsFile->addError( + 'Variable "%s" is not expected in a lang file', + $currentPtr, + 'UnexpectedVariable', + [$tokens[$currentPtr]['content']] + ); + continue; // We are done for this token. + } + + // Get the string key, if any. + if (!$stringKey = $this->getStringKey($phpcsFile, $currentPtr)) { + continue; // Problems with this string key, skip it (has been already reported). + } + + // Have found a valid $string[KEY], let's calculate the end and store it. + if ($currentEnd = $this->getStringEnd($phpcsFile, $currentPtr)) { + if (!isset($this->strings[$currentGroup])) { + $this->strings[$currentGroup] = []; + $this->previousString = null; // Reset the previous string on new group. + } + // Check if the string already has been found earlier. + if (isset($this->strings[$currentGroup][$stringKey])) { + $phpcsFile->addError('The string key "%s" is duplicated', $currentPtr, 'DuplicatedKey', [$stringKey]); + continue; // We are done for this string, won't report anything about it till fixed. + } else { + // We can safely add the string to the group, if we are before the last pointer to fix. + if ($currentPtr < $this->stopFixingPtr) { + $this->strings[$currentGroup][$stringKey] = [$currentPtr, $currentEnd]; + } + } + } + + if (null === $currentEnd) { + // The string end is not as expected, report as error unless the next token + // after the semicolon is a comment. In that case, we won't report it because + // UnexpectedComment will take on it. + $delegateToUnexpectedComment = false; + $semicolonPtr = $phpcsFile->findNext(T_SEMICOLON, $currentPtr + 1); + if ( + ( + isset($tokens[$semicolonPtr + 1]) && // There is a next token (not the end of the file) + $tokens[$semicolonPtr + 1]['code'] === T_COMMENT // And it's a comment. + ) || + ( + isset($tokens[$semicolonPtr + 2]) && // Or there are 2 more tokens (not the end of the file). + $tokens[$semicolonPtr + 1]['code'] === T_WHITESPACE && // And they are whitespace + comment. + $tokens[$semicolonPtr + 2]['code'] === T_COMMENT + ) + ) { + $delegateToUnexpectedComment = true; + } + if (!$delegateToUnexpectedComment) { + $phpcsFile->addError( + 'Unexpected string end, it should be a line feed after a semicolon', + $currentPtr, + 'UnexpectedEnd' + ); + continue; // We are done for this string, won't report anything about it till fixed. + } + } + + // Note: We only issue these warnings if there are previous strings to compare with, + // and, obviously, if the string is out of order. + if ($this->previousString && strcmp($this->previousString, $stringKey) > 0) { + // We are going to add this as fixable warning only if we are + // before the last pointer to fix. This is an unordered string. + $phpcsFile->addWarning( + 'The string key "%s" is not in the correct order, it should be before "%s"', + $currentPtr, + 'IncorrectOrder', + [$stringKey, $this->previousString], + 0, + $currentPtr < $this->stopFixingPtr + ); + } + + // Feed $previousString with the current string key. + $this->previousString = $stringKey; + } while ($currentPtr = $phpcsFile->findNext([T_VARIABLE, T_COMMENT], $currentPtr + 1)); // Move to next. + + // If we are fixing the file, we need to sort the strings and move them to the correct position. + if ($phpcsFile->fixer->enabled) { + $this->sortStringsAndFix($phpcsFile); + } + } + + /** + * Given a lang file, fix all the sorting issues found. + * + * This is really similar to the insertion-sort algorithm, but with + * a few optimisations to avoid unnecessary iterations. Should be + * efficient enough against lists that are expected to be not + * too long and already mostly sorted. + * + * @param File $phpcsFile The lang file being processed. + */ + protected function sortStringsAndFix(File $phpcsFile): void { + // Because of hard restrictions in CodeSniffer fixer (we cannot apply more than one change + // to the same token in the same pass), we need to accumulate all the changes and apply them + // at the end of the process. So we are going to build a big changeset to be applied all together. + // Keys will be the token index and values an array, with operation (index, DELETE, INSERT) and content. + + // Get the file tokens, for ease of use. + $tokens = $phpcsFile->getTokens(); + + // We are going to perform the sorting within each detected group/section. + foreach ($this->strings as $group => $strings) { + $changeSet = []; // The changeset to be applied at the end of the iteration. + + $strings = $this->strings[$group]; + // Let's compare the keys in the array of strings with the sorted version of it. + $sorted = $unSorted = array_keys($strings); + sort($sorted, SORT_STRING); + $count = count($sorted); + for ($i = 0; $i < $count; $i++) { + $sortedKey = $sorted[$i]; + $stringsKey = $unSorted[$i]; + + // The string being checked is not in order (comparing with the sorted array). + if ($sortedKey !== $stringsKey) { + // Apply the changes to the strings array by moving the key to the correct position. + $keyValue = $strings[$sortedKey]; + // Remove the element to move. + unset($strings[$sortedKey]); + // Rebuild the array, with the element in new position. + $strings = array_slice($strings, 0, $i, true) + + [$sortedKey => $keyValue] + + array_slice($strings, $i, null, true); + $this->strings[$group] = $strings; // Update the group array with the rebuilt version. + $unSorted = array_keys($strings); // Update the unsorted keys array. + + // Now add the required changes to the changeset that we'll be using when fixing the file. + // For every token in the string being moved, delete it and add it in the correct position. + foreach (range($keyValue[0], $keyValue[1]) as $tokenIndex) { + $tempToken = $tokens[$tokenIndex]; // Store the token. + $changeSet[$tokenIndex]['DELETE'] = ''; // Delete the current string token. + // Insert the token before the previous string. + if (!isset($changeSet[$strings[$stringsKey][0] - 1]['INSERT'])) { + $changeSet[$strings[$stringsKey][0] - 1]['INSERT'] = ''; + } + $changeSet[$strings[$stringsKey][0] - 1]['INSERT'] .= $tempToken['content']; + } + } + } + + // Let's apply the accumulated changes to the file. + if (!empty($changeSet)) { + $phpcsFile->fixer->beginChangeset(); + foreach ($changeSet as $tokenIndex => $operations) { + if (isset($operations['DELETE'])) { + $phpcsFile->fixer->replaceToken($tokenIndex, ''); + } + if (isset($operations['INSERT'])) { + $phpcsFile->fixer->addContent($tokenIndex, $operations['INSERT']); + } + } + $phpcsFile->fixer->endChangeset(); + } + } + } + + /** + * Return the string key corresponding to the string at the pointer. + * Note that the key has got any quote (single or double) trimmed. + * + * @param File $phpcsFile + * @param int $stackPtr + * @return string|null + */ + protected function getStringKey(File $phpcsFile, int $stackPtr): ?string { + $tokens = $phpcsFile->getTokens(); + + // If the structure is not exactly: $string[KEY], add error and return null. + if ( + $tokens[$stackPtr + 1]['code'] !== T_OPEN_SQUARE_BRACKET || + $tokens[$stackPtr + 2]['code'] !== T_CONSTANT_ENCAPSED_STRING || + $tokens[$stackPtr + 3]['code'] !== T_CLOSE_SQUARE_BRACKET + ) { + $phpcsFile->addError( + "Unexpected string syntax, it should be `\$string['key']`", + $stackPtr, + 'UnexpectedSyntax' + ); + return null; + } + + // Now we can safely extract the string key and return it. + return trim($tokens[$stackPtr + 2]['content'], "'\""); + } + + /** + * Return the string final pointer, it should be always a \n after a T_SEMICOLON. + * + * @param File $phpcsFile + * @param int $stackPtr + * @return int|null The pointer to the end of the string, or null if it's not an expected string end. + */ + protected function getStringEnd(File $phpcsFile, int $stackPtr): ?int { + $tokens = $phpcsFile->getTokens(); + $currentEndToken = $phpcsFile->findNext(T_SEMICOLON, $stackPtr + 1) + 1; + + // Verify that the current end token is a line feed, if not, we won't be able to fix (swap). + if ( + !isset($tokens[$currentEndToken]) || + $tokens[$currentEndToken]['code'] !== T_WHITESPACE || + $tokens[$currentEndToken]['content'] !== "\n" + ) { + return null; // This is not an expected string end. + } + + return $currentEndToken; + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/LineLengthSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/LineLengthSniff.php index 1c4cb4c5..f12e8c97 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/LineLengthSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/LineLengthSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Checks that lines are no more than 180 chars, ideally 132. * - * @package local_codechecker * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\Files; @@ -28,8 +28,8 @@ use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; -class LineLengthSniff extends GenericLineLengthSniff { - +class LineLengthSniff extends GenericLineLengthSniff +{ public function __construct() { $this->lineLimit = 132; $this->absoluteLineLimit = 180; @@ -37,8 +37,7 @@ public function __construct() { public function process(File $file, $stackptr) { // Lang files are allowed to have long lines. - if (strpos($file->getFilename(), - DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR) !== false) { + if (strpos($file->getFilename(), DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR) !== false) { return; } parent::process($file, $stackptr); diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/MoodleInternalSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/MoodleInternalSniff.php index e6c1d91d..7dbbe241 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/MoodleInternalSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/MoodleInternalSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Checks that each file contains the standard MOODLE_INTERNAL check or * a config.php inclusion. * - * @package local_codechecker * @copyright 2016 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\Files; -// phpcs:disable moodle.NamingConventions - use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; -class MoodleInternalSniff implements Sniff { +class MoodleInternalSniff implements Sniff +{ /** * Register for open tag (only process once per file). */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; } /** @@ -79,13 +78,13 @@ public function process(File $file, $pointer) { } // Find where real code is and check from there. - $pointer = $this->get_position_of_relevant_code($file, $pointer); + $pointer = $this->getPositionOfRelevantCode($file, $pointer); if (!$pointer) { // The file only contains non-relevant (and non side-effects) code. We are done. return; } - if ($this->is_config_php_incluson($file, $pointer)) { + if ($this->isConfigPhpInclusion($file, $pointer)) { // We are requiring config.php. This file is good, hurrah! return; } @@ -95,46 +94,60 @@ public function process(File $file, $pointer) { $sideEffectsPointer = $pointer; // OK, we've got to the first bit of relevant code. It must be the MOODLE_INTERNAL check. - if ($this->is_moodle_internal_or_die_check($file, $pointer)) { + if ($this->isMoodleInternalOrDieCheck($file, $pointer)) { $hasMoodleInternal = true; // Let's look for side effects after the check. $sideEffectsPointer = $file->findNext(T_SEMICOLON, $pointer) + 1; - - } else if ($this->is_if_not_moodle_internal_die_check($file, $pointer)) { + } elseif ($this->isIfNotMoodleInternalDieCheck($file, $pointer)) { $hasMoodleInternal = true; $isOldMoodleInternal = true; // Let's look for side effects after the check. $sideEffectsPointer = $file->getTokens()[$pointer]['scope_closer'] + 1; } - $hasSideEffects = $this->code_changes_global_state($file, $sideEffectsPointer, ($file->numTokens - 1)); - $hasMultipleArtifacts = ($this->count_artifacts($file) > 1); + $hasSideEffects = $this->codeChangesGlobalState($file, $sideEffectsPointer, ($file->numTokens - 1)); + $hasMultipleArtifacts = ($this->countArtifacts($file) > 1); // Missing MOODLE_INTERNAL and having side effects, error. if (!$hasMoodleInternal && $hasSideEffects) { - $file->addError('Expected MOODLE_INTERNAL check or config.php inclusion. Change in global state detected.', - $pointer, 'MoodleInternalGlobalState'); + $file->addError( + 'Expected MOODLE_INTERNAL check or config.php inclusion. Change in global state detected.', + $pointer, + 'MoodleInternalGlobalState' + ); return; } // Missing MOODLE_INTERNAL, not having side effects, but having multiple artifacts, warning. if (!$hasMoodleInternal && !$hasSideEffects && $hasMultipleArtifacts) { - $file->addWarning('Expected MOODLE_INTERNAL check or config.php inclusion. Multiple artifacts detected.', - $pointer, 'MoodleInternalMultipleArtifacts'); + $file->addWarning( + 'Expected MOODLE_INTERNAL check or config.php inclusion. Multiple artifacts detected.', + $pointer, + 'MoodleInternalMultipleArtifacts' + ); return; } // Having MOODLE_INTERNAL, not having side effects and not having multiple artifacts, error. - if ($hasMoodleInternal && !$hasSideEffects && !$hasMultipleArtifacts) { - $file->addWarning('Unexpected MOODLE_INTERNAL check. No side effects or multiple artifacts detected.', - $pointer, 'MoodleInternalNotNeeded'); + if ( + $hasMoodleInternal && + !$hasSideEffects && !$hasMultipleArtifacts + ) { + $file->addWarning( + 'Unexpected MOODLE_INTERNAL check. No side effects or multiple artifacts detected.', + $pointer, + 'MoodleInternalNotNeeded' + ); return; } // Having old MOODLE_INTERNAL check, warn. if ($hasMoodleInternal && $isOldMoodleInternal) { - $file->addWarning('Old MOODLE_INTERNAL check detected. Replace it by "defined(\'MOODLE_INTERNAL\') || die();"', - $pointer, 'MoodleInternalOld'); + $file->addWarning( + 'Old MOODLE_INTERNAL check detected. Replace it by "defined(\'MOODLE_INTERNAL\') || die();"', + $pointer, + 'MoodleInternalOld' + ); return; } } @@ -147,7 +160,7 @@ public function process(File $file, $pointer) { * @param int $pointer The position in the stack. * @return int position in stack of relevant code. */ - protected function get_position_of_relevant_code(File $file, $pointer) { + protected function getPositionOfRelevantCode(File $file, $pointer) { // Advance through tokens until we find some real code. $tokens = $file->getTokens(); $relevantcodefound = false; @@ -159,13 +172,16 @@ protected function get_position_of_relevant_code(File $file, $pointer) { if ($tokens[$pointer]['code'] === T_NAMESPACE || $tokens[$pointer]['code'] === T_USE) { // Namespace definitions are allowed before anything else, jump to end of namspace statement. $pointer = $file->findEndOfStatement($pointer + 1, T_COMMA); - } else if ($tokens[$pointer]['code'] === T_STRING && $tokens[$pointer]['content'] == 'define') { + } elseif ($tokens[$pointer]['code'] === T_STRING && $tokens[$pointer]['content'] == 'define') { // Some things like AJAX_SCRIPT NO_MOODLE_COOKIES need to be defined before config inclusion. // Jump to end of define(). $pointer = $file->findEndOfStatement($pointer + 1); - } else if ($tokens[$pointer]['code'] === T_DECLARE && $tokens[$pointer]['content'] == 'declare') { + } elseif ($tokens[$pointer]['code'] === T_DECLARE && $tokens[$pointer]['content'] == 'declare') { // Declare statements must be at start of file. $pointer = $file->findEndOfStatement($pointer + 1); + } elseif ($tokens[$pointer]['code'] === T_ATTRIBUTE) { + // Attribute statements may exist before code. Skip them. + $pointer = $tokens[$pointer]['attribute_closer'] + 1; } else { $relevantcodefound = true; } @@ -183,23 +199,25 @@ protected function get_position_of_relevant_code(File $file, $pointer) { * @param int $pointer The position in the stack. * @return bool true if is a moodle internal statement */ - protected function is_moodle_internal_or_die_check(File $file, $pointer) { + protected function isMoodleInternalOrDieCheck(File $file, $pointer) { $tokens = $file->getTokens(); - if ($tokens[$pointer]['code'] !== T_STRING or $tokens[$pointer]['content'] !== 'defined') { + if ($tokens[$pointer]['code'] !== T_STRING || $tokens[$pointer]['content'] !== 'defined') { return false; } $ignoredtokens = array_merge(Tokens::$emptyTokens, Tokens::$bracketTokens); $pointer = $file->findNext($ignoredtokens, $pointer + 1, null, true); - if ($tokens[$pointer]['code'] !== T_CONSTANT_ENCAPSED_STRING or - $tokens[$pointer]['content'] !== "'MOODLE_INTERNAL'") { + if ( + $tokens[$pointer]['code'] !== T_CONSTANT_ENCAPSED_STRING || + $tokens[$pointer]['content'] !== "'MOODLE_INTERNAL'" + ) { return false; } $pointer = $file->findNext($ignoredtokens, $pointer + 1, null, true); - if ($tokens[$pointer]['code'] !== T_BOOLEAN_OR and $tokens[$pointer]['code'] !== T_LOGICAL_OR) { + if ($tokens[$pointer]['code'] !== T_BOOLEAN_OR && $tokens[$pointer]['code'] !== T_LOGICAL_OR) { return false; } @@ -218,10 +236,13 @@ protected function is_moodle_internal_or_die_check(File $file, $pointer) { * @param int $pointer The position in the stack. * @return bool true if is a config.php inclusion. */ - protected function is_config_php_incluson(File $file, $pointer) { + protected function isConfigPhpInclusion(File $file, $pointer) { $tokens = $file->getTokens(); - if ($tokens[$pointer]['code'] !== T_REQUIRE and $tokens[$pointer]['code'] !== T_REQUIRE_ONCE) { + if ( + $tokens[$pointer]['code'] !== T_REQUIRE && + $tokens[$pointer]['code'] !== T_REQUIRE_ONCE + ) { return false; } @@ -245,11 +266,11 @@ protected function is_config_php_incluson(File $file, $pointer) { * @param int $pointer The position in the stack. * @return bool true if is a moodle internal statement */ - protected function is_if_not_moodle_internal_die_check(File $file, $pointer) { + protected function isIfNotMoodleInternalDieCheck(File $file, $pointer) { $tokens = $file->getTokens(); // Detect 'if'. - if ($tokens[$pointer]['code'] !== T_IF ) { + if ($tokens[$pointer]['code'] !== T_IF) { return false; } @@ -263,14 +284,16 @@ protected function is_if_not_moodle_internal_die_check(File $file, $pointer) { // Detect 'defined'. $pointer = $file->findNext($ignoredtokens, $pointer + 1, null, true); - if ($tokens[$pointer]['code'] !== T_STRING or $tokens[$pointer]['content'] !== 'defined') { + if ($tokens[$pointer]['code'] !== T_STRING || $tokens[$pointer]['content'] !== 'defined') { return false; } // Detect 'MOODLE_INTERNAL'. $pointer = $file->findNext($ignoredtokens, $pointer + 1, null, true); - if ($tokens[$pointer]['code'] !== T_CONSTANT_ENCAPSED_STRING or - $tokens[$pointer]['content'] !== "'MOODLE_INTERNAL'") { + if ( + $tokens[$pointer]['code'] !== T_CONSTANT_ENCAPSED_STRING || + $tokens[$pointer]['content'] !== "'MOODLE_INTERNAL'" + ) { return false; } @@ -290,14 +313,13 @@ protected function is_if_not_moodle_internal_die_check(File $file, $pointer) { * * @return int the number of classes, interfaces and traits in the file. */ - private function count_artifacts(File $file) { + private function countArtifacts(File $file) { $position = 0; $counter = 0; while ($position !== false) { - if ($position = $file->findNext([T_CLASS, T_INTERFACE, T_TRAIT], ($position + 1))) { + if ($position = $file->findNext([T_CLASS, T_INTERFACE, T_TRAIT, T_ENUM], ($position + 1))) { $counter++; } - } return $counter; } @@ -311,12 +333,17 @@ private function count_artifacts(File $file) { * @param File $file The file being scanned. * @param int $start The token to start searching from. * @param int $end The token to search to. - * @param array $tokens The stack of tokens that make up the file. - * @return true if side effect is detected in the code. + * @return bool true if side effect is detected in the code. */ - private function code_changes_global_state(File $file, $start, $end) { + private function codeChangesGlobalState(File $file, $start, $end) { $tokens = $file->getTokens(); - $symbols = [T_CLASS => T_CLASS, T_INTERFACE => T_INTERFACE, T_TRAIT => T_TRAIT, T_FUNCTION => T_FUNCTION]; + $symbols = [ + T_CLASS => T_CLASS, + T_INTERFACE => T_INTERFACE, + T_TRAIT => T_TRAIT, + T_FUNCTION => T_FUNCTION, + T_ENUM => T_ENUM, + ]; $conditions = [T_IF => T_IF, T_ELSE => T_ELSE, T_ELSEIF => T_ELSEIF]; for ($i = $start; $i <= $end; $i++) { @@ -373,10 +400,9 @@ private function code_changes_global_state(File $file, $start, $end) { if (isset($symbols[$tokens[$i]['code']]) === true && isset($tokens[$i]['scope_closer']) === true) { $i = $tokens[$i]['scope_closer']; continue; - } else if ($tokens[$i]['code'] === T_STRING && strtolower($tokens[$i]['content']) === 'define') { + } elseif ($tokens[$i]['code'] === T_STRING && strtolower($tokens[$i]['content']) === 'define') { $prev = $file->findPrevious(T_WHITESPACE, ($i - 1), null, true); if ($tokens[$prev]['code'] !== T_OBJECT_OPERATOR) { - $semicolon = $file->findNext(T_SEMICOLON, ($i + 1)); if ($semicolon !== false) { $i = $semicolon; @@ -395,7 +421,7 @@ private function code_changes_global_state(File $file, $start, $end) { continue; } - if ($this->code_changes_global_state($file, ($tokens[$i]['scope_opener'] + 1), ($tokens[$i]['scope_closer'] - 1))) { + if ($this->codeChangesGlobalState($file, ($tokens[$i]['scope_opener'] + 1), ($tokens[$i]['scope_closer'] - 1))) { return true; } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/RequireLoginSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/RequireLoginSniff.php index 3fa6beb2..b03d4dbe 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/RequireLoginSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Files/RequireLoginSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Checks that each file contains necessary login checks. * - * @package local_codechecker * @copyright 2016 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\Files; @@ -27,14 +27,15 @@ use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; -class RequireLoginSniff implements Sniff { +class RequireLoginSniff implements Sniff +{ public $loginfunctions = ['require_login', 'require_course_login', 'require_admin', 'admin_externalpage_setup']; public $ignorewhendefined = ['NO_MOODLE_COOKIES', 'CLI_SCRIPT', 'ABORT_AFTER_CONFIG']; /** * Register for open tag (only process once per file). */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; } /** @@ -50,22 +51,25 @@ public function process(File $file, $pointer) { return; // @codeCoverageIgnore } - $pointer = $this->get_config_inclusion_position($file, $pointer); + $pointer = $this->getConfigInclusionPosition($file, $pointer); if ($pointer === false) { // Config.php not included form file. return; } // OK, we've got a config.php. - if ($this->should_skip_login_checks($file, $pointer)) { + if ($this->shouldSkipLoginChecks($file, $pointer)) { // Login function check not necessary. return; } - if (!$this->is_login_function_present($file, $pointer)) { + if (!$this->isLoginFunctionPresent($file, $pointer)) { $loginfunctionsstr = implode(', ', $this->loginfunctions); - $file->addWarning("Expected login check ($loginfunctionsstr) following config inclusion. None found.", - $pointer, 'Missing'); + $file->addWarning( + "Expected login check ($loginfunctionsstr) following config inclusion. None found.", + $pointer, + 'Missing' + ); } } @@ -76,7 +80,7 @@ public function process(File $file, $pointer) { * @param int $pointer The position in the stack. * @return int|false the position in the file or false if no require statement found. */ - protected function get_config_inclusion_position(File $file, $pointer) { + protected function getConfigInclusionPosition(File $file, $pointer) { for ($i = $pointer; $i < $file->numTokens; $i++) { $i = $file->findNext([T_REQUIRE, T_REQUIRE_ONCE], $i); if ($i === false) { @@ -84,7 +88,7 @@ protected function get_config_inclusion_position(File $file, $pointer) { return false; } - if ($this->is_a_config_php_incluson($file, $i)) { + if ($this->isConfigPhpInclusion($file, $i)) { // Found config.php. return $i; } @@ -99,7 +103,7 @@ protected function get_config_inclusion_position(File $file, $pointer) { * @param int $pointer The position in the stack. * @return bool true if it is a config inclusion */ - protected function is_a_config_php_incluson(File $file, $pointer) { + protected function isConfigPhpInclusion(File $file, $pointer) { $tokens = $file->getTokens(); // It's a require() or require_once() statement. Is it require(config.php)? @@ -119,11 +123,10 @@ protected function is_a_config_php_incluson(File $file, $pointer) { * @param int $pointer The position in the stack. * @return bool true if the checks should be skipped */ - protected function should_skip_login_checks(File $file, $pointer) { + protected function shouldSkipLoginChecks(File $file, $pointer) { $tokens = $file->getTokens(); for ($i = $pointer; $i > 0; $i--) { - $i = $file->findPrevious(T_STRING, $i); if ($i === false) { // We've got to the start. A login function must be necessary. @@ -154,7 +157,7 @@ protected function should_skip_login_checks(File $file, $pointer) { * @param int $pointer The position in the stack. * @return bool true if the current point in stack is a login function. */ - protected function is_a_login_function(File $file, $pointer) { + protected function isLginFunction(File $file, $pointer) { $tokens = $file->getTokens(); if (in_array($tokens[$pointer]['content'], $this->loginfunctions)) { @@ -171,14 +174,14 @@ protected function is_a_login_function(File $file, $pointer) { * @param int $pointer The position in the stack. * @return true if login function is present. */ - protected function is_login_function_present(File $file, $pointer) { + protected function isLoginFunctionPresent(File $file, $pointer) { for ($i = $pointer; $i < $file->numTokens; $i++) { $i = $file->findNext(T_STRING, $i); if ($i === false) { return false; } - if ($this->is_a_login_function($file, $i)) { + if ($this->isLginFunction($file, $i)) { return true; } @@ -188,6 +191,5 @@ protected function is_login_function_present(File $file, $pointer) { return false; } } - } } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Methods/MethodDeclarationSpacingSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Methods/MethodDeclarationSpacingSniff.php new file mode 100644 index 00000000..9613ee10 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Methods/MethodDeclarationSpacingSniff.php @@ -0,0 +1,170 @@ +. + +/** + * This sniff checks that method declarations are correct, spacing-wise. + * + * This Sniff completes other Sniffs, already included in the moodle standard, + * to ensure that the methods declarations make a correct use of whitespace. + * More specifically, it completes the following: + * - PSR12.Functions.ReturnTypeDeclaration + * - PSR12.Functions.NullableTypeDeclaration + * - PSR2.Methods.MethodDeclaration + * - Squiz.Whitespace.ScopeKeywordSpacing + * + * If any of the above Sniffs is disabled, then we'll have to add more + * features to this one. + + * @copyright 2024 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\Methods; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\AbstractScopeSniff; +use PHP_CodeSniffer\Util\Tokens; + +class MethodDeclarationSpacingSniff extends AbstractScopeSniff +{ + public function __construct() { + parent::__construct(Tokens::$ooScopeTokens, [T_FUNCTION]); + } + + /** + * Processes the function tokens within the class. + * + * @param File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * @param int $currScope The current scope opener token. + * + * @return void + */ + protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) { + // List of tokens that require one space after them. + $oneSpaceTokens = [ + // T_PUBLIC, // Disabled. Squiz.WhiteSpace.ScopeKeywordSpacing handles it. + // T_PROTECTED, // Disabled. Squiz.WhiteSpace.ScopeKeywordSpacing handles it. + // T_PRIVATE, // Disabled. Squiz.WhiteSpace.ScopeKeywordSpacing handles it. + // T_STATIC, // Disabled. Squiz.WhiteSpace.ScopeKeywordSpacing handles it. + T_ABSTRACT, + T_FINAL, + T_FUNCTION, + ]; + + // List of tokens that require no space after them. + $noSpaceTokens = [ + T_STRING, + T_OPEN_PARENTHESIS, + ]; + + $tokens = $phpcsFile->getTokens(); + + // Determine if this is a function which needs to be examined. + $conditions = $tokens[$stackPtr]['conditions']; + end($conditions); + $deepestScope = key($conditions); + if ($deepestScope !== $currScope) { + return; + } + + $methodName = $phpcsFile->getDeclarationName($stackPtr); + if ($methodName === null) { + // Ignore closures. + return; + } + + // Find the opening parenthesis of the argument list. That's the last token + // that this Sniff is interested in. If, for any reason, the opening parenthesis + // is not found, then we'll start from current T_FUNCTION token. + $lastToken = $tokens[$stackPtr]['parenthesis_opener'] ?? $stackPtr; + + // These are the tokens that we are interested on. + $findTokens = array_merge($oneSpaceTokens, $noSpaceTokens); + + // Find the first token that we are interested in. + $foundToken = $phpcsFile->findPrevious($findTokens, $lastToken); + + // Search backwards and examine all the matches found until we change of line. + while ($tokens[$foundToken]['line'] === $tokens[$lastToken]['line']) { + // If it's a token that requires one space after it, check if there is one. + if (in_array($tokens[$foundToken]['code'], $oneSpaceTokens) === true) { + $replacement = ' '; + if ( + $tokens[$foundToken + 1]['code'] === T_WHITESPACE && // We only check whitespace. + $tokens[$foundToken + 1]['content'] !== ' ' + ) { + $error = 'Expected 1 space after "%s"; %s found'; + $data = [ + $tokens[$foundToken]['content'], + strlen($tokens[$foundToken + 1]['content']), + ]; + $fix = $phpcsFile->addFixableError($error, $foundToken, 'OneExpectedAfter', $data); + if ($fix === true) { + $phpcsFile->fixer->replaceToken($foundToken + 1, $replacement); + } + } + } + + // If it's a token that requires no space after it, check if there is none. + if (in_array($tokens[$foundToken]['code'], $noSpaceTokens) === true) { + $replacement = ''; + $process = true; + + // We only process T_STRING if it matches the method name. + if ($tokens[$foundToken]['code'] === T_STRING) { + if ($tokens[$foundToken]['content'] !== $methodName) { + $process = false; + } + } + + // We only process T_OPEN_PARENTHESIS if it has spaces, and only + // to get rid of them + if ($tokens[$foundToken]['code'] === T_OPEN_PARENTHESIS) { + if (strpos($tokens[$foundToken + 1]['content'], ' ') !== false) { + $replacement = str_replace(' ', '', $tokens[$foundToken + 1]['content']); + } else { + $process = false; + } + } + + if ( + $tokens[$foundToken + 1]['code'] === T_WHITESPACE && // We only check whitespace. + $tokens[$foundToken + 1]['content'] !== '' && + $process === true + ) { + $error = 'Expected 0 spaces after "%s"; %s found'; + $data = [ + $tokens[$foundToken]['content'], + strlen($tokens[$foundToken + 1]['content']), + ]; + $fix = $phpcsFile->addFixableError($error, $foundToken, 'ZeroExpectedAfter', $data); + if ($fix === true) { + $phpcsFile->fixer->replaceToken($foundToken + 1, $replacement); + } + } + } + + // Move to the previous interesting token. + $foundToken = $phpcsFile->findPrevious($findTokens, $foundToken - 1); + } + } + + protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) { + return; // @codeCoverageIgnore + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Namespaces/NamespaceStatementSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Namespaces/NamespaceStatementSniff.php index 19923b3b..04e940bf 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Namespaces/NamespaceStatementSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Namespaces/NamespaceStatementSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Checks that each file contains the standard GPL comment. * - * @package moodle-cs * @copyright 2023 Andrew Lyons - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\Namespaces; @@ -28,9 +28,8 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Util\Tokens; -// phpcs:disable moodle.NamingConventions - -class NamespaceStatementSniff implements Sniff { +class NamespaceStatementSniff implements Sniff +{ public function register() { return [ diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/NamingConventions/ValidFunctionNameSniff.php index ebb8b25c..a0b58f7a 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * moodle_sniffs_namingconventions_validfunctionnamesniff. @@ -20,23 +21,20 @@ * Ensures method names are correct depending on whether they are public * or private, and that functions are named correctly. * - * @package local_codechecker * @copyright 2009 Nicolas Connault - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\NamingConventions; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\AbstractScopeSniff; use PHP_CodeSniffer\Util\Tokens; -class ValidFunctionNameSniff extends AbstractScopeSniff { - +class ValidFunctionNameSniff extends AbstractScopeSniff +{ /** @var array A list of all PHP magic methods. */ - private $magicmethods = array( + private $magicmethods = [ 'construct', 'destruct', 'call', @@ -54,14 +52,14 @@ class ValidFunctionNameSniff extends AbstractScopeSniff { 'set_state', 'clone', 'debuginfo', - ); + ]; /** @var array A list of all PHP magic functions. */ - private $magicfunctions = array( - 'autoload' - ); + private $magicfunctions = [ + 'autoload', + ]; - private $permittedmethods = array( + private $permittedmethods = [ 'setUp', 'tearDown', // Used by simpletest. 'setUpBeforeClass', @@ -71,13 +69,13 @@ class ValidFunctionNameSniff extends AbstractScopeSniff { 'offsetUnset', // Defined by the PHP ArrayAccess interface. 'tearDownAfterClass', 'jsonSerialize', - ); + ]; /** * Constructs a moodle_sniffs_namingconventions_validfunctionnamesniff. */ public function __construct() { - parent::__construct(Tokens::$ooScopeTokens, array(T_FUNCTION), true); + parent::__construct(Tokens::$ooScopeTokens, [T_FUNCTION], true); } /** @@ -89,8 +87,7 @@ public function __construct() { * * @return void */ - protected function processTokenWithinScope(File $phpcsfile, - $stackptr, $currscope) { + protected function processTokenWithinScope(File $phpcsfile, $stackptr, $currscope) { $classname = $phpcsfile->getDeclarationName($currscope); $methodname = $phpcsfile->getDeclarationName($stackptr); @@ -112,12 +109,13 @@ protected function processTokenWithinScope(File $phpcsfile, $scopespecified = $methodprops['scope_specified']; // Only lower-case accepted. - if (preg_match('/[A-Z]+/', $methodname) && - !in_array($methodname, $this->permittedmethods)) { - + if ( + preg_match('/[A-Z]+/', $methodname) && + !in_array($methodname, $this->permittedmethods) + ) { if ($scopespecified === true) { $error = ucfirst($scope) . ' method name "' . $classname . '::' . - $methodname .'" must be in lower-case letters only'; + $methodname . '" must be in lower-case letters only'; } else { $error = 'method name "' . $classname . '::' . $methodname . '" must be in lower-case letters only'; diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/NamingConventions/ValidVariableNameSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/NamingConventions/ValidVariableNameSniff.php index 0d842bee..5655766d 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Checks variable names are all lower-case, no underscores. * - * @package local_codechecker * @copyright 2009 Nicolas Connault - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\NamingConventions; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Sniffs\AbstractVariableSniff; use PHP_CodeSniffer\Files\File; -class ValidVariableNameSniff extends AbstractVariableSniff { - - static public $allowedglobals = array('ADMIN', 'CFG', 'COURSE', 'DB', 'FULLME', - 'OUTPUT', 'PAGE', 'PERF', 'SESSION', 'SITE', 'THEME', 'USER', - '_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', '_SESSION', '_ENV', - '_COOKIE', '_HTTP_RAW_POST_DATA', 'ACCESSLIB_PRIVATE', 'ME', - 'CONDITIONLIB_PRIVATE', 'FILTERLIB_PRIVATE', 'SCRIPT', 'MNET_REMOTE_CLIENT', - 'http_response_header'); +class ValidVariableNameSniff extends AbstractVariableSniff +{ + public static $allowedglobals = ['ADMIN', 'CFG', 'COURSE', 'DB', 'FULLME', + 'OUTPUT', 'PAGE', 'PERF', 'SESSION', 'SITE', 'THEME', 'USER', + '_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', '_SESSION', '_ENV', + '_COOKIE', '_HTTP_RAW_POST_DATA', 'ACCESSLIB_PRIVATE', 'ME', + 'CONDITIONLIB_PRIVATE', 'FILTERLIB_PRIVATE', 'SCRIPT', 'MNET_REMOTE_CLIENT', + 'http_response_header']; /** * Processes class member variables. @@ -93,7 +91,7 @@ protected function processMemberVar(File $phpcsfile, $stackptr) { protected function processVariable(File $phpcsfile, $stackptr) { $tokens = $phpcsfile->getTokens(); $membername = ltrim($tokens[$stackptr]['content'], '$'); - $this->validate_moodle_variable_name($membername, $phpcsfile, $stackptr); + $this->validateMoodleVariableName($membername, $phpcsfile, $stackptr); } /** @@ -107,11 +105,18 @@ protected function processVariable(File $phpcsfile, $stackptr) { protected function processVariableInString(File $phpcsfile, $stackptr) { $tokens = $phpcsfile->getTokens(); - if (preg_match('/\$([A-Za-z0-9_]+)(\-\>([A-Za-z0-9_]+))?/i', - $tokens[$stackptr]['content'], $matches)) { - $firstvar = $matches[1]; - - $this->validate_moodle_variable_name($firstvar, $phpcsfile, $stackptr); + if ( + preg_match_all( + '/[^\\\\]\$([A-Za-z0-9_]+)(\-\>([A-Za-z0-9_]+))?/i', + $tokens[$stackptr]['content'], + $matches + ) + ) { + $captured = $matches[1]; + + foreach ($captured as $varname) { + $this->validateMoodleVariableName($varname, $phpcsfile, $stackptr); + } } } @@ -125,7 +130,7 @@ protected function processVariableInString(File $phpcsfile, $stackptr) { * * @return void */ - private function validate_moodle_variable_name($varname, File $phpcsfile, $stackptr) { + private function validateMoodleVariableName($varname, File $phpcsfile, $stackptr) { if (preg_match('/[A-Z]+/', $varname) && !in_array($varname, self::$allowedglobals)) { $error = "Variable \"$varname\" must be all lower-case"; $fix = $phpcsfile->addFixableError($error, $stackptr, 'VariableNameLowerCase'); @@ -133,7 +138,9 @@ private function validate_moodle_variable_name($varname, File $phpcsfile, $stack $phpcsfile->fixer->beginChangeset(); $tokens = $phpcsfile->getTokens(); $phpcsfile->fixer->replaceToken( - $stackptr, str_replace('$' . $varname, '$' . strtolower($varname), $tokens[$stackptr]['content'])); + $stackptr, + str_replace('$' . $varname, '$' . strtolower($varname), $tokens[$stackptr]['content']) + ); $phpcsfile->fixer->endChangeset(); } } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/DeprecatedFunctionsSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/DeprecatedFunctionsSniff.php index 80051c86..8d8e88d2 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/DeprecatedFunctionsSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/DeprecatedFunctionsSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHP; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DeprecatedFunctionsSniff as GenericDeprecatedFunctionsSniff; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; @@ -42,12 +41,11 @@ * (because unit tests DO NOT parse the ruleset.xml details, like * properties, excludes... and other info). * - * @package local_codechecker * @copyright 2021 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class DeprecatedFunctionsSniff extends GenericDeprecatedFunctionsSniff { - +class DeprecatedFunctionsSniff extends GenericDeprecatedFunctionsSniff +{ /** * If true, an error will be thrown; otherwise a warning. * @@ -84,7 +82,7 @@ class DeprecatedFunctionsSniff extends GenericDeprecatedFunctionsSniff { * @todo: This method can be removed once/if this PR accepted: * https://github.com/squizlabs/PHP_CodeSniffer/pull/3295 */ - protected function addError($phpcsFile, $stackPtr, $function, $pattern=null) { + protected function addError($phpcsFile, $stackPtr, $function, $pattern = null) { $data = [$function]; $error = 'Function %s() has been deprecated'; $type = 'Deprecated'; @@ -93,8 +91,9 @@ protected function addError($phpcsFile, $stackPtr, $function, $pattern=null) { $pattern = strtolower($function); } - if ($this->forbiddenFunctions[$pattern] !== null - && $this->forbiddenFunctions[$pattern] !== 'null' + if ( + $this->forbiddenFunctions[$pattern] !== null && + $this->forbiddenFunctions[$pattern] !== 'null' ) { $type .= 'WithAlternative'; $data[] = $this->forbiddenFunctions[$pattern]; @@ -106,6 +105,5 @@ protected function addError($phpcsFile, $stackPtr, $function, $pattern=null) { } else { $phpcsFile->addWarning($error, $stackPtr, $type, $data); } - - }//end addError() + } } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenFunctionsSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenFunctionsSniff.php index 84e03a33..4530eb60 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenFunctionsSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenFunctionsSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHP; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff as GenericForbiddenFunctionsSniff; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; @@ -42,12 +41,11 @@ * (because unit tests DO NOT parse the ruleset.xml details, like * properties, excludes... and other info). * - * @package local_codechecker * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class ForbiddenFunctionsSniff extends GenericForbiddenFunctionsSniff { - +class ForbiddenFunctionsSniff extends GenericForbiddenFunctionsSniff +{ /** * A list of forbidden functions with their alternatives. * diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenGlobalUseSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenGlobalUseSniff.php index 95e5eb8d..cc731005 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenGlobalUseSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenGlobalUseSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Sniff to detect people using global $PAGE and $OUTPUT in renderers, or global $PAGE in blocks. * - * @package local_codechecker * @copyright 2020 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHP; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Sniffs\AbstractVariableSniff; use PHP_CodeSniffer\Files\File; -class ForbiddenGlobalUseSniff extends AbstractVariableSniff { - +class ForbiddenGlobalUseSniff extends AbstractVariableSniff +{ /** * @var array list of problems to detect. Each element is an array with three keys: * classtype - this is a human-readable description of this type of class, used in error messages. @@ -67,7 +65,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $varName = ltrim($tokens[$stackPtr]['content'], '$'); - $this->check_variable_usage($varName, $phpcsFile, $stackPtr); + $this->checkVariableUsage($varName, $phpcsFile, $stackPtr); } /** @@ -78,7 +76,7 @@ protected function processVariableInString(File $phpcsFile, $stackPtr) { if (preg_match_all('|[^\\\]\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[$stackPtr]['content'], $matches) !== 0) { foreach ($matches[1] as $varName) { - $this->check_variable_usage($varName, $phpcsFile, $stackPtr); + $this->checkVariableUsage($varName, $phpcsFile, $stackPtr); } } } @@ -90,9 +88,9 @@ protected function processVariableInString(File $phpcsFile, $stackPtr) { * @param File $phpcsFile The PHP_CodeSniffer file where this token was found. * @param int $stackPtr The position where the token was found. */ - protected function check_variable_usage($varname, File $phpcsFile, $stackPtr) { + protected function checkVariableUsage($varname, File $phpcsFile, $stackPtr) { foreach ($this->forbiddencombinations as $forbiddencombination) { - $this->check_one_combination($varname, $forbiddencombination, $phpcsFile, $stackPtr); + $this->checkOneCombination($varname, $forbiddencombination, $phpcsFile, $stackPtr); } } @@ -106,8 +104,12 @@ protected function check_variable_usage($varname, File $phpcsFile, $stackPtr) { * @param File $phpcsFile The PHP_CodeSniffer file where this token was found. * @param int $stackPtr The position where the token was found. */ - protected function check_one_combination($varname, $forbiddencombination, - File $phpcsFile, $stackPtr) { + protected function checkOneCombination( + $varname, + $forbiddencombination, + File $phpcsFile, + $stackPtr + ) { $tokens = $phpcsFile->getTokens(); if (!in_array($varname, $forbiddencombination['variables'])) { @@ -127,9 +129,12 @@ protected function check_one_combination($varname, $forbiddencombination, // If the classname matches, report the error. if (preg_match($forbiddencombination['classnamepattern'], $classname)) { - $phpcsFile->addError('global $' . $varname . ' cannot be used in ' . - $forbiddencombination['classtype'] . '. Use $this->' . strtolower($varname) . '.', - $stackPtr, 'BadGlobal'); + $phpcsFile->addError( + 'global $' . $varname . ' cannot be used in ' . + $forbiddencombination['classtype'] . '. Use $this->' . strtolower($varname) . '.', + $stackPtr, + 'BadGlobal' + ); return; } } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenTokensSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenTokensSniff.php index a4296988..ce241d4a 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenTokensSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/ForbiddenTokensSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * The use of some tokens is forbidden. @@ -20,32 +21,29 @@ * This Sniff looks for some functions and operators that are handled * as specific tokens by the CS tokenizer. Complements {@link moodle_Sniffs_PHP_ForbiddenFunctionsSniff}. * - * @package local_codechecker - * @copyright 2014 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2014 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHP; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; -class ForbiddenTokensSniff implements Sniff { - +class ForbiddenTokensSniff implements Sniff +{ /** * Returns an array of Tokenizer tokens and errors this Sniff will listen and process. * * @return array with tokens as keys and error messages as description. */ - protected function get_forbidden_tokens() { - return array( + protected function getForbiddenTokens() { + return [ T_EVAL => 'The use of function eval() is forbidden', T_GOTO => 'The use of operator goto is forbidden', T_GOTO_LABEL => 'The use of goto labels is forbidden', T_BACKTICK => 'The use of backticks for shell execution is forbidden', - ); + ]; } /** @@ -54,7 +52,7 @@ protected function get_forbidden_tokens() { * @return array tokens this sniff will handle. */ public function register() { - return array_keys($this->get_forbidden_tokens()); + return array_keys($this->getForbiddenTokens()); } /** @@ -68,7 +66,7 @@ public function register() { public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $forbidden = $this->get_forbidden_tokens(); + $forbidden = $this->getForbiddenTokens(); $token = $tokens[$stackPtr]; $phpcsFile->addError($forbidden[$token['code']], $stackPtr, 'Found'); } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/IncludingFileSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/IncludingFileSniff.php index 4f7698ec..e2f20b2c 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/IncludingFileSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/IncludingFileSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Checks that the include_once is used in conditional situations, and @@ -22,22 +23,20 @@ * * Based on {@link PEAR_Sniffs_Files_IncludingFileSniff}. * - * @package local_codechecker * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHP; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Util\Tokens; -class IncludingFileSniff implements Sniff { +class IncludingFileSniff implements Sniff +{ public function register() { - return array(T_INCLUDE_ONCE, T_REQUIRE_ONCE, T_REQUIRE, T_INCLUDE); + return [T_INCLUDE_ONCE, T_REQUIRE_ONCE, T_REQUIRE, T_INCLUDE]; } public function process(File $file, $stackptr) { @@ -45,7 +44,7 @@ public function process(File $file, $stackptr) { if ($tokens[$stackptr + 1]['code'] !== T_OPEN_PARENTHESIS) { $error = '"%s" must be immediately followed by an open parenthesis'; - $data = array($tokens[$stackptr]['content']); + $data = [$tokens[$stackptr]['content']]; $file->addError($error, $stackptr, 'BracketsRequired', $data); } @@ -65,8 +64,7 @@ public function process(File $file, $stackptr) { // Check to see if they are assigning the return value of this // including call. If they are then they are probably checking it, so // it's conditional. - $previous = $file->findPrevious(Tokens::$emptyTokens, - ($stackptr - 1), null, true); + $previous = $file->findPrevious(Tokens::$emptyTokens, ($stackptr - 1), null, true); if (in_array($tokens[$previous]['code'], Tokens::$assignmentTokens)) { // The have assigned the return value to it, so its conditional. $incondition = true; @@ -79,7 +77,7 @@ public function process(File $file, $stackptr) { $error = 'File is being unconditionally included; '; $error .= 'use "require_once" instead'; $file->addError($error, $stackptr, 'UseRequireOnce'); - } else if ($tokentype === T_INCLUDE) { + } elseif ($tokentype === T_INCLUDE) { $error = 'File is being unconditionally included; '; $error .= 'use "require" instead'; $file->addError($error, $stackptr, 'UseRequire'); diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/MemberVarScopeSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/MemberVarScopeSniff.php index 923721d2..bd23dc51 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/MemberVarScopeSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHP/MemberVarScopeSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Verifies that class members have scope modifiers. Created by sam marshall, * based on a sniff by Greg Sherwood and Marc McIntyre. * - * @package local_codechecker * @author Greg Sherwood * @author Marc McIntyre * @author sam marshall * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @copyright 2011 The Open University - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence + * @license https://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHP; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Sniffs\AbstractVariableSniff; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Util\Tokens; -class MemberVarScopeSniff - extends AbstractVariableSniff { - +class MemberVarScopeSniff extends AbstractVariableSniff +{ /** * Processes the function tokens within the class. * @@ -54,7 +51,7 @@ protected function processMemberVar(File $file, $stackptr) { if ($modifier === false || $modifier < $semicolon) { $error = 'Scope modifier not specified for member variable "%s"'; - $data = array($tokens[$stackptr]['content']); + $data = [$tokens[$stackptr]['content']]; $file->addError($error, $stackptr, 'Missing', $data); } } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseCoversSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseCoversSniff.php index 04a57872..de5dece5 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseCoversSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseCoversSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit; -// phpcs:disable moodle.NamingConventions - use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; @@ -27,17 +26,16 @@ /** * Checks that a test file has the @coversxxx annotations properly defined. * - * @package local_codechecker * @copyright 2022 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class TestCaseCoversSniff implements Sniff { - +class TestCaseCoversSniff implements Sniff +{ /** * Register for open tag (only process once per file). */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; } /** @@ -131,10 +129,18 @@ public function process(File $file, $pointer) { // Both @covers and @coversNothing, that's a mistake. 2 errors. if ($classCovers && $classCoversNothing) { - $file->addError('Class %s has both @covers and @coversNothing tags, good contradiction', - $classCovers, 'ContradictoryClass', [$class]); - $file->addError('Class %s has both @covers and @coversNothing tags, good contradiction', - $classCoversNothing, 'ContradictoryClass', [$class]); + $file->addError( + 'Class %s has both @covers and @coversNothing tags, good contradiction', + $classCovers, + 'ContradictoryClass', + [$class] + ); + $file->addError( + 'Class %s has both @covers and @coversNothing tags, good contradiction', + $classCoversNothing, + 'ContradictoryClass', + [$class] + ); } // Iterate over all the methods in the class. @@ -172,8 +178,12 @@ public function process(File $file, $pointer) { break; case '@coversDefaultClass': // Not allowed in methods. - $file->addError('Method %s() has @coversDefaultClass tag, only allowed in classes', - $docPointer, 'DefaultClassNotAllowed', [$method]); + $file->addError( + 'Method %s() has @coversDefaultClass tag, only allowed in classes', + $docPointer, + 'DefaultClassNotAllowed', + [$method] + ); break; } } @@ -182,30 +192,54 @@ public function process(File $file, $pointer) { // No @covers or @coversNothing at any level, that's a missing one. if (!$classCovers && !$classCoversNothing && !$methodCovers && !$methodCoversNothing) { - $file->addWarning('Test method %s() is missing any coverage information, own or at class level', - $mStart, 'Missing', [$method]); + $file->addWarning( + 'Test method %s() is missing any coverage information, own or at class level', + $mStart, + 'Missing', + [$method] + ); } // Both @covers and @coversNothing, that's a mistake. 2 errors. if ($methodCovers && $methodCoversNothing) { - $file->addError('Method %s() has both @covers and @coversNothing tags, good contradiction', - $methodCovers, 'ContradictoryMethod', [$method]); - $file->addError('Method %s() has both @covers and @coversNothing tags, good contradiction', - $methodCoversNothing, 'ContradictoryMethod', [$method]); + $file->addError( + 'Method %s() has both @covers and @coversNothing tags, good contradiction', + $methodCovers, + 'ContradictoryMethod', + [$method] + ); + $file->addError( + 'Method %s() has both @covers and @coversNothing tags, good contradiction', + $methodCoversNothing, + 'ContradictoryMethod', + [$method] + ); } // Found @coversNothing at class, and @covers at method, strange. Warning. if ($classCoversNothing && $methodCovers) { - $file->addWarning('Class %s has @coversNothing, but there are methods covering stuff', - $classCoversNothing, 'ContradictoryMixed', [$class]); - $file->addWarning('Test method %s() is covering stuff, but class has @coversNothing', - $methodCovers, 'ContradictoryMixed', [$method]); + $file->addWarning( + 'Class %s has @coversNothing, but there are methods covering stuff', + $classCoversNothing, + 'ContradictoryMixed', + [$class] + ); + $file->addWarning( + 'Test method %s() is covering stuff, but class has @coversNothing', + $methodCovers, + 'ContradictoryMixed', + [$method] + ); } // Found @coversNothing at class and method, redundant. Warning. if ($classCoversNothing && $methodCoversNothing) { - $file->addWarning('Test method %s() has @coversNothing, but class also has it, redundant', - $methodCoversNothing, 'Redundant', [$method]); + $file->addWarning( + 'Test method %s() has @coversNothing, but class also has it, redundant', + $methodCoversNothing, + 'Redundant', + [$method] + ); } // Advance until the end of the method, if possible, to find the next one quicker. @@ -228,19 +262,31 @@ protected function checkCoversTagsSyntax(File $file, int $pointer, string $tag) if ($tag === '@coversNothing') { // Check that there isn't whitespace and string. - if ($tokens[$pointer + 1]['code'] === T_DOC_COMMENT_WHITESPACE && - $tokens[$pointer + 2]['code'] === T_DOC_COMMENT_STRING) { - $file->addError('Wrong %s annotation, it must be empty', - $pointer, 'NotEmpty', [$tag]); + if ( + $tokens[$pointer + 1]['code'] === T_DOC_COMMENT_WHITESPACE && + $tokens[$pointer + 2]['code'] === T_DOC_COMMENT_STRING + ) { + $file->addError( + 'Wrong %s annotation, it must be empty', + $pointer, + 'NotEmpty', + [$tag] + ); } } if ($tag === '@covers' || $tag === '@coversDefaultClass') { // Check that there is whitespace and string. - if ($tokens[$pointer + 1]['code'] !== T_DOC_COMMENT_WHITESPACE || - $tokens[$pointer + 2]['code'] !== T_DOC_COMMENT_STRING) { - $file->addError('Wrong %s annotation, it must contain some value', - $pointer, 'Empty', [$tag]); + if ( + $tokens[$pointer + 1]['code'] !== T_DOC_COMMENT_WHITESPACE || + $tokens[$pointer + 2]['code'] !== T_DOC_COMMENT_STRING + ) { + $file->addError( + 'Wrong %s annotation, it must contain some value', + $pointer, + 'Empty', + [$tag] + ); // No value, nothing else to check. return; } @@ -249,22 +295,36 @@ protected function checkCoversTagsSyntax(File $file, int $pointer, string $tag) if ($tag === '@coversDefaultClass') { // Check that value begins with \ (FQCN). if (strpos($tokens[$pointer + 2]['content'], '\\') !== 0) { - $file->addError('Wrong %s annotation, it must be FQCN (\\ prefixed)', - $pointer, 'NoFQCN', [$tag]); + $file->addError( + 'Wrong %s annotation, it must be FQCN (\\ prefixed)', + $pointer, + 'NoFQCN', + [$tag] + ); } // Check that value does not contain :: (method). if (strpos($tokens[$pointer + 2]['content'], '::') !== false) { - $file->addError('Wrong %s annotation, cannot point to a method (contains ::)', - $pointer, 'WrongMethod', [$tag]); + $file->addError( + 'Wrong %s annotation, cannot point to a method (contains ::)', + $pointer, + 'WrongMethod', + [$tag] + ); } } if ($tag === '@covers') { // Check value begins with \ (FQCN) or :: (method). - if (strpos($tokens[$pointer + 2]['content'], '\\') !== 0 && - strpos($tokens[$pointer + 2]['content'], '::') !== 0) { - $file->addError('Wrong %s annotation, it must be FQCN (\\ prefixed) or point to method (:: prefixed)', - $pointer, 'NoFQCNOrMethod', [$tag]); + if ( + strpos($tokens[$pointer + 2]['content'], '\\') !== 0 && + strpos($tokens[$pointer + 2]['content'], '::') !== 0 + ) { + $file->addError( + 'Wrong %s annotation, it must be FQCN (\\ prefixed) or point to method (:: prefixed)', + $pointer, + 'NoFQCNOrMethod', + [$tag] + ); } } } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseNamesSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseNamesSniff.php index c8ec5d8a..05f7575e 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseNamesSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseNamesSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Checks that a test file has a class name matching the file name. * - * @package local_codechecker * @copyright 2021 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit; -// phpcs:disable moodle.NamingConventions - use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; -class TestCaseNamesSniff implements Sniff { - +class TestCaseNamesSniff implements Sniff +{ /** * List of classes that have been found during checking. * @@ -50,7 +48,7 @@ class TestCaseNamesSniff implements Sniff { * Register for open tag (only process once per file). */ public function register() { - return array(T_OPEN_TAG); + return [T_OPEN_TAG]; } /** @@ -153,15 +151,23 @@ public function process(File $file, $pointer) { // Error if the found classname is "strange" (not "_test|_testcase" ended). if (substr($class, -5) !== '_test' && substr($class, -9) != '_testcase') { - $file->addError('PHPUnit irregular testcase name found: %s (_test/_testcase ended expected)', $cStart, - 'Irregular', [$class]); + $file->addError( + 'PHPUnit irregular testcase name found: %s (_test/_testcase ended expected)', + $cStart, + 'Irregular', + [$class] + ); } // Check if the file name and the class name match, warn if not. $baseName = pathinfo($fileName, PATHINFO_FILENAME); if ($baseName !== $class) { - $fix = $file->addFixableWarning('PHPUnit testcase name "%s" does not match file name "%s"', $cStart, - 'NoMatch', [$class, $baseName]); + $fix = $file->addFixableWarning( + 'PHPUnit testcase name "%s" does not match file name "%s"', + $cStart, + 'NoMatch', + [$class, $baseName] + ); if ($fix === true) { if ($cNameToken = $file->findNext(T_STRING, $cStart + 1, $tokens[$cStart]['scope_opener'])) { @@ -175,8 +181,12 @@ public function process(File $file, $pointer) { if (isset($this->foundClasses[$fdqnClass])) { // Already found, this is a dupe class name, error! foreach ($this->foundClasses[$fdqnClass] as $exists) { - $file->addError('PHPUnit testcase "%s" already exists at "%s" line %s', $cStart, - 'DuplicateExists', [$fdqnClass, $exists['file'], $exists['line']]); + $file->addError( + 'PHPUnit testcase "%s" already exists at "%s" line %s', + $cStart, + 'DuplicateExists', + [$fdqnClass, $exists['file'], $exists['line']] + ); } } else { // Create the empty element. @@ -193,9 +203,13 @@ public function process(File $file, $pointer) { if (isset($this->proposedClasses[$fdqnClass])) { // Already found, this is a dupe class name, error! foreach ($this->proposedClasses[$fdqnClass] as $exists) { - $file->addError('PHPUnit testcase "%s" already proposed for "%s" line %s. You ' . - 'may want to change the testcase name (file and class)', $cStart, - 'ProposedExists', [$fdqnClass, $exists['file'], $exists['line']]); + $file->addError( + 'PHPUnit testcase "%s" already proposed for "%s" line %s. You ' . + 'may want to change the testcase name (file and class)', + $cStart, + 'ProposedExists', + [$fdqnClass, $exists['file'], $exists['line']] + ); } } @@ -206,8 +220,12 @@ public function process(File $file, $pointer) { if ($namespace && $moodleComponent) { // Verify that the namespace declared in the class matches the namespace expected for the file. if (strpos($namespace . '\\', $moodleComponent . '\\') !== 0) { - $file->addError('PHPUnit class namespace "%s" does not match expected file namespace "%s"', $nsStart, - 'UnexpectedNS', [$namespace, $moodleComponent]); + $file->addError( + 'PHPUnit class namespace "%s" does not match expected file namespace "%s"', + $nsStart, + 'UnexpectedNS', + [$namespace, $moodleComponent] + ); } // Verify that level2 and down match the directory structure under tests. Soft warn if not (till we fix all). @@ -215,36 +233,48 @@ public function process(File $file, $pointer) { if ($bspos !== false) { // Only if there are level2 and down namespace. $relns = str_replace('\\', '/', substr(trim($namespace, ' \\'), $bspos + 1)); + $filename = MoodleUtil::getStandardisedFilename($file); // Calculate the relative path under tests directory. - $dirpos = strripos(trim(dirname($file->getFilename()), ' /') . '/', '/tests/'); - $reldir = str_replace('\\', '/', substr(trim(dirname($file->getFilename()), ' /'), $dirpos + 7)); + $dirpos = strripos(trim(dirname($filename), ' /') . '/', '/tests/'); + $reldir = str_replace('\\', '/', substr(trim(dirname($filename), ' /'), $dirpos + 7)); // Warning if the relative namespace does not match the relative directory. if ($reldir !== $relns) { - $file->addWarning('PHPUnit class "%s", with namespace "%s", currently located at "tests/%s" directory, '. - 'does not match its expected location at "tests/%s"', $nsStart, - 'UnexpectedLevel2NS', [$fdqnClass, $namespace, $reldir, $relns]); + $file->addWarning( + 'PHPUnit class "%s", with namespace "%s", currently located at "tests/%s" directory, ' . + 'does not match its expected location at "tests/%s"', + $nsStart, + 'UnexpectedLevel2NS', + [$fdqnClass, $namespace, $reldir, $relns] + ); } // TODO: When we have APIs (https://docs.moodle.org/dev/Core_APIs) somewhere at hand (in core) // let's add here an error when incorrect ones are used. See MDL-71096 about it. } - } if (!$namespace && $moodleComponent) { - $file->addWarning('PHPUnit class "%s" does not have any namespace. It is recommended to add it to the "%s" ' . - 'namespace, using more levels if needed, in order to match the code being tested', $cStart, - 'MissingNS', [$fdqnClass, $moodleComponent]); + $file->addWarning( + 'PHPUnit class "%s" does not have any namespace. It is recommended to add it to the "%s" ' . + 'namespace, using more levels if needed, in order to match the code being tested', + $cStart, + 'MissingNS', + [$fdqnClass, $moodleComponent] + ); // Check if the proposed class has been already proposed (this is useful when running against a lot of files). $fdqnProposed = $moodleComponent . '\\' . $fdqnClass; if (isset($this->proposedClasses[$fdqnProposed])) { // Already found, this is a dupe class name, error! foreach ($this->proposedClasses[$fdqnProposed] as $exists) { - $file->addError('Proposed PHPUnit testcase "%s" already proposed for "%s" line %s. You ' . - 'may want to change the testcase name (file and class)', $cStart, - 'DuplicateProposed', [$fdqnProposed, $exists['file'], $exists['line']]); + $file->addError( + 'Proposed PHPUnit testcase "%s" already proposed for "%s" line %s. You ' . + 'may want to change the testcase name (file and class)', + $cStart, + 'DuplicateProposed', + [$fdqnProposed, $exists['file'], $exists['line']] + ); } } else { // Create the empty element. @@ -261,9 +291,13 @@ public function process(File $file, $pointer) { if (isset($this->foundClasses[$fdqnProposed])) { // Already found, this is a dupe class name, error! foreach ($this->foundClasses[$fdqnProposed] as $exists) { - $file->addError('Proposed PHPUnit testcase "%s" already exists at "%s" line %s. You ' . - 'may want to change the testcase name (file and class)', $cStart, - 'ExistsProposed', [$fdqnProposed, $exists['file'], $exists['line']]); + $file->addError( + 'Proposed PHPUnit testcase "%s" already exists at "%s" line %s. You ' . + 'may want to change the testcase name (file and class)', + $cStart, + 'ExistsProposed', + [$fdqnProposed, $exists['file'], $exists['line']] + ); } } } diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseProviderSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseProviderSniff.php index dcf1431b..db010eb2 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseProviderSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCaseProviderSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit; -// phpcs:disable moodle.NamingConventions - use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; @@ -27,12 +26,11 @@ /** * Checks that a test file has the @coversxxx annotations properly defined. * - * @package local_codechecker * @copyright 2022 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class TestCaseProviderSniff implements Sniff { - +class TestCaseProviderSniff implements Sniff +{ /** * Whether to autofix static providers. * @@ -169,7 +167,7 @@ protected function checkDataProvider( if ($tokens[$pointer + 2]['code'] !== T_DOC_COMMENT_STRING) { $file->addError( 'Wrong @dataProvider tag specified for test %s, it must be followed by a space and a method name.', - $pointer + 2, + $pointer, 'dataProviderSyntaxMethodnameMissing', [ $testName, @@ -255,7 +253,7 @@ protected function checkDataProvider( } $file->fixer->endChangeset(); } - } else if ($methodProps['scope'] !== 'public') { + } elseif ($methodProps['scope'] !== 'public') { $scopePointer = $file->findPrevious(Tokens::$scopeModifiers, $providerPointer - 1); $fix = $file->addFixableError( 'Data provider method "%s" must be public.', @@ -281,9 +279,10 @@ protected function checkDataProvider( // All valid break; default: + $returnPointer = $file->findNext(T_CLOSE_PARENTHESIS, $providerPointer + 1); $file->addError( 'Data provider method "%s" must return an array, a Generator or an Iterable.', - $pointer + 2, + $returnPointer, 'dataProviderSyntaxMethodInvalidReturnType', [ $methodName, @@ -313,7 +312,7 @@ protected function checkDataProvider( if (!$supportAutomatedFix) { $file->addWarning( 'Data provider method "%s" will need to be converted to static in future.', - $pointer + 2, + $providerPointer, 'dataProviderNotStatic', [ $methodName, @@ -322,7 +321,7 @@ protected function checkDataProvider( } else { $fix = $file->addFixableWarning( 'Data provider method "%s" will need to be converted to static in future.', - $pointer + 2, + $providerPointer, 'dataProviderNotStatic', [ $methodName, @@ -356,8 +355,7 @@ protected static function findMethodCalls( File $phpcsFile, int $classPtr, string $methodName - ): array - { + ): array { $data = []; $mStart = $classPtr; diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCasesAbstractSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCasesAbstractSniff.php new file mode 100644 index 00000000..26e6ce74 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestCasesAbstractSniff.php @@ -0,0 +1,87 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit; + +use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Files\File; +use PHPCSUtils\Utils\ObjectDeclarations; + +/** + * Checks that testcase classes are declared as abstract. + * + * @copyright 2024 Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class TestCasesAbstractSniff implements Sniff +{ + public function register() { + return [ + T_OPEN_TAG, + ]; + } + + public function process(File $file, $pointer) { + // If the file is not a unit test file, nothing to check. + if (!MoodleUtil::isUnitTest($file) && !MoodleUtil::isUnitTestRunning()) { + return; // @codeCoverageIgnore + } + + // If we aren't checking Moodle 4.4dev (404) and up, nothing to check. + // Make and exception for codechecker phpunit tests, so they are run always. + if (!MoodleUtil::meetsMinimumMoodleVersion($file, 404) && !MoodleUtil::isUnitTestRunning()) { + return; // @codeCoverageIgnore + } + + // We only want to do this once per file. + $prevopentag = $file->findPrevious(T_OPEN_TAG, $pointer - 1); + if ($prevopentag !== false) { + return; // @codeCoverageIgnore + } + + $cStart = $pointer; + while ($cStart = $file->findNext(T_CLASS, $cStart + 1)) { + if (MoodleUtil::isUnitTestCaseClass($file, $cStart) === false) { + // This class does not relate to a unit test. + continue; + } + + $className = ObjectDeclarations::getName($file, $cStart); + if (substr($className, -9) !== '_testcase') { + continue; + } + + $classInfo = ObjectDeclarations::getClassProperties($file, $cStart); + + if (!$classInfo['is_abstract']) { + $fix = $file->addFixableWarning( + 'Testcase %s should be declared as abstract.', + $cStart, + 'UnitTestClassesAbstract', + [$className], + ); + + if ($fix) { + $file->fixer->beginChangeset(); + $file->fixer->addContentBefore($cStart, 'abstract '); + $file->fixer->endChangeset(); + } + } + } + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestClassesFinalSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestClassesFinalSniff.php new file mode 100644 index 00000000..923a9b09 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestClassesFinalSniff.php @@ -0,0 +1,124 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit; + +use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Files\File; +use PHPCSUtils\Utils\ObjectDeclarations; + +/** + * Checks that test classes are declared as final. + * + * @copyright 2024 Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class TestClassesFinalSniff implements Sniff +{ + public function register() { + return [ + T_OPEN_TAG, + ]; + } + + public function process(File $file, $pointer) { + // If the file is not a unit test file, nothing to check. + if (!MoodleUtil::isUnitTest($file) && !MoodleUtil::isUnitTestRunning()) { + return; // @codeCoverageIgnore + } + + // If we aren't checking Moodle 4.4dev (404) and up, nothing to check. + // Make and exception for codechecker phpunit tests, so they are run always. + if (!MoodleUtil::meetsMinimumMoodleVersion($file, 404) && !MoodleUtil::isUnitTestRunning()) { + return; // @codeCoverageIgnore + } + + // Get the file tokens, for ease of use. + $tokens = $file->getTokens(); + + // We only want to do this once per file. + $prevopentag = $file->findPrevious(T_OPEN_TAG, $pointer - 1); + if ($prevopentag !== false) { + return; // @codeCoverageIgnore + } + + $cStart = $pointer; + while ($cStart = $file->findNext(T_CLASS, $cStart + 1)) { + if (MoodleUtil::isUnitTestCaseClass($file, $cStart) === false) { + // This class does not relate to a unit test. + continue; + } + $className = ObjectDeclarations::getName($file, $cStart); + if (substr($className, -5) !== '_test') { + continue; + } + + $classInfo = ObjectDeclarations::getClassProperties($file, $cStart); + + if ($classInfo['is_final']) { + // Already final. + continue; + } + + if ($classInfo['is_abstract']) { + // See if this class has any abstract methods. + $mStart = $cStart + 1; + $hasAbstractMethod = false; + + while ($mStart = $file->findNext(T_ABSTRACT, $mStart, $tokens[$cStart]['scope_closer']) !== false) { + $hasAbstractMethod = true; + break; + } + if ($hasAbstractMethod) { + $file->addWarning( + 'Unit test %s should be declared as final and not abstract.', + $cStart, + 'UnitTestClassesFinal', + [$className], + ); + } else { + $fix = $file->addFixableWarning( + 'Unit test %s should be declared as final and not abstract.', + $cStart, + 'UnitTestClassesFinal', + [$className], + ); + + if ($fix) { + $file->fixer->beginChangeset(); + $file->fixer->replaceToken($classInfo['abstract_token'], 'final'); + $file->fixer->endChangeset(); + } + } + } elseif (!$classInfo['is_final']) { + $fix = $file->addFixableWarning( + 'Unit test %s should be declared as final.', + $cStart, + 'UnitTestClassesFinal', + [$className], + ); + + if ($fix) { + $file->fixer->beginChangeset(); + $file->fixer->addContentBefore($cStart, 'final '); + $file->fixer->endChangeset(); + } + } + } + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestReturnTypeSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestReturnTypeSniff.php index af5776a4..c27588bb 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestReturnTypeSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/PHPUnit/TestReturnTypeSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . namespace MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit; -// phpcs:disable moodle.NamingConventions - use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; @@ -27,13 +26,11 @@ /** * Checks that a test file has the @coversxxx annotations properly defined. * - * @package local_codechecker * @copyright 2022 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class TestReturnTypeSniff implements Sniff { - /** * Register for open tag (only process once per file). */ @@ -70,7 +67,8 @@ public function process(File $file, $pointer) $tokens = $file->getTokens(); // We only want to do this once per file. - $prevopentag = $file->findPrevious(T_OPEN_TAG, + $prevopentag = $file->findPrevious( + T_OPEN_TAG, $pointer - 1 ); if ($prevopentag !== false) { diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Strings/ForbiddenStringsSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Strings/ForbiddenStringsSniff.php index 70f4ffd9..527f5826 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/Strings/ForbiddenStringsSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/Strings/ForbiddenStringsSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Inspect some strings that may lead to incorrect uses of Moodle/PHP APIs. * - * @package local_codechecker - * @copyright 2014 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2014 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\Strings; -// phpcs:disable moodle.NamingConventions - use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; -class ForbiddenStringsSniff implements Sniff { - +class ForbiddenStringsSniff implements Sniff +{ /** * Returns an array of tokens this test wants to listen for. * @@ -38,7 +36,7 @@ class ForbiddenStringsSniff implements Sniff { */ public function register() { // We are going to handle strings here. - return array(T_CONSTANT_ENCAPSED_STRING); + return [T_CONSTANT_ENCAPSED_STRING]; } /** @@ -51,9 +49,9 @@ public function register() { */ public function process(File $phpcsFile, $stackPtr) { // Delegate the processing to specialised methods. - $this->process_sql_as_keyword($phpcsFile, $stackPtr); - $this->process_regexp_separator_e($phpcsFile, $stackPtr); - $this->process_string_with_backticks($phpcsFile, $stackPtr); + $this->processSqlAsKeyword($phpcsFile, $stackPtr); + $this->processRegexpSeparatorE($phpcsFile, $stackPtr); + $this->processStringWithBackticks($phpcsFile, $stackPtr); } /** @@ -64,7 +62,7 @@ public function process(File $phpcsFile, $stackPtr) { * * @return void */ - protected function process_sql_as_keyword(File $phpcsFile, $stackPtr) { + protected function processSqlAsKeyword(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; $text = trim($token['content'], "'\""); @@ -82,7 +80,7 @@ protected function process_sql_as_keyword(File $phpcsFile, $stackPtr) { * * @return void */ - protected function process_regexp_separator_e(File $phpcsFile, $stackPtr) { + protected function processRegexpSeparatorE(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; $text = trim($token['content'], " '\"\t\n"); @@ -113,28 +111,21 @@ protected function process_regexp_separator_e(File $phpcsFile, $stackPtr) { * * @return void */ - protected function process_string_with_backticks(File $phpcsFile, $stackPtr) { + protected function processStringWithBackticks(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; $text = trim($token['content'], "'\""); if (strpos($text, '`') !== false) { //phpcs:ignore moodle.Strings.ForbiddenStrings.Found - // Exception. lang strings ending with _desc or _help can // contain backticks as they are correct Markdown formatting. // Look for previous string. - $prevString = $phpcsFile->findPrevious( - T_CONSTANT_ENCAPSED_STRING, - ($stackPtr - 1)); + $prevString = $phpcsFile->findPrevious(T_CONSTANT_ENCAPSED_STRING, ($stackPtr - 1)); if ($prevString) { $prevtext = trim($tokens[$prevString]['content'], "'\""); // Verify it matches _desc|_help. if (preg_match('/(_desc|_help)$/', $prevtext)) { // Verify it's an $string array element. - $prevToken = $phpcsFile->findPrevious( - T_OPEN_SQUARE_BRACKET, - ($prevString - 1), - null, - true); + $prevToken = $phpcsFile->findPrevious(T_OPEN_SQUARE_BRACKET, ($prevString - 1), null, true); if ($prevToken) { if ($tokens[$prevToken]['code'] === T_VARIABLE && $tokens[$prevToken]['content'] === '$string') { // Confirmed we are in a valid lang string using Markdown, skip any warning. diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/WhiteSpace/SpaceAfterCommaSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/WhiteSpace/SpaceAfterCommaSniff.php index 56df6c90..3fd3d7bc 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/WhiteSpace/SpaceAfterCommaSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/WhiteSpace/SpaceAfterCommaSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Verify there is a single space after a comma. * - * @package local_codechecker * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\WhiteSpace; @@ -27,9 +27,10 @@ use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; -class SpaceAfterCommaSniff implements Sniff { +class SpaceAfterCommaSniff implements Sniff +{ public function register() { - return array(T_COMMA); + return [T_COMMA]; } /** diff --git a/vendor/moodlehq/moodle-cs/moodle/Sniffs/WhiteSpace/WhiteSpaceInStringsSniff.php b/vendor/moodlehq/moodle-cs/moodle/Sniffs/WhiteSpace/WhiteSpaceInStringsSniff.php index acff03f6..25177cd6 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Sniffs/WhiteSpace/WhiteSpaceInStringsSniff.php +++ b/vendor/moodlehq/moodle-cs/moodle/Sniffs/WhiteSpace/WhiteSpaceInStringsSniff.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . /** * Checks that each string does not have extra whitespace at end of line * - * @package local_codechecker * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace MoodleHQ\MoodleCS\moodle\Sniffs\WhiteSpace; @@ -27,20 +27,20 @@ use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; -class WhiteSpaceInStringsSniff implements Sniff { - +class WhiteSpaceInStringsSniff implements Sniff +{ /** * Returns an array of tokens this test wants to listen for. * * @return array */ public function register() { - return array( - T_CONSTANT_ENCAPSED_STRING, - T_DOUBLE_QUOTED_STRING, - T_HEREDOC, - T_WHITESPACE - ); + return [ + T_CONSTANT_ENCAPSED_STRING, + T_DOUBLE_QUOTED_STRING, + T_HEREDOC, + T_WHITESPACE, + ]; } /** diff --git a/vendor/moodlehq/moodle-cs/moodle/Util/Docblocks.php b/vendor/moodlehq/moodle-cs/moodle/Util/Docblocks.php new file mode 100644 index 00000000..6b86cb7e --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Util/Docblocks.php @@ -0,0 +1,379 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Util; + +use PHP_CodeSniffer\Files\File; + +/** + * Utilities related to PHP DocBlocks. + * + * @copyright 2024 Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +abstract class Docblocks +{ + /** + * List of valid, well known, phpdoc tags, always accepted. + * + * @var array + * @link http://manual.phpdoc.org/HTMLSmartyConverter/HandS/ */ + private static array $validTags = [ + // Behat tags. + 'Given' => true, + 'Then' => true, + 'When' => true, + 'BeforeFeature' => true, + 'BeforeScenario' => true, + 'BeforeStep' => true, + 'AfterFeature' => true, + 'AfterScenario' => true, + 'AfterStep' => true, + + // PHPUnit tags. + 'codeCoverageIgnore' => true, + 'codeCoverageIgnoreStart' => true, + 'codeCoverageIgnoreEnd' => true, + 'covers' => true, + 'coversDefaultClass' => true, + 'coversNothing' => true, + 'dataProvider' => true, + 'depends' => true, + 'group' => true, + 'requires' => true, + 'runTestsInSeparateProcesses' => true, + 'runInSeparateProcess' => true, + 'testWith' => true, + + // PHPDoc tags. + 'abstract' => false, + 'access' => false, + 'author' => true, + 'category' => true, + 'copyright' => true, + 'deprecated' => true, + 'example' => false, + 'final' => false, + 'filesource' => false, + 'global' => false, + 'ignore' => false, + 'internal' => false, + 'license' => true, + 'link' => true, + 'method' => false, + 'name' => false, + 'package' => true, + 'param' => true, + 'property' => true, + 'property-read' => true, + 'property-write' => true, + 'return' => true, + 'see' => true, + 'since' => true, + 'static' => false, + 'staticvar' => false, + 'subpackage' => true, + 'throws' => true, + 'todo' => true, + 'tutorial' => false, + 'uses' => true, // Also used by PHPUnit. + 'var' => true, + 'version' => false, + ]; + + /** + * List of invalid tags that should be removed. + * + * @var string[] + */ + private static array $invalidTagsToRemove = [ + 'void', + ]; + + /** + * List of tags that should be renamed. + * + * @var string[string] + */ + private static array $renameTags = [ + // Rename returns to return. + 'returns' => 'return', + ]; + + /** + * A list of phpdoc tags allowed to be used under certain directories. + * keys are tags, values are arrays of allowed paths (regexp patterns). + * + * @var array(string => array(string)) + */ + private static array $pathRestrictedTags = [ + 'Given' => ['#.*/tests/behat/.*#'], + 'Then' => ['#.*/tests/behat/.*#'], + 'When' => ['#.*/tests/behat/.*#'], + 'BeforeFeature' => ['#.*/tests/behat/.*#'], + 'BeforeScenario' => ['#.*/tests/behat/.*#'], + 'BeforeStep' => ['#.*/tests/behat/.*#'], + 'AfterFeature' => ['#.*/tests/behat/.*#'], + 'AfterScenario' => ['#.*/tests/behat/.*#'], + 'AfterStep' => ['#.*/tests/behat/.*#'], + + 'covers' => ['#.*/tests/.*_test.php#'], + 'coversDefaultClass' => ['#.*/tests/.*_test.php#'], + 'coversNothing' => ['#.*/tests/.*_test.php#'], + 'dataProvider' => ['#.*/tests/.*_test.php#'], + 'depends' => ['#.*/tests/.*_test.php#'], + 'group' => ['#.*/tests/.*_test.php#'], + 'requires' => ['#.*/tests/.*_test.php#'], + 'runTestsInSeparateProcesses' => ['#.*/tests/.*_test.php#'], + 'runInSeparateProcess' => ['#.*/tests/.*_test.php#'], + 'testWith' => ['#.*/tests/.*_test.php#'], + // Commented out: 'uses' => ['#.*/tests/.*_test.php#'], can also be out from tests (Coding style dixit). + ]; + + /** + * Get the docblock pointer for a file, class, interface, trait, or method. + * + * @param File $phpcsFile + * @param int $stackPtr + * @return null|int + */ + public static function getDocBlockPointer( + File $phpcsFile, + int $stackPtr + ): ?int { + $tokens = $phpcsFile->getTokens(); + $token = $tokens[$stackPtr]; + + // Check if the passed pointer was for a doc. + $midDocBlockTokens = [ + T_DOC_COMMENT, + T_DOC_COMMENT_STAR, + T_DOC_COMMENT_WHITESPACE, + T_DOC_COMMENT_TAG, + T_DOC_COMMENT_STRING, + ]; + if ($token['code'] === T_DOC_COMMENT_OPEN_TAG) { + return $stackPtr; + } elseif ($token['code'] === T_DOC_COMMENT_CLOSE_TAG) { + // The pointer was for a close tag. Fetch the corresponding open tag. + return $token['comment_opener']; + } elseif (in_array($token['code'], $midDocBlockTokens)) { + // The pointer was for a token inside the docblock. Fetch the corresponding open tag. + $commentStart = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPtr); + return $commentStart ?: null; + } + + // If the pointer was for a file, fetch the doc tag from the open tag. + if ($tokens[$stackPtr]['code'] === T_OPEN_TAG) { + return self::getDocTagFromOpenTag($phpcsFile, $stackPtr); + } + + // Assume that the stackPtr is for a class, interface, trait, or method, or some part of them. + // Back track over each previous pointer until we find the docblock. + // It should be on the line immediately before the pointer. + $pointerLine = $tokens[$stackPtr]['line']; + + $previousContent = null; + for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) { + $token = $tokens[$commentEnd]; + if ($previousContent === null) { + $previousContent = $commentEnd; + } + + if ($token['code'] === T_ATTRIBUTE_END && isset($token['attribute_opener'])) { + $commentEnd = $token['attribute_opener']; + $pointerLine = $tokens[$commentEnd]['line']; + continue; + } + + if ($token['line'] < ($pointerLine - 1)) { + // The comment must be on the line immediately before the pointer, or immediately before the attribute. z + return null; + } + + if ($token['code'] === T_DOC_COMMENT_CLOSE_TAG) { + // The pointer was for a close tag. Fetch the corresponding open tag. + return $token['comment_opener']; + } + } + + return null; // @codeCoverageIgnore + } + + /** + * Get the doc tag from the file open tag. + * + * @param File $phpcsFile + * @param int $stackPtr + * @return null|int + */ + protected static function getDocTagFromOpenTag( + File $phpcsFile, + int $stackPtr + ): ?int { + $tokens = $phpcsFile->getTokens(); + + $ignore = [ + T_WHITESPACE, + T_COMMENT, + ]; + + $stopAtTypes = [ + T_CLASS, + T_INTERFACE, + T_TRAIT, + T_ENUM, + T_FUNCTION, + T_CLOSURE, + T_PUBLIC, + T_PRIVATE, + T_PROTECTED, + T_FINAL, + T_STATIC, + T_ABSTRACT, + T_READONLY, + T_CONST, + T_PROPERTY, + T_INCLUDE, + T_INCLUDE_ONCE, + T_REQUIRE, + T_REQUIRE_ONCE, + T_ATTRIBUTE, + ]; + + while ($stackPtr = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true)) { + if ($tokens[$stackPtr]['code'] === T_NAMESPACE || $tokens[$stackPtr]['code'] === T_USE) { + $stackPtr = $phpcsFile->findNext(T_SEMICOLON, $stackPtr + 1); + continue; + } + + if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT_OPEN_TAG) { + $nextToken = $tokens[$stackPtr]['comment_closer']; + $closeLine = $tokens[$nextToken]['line']; + + while ($nextToken = $phpcsFile->findNext(T_WHITESPACE, $nextToken + 1, null, true)) { + if (in_array($tokens[$nextToken]['code'], $stopAtTypes)) { + // If the stop token is on the line immediately following the attribute or close comment + // then it belongs to that stop token, and not the file. + if ($tokens[$nextToken]['line'] === ($closeLine + 1)) { + return null; + } + } + break; + } + return $stackPtr; + } + } + + return null; + } + + /** + * Get the tags that match the given tag name. + * + * @param File $phpcsFile + * @param int|null $stackPtr The pointer of the docblock + * @param string $tagName + */ + public static function getMatchingDocTags( + File $phpcsFile, + ?int $stackPtr, + string $tagName + ): array { + if ($stackPtr === null) { + return []; + } + $tokens = $phpcsFile->getTokens(); + $docblock = $tokens[$stackPtr]; + $matchingTags = []; + foreach ($docblock['comment_tags'] as $tag) { + if ($tokens[$tag]['content'] === $tagName) { + $matchingTags[] = $tag; + } + } + + return $matchingTags; + } + + /** + * Whether this a valid tag. + * + * @param File $phpcsFile + * @param int $tagPtr + * @return bool + */ + public static function isValidTag( + File $phpcsFile, + int $tagPtr + ): bool { + $tokens = $phpcsFile->getTokens(); + $tag = ltrim($tokens[$tagPtr]['content'], '@'); + if (array_key_exists($tag, self::$validTags)) { + if (array_key_exists($tag, self::$pathRestrictedTags)) { + $file = MoodleUtil::getStandardisedFilename($phpcsFile); + foreach (self::$pathRestrictedTags[$tag] as $path) { + if (preg_match($path, $file)) { + return true; + } + } + return false; + } + return true; + } + + return false; + } + + /** + * Check if a tag is recommended. + * + * @param string $tagname + * @return bool + */ + public static function isRecommendedTag( + string $tagname + ): bool { + return array_key_exists($tagname, self::$validTags) && self::$validTags[$tagname]; + } + + /** + * Check if a tag should be removed. + * + * @param string $tagname + * @return bool + */ + public static function shouldRemoveTag( + string $tagname + ): bool { + return in_array($tagname, self::$invalidTagsToRemove); + } + + /** + * Get the tag name to rename to. + * + * @param string $tagname + * @return string|null + */ + public static function getRenameTag( + string $tagname + ): ?string { + if (array_key_exists($tagname, self::$renameTags)) { + return self::$renameTags[$tagname]; + } + return null; + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Util/MoodleUtil.php b/vendor/moodlehq/moodle-cs/moodle/Util/MoodleUtil.php index 61a0daa2..4af84570 100644 --- a/vendor/moodlehq/moodle-cs/moodle/Util/MoodleUtil.php +++ b/vendor/moodlehq/moodle-cs/moodle/Util/MoodleUtil.php @@ -1,5 +1,6 @@ . +// along with Moodle. If not, see . namespace MoodleHQ\MoodleCS\moodle\Util; @@ -22,17 +23,14 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Ruleset; -// phpcs:disable moodle.NamingConventions - /** * Various utility methods specific to Moodle stuff. * - * @package local_codechecker - * @copyright 2021 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2021 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -abstract class MoodleUtil { - +abstract class MoodleUtil +{ /** * @var string Absolute path, cached, containing moodle root detected directory. */ @@ -51,12 +49,18 @@ abstract class MoodleUtil { /** @var array A list of mocked component mappings for use in unit tests */ protected static $mockedComponentMappings = []; + /** @var array A cached list of APIs */ + protected static $apis = []; + + /** @var array A list of mocked API mappings for use in unit tests */ + protected static $mockedApisList = []; + /** * Mock component mappings for unit tests. * * @param array $mappings List of file path => component mappings * - * @throws Exception + * @throws \Exception */ public static function setMockedComponentMappings(array $mappings): void { if (!defined('PHPUNIT_TEST') || !PHPUNIT_TEST) { @@ -66,6 +70,20 @@ public static function setMockedComponentMappings(array $mappings): void { self::$mockedComponentMappings = $mappings; } + /** + * Mock API mappings for unit tests. + * + * @param array $mappings + * @throws \Exception + */ + public static function setMockedApiMappings(array $mappings): void { + if (!defined('PHPUNIT_TEST') || !PHPUNIT_TEST) { + throw new \Exception('Not running in a unit test'); // @codeCoverageIgnore + } + + self::$mockedApisList = $mappings; + } + /** * Load moodle core_component without needing an installed site. * @@ -102,7 +120,7 @@ protected static function loadCoreComponent(string $moodleRoot): bool { * @param string $moodleRoot Full path to a valid moodle.root * @return array Associative array of components as keys and paths as values or null if not found. */ - protected static function calculateAllComponents(string $moodleRoot) { + protected static function calculateAllComponents(string $moodleRoot): ?array { // If we have calculated the components already, straight return them. if (!empty(self::$moodleComponents)) { return self::$moodleComponents; @@ -119,7 +137,9 @@ protected static function calculateAllComponents(string $moodleRoot) { if ($componentsFile = Config::getConfigData('moodleComponentsListPath')) { if (!is_readable($componentsFile)) { throw new DeepExitException( - "ERROR: Incorrect 'moodleComponentsListPath' config/runtime option. File not found: '$componentsFile'", 3); + "ERROR: Incorrect 'moodleComponentsListPath' config/runtime option. File not found: '$componentsFile'", + 3 + ); } // Go processing the file. $handle = fopen($componentsFile, "r"); @@ -205,7 +225,7 @@ protected static function calculateAllComponents(string $moodleRoot) { * * @return string|null a valid moodle component for the file or null if not found. */ - public static function getMoodleComponent(File $file, $selfPath = true) { + public static function getMoodleComponent(File $file, $selfPath = true): ?string { if (defined('PHPUNIT_TEST') && PHPUNIT_TEST && !empty(self::$mockedComponentMappings)) { $components = self::$mockedComponentMappings; // @codeCoverageIgnore } else { @@ -222,14 +242,17 @@ public static function getMoodleComponent(File $file, $selfPath = true) { } } + $filepath = MoodleUtil::getStandardisedFilename($file); // Let's find the first component that matches the file path. foreach ($components as $component => $componentPath) { // Only components with path. if (empty($componentPath)) { continue; } + // Look for component paths matching the file path. - if (strpos($file->path, $componentPath . '/') === 0) { + $componentPath = str_replace('\\', '/', $componentPath . DIRECTORY_SEPARATOR); + if (strpos($filepath, $componentPath) === 0) { // First match found should be the better one always. We are done. return $component; } @@ -239,6 +262,50 @@ public static function getMoodleComponent(File $file, $selfPath = true) { return null; } + /** + * Get the list of Moodle APIs. + * + * @param File $file + * @param bool $selfPath + * @return null|array + */ + public static function getMoodleApis(File $file, bool $selfPath = true): ?array { + if (defined('PHPUNIT_TEST') && PHPUNIT_TEST && !empty(self::$mockedApisList)) { + return array_keys(self::$mockedApisList); // @codeCoverageIgnore + } + + if (empty(self::$apis)) { + // Verify that we are able to find a valid moodle root. + if ($moodleRoot = self::getMoodleRoot($file, $selfPath)) { + // APIs are located in lib/apis.json. + $apisFile = $moodleRoot . '/lib/apis.json'; + + if (is_readable($apisFile)) { + $data = json_decode(file_get_contents($apisFile), true); + if (json_last_error() === JSON_ERROR_NONE) { + self::$apis = $data; + } + } + } + + if (empty(self::$apis)) { + // If there is no apis.json file, we can't load the current APIs. + // Load the version from the release of 4.2 when the file was introduced. + // TODO Remove after min requirement is >= Moodle 4.2 #115. + $apisFile = __DIR__ . '/apis.json'; + + $data = json_decode(file_get_contents($apisFile), true); + if (json_last_error() !== JSON_ERROR_NONE) { + return null; // @codeCoverageIgnore + } + + self::$apis = $data; + } + } + + return array_keys(self::$apis); + } + /** * Try to guess moodle branch (numeric) * @@ -252,7 +319,7 @@ public static function getMoodleComponent(File $file, $selfPath = true) { * * @return int|null the numeric branch in moodle root version.php or null if not found */ - public static function getMoodleBranch(File $file = null, bool $selfPath = true) { + public static function getMoodleBranch(?File $file = null, bool $selfPath = true): ?int { // Return already calculated value if available. if (self::$moodleBranch !== false) { @@ -264,13 +331,17 @@ public static function getMoodleBranch(File $file = null, bool $selfPath = true) // Verify it's integer value and <= 9999 (4 digits max). if (filter_var($branch, FILTER_VALIDATE_INT) === false) { throw new DeepExitException( - "ERROR: Incorrect 'moodleBranch' config/runtime option. Value in not an integer: '$branch'", 3); + "ERROR: Incorrect 'moodleBranch' config/runtime option. Value in not an integer: '$branch'", + 3 + ); } if ($branch > 9999) { throw new DeepExitException( - "ERROR: Incorrect 'moodleBranch' config/runtime option. Value must be 4 digit max.: '$branch'", 3); + "ERROR: Incorrect 'moodleBranch' config/runtime option. Value must be 4 digit max.: '$branch'", + 3 + ); } - self::$moodleBranch = (int)$branch; + self::$moodleBranch = $branch; return self::$moodleBranch; } @@ -288,7 +359,7 @@ public static function getMoodleBranch(File $file = null, bool $selfPath = true) // Find the $branch value. if ($valueToken = $versionFile->findNext(T_CONSTANT_ENCAPSED_STRING, $varToken)) { $branch = trim($versionFile->getTokens()[$valueToken]['content'], "\"'"); - self::$moodleBranch = (int)$branch; + self::$moodleBranch = $branch; return self::$moodleBranch; } } @@ -313,7 +384,7 @@ public static function getMoodleBranch(File $file = null, bool $selfPath = true) * * @return string|null the full path to moodle root or null if not found. */ - public static function getMoodleRoot(File $file = null, bool $selfPath = true) { + public static function getMoodleRoot(?File $file = null, bool $selfPath = true): ?string { // Return already calculated value if available. if (self::$moodleRoot !== false) { return self::$moodleRoot; @@ -324,12 +395,16 @@ public static function getMoodleRoot(File $file = null, bool $selfPath = true) { // Verify the path is exists and is readable. if (!is_dir($path) || !is_readable($path)) { throw new DeepExitException( - "ERROR: Incorrect 'moodleRoot' config/runtime option. Directory does not exist or is not readable: '$path'", 3); + "ERROR: Incorrect 'moodleRoot' config/runtime option. Directory does not exist or is not readable: '$path'", + 3 + ); } // Verify the path has version.php and config-dist.php files. Very basic, but effective check. if (!is_readable($path . '/version.php') || !is_readable($path . '/config-dist.php')) { throw new DeepExitException( - "ERROR: Incorrect 'moodleRoot' config/runtime option. Directory is not a valid moodle root: '$path'", 3); + "ERROR: Incorrect 'moodleRoot' config/runtime option. Directory is not a valid moodle root: '$path'", + 3 + ); } self::$moodleRoot = $path; return self::$moodleRoot; @@ -370,6 +445,29 @@ public static function getMoodleRoot(File $file = null, bool $selfPath = true) { return self::$moodleRoot; } + /** + * Whether this file is a lang file. + * + * @param File $phpcsFile + * @return bool + */ + public static function isLangFile(File $phpcsFile): bool + { + $filename = MoodleUtil::getStandardisedFilename($phpcsFile); + // If the file is not under a /lang/[a-zA-Z0-9_-]+/ directory, nothing to check. + // (note that we are using that regex because it's what PARAM_LANG does). + if (preg_match('~/lang/[a-zA-Z0-9_-]+/~', $filename) === 0) { + return false; + } + + // If the file is not a PHP file, nothing to check. + if (substr($filename, -4) !== '.php') { + return false; + } + + return true; + } + /** * Whether this file is a unit test file. * @@ -377,33 +475,34 @@ public static function getMoodleRoot(File $file = null, bool $selfPath = true) { * * Any file which is not correctly named will be ignored. * - * @param File $phpcsFile - * @return bool + * @param File $phpcsFile + * @return bool */ public static function isUnitTest(File $phpcsFile): bool { + $filename = MoodleUtil::getStandardisedFilename($phpcsFile); // If the file isn't called, _test.php, nothing to check. if (stripos(basename($phpcsFile->getFilename()), '_test.php') === false) { return false; } // If the file isn't under tests directory, nothing to check. - if (stripos($phpcsFile->getFilename(), '/tests/') === false) { + if (stripos($filename, '/tests/') === false) { return false; } // If the file is in a fixture directory, ignore it. - if (stripos($phpcsFile->getFilename(), '/tests/fixtures/') !== false) { + if (stripos($filename, '/tests/fixtures/') !== false) { return false; } // If the file is in a generator directory, ignore it. - if (stripos($phpcsFile->getFilename(), '/tests/generator/') !== false) { + if (stripos($filename, '/tests/generator/') !== false) { return false; } // If the file is in a behat directory, ignore it. - if (stripos($phpcsFile->getFilename(), '/tests/behat/') !== false) { + if (stripos($filename, '/tests/behat/') !== false) { return false; } @@ -463,8 +562,7 @@ public static function isUnitTestCaseClass( public static function meetsMinimumMoodleVersion( File $phpcsFile, int $version - ): ?bool - { + ): ?bool { $moodleBranch = self::getMoodleBranch($phpcsFile); if (!isset($moodleBranch)) { // We cannot determine the moodle branch, so we cannot determine if the version is met. @@ -486,8 +584,7 @@ public static function findClassMethodPointer( File $phpcsFile, int $classPtr, string $methodName - ): ?int - { + ): ?int { $mStart = $classPtr; $tokens = $phpcsFile->getTokens(); while ($mStart = $phpcsFile->findNext(T_FUNCTION, $mStart + 1, $tokens[$classPtr]['scope_closer'])) { @@ -499,4 +596,32 @@ public static function findClassMethodPointer( return null; } + + /** + * Get all tokens relating to a particular line. + * + * @param File $phpcsFile + * @param int $line + * @return array + */ + public static function getTokensOnLine( + File $phpcsFile, + int $line + ): array { + return array_filter( + $phpcsFile->getTokens(), + fn($token) => $token['line'] === $line, + ARRAY_FILTER_USE_BOTH + ); + } + + /** + * Get the standardised filename for the file. + * + * @param File @phpcsFile + * @return string + */ + public static function getStandardisedFilename(File $phpcsFile): string { + return str_replace('\\', '/', $phpcsFile->getFilename()); + } } diff --git a/vendor/moodlehq/moodle-cs/moodle/Util/TokenUtil.php b/vendor/moodlehq/moodle-cs/moodle/Util/TokenUtil.php new file mode 100644 index 00000000..21208b01 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Util/TokenUtil.php @@ -0,0 +1,107 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Util; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Util\Tokens; +use PHPCSUtils\Utils\ObjectDeclarations; + +class TokenUtil +{ + /** + * Get the human-readable object type. + * + * @param File $phpcsFile + * @param int $stackPtr + * @return string + */ + public static function getObjectType( + File $phpcsFile, + int $stackPtr + ): string { + $tokens = $phpcsFile->getTokens(); + + if (!isset($tokens[$stackPtr])) { + return ''; + } + + if ($tokens[$stackPtr]['code'] === T_OPEN_TAG) { + return 'file'; + } + return $tokens[$stackPtr]['content']; + } + + /** + * Get the human readable object name. + * + * @param File $phpcsFile + * @param int $stackPtr + * @return null|string + */ + public static function getObjectName( + File $phpcsFile, + int $stackPtr + ): ?string { + $tokens = $phpcsFile->getTokens(); + if (!isset($tokens[$stackPtr])) { + return ''; + } + + if ($tokens[$stackPtr]['code'] === T_OPEN_TAG) { + return basename($phpcsFile->getFilename()); + } + + if ($tokens[$stackPtr]['code'] === T_ANON_CLASS) { + return 'anonymous class'; + } + + if ($tokens[$stackPtr]['code'] === T_CLOSURE) { + return 'closure'; + } + + return ObjectDeclarations::getName($phpcsFile, $stackPtr); + } + + /** + * Count the number of global scopes in a file. + * + * @param File $phpcsFile + * @return int + */ + public static function countGlobalScopesInFile( + File $phpcsFile + ): int { + $tokens = $phpcsFile->getTokens(); + $artifactCount = 0; + $find = Tokens::$ooScopeTokens; + $find[] = T_FUNCTION; + + $typePtr = 0; + while ($typePtr = $phpcsFile->findNext($find, $typePtr + 1)) { + $token = $tokens[$typePtr]; + if ($token['code'] === T_FUNCTION && !empty($token['conditions'])) { + // Skip methods of classes, traits and interfaces. + continue; + } + + $artifactCount++; + } + + return $artifactCount; + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Util/TypeUtil.php b/vendor/moodlehq/moodle-cs/moodle/Util/TypeUtil.php new file mode 100644 index 00000000..f0a602f9 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Util/TypeUtil.php @@ -0,0 +1,164 @@ +. + +namespace MoodleHQ\MoodleCS\moodle\Util; + +use PHP_CodeSniffer\Files\File; + +/** + * Utility class for handling types. + * + * @copyright Andrew Lyons + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class TypeUtil +{ + /** + * An array of variable types for param/var we will check. + * + * @var string[] + */ + protected static array $allowedTypes = [ + 'array', + 'bool', + 'false', + 'float', + 'int', + 'mixed', + 'null', + 'object', + 'string', + 'true', + 'resource', + 'callable', + ]; + + /** + * Standardise a type to a known type. + * + * @param string $type The type to standardise. + * @return string|null + */ + public static function standardiseType(string $type): ?string { + $type = strtolower($type); + if (in_array($type, self::$allowedTypes, true)) { + return $type; + } + + switch ($type) { + case 'array()': + return 'array'; + case 'boolean': + return 'bool'; + case 'double': + case 'real': + return 'float'; + case 'integer': + return 'int'; + default: + return null; + } + } + + + /** + * Returns a valid variable type for param/var tags. + * + * If type is not one of the standard types, it must be a custom type. + * Returns the correct type name suggestion if type name is invalid. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the stack passed in $tokens. + * @param string $varType The variable type to process. + * @return string + */ + public static function suggestType( + File $phpcsFile, + int $stackPtr, + string $varType + ): string { + $lowerVarType = strtolower($varType); + if ($normalisedType = self::standardiseType($lowerVarType)) { + return $normalisedType; + } + if (substr($varType, -2) === '[]') { + return sprintf( + '%s[]', + self::suggestType($phpcsFile, $stackPtr, substr($varType, 0, -2)) + ); + } + + if (strpos($lowerVarType, 'array(') !== false) { + // Valid array declaration: + // array, array(type), array(type1 => type2). + $matches = []; + $pattern = '/^array\(\s*([^\s^=^>]*)(\s*=>\s*(.*))?\s*\)/i'; + if (preg_match($pattern, $varType, $matches) !== 0) { + $type1 = ''; + if (isset($matches[1]) === true) { + $type1 = $matches[1]; + } + + $type2 = ''; + if (isset($matches[3]) === true) { + $type2 = $matches[3]; + } + + $type1 = self::suggestType($phpcsFile, $stackPtr, $type1); + $type2 = self::suggestType($phpcsFile, $stackPtr, $type2); + + // Note: The phpdoc array syntax only allows you to describe the array value type. + // https://docs.phpdoc.org/latest/guide/guides/types.html#arrays + if ($type1 && !$type2) { + // This is an array of [type2, type2, type2]. + return "{$type1}[]"; + } + // This is an array of [type1 => type2, type1 => type2, type1 => type2]. + return "{$type2}[]"; + } else { + return 'array'; + } + } + + // Must be a custom type name. + return $varType; + } + + /** + * Validate a type in its entirety. + * + * The method currently supports built-in types, and Union types. + * It does not currently support DNF, or other complex types. + * + * @param File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the stack passed in $tokens. + * @param string $type The type to validate. + * @return string The validated type. + */ + public static function getValidatedType( + File $phpcsFile, + int $stackPtr, + string $type + ): string { + $types = explode('|', $type); + $validatedTypes = []; + foreach ($types as $type) { + $validatedTypes[] = self::suggestType($phpcsFile, $stackPtr, $type); + } + return implode('|', $validatedTypes); + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/Util/apis.json b/vendor/moodlehq/moodle-cs/moodle/Util/apis.json new file mode 100644 index 00000000..8d91b221 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/moodle/Util/apis.json @@ -0,0 +1,272 @@ +{ + "access": { + "component": "core_access", + "allowedlevel2": true, + "allowedspread": false + }, + "admin": { + "component": "core_admin", + "allowedlevel2": false, + "allowedspread": false + }, + "adminpresets": { + "component": "core_adminpresets", + "allowedlevel2": true, + "allowedspread": false + }, + "analytics": { + "component": "core_analytics", + "allowedlevel2": true, + "allowedspread": true + }, + "availability": { + "component": "core_availability", + "allowedlevel2": false, + "allowedspread": false + }, + "backup": { + "component": "core_backup", + "allowedlevel2": true, + "allowedspread": true + }, + "badges": { + "component": "core_badges", + "allowedlevel2": false, + "allowedspread": false + }, + "cache": { + "component": "core_cache", + "allowedlevel2": true, + "allowedspread": true + }, + "calendar": { + "component": "core_calendar", + "allowedlevel2": false, + "allowedspread": false + }, + "check": { + "component": "core", + "allowedlevel2": true, + "allowedspread": true + }, + "comment": { + "component": "core_comment", + "allowedlevel2": false, + "allowedspread": false + }, + "competency": { + "component": "core_competency", + "allowedlevel2": false, + "allowedspread": false + }, + "completion": { + "component": "core_completion", + "allowedlevel2": true, + "allowedspread": true + }, + "context": { + "component": "core", + "allowedlevel2": true, + "allowedspread": false + }, + "core": { + "component": null, + "allowedlevel2": false, + "allowedspread": false + }, + "customfield": { + "component": "core_customfield", + "allowedlevel2": true, + "allowedspread": true + }, + "ddl": { + "component": "core", + "allowedlevel2": true, + "allowedspread": false + }, + "dml": { + "component": "core", + "allowedlevel2": true, + "allowedspread": false + }, + "enrol": { + "component": "core_enrol", + "allowedlevel2": false, + "allowedspread": false + }, + "event": { + "component": "core", + "allowedlevel2": true, + "allowedspread": true + }, + "external": { + "component": "core", + "allowedlevel2": true, + "allowedspread": true + }, + "files": { + "component": "core_files", + "allowedlevel2": true, + "allowedspread": false + }, + "form": { + "component": "core_form", + "allowedlevel2": true, + "allowedspread": true + }, + "grade": { + "component": "core_grades", + "allowedlevel2": false, + "allowedspread": false + }, + "grading": { + "component": "core_grading", + "allowedlevel2": false, + "allowedspread": false + }, + "group": { + "component": "core_group", + "allowedlevel2": false, + "allowedspread": false + }, + "h5p": { + "component": "core_h5p", + "allowedlevel2": true, + "allowedspread": true + }, + "lock": { + "component": "core", + "allowedlevel2": true, + "allowedspread": false + }, + "log": { + "component": "core", + "allowedlevel2": true, + "allowedspread": true + }, + "media": { + "component": "core_media", + "allowedlevel2": false, + "allowedspread": false + }, + "message": { + "component": "core_message", + "allowedlevel2": true, + "allowedspread": true + }, + "moodlenet": { + "component": "core", + "allowedlevel2": false, + "allowedspread": false + }, + "navigation": { + "component": "core", + "allowedlevel2": true, + "allowedspread": true + }, + "oauth2": { + "component": "core", + "allowedlevel2": true, + "allowedspread": true + }, + "output": { + "component": "core", + "allowedlevel2": true, + "allowedspread": true + }, + "page": { + "component": "core", + "allowedlevel2": false, + "allowedspread": false + }, + "payment": { + "component": "core_payment", + "allowedlevel2": true, + "allowedspread": true + }, + "plagiarism": { + "component": "core_plagiarism", + "allowedlevel2": false, + "allowedspread": false + }, + "portfolio": { + "component": "core_portfolio", + "allowedlevel2": false, + "allowedspread": false + }, + "preference": { + "component": "core", + "allowedlevel2": false, + "allowedspread": false + }, + "privacy": { + "component": "core_privacy", + "allowedlevel2": true, + "allowedspread": true + }, + "question": { + "component": "core_question", + "allowedlevel2": true, + "allowedspread": true + }, + "rating": { + "component": "core_rating", + "allowedlevel2": false, + "allowedspread": false + }, + "reportbuilder": { + "component": "core_reportbuilder", + "allowedlevel2": true, + "allowedspread": true + }, + "rss": { + "component": "core_rss", + "allowedlevel2": false, + "allowedspread": false + }, + "search": { + "component": "core_search", + "allowedlevel2": true, + "allowedspread": true + }, + "string": { + "component": "core", + "allowedlevel2": false, + "allowedspread": false + }, + "tag": { + "component": "core_tag", + "allowedlevel2": false, + "allowedspread": false + }, + "task": { + "component": "core", + "allowedlevel2": true, + "allowedspread": true + }, + "test": { + "component": "core", + "allowedlevel2": false, + "allowedspread": false + }, + "time": { + "component": "core", + "allowedlevel2": false, + "allowedspread": false + }, + "upgrade": { + "component": "core", + "allowedlevel2": true, + "allowedspread": false + }, + "webservice": { + "component": "core_webservice", + "allowedlevel2": false, + "allowedspread": false + }, + "xapi": { + "component": "core_xapi", + "allowedlevel2": true, + "allowedspread": true + } +} diff --git a/vendor/moodlehq/moodle-cs/moodle/ruleset.xml b/vendor/moodlehq/moodle-cs/moodle/ruleset.xml index 8098255c..c378a3dd 100644 --- a/vendor/moodlehq/moodle-cs/moodle/ruleset.xml +++ b/vendor/moodlehq/moodle-cs/moodle/ruleset.xml @@ -112,6 +112,10 @@ --> + + + + diff --git a/vendor/moodlehq/moodle-cs/phpcs.xml.dist b/vendor/moodlehq/moodle-cs/phpcs.xml.dist new file mode 100644 index 00000000..2eea4269 --- /dev/null +++ b/vendor/moodlehq/moodle-cs/phpcs.xml.dist @@ -0,0 +1,46 @@ + + + The coding rules configuration for the moodle-cs project. + + + */vendor/* + */Tests/fixtures/* + */Tests/*/fixtures/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/phpcompatibility/php-compatibility/CHANGELOG.md b/vendor/phpcompatibility/php-compatibility/CHANGELOG.md index b92ae254..8039e536 100644 --- a/vendor/phpcompatibility/php-compatibility/CHANGELOG.md +++ b/vendor/phpcompatibility/php-compatibility/CHANGELOG.md @@ -294,7 +294,7 @@ Also as of this version, [Juliette Reinders Folmer] is now officially a co-maint ### Upgrade instructions * If you have `` directives in your own project's custom ruleset which relate to sniffs from the PHPCompatibility library, you will need to update your ruleset to use the new sniff names. -* If you use the new [PHPCS 3.2+ inline annotations](https://github.com/squizlabs/PHP_CodeSniffer/releases/3.2.0), i.e. `// phpcs:ignore Standard.Category.SniffName`, in combination with PHPCompatibility sniff names, you will need to update these annotations. +* If you use the new [PHPCS 3.2+ inline annotations](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/3.2.0), i.e. `// phpcs:ignore Standard.Category.SniffName`, in combination with PHPCompatibility sniff names, you will need to update these annotations. * If you use neither of the above, you should be fine and upgrading should be painless. ### Overview of all the sniff renames: diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractFunctionCallParameterSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractFunctionCallParameterSniff.php index 83321c2d..06aa2269 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractFunctionCallParameterSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/AbstractFunctionCallParameterSniff.php @@ -120,7 +120,7 @@ public function process(File $phpcsFile, $stackPtr) if (Context::inAttribute($phpcsFile, $stackPtr) === true) { // Class instantiation or constant in attribute, not function call. - return false; + return; } $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/ParameterValues/RemovedLdapConnectSignaturesStandard.xml b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/ParameterValues/RemovedLdapConnectSignaturesStandard.xml index 62a1cc9e..84f36e25 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/ParameterValues/RemovedLdapConnectSignaturesStandard.xml +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Docs/ParameterValues/RemovedLdapConnectSignaturesStandard.xml @@ -8,7 +8,7 @@ Calling ldap_connect() with its two-parameter signature is deprecated since PHP 8.3 and support will be removed in PHP 9.0. Call ldap_connect() with an LDAP-URI as the first (and only) parameter instead. - Or in case the underlying library is Oracle and one wants to add wallet-details, pass an LDAP-URI as the $uri parameter and pass `null` as the $port parameter. + Or in case the underlying library is Oracle and one wants to add wallet-details, pass an LDAP-URI as the $uri parameter and pass `null` as the $port parameter (PHP < 8.4). ]]> @@ -24,7 +24,7 @@ ldap_connect($host, $port); - + "ldap://$host:$port??369", @@ -43,6 +43,47 @@ ldap_connect( $wallet, $password, $auth_mode, +); + ]]> + + + + + + + + ldap_connect_wallet( + "ldap://$host:$port??369", + $wallet, + $password, + $auth_mode, + ); +} else { + ldap_connect( + "ldap://$host:$port??369", + null, + $wallet, + $password, + $auth_mode, + ); +} + ]]> + + + ldap_connect( + $host, + 369, + $wallet, + $password, + $auth_mode, ); ]]> diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewConstantsSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewConstantsSniff.php index 8c005a9a..57d18c43 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewConstantsSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/NewConstantsSniff.php @@ -32,7 +32,7 @@ class NewConstantsSniff extends Sniff * A list of new PHP Constants, not present in older versions. * * The array lists : version number with false (not present) or true (present). - * If's sufficient to list the first version where the constant appears. + * It's sufficient to list the first version where the constant appears. * * Note: PHP constants are case-sensitive! * @@ -6802,6 +6802,7 @@ class NewConstantsSniff extends Sniff '7.3' => false, '7.4' => true, ], + // Note: this constant has special casing in the handleFeature() method as it was also present in PHP < 7.0. 'T_BAD_CHARACTER' => [ '7.3' => false, '7.4' => true, @@ -7826,26 +7827,6 @@ class NewConstantsSniff extends Sniff '8.3' => true, 'extension' => 'pgsql', ], - 'PGSQL_PIPELINE_SYNC' => [ - '8.2' => false, - '8.3' => true, - 'extension' => 'pgsql', - ], - 'PGSQL_PIPELINE_ON' => [ - '8.2' => false, - '8.3' => true, - 'extension' => 'pgsql', - ], - 'PGSQL_PIPELINE_OFF' => [ - '8.2' => false, - '8.3' => true, - 'extension' => 'pgsql', - ], - 'PGSQL_PIPELINE_ABORTED' => [ - '8.2' => false, - '8.3' => true, - 'extension' => 'pgsql', - ], 'PGSQL_SHOW_CONTEXT_NEVER' => [ '8.2' => false, '8.3' => true, @@ -8111,6 +8092,19 @@ protected function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo) return; } + if ($itemInfo['name'] === 'T_BAD_CHARACTER') { + // T_BAD_CHARACTER is a special case. It was removed in 7.0.0 and re-added in 7.4.0 + // See also PHPCompatibility.Constants.RemovedConstants + if (ScannedCode::shouldRunOnOrAbove('7.0')) { + $message = 'The constant "T_BAD_CHARACTER" is not present in PHP versions 7.0 through 7.3'; + $msgInfo = $this->getMessageInfo($itemInfo['name'], $itemInfo['name'], $versionInfo); + + $phpcsFile->addError($message, $stackPtr, $msgInfo['errorcode'], $msgInfo['data']); + } + + return; + } + $this->addError($phpcsFile, $stackPtr, $itemInfo, $versionInfo); } diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/RemovedConstantsSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/RemovedConstantsSniff.php index 13659b05..004a0674 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/RemovedConstantsSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Constants/RemovedConstantsSniff.php @@ -33,7 +33,7 @@ class RemovedConstantsSniff extends Sniff * A list of removed PHP Constants. * * The array lists : version number with false (deprecated) or true (removed). - * If's sufficient to list the first version where the constant was deprecated/removed. + * It's sufficient to list the first version where the constant was deprecated/removed. * * Optional, the array can contain an `alternative` key listing an alternative constant * to be used instead. @@ -1932,6 +1932,7 @@ class RemovedConstantsSniff extends Sniff '7.0' => true, 'extension' => 'tokenizer', ], + // Note: this constant has special casing in the handleFeature() method as it is also present in PHP >= 7.4. 'T_BAD_CHARACTER' => [ '7.0' => true, 'extension' => 'tokenizer', @@ -2735,6 +2736,19 @@ protected function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo) return; } + if ($itemInfo['name'] === 'T_BAD_CHARACTER') { + // T_BAD_CHARACTER is a special case. It was removed in 7.0.0 and re-added in 7.4.0 + // See also PHPCompatibility.Constants.NewConstants + if (ScannedCode::shouldRunOnOrBelow('7.3')) { + $message = 'The constant "T_BAD_CHARACTER" is not present in PHP versions 7.0 through 7.3'; + $msgInfo = $this->getMessageInfo($itemInfo['name'], $itemInfo['name'], $versionInfo); + + $phpcsFile->addError($message, $stackPtr, $msgInfo['errorcode'], $msgInfo['data']); + } + + return; + } + $this->addMessage($phpcsFile, $stackPtr, $isError, $itemInfo, $versionInfo); } diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/NewFunctionsSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/NewFunctionsSniff.php index 116215aa..400508bf 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/NewFunctionsSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/NewFunctionsSniff.php @@ -4943,26 +4943,6 @@ class NewFunctionsSniff extends Sniff '8.3' => true, 'extension' => 'pgsql', ], - 'pg_enter_pipeline_mode' => [ - '8.2' => false, - '8.3' => true, - 'extension' => 'pgsql', - ], - 'pg_exit_pipeline_mode' => [ - '8.2' => false, - '8.3' => true, - 'extension' => 'pgsql', - ], - 'pg_pipeline_sync' => [ - '8.2' => false, - '8.3' => true, - 'extension' => 'pgsql', - ], - 'pg_pipeline_status' => [ - '8.2' => false, - '8.3' => true, - 'extension' => 'pgsql', - ], 'posix_sysconf' => [ '8.2' => false, '8.3' => true, diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/OptionalToRequiredFunctionParametersSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/OptionalToRequiredFunctionParametersSniff.php index 610a68f3..78016abc 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/OptionalToRequiredFunctionParametersSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/OptionalToRequiredFunctionParametersSniff.php @@ -96,6 +96,16 @@ class OptionalToRequiredFunctionParametersSniff extends AbstractFunctionCallPara '8.0' => true, ], ], + 'stream_context_set_option' => [ + 3 => [ + 'name' => 'option_name', + '8.4' => false, + ], + 4 => [ + 'name' => 'value', + '8.4' => false, + ], + ], ]; diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionParametersSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionParametersSniff.php index 7dd228dc..23056bc8 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionParametersSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionParametersSniff.php @@ -111,6 +111,18 @@ class RemovedFunctionParametersSniff extends AbstractFunctionCallParameterSniff '8.0' => true, ], ], + 'ldap_exop' => [ + 5 => [ + 'name' => 'response_data', + '8.4' => false, + 'alternative' => 'the PHP 8.3+ ldap_exop_sync() function', + ], + 6 => [ + 'name' => 'response_oid', + '8.4' => false, + 'alternative' => 'the PHP 8.3+ ldap_exop_sync() function', + ], + ], 'ldap_first_attribute' => [ 3 => [ 'name' => 'ber_identifier', @@ -169,6 +181,43 @@ class RemovedFunctionParametersSniff extends AbstractFunctionCallParameterSniff '8.0' => true, ], ], + 'session_set_save_handler' => [ + 3 => [ + 'name' => 'read', + '8.4' => false, + 'alternative' => 'a SessionHandlerInterface implementation for the callbacks instead', + ], + 4 => [ + 'name' => 'write', + '8.4' => false, + 'alternative' => 'a SessionHandlerInterface implementation for the callbacks instead', + ], + 5 => [ + 'name' => 'destroy', + '8.4' => false, + 'alternative' => 'a SessionHandlerInterface implementation for the callbacks instead', + ], + 6 => [ + 'name' => 'gc', + '8.4' => false, + 'alternative' => 'a SessionHandlerInterface implementation for the callbacks instead', + ], + 7 => [ + 'name' => 'create_sid', + '8.4' => false, + 'alternative' => 'a SessionHandlerInterface implementation for the callbacks instead', + ], + 8 => [ + 'name' => 'validate_sid', + '8.4' => false, + 'alternative' => 'a SessionHandlerInterface implementation for the callbacks instead', + ], + 9 => [ + 'name' => 'update_timestamp', + '8.4' => false, + 'alternative' => 'a SessionHandlerInterface implementation for the callbacks instead', + ], + ], ]; /** diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionsSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionsSniff.php index 6c724f3f..cff9f3d7 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionsSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/FunctionUse/RemovedFunctionsSniff.php @@ -5074,6 +5074,17 @@ class RemovedFunctionsSniff extends Sniff 'assert_options' => [ '8.3' => false, ], + + 'intlcal_set' => [ + '8.4' => false, + 'alternative' => 'IntlCalendar::setDate() or IntlCalendar::setDateTime()', + 'extension' => 'intl', + ], + 'intlgregcal_create_instance' => [ + '8.4' => false, + 'alternative' => 'IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime()', + 'extension' => 'intl', + ], ]; diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/RemovedLdapConnectSignaturesSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/RemovedLdapConnectSignaturesSniff.php index d6b244a4..1a7185a8 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/RemovedLdapConnectSignaturesSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ParameterValues/RemovedLdapConnectSignaturesSniff.php @@ -25,7 +25,11 @@ * * The two parameter - $host, $port - signature is deprecated since PHP 8.3 and support will be removed in PHP 9.0. * + * The three+ parameter - $uri, $port, $wallet, $password, $auth_mode - signature is deprecated since PHP 8.4 + * and support will be removed in PHP 9.0. + * * PHP version 8.3 + * PHP version 8.4 * PHP version 9.0 * * {@internal Normally this would be handled via the RemovedFunctionParameters sniff, but this @@ -35,6 +39,7 @@ * For that reason, the RemovedFunctionParameters sniff is not suitable to handle this.} * * @link https://wiki.php.net/rfc/deprecations_php_8_3#deprecate_calling_ldap_connect_with_2_parameters + * @link https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#ldap_connect * @link https://www.php.net/ldap_connect * * @since 10.0.0 @@ -80,6 +85,34 @@ protected function bowOutEarly() */ public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) { + if (ScannedCode::shouldRunOnOrAbove('8.4') === true) { + /* + * On PHP 8.4, the 3+ param signature is deprecated. + */ + $walletParam = PassedParameters::getParameterFromStack($parameters, 3, 'wallet'); + $passwordParam = PassedParameters::getParameterFromStack($parameters, 4, 'password'); + $authmodeParam = PassedParameters::getParameterFromStack($parameters, 5, 'auth_mode'); + + if ($walletParam !== false || $passwordParam !== false || $authmodeParam !== false) { + // Found a 3+ param signature. + $phpcsFile->addWarning( + 'Calling ldap_connect() with three or more parameters is deprecated since PHP 8.4. Use ldap_connect_wallet() (PHP 8.3+) instead.', + $stackPtr, + 'DeprecatedThreePlusParamSignature' + ); + + /* + * If this notice has been thrown, we shouldn't throw the PHP 8.3 related notice for 3+ param + * signatures as the "do this instead" advise conflicts. + */ + return; + } + } + + /* + * On PHP 8.3, the 2-param signature is deprecated, including passing a non-null $port value + * when using the 3+ param signature. + */ $uriParam = PassedParameters::getParameterFromStack($parameters, 1, ['uri', 'host']); $portParam = PassedParameters::getParameterFromStack($parameters, 2, 'port'); diff --git a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Variables/ForbiddenThisUseContextsSniff.php b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Variables/ForbiddenThisUseContextsSniff.php index 19758f49..85b0f0ee 100644 --- a/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Variables/ForbiddenThisUseContextsSniff.php +++ b/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/Variables/ForbiddenThisUseContextsSniff.php @@ -243,6 +243,12 @@ public function process(File $phpcsFile, $stackPtr) } for ($i = ($openParenthesis + 1); $i < $tokens[$openParenthesis]['parenthesis_closer']; $i++) { + // Ignore anything within square brackets (array access keys). + if (isset($tokens[$i]['bracket_closer'])) { + $i = $tokens[$i]['bracket_closer']; + continue; + } + if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$this') { continue; } diff --git a/vendor/phpcompatibility/php-compatibility/README.md b/vendor/phpcompatibility/php-compatibility/README.md index 6c62f005..db9be9b6 100644 --- a/vendor/phpcompatibility/php-compatibility/README.md +++ b/vendor/phpcompatibility/php-compatibility/README.md @@ -11,10 +11,10 @@ PHP Compatibility Coding Standard for PHP CodeSniffer [![Coverage Status](https://coveralls.io/repos/github/PHPCompatibility/PHPCompatibility/badge.svg?branch=develop)](https://coveralls.io/github/PHPCompatibility/PHPCompatibility?branch=develop) [![Minimum PHP Version](https://img.shields.io/packagist/php-v/phpcompatibility/php-compatibility.svg?maxAge=3600)](https://packagist.org/packages/phpcompatibility/php-compatibility) -[![Tested on PHP 5.4 to nightly](https://img.shields.io/badge/tested%20on-PHP%205.4%20|%205.5%20|%205.6%20|%207.0%20|%207.1%20|%207.2%20|%207.3%20|%207.4%20|%208.0%20|%20nightly%20-brightgreen.svg?maxAge=2419200)](https://github.com/PHPCompatibility/PHPCompatibility/actions?query=workflow%3ATest) +[![Tested on PHP 5.4 to nightly](https://img.shields.io/badge/tested%20on-PHP%205.4%20|%205.5%20|%205.6%20|%207.0%20|%207.1%20|%207.2%20|%207.3%20|%207.4%20|%208.0%20|%208.1%20|%208.2%20|%208.3%20|%20nightly%20-brightgreen.svg?maxAge=2419200)](https://github.com/PHPCompatibility/PHPCompatibility/actions?query=workflow%3ATest) -This is a set of sniffs for [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) that checks for PHP cross-version compatibility. +This is a set of sniffs for [PHP CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) that checks for PHP cross-version compatibility. It will allow you to analyse your code for compatibility with higher and lower versions of PHP. * [PHP Version Support](#php-version-support) @@ -43,13 +43,13 @@ Requirements ------- * PHP 5.4+ -* PHP CodeSniffer: 3.7.1+. +* PHP CodeSniffer: 3.8.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.7.1 has been dropped. +As of version 10.0.0, support for PHP < 5.4 and PHP CodeSniffer < 3.8.0 has been dropped. Thank you @@ -63,9 +63,9 @@ Thanks to [WP Engine](https://wpengine.com) for their support on the PHP 7.0 sni -------- This library has been reorganized. All sniffs have been placed in categories and a significant number of sniffs have been renamed. -If you use the complete `PHPCompatibility` standard without `exclude` directives in a custom ruleset and do not (yet) use the new-style PHP_CodeSniffer annotation as introduced in [PHP_CodeSniffer 3.2.0](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.2.0), this will have no noticeable effect and everything should work as before. +If you use the complete `PHPCompatibility` standard without `exclude` directives in a custom ruleset and do not (yet) use the new-style PHP_CodeSniffer annotation as introduced in [PHP_CodeSniffer 3.2.0](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.2.0), this will have no noticeable effect and everything should work as before. -However, if you do use `exclude` directives for PHPCompatibility sniffs in a custom ruleset or if you use the [new-style PHP_CodeSniffer inline annotations](https://github.com/squizlabs/PHP_CodeSniffer/releases/3.2.0), you will need to update these when upgrading. This should be a one-time only change. +However, if you do use `exclude` directives for PHPCompatibility sniffs in a custom ruleset or if you use the [new-style PHP_CodeSniffer inline annotations](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/3.2.0), you will need to update these when upgrading. This should be a one-time only change. The changelog contains detailed information about all the sniff renames. Please read the changelog for version [9.0.0](https://github.com/PHPCompatibility/PHPCompatibility/releases/tag/9.0.0) carefully before upgrading. @@ -110,7 +110,7 @@ Installation in a Composer project (method 1) Installation via a git check-out to an arbitrary directory (method 2) ----------------------- -* Install [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) via [your preferred method](https://github.com/squizlabs/PHP_CodeSniffer#installation). +* Install [PHP CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) via [your preferred method](https://github.com/PHPCSStandards/PHP_CodeSniffer#installation). PHP CodeSniffer offers a variety of installation methods to suit your work-flow: Composer, [PEAR](http://pear.php.net/PHP_CodeSniffer), a Phar file, zipped/tarred release archives or checking the repository out using Git. @@ -122,7 +122,7 @@ Installation via a git check-out to an arbitrary directory (method 2) ```bash phpcs --config-set installed_paths /path/to/PHPCompatibility ``` - I.e. if you placed the `PHPCompatibility` repository in the `/my/custom/standards/PHPCompatibility` directory, you will need to add that directory to the PHP CodeSniffer [`installed_paths` configuration variable](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-installed-standard-paths). + I.e. if you placed the `PHPCompatibility` repository in the `/my/custom/standards/PHPCompatibility` directory, you will need to add that directory to the PHP CodeSniffer [`installed_paths` configuration variable](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-installed-standard-paths). **Warning**: :warning: The `installed_paths` command overwrites any previously set `installed_paths`. If you have previously set `installed_paths` for other external standards, run `phpcs --config-show` first and then run the `installed_paths` command with all the paths you need separated by commas, i.e.: ```bash @@ -148,7 +148,7 @@ Sniffing your code for compatibility with specific PHP version(s) - You can also specify a range of PHP versions that your code needs to support. In this situation, compatibility issues that affect any of the PHP versions in that range will be reported: `--runtime-set testVersion 5.3-5.5`. - As of PHPCompatibility 7.1.3, you can omit one part of the range if you want to support everything above or below a particular version, i.e. use `--runtime-set testVersion 7.0-` to run all the checks for PHP 7.0 and above. * By default the report will be sent to the console, if you want to save the report to a file, add the following to the command line command: `--report-full=path/to/report-file`. - For more information and other reporting options, check the [PHP CodeSniffer wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Reporting). + For more information and other reporting options, check the [PHP CodeSniffer wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Reporting). ### Using a framework/CMS/polyfill specific ruleset @@ -191,7 +191,7 @@ You can also set the `testVersion` from within the ruleset: ``` -Other advanced options, such as changing the message type or severity of select sniffs, as described in the [PHPCS Annotated ruleset](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml) wiki page are, of course, also supported. +Other advanced options, such as changing the message type or severity of select sniffs, as described in the [PHPCS Annotated ruleset](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-ruleset.xml) wiki page are, of course, also supported. ### `testVersion` in the ruleset versus command-line diff --git a/vendor/phpcompatibility/php-compatibility/composer.json b/vendor/phpcompatibility/php-compatibility/composer.json index 0bb721ad..e1b705df 100644 --- a/vendor/phpcompatibility/php-compatibility/composer.json +++ b/vendor/phpcompatibility/php-compatibility/composer.json @@ -28,8 +28,8 @@ }, "require": { "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.7.1", - "phpcsstandards/phpcsutils": "^1.0.5" + "squizlabs/php_codesniffer": "^3.8.0", + "phpcsstandards/phpcsutils": "^1.0.9" }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.3.2", diff --git a/vendor/phpcsstandards/phpcsutils/CHANGELOG.md b/vendor/phpcsstandards/phpcsutils/CHANGELOG.md index cc5bb53d..12cfc3e2 100644 --- a/vendor/phpcsstandards/phpcsutils/CHANGELOG.md +++ b/vendor/phpcsstandards/phpcsutils/CHANGELOG.md @@ -9,6 +9,34 @@ This projects adheres to [Keep a CHANGELOG](https://keepachangelog.com/) and use _Nothing yet._ +## [1.0.10] - 2024-03-18 + +### Changed + +#### Other + +* Dropped support for [PHP_CodeSniffer] < 3.9.0. [#561] + Please ensure you run `composer update phpcsstandards/phpcsutils --with-dependencies` to benefit from this. +* Various housekeeping and documentation improvements. + +### Deprecated + +#### Utils + +* `NamingConventions::AZ_UPPER` constant. [#563] +* `NamingConventions::AZ_LOWER` constant. [#563] + +### Fixed + +#### PHPCS BackCompat + +* `BackCompat\Helper::getEncoding()`: PHP 8.4 deprecation notice. [#568] +* `BackCompat\Helper::ignoreAnnotations()`: PHP 8.4 deprecation notice. [#568] + +[#561]: https://github.com/PHPCSStandards/PHPCSUtils/pull/561 +[#563]: https://github.com/PHPCSStandards/PHPCSUtils/pull/563 +[#568]: https://github.com/PHPCSStandards/PHPCSUtils/pull/568 + ## [1.0.9] - 2023-12-08 @@ -956,6 +984,7 @@ This initial alpha release contains the following utility classes: [Unreleased]: https://github.com/PHPCSStandards/PHPCSUtils/compare/stable...HEAD +[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 [1.0.7]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.6...1.0.7 diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCFile.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCFile.php index af4ec95e..14c6adf6 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. - * - PHPCS 3.8.0: OO methods called `self`, `parent` or `static` are now correctly recognized. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::getDeclarationName() Original source. * @see \PHPCSUtils\Utils\ObjectDeclarations::getName() PHPCSUtils native improved version. @@ -98,44 +98,7 @@ final class BCFile */ public static function getDeclarationName(File $phpcsFile, $stackPtr) { - $tokens = $phpcsFile->getTokens(); - $tokenCode = $tokens[$stackPtr]['code']; - - if ($tokenCode === T_ANON_CLASS || $tokenCode === T_CLOSURE) { - return null; - } - - if ($tokenCode !== T_FUNCTION - && $tokenCode !== T_CLASS - && $tokenCode !== T_INTERFACE - && $tokenCode !== T_TRAIT - && $tokenCode !== T_ENUM - ) { - throw new RuntimeException('Token type "' . $tokens[$stackPtr]['type'] . '" is not T_FUNCTION, T_CLASS, T_INTERFACE, T_TRAIT or T_ENUM'); - } - - if ($tokenCode === T_FUNCTION - && strtolower($tokens[$stackPtr]['content']) !== 'function' - ) { - // This is a function declared without the "function" keyword. - // So this token is the function name. - return $tokens[$stackPtr]['content']; - } - - $content = null; - for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { - if ($tokens[$i]['code'] === T_STRING - // BC: PHPCS < 3.8.0. - || $tokens[$i]['code'] === T_SELF - || $tokens[$i]['code'] === T_PARENT - || $tokens[$i]['code'] === T_STATIC - ) { - $content = $tokens[$i]['content']; - break; - } - } - - return $content; + return $phpcsFile->getDeclarationName($stackPtr); } /** @@ -161,7 +124,7 @@ public static function getDeclarationName(File $phpcsFile, $stackPtr) * // or FALSE if there is no type hint. * 'type_hint_end_token' => integer|false, // The stack pointer to the end of the type hint * // or FALSE if there is no type hint. - * 'nullable_type' => boolean, // TRUE if the var type is preceded by the nullability + * 'nullable_type' => boolean, // TRUE if the param type is preceded by the nullability * // operator. * 'comma_token' => integer|false, // The stack pointer to the comma after the param * // or FALSE if this is the last param. @@ -178,9 +141,9 @@ public static function getDeclarationName(File $phpcsFile, $stackPtr) * Parameters declared using PHP 8 constructor property promotion, have these additional array indexes: * ```php * 'property_visibility' => string, // The property visibility as declared. - * 'visibility_token' => integer,|false // The stack pointer to the visibility modifier token. + * 'visibility_token' => integer|false, // The stack pointer to the visibility modifier token. * // or FALSE if the visibility is not explicitly declared. - * 'property_readonly' => bool, // TRUE if the readonly keyword was found. + * 'property_readonly' => boolean, // TRUE if the readonly keyword was found. * 'readonly_token' => integer, // The stack pointer to the readonly modifier token. * // This index will only be set if the property is readonly. * ``` @@ -499,7 +462,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.8.0. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::getMethodProperties() Original source. * @see \PHPCSUtils\Utils\FunctionDeclarations::getProperties() PHPCSUtils native improved version. @@ -544,7 +507,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.8.0. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::getMemberProperties() Original source. * @see \PHPCSUtils\Utils\Variables::getMemberProperties() PHPCSUtils native improved version. @@ -582,13 +545,12 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr) * * Changelog for the PHPCS native function: * - Introduced in PHPCS 1.3.0. - * - PHPCS 3.8.0: Added support for PHP 8.2 `readonly` classes. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::getClassProperties() Original source. * @see \PHPCSUtils\Utils\ObjectDeclarations::getClassProperties() PHPCSUtils native improved version. * * @since 1.0.0 - * @since 1.0.6 Sync with PHPCS 3.8.0, support for readonly classes. PHPCS#3686. * * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * @param int $stackPtr The position in the stack of the `T_CLASS` @@ -601,50 +563,7 @@ public static function getMemberProperties(File $phpcsFile, $stackPtr) */ public static function getClassProperties(File $phpcsFile, $stackPtr) { - $tokens = $phpcsFile->getTokens(); - - if ($tokens[$stackPtr]['code'] !== T_CLASS) { - throw new RuntimeException('$stackPtr must be of type T_CLASS'); - } - - $valid = [ - T_FINAL => T_FINAL, - T_ABSTRACT => T_ABSTRACT, - T_READONLY => T_READONLY, - T_WHITESPACE => T_WHITESPACE, - T_COMMENT => T_COMMENT, - T_DOC_COMMENT => T_DOC_COMMENT, - ]; - - $isAbstract = false; - $isFinal = false; - $isReadonly = false; - - for ($i = ($stackPtr - 1); $i > 0; $i--) { - if (isset($valid[$tokens[$i]['code']]) === false) { - break; - } - - switch ($tokens[$i]['code']) { - case T_ABSTRACT: - $isAbstract = true; - break; - - case T_FINAL: - $isFinal = true; - break; - - case T_READONLY: - $isReadonly = true; - break; - } - } - - return [ - 'is_abstract' => $isAbstract, - 'is_final' => $isFinal, - 'is_readonly' => $isReadonly, - ]; + return $phpcsFile->getClassProperties($stackPtr); } /** @@ -654,7 +573,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.8.0. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::isReference() Original source. * @see \PHPCSUtils\Utils\Operators::isReference() PHPCSUtils native improved version. @@ -680,7 +599,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.8.0. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::getTokensAsString() Original source. * @see \PHPCSUtils\Utils\GetTokensAsString Related set of functions. @@ -709,7 +628,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.8.0. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::findStartOfStatement() Original source. * @@ -733,7 +652,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.8.0. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::findEndOfStatement() Original source. * @@ -757,7 +676,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.8.0. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::hasCondition() Original source. * @see \PHPCSUtils\Utils\Conditions::hasCondition() PHPCSUtils native alternative. @@ -782,7 +701,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.8.0. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::getCondition() Original source. * @see \PHPCSUtils\Utils\Conditions::getCondition() More versatile alternative. @@ -813,7 +732,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.8.0. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::findExtendedClassName() Original source. * @see \PHPCSUtils\Utils\ObjectDeclarations::findExtendedClassName() PHPCSUtils native improved version. @@ -838,7 +757,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.8.0. + * - The upstream method has received no significant updates since PHPCS 3.9.0. * * @see \PHP_CodeSniffer\Files\File::findImplementedInterfaceNames() Original source. * @see \PHPCSUtils\Utils\ObjectDeclarations::findImplementedInterfaceNames() PHPCSUtils native improved version. @@ -848,8 +767,8 @@ public static function findExtendedClassName(File $phpcsFile, $stackPtr) * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * @param int $stackPtr The stack position of the class or enum token. * - * @return string[]|false Array with names of the implemented interfaces or `FALSE` on - * error or if there are no implemented interface names. + * @return array|false Array with names of the implemented interfaces or `FALSE` on + * error or if there are no implemented interface names. */ public static function findImplementedInterfaceNames(File $phpcsFile, $stackPtr) { diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCTokens.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCTokens.php index 9424f70c..dac8feb1 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.8.0. + * changes since PHPCS 3.9.0. * * @since 1.0.0 * diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/Helper.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/Helper.php index 7352a8cb..aa033e92 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/Helper.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/Helper.php @@ -143,13 +143,14 @@ public static function getTabWidth(File $phpcsFile) * command-line or the ruleset. * * @since 1.0.0 + * @since 1.0.10 The `File` type declaration has been removed from the parameter declaration. * * @param \PHP_CodeSniffer\Files\File|null $phpcsFile Optional. The current file being processed. * * @return string Encoding. Defaults to the PHPCS native default, which is 'utf-8' * for PHPCS 3.x. */ - public static function getEncoding(File $phpcsFile = null) + public static function getEncoding($phpcsFile = null) { $default = 'utf-8'; @@ -176,14 +177,18 @@ public static function getEncoding(File $phpcsFile = null) * Check whether the "--ignore-annotations" option is in effect. * * @since 1.0.0 + * @since 1.0.10 The `File` type declaration has been removed from the parameter declaration. * * @param \PHP_CodeSniffer\Files\File|null $phpcsFile Optional. The current file being processed. * * @return bool `TRUE` if annotations should be ignored, `FALSE` otherwise. */ - public static function ignoreAnnotations(File $phpcsFile = null) + public static function ignoreAnnotations($phpcsFile = null) { - if (isset($phpcsFile, $phpcsFile->config->annotations)) { + if (isset($phpcsFile) + && $phpcsFile instanceof File + && isset($phpcsFile->config->annotations) + ) { return ! $phpcsFile->config->annotations; } diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrList.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrList.php index 28a38989..36eb7a42 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrList.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrList.php @@ -161,7 +161,7 @@ final class IsShortArrayOrList * * @var string */ - private $phpcsVersion; + private $phpcsVersion; // @phpstan-ignore-line /** * Tokens which can open a short array or short list (PHPCS cross-version compatible). @@ -362,27 +362,7 @@ private function isSquareBracket() private function isShortArrayBracket() { if ($this->tokens[$this->opener]['code'] === \T_OPEN_SQUARE_BRACKET) { - if (\version_compare($this->phpcsVersion, '3.7.2', '>=') === true) { - // These will just be properly tokenized, plain square brackets. No need for further checks. - return false; - } - - /* - * BC: Work around a bug in the tokenizer of PHPCS < 3.7.2, where a `[` would be - * tokenized as T_OPEN_SQUARE_BRACKET instead of T_OPEN_SHORT_ARRAY if it was - * preceded by the close parenthesis of a non-braced control structure. - * - * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/3632 - */ - if ($this->tokens[$this->beforeOpener]['code'] === \T_CLOSE_PARENTHESIS - && isset($this->tokens[$this->beforeOpener]['parenthesis_owner']) === true - // phpcs:ignore Generic.Files.LineLength.TooLong - && isset(Tokens::$scopeOpeners[$this->tokens[$this->tokens[$this->beforeOpener]['parenthesis_owner']]['code']]) === true - ) { - return true; - } - - // These are really just plain square brackets. + // Currently there are no known issues with the tokenization in PHPCS 3.9.0 and higher. return false; } diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrListWithCache.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrListWithCache.php index b1b8c47e..b4772bb5 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrListWithCache.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrListWithCache.php @@ -138,7 +138,7 @@ public static function isShortList(File $phpcsFile, $stackPtr) * * @return string|false The type of construct this bracket was determined to be. * Either 'short array', 'short list' or 'square brackets'. - * Or FALSE is this was not a bracket token. + * Or FALSE if this was not a bracket token. */ public static function getType(File $phpcsFile, $stackPtr) { diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php index 2de11a2d..55904857 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php @@ -10,8 +10,11 @@ namespace PHPCSUtils\TestUtils; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Exceptions\TokenizerException; +use PHP_CodeSniffer\Files\DummyFile; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Ruleset; use PHPCSUtils\BackCompat\Helper; use PHPCSUtils\Exceptions\TestFileNotFound; use PHPCSUtils\Exceptions\TestMarkerNotFound; @@ -169,7 +172,7 @@ abstract class UtilityMethodTestCase extends TestCase * * @since 1.0.0 * - * @var string[] + * @var array */ protected static $selectedSniff = ['Dummy.Dummy.Dummy']; @@ -220,7 +223,7 @@ public static function setUpTestFile() self::setStaticConfigProperty('configData', ['report_width' => 80]); self::setStaticConfigProperty('configDataFile', ''); - $config = new \PHP_CodeSniffer\Config(); + $config = new Config(); /* * Set to a usable value to circumvent Config trying to find a phpcs.xml config file. @@ -243,12 +246,12 @@ public static function setUpTestFile() // Also set a tab-width to enable testing tab-replaced vs `orig_content`. $config->tabWidth = static::$tabWidth; - $ruleset = new \PHP_CodeSniffer\Ruleset($config); + $ruleset = new Ruleset($config); // Make sure the file gets parsed correctly based on the file type. $contents = 'phpcs_input_file: ' . $caseFile . \PHP_EOL . $contents; - self::$phpcsFile = new \PHP_CodeSniffer\Files\DummyFile($contents, $ruleset, $config); + self::$phpcsFile = new DummyFile($contents, $ruleset, $config); // Only tokenize the file, do not process it. try { @@ -322,6 +325,8 @@ public static function resetTestFile() /** * Helper function to set the value of a private static property on the PHPCS Config class. * + * @since 1.0.9 + * * @param string $name The name of the property to set. * @param mixed $value The value to set the property to. * @@ -367,7 +372,7 @@ public static function usesPhp8NameTokens() * @param string $commentString The complete delimiter comment to look for as a string. * This string should include the comment opener and closer. * @param int|string|array $tokenType The type of token(s) to look for. - * @param string $tokenContent Optional. The token content for the target token. + * @param string|null $tokenContent Optional. The token content for the target token. * * @return int * diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php index c8465152..a842c9ec 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php @@ -10,7 +10,6 @@ namespace PHPCSUtils\Tokens; -use PHPCSUtils\BackCompat\Helper; use PHPCSUtils\Exceptions\InvalidTokenArray; /** @@ -447,7 +446,7 @@ final class Collections * @var array */ private static $propertyTypeTokens = [ - \T_CALLABLE => \T_CALLABLE, + \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, diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php index c13d0a21..49554580 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php @@ -40,7 +40,8 @@ final class NamingConventions /** * Uppercase A-Z. * - * @since 1.0.0 + * @since 1.0.0 + * @deprecated 1.0.10 * * @var string */ @@ -49,7 +50,8 @@ final class NamingConventions /** * Lowercase a-z. * - * @since 1.0.0 + * @since 1.0.0 + * @deprecated 1.0.10 * * @var string */ @@ -108,10 +110,7 @@ public static function isEqual($nameA, $nameB) return true; } - // OK, so these may be different names or they may be the same name with case differences. - $nameA = \strtr($nameA, self::AZ_UPPER, self::AZ_LOWER); - $nameB = \strtr($nameB, self::AZ_UPPER, self::AZ_LOWER); - - return ($nameA === $nameB); + // Comparing via strcasecmp will only compare ASCII letters case-insensitively. + return (strcasecmp($nameA, $nameB) === 0); } } diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ObjectDeclarations.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ObjectDeclarations.php index cb45bd4f..ffa346ae 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ObjectDeclarations.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ObjectDeclarations.php @@ -272,8 +272,8 @@ public static function findExtendedClassName(File $phpcsFile, $stackPtr) * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * @param int $stackPtr The stack position of the class or enum token. * - * @return string[]|false Array with names of the implemented interfaces or `FALSE` on - * error or if there are no implemented interface names. + * @return array|false Array with names of the implemented interfaces or `FALSE` on + * error or if there are no implemented interface names. */ public static function findImplementedInterfaceNames(File $phpcsFile, $stackPtr) { @@ -290,8 +290,8 @@ public static function findImplementedInterfaceNames(File $phpcsFile, $stackPtr) * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found. * @param int $stackPtr The stack position of the interface keyword. * - * @return string[]|false Array with names of the extended interfaces or `FALSE` on - * error or if there are no extended interface names. + * @return array|false Array with names of the extended interfaces or `FALSE` on + * error or if there are no extended interface names. */ public static function findExtendedInterfaceNames(File $phpcsFile, $stackPtr) { @@ -317,8 +317,8 @@ public static function findExtendedInterfaceNames(File $phpcsFile, $stackPtr) * @param array $allowedFor Array of OO types for which use of the keyword * is allowed. * - * @return string[]|false Returns an array of names or `FALSE` on error or when the object - * being declared does not extend/implement another object. + * @return array|false Returns an array of names or `FALSE` on error or when the object + * being declared does not extend/implement another object. */ private static function findNames(File $phpcsFile, $stackPtr, $keyword, array $allowedFor) { diff --git a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php index 35f1f391..00c6311d 100644 --- a/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php +++ b/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php @@ -170,7 +170,7 @@ public static function hasParameters(File $phpcsFile, $stackPtr, $isShortArray = * Efficiency tweak for when this has already been established, * Use with EXTREME care. * - * @return array> + * @return array> * A multi-dimentional array with information on each parameter/array item. * The information gathered about each parameter/array item is in the following format: * ```php @@ -367,7 +367,7 @@ public static function getParameters(File $phpcsFile, $stackPtr, $limit = 0, $is * @param int $stackPtr The position of function call name, * language construct or array open token. * @param int $paramOffset The 1-based index position of the parameter to retrieve. - * @param string|string[] $paramNames Optional. Either the name of the target parameter + * @param string|array $paramNames Optional. Either the name of the target parameter * to retrieve as a string or an array of names for the * same target parameter. * Only relevant for function calls. @@ -453,17 +453,17 @@ public static function getParameterCount(File $phpcsFile, $stackPtr) * * @since 1.0.0 * - * @param array> $parameters The output of a previous call to - * {@see PassedParameters::getParameters()}. - * @param int $paramOffset The 1-based index position of the parameter - * to retrieve. - * @param string|string[] $paramNames Either the name of the target parameter to retrieve - * as a string or an array of names for the same target - * parameter. - * An array of names is supported to allow for functions - * for which the parameter names have undergone name - * changes over time. - * The name will take precedence over the offset. + * @param array> $parameters The output of a previous call to + * {@see PassedParameters::getParameters()}. + * @param int $paramOffset The 1-based index position of the parameter + * to retrieve. + * @param string|array $paramNames Either the name of the target parameter to retrieve + * as a string or an array of names for the same target + * parameter. + * An array of names is supported to allow for functions + * for which the parameter names have undergone name + * changes over time. + * The name will take precedence over the offset. * * @return array|false Array with information on the parameter at the specified offset, * or with the specified name. diff --git a/vendor/phpcsstandards/phpcsutils/README.md b/vendor/phpcsstandards/phpcsutils/README.md index 430855ea..60cfe41d 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.8.0 up to PHPCS `master`. +These functions are compatible with PHPCS 3.9.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.8.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.9.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.8.0+. +* [PHP_CodeSniffer] 3.9.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 bd5c4ae0..0fe11b88 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.8.0 || 4.0.x-dev@dev", + "squizlabs/php_codesniffer" : "^3.9.0 || 4.0.x-dev@dev", "dealerdirect/phpcodesniffer-composer-installer" : "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0" }, "require-dev" : { diff --git a/vendor/squizlabs/php_codesniffer/CHANGELOG.md b/vendor/squizlabs/php_codesniffer/CHANGELOG.md index 2da2e810..15cf61f3 100644 --- a/vendor/squizlabs/php_codesniffer/CHANGELOG.md +++ b/vendor/squizlabs/php_codesniffer/CHANGELOG.md @@ -5,6 +5,163 @@ The file documents changes to the PHP_CodeSniffer project. _Nothing yet._ +## [3.9.1] - 2024-03-31 + +### Added +- Documentation for the following sniffs: + - Generic.PHP.RequireStrictTypes + - Squiz.WhiteSpace.MemberVarSpacing + - Squiz.WhiteSpace.ScopeClosingBrace + - Squiz.WhiteSpace.SuperfluousWhitespace + - Thanks to [Jay McPartland][@jonmcp] and [Rodrigo Primo][@rodrigoprimo] for the patches. + +### Changed +- The following sniffs have received performance related improvements: + - Generic.CodeAnalysis.UselessOverridingMethod + - Generic.Files.ByteOrderMark + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patches. +- Performance improvement for the "Diff" report. Should be most notable for Windows users. [#355] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- The test suite has received some performance improvements. Should be most notable contributors using Windows. [#351] + - External standards with sniff tests using the PHP_CodeSniffer native test framework will also benefit from these changes. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch. +- Various housekeeping, including improvements to the tests and documentation. + - Thanks to [Jay McPartland][@jonmcp], [João Pedro Oliveira][@jpoliveira08], [Rodrigo Primo][@rodrigoprimo] and [Juliette Reinders Folmer][@jrfnl] for their contributions. + +### Fixed +- Fixed bug [#289] : Squiz.WhiteSpace.OperatorSpacing and PSR12.Operators.OperatorSpacing : improved fixer conflict protection by more strenuously avoiding handling operators in declare statements. + - Thanks to [Dan Wallis][@fredden] for the patch. +- Fixed bug [#366] : Generic.CodeAnalysis.UselessOverridingMethod : prevent false negative when the declared method name and the called method name do not use the same case. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch. +- Fixed bug [#368] : Squiz.Arrays.ArrayDeclaration fixer did not handle static closures correctly when moving array items to their own line. + - Thanks to [Michał Bundyra][@michalbundyra] for the patch. +- Fixed bug [#404] : Test framework : fixed PHP 8.4 deprecation notice. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch + +[#289]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/289 +[#351]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/351 +[#355]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/355 +[#366]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/366 +[#368]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/368 +[#404]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/404 + +## [3.9.0] - 2024-02-16 + +### Added +- Tokenizer support for PHP 8.3 typed class constants. [#321] + - Additionally, the following sniffs have been updated to support typed class constants: + - Generic.NamingConventions.UpperCaseConstantName [#332] + - Generic.PHP.LowerCaseConstant [#330] + - Generic.PHP.LowerCaseType [#331] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patches +- Tokenizer support for PHP 8.3 readonly anonymous classes. [#309] + - Additionally, the following sniffs have been updated to support readonly anonymous classes: + - PSR12.Classes.ClassInstantiation [#324] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patches +- New `PHP_CodeSniffer\Sniffs\DeprecatedSniff` interface to allow for marking a sniff as deprecated. [#281] + - If a ruleset uses deprecated sniffs, deprecation notices will be shown to the end-user before the scan starts. + When running in `-q` (quiet) mode, the deprecation notices will be hidden. + - Deprecated sniffs will still run and using them will have no impact on the exit code for a scan. + - In ruleset "explain"-mode (`-e`) an asterix `*` will show next to deprecated sniffs. + - Sniff maintainers are advised to read through the PR description for full details on how to use this feature for their own (deprecated) sniffs. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- New `Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence` sniff. [#197] + - Forbid mixing different binary boolean operators within a single expression without making precedence clear using parentheses + - Thanks to [Tim Düsterhus][@TimWolla] for the contribution +- Squiz.PHP.EmbeddedPhp : the sniff will now also examine the formatting of embedded PHP statements using short open echo tags. [#27] + - Includes a new `ShortOpenEchoNoSemicolon` errorcode to allow for selectively ignoring missing semicolons in single line embedded PHP snippets within short open echo tags. + - The other error codes are the same and do not distinguish between what type of open tag was used. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Documentation for the following sniffs: + - Generic.WhiteSpace.IncrementDecrementSpacing + - PSR12.ControlStructures.ControlStructureSpacing + - PSR12.Files.ImportStatement + - PSR12.Functions.ReturnTypeDeclaration + - PSR12.Properties.ConstantVisibility + - Thanks to [Denis Žoljom][@dingo-d] and [Rodrigo Primo][@rodrigoprimo] for the patches + +### Changed +- The Performance report can now also be used for a `phpcbf` run. [#308] + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Sniff tests which extend the PHPCS native `AbstractSniffUnitTest` class will now show a (non-build-breaking) warning when test case files contain fixable errors/warnings, but there is no corresponding `.fixed` file available in the test suite to verify the fixes against. [#336] + - The warning is only displayed on PHPUnit 7.3.0 and higher. + - The warning will be elevated to a test failure in PHPCS 4.0. + - Thanks to [Dan Wallis][@fredden] for the patch +- The following sniffs have received performance related improvements: + - Squiz.PHP.EmbeddedPhp + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Various housekeeping, including improvements to the tests and documentation + - Thanks to [Dan Wallis][@fredden], [Joachim Noreiko][@joachim-n], [Remi Collet][@remicollet], [Rodrigo Primo][@rodrigoprimo] and [Juliette Reinders Folmer][@jrfnl] for their contributions + +### Deprecated +- Support for scanning JavaScript and CSS files. See [#2448][sq-2448]. + - This also means that all sniffs which are only aimed at JavaScript or CSS files are now deprecated. + - The Javascript and CSS Tokenizers, all Javascript and CSS specific sniffs, and support for JS and CSS in select sniffs which support multiple file types, will be removed in version 4.0.0. +- The abstract `PHP_CodeSniffer\Filters\ExactMatch::getBlacklist()` and `PHP_CodeSniffer\Filters\ExactMatch::getWhitelist()` methods are deprecated and will be removed in the 4.0 release. See [#198]. + - In version 4.0, these methods will be replaced with abstract `ExactMatch::getDisallowedFiles()` and `ExactMatch::getAllowedFiles()` methods + - To make Filters extending `ExactMatch` cross-version compatible with both PHP_CodeSniffer 3.9.0+ as well as 4.0+, implement the new `getDisallowedFiles()` and `getAllowedFiles()` methods. + - When both the `getDisallowedFiles()` and `getAllowedFiles()` methods as well as the `getBlacklist()` and `getWhitelist()` are available, the new methods will take precedence over the old methods. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- The MySource standard and all sniffs in it. See [#2471][sq-2471]. + - The MySource standard and all sniffs in it will be removed in version 4.0.0. +- The `Zend.Debug.CodeAnalyzer` sniff. See [#277]. + - This sniff will be removed in version 4.0.0. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch + +### Fixed +- Fixed bug [#127] : Squiz.Commenting.FunctionComment : The `MissingParamType` error code will now be used instead of `MissingParamName` when a parameter name is provided, but not its type. Additionally, invalid type hint suggestions will no longer be provided in these cases. + - Thanks to [Dan Wallis][@fredden] for the patch +- Fixed bug [#196] : Squiz.PHP.EmbeddedPhp : fixer will no longer leave behind trailing whitespace when moving code to another line. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#196] : Squiz.PHP.EmbeddedPhp : will now determine the needed indent with higher precision in multiple situations. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#196] : Squiz.PHP.EmbeddedPhp : fixer will no longer insert a stray new line when the closer of a multi-line embedded PHP block and the opener of the next multi-line embedded PHP block would be on the same line. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#235] : Generic.CodeAnalysis.ForLoopWithTestFunctionCall : prevent a potential PHP 8.3 deprecation notice during live coding + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch +- Fixed bug [#288] : Generic.WhiteSpace.IncrementDecrementSpacing : error message for post-in/decrement will now correctly inform about new lines found before the operator. + - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch +- Fixed bug [#296] : Generic.WhiteSpace.ArbitraryParenthesesSpacing : false positive for non-arbitrary parentheses when these follow the scope closer of a `switch` `case`. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#307] : PSR2.Classes.ClassDeclaration : space between a modifier keyword and the `class` keyword was not checked when the space included a new line or comment. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#325] : Squiz.Operators.IncrementDecrementUsage : the sniff was underreporting when there was (no) whitespace and/or comments in unexpected places. + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#335] : PSR12.Files.DeclareStatement : bow out in a certain parse error situation to prevent incorrect auto-fixes from being made. + - Thanks to [Dan Wallis][@fredden] for the patch +- Fixed bug [#340] : Squiz.Commenting.ClosingDeclarationComment : no longer adds a stray newline when adding a missing comment. + - Thanks to [Dan Wallis][@fredden] for the patch + +### Other +- A "Community cc list" has been introduced to ping maintainers of external standards and integrators for input regarding change proposals for PHP_CodeSniffer which may impact them. [#227] + - For anyone who missed the discussion about this and is interested to be on this list, please feel invited to submit a PR to add yourself. + The list is located in the `.github` folder. + +[sq-2448]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2448 +[sq-2471]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2471 +[#27]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/27 +[#127]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/127 +[#196]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/196 +[#197]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/197 +[#198]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/198 +[#227]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/227 +[#235]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/235 +[#277]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/277 +[#281]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/281 +[#288]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/288 +[#296]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/296 +[#307]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/307 +[#308]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/308 +[#309]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/309 +[#321]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/321 +[#324]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/324 +[#325]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/325 +[#330]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/330 +[#331]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/331 +[#332]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/332 +[#335]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/335 +[#336]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/336 +[#340]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/340 ## [3.8.1] - 2024-01-11 @@ -45,14 +202,13 @@ _Nothing yet._ - Thanks to [Rodrigo Primo][@rodrigoprimo] for the patch [#124]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/124 -[#150]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/150 -[#154]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/154 +[#150]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/150 +[#154]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/154 [#178]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/178 [#205]: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/205 [#211]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/211 [#226]: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/226 - ## [3.8.0] - 2023-12-08 [Squizlabs/PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is dead. Long live [PHPCSStandards/PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer)! @@ -187,126 +343,126 @@ _Nothing yet._ - Use composer or the PHAR files instead ### Fixed -- Fixed bug [#2857] : Squiz/NonExecutableCode: prevent false positives when exit is used in a ternary expression or as default with null coalesce +- Fixed bug [#2857][sq-2857] : Squiz/NonExecutableCode: prevent false positives when exit is used in a ternary expression or as default with null coalesce - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3386] : PSR1/SideEffects : improved recognition of disable/enable annotations +- Fixed bug [#3386][sq-3386] : PSR1/SideEffects : improved recognition of disable/enable annotations - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3557] : Squiz.Arrays.ArrayDeclaration will now ignore PHP 7.4 array unpacking when determining whether an array is associative +- Fixed bug [#3557][sq-3557] : Squiz.Arrays.ArrayDeclaration will now ignore PHP 7.4 array unpacking when determining whether an array is associative - Thanks to [Volker Dusch][@edorian] for the patch -- Fixed bug [#3592] : Squiz/NonExecutableCode: prevent false positives when a PHP 8.0+ inline throw expression is encountered +- Fixed bug [#3592][sq-3592] : Squiz/NonExecutableCode: prevent false positives when a PHP 8.0+ inline throw expression is encountered - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3715] : Generic/UnusedFunctionParameter: fixed incorrect errorcode for closures/arrow functions nested within extended classes/classes which implement +- Fixed bug [#3715][sq-3715] : Generic/UnusedFunctionParameter: fixed incorrect errorcode for closures/arrow functions nested within extended classes/classes which implement - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3717] : Squiz.Commenting.FunctionComment: fixed false positive for `InvalidNoReturn` when type is never +- Fixed bug [#3717][sq-3717] : Squiz.Commenting.FunctionComment: fixed false positive for `InvalidNoReturn` when type is never - Thanks to [Choraimy Kroonstuiver][@axlon] for the patch -- Fixed bug [#3720] : Generic/RequireStrictTypes : will now bow out silently in case of parse errors/live coding instead of throwing false positives/false negatives +- Fixed bug [#3720][sq-3720] : Generic/RequireStrictTypes : will now bow out silently in case of parse errors/live coding instead of throwing false positives/false negatives - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3720] : Generic/RequireStrictTypes : did not handle multi-directive declare statements +- Fixed bug [#3720][sq-3720] : Generic/RequireStrictTypes : did not handle multi-directive declare statements - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3722] : Potential "Uninitialized string offset 1" in octal notation backfill +- Fixed bug [#3722][sq-3722] : Potential "Uninitialized string offset 1" in octal notation backfill - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3736] : PEAR/FunctionDeclaration: prevent fixer removing the close brace (and creating a parse error) when there is no space between the open brace and close brace of a function +- Fixed bug [#3736][sq-3736] : PEAR/FunctionDeclaration: prevent fixer removing the close brace (and creating a parse error) when there is no space between the open brace and close brace of a function - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3739] : PEAR/FunctionDeclaration: prevent fixer conflict, and potentially creating a parse error, for unconventionally formatted return types +- Fixed bug [#3739][sq-3739] : PEAR/FunctionDeclaration: prevent fixer conflict, and potentially creating a parse error, for unconventionally formatted return types - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3770] : Squiz/NonExecutableCode: prevent false positives for switching between PHP and HTML +- Fixed bug [#3770][sq-3770] : Squiz/NonExecutableCode: prevent false positives for switching between PHP and HTML - Thanks to [Dan Wallis][@fredden] for the patch -- Fixed bug [#3773] : Tokenizer/PHP: tokenization of the readonly keyword when used in combination with PHP 8.2 disjunctive normal types +- Fixed bug [#3773][sq-3773] : Tokenizer/PHP: tokenization of the readonly keyword when used in combination with PHP 8.2 disjunctive normal types - Thanks to [Dan Wallis][@fredden] and [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3776] : Generic/JSHint: error when JSHint is not available +- Fixed bug [#3776][sq-3776] : Generic/JSHint: error when JSHint is not available - Thanks to [Dan Wallis][@fredden] for the patch -- Fixed bug [#3777] : Squiz/NonExecutableCode: slew of bug fixes, mostly related to modern PHP +- Fixed bug [#3777][sq-3777] : Squiz/NonExecutableCode: slew of bug fixes, mostly related to modern PHP - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3778] : Squiz/LowercasePHPFunctions: bug fix for class names in attributes +- Fixed bug [#3778][sq-3778] : Squiz/LowercasePHPFunctions: bug fix for class names in attributes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3779] : Generic/ForbiddenFunctions: bug fix for class names in attributes +- Fixed bug [#3779][sq-3779] : Generic/ForbiddenFunctions: bug fix for class names in attributes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3785] : Squiz.Commenting.FunctionComment: potential "Uninitialized string offset 0" when a type contains a duplicate pipe symbol +- Fixed bug [#3785][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] : 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] : Incorrect tokenization for ternary operator with `match` inside of it +- Fixed bug [#3789][sq-3789] : Incorrect tokenization for ternary operator with `match` inside of it - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3790] : PSR12/AnonClassDeclaration: prevent fixer creating parse error when there was no space before the open brace +- Fixed bug [#3790][sq-3790] : PSR12/AnonClassDeclaration: prevent fixer creating parse error when there was no space before the open brace - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3797] : Tokenizer/PHP: more context sensitive keyword fixes +- Fixed bug [#3797][sq-3797] : Tokenizer/PHP: more context sensitive keyword fixes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3801] : File::getMethodParameters(): allow for readonly promoted properties without visibility +- Fixed bug [#3801][sq-3801] : File::getMethodParameters(): allow for readonly promoted properties without visibility - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3805] : Generic/FunctionCallArgumentSpacing: prevent fixer conflict over PHP 7.3+ trailing comma's in function calls +- Fixed bug [#3805][sq-3805] : Generic/FunctionCallArgumentSpacing: prevent fixer conflict over PHP 7.3+ trailing comma's in function calls - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3806] : Squiz.PHP.InnerFunctions sniff now correctly reports inner functions declared within a closure +- Fixed bug [#3806][sq-3806] : Squiz.PHP.InnerFunctions sniff now correctly reports inner functions declared within a closure - Thanks to [@Daimona] for the patch -- Fixed bug [#3809] : GitBlame report was broken when passing a basepath +- Fixed bug [#3809][sq-3809] : GitBlame report was broken when passing a basepath - Thanks to [Chris][@datengraben] for the patch -- Fixed bug [#3813] : Squiz.Commenting.FunctionComment: false positive for parameter name mismatch on parameters annotated as passed by reference +- Fixed bug [#3813][sq-3813] : Squiz.Commenting.FunctionComment: false positive for parameter name mismatch on parameters annotated as passed by reference - Thanks to [Dan Wallis][@fredden] for the patch -- Fixed bug [#3833] : Generic.PHP.LowerCaseType: fixed potential undefined array index notice +- Fixed bug [#3833][sq-3833] : Generic.PHP.LowerCaseType: fixed potential undefined array index notice - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3846] : PSR2.Classes.ClassDeclaration.CloseBraceAfterBody : fixer will no longer remove indentation on the close brace line +- Fixed bug [#3846][sq-3846] : PSR2.Classes.ClassDeclaration.CloseBraceAfterBody : fixer will no longer remove indentation on the close brace line - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3854] : Fatal error when using Gitblame report in combination with `--basepath` and running from project subdirectory +- Fixed bug [#3854][sq-3854] : Fatal error when using Gitblame report in combination with `--basepath` and running from project subdirectory - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3856] : PSR12.Traits.UseDeclaration was using the wrong error code - SpacingAfterAs - for spacing issues after the `use` keyword +- Fixed bug [#3856][sq-3856] : PSR12.Traits.UseDeclaration was using the wrong error code - SpacingAfterAs - for spacing issues after the `use` keyword - These will now be reported using the SpacingAfterUse error code - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3856] : PSR12.Traits.UseDeclaration did not check spacing after `use` keyword for multi-line trait use statements +- Fixed bug [#3856][sq-3856] : PSR12.Traits.UseDeclaration did not check spacing after `use` keyword for multi-line trait use statements - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3867] : Tokenizer/PHP: union type and intersection type operators were not correctly tokenized for static properties without explicit visibility +- Fixed bug [#3867][sq-3867] : Tokenizer/PHP: union type and intersection type operators were not correctly tokenized for static properties without explicit visibility - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3877] : Filter names can be case-sensitive. The -h help text will now display the correct case for the available filters +- Fixed bug [#3877][sq-3877] : Filter names can be case-sensitive. The -h help text will now display the correct case for the available filters - Thanks to [@simonsan] for the patch -- Fixed bug [#3893] : Generic/DocComment : the SpacingAfterTagGroup fixer could accidentally remove ignore annotations +- Fixed bug [#3893][sq-3893] : Generic/DocComment : the SpacingAfterTagGroup fixer could accidentally remove ignore annotations - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3898] : Squiz/NonExecutableCode : the sniff could get confused over comments in unexpected places +- Fixed bug [#3898][sq-3898] : Squiz/NonExecutableCode : the sniff could get confused over comments in unexpected places - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3904] : Squiz/FunctionSpacing : prevent potential fixer conflict +- Fixed bug [#3904][sq-3904] : Squiz/FunctionSpacing : prevent potential fixer conflict - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug [#3906] : Tokenizer/CSS: bug fix related to the unsupported slash comment syntax +- Fixed bug [#3906][sq-3906] : Tokenizer/CSS: bug fix related to the unsupported slash comment syntax - Thanks to [Dan Wallis][@fredden] for the patch -- Fixed bug [#3913] : Config did not always correctly store unknown "long" arguments in the `$unknown` property +- Fixed bug [#3913][sq-3913] : Config did not always correctly store unknown "long" arguments in the `$unknown` property - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch Thanks go to [Dan Wallis][@fredden] and [Danny van der Sluijs][@DannyvdSluijs] for reviewing quite a few of the PRs for this release. Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo change over. -[#2857]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2857 -[#3386]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3386 -[#3557]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3557 -[#3592]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3592 -[#3715]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3715 -[#3717]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3717 -[#3720]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3720 -[#3722]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3722 -[#3736]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3736 -[#3739]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3739 -[#3770]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3770 -[#3773]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3773 -[#3776]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3776 -[#3777]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3777 -[#3778]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3778 -[#3779]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3779 -[#3785]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3785 -[#3787]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3787 -[#3789]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3789 -[#3790]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3790 -[#3797]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3797 -[#3801]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3801 -[#3805]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3805 -[#3806]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3806 -[#3809]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3809 -[#3813]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3813 -[#3833]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3833 -[#3846]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3846 -[#3854]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3854 -[#3856]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3856 -[#3867]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3867 -[#3877]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3877 -[#3893]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3893 -[#3898]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3898 -[#3904]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3904 -[#3906]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3906 -[#3913]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3913 +[sq-2857]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2857 +[sq-3386]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3386 +[sq-3557]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3557 +[sq-3592]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3592 +[sq-3715]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3715 +[sq-3717]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3717 +[sq-3720]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3720 +[sq-3722]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3722 +[sq-3736]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3736 +[sq-3739]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3739 +[sq-3770]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3770 +[sq-3773]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3773 +[sq-3776]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3776 +[sq-3777]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3777 +[sq-3778]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3778 +[sq-3779]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3779 +[sq-3785]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3785 +[sq-3787]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3787 +[sq-3789]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3789 +[sq-3790]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3790 +[sq-3797]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3797 +[sq-3801]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3801 +[sq-3805]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3805 +[sq-3806]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3806 +[sq-3809]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3809 +[sq-3813]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3813 +[sq-3833]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3833 +[sq-3846]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3846 +[sq-3854]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3854 +[sq-3856]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3856 +[sq-3867]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3867 +[sq-3877]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3877 +[sq-3893]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3893 +[sq-3898]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3898 +[sq-3904]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3904 +[sq-3906]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3906 +[sq-3913]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3913 ## [3.7.2] - 2023-02-23 ### Changed @@ -320,33 +476,47 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz.Formatting.OperatorBracket no longer reports false positives in match() structures ### Fixed -- Fixed bug #3616 : Squiz.PHP.DisallowComparisonAssignment false positive for PHP 8 match expression +- Fixed bug [#3616][sq-3616] : Squiz.PHP.DisallowComparisonAssignment false positive for PHP 8 match expression - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3618 : Generic.WhiteSpace.ArbitraryParenthesesSpacing false positive for return new parent() +- Fixed bug [#3618][sq-3618] : Generic.WhiteSpace.ArbitraryParenthesesSpacing false positive for return new parent() - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3632 : Short list not tokenized correctly in control structures without braces +- Fixed bug [#3632][sq-3632] : Short list not tokenized correctly in control structures without braces - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3639 : Tokenizer not applying tab replacement to heredoc/nowdoc closers +- Fixed bug [#3639][sq-3639] : Tokenizer not applying tab replacement to heredoc/nowdoc closers - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3640 : Generic.WhiteSpace.DisallowTabIndent not reporting errors for PHP 7.3 flexible heredoc/nowdoc syntax +- Fixed bug [#3640][sq-3640] : Generic.WhiteSpace.DisallowTabIndent not reporting errors for PHP 7.3 flexible heredoc/nowdoc syntax - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3645 : PHPCS can show 0 exit code when running in parallel even if child process has fatal error +- Fixed bug [#3645][sq-3645] : PHPCS can show 0 exit code when running in parallel even if child process has fatal error - Thanks to [Alex Panshin][@enl] for the patch -- Fixed bug #3653 : False positives for match() in OperatorSpacingSniff +- Fixed bug [#3653][sq-3653] : False positives for match() in OperatorSpacingSniff - Thanks to [Jaroslav Hanslík][@kukulich] for the patch -- Fixed bug #3666 : PEAR.Functions.FunctionCallSignature incorrect indent fix when checking mixed HTML/PHP files -- Fixed bug #3668 : PSR12.Classes.ClassInstantiation.MissingParentheses false positive when instantiating parent classes +- Fixed bug [#3666][sq-3666] : PEAR.Functions.FunctionCallSignature incorrect indent fix when checking mixed HTML/PHP files +- Fixed bug [#3668][sq-3668] : PSR12.Classes.ClassInstantiation.MissingParentheses false positive when instantiating parent classes - Similar issues also fixed in Generic.Functions.FunctionCallArgumentSpacing and Squiz.Formatting.OperatorBracket - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3672 : Incorrect ScopeIndent.IncorrectExact report for match inside array literal -- Fixed bug #3694 : Generic.WhiteSpace.SpreadOperatorSpacingAfter does not ignore spread operator in PHP 8.1 first class callables +- Fixed bug [#3672][sq-3672] : Incorrect ScopeIndent.IncorrectExact report for match inside array literal +- Fixed bug [#3694][sq-3694] : Generic.WhiteSpace.SpreadOperatorSpacingAfter does not ignore spread operator in PHP 8.1 first class callables - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[sq-3616]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3616 +[sq-3618]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3618 +[sq-3632]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3632 +[sq-3639]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3639 +[sq-3640]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3640 +[sq-3645]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3645 +[sq-3653]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3653 +[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 + ## [3.7.1] - 2022-06-18 ### Fixed -- Fixed bug #3609 : Methods/constants with name empty/isset/unset are always reported as error +- Fixed bug [#3609][sq-3609] : Methods/constants with name empty/isset/unset are always reported as error - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[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 @@ -359,7 +529,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Thanks to [Juliette Reinders Folmer][@jrfnl] for additional core and sniff support - Added support for the PHP 8.1 readonly token - - Tokenzing of the readonly keyword has been backfilled for PHP versions less than 8.1 + - Tokenizing of the readonly keyword has been backfilled for PHP versions less than 8.1 - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - Added support for PHP 8.1 intersection types - Includes a new T_TYPE_INTERSECTION token to represent the ampersand character inside intersection types @@ -391,58 +561,80 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Jaroslav Hanslík][@kukulich] for the patch ### Fixed -- Fixed bug #3502 : A match statement within an array produces Squiz.Arrays.ArrayDeclaration.NoKeySpecified -- Fixed bug #3503 : Squiz.Commenting.FunctionComment.ThrowsNoFullStop false positive when one line @throw -- Fixed bug #3505 : The nullsafe operator is not counted in Generic.Metrics.CyclomaticComplexity +- Fixed bug [#3502][sq-3502] : A match statement within an array produces Squiz.Arrays.ArrayDeclaration.NoKeySpecified +- Fixed bug [#3503][sq-3503] : Squiz.Commenting.FunctionComment.ThrowsNoFullStop false positive when one line @throw +- Fixed bug [#3505][sq-3505] : The nullsafe operator is not counted in Generic.Metrics.CyclomaticComplexity - Thanks to [Mark Baker][@MarkBaker] for the patch -- Fixed bug #3526 : PSR12.Properties.ConstantVisibility false positive when using public final const syntax +- Fixed bug [#3526][sq-3526] : PSR12.Properties.ConstantVisibility false positive when using public final const syntax - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3530 : Line indented incorrectly false positive when using match-expression inside switch case -- Fixed bug #3534 : Name of typed enum tokenized as T_GOTO_LABEL +- Fixed bug [#3530][sq-3530] : Line indented incorrectly false positive when using match-expression inside switch case +- Fixed bug [#3534][sq-3534] : Name of typed enum tokenized as T_GOTO_LABEL - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3546 : Tokenizer/PHP: bug fix - parent/static keywords in class instantiations +- Fixed bug [#3546][sq-3546] : Tokenizer/PHP: bug fix - parent/static keywords in class instantiations - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3550 : False positive from PSR2.ControlStructures.SwitchDeclaration.TerminatingComment when using trailing comment +- Fixed bug [#3550][sq-3550] : False positive from PSR2.ControlStructures.SwitchDeclaration.TerminatingComment when using trailing comment - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3575: Squiz.Scope.MethodScope misses visibility keyword on previous line +- Fixed bug [#3575][sq-3575] : Squiz.Scope.MethodScope misses visibility keyword on previous line - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3604: Tokenizer/PHP: bug fix for double quoted strings using ${ +- Fixed bug [#3604][sq-3604] : Tokenizer/PHP: bug fix for double quoted strings using ${ - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[sq-3502]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3502 +[sq-3503]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3503 +[sq-3505]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3505 +[sq-3526]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3526 +[sq-3530]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3530 +[sq-3534]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3534 +[sq-3546]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3546 +[sq-3550]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3550 +[sq-3575]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3575 +[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 ### Fixed -- Fixed bug #3388 : phpcs does not work when run from WSL drives +- Fixed bug [#3388][sq-3388] : phpcs does not work when run from WSL drives - Thanks to [Juliette Reinders Folmer][@jrfnl] and [Graham Wharton][@gwharton] for the patch -- Fixed bug #3422 : Squiz.WhiteSpace.ScopeClosingBrace fixer removes HTML content when fixing closing brace alignment +- Fixed bug [#3422][sq-3422] : Squiz.WhiteSpace.ScopeClosingBrace fixer removes HTML content when fixing closing brace alignment - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3437 : PSR12 does not forbid blank lines at the start of the class body +- Fixed bug [#3437][sq-3437] : PSR12 does not forbid blank lines at the start of the class body - Added new PSR12.Classes.OpeningBraceSpace sniff to enforce this -- Fixed bug #3440 : Squiz.WhiteSpace.MemberVarSpacing false positives when attributes used without docblock +- Fixed bug [#3440][sq-3440] : Squiz.WhiteSpace.MemberVarSpacing false positives when attributes used without docblock - Thanks to [Vadim Borodavko][@javer] for the patch -- Fixed bug #3448 : PHP 8.1 deprecation notice while generating running time value - - Thanks to [Juliette Reinders Folmer][@jrfnl] and Andy Postnikov for the patch -- Fixed bug #3456 : PSR12.Classes.ClassInstantiation.MissingParentheses false positive using attributes on anonymous class +- Fixed bug [#3448][sq-3448] : PHP 8.1 deprecation notice while generating running time value + - Thanks to [Juliette Reinders Folmer][@jrfnl] and [Andy Postnikov][@andypost] for the patch +- Fixed bug [#3456][sq-3456] : PSR12.Classes.ClassInstantiation.MissingParentheses false positive using attributes on anonymous class - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3460 : Generic.Formatting.MultipleStatementAlignment false positive on closure with parameters +- Fixed bug [#3460][sq-3460] : Generic.Formatting.MultipleStatementAlignment false positive on closure with parameters - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3468 : do/while loops are double-counted in Generic.Metrics.CyclomaticComplexity +- Fixed bug [#3468][sq-3468] : do/while loops are double-counted in Generic.Metrics.CyclomaticComplexity - Thanks to [Mark Baker][@MarkBaker] for the patch -- Fixed bug #3469 : Ternary Operator and Null Coalescing Operator are not counted in Generic.Metrics.CyclomaticComplexity +- Fixed bug [#3469][sq-3469] : Ternary Operator and Null Coalescing Operator are not counted in Generic.Metrics.CyclomaticComplexity - Thanks to [Mark Baker][@MarkBaker] for the patch -- Fixed bug #3472 : PHP 8 match() expression is not counted in Generic.Metrics.CyclomaticComplexity +- Fixed bug [#3472][sq-3472] : PHP 8 match() expression is not counted in Generic.Metrics.CyclomaticComplexity - Thanks to [Mark Baker][@MarkBaker] for the patch +[sq-3388]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3388 +[sq-3422]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3422 +[sq-3437]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3437 +[sq-3440]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3440 +[sq-3448]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3448 +[sq-3456]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3456 +[sq-3460]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3460 +[sq-3468]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3468 +[sq-3469]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3469 +[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 - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- The new PHP 8.1 tokenisation for ampersands has been reverted to use the existing PHP_CodeSniffer method - - The PHP 8.1 tokens T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG and T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG are unsued +- The new PHP 8.1 tokenization for ampersands has been reverted to use the existing PHP_CodeSniffer method + - The PHP 8.1 tokens T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG and T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG are unused - Ampersands continue to be tokenized as T_BITWISE_AND for all PHP versions - Thanks to [Juliette Reinders Folmer][@jrfnl] and [Anna Filina][@afilina] for the patch - File::getMethodParameters() no longer incorrectly returns argument attributes in the type hint array index @@ -474,45 +666,68 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz.Commenting.VariableComment - Squiz.WhiteSpace.MemberVarSpacing - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3294 : Bug in attribute tokenization when content contains PHP end token or attribute closer on new line +- Fixed bug [#3294][sq-3294] : Bug in attribute tokenization when content contains PHP end token or attribute closer on new line - Thanks to [Alessandro Chitolina][@alekitto] for the patch - Thanks to [Juliette Reinders Folmer][@jrfnl] for the tests -- Fixed bug #3296 : PSR2.ControlStructures.SwitchDeclaration takes phpcs:ignore as content of case body -- Fixed bug #3297 : PSR2.ControlStructures.SwitchDeclaration.TerminatingComment does not handle try/finally blocks +- Fixed bug [#3296][sq-3296] : PSR2.ControlStructures.SwitchDeclaration takes phpcs:ignore as content of case body +- Fixed bug [#3297][sq-3297] : PSR2.ControlStructures.SwitchDeclaration.TerminatingComment does not handle try/finally blocks - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3302 : PHP 8.0 | Tokenizer/PHP: bugfix for union types using namespace operator +- Fixed bug [#3302][sq-3302] : PHP 8.0 | Tokenizer/PHP: bugfix for union types using namespace operator - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3303 : findStartOfStatement() doesn't work with T_OPEN_TAG_WITH_ECHO -- Fixed bug #3316 : Arrow function not tokenized correctly when using null in union type -- Fixed bug #3317 : Problem with how phpcs handles ignored files when running in parallel +- Fixed bug [#3303][sq-3303] : findStartOfStatement() doesn't work with T_OPEN_TAG_WITH_ECHO +- Fixed bug [#3316][sq-3316] : Arrow function not tokenized correctly when using null in union type +- Fixed bug [#3317][sq-3317] : Problem with how phpcs handles ignored files when running in parallel - Thanks to [Emil Andersson][@emil-nasso] for the patch -- Fixed bug #3324 : PHPCS hangs processing some nested arrow functions inside a function call -- Fixed bug #3326 : Generic.Formatting.MultipleStatementAlignment error with const DEFAULT +- Fixed bug [#3324][sq-3324] : PHPCS hangs processing some nested arrow functions inside a function call +- Fixed bug [#3326][sq-3326] : Generic.Formatting.MultipleStatementAlignment error with const DEFAULT - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3333 : Squiz.Objects.ObjectInstantiation: null coalesce operators are not recognized as assignment +- Fixed bug [#3333][sq-3333] : Squiz.Objects.ObjectInstantiation: null coalesce operators are not recognized as assignment - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3340 : Ensure interface and trait names are always tokenized as T_STRING +- Fixed bug [#3340][sq-3340] : Ensure interface and trait names are always tokenized as T_STRING - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3342 : PSR12/Squiz/PEAR standards all error on promoted properties with docblocks +- Fixed bug [#3342][sq-3342] : PSR12/Squiz/PEAR standards all error on promoted properties with docblocks - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3345 : IF statement with no braces and double catch turned into syntax error by auto-fixer +- Fixed bug [#3345][sq-3345] : IF statement with no braces and double catch turned into syntax error by auto-fixer - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3352 : PSR2.ControlStructures.SwitchDeclaration can remove comments on the same line as the case statement while fixing +- Fixed bug [#3352][sq-3352] : PSR2.ControlStructures.SwitchDeclaration can remove comments on the same line as the case statement while fixing - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3357 : Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present +- Fixed bug [#3357][sq-3357] : Generic.Functions.OpeningFunctionBraceBsdAllman removes return type when additional lines are present - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3362 : Generic.WhiteSpace.ScopeIndent false positive for arrow functions inside arrays -- Fixed bug #3384 : Squiz.Commenting.FileComment.SpacingAfterComment false positive on empty file -- Fixed bug #3394 : Fix PHP 8.1 auto_detect_line_endings deprecation notice -- Fixed bug #3400 : PHP 8.1: prevent deprecation notices about missing return types +- Fixed bug [#3362][sq-3362] : Generic.WhiteSpace.ScopeIndent false positive for arrow functions inside arrays +- Fixed bug [#3384][sq-3384] : Squiz.Commenting.FileComment.SpacingAfterComment false positive on empty file +- Fixed bug [#3394][sq-3394] : Fix PHP 8.1 auto_detect_line_endings deprecation notice +- Fixed bug [#3400][sq-3400] : PHP 8.1: prevent deprecation notices about missing return types - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3424 : PHPCS fails when using PHP 8 Constructor property promotion with attributes +- Fixed bug [#3424][sq-3424] : PHPCS fails when using PHP 8 Constructor property promotion with attributes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3425 : PHP 8.1 | Runner::processChildProcs(): fix passing null to non-nullable bug +- Fixed bug [#3425][sq-3425] : PHP 8.1 | Runner::processChildProcs(): fix passing null to non-nullable bug - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3445 : Nullable parameter after attribute incorrectly tokenized as ternary operator +- Fixed bug [#3445][sq-3445] : Nullable parameter after attribute incorrectly tokenized as ternary operator - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[sq-3294]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3294 +[sq-3296]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3296 +[sq-3297]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3297 +[sq-3302]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3302 +[sq-3303]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3303 +[sq-3316]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3316 +[sq-3317]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3317 +[sq-3324]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3324 +[sq-3326]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3326 +[sq-3333]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3333 +[sq-3340]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3340 +[sq-3342]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3342 +[sq-3345]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3345 +[sq-3352]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3352 +[sq-3357]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3357 +[sq-3362]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3362 +[sq-3384]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3384 +[sq-3394]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3394 +[sq-3400]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3400 +[sq-3424]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3424 +[sq-3425]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3425 +[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 @@ -540,7 +755,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Added support for PHP 8.0 dereferencing of text strings with interpolated variables - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added support for PHP 8.0 match expressions - - Match expressions are now tokenised with parenthesis and scope openers and closers + - Match expressions are now tokenized with parenthesis and scope openers and closers - Sniffs can listen for the T_MATCH token to process match expressions - Note that the case and default statements inside match expressions do not have scopes set - A new T_MATCH_ARROW token is available to represent the arrows in match expressions @@ -590,9 +805,9 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Spaces are now correctly escaped in the paths to external on Windows - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.CodeAnalysis.UnusedFunctionParameter can now be configured to ignore variable usage for specific type hints - -- This allows you to suppress warnings for some variables that are not required, but leave warnings for others - -- Set the ignoreTypeHints array property to a list of type hints to ignore - -- Thanks to [Petr Bugyík][@o5] for the patch + - This allows you to suppress warnings for some variables that are not required, but leave warnings for others + - Set the ignoreTypeHints array property to a list of type hints to ignore + - Thanks to [Petr Bugyík][@o5] for the patch - Generic.Formatting.MultipleStatementAlignment can now align statements at the start of the assignment token - Previously, the sniff enforced that the values were aligned, even if this meant the assignment tokens were not - Now, the sniff can enforce that the assignment tokens are aligned, even if this means the values are not @@ -615,7 +830,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - PSR2.ControlStructures.SwitchDeclaration now supports nested switch statements where every branch terminates - Previously, if a CASE only contained a SWITCH and no direct terminating statement, a fall-through error was displayed - - Now, the error is surpressed if every branch of the SWITCH has a terminating statement + - Now, the error is suppressed if every branch of the SWITCH has a terminating statement - Thanks to [Vincent Langlet][@VincentLanglet] for the patch - The PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket error message is now reported on the closing parenthesis token - Previously, the error was being reported on the function keyword, leading to confusing line numbers in the error report @@ -639,33 +854,54 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Sniff no longer errors for assignments on first line of closure - Sniff no longer errors for assignments after a goto label - Thanks to [Jaroslav Hanslík][@kukulich] for the patch -- Fixed bug #2913 : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional -- Fixed bug #2992 : Enabling caching using a ruleset produces invalid cache files when using --sniffs and --exclude CLI args -- Fixed bug #3003 : Squiz.Formatting.OperatorBracket autofix incorrect when assignment used with null coalescing operator -- Fixed bug #3145 : Autoloading of sniff fails when multiple classes declared in same file -- Fixed bug #3157 : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented -- Fixed bug #3163 : Undefined index error with pre-commit hook using husky on PHP 7.4 +- Fixed bug [#2913][sq-2913] : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional +- Fixed bug [#2992][sq-2992] : Enabling caching using a ruleset produces invalid cache files when using --sniffs and --exclude CLI args +- Fixed bug [#3003][sq-3003] : Squiz.Formatting.OperatorBracket autofix incorrect when assignment used with null coalescing operator +- Fixed bug [#3145][sq-3145] : Autoloading of sniff fails when multiple classes declared in same file +- Fixed bug [#3157][sq-3157] : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented +- Fixed bug [#3163][sq-3163] : Undefined index error with pre-commit hook using husky on PHP 7.4 - Thanks to [Ismo Vuorinen][@ivuorinen] for the patch -- Fixed bug #3165 : Squiz.PHP.DisallowComparisonAssignment false positive when comparison inside closure -- Fixed bug #3167 : Generic.WhiteSpace.ScopeIndent false positive when using PHP 8.0 constructor property promotion -- Fixed bug #3170 : Squiz.WhiteSpace.OperatorSpacing false positive when using negation with string concat +- Fixed bug [#3165][sq-3165] : Squiz.PHP.DisallowComparisonAssignment false positive when comparison inside closure +- Fixed bug [#3167][sq-3167] : Generic.WhiteSpace.ScopeIndent false positive when using PHP 8.0 constructor property promotion +- Fixed bug [#3170][sq-3170] : Squiz.WhiteSpace.OperatorSpacing false positive when using negation with string concat - This also fixes the same issue in the PSR12.Operators.OperatorSpacing sniff -- Fixed bug #3177 : Incorrect tokenization of GOTO statements in mixed PHP/HTML files +- Fixed bug [#3177][sq-3177] : Incorrect tokenization of GOTO statements in mixed PHP/HTML files - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3184 : PSR2.Namespace.NamespaceDeclaration false positive on namespace operator +- Fixed bug [#3184][sq-3184] : PSR2.Namespace.NamespaceDeclaration false positive on namespace operator - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3188 : Squiz.WhiteSpace.ScopeKeywordSpacing false positive for static return type +- Fixed bug [#3188][sq-3188] : Squiz.WhiteSpace.ScopeKeywordSpacing false positive for static return type - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3192 : findStartOfStatement doesn't work correctly inside switch +- Fixed bug [#3192][sq-3192] : findStartOfStatement doesn't work correctly inside switch - Thanks to [Vincent Langlet][@VincentLanglet] for the patch -- Fixed bug #3195 : Generic.WhiteSpace.ScopeIndent confusing message when combination of tabs and spaces found -- Fixed bug #3197 : Squiz.NamingConventions.ValidVariableName does not use correct error code for all member vars -- Fixed bug #3219 : Generic.Formatting.MultipleStatementAlignment false positive for empty anonymous classes and closures -- Fixed bug #3258 : Squiz.Formatting.OperatorBracket duplicate error messages for unary minus - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3273 : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis -- Fixed bug #3277 : Nullable static return typehint causes whitespace error -- Fixed bug #3284 : Unused parameter false positive when using array index in arrow function +- Fixed bug [#3195][sq-3195] : Generic.WhiteSpace.ScopeIndent confusing message when combination of tabs and spaces found +- Fixed bug [#3197][sq-3197] : Squiz.NamingConventions.ValidVariableName does not use correct error code for all member vars +- Fixed bug [#3219][sq-3219] : Generic.Formatting.MultipleStatementAlignment false positive for empty anonymous classes and closures +- Fixed bug [#3258][sq-3258] : Squiz.Formatting.OperatorBracket duplicate error messages for unary minus + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#3273][sq-3273] : Squiz.Functions.FunctionDeclarationArgumentSpacing reports line break as 0 spaces between parenthesis +- Fixed bug [#3277][sq-3277] : Nullable static return typehint causes whitespace error +- Fixed bug [#3284][sq-3284] : Unused parameter false positive when using array index in arrow function + +[sq-2913]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2913 +[sq-2992]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2992 +[sq-3003]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3003 +[sq-3145]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3145 +[sq-3157]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3157 +[sq-3163]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3163 +[sq-3165]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3165 +[sq-3167]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3167 +[sq-3170]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3170 +[sq-3177]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3177 +[sq-3184]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3184 +[sq-3188]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3188 +[sq-3192]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3192 +[sq-3195]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3195 +[sq-3197]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3197 +[sq-3219]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3219 +[sq-3258]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3258 +[sq-3273]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3273 +[sq-3277]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3277 +[sq-3284]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3284 ## [3.5.8] - 2020-10-23 ### Removed @@ -675,9 +911,9 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ## [3.5.7] - 2020-10-23 ### Added - The PHP 8.0 T_NULLSAFE_OBJECT_OPERATOR token has been made available for older versions - - Existing sniffs that check for T_OBJECT_OPERATOR have been modified to apply the same rules for the nullsafe object operator + - Existing sniffs that check for T_OBJECT_OPERATOR have been modified to apply the same rules for the nullsafe object operator - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- The new method of PHP 8.0 tokenizing for namespaced names has been revert to thr pre 8.0 method +- The new method of PHP 8.0 tokenizing for namespaced names has been reverted to the pre 8.0 method - This maintains backwards compatible for existing sniffs on PHP 8.0 - This change will be removed in PHPCS 4.0 as the PHP 8.0 tokenizing method will be backported for pre 8.0 versions - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -698,37 +934,57 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed Squiz.Formatting.OperatorBracket false positive when exiting with a negative number - Fixed Squiz.PHP.DisallowComparisonAssignment false positive for methods called on an object -- Fixed bug #2882 : Generic.Arrays.ArrayIndent can request close brace indent to be less than the statement indent level -- Fixed bug #2883 : Generic.WhiteSpace.ScopeIndent.Incorrect issue after NOWDOC -- Fixed bug #2975 : Undefined offset in PSR12.Functions.ReturnTypeDeclaration when checking function return type inside ternary -- Fixed bug #2988 : Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding +- Fixed bug [#2882][sq-2882] : Generic.Arrays.ArrayIndent can request close brace indent to be less than the statement indent level +- Fixed bug [#2883][sq-2883] : Generic.WhiteSpace.ScopeIndent.Incorrect issue after NOWDOC +- Fixed bug [#2975][sq-2975] : Undefined offset in PSR12.Functions.ReturnTypeDeclaration when checking function return type inside ternary +- Fixed bug [#2988][sq-2988] : Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding - Thanks to [Thiemo Kreuz][@thiemowmde] for the patch -- Fixed bug #2989 : Incorrect auto-fixing in Generic.ControlStructures.InlineControlStructure during live coding +- Fixed bug [#2989][sq-2989] : Incorrect auto-fixing in Generic.ControlStructures.InlineControlStructure during live coding - Thanks to [Thiemo Kreuz][@thiemowmde] for the patch -- Fixed bug #3007 : Directory exclude pattern improperly excludes directories with names that start the same +- Fixed bug [#3007][sq-3007] : Directory exclude pattern improperly excludes directories with names that start the same - Thanks to [Steve Talbot][@SteveTalbot] for the patch -- Fixed bug #3043 : Squiz.WhiteSpace.OperatorSpacing false positive for negation in arrow function +- Fixed bug [#3043][sq-3043] : Squiz.WhiteSpace.OperatorSpacing false positive for negation in arrow function - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3049 : Incorrect error with arrow function and parameter passed as reference +- Fixed bug [#3049][sq-3049] : Incorrect error with arrow function and parameter passed as reference - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3053 : PSR2 incorrect fix when multiple use statements on same line do not have whitespace between them -- Fixed bug #3058 : Progress gets unaligned when 100% happens at the end of the available dots -- Fixed bug #3059 : Squiz.Arrays.ArrayDeclaration false positive when using type casting +- Fixed bug [#3053][sq-3053] : PSR2 incorrect fix when multiple use statements on same line do not have whitespace between them +- Fixed bug [#3058][sq-3058] : Progress gets unaligned when 100% happens at the end of the available dots +- Fixed bug [#3059][sq-3059] : Squiz.Arrays.ArrayDeclaration false positive when using type casting - Thanks to [Sergei Morozov][@morozov] for the patch -- Fixed bug #3060 : Squiz.Arrays.ArrayDeclaration false positive for static functions +- Fixed bug [#3060][sq-3060] : Squiz.Arrays.ArrayDeclaration false positive for static functions - Thanks to [Sergei Morozov][@morozov] for the patch -- Fixed bug #3065 : Should not fix Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma if comment between element and comma +- Fixed bug [#3065][sq-3065] : Should not fix Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma if comment between element and comma - Thanks to [Sergei Morozov][@morozov] for the patch -- Fixed bug #3066 : No support for namespace operator used in type declarations +- Fixed bug [#3066][sq-3066] : No support for namespace operator used in type declarations - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3075 : PSR12.ControlStructures.BooleanOperatorPlacement false positive when operator is the only content on line -- Fixed bug #3099 : Squiz.WhiteSpace.OperatorSpacing false positive when exiting with negative number +- Fixed bug [#3075][sq-3075] : PSR12.ControlStructures.BooleanOperatorPlacement false positive when operator is the only content on line +- Fixed bug [#3099][sq-3099] : Squiz.WhiteSpace.OperatorSpacing false positive when exiting with negative number - Thanks to [Sergei Morozov][@morozov] for the patch -- Fixed bug #3102 : PSR12.Squiz.OperatorSpacing false positive for default values of arrow functions - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #3124 : PSR-12 not reporting error for empty lines with only whitespace -- Fixed bug #3135 : Ignore annotations are broken on PHP 8.0 - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#3102][sq-3102] : PSR12.Squiz.OperatorSpacing false positive for default values of arrow functions + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#3124][sq-3124] : PSR-12 not reporting error for empty lines with only whitespace +- Fixed bug [#3135][sq-3135] : Ignore annotations are broken on PHP 8.0 + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch + +[sq-2882]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2882 +[sq-2883]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2883 +[sq-2975]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2975 +[sq-2988]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2988 +[sq-2989]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2989 +[sq-3007]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3007 +[sq-3043]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3043 +[sq-3049]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3049 +[sq-3053]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3053 +[sq-3058]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3058 +[sq-3059]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3059 +[sq-3060]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3060 +[sq-3065]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3065 +[sq-3066]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3066 +[sq-3075]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3075 +[sq-3099]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3099 +[sq-3102]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3102 +[sq-3124]: https://github.com/squizlabs/PHP_CodeSniffer/issues/3124 +[sq-3135]: https://github.com/squizlabs/PHP_CodeSniffer/pull/3135 ## [3.5.6] - 2020-08-10 ### Added @@ -753,19 +1009,28 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Michał Bundyra][@michalbundyra] for the patch ### Fixed -- Fixed bug #2877 : PEAR.Functions.FunctionCallSignature false positive for array of functions +- Fixed bug [#2877][sq-2877] : PEAR.Functions.FunctionCallSignature false positive for array of functions - Thanks to [Vincent Langlet][@VincentLanglet] for the patch -- Fixed bug #2888 : PSR12.Files.FileHeader blank line error with multiple namespaces in one file -- Fixed bug #2926 : phpcs hangs when using arrow functions that return heredoc -- Fixed bug #2943 : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed -- Fixed bug #2967 : Markdown generator does not output headings correctly +- Fixed bug [#2888][sq-2888] : PSR12.Files.FileHeader blank line error with multiple namespaces in one file +- Fixed bug [#2926][sq-2926] : phpcs hangs when using arrow functions that return heredoc +- Fixed bug [#2943][sq-2943] : Redundant semicolon added to a file when fixing PSR2.Files.ClosingTag.NotAllowed +- Fixed bug [#2967][sq-2967] : Markdown generator does not output headings correctly - Thanks to [Petr Bugyík][@o5] for the patch -- Fixed bug #2977 : File::isReference() does not detect return by reference for closures +- Fixed bug [#2977][sq-2977] : File::isReference() does not detect return by reference for closures - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2994 : Generic.Formatting.DisallowMultipleStatements false positive for FOR loop with no body -- Fixed bug #3033 : Error generated during tokenizing of goto statements on PHP 8 +- Fixed bug [#2994][sq-2994] : Generic.Formatting.DisallowMultipleStatements false positive for FOR loop with no body +- Fixed bug [#3033][sq-3033] : Error generated during tokenizing of goto statements on PHP 8 - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[sq-2877]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2877 +[sq-2888]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2888 +[sq-2926]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2926 +[sq-2943]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2943 +[sq-2967]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2967 +[sq-2977]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2977 +[sq-2994]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2994 +[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 @@ -776,23 +1041,37 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Error wording in PEAR.Functions.FunctionCallSignature now always uses "parenthesis" instead of sometimes using "bracket" - Thanks to [Vincent Langlet][@VincentLanglet] for the patch -- Fixed bug #2787 : Squiz.PHP.DisallowMultipleAssignments not ignoring typed property declarations +- Fixed bug [#2787][sq-2787] : Squiz.PHP.DisallowMultipleAssignments not ignoring typed property declarations - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2810 : PHPCBF fails to fix file with empty statement at start on control structure -- Fixed bug #2812 : Squiz.Arrays.ArrayDeclaration not detecting some arrays with multiple arguments on the same line +- Fixed bug [#2810][sq-2810] : PHPCBF fails to fix file with empty statement at start on control structure +- Fixed bug [#2812][sq-2812] : Squiz.Arrays.ArrayDeclaration not detecting some arrays with multiple arguments on the same line - Thanks to [Jakub Chábek][@grongor] for the patch -- Fixed bug #2826 : Generic.WhiteSpace.ArbitraryParenthesesSpacing doesn't detect issues for statements directly after a control structure +- Fixed bug [#2826][sq-2826] : Generic.WhiteSpace.ArbitraryParenthesesSpacing doesn't detect issues for statements directly after a control structure - Thanks to [Vincent Langlet][@VincentLanglet] for the patch -- Fixed bug #2848 : PSR12.Files.FileHeader false positive for file with mixed PHP and HTML and no file header -- Fixed bug #2849 : Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array -- Fixed bug #2850 : Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase -- Fixed bug #2853 : Undefined variable error when using Info report - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2865 : Double arrow tokenized as T_STRING when placed after function named "fn" -- Fixed bug #2867 : Incorrect scope matching when arrow function used inside IF condition -- Fixed bug #2868 : phpcs:ignore annotation doesnt work inside a docblock -- Fixed bug #2878 : PSR12.Files.FileHeader conflicts with Generic.Files.LineEndings -- Fixed bug #2895 : PSR2.Methods.FunctionCallSignature.MultipleArguments false positive with arrow function argument +- Fixed bug [#2848][sq-2848] : PSR12.Files.FileHeader false positive for file with mixed PHP and HTML and no file header +- Fixed bug [#2849][sq-2849] : Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array +- Fixed bug [#2850][sq-2850] : Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase +- Fixed bug [#2853][sq-2853] : Undefined variable error when using Info report + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2865][sq-2865] : Double arrow tokenized as T_STRING when placed after function named "fn" +- Fixed bug [#2867][sq-2867] : Incorrect scope matching when arrow function used inside IF condition +- Fixed bug [#2868][sq-2868] : phpcs:ignore annotation doesn't work inside a docblock +- Fixed bug [#2878][sq-2878] : PSR12.Files.FileHeader conflicts with Generic.Files.LineEndings +- Fixed bug [#2895][sq-2895] : PSR2.Methods.FunctionCallSignature.MultipleArguments false positive with arrow function argument + +[sq-2787]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2787 +[sq-2810]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2810 +[sq-2812]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2812 +[sq-2826]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2826 +[sq-2848]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2848 +[sq-2849]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2849 +[sq-2850]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2850 +[sq-2853]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2853 +[sq-2865]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2865 +[sq-2867]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2867 +[sq-2868]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2868 +[sq-2878]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2878 +[sq-2895]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2895 ## [3.5.4] - 2020-01-31 ### Changed @@ -808,7 +1087,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Previously it required these to have curly braces, but there were no statements to enclose in them - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PSR12.ControlStructures.BooleanOperatorPlacement can now be configured to enforce a specific operator position - - By default, the sniff ensures that operators are all at the begining or end of lines, but not a mix of both + - By default, the sniff ensures that operators are all at the beginning or end of lines, but not a mix of both - Set the allowOnly property to "first" to enforce all boolean operators to be at the start of a line - Set the allowOnly property to "last" to enforce all boolean operators to be at the end of a line - Thanks to [Vincent Langlet][@VincentLanglet] for the patch @@ -820,37 +1099,56 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz.PHP.InnerFunctions now handles multiple nested anon classes correctly ### Fixed -- Fixed bug #2497 : Sniff properties not set when referencing a sniff using relative paths or non-native slashes +- Fixed bug [#2497][sq-2497] : Sniff properties not set when referencing a sniff using relative paths or non-native slashes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2657 : Squiz.WhiteSpace.FunctionSpacing can remove spaces between comment and first/last method during auto-fixing +- Fixed bug [#2657][sq-2657] : Squiz.WhiteSpace.FunctionSpacing can remove spaces between comment and first/last method during auto-fixing - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2688 : Case statements not tokenized correctly when switch is contained within ternary -- Fixed bug #2698 : PHPCS throws errors determining auto report width when shell_exec is disabled +- Fixed bug [#2688][sq-2688] : Case statements not tokenized correctly when switch is contained within ternary +- Fixed bug [#2698][sq-2698] : PHPCS throws errors determining auto report width when shell_exec is disabled - Thanks to [Matthew Peveler][@MasterOdin] for the patch -- Fixed bug #2730 : PSR12.ControlStructures.ControlStructureSpacing does not ignore comments between conditions +- Fixed bug [#2730][sq-2730] : PSR12.ControlStructures.ControlStructureSpacing does not ignore comments between conditions - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2732 : PSR12.Files.FileHeader misidentifies file header in mixed content file -- Fixed bug #2745 : AbstractArraySniff wrong indices when mixed coalesce and ternary values +- Fixed bug [#2732][sq-2732] : PSR12.Files.FileHeader misidentifies file header in mixed content file +- Fixed bug [#2745][sq-2745] : AbstractArraySniff wrong indices when mixed coalesce and ternary values - Thanks to [Michał Bundyra][@michalbundyra] for the patch -- Fixed bug #2748 : Wrong end of statement for fn closures +- Fixed bug [#2748][sq-2748] : Wrong end of statement for fn closures - Thanks to [Michał Bundyra][@michalbundyra] for the patch -- Fixed bug #2751 : Autoload relative paths first to avoid confusion with files from the global include path +- Fixed bug [#2751][sq-2751] : Autoload relative paths first to avoid confusion with files from the global include path - Thanks to [Klaus Purer][@klausi] for the patch -- Fixed bug #2763 : PSR12 standard reports errors for multi-line FOR definitions -- Fixed bug #2768 : Generic.Files.LineLength false positive for non-breakable strings at exactly the soft limit +- Fixed bug [#2763][sq-2763] : PSR12 standard reports errors for multi-line FOR definitions +- Fixed bug [#2768][sq-2768] : Generic.Files.LineLength false positive for non-breakable strings at exactly the soft limit - Thanks to [Alex Miles][@ghostal] for the patch -- Fixed bug #2773 : PSR2.Methods.FunctionCallSignature false positive when arrow function has array return type -- Fixed bug #2790 : PSR12.Traits.UseDeclaration ignores block comments +- Fixed bug [#2773][sq-2773] : PSR2.Methods.FunctionCallSignature false positive when arrow function has array return type +- Fixed bug [#2790][sq-2790] : PSR12.Traits.UseDeclaration ignores block comments - Thanks to [Vincent Langlet][@VincentLanglet] for the patch -- Fixed bug #2791 : PSR12.Functions.NullableTypeDeclaration false positive when ternary operator used with instanceof - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2802 : Can't specify a report file path using the tilde shortcut -- Fixed bug #2804 : PHP4-style typed properties not tokenized correctly - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2805 : Undefined Offset notice during live coding of arrow functions - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2843 : Tokenizer does not support alternative syntax for declare statements - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2791][sq-2791] : PSR12.Functions.NullableTypeDeclaration false positive when ternary operator used with instanceof + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2802][sq-2802] : Can't specify a report file path using the tilde shortcut +- Fixed bug [#2804][sq-2804] : PHP4-style typed properties not tokenized correctly + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2805][sq-2805] : Undefined Offset notice during live coding of arrow functions + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2843][sq-2843] : Tokenizer does not support alternative syntax for declare statements + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch + +[sq-2497]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2497 +[sq-2657]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2657 +[sq-2688]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2688 +[sq-2698]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2698 +[sq-2730]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2730 +[sq-2732]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2732 +[sq-2745]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2745 +[sq-2748]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2748 +[sq-2751]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2751 +[sq-2763]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2763 +[sq-2768]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2768 +[sq-2773]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2773 +[sq-2790]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2790 +[sq-2791]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2791 +[sq-2802]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2802 +[sq-2804]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2804 +[sq-2805]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2805 +[sq-2843]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2843 ## [3.5.3] - 2019-12-04 ### Changed @@ -859,7 +1157,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - The double arrow becomes the scope opener, and uses a new T_FN_ARROW token type - The token after the statement (normally a semicolon) becomes the scope closer - The token is also associated with the opening and closing parenthesis of the statement - - Any functions named "fn" will cause have a T_FN token for the function name, but have no scope information + - Any functions named "fn" will have a T_FN token for the function name, but have no scope information - Thanks to [Michał Bundyra][@michalbundyra] for the help with this change - PHP 7.4 numeric separators are now tokenized in the same way when using older PHP versions - Previously, a number like 1_000 would tokenize as T_LNUMBER (1), T_STRING (_000) @@ -895,24 +1193,34 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Michał Bundyra][@michalbundyra] for the patch ### Fixed -- Fixed bug #2586 : Generic.WhiteSpace.ScopeIndent false positives when indenting open tags at a non tab-stop -- Fixed bug #2638 : Squiz.CSS.DuplicateClassDefinitionSniff sees comments as part of the class name +- Fixed bug [#2586][sq-2586] : Generic.WhiteSpace.ScopeIndent false positives when indenting open tags at a non tab-stop +- Fixed bug [#2638][sq-2638] : Squiz.CSS.DuplicateClassDefinitionSniff sees comments as part of the class name - Thanks to [Raphael Horber][@rhorber] for the patch -- Fixed bug #2640 : Squiz.WhiteSpace.OperatorSpacing false positives for some negation operators +- Fixed bug [#2640][sq-2640] : Squiz.WhiteSpace.OperatorSpacing false positives for some negation operators - Thanks to [Jakub Chábek][@grongor] and [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2674 : Squiz.Functions.FunctionDeclarationArgumentSpacing prints wrong argument name in error message -- Fixed bug #2676 : PSR12.Files.FileHeader locks up when file ends with multiple inline comments -- Fixed bug #2678 : PSR12.Classes.AnonClassDeclaration incorrectly enforcing that closing brace be on a line by itself -- Fixed bug #2685 : File::getMethodParameters() setting typeHintEndToken for vars with no type hint +- Fixed bug [#2674][sq-2674] : Squiz.Functions.FunctionDeclarationArgumentSpacing prints wrong argument name in error message +- Fixed bug [#2676][sq-2676] : PSR12.Files.FileHeader locks up when file ends with multiple inline comments +- Fixed bug [#2678][sq-2678] : PSR12.Classes.AnonClassDeclaration incorrectly enforcing that closing brace be on a line by itself +- Fixed bug [#2685][sq-2685] : File::getMethodParameters() setting typeHintEndToken for vars with no type hint - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2694 : AbstractArraySniff produces invalid indices when using ternary operator +- Fixed bug [#2694][sq-2694] : AbstractArraySniff produces invalid indices when using ternary operator - Thanks to [Michał Bundyra][@michalbundyra] for the patch -- Fixed bug #2702 : Generic.WhiteSpace.ScopeIndent false positive when using ternary operator with short arrays +- Fixed bug [#2702][sq-2702] : Generic.WhiteSpace.ScopeIndent false positive when using ternary operator with short arrays + +[sq-2586]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2586 +[sq-2638]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2638 +[sq-2640]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2640 +[sq-2674]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2674 +[sq-2676]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2676 +[sq-2678]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2678 +[sq-2685]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2685 +[sq-2694]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2694 +[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 comparisions, or when performing some function calls + - False positives were being returned for array comparisons, or when performing some function calls - Squiz.WhiteSpace.SemicolonSpacing.Incorrect error message now escapes newlines and tabs - Provides a clearer error message as whitespace is now visible - Also allows for better output for report types such as CSV and XML @@ -921,13 +1229,20 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Craig Duncan][@duncan3dc] for the patch ### Fixed -- Fixed bug #2654 : Incorrect indentation for arguments of multiline function calls -- Fixed bug #2656 : Squiz.WhiteSpace.MemberVarSpacing removes comments before first member var during auto fixing +- Fixed bug [#2654][sq-2654] : Incorrect indentation for arguments of multiline function calls +- Fixed bug [#2656][sq-2656] : Squiz.WhiteSpace.MemberVarSpacing removes comments before first member var during auto fixing - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2663 : Generic.NamingConventions.ConstructorName complains about old constructor in interfaces -- Fixed bug #2664 : PSR12.Files.OpenTag incorrectly identifies PHP file with only an opening tag -- Fixed bug #2665 : PSR12.Files.ImportStatement should not apply to traits -- Fixed bug #2673 : PSR12.Traits.UseDeclaration does not allow comments or blank lines between use statements +- Fixed bug [#2663][sq-2663] : Generic.NamingConventions.ConstructorName complains about old constructor in interfaces +- Fixed bug [#2664][sq-2664] : PSR12.Files.OpenTag incorrectly identifies PHP file with only an opening tag +- Fixed bug [#2665][sq-2665] : PSR12.Files.ImportStatement should not apply to traits +- Fixed bug [#2673][sq-2673] : PSR12.Traits.UseDeclaration does not allow comments or blank lines between use statements + +[sq-2654]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2654 +[sq-2656]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2656 +[sq-2663]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2663 +[sq-2664]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2664 +[sq-2665]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2665 +[sq-2673]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2673 ## [3.5.1] - 2019-10-17 ### Changed @@ -939,26 +1254,39 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - This check has been missing from these standards, but has now been implemented - When using the PEAR standard, the error code is PEAR.Functions.FunctionCallSignature.FirstArgumentPosition - When using PSR2 or PSR12, the error code is PSR2.Methods.FunctionCallSignature.FirstArgumentPosition -- PSR12.ControlStructures.BooleanOperatorPlacement no longer complains when multiple expression appears on the same line - - Previously, boolean operators were enforce to appear at the start or end of lines only +- PSR12.ControlStructures.BooleanOperatorPlacement no longer complains when multiple expressions appear on the same line + - Previously, boolean operators were enforced to appear at the start or end of lines only - Boolean operators can now appear in the middle of the line - PSR12.Files.FileHeader no longer ignores comments preceding a use, namespace, or declare statement - PSR12.Files.FileHeader now allows a hashbang line at the top of the file ### Fixed -- Fixed bug #2506 : PSR2 standard can't auto fix multi-line function call inside a string concat statement -- Fixed bug #2530 : PEAR.Commenting.FunctionComment does not support intersection types in comments -- Fixed bug #2615 : Constant visibility false positive on non-class constants -- Fixed bug #2616 : PSR12.Files.FileHeader false positive when file only contains docblock -- Fixed bug #2619 : PSR12.Files.FileHeader locks up when inline comment is the last content in a file -- Fixed bug #2621 : PSR12.Classes.AnonClassDeclaration.CloseBraceSameLine false positive for anon class passed as function argument +- Fixed bug [#2506][sq-2506] : PSR2 standard can't auto fix multi-line function call inside a string concat statement +- Fixed bug [#2530][sq-2530] : PEAR.Commenting.FunctionComment does not support intersection types in comments +- Fixed bug [#2615][sq-2615] : Constant visibility false positive on non-class constants +- Fixed bug [#2616][sq-2616] : PSR12.Files.FileHeader false positive when file only contains docblock +- Fixed bug [#2619][sq-2619] : PSR12.Files.FileHeader locks up when inline comment is the last content in a file +- Fixed bug [#2621][sq-2621] : PSR12.Classes.AnonClassDeclaration.CloseBraceSameLine false positive for anon class passed as function argument - Thanks to [Martins Sipenko][@martinssipenko] for the patch -- Fixed bug #2623 : PSR12.ControlStructures.ControlStructureSpacing not ignoring indentation inside multi-line string arguments -- Fixed bug #2624 : PSR12.Traits.UseDeclaration doesnt apply the correct indent during auto fixing -- Fixed bug #2626 : PSR12.Files.FileHeader detects @var annotations as file docblocks -- Fixed bug #2628 : PSR12.Traits.UseDeclaration does not allow comments above a USE declaration -- Fixed bug #2632 : Incorrect indentation of lines starting with "static" inside closures -- Fixed bug #2641 : PSR12.Functions.NullableTypeDeclaration false positive when using new static() +- Fixed bug [#2623][sq-2623] : PSR12.ControlStructures.ControlStructureSpacing not ignoring indentation inside multi-line string arguments +- Fixed bug [#2624][sq-2624] : PSR12.Traits.UseDeclaration doesnt apply the correct indent during auto fixing +- Fixed bug [#2626][sq-2626] : PSR12.Files.FileHeader detects @var annotations as file docblocks +- Fixed bug [#2628][sq-2628] : PSR12.Traits.UseDeclaration does not allow comments above a USE declaration +- Fixed bug [#2632][sq-2632] : Incorrect indentation of lines starting with "static" inside closures +- Fixed bug [#2641][sq-2641] : PSR12.Functions.NullableTypeDeclaration false positive when using new static() + +[sq-2506]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2506 +[sq-2530]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2530 +[sq-2615]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2615 +[sq-2616]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2616 +[sq-2619]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2619 +[sq-2621]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2621 +[sq-2623]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2623 +[sq-2624]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2624 +[sq-2626]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2626 +[sq-2628]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2628 +[sq-2632]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2632 +[sq-2641]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2641 ## [3.5.0] - 2019-09-27 ### Changed @@ -984,11 +1312,11 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The tokenizer now correctly identifies inline control structures in more cases - All helper methods inside the File class now throw RuntimeException instead of TokenizerException - - Some tokenizer methods were also throwing RuntimeExpection but now correctly throw TokenizerException + - Some tokenizer methods were also throwing RuntimeException but now correctly throw TokenizerException - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The File::getMethodParameters() method now returns more information, and supports closure USE groups - If a type hint is specified, the position of the last token in the hint will be set in a "type_hint_end_token" array index - - If a default is specified, the position of the first token in the default value will be set in a "default_token" array index + - If a default is specified, the position of the first token in the default value will be set in a "default_token" array index - If a default is specified, the position of the equals sign will be set in a "default_equal_token" array index - If the param is not the last, the position of the comma will be set in a "comma_token" array index - If the param is passed by reference, the position of the reference operator will be set in a "reference_token" array index @@ -1048,9 +1376,9 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Use the Squiz.WhiteSpace.OperatorSpacing sniff to enforce spacing around assignment operators - Note that this sniff checks spacing around all assignment operators, not just inside function calls - The Generic.Functions.FunctionCallArgumentSpacing.NoSpaceBeforeEquals error has been removed - - use Squiz.WhiteSpace.OperatorSpacing.NoSpaceBefore instead + - Use Squiz.WhiteSpace.OperatorSpacing.NoSpaceBefore instead - The Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterEquals error has been removed - - use Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter instead + - Use Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter instead - This also changes the PEAR/PSR2/PSR12 standards so they no longer check assignment operators inside function calls - They were previously checking these operators when they should not have - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -1078,7 +1406,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz.Operators.IncrementDecrementUsage now suggests pre-increment of variables instead of post-increment - This change does not enforce pre-increment over post-increment; only the suggestion has changed - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Squiz.PHP.DisallowMultipleAssignments now has a second error code for when assignments are found inside control structure conditions +- Squiz.PHP.DisallowMultipleAssignments now has a second error code for when assignments are found inside control structure conditions - The new error code is Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure - All other multiple assignment cases use the existing error code Squiz.PHP.DisallowMultipleAssignments.Found - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -1096,40 +1424,63 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Jakub Chábek][@grongor] for the patch ### Fixed -- Fixed bug #2391 : Sniff-specific ignore rules inside rulesets are filtering out too many files +- Fixed bug [#2391][sq-2391] : Sniff-specific ignore rules inside rulesets are filtering out too many files - Thanks to [Juliette Reinders Folmer][@jrfnl] and [Willington Vega][@wvega] for the patch -- Fixed bug #2478 : FunctionCommentThrowTag.WrongNumber when exception is thrown once but built conditionally -- Fixed bug #2479 : Generic.WhiteSpace.ScopeIndent error when using array destructing with exact indent checking -- Fixed bug #2498 : Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed autofix breaks heredoc -- Fixed bug #2502 : Generic.WhiteSpace.ScopeIndent false positives with nested switch indentation and case fall-through -- Fixed bug #2504 : Generic.WhiteSpace.ScopeIndent false positives with nested arrays and nowdoc string -- Fixed bug #2511 : PSR2 standard not checking if closing paren of single-line function declaration is on new line -- Fixed bug #2512 : Squiz.PHP.NonExecutableCode does not support alternate SWITCH control structure +- Fixed bug [#2478][sq-2478] : FunctionCommentThrowTag.WrongNumber when exception is thrown once but built conditionally +- Fixed bug [#2479][sq-2479] : Generic.WhiteSpace.ScopeIndent error when using array destructing with exact indent checking +- Fixed bug [#2498][sq-2498] : Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed autofix breaks heredoc +- Fixed bug [#2502][sq-2502] : Generic.WhiteSpace.ScopeIndent false positives with nested switch indentation and case fall-through +- Fixed bug [#2504][sq-2504] : Generic.WhiteSpace.ScopeIndent false positives with nested arrays and nowdoc string +- Fixed bug [#2511][sq-2511] : PSR2 standard not checking if closing paren of single-line function declaration is on new line +- Fixed bug [#2512][sq-2512] : Squiz.PHP.NonExecutableCode does not support alternate SWITCH control structure - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2522 : Text generator throws error when code sample line is too long +- Fixed bug [#2522][sq-2522] : Text generator throws error when code sample line is too long - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2526 : XML report format has bad syntax on Windows +- Fixed bug [#2526][sq-2526] : XML report format has bad syntax on Windows - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2529 : Generic.Formatting.MultipleStatementAlignment wrong error for assign in string concat -- Fixed bug #2534 : Unresolvable installed_paths can lead to open_basedir errors +- Fixed bug [#2529][sq-2529] : Generic.Formatting.MultipleStatementAlignment wrong error for assign in string concat +- Fixed bug [#2534][sq-2534] : Unresolvable installed_paths can lead to open_basedir errors - Thanks to [Oliver Nowak][@ndm2] for the patch -- Fixed bug #2541 : Text doc generator does not allow for multi-line rule explanations +- Fixed bug [#2541][sq-2541] : Text doc generator does not allow for multi-line rule explanations - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2549 : Searching for a phpcs.xml file can throw warnings due to open_basedir restrictions +- Fixed bug [#2549][sq-2549] : Searching for a phpcs.xml file can throw warnings due to open_basedir restrictions - Thanks to [Matthew Peveler][@MasterOdin] for the patch -- Fixed bug #2558 : PHP 7.4 throwing offset syntax with curly braces is deprecated message +- Fixed bug [#2558][sq-2558] : PHP 7.4 throwing offset syntax with curly braces is deprecated message - Thanks to [Matthew Peveler][@MasterOdin] for the patch -- Fixed bug #2561 : PHP 7.4 compatibility fix / implode argument order - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2562 : Inline WHILE triggers SpaceBeforeSemicolon incorrectly - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2565 : Generic.ControlStructures.InlineControlStructure confused by mixed short/long tags - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2566 : Author tag email validation doesn't support all TLDs - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2575 : Custom error messages don't have data replaced when cache is enabled -- Fixed bug #2601 : Squiz.WhiteSpace.FunctionSpacing incorrect fix when spacing is 0 -- Fixed bug #2608 : PSR2 throws errors for use statements when multiple namespaces are defined in a file +- Fixed bug [#2561][sq-2561] : PHP 7.4 compatibility fix / implode argument order + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2562][sq-2562] : Inline WHILE triggers SpaceBeforeSemicolon incorrectly + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2565][sq-2565] : Generic.ControlStructures.InlineControlStructure confused by mixed short/long tags + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2566][sq-2566] : Author tag email validation doesn't support all TLDs + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2575][sq-2575] : Custom error messages don't have data replaced when cache is enabled +- Fixed bug [#2601][sq-2601] : Squiz.WhiteSpace.FunctionSpacing incorrect fix when spacing is 0 +- Fixed bug [#2608][sq-2608] : PSR2 throws errors for use statements when multiple namespaces are defined in a file + +[sq-2391]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2391 +[sq-2478]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2478 +[sq-2479]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2479 +[sq-2498]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2498 +[sq-2502]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2502 +[sq-2504]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2504 +[sq-2511]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2511 +[sq-2512]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2512 +[sq-2522]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2522 +[sq-2526]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2526 +[sq-2529]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2529 +[sq-2534]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2534 +[sq-2541]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2541 +[sq-2549]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2549 +[sq-2558]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2558 +[sq-2561]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2561 +[sq-2562]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2562 +[sq-2565]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2565 +[sq-2566]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2566 +[sq-2575]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2575 +[sq-2601]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2601 +[sq-2608]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2608 ## [3.4.2] - 2019-04-11 ### Changed @@ -1138,16 +1489,26 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed an issue where the PCRE JIT on PHP 7.3 caused PHPCS to die when using the parallel option - PHPCS now disables the PCRE JIT before running -- Fixed bug #2368 : MySource.PHP.AjaxNullComparison throws error when first function has no doc comment -- Fixed bug #2414 : Indention false positive in switch/case/if combination -- Fixed bug #2423 : Squiz.Formatting.OperatorBracket.MissingBrackets error with static -- Fixed bug #2450 : Indentation false positive when closure containing nested IF conditions used as function argument -- Fixed bug #2452 : LowercasePHPFunctions sniff failing on "new \File()" -- Fixed bug #2453 : Squiz.CSS.SemicolonSpacingSniff false positive when style name proceeded by an asterisk - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2464 : Fixer conflict between Generic.WhiteSpace.ScopeIndent and Squiz.WhiteSpace.ScopeClosingBrace when class indented 1 space -- Fixed bug #2465 : Excluding a sniff by path is not working -- Fixed bug #2467 : PHP open/close tags inside CSS files are replaced with internal PHPCS token strings when auto fixing +- Fixed bug [#2368][sq-2368] : MySource.PHP.AjaxNullComparison throws error when first function has no doc comment +- Fixed bug [#2414][sq-2414] : Indention false positive in switch/case/if combination +- Fixed bug [#2423][sq-2423] : Squiz.Formatting.OperatorBracket.MissingBrackets error with static +- Fixed bug [#2450][sq-2450] : Indentation false positive when closure containing nested IF conditions used as function argument +- Fixed bug [#2452][sq-2452] : LowercasePHPFunctions sniff failing on "new \File()" +- Fixed bug [#2453][sq-2453] : Squiz.CSS.SemicolonSpacingSniff false positive when style name proceeded by an asterisk + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2464][sq-2464] : Fixer conflict between Generic.WhiteSpace.ScopeIndent and Squiz.WhiteSpace.ScopeClosingBrace when class indented 1 space +- Fixed bug [#2465][sq-2465] : Excluding a sniff by path is not working +- Fixed bug [#2467][sq-2467] : PHP open/close tags inside CSS files are replaced with internal PHPCS token strings when auto fixing + +[sq-2368]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2368 +[sq-2414]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2414 +[sq-2423]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2423 +[sq-2450]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2450 +[sq-2452]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2452 +[sq-2453]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2453 +[sq-2464]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2464 +[sq-2465]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2465 +[sq-2467]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2467 ## [3.4.1] - 2019-03-19 ### Changed @@ -1175,16 +1536,16 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Files.LineEndings no longer adds superfluous new line at the end of JS and CSS files - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Generic.Formatting.DisallowMultipleStatements no longer tries fix lines containing phpcs:ignore statements +- Generic.Formatting.DisallowMultipleStatements no longer tries to fix lines containing phpcs:ignore statements - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.Functions.FunctionCallArgumentSpacing now has improved performance and anonymous class support - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.WhiteSpace.ScopeIndent now respects changes to the "exact" property using phpcs:set mid-way through a file - - This allows you change the "exact" rule for only some parts of a file + - This allows you to change the "exact" rule for only some parts of a file - Generic.WhiteSpace.ScopeIndent now disables exact indent checking inside all arrays - Previously, this was only done when using long array syntax, but it now works for short array syntax as well - PEAR.Classes.ClassDeclaration now has improved handling of PHPCS annotations and tab indents -- PSR12.Classes.ClassInstantiation has changed it's error code from MissingParenthesis to MissingParentheses +- PSR12.Classes.ClassInstantiation has changed its error code from MissingParenthesis to MissingParentheses - PSR12.Keywords.ShortFormTypeKeywords now ignores all spacing inside type casts during both checking and fixing - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Squiz.Classes.LowercaseClassKeywords now examines the class keyword for anonymous classes @@ -1224,16 +1585,24 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed -- Fixed bug #2298 : PSR2.Classes.ClassDeclaration allows extended class on new line +- Fixed bug [#2298][sq-2298] : PSR2.Classes.ClassDeclaration allows extended class on new line - Thanks to [Michał Bundyra][@michalbundyra] for the patch -- Fixed bug #2337 : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line function call starts on same line as open tag -- Fixed bug #2348 : Cache not invalidated when changing a ruleset included by another -- Fixed bug #2376 : Using __halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it's last in the function list +- Fixed bug [#2337][sq-2337] : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line function call starts on same line as open tag +- Fixed bug [#2348][sq-2348] : Cache not invalidated when changing a ruleset included by another +- Fixed bug [#2376][sq-2376] : Using __halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it's last in the function list - Thanks to [Sijun Zhu][@Billz95] for the patch -- Fixed bug #2393 : The gitmodified filter will infinitely loop when encountering deleted file paths +- Fixed bug [#2393][sq-2393] : The gitmodified filter will infinitely loop when encountering deleted file paths - Thanks to [Lucas Manzke][@lmanzke] for the patch -- Fixed bug #2396 : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line IF condition mixed with HTML -- Fixed bug #2431 : Use function/const not tokenized as T_STRING when preceded by comment +- Fixed bug [#2396][sq-2396] : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line IF condition mixed with HTML +- Fixed bug [#2431][sq-2431] : Use function/const not tokenized as T_STRING when preceded by comment + +[sq-2298]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2298 +[sq-2337]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2337 +[sq-2348]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2348 +[sq-2376]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2376 +[sq-2393]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2393 +[sq-2396]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2396 +[sq-2431]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2431 ## [3.4.0] - 2018-12-20 ### Deprecated @@ -1258,7 +1627,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - This change also converts '(binary)' from T_STRING_CAST to T_BINARY_CAST - Thanks to [Juliette Reinders Folmer][@jrfnl] for the help with this patch - Array properties set inside a ruleset.xml file can now extend a previous value instead of always overwriting it - - e.g., if you include a ruleset that defines forbidden functions, can you now add to that list instead of having to redefine it + - e.g., if you include a ruleset that defines forbidden functions, can you now add to that list instead of having to redefine it - To use this feature, add extends="true" to the property tag - e.g., property name="forbiddenFunctionNames" type="array" extend="true" - Thanks to [Michael Moravec][@Majkl578] for the patch @@ -1302,7 +1671,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz.Scope.MethodScope - Squiz.Scope.StaticThisUsage - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Generic.CodeAnalysis.UnusedFunctionParameter now only skips functions with empty bodies when the class implements an interface +- Generic.CodeAnalysis.UnusedFunctionParameter now only skips functions with empty bodies when the class implements an interface - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.CodeAnalysis.UnusedFunctionParameter now has additional error codes to indicate where unused params were found - The new error code prefixes are: @@ -1375,47 +1744,68 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed -- Fixed bug #2109 : Generic.Functions.CallTimePassByReference false positive for bitwise and used in function argument -- Fixed bug #2165 : Conflict between Squiz.Arrays.ArrayDeclaration and ScopeIndent sniffs when heredoc used in array -- Fixed bug #2167 : Generic.WhiteSpace.ScopeIndent shows invalid error when scope opener indented inside inline HTML -- Fixed bug #2178 : Generic.NamingConventions.ConstructorName matches methods in anon classes with same name as containing class +- Fixed bug [#2109][sq-2109] : Generic.Functions.CallTimePassByReference false positive for bitwise and used in function argument +- Fixed bug [#2165][sq-2165] : Conflict between Squiz.Arrays.ArrayDeclaration and ScopeIndent sniffs when heredoc used in array +- Fixed bug [#2167][sq-2167] : Generic.WhiteSpace.ScopeIndent shows invalid error when scope opener indented inside inline HTML +- Fixed bug [#2178][sq-2178] : Generic.NamingConventions.ConstructorName matches methods in anon classes with same name as containing class - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2190 : PEAR.Functions.FunctionCallSignature incorrect error when encountering trailing PHPCS annotation +- Fixed bug [#2190][sq-2190] : PEAR.Functions.FunctionCallSignature incorrect error when encountering trailing PHPCS annotation - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2194 : Generic.Whitespace.LanguageConstructSpacing should not be checking namespace operators +- Fixed bug [#2194][sq-2194] : Generic.Whitespace.LanguageConstructSpacing should not be checking namespace operators - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2202 : Squiz.WhiteSpace.OperatorSpacing throws error for negative index when using curly braces for string access +- Fixed bug [#2202][sq-2202] : Squiz.WhiteSpace.OperatorSpacing throws error for negative index when using curly braces for string access - Same issue fixed in Squiz.Formatting.OperatorBracket - Thanks to [Andreas Buchenrieder][@anbuc] for the patch -- Fixed bug #2210 : Generic.NamingConventions.CamelCapsFunctionName not ignoring SoapClient __getCookies() method +- Fixed bug [#2210][sq-2210] : Generic.NamingConventions.CamelCapsFunctionName not ignoring SoapClient __getCookies() method - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2211 : PSR2.Methods.MethodDeclaration gets confused over comments between modifier keywords +- Fixed bug [#2211][sq-2211] : PSR2.Methods.MethodDeclaration gets confused over comments between modifier keywords - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2212 : FUNCTION and CONST in use groups being tokenised as T_FUNCTION and T_CONST +- Fixed bug [#2212][sq-2212] : FUNCTION and CONST in use groups being tokenized as T_FUNCTION and T_CONST - Thanks to [Chris Wilkinson][@thewilkybarkid] for the patch -- Fixed bug #2214 : File::getMemberProperties() is recognizing method params as properties +- Fixed bug [#2214][sq-2214] : File::getMemberProperties() is recognizing method params as properties - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2236 : Memory info measurement unit is Mb but probably should be MB -- Fixed bug #2246 : CSS tokenizer does not tokenize class names correctly when they contain the string NEW +- Fixed bug [#2236][sq-2236] : Memory info measurement unit is Mb but probably should be MB +- Fixed bug [#2246][sq-2246] : CSS tokenizer does not tokenize class names correctly when they contain the string NEW - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2278 : Squiz.Operators.ComparisonOperatorUsage false positive when inline IF contained in parentheses +- Fixed bug [#2278][sq-2278] : Squiz.Operators.ComparisonOperatorUsage false positive when inline IF contained in parentheses - Thanks to [Arnout Boks][@aboks] for the patch -- Fixed bug #2284 : Squiz.Functions.FunctionDeclarationArgumentSpacing removing type hint during fixing +- Fixed bug [#2284][sq-2284] : Squiz.Functions.FunctionDeclarationArgumentSpacing removing type hint during fixing - Thanks to [Michał Bundyra][@michalbundyra] for the patch -- Fixed bug #2297 : Anonymous class not tokenized correctly when used as argument to another anon class +- Fixed bug [#2297][sq-2297] : Anonymous class not tokenized correctly when used as argument to another anon class - Thanks to [Michał Bundyra][@michalbundyra] for the patch +[sq-2109]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2109 +[sq-2165]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2165 +[sq-2167]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2167 +[sq-2178]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2178 +[sq-2190]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2190 +[sq-2194]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2194 +[sq-2202]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2202 +[sq-2210]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2210 +[sq-2211]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2211 +[sq-2212]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2212 +[sq-2214]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2214 +[sq-2236]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2236 +[sq-2246]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2246 +[sq-2278]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2278 +[sq-2284]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2284 +[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 ### Fixed -- Fixed bug #1496 : Squiz.Strings.DoubleQuoteUsage not unescaping dollar sign when fixing +- Fixed bug [#1496][sq-1496] : Squiz.Strings.DoubleQuoteUsage not unescaping dollar sign when fixing - Thanks to [Michał Bundyra][@michalbundyra] for the patch -- Fixed bug #1549 : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag +- Fixed bug [#1549][sq-1549] : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1890 : Incorrect Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose error between catch and finally statements +- 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 @@ -1439,20 +1829,31 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed a problem where referencing a relative file path in a ruleset XML file could add unnecessary sniff exclusions - This didn't actually exclude anything, but caused verbose output to list strange exclusion rules -- Fixed bug #2110 : Squiz.WhiteSpace.FunctionSpacing is removing indents from the start of functions when fixing +- Fixed bug [#2110][sq-2110] : Squiz.WhiteSpace.FunctionSpacing is removing indents from the start of functions when fixing - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2115 : Squiz.Commenting.VariableComment not checking var types when the @var line contains a comment -- Fixed bug #2120 : Tokenizer fails to match T_INLINE_ELSE when used after function call containing closure -- Fixed bug #2121 : Squiz.PHP.DisallowMultipleAssignments false positive in while loop conditions +- Fixed bug [#2115][sq-2115] : Squiz.Commenting.VariableComment not checking var types when the @var line contains a comment +- Fixed bug [#2120][sq-2120] : Tokenizer fails to match T_INLINE_ELSE when used after function call containing closure +- Fixed bug [#2121][sq-2121] : Squiz.PHP.DisallowMultipleAssignments false positive in while loop conditions - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2127 : File::findExtendedClassName() doesn't support nested classes +- Fixed bug [#2127][sq-2127] : File::findExtendedClassName() doesn't support nested classes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2138 : Tokenizer detects wrong token for php ::class feature with spaces -- Fixed bug #2143 : PSR2.Namespaces.UseDeclaration does not properly fix "use function" and "use const" statements +- 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 : Squiz.Arrays.ArrayDeclaration does incorrect align calculation in array with cyrillic keys -- Fixed bug #2146 : Zend.Files.ClosingTag removes closing tag from end of file without inserting a semicolon -- Fixed bug #2151 : XML schema not updated with the new array property syntax +- Fixed bug [#2144][sq-2144] : Squiz.Arrays.ArrayDeclaration does incorrect align calculation in array with cyrillic keys +- Fixed bug [#2146][sq-2146] : Zend.Files.ClosingTag removes closing tag from end of file without inserting a semicolon +- Fixed bug [#2151][sq-2151] : XML schema not updated with the new array property syntax + +[sq-2110]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2110 +[sq-2115]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2115 +[sq-2120]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2120 +[sq-2121]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2121 +[sq-2127]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2127 +[sq-2138]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2138 +[sq-2143]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2143 +[sq-2144]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2144 +[sq-2146]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2146 +[sq-2151]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2151 ## [3.3.1] - 2018-07-27 ### Removed @@ -1507,15 +1908,24 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed -- Fixed bug #2029 : Squiz.Scope.MemberVarScope throws fatal error when a property is found in an interface - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2047 : PSR12.Classes.ClassInstantiation false positive when instantiating class from array index -- Fixed bug #2048 : GenericFormatting.MultipleStatementAlignment false positive when assigning values inside an array -- Fixed bug #2053 : PSR12.Classes.ClassInstantiation incorrectly fix when using member vars and some variable formats -- Fixed bug #2065 : Generic.ControlStructures.InlineControlStructure fixing fails when inline control structure contains closure -- Fixed bug #2072 : Squiz.Arrays.ArrayDeclaration throws NoComma error when array value is a shorthand IF statement -- Fixed bug #2082 : File with "defined() or define()" syntax triggers PSR1.Files.SideEffects.FoundWithSymbols -- Fixed bug #2095 : PSR2.Namespaces.NamespaceDeclaration does not handle namespaces defined over multiple lines +- Fixed bug [#2029][sq-2029] : Squiz.Scope.MemberVarScope throws fatal error when a property is found in an interface + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2047][sq-2047] : PSR12.Classes.ClassInstantiation false positive when instantiating class from array index +- Fixed bug [#2048][sq-2048] : GenericFormatting.MultipleStatementAlignment false positive when assigning values inside an array +- Fixed bug [#2053][sq-2053] : PSR12.Classes.ClassInstantiation incorrectly fix when using member vars and some variable formats +- Fixed bug [#2065][sq-2065] : Generic.ControlStructures.InlineControlStructure fixing fails when inline control structure contains closure +- Fixed bug [#2072][sq-2072] : Squiz.Arrays.ArrayDeclaration throws NoComma error when array value is a shorthand IF statement +- Fixed bug [#2082][sq-2082] : File with "defined() or define()" syntax triggers PSR1.Files.SideEffects.FoundWithSymbols +- Fixed bug [#2095][sq-2095] : PSR2.Namespaces.NamespaceDeclaration does not handle namespaces defined over multiple lines + +[sq-2029]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2029 +[sq-2047]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2047 +[sq-2048]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2048 +[sq-2053]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2053 +[sq-2065]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2065 +[sq-2072]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2072 +[sq-2082]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2082 +[sq-2095]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2095 ## [3.3.0] - 2018-06-07 ### Deprecated @@ -1689,42 +2099,66 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - If not set, the sniff will use whatever value is set for the existing 'spacing' property ### Fixed -- Fixed bug #1863 : File::findEndOfStatement() not working when passed a scope opener -- Fixed bug #1876 : PSR2.Namespaces.UseDeclaration not giving error for use statements before the namespace declaration +- Fixed bug [#1863][sq-1863] : File::findEndOfStatement() not working when passed a scope opener +- Fixed bug [#1876][sq-1876] : PSR2.Namespaces.UseDeclaration not giving error for use statements before the namespace declaration - Adds a new PSR2.Namespaces.UseDeclaration.UseBeforeNamespace error message -- Fixed bug #1881 : Generic.Arrays.ArrayIndent is indenting sub-arrays incorrectly when comma not used after the last value -- Fixed bug #1882 : Conditional with missing braces confused by indirect variables -- Fixed bug #1915 : JS tokenizer fails to tokenize regular expression proceeded by boolean not operator -- Fixed bug #1920 : Directory exclude pattern improperly excludes files with names that start the same +- Fixed bug [#1881][sq-1881] : Generic.Arrays.ArrayIndent is indenting sub-arrays incorrectly when comma not used after the last value +- Fixed bug [#1882][sq-1882] : Conditional with missing braces confused by indirect variables +- Fixed bug [#1915][sq-1915] : JS tokenizer fails to tokenize regular expression proceeded by boolean not operator +- Fixed bug [#1920][sq-1920] : Directory exclude pattern improperly excludes files with names that start the same - Thanks to [Jeff Puckett][@jpuck] for the patch -- Fixed bug #1922 : Equal sign alignment check broken when list syntax used before assignment operator -- Fixed bug #1925 : Generic.Formatting.MultipleStatementAlignment skipping assignments within closures -- Fixed bug #1931 : Generic opening brace placement sniffs do not correctly support function return types -- Fixed bug #1932 : Generic.ControlStructures.InlineControlStructure fixer moves new PHPCS annotations -- Fixed bug #1938 : Generic opening brace placement sniffs incorrectly move PHPCS annotations +- Fixed bug [#1922][sq-1922] : Equal sign alignment check broken when list syntax used before assignment operator +- Fixed bug [#1925][sq-1925] : Generic.Formatting.MultipleStatementAlignment skipping assignments within closures +- Fixed bug [#1931][sq-1931] : Generic opening brace placement sniffs do not correctly support function return types +- Fixed bug [#1932][sq-1932] : Generic.ControlStructures.InlineControlStructure fixer moves new PHPCS annotations +- Fixed bug [#1938][sq-1938] : Generic opening brace placement sniffs incorrectly move PHPCS annotations - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1939 : phpcs:set annotations do not cause the line they are on to be ignored +- Fixed bug [#1939][sq-1939] : phpcs:set annotations do not cause the line they are on to be ignored - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1949 : Squiz.PHP.DisallowMultipleAssignments false positive when using namespaces with static assignments -- Fixed bug #1959 : SquizMultiLineFunctionDeclaration error when param has trailing comment +- Fixed bug [#1949][sq-1949] : Squiz.PHP.DisallowMultipleAssignments false positive when using namespaces with static assignments +- Fixed bug [#1959][sq-1959] : SquizMultiLineFunctionDeclaration error when param has trailing comment - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1963 : Squiz.Scope.MemberVarScope does not work for multiline member declaration +- Fixed bug [#1963][sq-1963] : Squiz.Scope.MemberVarScope does not work for multiline member declaration - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1971 : Short array list syntax not correctly tokenized if short array is the first content in a file -- Fixed bug #1979 : Tokenizer does not change heredoc to nowdoc token if the start tag contains spaces -- Fixed bug #1982 : Squiz.Arrays.ArrayDeclaration fixer sometimes puts a comma in front of the last array value -- Fixed bug #1993 : PSR1/PSR2 not reporting or fixing short open tags -- Fixed bug #1996 : Custom report paths don't work on case-sensitive filesystems -- Fixed bug #2006 : Squiz.Functions.FunctionDeclarationArgumentSpacing fixer removes comment between parens when no args +- Fixed bug [#1971][sq-1971] : Short array list syntax not correctly tokenized if short array is the first content in a file +- Fixed bug [#1979][sq-1979] : Tokenizer does not change heredoc to nowdoc token if the start tag contains spaces +- Fixed bug [#1982][sq-1982] : Squiz.Arrays.ArrayDeclaration fixer sometimes puts a comma in front of the last array value +- Fixed bug [#1993][sq-1993] : PSR1/PSR2 not reporting or fixing short open tags +- Fixed bug [#1996][sq-1996] : Custom report paths don't work on case-sensitive filesystems +- Fixed bug [#2006][sq-2006] : Squiz.Functions.FunctionDeclarationArgumentSpacing fixer removes comment between parens when no args - The SpacingAfterOpenHint error message has been removed - - It is replaced by the the existing SpacingAfterOpen message + - It is replaced by the existing SpacingAfterOpen message - The error message format for the SpacingAfterOpen and SpacingBeforeClose messages has been changed - These used to contain 3 pieces of data, but now only contain 2 - If you have customised the error messages of this sniff, please review your ruleset after upgrading -- Fixed bug #2018 : Generic.Formatting.MultipleStatementAlignment does see PHP close tag as end of statement block - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #2027 : PEAR.NamingConventions.ValidFunctionName error when function name includes double underscore - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2018][sq-2018] : Generic.Formatting.MultipleStatementAlignment does see PHP close tag as end of statement block + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#2027][sq-2027] : PEAR.NamingConventions.ValidFunctionName error when function name includes double underscore + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch + +[sq-1863]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1863 +[sq-1876]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1876 +[sq-1881]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1881 +[sq-1882]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1882 +[sq-1915]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1915 +[sq-1920]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1920 +[sq-1922]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1922 +[sq-1925]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1925 +[sq-1931]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1931 +[sq-1932]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1932 +[sq-1938]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1938 +[sq-1939]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1939 +[sq-1949]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1949 +[sq-1959]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1959 +[sq-1963]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1963 +[sq-1971]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1971 +[sq-1979]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1979 +[sq-1982]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1982 +[sq-1993]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1993 +[sq-1996]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1996 +[sq-2006]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2006 +[sq-2018]: https://github.com/squizlabs/PHP_CodeSniffer/pull/2018 +[sq-2027]: https://github.com/squizlabs/PHP_CodeSniffer/issues/2027 ## [3.2.3] - 2018-02-21 ### Changed @@ -1764,22 +2198,34 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed test suite compatibility with PHPUnit 7 -- Fixed bug #1793 : PSR2 forcing exact indent for function call opening statements -- Fixed bug #1803 : Squiz.WhiteSpace.ScopeKeywordSpacing removes member var name while fixing if no space after scope keyword -- Fixed bug #1817 : Blank line not enforced after control structure if comment on same line as closing brace -- Fixed bug #1827 : A phpcs:enable comment is not tokenized correctly if it is outside a phpcs:disable block - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1828 : Squiz.WhiteSpace.SuperfluousWhiteSpace ignoreBlankLines property ignores whitespace after single line comments - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1840 : When a comment has too many asterisks, phpcbf gives FAILED TO FIX error -- Fixed bug #1867 : Cant use phpcs:ignore where the next line is HTML -- Fixed bug #1870 : Invalid warning in multiple assignments alignment with closure or anon class -- Fixed bug #1890 : Incorrect Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose error between catch and finally statements -- Fixed bug #1891 : Comment on last USE statement causes false positive for PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse +- Fixed bug [#1793][sq-1793] : PSR2 forcing exact indent for function call opening statements +- Fixed bug [#1803][sq-1803] : Squiz.WhiteSpace.ScopeKeywordSpacing removes member var name while fixing if no space after scope keyword +- Fixed bug [#1817][sq-1817] : Blank line not enforced after control structure if comment on same line as closing brace +- Fixed bug [#1827][sq-1827] : A phpcs:enable comment is not tokenized correctly if it is outside a phpcs:disable block + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#1828][sq-1828] : Squiz.WhiteSpace.SuperfluousWhiteSpace ignoreBlankLines property ignores whitespace after single line comments + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#1840][sq-1840] : When a comment has too many asterisks, phpcbf gives FAILED TO FIX error +- Fixed bug [#1867][sq-1867] : Can't use phpcs:ignore where the next line is HTML +- Fixed bug [#1870][sq-1870] : Invalid warning in multiple assignments alignment with closure or anon class +- Fixed bug [#1890][sq-1890] : Incorrect Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose error between catch and finally statements +- Fixed bug [#1891][sq-1891] : Comment on last USE statement causes false positive for PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse - Thanks to [Matt Coleman][@iammattcoleman], [Daniel Hensby][@dhensby], and [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1901 : Fixed PHPCS annotations in multi-line tab-indented comments + not ignoring whole line for phpcs:set +- Fixed bug [#1901][sq-1901] : Fixed PHPCS annotations in multi-line tab-indented comments + not ignoring whole line for phpcs:set - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[sq-1793]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1793 +[sq-1803]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1803 +[sq-1817]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1817 +[sq-1827]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1827 +[sq-1828]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1828 +[sq-1840]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1840 +[sq-1867]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1867 +[sq-1870]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1870 +[sq-1890]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1890 +[sq-1891]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1891 +[sq-1901]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1901 + ## [3.2.2] - 2017-12-20 ### Changed - Disabled STDIN detection on Windows @@ -1787,7 +2233,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ## [3.2.1] - 2017-12-18 ### Changed -- Empty diffs are no longer followed by a newline character (request #1781) +- 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 - This makes the sniff more useful when used in templates - Thanks to [Joseph Zidell][@josephzidell] for the patch @@ -1795,7 +2241,10 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed problems with some scripts and plugins waiting for STDIN - This was a notable problem with IDE plugins (e.g., PHPStorm) and build systems -- Fixed bug #1782 : Incorrect detection of operator in ternary + anonymous function +- Fixed bug [#1782][sq-1782] : Incorrect detection of operator in ternary + anonymous function + +[sq-1781]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1781 +[sq-1782]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1782 ## [3.2.0] - 2017-12-13 ### Deprecated @@ -1818,7 +2267,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - phpcs:set has the token T_PHPCS_SET ### Changed -- The phpcs:disable and phpcs:ignore comments can now selectively ignore specific sniffs (request #604) +- The phpcs:disable and phpcs:ignore comments can now selectively ignore specific sniffs (request [#604][sq-604]) - E.g., phpcs:disable Generic.Commenting.Todo.Found for a specific message - E.g., phpcs:disable Generic.Commenting.Todo for a whole sniff - E.g., phpcs:disable Generic.Commenting for a whole category of sniffs @@ -1840,7 +2289,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added phpcs.xsd to allow validation of ruleset XML files - Thanks to [Renaat De Muynck][@renaatdemuynck] for the contribution -- File paths specified using --stdin-path can now point to fake file locations (request #1488) +- File paths specified using --stdin-path can now point to fake file locations (request [#1488][sq-1488]) - Previously, STDIN files using fake file paths were excluded from checking - Setting an empty basepath (--basepath=) on the CLI will now clear a basepath set directly in a ruleset - Thanks to [Xaver Loppenstedt][@xalopp] for the patch @@ -1901,23 +2350,41 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed -- Fixed bug #1462 : Error processing cyrillic strings in Tokenizer -- Fixed bug #1573 : Squiz.WhiteSpace.LanguageConstructSpacing does not properly check for tabs and newlines +- Fixed bug [#1462][sq-1462] : Error processing cyrillic strings in Tokenizer +- Fixed bug [#1573][sq-1573] : Squiz.WhiteSpace.LanguageConstructSpacing does not properly check for tabs and newlines - Thanks to [Michał Bundyra][@michalbundyra] for the patch -- Fixed bug #1590 : InlineControlStructure CBF issue while adding braces to an if thats returning a nested function -- Fixed bug #1718 : Unclosed strings at EOF sometimes tokenized as T_WHITESPACE by the JS tokenizer -- Fixed bug #1731 : Directory exclusions do not work as expected when a single file name is passed to phpcs -- Fixed bug #1737 : Squiz.CSS.EmptyStyleDefinition sees comment as style definition and fails to report error -- Fixed bug #1746 : Very large reports can sometimes become garbled when using the parallel option -- Fixed bug #1747 : Squiz.Scope.StaticThisUsage incorrectly looking inside closures -- Fixed bug #1757 : Unknown type hint "object" in Squiz.Commenting.FunctionComment -- Fixed bug #1758 : PHPCS gets stuck creating file list when processing circular symlinks -- Fixed bug #1761 : Generic.WhiteSpace.ScopeIndent error on multi-line function call with static closure argument -- Fixed bug #1762 : Generic.WhiteSpace.Disallow[Space/Tab]Indent not inspecting content before open tag - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1769 : Custom "define" function triggers a warning about declaring new symbols -- Fixed bug #1776 : Squiz.Scope.StaticThisUsage incorrectly looking inside anon classes -- Fixed bug #1777 : Generic.WhiteSpace.ScopeIndent incorrect indent errors when self called function proceeded by comment +- Fixed bug [#1590][sq-1590] : InlineControlStructure CBF issue while adding braces to an if that's returning a nested function +- Fixed bug [#1718][sq-1718] : Unclosed strings at EOF sometimes tokenized as T_WHITESPACE by the JS tokenizer +- Fixed bug [#1731][sq-1731] : Directory exclusions do not work as expected when a single file name is passed to phpcs +- Fixed bug [#1737][sq-1737] : Squiz.CSS.EmptyStyleDefinition sees comment as style definition and fails to report error +- Fixed bug [#1746][sq-1746] : Very large reports can sometimes become garbled when using the parallel option +- Fixed bug [#1747][sq-1747] : Squiz.Scope.StaticThisUsage incorrectly looking inside closures +- 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 + - 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 +- Fixed bug [#1777][sq-1777] : Generic.WhiteSpace.ScopeIndent incorrect indent errors when self called function proceeded by comment + +[sq-604]: https://github.com/squizlabs/PHP_CodeSniffer/issues/604 +[sq-1462]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1462 +[sq-1488]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1488 +[sq-1573]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1573 +[sq-1590]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1590 +[sq-1718]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1718 +[sq-1731]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1731 +[sq-1737]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1737 +[sq-1746]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1746 +[sq-1747]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1747 +[sq-1757]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1757 +[sq-1758]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1758 +[sq-1761]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1761 +[sq-1762]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1762 +[sq-1769]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1769 +[sq-1776]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1776 +[sq-1777]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1777 ## [3.1.1] - 2017-10-17 ### Changed @@ -1925,27 +2392,40 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - The order that the files are searched is now: .phpcs.xml, phpcs.xml, .phpcs.xml.dist, phpcs.xml.dist - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Progress output now correctly shows skipped files -- Progress output now shows 100% when the file list has finished processing (request #1697) +- Progress output now shows 100% when the file list has finished processing (request [#1697][sq-1697]) - Stopped some IDEs complaining about testing class aliases - Thanks to [Vytautas Stankus][@svycka] for the patch - Squiz.Commenting.InlineComment incorrectly identified comment blocks in some cases, muting some errors - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch ### Fixed -- Fixed bug #1512 : PEAR.Functions.FunctionCallSignature enforces spaces when no arguments if required spaces is not 0 -- Fixed bug #1522 : Squiz Arrays.ArrayDeclaration and Strings.ConcatenationSpacing fixers causing parse errors with here/ nowdocs -- Fixed bug #1570 : Squiz.Arrays.ArrayDeclaration fixer removes comments between array keyword and open parentheses -- Fixed bug #1604 : File::isReference has problems with some bitwise operators and class property references - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1645 : Squiz.Commenting.InlineComment will fail to fix comments at the end of the file - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1656 : Using the --sniffs argument has a problem with case sensitivity -- Fixed bug #1657 : Uninitialized string offset: 0 when sniffing CSS -- Fixed bug #1669 : Temporary expression proceeded by curly brace is detected as function call -- Fixed bug #1681 : Huge arrays are super slow to scan with Squiz.Arrays.ArrayDeclaration sniff -- Fixed bug #1694 : Squiz.Arrays.ArrayBracketSpacing is removing some comments during fixing - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1702 : Generic.WhiteSpaceDisallowSpaceIndent fixer bug when line only contains superfluous whitespace +- Fixed bug [#1512][sq-1512] : PEAR.Functions.FunctionCallSignature enforces spaces when no arguments if required spaces is not 0 +- Fixed bug [#1522][sq-1522] : Squiz Arrays.ArrayDeclaration and Strings.ConcatenationSpacing fixers causing parse errors with here/nowdocs +- Fixed bug [#1570][sq-1570] : Squiz.Arrays.ArrayDeclaration fixer removes comments between array keyword and open parentheses +- Fixed bug [#1604][sq-1604] : File::isReference has problems with some bitwise operators and class property references + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#1645][sq-1645] : Squiz.Commenting.InlineComment will fail to fix comments at the end of the file + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#1656][sq-1656] : Using the --sniffs argument has a problem with case sensitivity +- Fixed bug [#1657][sq-1657] : Uninitialized string offset: 0 when sniffing CSS +- Fixed bug [#1669][sq-1669] : Temporary expression proceeded by curly brace is detected as function call +- Fixed bug [#1681][sq-1681] : Huge arrays are super slow to scan with Squiz.Arrays.ArrayDeclaration sniff +- Fixed bug [#1694][sq-1694] : Squiz.Arrays.ArrayBracketSpacing is removing some comments during fixing + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#1702][sq-1702] : Generic.WhiteSpaceDisallowSpaceIndent fixer bug when line only contains superfluous whitespace + +[sq-1512]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1512 +[sq-1522]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1522 +[sq-1570]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1570 +[sq-1604]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1604 +[sq-1645]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1645 +[sq-1656]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1656 +[sq-1657]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1657 +[sq-1669]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1669 +[sq-1681]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1681 +[sq-1694]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1694 +[sq-1697]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1697 +[sq-1702]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1702 ## [3.1.0] - 2017-09-20 ### Changed @@ -1959,7 +2439,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - A phpcs.xml or phpcs.xml.dist file now takes precedence over the default_standard config setting - Thanks to [Björn Fischer][@Fischer-Bjoern] for the patch -- Both phpcs.xml and phpcs.xml.dist files can now be prefixed with a dot (request #1566) +- Both phpcs.xml and phpcs.xml.dist files can now be prefixed with a dot (request [#1566][sq-1566]) - The order that the files are searched is: .phpcs.xml, .phpcs.xml.dist, phpcs.xml, phpcs.xml.dist - The autoloader will now search for files during unit tests runs from the same locations as during normal phpcs runs - Allows for easier unit testing of custom standards that use helper classes or custom namespaces @@ -1981,7 +2461,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Added Generic.Files.OneObjectStructurePerFile sniff to ensure there is a single class/interface/trait per file - Thanks to [Mponos George][@gmponos] for the contribution - Function call sniffs now check variable function names and self/static object creation - - Specific sniffs are Generic.Functions.FunctionCallArgumentSpacing, PEAR.Functions.FunctionCallSignature, and PSR2.Methods.FunctionCallSignature + - Specific sniffs are Generic.Functions.FunctionCallArgumentSpacing, PEAR.Functions.FunctionCallSignature, and PSR2.Methods.FunctionCallSignature - Thanks to [Michał Bundyra][@michalbundyra] for the patch - Generic.Files.LineLength can now be configured to ignore all comment lines, no matter their length - Set the ignoreComments property to TRUE (default is FALSE) in your ruleset.xml file to enable this @@ -2010,22 +2490,33 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Martin Hujer][@mhujer] for the patch ### Fixed -- Fixed bug #1550 : Squiz.Commenting.FunctionComment false positive when function contains closure -- Fixed bug #1577 : Generic.InlineControlStructureSniff breaks with a comment between body and condition in do while loops -- Fixed bug #1581 : Sniffs not loaded when one-standard directories are being registered in installed_paths -- Fixed bug #1591 : Autoloader failing to load arbitrary files when installed_paths only set via a custom ruleset -- Fixed bug #1605 : Squiz.WhiteSpace.OperatorSpacing false positive on unary minus after comment - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1615 : Uncaught RuntimeException when phpcbf fails to fix files -- Fixed bug #1637 : Generic.WhiteSpaceScopeIndent closure argument indenting incorrect with multi-line strings -- Fixed bug #1638 : Squiz.WhiteSpace.ScopeClosingBrace closure argument indenting incorrect with multi-line strings -- Fixed bug #1640 : Squiz.Strings.DoubleQuoteUsage replaces tabs with spaces when fixing - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#1550][sq-1550] : Squiz.Commenting.FunctionComment false positive when function contains closure +- Fixed bug [#1577][sq-1577] : Generic.InlineControlStructureSniff breaks with a comment between body and condition in do while loops +- Fixed bug [#1581][sq-1581] : Sniffs not loaded when one-standard directories are being registered in installed_paths +- Fixed bug [#1591][sq-1591] : Autoloader failing to load arbitrary files when installed_paths only set via a custom ruleset +- Fixed bug [#1605][sq-1605] : Squiz.WhiteSpace.OperatorSpacing false positive on unary minus after comment + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#1615][sq-1615] : Uncaught RuntimeException when phpcbf fails to fix files +- Fixed bug [#1637][sq-1637] : Generic.WhiteSpaceScopeIndent closure argument indenting incorrect with multi-line strings +- Fixed bug [#1638][sq-1638] : Squiz.WhiteSpace.ScopeClosingBrace closure argument indenting incorrect with multi-line strings +- Fixed bug [#1640][sq-1640] : Squiz.Strings.DoubleQuoteUsage replaces tabs with spaces when fixing + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch + +[sq-1550]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1550 +[sq-1566]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1566 +[sq-1577]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1577 +[sq-1581]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1581 +[sq-1591]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1591 +[sq-1605]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1605 +[sq-1615]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1615 +[sq-1637]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1637 +[sq-1638]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1638 +[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 and now the only places that exit() in the code +- The phpcs and phpcbf scripts are now the only places that exit() in the code - This allows for easier usage of core PHPCS functions from external scripts - If you are calling Runner::runPHPCS() or Runner::runPHPCBF() directly, you will get back the full range of exit codes - If not, catch the new DeepExitException to get the error message ($e->getMessage()) and exit code ($e->getCode()); @@ -2040,20 +2531,31 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed a problem where the source report was not printing the correct number of errors found - Fixed a problem where the --cache=/path/to/cachefile CLI argument was not working -- Fixed bug #1465 : Generic.WhiteSpace.ScopeIndent reports incorrect errors when indenting double arrows in short arrays -- Fixed bug #1478 : Indentation in fallthrough CASE that contains a closure -- Fixed bug #1497 : Fatal error if composer prepend-autoloader is set to false +- Fixed bug [#1465][sq-1465] : Generic.WhiteSpace.ScopeIndent reports incorrect errors when indenting double arrows in short arrays +- Fixed bug [#1478][sq-1478] : Indentation in fallthrough CASE that contains a closure +- Fixed bug [#1497][sq-1497] : Fatal error if composer prepend-autoloader is set to false - Thanks to [Kunal Mehta][@legoktm] for the patch -- Fixed bug #1503 : Alternative control structure syntax not always recognized as scoped -- Fixed bug #1523 : Fatal error when using the --suffix argument +- Fixed bug [#1503][sq-1503] : Alternative control structure syntax not always recognized as scoped +- Fixed bug [#1523][sq-1523] : Fatal error when using the --suffix argument - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1526 : Use of basepath setting can stop PHPCBF being able to write fixed files -- Fixed bug #1530 : Generic.WhiteSpace.ScopeIndent can increase indent too much for lines within code blocks -- Fixed bug #1547 : Wrong token type for backslash in use function +- Fixed bug [#1526][sq-1526] : Use of basepath setting can stop PHPCBF being able to write fixed files +- Fixed bug [#1530][sq-1530] : Generic.WhiteSpace.ScopeIndent can increase indent too much for lines within code blocks +- Fixed bug [#1547][sq-1547] : Wrong token type for backslash in use function - Thanks to [Michał Bundyra][@michalbundyra] for the patch -- Fixed bug #1549 : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag +- Fixed bug [#1549][sq-1549] : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1560 : Squiz.Commenting.FunctionComment fatal error when fixing additional param comment lines that have no indent +- Fixed bug [#1560][sq-1560] : Squiz.Commenting.FunctionComment fatal error when fixing additional param comment lines that have no indent + +[sq-1465]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1465 +[sq-1478]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1478 +[sq-1497]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1497 +[sq-1503]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1503 +[sq-1523]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1523 +[sq-1526]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1526 +[sq-1530]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1530 +[sq-1547]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1547 +[sq-1549]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1549 +[sq-1560]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1560 ## [3.0.1] - 2017-06-14 ### Security @@ -2072,7 +2574,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - PHPCS now stops looking for a phpcs.xml file as soon as one is found, favoring the closest one to the current dir - Added missing help text for the --stdin-path CLI option to --help - Re-added missing help text for the --file-list and --bootstrap CLI options to --help -- Runner::runPHPCS() and Runner::runPHPCBF() now return an exit code instead of exiting directly (request #1484) +- Runner::runPHPCS() and Runner::runPHPCBF() now return an exit code instead of exiting directly (request [#1484][sq-1484]) - The Squiz standard now enforces short array syntax by default - The autoloader is now working correctly with classes created with class_alias() - The autoloader will now search for files inside all directories in the installed_paths config var @@ -2093,34 +2595,49 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed a problem where excluding a message from a custom standard's own sniff would exclude the whole sniff - This caused some PSR2 errors to be under-reported -- Fixed bug #1442 : T_NULLABLE detection not working for nullable parameters and return type hints in some cases -- Fixed bug #1447 : Running the unit tests with a phpunit config file breaks the test suite +- 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 - Unknown arguments were not being handled correctly, but are now stored in $config->unknown -- Fixed bug #1449 : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace +- Fixed bug [#1449][sq-1449] : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1450 : Coding standard located under an installed_path with the same directory name throws an error +- Fixed bug [#1450][sq-1450] : Coding standard located under an installed_path with the same directory name throws an error - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1451 : Sniff exclusions/restrictions dont work with custom sniffs unless they use the PHP_CodeSniffer NS -- Fixed bug #1454 : Squiz.WhiteSpace.OperatorSpacing is not checking spacing on either side of a short ternary operator +- Fixed bug [#1451][sq-1451] : Sniff exclusions/restrictions don't work with custom sniffs unless they use the PHP_CodeSniffer NS +- Fixed bug [#1454][sq-1454] : Squiz.WhiteSpace.OperatorSpacing is not checking spacing on either side of a short ternary operator - Thanks to [Mponos George][@gmponos] for the patch -- Fixed bug #1495 : Setting an invalid installed path breaks all commands -- Fixed bug #1496 : Squiz.Strings.DoubleQuoteUsage not unescaping dollar sign when fixing +- Fixed bug [#1495][sq-1495] : Setting an invalid installed path breaks all commands +- Fixed bug [#1496][sq-1496] : Squiz.Strings.DoubleQuoteUsage not unescaping dollar sign when fixing - Thanks to [Michał Bundyra][@michalbundyra] for the patch -- Fixed bug #1501 : Interactive mode is broken -- Fixed bug #1504 : PSR2.Namespaces.UseDeclaration hangs fixing use statement with no trailing code +- 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 +[sq-1451]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1451 +[sq-1454]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1454 +[sq-1484]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1484 +[sq-1495]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1495 +[sq-1496]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1496 +[sq-1501]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1501 +[sq-1504]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1504 ## [2.9.1] - 2017-05-22 ### Fixed -- Fixed bug #1442 : T_NULLABLE detection not working for nullable parameters and return type hints in some cases -- Fixed bug #1448 : Generic.Classes.OpeningBraceSameLine doesn't detect comment before opening brace +- 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 - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +[sq-1442]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1442 +[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) +- 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 - - Also stop files being able to change sniff properties mid way through processing -- An error is now reported if no sniffs were registered to be run (request #1129) + - Also stop files being able to change sniff properties midway through processing +- An error is now reported if no sniffs were registered to be run (request [#1129][sq-1129]) - The autoloader will now search for files inside the directory of any loaded coding standard - This allows autoloading of any file inside a custom coding standard without manually requiring them - Ensure your namespace begins with your coding standard's directory name and follows PSR-4 @@ -2135,9 +2652,13 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Includes all changes from the 2.9.0 release ### Fixed -- Fixed bug #834 : PSR2.ControlStructures.SwitchDeclaration does not handle if branches with returns +- Fixed bug [#834][sq-834] : PSR2.ControlStructures.SwitchDeclaration does not handle if branches with returns - Thanks to [Fabian Wiget][@fabacino] for the patch +[sq-811]: https://github.com/squizlabs/PHP_CodeSniffer/issues/811 +[sq-834]: https://github.com/squizlabs/PHP_CodeSniffer/issues/834 +[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 @@ -2168,20 +2689,23 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Includes all changes from the 2.8.1 release ### Fixed -- Fixed bug #1333 : The new autoloader breaks some frameworks with custom autoloaders -- Fixed bug #1334 : Undefined offset when explaining standard with custom sniffs +- Fixed bug [#1333][sq-1333] : The new autoloader breaks some frameworks with custom autoloaders +- Fixed bug [#1334][sq-1334] : Undefined offset when explaining standard with custom sniffs + +[sq-1333]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1333 +[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 - Added support for ES6 method declarations, where the "function" keyword is not used - - Previously, these methods were tokenized as JS objects (fixes bug #1251) + - Previously, these methods were tokenized as JS objects (fixes bug [#1251][sq-1251]) - The name of the ES6 method is now assigned the T_FUNCTION keyword and treated like a normal function - - Custom sniffs that support JS and listen for T_FUNCTION tokens can't assume the token represents the word "function" + - Custom sniffs that support JS and listen for T_FUNCTION tokens can't assume the token represents the word "function" - Check the contents of the token first, or use $phpcsFile->getDeclarationName($stackPtr) if you just want its name - There is no change for custom sniffs that only check PHP code -- PHPCBF exit codes have been changed so they are now more useful (request #1270) +- PHPCBF exit codes have been changed so they are now more useful (request [#1270][sq-1270]) - Exit code 0 is now used to indicate that no fixable errors were found, and so nothing was fixed - Exit code 1 is now used to indicate that all fixable errors were fixed correctly - Exit code 2 is now used to indicate that PHPCBF failed to fix some of the fixable errors it found @@ -2193,26 +2717,35 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Fixed an issue where excluding a file using a @codingStandardsIgnoreFile comment would produce errors - For PHPCS, it would show empty files being processed - For PHPCBF, it would produce a PHP error -- Fixed bug #1233 : Can't set config data inside ruleset.xml file -- Fixed bug #1241 : CodeSniffer.conf not working with 3.x PHAR file +- Fixed bug [#1233][sq-1233] : Can't set config data inside ruleset.xml file +- Fixed bug [#1241][sq-1241] : CodeSniffer.conf not working with 3.x PHAR file + +[sq-1233]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1233 +[sq-1241]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1241 +[sq-1251]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1251 +[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) +- Full usage information is no longer printed when a usage error is encountered (request [#1186][sq-1186]) - Makes it a lot easier to find and read the error message that was printed - Includes all changes from the 2.7.1 release ### Fixed - Fixed an undefined var name error that could be produced while running PHPCBF -- Fixed bug #1167 : 3.0.0RC1 PHAR does not work with PEAR standard -- Fixed bug #1208 : Excluding files doesn't work when using STDIN with a filename specified +- Fixed bug [#1167][sq-1167] : 3.0.0RC1 PHAR does not work with PEAR standard +- Fixed bug [#1208][sq-1208] : Excluding files doesn't work when using STDIN with a filename specified + +[sq-1167]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1167 +[sq-1186]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1186 +[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 -- PHPCBF no longer produces verbose output by default (request #699) +- PHPCBF no longer produces verbose output by default (request [#699][sq-699]) - Use the -v command line argument to show verbose fixing output - Use the -q command line argument to disable verbose information if enabled by default - PHPBF now prints a summary report after fixing files @@ -2227,24 +2760,26 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo ### Fixed - Fixed shell error appearing on some systems when trying to find executable paths +[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) +- Added optional caching of results between runs (request [#530][sq-530]) - Enable the cache by using the --cache command line argument - If you want the cache file written somewhere specific, use --cache=/path/to/cacheFile - Use the command "phpcs --config-set cache true" to turn caching on by default - Use the --no-cache command line argument to disable caching if it is being turned on automatically -- Add support for checking file in parallel (request #421) +- Add support for checking file in parallel (request [#421][sq-421]) - Tell PHPCS how many files to check at once using the --parallel command line argument - To check 100 files at once, using --parallel=100 - To disable parallel checking if it is being turned on automatically, use --parallel=1 - Requires PHP to be compiled with the PCNTL package -- The default encoding has been changed from iso-8859-1 to utf-8 (request #760) +- The default encoding has been changed from iso-8859-1 to utf-8 (request [#760][sq-760]) - The --encoding command line argument still works, but you no longer have to set it to process files as utf-8 - If encoding is being set to utf-8 in a ruleset or on the CLI, it can be safely removed - If the iconv PHP extension is not installed, standard non-multibyte aware functions will be used -- Added a new "code" report type to show a code snippet for each error (request #419) +- Added a new "code" report type to show a code snippet for each error (request [#419][sq-419]) - The line containing the error is printed, along with 2 lines above and below it to show context - The location of the errors is underlined in the code snippet if you also use --colors - Use --report=code to generate this report @@ -2257,7 +2792,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Added support for only checking files that have been locally modified or added in a git repo - Use --filter=gitmodified to check these files - You still need to give PHPCS a list of files or directories in which to check -- Added automatic discovery of executable paths (request #571) +- Added automatic discovery of executable paths (request [#571][sq-571]) - Thanks to [Sergei Morozov][@morozov] for the patch - You must now pass "-" on the command line to have PHPCS wait for STDIN - E.g., phpcs --standard=PSR2 - @@ -2267,14 +2802,14 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - This should stop bugs inside sniffs causing infinite loops - Also stops invalid reports being produced as errors don't print to the screen directly - Sniff codes are no longer optional - - If a sniff throws and error or a warning, it must specify an internal code for that message + - If a sniff throws an error or a warning, it must specify an internal code for that message - The installed_paths config setting can now point directly to a standard - Previously, it had to always point to the directory in which the standard lives - Multiple reports can now be specified using the --report command line argument - Report types are separated by commas - E.g., --report=full,summary,info - Previously, you had to use one argument for each report such as --report=full --report=summary --report=info -- You can now set the severity, message type, and exclude patterns for and entire sniff, category, or standard +- You can now set the severity, message type, and exclude patterns for an entire sniff, category, or standard - Previously, this was only available for a single message - You can now include a single sniff code in a ruleset instead of having to include an entire sniff - Including a sniff code will automatically exclude all other messages from that sniff @@ -2282,17 +2817,17 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - PHPCBF no longer uses patch - Files are now always overwritten - The --no-patch option has been removed -- Added a --basepath option to strip a directory from the front of file paths in output (request #470) +- Added a --basepath option to strip a directory from the front of file paths in output (request [#470][sq-470]) - The basepath is absolute or relative to the current directory - E.g., to output paths relative to current dir in reports, use --basepath=. -- Ignore rules are now checked when using STDIN (request #733) -- Added an include-pattern tag to rulesets to include a sniff for specific files and folders only (request #656) +- Ignore rules are now checked when using STDIN (request [#733][sq-733]) +- Added an include-pattern tag to rulesets to include a sniff for specific files and folders only (request [#656][sq-656]) - This is the exact opposite of the exclude-pattern tag - This option is only usable within sniffs, not globally like exclude-patterns are - Added a new -m option to stop error messages from being recorded, which saves a lot of memory - PHPCBF always uses this setting to reduce memory as it never outputs error messages - Setting the $recordErrors member var inside custom report classes is no longer supported (use -m instead) -- Exit code 2 is now used to indicate fixable errors were found (request #930) +- Exit code 2 is now used to indicate fixable errors were found (request [#930][sq-930]) - Exit code 3 is now used for general script execution errors - Exit code 1 is used to indicate that coding standard errors were found, but none are fixable - Exit code 0 is unchanged and continues to mean no coding standard errors found @@ -2304,6 +2839,16 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - The included SVN pre-commit hook has been removed - Hooks for version control systems will no longer be maintained within the PHPCS project +[sq-419]: https://github.com/squizlabs/PHP_CodeSniffer/issues/419 +[sq-421]: https://github.com/squizlabs/PHP_CodeSniffer/issues/421 +[sq-470]: https://github.com/squizlabs/PHP_CodeSniffer/issues/470 +[sq-530]: https://github.com/squizlabs/PHP_CodeSniffer/issues/530 +[sq-571]: https://github.com/squizlabs/PHP_CodeSniffer/pull/571 +[sq-656]: https://github.com/squizlabs/PHP_CodeSniffer/issues/656 +[sq-733]: https://github.com/squizlabs/PHP_CodeSniffer/issues/733 +[sq-760]: https://github.com/squizlabs/PHP_CodeSniffer/issues/760 +[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 @@ -2320,7 +2865,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - PEAR.Commenting.ClassComment now supports checking of traits as well as classes and interfaces - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Squiz.Commenting.FunctionCommentThrowTag now supports re-throwing exceptions (request #946) +- Squiz.Commenting.FunctionCommentThrowTag now supports re-throwing exceptions (request [#946][sq-946]) - Thanks to [Samuel Levy][@samlev] for the patch - Squiz.PHP.DisallowMultipleAssignments now ignores PHP4-style member var assignments - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -2331,20 +2876,33 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Added missing error codes for a couple of sniffs so they can now be customised as normal ### Fixed -- Fixed bug #1266 : PEAR.WhiteSpace.ScopeClosingBrace can throw an error while fixing mixed PHP/HTML -- Fixed bug #1364 : Yield From values are not recognised as returned values in Squiz FunctionComment sniff -- Fixed bug #1373 : Error in tab expansion results in white-space of incorrect size +- Fixed bug [#1266][sq-1266] : PEAR.WhiteSpace.ScopeClosingBrace can throw an error while fixing mixed PHP/HTML +- Fixed bug [#1364][sq-1364] : Yield From values are not recognised as returned values in Squiz FunctionComment sniff +- Fixed bug [#1373][sq-1373] : Error in tab expansion results in white-space of incorrect size - Thanks to [Mark Clements][@MarkMaldaba] for the patch -- Fixed bug #1381 : Tokenizer: dereferencing incorrectly identified as short array -- Fixed bug #1387 : Squiz.ControlStructures.ControlSignature does not handle alt syntax when checking space after closing brace -- Fixed bug #1392 : Scope indent calculated incorrectly when using array destructuring -- Fixed bug #1394 : integer type hints appearing as TypeHintMissing instead of ScalarTypeHintMissing +- Fixed bug [#1381][sq-1381] : Tokenizer: dereferencing incorrectly identified as short array +- Fixed bug [#1387][sq-1387] : Squiz.ControlStructures.ControlSignature does not handle alt syntax when checking space after closing brace +- Fixed bug [#1392][sq-1392] : Scope indent calculated incorrectly when using array destructuring +- Fixed bug [#1394][sq-1394] : integer type hints appearing as TypeHintMissing instead of ScalarTypeHintMissing - PHP 7 type hints were also being shown when run under PHP 5 in some cases -- Fixed bug #1405 : Squiz.WhiteSpace.ScopeClosingBrace fails to fix closing brace within indented PHP tags -- Fixed bug #1421 : Ternaries used in constant scalar expression for param default misidentified by tokenizer -- Fixed bug #1431 : PHPCBF can't fix short open tags when they are not followed by a space +- Fixed bug [#1405][sq-1405] : Squiz.WhiteSpace.ScopeClosingBrace fails to fix closing brace within indented PHP tags +- Fixed bug [#1421][sq-1421] : Ternaries used in constant scalar expression for param default misidentified by tokenizer +- Fixed bug [#1431][sq-1431] : PHPCBF can't fix short open tags when they are not followed by a space - Thanks to [Gonçalo Queirós][@ghunti] for the patch -- Fixed bug #1432 : PHPCBF can make invalid fixes to inline JS control structures that make use of JS objects +- Fixed bug [#1432][sq-1432] : PHPCBF can make invalid fixes to inline JS control structures that make use of JS objects + +[sq-946]: https://github.com/squizlabs/PHP_CodeSniffer/pull/946 +[sq-1266]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1266 +[sq-1364]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1364 +[sq-1373]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1373 +[sq-1381]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1381 +[sq-1387]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1387 +[sq-1392]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1392 +[sq-1394]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1394 +[sq-1405]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1405 +[sq-1421]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1421 +[sq-1431]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1431 +[sq-1432]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1432 ## [2.8.1] - 2017-03-02 ### Security @@ -2382,15 +2940,22 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz.ControlStructures.InlineIfDeclaration is now able to fix the spacing errors it reports ### Fixed -- Fixed bug #1340 : STDIN file contents not being populated in some cases +- Fixed bug [#1340][sq-1340] : STDIN file contents not being populated in some cases - Thanks to [David Biňovec][@david-binda] for the patch -- Fixed bug #1344 : PEAR.Functions.FunctionCallSignatureSniff throws error for blank comment lines -- Fixed bug #1347 : PSR2.Methods.FunctionCallSignature strips some comments during fixing +- Fixed bug [#1344][sq-1344] : PEAR.Functions.FunctionCallSignatureSniff throws error for blank comment lines +- Fixed bug [#1347][sq-1347] : PSR2.Methods.FunctionCallSignature strips some comments during fixing - Thanks to [Algirdas Gurevicius][@uniquexor] for the patch -- Fixed bug #1349 : Squiz.Strings.DoubleQuoteUsage.NotRequired message is badly formatted when string contains a CR newline char +- Fixed bug [#1349][sq-1349] : Squiz.Strings.DoubleQuoteUsage.NotRequired message is badly formatted when string contains a CR newline char - Thanks to [Algirdas Gurevicius][@uniquexor] for the patch -- Fixed bug #1350 : Invalid Squiz.Formatting.OperatorBracket error when using namespaces -- Fixed bug #1369 : Empty line in multi-line function declaration cause infinite loop +- Fixed bug [#1350][sq-1350] : Invalid Squiz.Formatting.OperatorBracket error when using namespaces +- Fixed bug [#1369][sq-1369] : Empty line in multi-line function declaration cause infinite loop + +[sq-1340]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1340 +[sq-1344]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1344 +[sq-1347]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1347 +[sq-1349]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1349 +[sq-1350]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1350 +[sq-1369]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1369 ## [2.8.0] - 2017-02-02 ### Changed @@ -2406,13 +2971,13 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - The getMethodParameters() method now supports closures - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Added more guard code for JS files with syntax errors (request #1271 and request #1272) -- Added more guard code for CSS files with syntax errors (request #1304) +- Added more guard code for JS files with syntax errors (request [#1271][sq-1271] and request [#1272][sq-1272]) +- Added more guard code for CSS files with syntax errors (request [#1304][sq-1304]) - PEAR.Commenting.FunctionComment fixers now correctly handle multi-line param comments - AbstractVariableSniff now supports anonymous classes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.NamingConventions.ConstructorName and PEAR.NamingConventions.ValidVariable now support anonymous classes -- Generic.NamingConventions.CamelCapsFunctionName and PEAR.NamingConventions.ValidFunctionName now support anonymous classes +- Generic.NamingConventions.CamelCapsFunctionName and PEAR.NamingConventions.ValidFunctionName now support anonymous classes - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Generic.CodeAnalysis.UnusedFunctionParameter and PEAR.Functions.ValidDefaultValue now support closures - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch @@ -2427,30 +2992,52 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Algirdas Gurevicius][@uniquexor] for the patch ### Fixed -- Fixed bug #1230 : JS tokeniser incorrectly tokenises bitwise shifts as comparison +- Fixed bug [#1230][sq-1230] : JS tokeniser incorrectly tokenises bitwise shifts as comparison - Thanks to [Ryan McCue][@rmccue] for the patch -- Fixed bug #1237 : Uninitialized string offset in PHP Tokenizer on PHP 5.2 -- Fixed bug #1239 : Warning when static method name is 'default' -- Fixed bug #1240 : False positive for function names starting with triple underscore +- Fixed bug [#1237][sq-1237] : Uninitialized string offset in PHP Tokenizer on PHP 5.2 +- Fixed bug [#1239][sq-1239] : Warning when static method name is 'default' +- Fixed bug [#1240][sq-1240] : False positive for function names starting with triple underscore - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1245 : SELF is not recognised as T_SELF token in: return new self -- Fixed bug #1246 : A mix of USE statements with and without braces can cause the tokenizer to mismatch brace tokens +- Fixed bug [#1245][sq-1245] : SELF is not recognised as T_SELF token in: return new self +- Fixed bug [#1246][sq-1246] : A mix of USE statements with and without braces can cause the tokenizer to mismatch brace tokens - Thanks to [Michał Bundyra][@michalbundyra] for the patch -- Fixed bug #1249 : GitBlame report requires a .git directory -- Fixed bug #1252 : Squiz.Strings.ConcatenationSpacing fix creates syntax error when joining a number to a string -- Fixed bug #1253 : Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch -- Fixed bug #1255 : Inconsistent indentation check results when ELSE on new line -- Fixed bug #1257 : Double dash in CSS class name can lead to "Named colours are forbidden" false positives -- Fixed bug #1260 : Syntax errors not being shown when error_prepend_string is set - - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Fixed bug #1264 : Array return type hint is sometimes detected as T_ARRAY_HINT instead of T_RETURN_TYPE +- Fixed bug [#1249][sq-1249] : GitBlame report requires a .git directory +- Fixed bug [#1252][sq-1252] : Squiz.Strings.ConcatenationSpacing fix creates syntax error when joining a number to a string +- Fixed bug [#1253][sq-1253] : Generic.ControlStructures.InlineControlStructure fix creates syntax error fixing if-try/catch +- Fixed bug [#1255][sq-1255] : Inconsistent indentation check results when ELSE on new line +- Fixed bug [#1257][sq-1257] : Double dash in CSS class name can lead to "Named colours are forbidden" false positives +- Fixed bug [#1260][sq-1260] : Syntax errors not being shown when error_prepend_string is set + - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch +- Fixed bug [#1264][sq-1264] : Array return type hint is sometimes detected as T_ARRAY_HINT instead of T_RETURN_TYPE - Thanks to [Jaroslav Hanslík][@kukulich] for the patch -- Fixed bug #1265 : ES6 arrow function raises unexpected operator spacing errors -- Fixed bug #1267 : Fixer incorrectly handles filepaths with repeated dir names +- Fixed bug [#1265][sq-1265] : ES6 arrow function raises unexpected operator spacing errors +- Fixed bug [#1267][sq-1267] : Fixer incorrectly handles filepaths with repeated dir names - Thanks to [Sergey Ovchinnikov][@orx0r] for the patch -- Fixed bug #1276 : Commenting.FunctionComment.InvalidReturnVoid conditional issue with anonymous classes -- Fixed bug #1277 : Squiz.PHP.DisallowMultipleAssignments.Found error when var assignment is on the same line as an open tag -- Fixed bug #1284 : Squiz.Arrays.ArrayBracketSpacing.SpaceBeforeBracket false positive match for short list syntax +- Fixed bug [#1276][sq-1276] : Commenting.FunctionComment.InvalidReturnVoid conditional issue with anonymous classes +- Fixed bug [#1277][sq-1277] : Squiz.PHP.DisallowMultipleAssignments.Found error when var assignment is on the same line as an open tag +- Fixed bug [#1284][sq-1284] : Squiz.Arrays.ArrayBracketSpacing.SpaceBeforeBracket false positive match for short list syntax + +[sq-1230]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1230 +[sq-1237]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1237 +[sq-1239]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1239 +[sq-1240]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1240 +[sq-1245]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1245 +[sq-1246]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1246 +[sq-1249]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1249 +[sq-1252]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1252 +[sq-1253]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1253 +[sq-1255]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1255 +[sq-1257]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1257 +[sq-1260]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1260 +[sq-1264]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1264 +[sq-1265]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1265 +[sq-1267]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1267 +[sq-1271]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1271 +[sq-1272]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1272 +[sq-1276]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1276 +[sq-1277]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1277 +[sq-1284]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1284 +[sq-1304]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1304 ## [2.7.1] - 2016-11-30 ### Changed @@ -2468,34 +3055,51 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Sergey][@sserbin] for the patch ### Fixed -- Fixed bug #1135 : PEAR.ControlStructures.MultiLineCondition.CloseBracketNewLine not detected if preceded by multiline function call -- Fixed bug #1138 : PEAR.ControlStructures.MultiLineCondition.Alignment not detected if closing brace is first token on line -- Fixed bug #1141 : Sniffs that check EOF newlines don't detect newlines properly when the last token is a doc block -- Fixed bug #1150 : Squiz.Strings.EchoedStrings does not properly fix bracketed statements -- Fixed bug #1156 : Generic.Formatting.DisallowMultipleStatements errors when multiple short echo tags are used on the same line +- Fixed bug [#1135][sq-1135] : PEAR.ControlStructures.MultiLineCondition.CloseBracketNewLine not detected if preceded by multiline function call +- Fixed bug [#1138][sq-1138] : PEAR.ControlStructures.MultiLineCondition.Alignment not detected if closing brace is first token on line +- Fixed bug [#1141][sq-1141] : Sniffs that check EOF newlines don't detect newlines properly when the last token is a doc block +- Fixed bug [#1150][sq-1150] : Squiz.Strings.EchoedStrings does not properly fix bracketed statements +- Fixed bug [#1156][sq-1156] : Generic.Formatting.DisallowMultipleStatements errors when multiple short echo tags are used on the same line - Thanks to [Nikola Kovacs][@nkovacs] for the patch -- Fixed bug #1161 : Absolute report path is treated like a relative path if it also exists within the current directory -- Fixed bug #1170 : Javascript regular expression literal not recognized after comparison operator -- Fixed bug #1180 : Class constant named FUNCTION is incorrectly tokenized -- Fixed bug #1181 : Squiz.Operators.IncrementDecrementUsage.NoBrackets false positive when incrementing properties +- Fixed bug [#1161][sq-1161] : Absolute report path is treated like a relative path if it also exists within the current directory +- Fixed bug [#1170][sq-1170] : Javascript regular expression literal not recognized after comparison operator +- Fixed bug [#1180][sq-1180] : Class constant named FUNCTION is incorrectly tokenized +- Fixed bug [#1181][sq-1181] : Squiz.Operators.IncrementDecrementUsage.NoBrackets false positive when incrementing properties - Thanks to [Jürgen Henge-Ernst][@hernst42] for the patch -- Fixed bug #1188 : Generic.WhiteSpace.ScopeIndent issues with inline HTML and multi-line function signatures -- Fixed bug #1190 : phpcbf on if/else with trailing comment generates erroneous code -- Fixed bug #1191 : Javascript sniffer fails with function called "Function" -- Fixed bug #1203 : Inconsistent behavior of PHP_CodeSniffer_File::findEndOfStatement -- Fixed bug #1218 : CASE conditions using class constants named NAMESPACE/INTERFACE/TRAIT etc are incorrectly tokenized -- Fixed bug #1221 : Indented function call with multiple closure arguments can cause scope indent error -- Fixed bug #1224 : PHPCBF fails to fix code with heredoc/nowdoc as first argument to a function +- Fixed bug [#1188][sq-1188] : Generic.WhiteSpace.ScopeIndent issues with inline HTML and multi-line function signatures +- Fixed bug [#1190][sq-1190] : phpcbf on if/else with trailing comment generates erroneous code +- Fixed bug [#1191][sq-1191] : Javascript sniffer fails with function called "Function" +- Fixed bug [#1203][sq-1203] : Inconsistent behavior of PHP_CodeSniffer_File::findEndOfStatement +- Fixed bug [#1218][sq-1218] : CASE conditions using class constants named NAMESPACE/INTERFACE/TRAIT etc are incorrectly tokenized +- Fixed bug [#1221][sq-1221] : Indented function call with multiple closure arguments can cause scope indent error +- Fixed bug [#1224][sq-1224] : PHPCBF fails to fix code with heredoc/nowdoc as first argument to a function + +[sq-1135]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1135 +[sq-1138]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1138 +[sq-1141]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1141 +[sq-1150]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1150 +[sq-1156]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1156 +[sq-1161]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1161 +[sq-1170]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1170 +[sq-1180]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1180 +[sq-1181]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1181 +[sq-1188]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1188 +[sq-1190]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1190 +[sq-1191]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1191 +[sq-1203]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1203 +[sq-1218]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1218 +[sq-1221]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1221 +[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 is you have a generated list of files to check that would be too long for the command line + - Useful if you have a generated list of files to check that would be too long for the command line - File and directory paths are listed one per line - Usage is: phpcs --file-list=/path/to/file-list ... - Thanks to [Blotzu][@andrei-propertyguru] for the patch - Values set using @codingStandardsChangeSetting comments can now contain spaces -- Sniff unit tests can now specify a list of test files instead of letting the runner pick them (request #1078) +- Sniff unit tests can now specify a list of test files instead of letting the runner pick them (request [#1078][sq-1078]) - Useful if a sniff needs to exclude files based on the environment, or is checking filenames - Override the new getTestFiles() method to specify your own list of test files - Generic.Functions.OpeningFunctionBraceKernighanRitchie now ignores spacing for function return types @@ -2520,7 +3124,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch - Added Generic.PHP.DisallowAlternativePHPTags to ban the use of alternate PHP tags - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Squiz.WhiteSpace.LanguageConstructSpacing no longer checks for spaces if parenthesis are being used (request #1062) +- Squiz.WhiteSpace.LanguageConstructSpacing no longer checks for spaces if parenthesis are being used (request [#1062][sq-1062]) - Makes this sniff more compatible with those that check parenthesis spacing of function calls - Squiz.WhiteSpace.ObjectOperatorSpacing now has a setting to ignore newline characters around object operators - Default remains FALSE, so newlines are not allowed @@ -2534,8 +3138,8 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Walt Sorensen][@photodude] for the patch - PHPCBF is now able to fix Generic.PHP.DisallowShortOpenTag - Thanks to [Juliette Reinders Folmer][@jrfnl] for the patch -- Improved the formatting of the end brace when auto fixing InlineControlStructure errors (request #1121) -- Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine fix no longer leaves blank line after brace (request #1085) +- 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 - Squiz DoubleQuoteUsageSniff is now more tolerant of syntax errors caused by mismatched string tokens @@ -2546,58 +3150,98 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Finlay Beaton][@ofbeaton] for the patch ### Fixed -- Fixed bug #985 : Duplicate class definition detection generates false-positives in media queries +- 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 : Squiz VariableCommentSniff doesn't always detect a missing comment -- Fixed bug #1066 : Undefined index: quiet in CLI.php during unit test run with -v command line arg -- Fixed bug #1072 : Squiz.SelfMemberReference.NotUsed not detected if leading namespace separator is used -- Fixed bug #1089 : Rulesets cannot be loaded if the path contains urlencoded characters -- Fixed bug #1091 : PEAR and Squiz FunctionComment sniffs throw errors for some invalid @param line formats -- Fixed bug #1092 : PEAR.Functions.ValidDefaultValue should not flag type hinted methods with a NULL default argument -- Fixed bug #1095 : Generic LineEndings sniff replaces tabs with spaces with --tab-width is set -- Fixed bug #1096 : Squiz FunctionDeclarationArgumentSpacing gives incorrect error/fix when variadic operator is followed by a space -- Fixed bug #1099 : Group use declarations are incorrectly fixed by the PSR2 standard +- 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 [#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 +- Fixed bug [#1092][sq-1092] : PEAR.Functions.ValidDefaultValue should not flag type hinted methods with a NULL default argument +- Fixed bug [#1095][sq-1095] : Generic LineEndings sniff replaces tabs with spaces with --tab-width is set +- Fixed bug [#1096][sq-1096] : Squiz FunctionDeclarationArgumentSpacing gives incorrect error/fix when variadic operator is followed by a space +- Fixed bug [#1099][sq-1099] : Group use declarations are incorrectly fixed by the PSR2 standard - Thanks to [Jason McCreary][@jasonmccreary] for the patch -- Fixed bug #1101 : Incorrect indent errors when breaking out of PHP inside an IF statement -- Fixed bug #1102 : Squiz.Formatting.OperatorBracket.MissingBrackets faulty bracketing fix -- Fixed bug #1109 : Wrong scope indent reported in anonymous class -- Fixed bug #1112 : File docblock not recognized when require_once follows it -- Fixed bug #1120 : InlineControlStructureSniff does not handle auto-fixing for control structures that make function calls -- Fixed bug #1124 : Squiz.Operators.ComparisonOperatorUsage does not detect bracketed conditions for inline IF statements +- Fixed bug [#1101][sq-1101] : Incorrect indent errors when breaking out of PHP inside an IF statement +- Fixed bug [#1102][sq-1102] : Squiz.Formatting.OperatorBracket.MissingBrackets faulty bracketing fix +- Fixed bug [#1109][sq-1109] : Wrong scope indent reported in anonymous class +- Fixed bug [#1112][sq-1112] : File docblock not recognized when require_once follows it +- Fixed bug [#1120][sq-1120] : InlineControlStructureSniff does not handle auto-fixing for control structures that make function calls +- Fixed bug [#1124][sq-1124] : Squiz.Operators.ComparisonOperatorUsage does not detect bracketed conditions for inline IF statements - Thanks to [Raphael Horber][@rhorber] for the patch +[sq-985]: https://github.com/squizlabs/PHP_CodeSniffer/issues/985 +[sq-1014]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1014 +[sq-1062]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1062 +[sq-1066]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1066 +[sq-1072]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1072 +[sq-1078]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1078 +[sq-1085]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1085 +[sq-1089]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1089 +[sq-1091]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1091 +[sq-1092]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1092 +[sq-1095]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1095 +[sq-1096]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1096 +[sq-1099]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1099 +[sq-1101]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1101 +[sq-1102]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1102 +[sq-1109]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1109 +[sq-1112]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1112 +[sq-1120]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1120 +[sq-1121]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1121 +[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) +- 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 -- Added a new -q command line argument to disable progress and verbose information from being printed (request #969) +- Added a new -q command line argument to disable progress and verbose information from being printed (request [#969][sq-969]) - Useful if a coding standard hard-codes progress or verbose output but you want PHPCS to be quiet - Use the command "phpcs --config-set quiet true" to turn quiet mode on by default -- Generic LineLength sniff no longer errors for comments that cannot be broken out onto a new line (request #766) +- Generic LineLength sniff no longer errors for comments that cannot be broken out onto a new line (request [#766][sq-766]) - A typical case is a comment that contains a very long URL - - The comment is ignored if putting the URL on a indented new comment line would be longer than the allowed length + - The comment is ignored if putting the URL on an indented new comment line would be longer than the allowed length - Settings extensions in a ruleset no longer causes PHP notices during unit testing - Thanks to [Klaus Purer][@klausi] for the patch - Version control reports now show which errors are fixable if you are showing sources -- Added a new sniff to enforce a single space after a NOT operator (request #1051) +- Added a new sniff to enforce a single space after a NOT operator (request [#1051][sq-1051]) - Include in a ruleset using the code Generic.Formatting.SpaceAfterNot -- The Squiz.Commenting.BlockComment sniff now supports tabs for indenting comment lines (request #1056) +- The Squiz.Commenting.BlockComment sniff now supports tabs for indenting comment lines (request [#1056][sq-1056]) ### Fixed -- Fixed bug #790 : Incorrect missing @throws error in methods that use closures -- Fixed bug #908 : PSR2 standard is not checking that closing brace is on line following the body -- Fixed bug #945 : Incorrect indent behavior using deep-nested function and arrays -- Fixed bug #961 : Two anonymous functions passed as function/method arguments cause indentation false positive -- Fixed bug #1005 : Using global composer vendor autoload breaks PHP lowercase built-in function sniff +- Fixed bug [#790][sq-790] : Incorrect missing @throws error in methods that use closures +- Fixed bug [#908][sq-908] : PSR2 standard is not checking that closing brace is on line following the body +- Fixed bug [#945][sq-945] : Incorrect indent behavior using deep-nested function and arrays +- Fixed bug [#961][sq-961] : Two anonymous functions passed as function/method arguments cause indentation false positive +- Fixed bug [#1005][sq-1005] : Using global composer vendor autoload breaks PHP lowercase built-in function sniff - Thanks to [Michael Butler][@michaelbutler] for the patch -- Fixed bug #1007 : Squiz Unreachable code detection is not working properly with a closure inside a case -- Fixed bug #1023 : PSR2.Classes.ClassDeclaration fails if class extends base class and "implements" is on trailing line -- Fixed bug #1026 : Arrays in comma delimited class properties cause ScopeIndent to increase indent -- Fixed bug #1028 : Squiz ArrayDeclaration incorrectly fixes multi-line array where end bracket is not on a new line -- Fixed bug #1034 : Squiz FunctionDeclarationArgumentSpacing gives incorrect error when first arg is a variadic -- Fixed bug #1036 : Adjacent assignments aligned analysis statement wrong -- Fixed bug #1049 : Version control reports can show notices when the report width is very small -- Fixed bug #21050 : PEAR MultiLineCondition sniff suppresses errors on last condition line +- Fixed bug [#1007][sq-1007] : Squiz Unreachable code detection is not working properly with a closure inside a case +- Fixed bug [#1023][sq-1023] : PSR2.Classes.ClassDeclaration fails if class extends base class and "implements" is on trailing line +- Fixed bug [#1026][sq-1026] : Arrays in comma delimited class properties cause ScopeIndent to increase indent +- Fixed bug [#1028][sq-1028] : Squiz ArrayDeclaration incorrectly fixes multi-line array where end bracket is not on a new line +- Fixed bug [#1034][sq-1034] : Squiz FunctionDeclarationArgumentSpacing gives incorrect error when first arg is a variadic +- Fixed bug [#1036][sq-1036] : Adjacent assignments aligned analysis statement wrong +- Fixed bug [#1049][sq-1049] : Version control reports can show notices when the report width is very small +- Fixed bug [#21050][pear-21050] : PEAR MultiLineCondition sniff suppresses errors on last condition line + +[sq-766]: https://github.com/squizlabs/PHP_CodeSniffer/issues/766 +[sq-790]: https://github.com/squizlabs/PHP_CodeSniffer/issues/790 +[sq-904]: https://github.com/squizlabs/PHP_CodeSniffer/issues/904 +[sq-908]: https://github.com/squizlabs/PHP_CodeSniffer/issues/908 +[sq-945]: https://github.com/squizlabs/PHP_CodeSniffer/issues/945 +[sq-961]: https://github.com/squizlabs/PHP_CodeSniffer/issues/961 +[sq-969]: https://github.com/squizlabs/PHP_CodeSniffer/issues/969 +[sq-1005]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1005 +[sq-1007]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1007 +[sq-1023]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1023 +[sq-1026]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1026 +[sq-1028]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1028 +[sq-1034]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1034 +[sq-1036]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1036 +[sq-1049]: https://github.com/squizlabs/PHP_CodeSniffer/pull/1049 +[sq-1051]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1051 +[sq-1056]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1056 +[pear-21050]: https://pear.php.net/bugs/bug.php?id=21050 ## [2.6.1] - 2016-05-31 ### Changed @@ -2606,43 +3250,60 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Jaroslav Hanslík][@kukulich] for the patch - The default_standard config setting now allows multiple standards to be listed, like on the command line - Thanks to [Michael Mayer][@schnittstabil] for the patch -- Installations done via composer now only include the composer autoloader for PHP 5.3.2+ (request #942) +- Installations done via composer now only include the composer autoloader for PHP 5.3.2+ (request [#942][sq-942]) - Added a rollbackChangeset() method to the Fixer class to purposely rollback the active changeset ### Fixed -- Fixed bug #940 : Auto-fixing issue encountered with inconsistent use of braces -- Fixed bug #943 : Squiz.PHP.InnerFunctions.NotAllowed reported in anonymous classes -- Fixed bug #944 : PHP warning when running the latest phar -- Fixed bug #951 : InlineIfDeclaration: invalid error produced with UTF-8 string -- Fixed bug #957 : Operator spacing sniff errors when plus is used as part of a number +- Fixed bug [#940][sq-940] : Auto-fixing issue encountered with inconsistent use of braces +- Fixed bug [#943][sq-943] : Squiz.PHP.InnerFunctions.NotAllowed reported in anonymous classes +- Fixed bug [#944][sq-944] : PHP warning when running the latest phar +- Fixed bug [#951][sq-951] : InlineIfDeclaration: invalid error produced with UTF-8 string +- Fixed bug [#957][sq-957] : Operator spacing sniff errors when plus is used as part of a number - Thanks to [Klaus Purer][@klausi] for the patch -- Fixed bug #959 : Call-time pass-by-reference false positive if there is a square bracket before the ampersand +- Fixed bug [#959][sq-959] : Call-time pass-by-reference false positive if there is a square bracket before the ampersand - Thanks to [Konstantin Leboev][@realmfoo] for the patch -- Fixed bug #962 : Null coalescing operator (??) not detected as a token +- Fixed bug [#962][sq-962] : Null coalescing operator (??) not detected as a token - Thanks to [Joel Posti][@joelposti] for the patch -- Fixed bug #973 : Anonymous class declaration and PSR1.Files.SideEffects.FoundWithSymbols -- Fixed bug #974 : Error when file ends with "function" -- Fixed bug #979 : Anonymous function with return type hint is not refactored as expected -- Fixed bug #983 : Squiz.WhiteSpace.MemberVarSpacing.AfterComment fails to fix error when comment is not a docblock -- Fixed bug #1010 : Squiz NonExecutableCode sniff does not detect boolean OR +- Fixed bug [#973][sq-973] : Anonymous class declaration and PSR1.Files.SideEffects.FoundWithSymbols +- Fixed bug [#974][sq-974] : Error when file ends with "function" +- Fixed bug [#979][sq-979] : Anonymous function with return type hint is not refactored as expected +- Fixed bug [#983][sq-983] : Squiz.WhiteSpace.MemberVarSpacing.AfterComment fails to fix error when comment is not a docblock +- Fixed bug [#1010][sq-1010] : Squiz NonExecutableCode sniff does not detect boolean OR - Thanks to [Derek Henderson][@2shediac] for the patch -- Fixed bug #1015 : The Squiz.Commenting.FunctionComment sniff doesn't allow description in @return tag +- Fixed bug [#1015][sq-1015] : The Squiz.Commenting.FunctionComment sniff doesn't allow description in @return tag - Thanks to [Alexander Obuhovich][@aik099] for the patch -- Fixed bug #1022 : Duplicate spaces after opening bracket error with PSR2 standard -- Fixed bug #1025 : Syntax error in JS file can cause undefined index for parenthesis_closer +- Fixed bug [#1022][sq-1022] : Duplicate spaces after opening bracket error with PSR2 standard +- Fixed bug [#1025][sq-1025] : Syntax error in JS file can cause undefined index for parenthesis_closer + +[sq-940]: https://github.com/squizlabs/PHP_CodeSniffer/issues/940 +[sq-942]: https://github.com/squizlabs/PHP_CodeSniffer/issues/942 +[sq-943]: https://github.com/squizlabs/PHP_CodeSniffer/issues/943 +[sq-944]: https://github.com/squizlabs/PHP_CodeSniffer/issues/944 +[sq-951]: https://github.com/squizlabs/PHP_CodeSniffer/issues/951 +[sq-957]: https://github.com/squizlabs/PHP_CodeSniffer/pull/957 +[sq-959]: https://github.com/squizlabs/PHP_CodeSniffer/issues/959 +[sq-962]: https://github.com/squizlabs/PHP_CodeSniffer/issues/962 +[sq-973]: https://github.com/squizlabs/PHP_CodeSniffer/issues/973 +[sq-974]: https://github.com/squizlabs/PHP_CodeSniffer/issues/974 +[sq-979]: https://github.com/squizlabs/PHP_CodeSniffer/issues/979 +[sq-983]: https://github.com/squizlabs/PHP_CodeSniffer/issues/983 +[sq-1010]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1010 +[sq-1015]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1015 +[sq-1022]: https://github.com/squizlabs/PHP_CodeSniffer/issues/1022 +[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) +- 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 - Previously, the paths were relative to the directory PHPCS was being run from - Absolute paths are still allowed and work the same way they always have - This change allows ruleset.xml files to be more portable - Content passed via STDIN will now be processed even if files are specified on the command line or in a ruleset -- When passing content via STDIN, you can now specify the file path to use on the command line (request #934) +- When passing content via STDIN, you can now specify the file path to use on the command line (request [#934][sq-934]) - This allows sniffs that check file paths to work correctly - This is the same functionality provided by the phpcs_input_file line, except it is available on the command line -- Files processed with custom tokenizers will no longer be skipped if they appear minified (request #877) +- Files processed with custom tokenizers will no longer be skipped if they appear minified (request [#877][sq-877]) - If the custom tokenizer wants minified files skipped, it can set a $skipMinified member var to TRUE - See the included JS and CSS tokenizers for an example - Config vars set in ruleset.xml files are now processed earlier, allowing them to be used during sniff registration @@ -2653,12 +3314,12 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - 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) +- Added support for PHP7 use group declarations (request [#878][sq-878]) - New tokens T_OPEN_USE_GROUP and T_CLOSE_USE_GROUP are assigned to the open and close curly braces -- Generic ScopeIndent sniff now reports errors for every line that needs the indent changed (request #903) +- Generic ScopeIndent sniff now reports errors for every line that needs the indent changed (request [#903][sq-903]) - Previously, it ignored lines that were indented correctly in the context of their block - This change produces more technically accurate error messages, but is much more verbose -- The PSR2 and Squiz standards now allow multi-line default values in function declarations (request #542) +- The PSR2 and Squiz standards now allow multi-line default values in function declarations (request [#542][sq-542]) - Previously, these would automatically make the function a multi-line declaration - Squiz InlineCommentSniff now allows docblocks on require(_once) and include(_once) statements - Thanks to [Gary Jones][@GaryJones] for the patch @@ -2670,31 +3331,56 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Renamed Squiz.CSS.Opacity.SpacingAfterPoint to Squiz.CSS.Opacity.DecimalPrecision - Please update your ruleset if you are referencing this error code directly - Fixed PHP tokenizer problem that caused an infinite loop when checking a comment with specific content -- Generic Disallow Space and Tab indent sniffs now detect and fix indents inside embedded HTML chunks (request #882) +- Generic Disallow Space and Tab indent sniffs now detect and fix indents inside embedded HTML chunks (request [#882][sq-882]) - Squiz CSS IndentationSniff no longer assumes the class opening brace is at the end of a line - Squiz FunctionCommentThrowTagSniff now ignores non-docblock comments - Squiz ComparisonOperatorUsageSniff now allows conditions like while(true) - PEAR FunctionCallSignatureSniff (and the Squiz and PSR2 sniffs that use it) now correctly check the first argument - - Further fix for bug #698 + - Further fix for bug [#698][sq-698] ### Fixed -- Fixed bug #791 : codingStandardsChangeSetting settings not working with namespaces -- Fixed bug #872 : Incorrect detection of blank lines between CSS class names -- Fixed bug #879 : Generic InlineControlStructureSniff can create parse error when case/if/elseif/else have mixed brace and braceless definitions -- Fixed bug #883 : PSR2 is not checking for blank lines at the start and end of control structures -- Fixed bug #884 : Incorrect indentation notice for anonymous classes -- Fixed bug #887 : Using curly braces for a shared CASE/DEFAULT statement can generate an error in PSR2 SwitchDeclaration -- Fixed bug #889 : Closure inside catch/else/elseif causes indentation error -- Fixed bug #890 : Function call inside returned short array value can cause indentation error inside CASE statements -- Fixed bug #897 : Generic.Functions.CallTimePassByReference.NotAllowed false positive when short array syntax -- Fixed bug #900 : Squiz.Functions.FunctionDeclarationArgumentSpacing bug when no space between type hint and argument -- Fixed bug #902 : T_OR_EQUAL and T_POW_EQUAL are not seen as assignment tokens -- Fixed bug #910 : Unrecognized "extends" and indentation on anonymous classes -- Fixed bug #915 : JS Tokenizer generates errors when processing some decimals -- Fixed bug #928 : Endless loop when sniffing a PHP file with a git merge conflict inside a function -- Fixed bug #937 : Shebang can cause PSR1 SideEffects warning +- Fixed bug [#791][sq-791] : codingStandardsChangeSetting settings not working with namespaces +- Fixed bug [#872][sq-872] : Incorrect detection of blank lines between CSS class names +- Fixed bug [#879][sq-879] : Generic InlineControlStructureSniff can create parse error when case/if/elseif/else have mixed brace and braceless definitions +- Fixed bug [#883][sq-883] : PSR2 is not checking for blank lines at the start and end of control structures +- Fixed bug [#884][sq-884] : Incorrect indentation notice for anonymous classes +- Fixed bug [#887][sq-887] : Using curly braces for a shared CASE/DEFAULT statement can generate an error in PSR2 SwitchDeclaration +- Fixed bug [#889][sq-889] : Closure inside catch/else/elseif causes indentation error +- Fixed bug [#890][sq-890] : Function call inside returned short array value can cause indentation error inside CASE statements +- Fixed bug [#897][sq-897] : Generic.Functions.CallTimePassByReference.NotAllowed false positive when short array syntax +- Fixed bug [#900][sq-900] : Squiz.Functions.FunctionDeclarationArgumentSpacing bug when no space between type hint and argument +- Fixed bug [#902][sq-902] : T_OR_EQUAL and T_POW_EQUAL are not seen as assignment tokens +- Fixed bug [#910][sq-910] : Unrecognized "extends" and indentation on anonymous classes +- Fixed bug [#915][sq-915] : JS Tokenizer generates errors when processing some decimals +- Fixed bug [#928][sq-928] : Endless loop when sniffing a PHP file with a git merge conflict inside a function +- Fixed bug [#937][sq-937] : Shebang can cause PSR1 SideEffects warning - Thanks to [Clay Loveless][@claylo] for the patch -- Fixed bug #938 : CallTimePassByReferenceSniff ignores functions with return value +- 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 +[sq-877]: https://github.com/squizlabs/PHP_CodeSniffer/issues/877 +[sq-878]: https://github.com/squizlabs/PHP_CodeSniffer/issues/878 +[sq-879]: https://github.com/squizlabs/PHP_CodeSniffer/issues/879 +[sq-882]: https://github.com/squizlabs/PHP_CodeSniffer/issues/882 +[sq-883]: https://github.com/squizlabs/PHP_CodeSniffer/issues/883 +[sq-884]: https://github.com/squizlabs/PHP_CodeSniffer/issues/884 +[sq-887]: https://github.com/squizlabs/PHP_CodeSniffer/issues/887 +[sq-889]: https://github.com/squizlabs/PHP_CodeSniffer/issues/889 +[sq-890]: https://github.com/squizlabs/PHP_CodeSniffer/issues/890 +[sq-897]: https://github.com/squizlabs/PHP_CodeSniffer/issues/897 +[sq-900]: https://github.com/squizlabs/PHP_CodeSniffer/issues/900 +[sq-902]: https://github.com/squizlabs/PHP_CodeSniffer/issues/902 +[sq-903]: https://github.com/squizlabs/PHP_CodeSniffer/issues/903 +[sq-910]: https://github.com/squizlabs/PHP_CodeSniffer/issues/910 +[sq-915]: https://github.com/squizlabs/PHP_CodeSniffer/issues/915 +[sq-928]: https://github.com/squizlabs/PHP_CodeSniffer/issues/928 +[sq-934]: https://github.com/squizlabs/PHP_CodeSniffer/issues/934 +[sq-937]: https://github.com/squizlabs/PHP_CodeSniffer/pull/937 +[sq-938]: https://github.com/squizlabs/PHP_CodeSniffer/issues/938 ## [2.5.1] - 2016-01-20 ### Changed @@ -2706,51 +3392,77 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz ComparisonOperatorUsageSniff no longer hangs on JS FOR loops that don't use semicolons - PHP_CodesSniffer now includes the composer autoload.php file, if there is one - Thanks to [Klaus Purer][@klausi] for the patch -- Added error Squiz.Commenting.FunctionComment.ScalarTypeHintMissing for PHP7 only (request #858) +- 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 - Disable this error message in a ruleset.xml file if your code needs to run on both PHP5 and PHP7 - The PHP 5.6 __debugInfo magic method no longer produces naming convention errors - Thanks to [Michael Nowack][@syranez] for the patch -- PEAR and Squiz FunctionComment sniffs now support variadic functions (request #841) +- PEAR and Squiz FunctionComment sniffs now support variadic functions (request [#841][sq-841]) ### Fixed -- Fixed bug #622 : Wrong detection of Squiz.CSS.DuplicateStyleDefinition with media queries -- Fixed bug #752 : The missing exception error is reported in first found DocBlock -- Fixed bug #794 : PSR2 MultiLineFunctionDeclaration forbids comments after opening parenthesis of a multiline call -- Fixed bug #820 : PEAR/PSR2 FunctionCallSignature sniffs suggest wrong indent when there are multiple arguments on a line -- Fixed bug #822 : Ruleset hard-coded file paths are not used if not running from the same directory as the ruleset -- Fixed bug #825 : FunctionCallArgumentSpacing sniff complains about more than one space before comment in multi-line function call -- Fixed bug #828 : Null classname is tokenized as T_NULL instead of T_STRING -- Fixed bug #829 : Short array argument not fixed correctly when multiple function arguments are on the same line -- Fixed bug #831 : PHPCS freezes in an infinite loop under Windows if no standard is passed -- Fixed bug #832 : Tokenizer does not support context sensitive parsing +- Fixed bug [#622][sq-622] : Wrong detection of Squiz.CSS.DuplicateStyleDefinition with media queries +- Fixed bug [#752][sq-752] : The missing exception error is reported in first found DocBlock +- Fixed bug [#794][sq-794] : PSR2 MultiLineFunctionDeclaration forbids comments after opening parenthesis of a multiline call +- Fixed bug [#820][sq-820] : PEAR/PSR2 FunctionCallSignature sniffs suggest wrong indent when there are multiple arguments on a line +- Fixed bug [#822][sq-822] : Ruleset hard-coded file paths are not used if not running from the same directory as the ruleset +- Fixed bug [#825][sq-825] : FunctionCallArgumentSpacing sniff complains about more than one space before comment in multi-line function call +- Fixed bug [#828][sq-828] : Null classname is tokenized as T_NULL instead of T_STRING +- Fixed bug [#829][sq-829] : Short array argument not fixed correctly when multiple function arguments are on the same line +- Fixed bug [#831][sq-831] : PHPCS freezes in an infinite loop under Windows if no standard is passed +- Fixed bug [#832][sq-832] : Tokenizer does not support context sensitive parsing - Thanks to [Jaroslav Hanslík][@kukulich] for the patch -- Fixed bug #835 : PEAR.Functions.FunctionCallSignature broken when closure uses return types -- Fixed bug #838 : CSS indentation fixer changes color codes +- Fixed bug [#835][sq-835] : PEAR.Functions.FunctionCallSignature broken when closure uses return types +- Fixed bug [#838][sq-838] : CSS indentation fixer changes color codes - Thanks to [Klaus Purer][@klausi] for the patch -- Fixed bug #839 : "__()" method is marked as not camel caps +- Fixed bug [#839][sq-839] : "__()" method is marked as not camel caps - Thanks to [Tim Bezhashvyly][@tim-bezhashvyly] for the patch -- Fixed bug #852 : Generic.Commenting.DocComment not finding errors when long description is omitted -- Fixed bug #854 : Return typehints in interfaces are not reported as T_RETURN_TYPE +- Fixed bug [#852][sq-852] : Generic.Commenting.DocComment not finding errors when long description is omitted +- Fixed bug [#854][sq-854] : Return typehints in interfaces are not reported as T_RETURN_TYPE - Thanks to [Jaroslav Hanslík][@kukulich] for the patch -- Fixed bug #855 : Capital letter detection for multibyte strings doesn't work correctly -- Fixed bug #857 : PSR2.ControlStructure.SwitchDeclaration shouldn't check indent of curly brace closers -- Fixed bug #859 : Switch statement indention issue when returning function call with closure -- Fixed bug #861 : Single-line arrays and function calls can generate incorrect indentation errors -- Fixed bug #867 : Squiz.Strings.DoubleQuoteUsage broken for some escape codes +- Fixed bug [#855][sq-855] : Capital letter detection for multibyte strings doesn't work correctly +- Fixed bug [#857][sq-857] : PSR2.ControlStructure.SwitchDeclaration shouldn't check indent of curly brace closers +- Fixed bug [#859][sq-859] : Switch statement indention issue when returning function call with closure +- Fixed bug [#861][sq-861] : Single-line arrays and function calls can generate incorrect indentation errors +- Fixed bug [#867][sq-867] : Squiz.Strings.DoubleQuoteUsage broken for some escape codes - Thanks to [Jack Blower][@ElvenSpellmaker] for the help with the fix -- Fixed bug #21005 : Incorrect indent detection when multiple properties are initialized to arrays -- Fixed bug #21010 : Incorrect missing colon detection in CSS when first style is not on new line -- Fixed bug #21011 : Incorrect error message text when newline found after opening brace +- Fixed bug [#21005][pear-21005] : Incorrect indent detection when multiple properties are initialized to arrays +- Fixed bug [#21010][pear-21010] : Incorrect missing colon detection in CSS when first style is not on new line +- Fixed bug [#21011][pear-21011] : Incorrect error message text when newline found after opening brace + +[sq-622]: https://github.com/squizlabs/PHP_CodeSniffer/issues/622 +[sq-752]: https://github.com/squizlabs/PHP_CodeSniffer/issues/752 +[sq-794]: https://github.com/squizlabs/PHP_CodeSniffer/issues/794 +[sq-820]: https://github.com/squizlabs/PHP_CodeSniffer/issues/820 +[sq-822]: https://github.com/squizlabs/PHP_CodeSniffer/issues/822 +[sq-825]: https://github.com/squizlabs/PHP_CodeSniffer/issues/825 +[sq-828]: https://github.com/squizlabs/PHP_CodeSniffer/issues/828 +[sq-829]: https://github.com/squizlabs/PHP_CodeSniffer/issues/829 +[sq-831]: https://github.com/squizlabs/PHP_CodeSniffer/issues/831 +[sq-832]: https://github.com/squizlabs/PHP_CodeSniffer/issues/832 +[sq-835]: https://github.com/squizlabs/PHP_CodeSniffer/issues/835 +[sq-838]: https://github.com/squizlabs/PHP_CodeSniffer/pull/838 +[sq-839]: https://github.com/squizlabs/PHP_CodeSniffer/issues/839 +[sq-841]: https://github.com/squizlabs/PHP_CodeSniffer/issues/841 +[sq-852]: https://github.com/squizlabs/PHP_CodeSniffer/issues/852 +[sq-854]: https://github.com/squizlabs/PHP_CodeSniffer/issues/854 +[sq-855]: https://github.com/squizlabs/PHP_CodeSniffer/pull/855 +[sq-857]: https://github.com/squizlabs/PHP_CodeSniffer/issues/857 +[sq-858]: https://github.com/squizlabs/PHP_CodeSniffer/issues/858 +[sq-859]: https://github.com/squizlabs/PHP_CodeSniffer/issues/859 +[sq-861]: https://github.com/squizlabs/PHP_CodeSniffer/issues/861 +[sq-867]: https://github.com/squizlabs/PHP_CodeSniffer/issues/867 +[pear-21005]: https://pear.php.net/bugs/bug.php?id=21005 +[pear-21010]: https://pear.php.net/bugs/bug.php?id=21010 +[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) +- 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 - This file is still only used if no standard is specified on the command line -- Added support for a phpcs.xml.dist file (request #583) +- Added support for a phpcs.xml.dist file (request [#583][sq-583]) - If both a phpcs.xml and phpcs.xml.dist file are present, the phpcs.xml file will be used -- Added support for setting PHP ini values in ruleset.xml files (request #560) +- Added support for setting PHP ini values in ruleset.xml files (request [#560][sq-560]) - Setting the value of the new ini tags to name="memory_limit" value="32M" is the same as -d memory_limit=32M - Added support for one or more bootstrap files to be run before processing begins - Use the --bootstrap=file,file,file command line argument to include bootstrap files @@ -2761,16 +3473,30 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Arnout Boks][@aboks] for the patch ### Fixed -- Fixed bug #660 : Syntax checks can fail on Windows with PHP5.6 -- Fixed bug #784 : $this->trait is seen as a T_TRAIT token -- Fixed bug #786 : Switch indent issue with short array notation -- Fixed bug #787 : SpacingAfterDefaultBreak confused by multi-line statements -- Fixed bug #797 : Parsing CSS url() value breaks further parsing -- Fixed bug #805 : Squiz.Commenting.FunctionComment.InvalidTypeHint on Scalar types on PHP7 -- Fixed bug #807 : Cannot fix line endings when open PHP tag is not on the first line -- Fixed bug #808 : JS tokeniser incorrectly setting some function and class names to control structure tokens -- Fixed bug #809 : PHPCBF can break a require_once statement with a space before the open parenthesis -- Fixed bug #813 : PEAR FunctionCallSignature checks wrong indent when first token on line is part of a multi-line string +- Fixed bug [#660][sq-660] : Syntax checks can fail on Windows with PHP5.6 +- Fixed bug [#784][sq-784] : $this->trait is seen as a T_TRAIT token +- Fixed bug [#786][sq-786] : Switch indent issue with short array notation +- Fixed bug [#787][sq-787] : SpacingAfterDefaultBreak confused by multi-line statements +- Fixed bug [#797][sq-797] : Parsing CSS url() value breaks further parsing +- Fixed bug [#805][sq-805] : Squiz.Commenting.FunctionComment.InvalidTypeHint on Scalar types on PHP7 +- Fixed bug [#807][sq-807] : Cannot fix line endings when open PHP tag is not on the first line +- Fixed bug [#808][sq-808] : JS tokenizer incorrectly setting some function and class names to control structure tokens +- Fixed bug [#809][sq-809] : PHPCBF can break a require_once statement with a space before the open parenthesis +- Fixed bug [#813][sq-813] : PEAR FunctionCallSignature checks wrong indent when first token on line is part of a multi-line string + +[sq-560]: https://github.com/squizlabs/PHP_CodeSniffer/issues/560 +[sq-583]: https://github.com/squizlabs/PHP_CodeSniffer/issues/583 +[sq-626]: https://github.com/squizlabs/PHP_CodeSniffer/issues/626 +[sq-660]: https://github.com/squizlabs/PHP_CodeSniffer/pull/660 +[sq-784]: https://github.com/squizlabs/PHP_CodeSniffer/issues/784 +[sq-786]: https://github.com/squizlabs/PHP_CodeSniffer/issues/786 +[sq-787]: https://github.com/squizlabs/PHP_CodeSniffer/issues/787 +[sq-797]: https://github.com/squizlabs/PHP_CodeSniffer/issues/797 +[sq-805]: https://github.com/squizlabs/PHP_CodeSniffer/issues/805 +[sq-807]: https://github.com/squizlabs/PHP_CodeSniffer/issues/807 +[sq-808]: https://github.com/squizlabs/PHP_CodeSniffer/issues/808 +[sq-809]: https://github.com/squizlabs/PHP_CodeSniffer/issues/809 +[sq-813]: https://github.com/squizlabs/PHP_CodeSniffer/issues/813 ## [2.4.0] - 2015-11-24 ### Changed @@ -2778,7 +3504,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Anonymous classes are now tokenized as T_ANON_CLASS and ignored by normal class sniffs - Added support for PHP 7 function return type declarations - Return types are now tokenized as T_RETURN_TYPE -- Fixed tokenizing of the XOR operator, which was incorrectly identified as a power operator (bug #765) +- Fixed tokenizing of the XOR operator, which was incorrectly identified as a power operator (bug [#765][sq-765]) - The T_POWER token has been removed and replaced by the T_BITWISE_XOR token - The PHP-supplied T_POW token has been replicated for PHP versions before 5.6 - Traits are now tokenized in PHP versions before 5.4 to make testing easier @@ -2798,39 +3524,64 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Generic InlineControlStructureSniff now correctly fixes ELSEIF statements ### Fixed -- Fixed bug #601 : Expected type hint int[]; found array in Squiz FunctionCommentSniff +- Fixed bug [#601][sq-601] : Expected type hint int[]; found array in Squiz FunctionCommentSniff - Thanks to [Scato Eggen][@scato] for the patch -- Fixed bug #625 : Consider working around T_HASHBANG in HHVM 3.5.x and 3.6.x +- Fixed bug [#625][sq-625] : Consider working around T_HASHBANG in HHVM 3.5.x and 3.6.x - Thanks to [Kunal Mehta][@legoktm] for the patch -- Fixed bug #692 : Comment tokenizer can break when using mbstring function overloading -- Fixed bug #694 : Long sniff codes can cause PHP warnings in source report when showing error codes -- Fixed bug #698 : PSR2.Methods.FunctionCallSignature.Indent forces exact indent of ternary operator parameters -- Fixed bug #704 : ScopeIndent can fail when an opening parenthesis is on a line by itself -- Fixed bug #707 : Squiz MethodScopeSniff doesn't handle nested functions -- Fixed bug #709 : Squiz.Sniffs.Whitespace.ScopeClosingBraceSniff marking indented endif in mixed inline HTML blocks -- Fixed bug #711 : Sniffing from STDIN shows Generic.Files.LowercasedFilename.NotFound error -- Fixed bug #714 : Fixes suppression of errors using docblocks +- Fixed bug [#692][sq-692] : Comment tokenizer can break when using mbstring function overloading +- Fixed bug [#694][sq-694] : Long sniff codes can cause PHP warnings in source report when showing error codes +- Fixed bug [#698][sq-698] : PSR2.Methods.FunctionCallSignature.Indent forces exact indent of ternary operator parameters +- Fixed bug [#704][sq-704] : ScopeIndent can fail when an opening parenthesis is on a line by itself +- Fixed bug [#707][sq-707] : Squiz MethodScopeSniff doesn't handle nested functions +- Fixed bug [#709][sq-709] : Squiz.Sniffs.Whitespace.ScopeClosingBraceSniff marking indented endif in mixed inline HTML blocks +- Fixed bug [#711][sq-711] : Sniffing from STDIN shows Generic.Files.LowercasedFilename.NotFound error +- Fixed bug [#714][sq-714] : Fixes suppression of errors using docblocks - Thanks to [Andrzej Karmazyn][@akarmazyn] for the patch -- Fixed bug #716 : JSON report is invalid when messages contain newlines or tabs +- Fixed bug [#716][sq-716] : JSON report is invalid when messages contain newlines or tabs - Thanks to [Pieter Frenssen][@pfrenssen] for the patch -- Fixed bug #723 : ScopeIndent can fail when multiple array closers are on the same line -- Fixed bug #730 : ScopeIndent can fail when a short array opening square bracket is on a line by itself -- Fixed bug #732 : PHP Notice if @package name is made up of all invalid characters +- Fixed bug [#723][sq-723] : ScopeIndent can fail when multiple array closers are on the same line +- Fixed bug [#730][sq-730] : ScopeIndent can fail when a short array opening square bracket is on a line by itself +- Fixed bug [#732][sq-732] : PHP Notice if @package name is made up of all invalid characters - Adds new error code PEAR.Commenting.FileComment.InvalidPackageValue -- Fixed bug #748 : Auto fix for Squiz.Commenting.BlockComment.WrongEnd is incorrect +- Fixed bug [#748][sq-748] : Auto fix for Squiz.Commenting.BlockComment.WrongEnd is incorrect - Thanks to [J.D. Grimes][@JDGrimes] for the patch -- Fixed bug #753 : PSR2 standard shouldn't require space after USE block when next code is a closing tag -- Fixed bug #768 : PEAR FunctionCallSignature sniff forbids comments after opening parenthesis of a multiline call -- Fixed bug #769 : Incorrect detection of variable reference operator when used with short array syntax +- Fixed bug [#753][sq-753] : PSR2 standard shouldn't require space after USE block when next code is a closing tag +- Fixed bug [#768][sq-768] : PEAR FunctionCallSignature sniff forbids comments after opening parenthesis of a multiline call +- Fixed bug [#769][sq-769] : Incorrect detection of variable reference operator when used with short array syntax - Thanks to [Klaus Purer][@klausi] for the patch -- Fixed bug #772 : Syntax error when using PHPCBF on alternative style foreach loops -- Fixed bug #773 : Syntax error when stripping trailing PHP close tag and previous statement has no semicolon -- Fixed bug #778 : PHPCBF creates invalid PHP for inline FOREACH containing multiple control structures -- Fixed bug #781 : Incorrect checking for PHP7 return types on multi-line function declarations -- Fixed bug #782 : Conditional function declarations cause fixing conflicts in Squiz standard +- Fixed bug [#772][sq-772] : Syntax error when using PHPCBF on alternative style foreach loops +- Fixed bug [#773][sq-773] : Syntax error when stripping trailing PHP close tag and previous statement has no semicolon +- Fixed bug [#778][sq-778] : PHPCBF creates invalid PHP for inline FOREACH containing multiple control structures +- Fixed bug [#781][sq-781] : Incorrect checking for PHP7 return types on multi-line function declarations +- Fixed bug [#782][sq-782] : Conditional function declarations cause fixing conflicts in Squiz standard - Squiz.ControlStructures.ControlSignature no longer enforces a single newline after open brace - Squiz.WhiteSpace.ControlStructureSpacing can be used to check spacing at the start/end of control structures +[sq-601]: https://github.com/squizlabs/PHP_CodeSniffer/issues/601 +[sq-625]: https://github.com/squizlabs/PHP_CodeSniffer/issues/625 +[sq-692]: https://github.com/squizlabs/PHP_CodeSniffer/pull/692 +[sq-694]: https://github.com/squizlabs/PHP_CodeSniffer/issues/694 +[sq-698]: https://github.com/squizlabs/PHP_CodeSniffer/issues/698 +[sq-704]: https://github.com/squizlabs/PHP_CodeSniffer/issues/704 +[sq-707]: https://github.com/squizlabs/PHP_CodeSniffer/pull/707 +[sq-709]: https://github.com/squizlabs/PHP_CodeSniffer/issues/709 +[sq-711]: https://github.com/squizlabs/PHP_CodeSniffer/issues/711 +[sq-714]: https://github.com/squizlabs/PHP_CodeSniffer/pull/714 +[sq-716]: https://github.com/squizlabs/PHP_CodeSniffer/pull/716 +[sq-723]: https://github.com/squizlabs/PHP_CodeSniffer/issues/723 +[sq-730]: https://github.com/squizlabs/PHP_CodeSniffer/pull/730 +[sq-732]: https://github.com/squizlabs/PHP_CodeSniffer/pull/732 +[sq-748]: https://github.com/squizlabs/PHP_CodeSniffer/pull/748 +[sq-753]: https://github.com/squizlabs/PHP_CodeSniffer/issues/753 +[sq-765]: https://github.com/squizlabs/PHP_CodeSniffer/issues/765 +[sq-768]: https://github.com/squizlabs/PHP_CodeSniffer/issues/768 +[sq-769]: https://github.com/squizlabs/PHP_CodeSniffer/pull/769 +[sq-772]: https://github.com/squizlabs/PHP_CodeSniffer/issues/772 +[sq-773]: https://github.com/squizlabs/PHP_CodeSniffer/issues/773 +[sq-778]: https://github.com/squizlabs/PHP_CodeSniffer/issues/778 +[sq-781]: https://github.com/squizlabs/PHP_CodeSniffer/issues/781 +[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 @@ -2841,31 +3592,48 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Set the allowMultiline property to TRUE (default is FALSE) in your ruleset.xml file to enable this - By default, concat used only for getting around line length limits still generates an error - Thanks to [Stefan Lenselink][@stefanlenselink] for the contribution -- Invalid byte sequences no longer throw iconv_strlen() errors (request #639) +- Invalid byte sequences no longer throw iconv_strlen() errors (request [#639][sq-639]) - Thanks to [Willem Stuursma][@willemstuursma] for the patch - Generic TodoSniff and FixmeSniff are now better at processing strings with invalid characters - PEAR FunctionCallSignatureSniff now ignores indentation of inline HTML content - Squiz ControlSignatureSniff now supports control structures with only inline HTML content ### Fixed -- Fixed bug #636 : Some class names cause CSS tokenizer to hang -- Fixed bug #638 : VCS blame reports output error content from the blame commands for files not under VC -- Fixed bug #642 : Method params incorrectly detected when default value uses short array syntax +- Fixed bug [#636][sq-636] : Some class names cause CSS tokenizer to hang +- Fixed bug [#638][sq-638] : VCS blame reports output error content from the blame commands for files not under VC +- Fixed bug [#642][sq-642] : Method params incorrectly detected when default value uses short array syntax - Thanks to [Josh Davis][@joshdavis11] for the patch -- Fixed bug #644 : PEAR ScopeClosingBrace sniff does not work with mixed HTML/PHP -- Fixed bug #645 : FunctionSignature and ScopeIndent sniffs don't detect indents correctly when PHP open tag is not on a line by itself -- Fixed bug #648 : Namespace not tokenized correctly when followed by multiple use statements -- Fixed bug #654 : Comments affect indent check for BSDAllman brace style -- Fixed bug #658 : Squiz.Functions.FunctionDeclarationSpacing error for multi-line declarations with required spaces greater than zero +- Fixed bug [#644][sq-644] : PEAR ScopeClosingBrace sniff does not work with mixed HTML/PHP +- Fixed bug [#645][sq-645] : FunctionSignature and ScopeIndent sniffs don't detect indents correctly when PHP open tag is not on a line by itself +- Fixed bug [#648][sq-648] : Namespace not tokenized correctly when followed by multiple use statements +- Fixed bug [#654][sq-654] : Comments affect indent check for BSDAllman brace style +- Fixed bug [#658][sq-658] : Squiz.Functions.FunctionDeclarationSpacing error for multi-line declarations with required spaces greater than zero - Thanks to [J.D. Grimes][@JDGrimes] for the patch -- Fixed bug #663 : No space after class name generates: Class name "" is not in camel caps format -- Fixed bug #667 : Scope indent check can go into infinite loop due to some parse errors -- Fixed bug #670 : Endless loop in PSR1 SideEffects sniffer if no semicolon after last statement +- Fixed bug [#663][sq-663] : No space after class name generates: Class name "" is not in camel caps format +- Fixed bug [#667][sq-667] : Scope indent check can go into infinite loop due to some parse errors +- Fixed bug [#670][sq-670] : Endless loop in PSR1 SideEffects sniffer if no semicolon after last statement - Thanks to [Thomas Jarosch][@thomasjfox] for the patch -- Fixed bug #672 : Call-time pass-by-reference false positive -- Fixed bug #683 : Comments are incorrectly reported by PSR2.ControlStructures.SwitchDeclaration sniff -- Fixed bug #687 : ScopeIndent does not check indent correctly for method prefixes like public and abstract -- Fixed bug #689 : False error on some comments after class closing brace +- Fixed bug [#672][sq-672] : Call-time pass-by-reference false positive +- Fixed bug [#683][sq-683] : Comments are incorrectly reported by PSR2.ControlStructures.SwitchDeclaration sniff +- Fixed bug [#687][sq-687] : ScopeIndent does not check indent correctly for method prefixes like public and abstract +- Fixed bug [#689][sq-689] : False error on some comments after class closing brace + +[sq-636]: https://github.com/squizlabs/PHP_CodeSniffer/issues/636 +[sq-638]: https://github.com/squizlabs/PHP_CodeSniffer/issues/638 +[sq-639]: https://github.com/squizlabs/PHP_CodeSniffer/pull/639 +[sq-642]: https://github.com/squizlabs/PHP_CodeSniffer/pull/642 +[sq-644]: https://github.com/squizlabs/PHP_CodeSniffer/issues/644 +[sq-645]: https://github.com/squizlabs/PHP_CodeSniffer/issues/645 +[sq-648]: https://github.com/squizlabs/PHP_CodeSniffer/issues/648 +[sq-654]: https://github.com/squizlabs/PHP_CodeSniffer/issues/654 +[sq-658]: https://github.com/squizlabs/PHP_CodeSniffer/pull/658 +[sq-663]: https://github.com/squizlabs/PHP_CodeSniffer/issues/663 +[sq-667]: https://github.com/squizlabs/PHP_CodeSniffer/issues/667 +[sq-670]: https://github.com/squizlabs/PHP_CodeSniffer/pull/670 +[sq-672]: https://github.com/squizlabs/PHP_CodeSniffer/issues/672 +[sq-683]: https://github.com/squizlabs/PHP_CodeSniffer/issues/683 +[sq-687]: https://github.com/squizlabs/PHP_CodeSniffer/issues/687 +[sq-689]: https://github.com/squizlabs/PHP_CodeSniffer/issues/689 ## [2.3.3] - 2015-06-24 ### Changed @@ -2876,82 +3644,121 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Added more guard code for syntax errors to various sniffs - Improved support for older HHVM versions - Thanks to [Kunal Mehta][@legoktm] for the patch -- Squiz ValidLogicalOperatorsSniff now ignores XOR as type casting is different when using the ^ operator (request #567) +- Squiz ValidLogicalOperatorsSniff now ignores XOR as type casting is different when using the ^ operator (request [#567][sq-567]) - Squiz CommentedOutCodeSniff is now better at ignoring URLs inside comments - Squiz ControlSignatureSniff is now better at checking embedded PHP code - Squiz ScopeClosingBraceSniff is now better at checking embedded PHP code ### Fixed -- Fixed bug #584 : Squiz.Arrays.ArrayDeclaration sniff gives incorrect NoComma error for multiline string values -- Fixed bug #589 : PEAR.Functions.FunctionCallSignature sniff not checking all function calls -- Fixed bug #592 : USE statement tokenising can sometimes result in mismatched scopes -- Fixed bug #594 : Tokenizer issue on closure that returns by reference -- Fixed bug #595 : Colons in CSS selectors within media queries throw false positives +- 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 [#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 -- Fixed bug #598 : PHPCBF can break function/use closure brace placement -- Fixed bug #603 : Squiz ControlSignatureSniff hard-codes opener type while fixing -- Fixed bug #605 : Auto report-width specified in ruleset.xml ignored -- Fixed bug #611 : Invalid numeric literal on CSS files under PHP7 -- Fixed bug #612 : Multi-file diff generating incorrectly if files do not end with EOL char -- Fixed bug #615 : Squiz OperatorBracketSniff incorrectly reports and fixes operations using self:: -- Fixed bug #616 : Squiz DisallowComparisonAssignmentSniff inconsistent errors with inline IF statements -- Fixed bug #617 : Space after switch keyword in PSR-2 is not being enforced -- Fixed bug #621 : PSR2 SwitchDeclaration sniff doesn't detect, or correctly fix, case body on same line as statement +- Fixed bug [#598][sq-598] : PHPCBF can break function/use closure brace placement +- Fixed bug [#603][sq-603] : Squiz ControlSignatureSniff hard-codes opener type while fixing +- Fixed bug [#605][sq-605] : Auto report-width specified in ruleset.xml ignored +- Fixed bug [#611][sq-611] : Invalid numeric literal on CSS files under PHP7 +- Fixed bug [#612][sq-612] : Multi-file diff generating incorrectly if files do not end with EOL char +- Fixed bug [#615][sq-615] : Squiz OperatorBracketSniff incorrectly reports and fixes operations using self:: +- Fixed bug [#616][sq-616] : Squiz DisallowComparisonAssignmentSniff inconsistent errors with inline IF statements +- Fixed bug [#617][sq-617] : Space after switch keyword in PSR-2 is not being enforced +- Fixed bug [#621][sq-621] : PSR2 SwitchDeclaration sniff doesn't detect, or correctly fix, case body on same line as statement + +[sq-567]: https://github.com/squizlabs/PHP_CodeSniffer/issues/567 +[sq-584]: https://github.com/squizlabs/PHP_CodeSniffer/issues/584 +[sq-589]: https://github.com/squizlabs/PHP_CodeSniffer/issues/589 +[sq-592]: https://github.com/squizlabs/PHP_CodeSniffer/issues/592 +[sq-594]: https://github.com/squizlabs/PHP_CodeSniffer/issues/594 +[sq-595]: https://github.com/squizlabs/PHP_CodeSniffer/pull/595 +[sq-598]: https://github.com/squizlabs/PHP_CodeSniffer/issues/598 +[sq-603]: https://github.com/squizlabs/PHP_CodeSniffer/issues/603 +[sq-605]: https://github.com/squizlabs/PHP_CodeSniffer/issues/605 +[sq-611]: https://github.com/squizlabs/PHP_CodeSniffer/issues/611 +[sq-612]: https://github.com/squizlabs/PHP_CodeSniffer/issues/612 +[sq-615]: https://github.com/squizlabs/PHP_CodeSniffer/issues/615 +[sq-616]: https://github.com/squizlabs/PHP_CodeSniffer/issues/616 +[sq-617]: https://github.com/squizlabs/PHP_CodeSniffer/issues/617 +[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) +- The error message for PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase is now clearer (request [#579][sq-579]) ### Fixed -- Fixed bug #545 : Long list of CASE statements can cause tokenizer to reach a depth limit -- Fixed bug #565 : Squiz.WhiteSpace.OperatorSpacing reports negative number in short array +- Fixed bug [#545][sq-545] : Long list of CASE statements can cause tokenizer to reach a depth limit +- Fixed bug [#565][sq-565] : Squiz.WhiteSpace.OperatorSpacing reports negative number in short array - Thanks to [Vašek Purchart][@VasekPurchart] for the patch - Same fix also applied to Squiz.Formatting.OperatorBracket -- Fixed bug #569 : Generic ScopeIndentSniff throws PHP notices in JS files -- Fixed bug #570 : Phar class fatals in PHP less than 5.3 +- Fixed bug [#569][sq-569] : Generic ScopeIndentSniff throws PHP notices in JS files +- Fixed bug [#570][sq-570] : Phar class fatals in PHP less than 5.3 + +[sq-545]: https://github.com/squizlabs/PHP_CodeSniffer/issues/545 +[sq-565]: https://github.com/squizlabs/PHP_CodeSniffer/pull/565 +[sq-569]: https://github.com/squizlabs/PHP_CodeSniffer/pull/569 +[sq-570]: https://github.com/squizlabs/PHP_CodeSniffer/issues/570 +[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 - Use with the ignore_warnings_on_exit config variable to never return a non-zero exit code -- Added Generic DisallowLongArraySyntaxSniff to enforce the use of the PHP short array syntax (request #483) +- Added Generic DisallowLongArraySyntaxSniff to enforce the use of the PHP short array syntax (request [#483][sq-483]) - Thanks to [Xaver Loppenstedt][@xalopp] for helping with tests -- Added Generic DisallowShortArraySyntaxSniff to ban the use of the PHP short array syntax (request #483) +- Added Generic DisallowShortArraySyntaxSniff to ban the use of the PHP short array syntax (request [#483][sq-483]) - Thanks to [Xaver Loppenstedt][@xalopp] for helping with tests -- Generic ScopeIndentSniff no longer does exact checking for content inside parenthesis (request #528) +- Generic ScopeIndentSniff no longer does exact checking for content inside parenthesis (request [#528][sq-528]) - Only applies to custom coding standards that set the "exact" flag to TRUE -- Squiz ConcatenationSpacingSniff now has a setting to ignore newline characters around operators (request #511) +- Squiz ConcatenationSpacingSniff now has a setting to ignore newline characters around operators (request [#511][sq-511]) - Default remains FALSE, so newlines are not allowed - Override the "ignoreNewlines" setting in a ruleset.xml file to change -- Squiz InlineCommentSniff no longer checks the last char of a comment if the first char is not a letter (request #505) +- Squiz InlineCommentSniff no longer checks the last char of a comment if the first char is not a letter (request [#505][sq-505]) - The Squiz standard has increased the max padding for statement alignment from 12 to 20 ### Fixed -- Fixed bug #479 : Yielded values are not recognised as returned values in Squiz FunctionComment sniff -- Fixed bug #512 : Endless loop whilst parsing mixture of control structure styles -- Fixed bug #515 : Spaces in JS block incorrectly flagged as indentation error -- Fixed bug #523 : Generic ScopeIndent errors for IF in FINALLY -- Fixed bug #527 : Closure inside IF statement is not tokenized correctly -- Fixed bug #529 : Squiz.Strings.EchoedStrings gives false positive when echo'ing using an inline condition -- Fixed bug #537 : Using --config-set is breaking phpcs.phar -- Fixed bug #543 : SWITCH with closure in condition generates inline control structure error -- Fixed bug #551 : Multiple catch blocks not checked in Squiz.ControlStructures.ControlSignature sniff -- Fixed bug #554 : ScopeIndentSniff causes errors when encountering an unmatched parenthesis -- Fixed bug #558 : PHPCBF adds brace for ELSE IF split over multiple lines -- Fixed bug #564 : Generic MultipleStatementAlignment sniff reports incorrect errors for multiple assignments on a single line +- Fixed bug [#479][sq-479] : Yielded values are not recognised as returned values in Squiz FunctionComment sniff +- Fixed bug [#512][sq-512] : Endless loop whilst parsing mixture of control structure styles +- Fixed bug [#515][sq-515] : Spaces in JS block incorrectly flagged as indentation error +- Fixed bug [#523][sq-523] : Generic ScopeIndent errors for IF in FINALLY +- Fixed bug [#527][sq-527] : Closure inside IF statement is not tokenized correctly +- Fixed bug [#529][sq-529] : Squiz.Strings.EchoedStrings gives false positive when echoing using an inline condition +- Fixed bug [#537][sq-537] : Using --config-set is breaking phpcs.phar +- Fixed bug [#543][sq-543] : SWITCH with closure in condition generates inline control structure error +- Fixed bug [#551][sq-551] : Multiple catch blocks not checked in Squiz.ControlStructures.ControlSignature sniff +- Fixed bug [#554][sq-554] : ScopeIndentSniff causes errors when encountering an unmatched parenthesis +- Fixed bug [#558][sq-558] : PHPCBF adds brace for ELSE IF split over multiple lines +- Fixed bug [#564][sq-564] : Generic MultipleStatementAlignment sniff reports incorrect errors for multiple assignments on a single line + +[sq-479]: https://github.com/squizlabs/PHP_CodeSniffer/issues/479 +[sq-483]: https://github.com/squizlabs/PHP_CodeSniffer/issues/483 +[sq-505]: https://github.com/squizlabs/PHP_CodeSniffer/issues/505 +[sq-511]: https://github.com/squizlabs/PHP_CodeSniffer/issues/511 +[sq-512]: https://github.com/squizlabs/PHP_CodeSniffer/issues/512 +[sq-515]: https://github.com/squizlabs/PHP_CodeSniffer/issues/515 +[sq-523]: https://github.com/squizlabs/PHP_CodeSniffer/issues/523 +[sq-527]: https://github.com/squizlabs/PHP_CodeSniffer/issues/527 +[sq-528]: https://github.com/squizlabs/PHP_CodeSniffer/issues/528 +[sq-529]: https://github.com/squizlabs/PHP_CodeSniffer/issues/529 +[sq-537]: https://github.com/squizlabs/PHP_CodeSniffer/issues/537 +[sq-543]: https://github.com/squizlabs/PHP_CodeSniffer/issues/543 +[sq-551]: https://github.com/squizlabs/PHP_CodeSniffer/issues/551 +[sq-554]: https://github.com/squizlabs/PHP_CodeSniffer/issues/554 +[sq-558]: https://github.com/squizlabs/PHP_CodeSniffer/issues/558 +[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) -- Abstract classes inside the Sniffs directory are now ignored even if they are named [Name]Sniff.php (request #476) +- 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]) - Thanks to [David Vernet][@Decave] for the patch - PEAR and Squiz FileComment sniffs no longer have @ in their error codes - e.g., PEAR.Commenting.FileComment.Duplicate@categoryTag becomes PEAR.Commenting.FileComment.DuplicateCategoryTag - e.g., Squiz.Commenting.FileComment.Missing@categoryTag becomes Squiz.Commenting.FileComment.MissingCategoryTag - PEAR MultiLineConditionSniff now allows comment lines inside multi-line IF statement conditions - Thanks to [Klaus Purer][@klausi] for the patch -- Generic ForbiddenFunctionsSniff now supports setting null replacements in ruleset files (request #263) +- Generic ForbiddenFunctionsSniff now supports setting null replacements in ruleset files (request [#263][sq-263]) - Generic opening function brace sniffs now support checking of closures - Set the checkClosures property to TRUE (default is FALSE) in your ruleset.xml file to enable this - Can also set the checkFunctions property to FALSE (default is TRUE) in your ruleset.xml file to only check closures @@ -2962,7 +3769,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Improved auto report width for the "full" report - Improved conflict detection during auto fixing - Generic ScopeIndentSniff is no longer confused by empty closures -- Squiz ControlSignatureSniff now always ignores comments (fixes bug #490) +- Squiz ControlSignatureSniff now always ignores comments (fixes bug [#490][sq-490]) - Include the Squiz.Commenting.PostStatementComment sniff in your ruleset.xml to ban these comments again - Squiz OperatorSpacingSniff no longer throws errors for code in the form ($foo || -1 === $bar) - Fixed errors tokenizing T_ELSEIF tokens on HHVM 3.5 @@ -2970,24 +3777,44 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - PEAR IncludingFileSniff no longer produces invalid code when removing parenthesis from require/include statements ### Fixed -- Fixed bug #415 : The @codingStandardsIgnoreStart has no effect during fixing -- Fixed bug #432 : Properties of custom sniffs cannot be configured -- Fixed bug #453 : PSR2 standard does not allow closing tag for mixed PHP/HTML files -- Fixed bug #457 : FunctionCallSignature sniffs do not support here/nowdoc syntax and can cause syntax error when fixing -- Fixed bug #466 : PropertyLabelSpacing JS fixer issue when there is no space after colon -- Fixed bug #473 : Writing a report for an empty folder to existing file includes the existing contents -- Fixed bug #485 : PHP notice in Squiz.Commenting.FunctionComment when checking malformed @throws comment -- Fixed bug #491 : Generic InlineControlStructureSniff can correct with missing semicolon +- Fixed bug [#415][sq-415] : The @codingStandardsIgnoreStart has no effect during fixing +- Fixed bug [#432][sq-432] : Properties of custom sniffs cannot be configured +- Fixed bug [#453][sq-453] : PSR2 standard does not allow closing tag for mixed PHP/HTML files +- Fixed bug [#457][sq-457] : FunctionCallSignature sniffs do not support here/nowdoc syntax and can cause syntax error when fixing +- Fixed bug [#466][sq-466] : PropertyLabelSpacing JS fixer issue when there is no space after colon +- Fixed bug [#473][sq-473] : Writing a report for an empty folder to existing file includes the existing contents +- Fixed bug [#485][sq-485] : PHP notice in Squiz.Commenting.FunctionComment when checking malformed @throws comment +- Fixed bug [#491][sq-491] : Generic InlineControlStructureSniff can correct with missing semicolon - Thanks to [Jesse Donat][@donatj] for the patch -- Fixed bug #492 : Use statements don't increase the scope indent -- Fixed bug #493 : PSR1_Sniffs_Methods_CamelCapsMethodNameSniff false positives for some magic method detection +- Fixed bug [#492][sq-492] : Use statements don't increase the scope indent +- Fixed bug [#493][sq-493] : PSR1_Sniffs_Methods_CamelCapsMethodNameSniff false positives for some magic method detection - Thanks to [Andreas Möller][@localheinz] for the patch -- Fixed bug #496 : Closures in PSR2 are not checked for a space after the function keyword -- Fixed bug #497 : Generic InlineControlStructureSniff does not support alternative SWITCH syntax -- Fixed bug #500 : Functions not supported as values in Squiz ArrayDeclaration sniff -- Fixed bug #501 : ScopeClosingBrace and ScopeIndent conflict with closures used as array values +- Fixed bug [#496][sq-496] : Closures in PSR2 are not checked for a space after the function keyword +- Fixed bug [#497][sq-497] : Generic InlineControlStructureSniff does not support alternative SWITCH syntax +- Fixed bug [#500][sq-500] : Functions not supported as values in Squiz ArrayDeclaration sniff +- Fixed bug [#501][sq-501] : ScopeClosingBrace and ScopeIndent conflict with closures used as array values - Generic ScopeIndentSniff may now report fewer errors for closures, but perform the same fixes -- Fixed bug #502 : PSR1 SideEffectsSniff sees declare() statements as side effects +- 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 +[sq-457]: https://github.com/squizlabs/PHP_CodeSniffer/issues/457 +[sq-466]: https://github.com/squizlabs/PHP_CodeSniffer/issues/466 +[sq-473]: https://github.com/squizlabs/PHP_CodeSniffer/issues/473 +[sq-476]: https://github.com/squizlabs/PHP_CodeSniffer/issues/476 +[sq-485]: https://github.com/squizlabs/PHP_CodeSniffer/issues/485 +[sq-486]: https://github.com/squizlabs/PHP_CodeSniffer/issues/486 +[sq-490]: https://github.com/squizlabs/PHP_CodeSniffer/issues/490 +[sq-491]: https://github.com/squizlabs/PHP_CodeSniffer/pull/491 +[sq-492]: https://github.com/squizlabs/PHP_CodeSniffer/pull/492 +[sq-493]: https://github.com/squizlabs/PHP_CodeSniffer/pull/493 +[sq-496]: https://github.com/squizlabs/PHP_CodeSniffer/issues/496 +[sq-497]: https://github.com/squizlabs/PHP_CodeSniffer/issues/497 +[sq-500]: https://github.com/squizlabs/PHP_CodeSniffer/issues/500 +[sq-501]: https://github.com/squizlabs/PHP_CodeSniffer/issues/501 +[sq-502]: https://github.com/squizlabs/PHP_CodeSniffer/issues/502 ## [2.2.0] - 2015-01-22 ### Changed @@ -3013,24 +3840,24 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - PHP and JS functions and closures are now treated the same way - Squiz MultiLineFunctionDeclarationSniff now supports JS files - Interactive mode no longer breaks if you also specify a report type on the command line -- PEAR InlineCommentSniff now fixes the Perl-style comments that it finds (request #375) +- PEAR InlineCommentSniff now fixes the Perl-style comments that it finds (request [#375][sq-375]) - PSR2 standard no longer fixes the placement of docblock open tags as comments are excluded from this standard - PSR2 standard now sets a default tab width of 4 spaces -- Generic DocCommentSniff now only disallows lowercase letters at the start of a long/short comment (request #377) +- Generic DocCommentSniff now only disallows lowercase letters at the start of a long/short comment (request [#377][sq-377]) - All non-letter characters are now allowed, including markdown special characters and numbers -- Generic DisallowMultipleStatementsSniff now allows multiple open/close tags on the same line (request #423) -- Generic CharacterBeforePHPOpeningTagSniff now only checks the first PHP tag it finds (request #423) -- Generic CharacterBeforePHPOpeningTagSniff now allows a shebang line at the start of the file (request #20481) -- Generic InlineHTMLUnitTest now allows a shebang line at the start of the file (request #20481) +- Generic DisallowMultipleStatementsSniff now allows multiple open/close tags on the same line (request [#423][sq-423]) +- Generic CharacterBeforePHPOpeningTagSniff now only checks the first PHP tag it finds (request [#423][sq-423]) +- Generic CharacterBeforePHPOpeningTagSniff now allows a shebang line at the start of the file (request [#20481][pear-20481]) +- Generic InlineHTMLUnitTest now allows a shebang line at the start of the file (request [#20481][pear-20481]) - PEAR ObjectOperatorIndentSniff now only checks object operators at the start of a line - PEAR FileComment and ClassComment sniffs no longer have @ in their error codes - E.g., PEAR.Commenting.FileComment.Missing@categoryTag becomes PEAR.Commenting.FileComment.MissingCategoryTag - Thanks to [Grzegorz Rygielski][@grzr] for the patch - Squiz ControlStructureSpacingSniff no longer enforces a blank line before CATCH statements -- Squiz FunctionCommentSniff now fixes the return type in the @return tag (request #392) +- Squiz FunctionCommentSniff now fixes the return type in the @return tag (request [#392][sq-392]) - Squiz BlockCommentSniff now only disallows lowercase letters at the start of the comment - Squiz InlineCommentSniff now only disallows lowercase letters at the start of the comment -- Squiz OperatorSpacingSniff now has a setting to ignore newline characters around operators (request #348) +- Squiz OperatorSpacingSniff now has a setting to ignore newline characters around operators (request [#348][sq-348]) - Default remains FALSE, so newlines are not allowed - Override the "ignoreNewlines" setting in a ruleset.xml file to change - PSR2 ControlStructureSpacingSniff now checks for, and fixes, newlines after the opening parenthesis @@ -3038,28 +3865,52 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Stefano Kowalke][@Konafets] for the contribution ### Fixed -- Fixed bug #379 : Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast incorrectly detects comments -- Fixed bug #382 : JS tokenizer incorrect for inline conditionally created immediately invoked anon function -- Fixed bug #383 : Squiz.Arrays.ArrayDeclaration.ValueNoNewline incorrectly detects nested arrays -- Fixed bug #386 : Undefined offset in Squiz.FunctionComment sniff when param has no comment -- Fixed bug #390 : Indentation of non-control structures isn't adjusted when containing structure is fixed -- Fixed bug #400 : InlineControlStructureSniff fails to fix when statement has no semicolon -- Fixed bug #401 : PHPCBF no-patch option shows an error when there are no fixable violations in a file -- Fixed bug #405 : The "Squiz.WhiteSpace.FunctionSpacing" sniff removes class "}" during fixing -- Fixed bug #407 : PEAR.ControlStructures.MultiLineCondition doesn't account for comments at the end of lines -- Fixed bug #410 : The "Squiz.WhiteSpace.MemberVarSpacing" not respecting "var" -- Fixed bug #411 : Generic.WhiteSpace.ScopeIndent.Incorrect - false positive with multiple arrays in argument list -- Fixed bug #412 : PSR2 multi-line detection doesn't work for inline IF and string concats -- Fixed bug #414 : Squiz.WhiteSpace.MemberVarSpacing - inconsistent checking of member vars with comment -- Fixed bug #433 : Wrong detection of Squiz.Arrays.ArrayDeclaration.KeyNotAligned when key contains space -- Fixed bug #434 : False positive for spacing around "=>" in inline array within foreach -- Fixed bug #452 : Ruleset exclude-pattern for specific sniff code ignored when using CLI --ignore option -- Fixed bug #20482 : Scope indent sniff can get into infinite loop when processing a parse error +- Fixed bug [#379][sq-379] : Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast incorrectly detects comments +- Fixed bug [#382][sq-382] : JS tokenizer incorrect for inline conditionally created immediately invoked anon function +- Fixed bug [#383][sq-383] : Squiz.Arrays.ArrayDeclaration.ValueNoNewline incorrectly detects nested arrays +- Fixed bug [#386][sq-386] : Undefined offset in Squiz.FunctionComment sniff when param has no comment +- Fixed bug [#390][sq-390] : Indentation of non-control structures isn't adjusted when containing structure is fixed +- Fixed bug [#400][sq-400] : InlineControlStructureSniff fails to fix when statement has no semicolon +- Fixed bug [#401][sq-401] : PHPCBF no-patch option shows an error when there are no fixable violations in a file +- Fixed bug [#405][sq-405] : The "Squiz.WhiteSpace.FunctionSpacing" sniff removes class "}" during fixing +- Fixed bug [#407][sq-407] : PEAR.ControlStructures.MultiLineCondition doesn't account for comments at the end of lines +- Fixed bug [#410][sq-410] : The "Squiz.WhiteSpace.MemberVarSpacing" not respecting "var" +- Fixed bug [#411][sq-411] : Generic.WhiteSpace.ScopeIndent.Incorrect - false positive with multiple arrays in argument list +- Fixed bug [#412][sq-412] : PSR2 multi-line detection doesn't work for inline IF and string concats +- Fixed bug [#414][sq-414] : Squiz.WhiteSpace.MemberVarSpacing - inconsistent checking of member vars with comment +- Fixed bug [#433][sq-433] : Wrong detection of Squiz.Arrays.ArrayDeclaration.KeyNotAligned when key contains space +- Fixed bug [#434][sq-434] : False positive for spacing around "=>" in inline array within foreach +- Fixed bug [#452][sq-452] : Ruleset exclude-pattern for specific sniff code ignored when using CLI --ignore option +- Fixed bug [#20482][pear-20482] : Scope indent sniff can get into infinite loop when processing a parse error + +[sq-348]: https://github.com/squizlabs/PHP_CodeSniffer/issues/348 +[sq-375]: https://github.com/squizlabs/PHP_CodeSniffer/issues/375 +[sq-377]: https://github.com/squizlabs/PHP_CodeSniffer/issues/377 +[sq-379]: https://github.com/squizlabs/PHP_CodeSniffer/issues/379 +[sq-382]: https://github.com/squizlabs/PHP_CodeSniffer/issues/382 +[sq-383]: https://github.com/squizlabs/PHP_CodeSniffer/issues/383 +[sq-386]: https://github.com/squizlabs/PHP_CodeSniffer/issues/386 +[sq-390]: https://github.com/squizlabs/PHP_CodeSniffer/issues/390 +[sq-392]: https://github.com/squizlabs/PHP_CodeSniffer/issues/392 +[sq-400]: https://github.com/squizlabs/PHP_CodeSniffer/issues/400 +[sq-401]: https://github.com/squizlabs/PHP_CodeSniffer/issues/401 +[sq-405]: https://github.com/squizlabs/PHP_CodeSniffer/issues/405 +[sq-407]: https://github.com/squizlabs/PHP_CodeSniffer/issues/407 +[sq-410]: https://github.com/squizlabs/PHP_CodeSniffer/issues/410 +[sq-411]: https://github.com/squizlabs/PHP_CodeSniffer/issues/411 +[sq-412]: https://github.com/squizlabs/PHP_CodeSniffer/issues/412 +[sq-414]: https://github.com/squizlabs/PHP_CodeSniffer/issues/414 +[sq-423]: https://github.com/squizlabs/PHP_CodeSniffer/issues/423 +[sq-433]: https://github.com/squizlabs/PHP_CodeSniffer/issues/433 +[sq-434]: https://github.com/squizlabs/PHP_CodeSniffer/issues/434 +[sq-452]: https://github.com/squizlabs/PHP_CodeSniffer/issues/452 +[pear-20481]: https://pear.php.net/bugs/bug.php?id=20481 +[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) -- A tilde can now be used to reference a user's home directory in a path to a standard (request #353) +- 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]) - Added PHP_CodeSniffer_File::findStartOfStatement() to find the first non-whitespace token in a statement - Possible alternative for code using PHP_CodeSniffer_File::findPrevious() with the local flag set - Added PHP_CodeSniffer_File::findEndOfStatement() to find the last non-whitespace token in a statement @@ -3068,7 +3919,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Affects OpeningFunctionBraceBsdAllmanSniff and OpeningFunctionBraceKernighanRitchieSniff - Also enforced in PEAR FunctionDeclarationSniff and Squiz MultiLineFunctionDeclarationSniff - Generic DisallowTabIndentSniff now replaces tabs everywhere it finds them, except in strings and here/now docs -- Generic EmptyStatementSniff error codes now contain the type of empty statement detected (request #314) +- 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 @@ -3078,7 +3929,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - PEAR and Squiz FunctionCommentSniffs no longer ban @return tags for constructors and destructors - Removed message PEAR.Commenting.FunctionComment.ReturnNotRequired - Removed message Squiz.Commenting.FunctionComment.ReturnNotRequired - - Change initiated by request #324 and request #369 + - Change initiated by request [#324][sq-324] and request [#369][sq-369] - Squiz EmptyStatementSniff has been removed - Squiz standard now includes Generic EmptyStatementSniff and turns off the empty CATCH error - Squiz ControlSignatureSniff fixes now retain comments between the closing parenthesis and open brace @@ -3087,21 +3938,41 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz ArrayDeclarationSniff now skips function calls while checking multi-line arrays ### Fixed -- Fixed bug #337 : False positive with anonymous functions in Generic_Sniffs_WhiteSpace_ScopeIndentSniff -- Fixed bug #339 : reformatting brace location can result in broken code -- Fixed bug #342 : Nested ternary operators not tokenized correctly -- Fixed bug #345 : Javascript regex not tokenized when inside array -- Fixed bug #346 : PHP path can't be determined in some cases in "phpcs.bat" (on Windows XP) -- Fixed bug #358 : False positives for Generic_Sniffs_WhiteSpace_ScopeIndentSniff -- Fixed bug #361 : Sniff-specific exclude patterns don't work for Windows -- Fixed bug #364 : Don't interpret "use function" as declaration -- Fixed bug #366 : phpcbf with PSR2 errors on control structure alternative syntax -- Fixed bug #367 : Nested Anonymous Functions Causing False Negative -- Fixed bug #371 : Shorthand binary cast causes tokenizer errors +- Fixed bug [#337][sq-337] : False positive with anonymous functions in Generic_Sniffs_WhiteSpace_ScopeIndentSniff +- Fixed bug [#339][sq-339] : reformatting brace location can result in broken code +- Fixed bug [#342][sq-342] : Nested ternary operators not tokenized correctly +- Fixed bug [#345][sq-345] : Javascript regex not tokenized when inside array +- Fixed bug [#346][sq-346] : PHP path can't be determined in some cases in "phpcs.bat" (on Windows XP) +- Fixed bug [#358][sq-358] : False positives for Generic_Sniffs_WhiteSpace_ScopeIndentSniff +- Fixed bug [#361][sq-361] : Sniff-specific exclude patterns don't work for Windows +- Fixed bug [#364][sq-364] : Don't interpret "use function" as declaration +- Fixed bug [#366][sq-366] : phpcbf with PSR2 errors on control structure alternative syntax +- Fixed bug [#367][sq-367] : Nested Anonymous Functions Causing False Negative +- Fixed bug [#371][sq-371] : Shorthand binary cast causes tokenizer errors - New token T_BINARY_CAST added for the b"string" cast format (the 'b' is the T_BINARY_CAST token) -- Fixed bug #372 : phpcbf parse problem, wrong brace placement for inline IF -- Fixed bug #373 : Double quote usage fix removing too many double quotes -- Fixed bug #20196 : 1.5.2 breaks scope_closer position +- Fixed bug [#372][sq-372] : phpcbf parse problem, wrong brace placement for inline IF +- Fixed bug [#373][sq-373] : Double quote usage fix removing too many double quotes +- Fixed bug [#20196][pear-20196] : 1.5.2 breaks scope_closer position + +[sq-314]: https://github.com/squizlabs/PHP_CodeSniffer/issues/314 +[sq-324]: https://github.com/squizlabs/PHP_CodeSniffer/issues/324 +[sq-335]: https://github.com/squizlabs/PHP_CodeSniffer/issues/335 +[sq-337]: https://github.com/squizlabs/PHP_CodeSniffer/issues/337 +[sq-339]: https://github.com/squizlabs/PHP_CodeSniffer/issues/339 +[sq-342]: https://github.com/squizlabs/PHP_CodeSniffer/issues/342 +[sq-345]: https://github.com/squizlabs/PHP_CodeSniffer/issues/345 +[sq-346]: https://github.com/squizlabs/PHP_CodeSniffer/issues/346 +[sq-353]: https://github.com/squizlabs/PHP_CodeSniffer/issues/353 +[sq-358]: https://github.com/squizlabs/PHP_CodeSniffer/issues/358 +[sq-361]: https://github.com/squizlabs/PHP_CodeSniffer/issues/361 +[sq-364]: https://github.com/squizlabs/PHP_CodeSniffer/pull/364 +[sq-366]: https://github.com/squizlabs/PHP_CodeSniffer/issues/366 +[sq-367]: https://github.com/squizlabs/PHP_CodeSniffer/issues/367 +[sq-369]: https://github.com/squizlabs/PHP_CodeSniffer/issues/369 +[sq-371]: https://github.com/squizlabs/PHP_CodeSniffer/issues/371 +[sq-372]: https://github.com/squizlabs/PHP_CodeSniffer/issues/372 +[sq-373]: https://github.com/squizlabs/PHP_CodeSniffer/issues/373 +[pear-20196]: https://pear.php.net/bugs/bug.php?id=20196 ## [2.0.0] - 2014-12-05 ### Changed @@ -3133,9 +4004,13 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Improved fixing of lines after cases statements in Squiz SwitchDeclarationSniff ### Fixed -- Fixed bug #311 : Suppression of function prototype breaks checking of lines within function -- Fixed bug #320 : Code sniffer indentation issue -- Fixed bug #333 : Nested ternary operators causing problems +- Fixed bug [#311][sq-311] : Suppression of function prototype breaks checking of lines within function +- 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 @@ -3152,11 +4027,17 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Thibaud Fabre][@fabre-thibaud] for the patch ### Fixed -- Fixed bug #280 : The --config-show option generates error when there is no config file -- Fixed bug #306 : File containing only a namespace declaration raises undefined index notice -- Fixed bug #308 : Squiz InlineIfDeclarationSniff fails on ternary operators inside closure -- Fixed bug #310 : Variadics not recognized by tokenizer -- Fixed bug #311 : Suppression of function prototype breaks checking of lines within function +- Fixed bug [#280][sq-280] : The --config-show option generates error when there is no config file +- Fixed bug [#306][sq-306] : File containing only a namespace declaration raises undefined index notice +- Fixed bug [#308][sq-308] : Squiz InlineIfDeclarationSniff fails on ternary operators inside closure +- 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 @@ -3182,14 +4063,23 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Running unit tests with the -v CLI argument no longer generates PHP errors ### Fixed -- Fixed bug #295 : ScopeIndentSniff hangs when processing nested closures -- Fixed bug #298 : False positive in ScopeIndentSniff when anonymous functions are used with method chaining -- Fixed bug #302 : Fixing code in Squiz InlineComment sniff can remove some comment text -- Fixed bug #303 : Open and close tag on same line can cause a PHP notice checking scope indent -- Fixed bug #306 : File containing only a namespace declaration raises undefined index notice -- Fixed bug #307 : Conditional breaks in case statements get incorrect indentations -- Fixed bug #308 : Squiz InlineIfDeclarationSniff fails on ternary operators inside closure -- Fixed bug #310 : Variadics not recognized by tokenizer +- Fixed bug [#295][sq-295] : ScopeIndentSniff hangs when processing nested closures +- Fixed bug [#298][sq-298] : False positive in ScopeIndentSniff when anonymous functions are used with method chaining +- Fixed bug [#302][sq-302] : Fixing code in Squiz InlineComment sniff can remove some comment text +- Fixed bug [#303][sq-303] : Open and close tag on same line can cause a PHP notice checking scope indent +- Fixed bug [#306][sq-306] : File containing only a namespace declaration raises undefined index notice +- Fixed bug [#307][sq-307] : Conditional breaks in case statements get incorrect indentations +- Fixed bug [#308][sq-308] : Squiz InlineIfDeclarationSniff fails on ternary operators inside closure +- Fixed bug [#310][sq-310] : Variadics not recognized by tokenizer + +[sq-295]: https://github.com/squizlabs/PHP_CodeSniffer/issues/295 +[sq-298]: https://github.com/squizlabs/PHP_CodeSniffer/issues/298 +[sq-302]: https://github.com/squizlabs/PHP_CodeSniffer/issues/302 +[sq-303]: https://github.com/squizlabs/PHP_CodeSniffer/issues/303 +[sq-306]: https://github.com/squizlabs/PHP_CodeSniffer/issues/306 +[sq-307]: https://github.com/squizlabs/PHP_CodeSniffer/issues/307 +[sq-308]: https://github.com/squizlabs/PHP_CodeSniffer/issues/308 +[sq-310]: https://github.com/squizlabs/PHP_CodeSniffer/issues/310 ## [2.0.0RC3] - 2014-10-16 ### Changed @@ -3210,26 +4100,29 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz EmbeddedPhpSniff now checks open and close tag indents and fixes some errors - Squiz FileCommentSniff no longer throws incorrect blank line before comment errors in JS files - Squiz ClassDeclarationSniff now has better checking for blank lines after a closing brace -- Removed error Squiz.Classes.ClassDeclaration.NoNewlineAfterCloseBrace (request #285) +- Removed error Squiz.Classes.ClassDeclaration.NoNewlineAfterCloseBrace (request [#285][sq-285]) - Already handled by Squiz.Classes.ClassDeclaration.CloseBraceSameLine ### Fixed -- Fixed bug #280 : The --config-show option generates error when there is no config file +- Fixed bug [#280][sq-280] : The --config-show option generates error when there is no config file + +[sq-280]: https://github.com/squizlabs/PHP_CodeSniffer/issues/280 +[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 and bug #19899) +- 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 - Fixed incorrect length of JS object operator tokens - PHP tokenizer no longer converts class/function names to special tokens types - Class/function names such as parent and true would become special tokens such as T_PARENT and T_TRUE -- PHPCS can now exit with 0 if only warnings were found (request #262) +- PHPCS can now exit with 0 if only warnings were found (request [#262][sq-262]) - Set the ignore_warnings_on_exit config variable to 1 to set this behaviour - Default remains at exiting with 0 only if no errors and no warnings were found - Also changes return value of PHP_CodeSniffer_Reporting::printReport() - Rulesets can now set associative array properties - property name="[property]" type="array" value="foo=>bar,baz=>qux" -- Generic ForbiddenFunctionsSniff now has a public property called forbiddenFunctions (request #263) +- 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 - e.g., value="delete=>unset,print=>echo,create_function=>null" @@ -3241,14 +4134,14 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - If 2 sniffs look to be conflicting, one change will be ignored to allow a fix to occur - Generic CamelCapsFunctionNameSniff now ignores a single leading underscore - Thanks to [Alex Slobodiskiy][@xt99] for the patch -- Standards can now be located within hidden directories (further fix for bug #20323) +- Standards can now be located within hidden directories (further fix for bug [#20323][pear-20323]) - Thanks to [Klaus Purer][@klausi] for the patch - Sniff ignore patterns now replace Win dir separators like file ignore patterns already did - Exclude patterns now use backtick delimiters, allowing all special characters to work correctly again - Thanks to [Jeremy Edgell][@jedgell] for the patch - Errors converted to warnings in a ruleset (and vice versa) now retain their fixable status - Thanks to [Alexander Obuhovich][@aik099] for the patch -- Squiz ConcatenationSpacingSniff now has a setting to specify how many spaces there should around concat operators +- Squiz ConcatenationSpacingSniff now has a setting to specify how many spaces there should be around concat operators - Default remains at 0 - Override the "spacing" setting in a ruleset.xml file to change - Added auto-fixes for Squiz InlineCommentSniff @@ -3266,15 +4159,29 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Generic UpperCaseConstantSniff and LowerCaseConstantSniff now ignore function names ### Fixed -- Fixed bug #243 : Missing DocBlock not detected -- Fixed bug #248 : FunctionCommentSniff expects ampersand on param name -- Fixed bug #265 : False positives with type hints in ForbiddenFunctionsSniff -- Fixed bug #20373 : Inline comment sniff tab handling way -- Fixed bug #20377 : Error when trying to execute phpcs with report=json -- Fixed bug #20378 : Report appended to existing file if no errors found in run -- Fixed bug #20381 : Invalid "Comment closer must be on a new line" +- Fixed bug [#243][sq-243] : Missing DocBlock not detected +- Fixed bug [#248][sq-248] : FunctionCommentSniff expects ampersand on param name +- Fixed bug [#265][sq-265] : False positives with type hints in ForbiddenFunctionsSniff +- Fixed bug [#20373][pear-20373] : Inline comment sniff tab handling way +- Fixed bug [#20377][pear-20377] : Error when trying to execute phpcs with report=json +- Fixed bug [#20378][pear-20378] : Report appended to existing file if no errors found in run +- Fixed bug [#20381][pear-20381] : Invalid "Comment closer must be on a new line" - Thanks to [Brad Kent][@bkdotcom] for the patch -- Fixed bug #20402 : SVN pre-commit hook fails due to unknown argument error +- 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 @@ -3284,7 +4191,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Improved indented PHP tag support in Generic ScopeIndentSniff - Generic CamelCapsFunctionNameSniff now ignores a single leading underscore - Thanks to [Alex Slobodiskiy][@xt99] for the patch -- Standards can now be located within hidden directories (further fix for bug #20323) +- Standards can now be located within hidden directories (further fix for bug [#20323][pear-20323]) - Thanks to [Klaus Purer][@klausi] for the patch - Added Generic SyntaxSniff to check for syntax errors in PHP files - Thanks to [Blaine Schmeisser][@bayleedev] for the contribution @@ -3294,18 +4201,26 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Generic UpperCaseConstantSniff and LowerCaseConstantSniff now ignore function names ### Fixed -- Fixed bug #248 : FunctionCommentSniff expects ampersand on param name -- Fixed bug #265 : False positives with type hints in ForbiddenFunctionsSniff -- Fixed bug #20373 : Inline comment sniff tab handling way -- Fixed bug #20378 : Report appended to existing file if no errors found in run -- Fixed bug #20381 : Invalid "Comment closer must be on a new line" +- Fixed bug [#248][sq-248] : FunctionCommentSniff expects ampersand on param name +- Fixed bug [#265][sq-265] : False positives with type hints in ForbiddenFunctionsSniff +- Fixed bug [#20373][pear-20373] : Inline comment sniff tab handling way +- Fixed bug [#20378][pear-20378] : Report appended to existing file if no errors found in run +- Fixed bug [#20381][pear-20381] : Invalid "Comment closer must be on a new line" - Thanks to [Brad Kent][@bkdotcom] for the patch -- Fixed bug #20386 : Squiz.Commenting.ClassComment.SpacingBefore thrown if first block comment +- Fixed bug [#20386][pear-20386] : Squiz.Commenting.ClassComment.SpacingBefore thrown if first block comment + +[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 exists cleanly when there are no errors to fix +- PHPCBF now exits cleanly when there are no errors to fix - Added phpcbf.bat file for Windows - Verbose option no longer errors when using a phar file with a space in the path - Fixed a reporting error when using HHVM @@ -3323,7 +4238,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - The filtering component of the --extensions argument is now ignored again when passing filenames - Can still be used to specify a custom tokenizer for each extension when passing filenames - If no tokenizer is specified, default values will be used for common file extensions -- Diff report now produces relative paths on Windows, where possible (further fix for bug #20234) +- Diff report now produces relative paths on Windows, where possible (further fix for bug [#20234][pear-20234]) - If a token's content has been modified by the tab-width setting, it will now have an orig_content in the tokens array - Generic DisallowSpaceIndent and DisallowTabIndent sniffs now check original indent content even when tab-width is set - Previously, setting --tab-width would force both to check the indent as spaces @@ -3347,29 +4262,46 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Ole Martin Handeland][@olemartinorg] for the patch - Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore namespaces beginning with TRUE/FALSE/NULL - Thanks to [Renan Gonçalves][@renan] for the patch -- Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request #20299) +- Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request [#20299][pear-20299]) - Squiz SelfMemberReferenceSniff now works correctly with namespaces - Squiz FunctionCommentSniff is now more relaxed when checking namespaced type hints -- Tab characters are now encoded in abstract pattern errors messages +- Tab characters are now encoded in abstract pattern error messages - Thanks to [Blaine Schmeisser][@bayleedev] for the patch -- Invalid sniff codes passed to --sniffs now show a friendly error message (request #20313) -- Generic LineLengthSniff now shows a warning if the iconv module is disabled (request #20314) +- Invalid sniff codes passed to --sniffs now show a friendly error message (request [#20313][pear-20313]) +- Generic LineLengthSniff now shows a warning if the iconv module is disabled (request [#20314][pear-20314]) - Source report no longer shows errors if category or sniff names ends in an uppercase error - Thanks to [Jonathan Marcil][@jmarcil] for the patch ### Fixed -- Fixed bug #20261 : phpcbf has an endless fixing loop -- Fixed bug #20268 : Incorrect documentation titles in PEAR documentation -- Fixed bug #20296 : new array notion in function comma check fails -- Fixed bug #20297 : phar does not work when renamed it to phpcs -- Fixed bug #20307 : PHP_CodeSniffer_Standards_AbstractVariableSniff analyze traits -- Fixed bug #20308 : Squiz.ValidVariableNameSniff - wrong variable usage -- Fixed bug #20309 : Use "member variable" term in sniff "processMemberVar" method -- Fixed bug #20310 : PSR2 does not check for space after function name -- Fixed bug #20322 : Display rules set to type=error even when suppressing warnings -- Fixed bug #20323 : PHPCS tries to load sniffs from hidden directories -- Fixed bug #20346 : Fixer endless loop with Squiz.CSS sniffs -- Fixed bug #20355 : No sniffs are registered with PHAR on Windows +- Fixed bug [#20261][pear-20261] : phpcbf has an endless fixing loop +- Fixed bug [#20268][pear-20268] : Incorrect documentation titles in PEAR documentation +- Fixed bug [#20296][pear-20296] : new array notion in function comma check fails +- Fixed bug [#20297][pear-20297] : phar does not work when renamed it to phpcs +- Fixed bug [#20307][pear-20307] : PHP_CodeSniffer_Standards_AbstractVariableSniff analyze traits +- Fixed bug [#20308][pear-20308] : Squiz.ValidVariableNameSniff - wrong variable usage +- Fixed bug [#20309][pear-20309] : Use "member variable" term in sniff "processMemberVar" method +- Fixed bug [#20310][pear-20310] : PSR2 does not check for space after function name +- Fixed bug [#20322][pear-20322] : Display rules set to type=error even when suppressing warnings +- Fixed bug [#20323][pear-20323] : PHPCS tries to load sniffs from hidden directories +- 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 @@ -3386,24 +4318,36 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Ole Martin Handeland][@olemartinorg] for the patch - Generic LowerCaseConstantSniff and UpperCaseConstantSniff now ignore namespaces beginning with TRUE/FALSE/NULL - Thanks to [Renan Gonçalves][@renan] for the patch -- Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request #20299) +- Squiz InlineCommentSniff no longer requires a blank line after post-statement comments (request [#20299][pear-20299]) - Squiz SelfMemberReferenceSniff now works correctly with namespaces -- Tab characters are now encoded in abstract pattern errors messages +- Tab characters are now encoded in abstract pattern error messages - Thanks to [Blaine Schmeisser][@bayleedev] for the patch -- Invalid sniff codes passed to --sniffs now show a friendly error message (request #20313) -- Generic LineLengthSniff now shows a warning if the iconv module is disabled (request #20314) +- Invalid sniff codes passed to --sniffs now show a friendly error message (request [#20313][pear-20313]) +- Generic LineLengthSniff now shows a warning if the iconv module is disabled (request [#20314][pear-20314]) - Source report no longer shows errors if category or sniff names ends in an uppercase error - Thanks to [Jonathan Marcil][@jmarcil] for the patch ### Fixed -- Fixed bug #20268 : Incorrect documentation titles in PEAR documentation -- Fixed bug #20296 : new array notion in function comma check fails -- Fixed bug #20307 : PHP_CodeSniffer_Standards_AbstractVariableSniff analyze traits -- Fixed bug #20308 : Squiz.ValidVariableNameSniff - wrong variable usage -- Fixed bug #20309 : Use "member variable" term in sniff "processMemberVar" method -- Fixed bug #20310 : PSR2 does not check for space after function name -- Fixed bug #20322 : Display rules set to type=error even when suppressing warnings -- Fixed bug #20323 : PHPCS tries to load sniffs from hidden directories +- Fixed bug [#20268][pear-20268] : Incorrect documentation titles in PEAR documentation +- Fixed bug [#20296][pear-20296] : new array notion in function comma check fails +- Fixed bug [#20307][pear-20307] : PHP_CodeSniffer_Standards_AbstractVariableSniff analyze traits +- Fixed bug [#20308][pear-20308] : Squiz.ValidVariableNameSniff - wrong variable usage +- Fixed bug [#20309][pear-20309] : Use "member variable" term in sniff "processMemberVar" method +- Fixed bug [#20310][pear-20310] : PSR2 does not check for space after function name +- Fixed bug [#20322][pear-20322] : Display rules set to type=error even when suppressing warnings +- Fixed bug [#20323][pear-20323] : PHPCS tries to load sniffs from hidden directories + +[pear-20268]: https://pear.php.net/bugs/bug.php?id=20268 +[pear-20296]: https://pear.php.net/bugs/bug.php?id=20296 +[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 ## [2.0.0a2] - 2014-05-01 ### Changed @@ -3429,7 +4373,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - PSR1 CamelCapsMethodNameSniff now ignores magic methods - Thanks to [Eser Ozvataf][@eser] for the patch - PSR1 SideEffectsSniff now ignores methods named define() -- PSR1 and PEAR ClassDeclarationSniffs now support traits (request #20208) +- PSR1 and PEAR ClassDeclarationSniffs now support traits (request [#20208][pear-20208]) - PSR2 ControlStructureSpacingSniff now allows newlines before/after parentheses - Thanks to [Maurus Cuelenaere][@mcuelenaere] for the patch - PSR2 ControlStructureSpacingSniff now checks TRY and CATCH statements @@ -3440,20 +4384,33 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz SwitchDeclarationSniff now allows exit() as a breaking statement for case/default - Squiz ValidVariableNameSniff and Zend ValidVariableNameSniff now ignore additional PHP reserved vars - Thanks to Mikuláš Dítě and Adrian Crepaz for the patch -- Sniff code Squiz.WhiteSpace.MemberVarSpacing.After changed to Squiz.WhiteSpace.MemberVarSpacing.Incorrect (request #20241) +- Sniff code Squiz.WhiteSpace.MemberVarSpacing.After changed to Squiz.WhiteSpace.MemberVarSpacing.Incorrect (request [#20241][pear-20241]) ### Fixed -- Fixed bug #20200 : Invalid JSON produced with specific error message -- Fixed bug #20204 : Ruleset exclude checks are case sensitive -- Fixed bug #20213 : Invalid error, Inline IF must be declared on single line -- Fixed bug #20225 : array_merge() that takes more than one line generates error -- Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting -- Fixed bug #20234 : phpcbf patch command absolute paths -- Fixed bug #20240 : Squiz block comment sniff fails when newline present -- Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while +- Fixed bug [#20200][pear-20200] : Invalid JSON produced with specific error message +- Fixed bug [#20204][pear-20204] : Ruleset exclude checks are case sensitive +- Fixed bug [#20213][pear-20213] : Invalid error, Inline IF must be declared on single line +- Fixed bug [#20225][pear-20225] : array_merge() that takes more than one line generates error +- Fixed bug [#20230][pear-20230] : Squiz ControlStructureSpacing sniff assumes specific condition formatting +- Fixed bug [#20234][pear-20234] : phpcbf patch command absolute paths +- Fixed bug [#20240][pear-20240] : Squiz block comment sniff fails when newline present +- Fixed bug [#20247][pear-20247] : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while - Thanks to [Alexander Obuhovich][@aik099] for the patch -- Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope -- Fixed bug #20252 : Unitialized string offset when package name starts with underscore +- 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 @@ -3462,7 +4419,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - PSR1 CamelCapsMethodNameSniff now ignores magic methods - Thanks to [Eser Ozvataf][@eser] for the patch - PSR1 SideEffectsSniff now ignores methods named define() -- PSR1 and PEAR ClassDeclarationSniffs now support traits (request #20208) +- PSR1 and PEAR ClassDeclarationSniffs now support traits (request [#20208][pear-20208]) - PSR2 ControlStructureSpacingSniff now allows newlines before/after parentheses - Thanks to [Maurus Cuelenaere][@mcuelenaere] for the patch - Squiz LowercasePHPFunctionsSniff no longer reports errors for namespaced functions @@ -3470,19 +4427,31 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Squiz SwitchDeclarationSniff now allows exit() as a breaking statement for case/default - Squiz ValidVariableNameSniff and Zend ValidVariableNameSniff now ignore additional PHP reserved vars - Thanks to Mikuláš Dítě and Adrian Crepaz for the patch -- Sniff code Squiz.WhiteSpace.MemberVarSpacing.After changed to Squiz.WhiteSpace.MemberVarSpacing.Incorrect (request #20241) +- Sniff code Squiz.WhiteSpace.MemberVarSpacing.After changed to Squiz.WhiteSpace.MemberVarSpacing.Incorrect (request [#20241][pear-20241]) ### Fixed -- Fixed bug #20200 : Invalid JSON produced with specific error message -- Fixed bug #20204 : Ruleset exclude checks are case sensitive -- Fixed bug #20213 : Invalid error, Inline IF must be declared on single line -- Fixed bug #20225 : array_merge() that takes more than one line generates error -- Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting -- Fixed bug #20240 : Squiz block comment sniff fails when newline present -- Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while +- Fixed bug [#20200][pear-20200] : Invalid JSON produced with specific error message +- Fixed bug [#20204][pear-20204] : Ruleset exclude checks are case sensitive +- Fixed bug [#20213][pear-20213] : Invalid error, Inline IF must be declared on single line +- Fixed bug [#20225][pear-20225] : array_merge() that takes more than one line generates error +- Fixed bug [#20230][pear-20230] : Squiz ControlStructureSpacing sniff assumes specific condition formatting +- Fixed bug [#20240][pear-20240] : Squiz block comment sniff fails when newline present +- Fixed bug [#20247][pear-20247] : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while - Thanks to [Alexander Obuhovich][@aik099] for the patch -- Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope -- Fixed bug #20252 : Uninitialized string offset when package name starts with underscore +- Fixed bug [#20248][pear-20248] : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope +- Fixed bug [#20252][pear-20252] : Uninitialized 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-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 ## [2.0.0a1] - 2014-02-05 ### Changed @@ -3497,7 +4466,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - e.g., arg name="report" value="summary" (print summary report; same as --report=summary) - e.g., arg value="sp" (print source and progress information; same as -sp) - The -vvv, --sniffs, --standard and -l command line arguments cannot be set in this way -- Sniff process() methods can not optionally return a token to ignore up to +- 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 - Removed the comment parser classes and replaced it with a simple comment tokenizer @@ -3569,10 +4538,15 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Generic FixmeSniff and TodoSniff now work correctly with accented characters ### Fixed -- Fixed bug #20145 : Custom ruleset preferences directory over installed standard -- Fixed bug #20147 : phpcs-svn-pre-commit - no more default error report -- Fixed bug #20151 : Problem handling "if(): ... else: ... endif;" syntax -- Fixed bug #20190 : Invalid regex in Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff +- Fixed bug [#20145][pear-20145] : Custom ruleset preferences directory over installed standard +- Fixed bug [#20147][pear-20147] : phpcs-svn-pre-commit - no more default error report +- Fixed bug [#20151][pear-20151] : Problem handling "if(): ... else: ... endif;" syntax +- Fixed bug [#20190][pear-20190] : Invalid regex in Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff + +[pear-20145]: https://pear.php.net/bugs/bug.php?id=20145 +[pear-20147]: https://pear.php.net/bugs/bug.php?id=20147 +[pear-20151]: https://pear.php.net/bugs/bug.php?id=20151 +[pear-20190]: https://pear.php.net/bugs/bug.php?id=20190 ## [1.5.1] - 2013-12-12 ### Changed @@ -3591,13 +4565,18 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - PSR2 ClassDeclarationSniff now allows a list of extended interfaces to be split across multiple lines - Squiz DoubleQuoteUsageSniff now allows \b in double quoted strings - Generic ForbiddenFunctionsSniff now ignores object creation - - This is a further fix for bug #20100 : incorrect Function mysql() has been deprecated report + - This is a further fix for bug [#20100][pear-20100] : incorrect Function mysql() has been deprecated report ### Fixed -- Fixed bug #20136 : Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff and Traits -- Fixed bug #20138 : Protected property underscore and camel caps issue (in trait with Zend) +- Fixed bug [#20136][pear-20136] : Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff and Traits +- Fixed bug [#20138][pear-20138] : Protected property underscore and camel caps issue (in trait with Zend) - Thanks to [Gaetan Rousseau][@Naelyth] for the patch -- Fixed bug #20139 : No report file generated on success +- 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 @@ -3607,9 +4586,9 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - E.g., to ignore comments, override a property using: - name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT" - PSR2 standard now ignores comments when checking indentation rules -- Generic UpperCaseConstantNameSniff no longer reports errors where constants are used (request #20090) +- Generic UpperCaseConstantNameSniff no longer reports errors where constants are used (request [#20090][pear-20090]) - It still reports errors where constants are defined -- Individual messages can now be excluded in ruleset.xml files using the exclude tag (request #20091) +- Individual messages can now be excluded in ruleset.xml files using the exclude tag (request [#20091][pear-20091]) - Setting message severity to 0 continues to be supported - Squiz OperatorSpacingSniff no longer throws errors for the ?: short ternary operator - Thanks to [Antoine Musso][@hashar] for the patch @@ -3622,13 +4601,23 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo - Thanks to [Maksim Kochkin][@ksimka] for the patch ### Fixed -- Fixed bug #20093 : Bug with ternary operator token -- Fixed bug #20097 : CLI.php throws error in php 5.2 -- Fixed bug #20100 : incorrect Function mysql() has been deprecated report -- Fixed bug #20119 : PHP warning: invalid argument to str_repeat() in SVN blame report with -s -- Fixed bug #20123 : PSR2 complains about an empty second statement in for-loop -- Fixed bug #20131 : PHP errors in svnblame report, if there are files not under version control -- Fixed bug #20133 : Allow "HG: hg_id" as value for @version tag +- 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 [#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-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 @@ -5393,6 +6382,8 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo --> [Unreleased]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/master...HEAD +[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 [3.8.0]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.2...3.8.0 [3.7.2]: https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.7.1...3.7.2 @@ -5502,6 +6493,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@andrei-propertyguru]: https://github.com/andrei-propertyguru [@AndrewDawes]: https://github.com/AndrewDawes [@andygrunwald]: https://github.com/andygrunwald +[@andypost]: https://github.com/andypost [@annechko]: https://github.com/annechko [@anomiex]: https://github.com/anomiex [@arnested]: https://github.com/arnested @@ -5584,13 +6576,16 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@jeffslofish]: https://github.com/jeffslofish [@jmarcil]: https://github.com/jmarcil [@jnrbsn]: https://github.com/jnrbsn +[@joachim-n]: https://github.com/joachim-n [@joelposti]: https://github.com/joelposti [@johanderuijter]: https://github.com/johanderuijter [@johnmaguire]: https://github.com/johnmaguire [@johnpbloch]: https://github.com/johnpbloch +[@jonmcp]: https://github.com/jonmcp [@JorisDebonnet]: https://github.com/JorisDebonnet [@josephzidell]: https://github.com/josephzidell [@joshdavis11]: https://github.com/joshdavis11 +[@jpoliveira08]: https://github.com/jpoliveira08 [@jpuck]: https://github.com/jpuck [@jrfnl]: https://github.com/jrfnl [@kdebisschop]: https://github.com/kdebisschop @@ -5642,6 +6637,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@r3nat]: https://github.com/r3nat [@raul338]: https://github.com/raul338 [@realmfoo]: https://github.com/realmfoo +[@remicollet]: https://github.com/remicollet [@renaatdemuynck]: https://github.com/renaatdemuynck [@renan]: https://github.com/renan [@rhorber]: https://github.com/rhorber @@ -5677,6 +6673,7 @@ Additionally, thanks to [Alexander Turek][@derrabus] for consulting on the repo [@thomasjfox]: https://github.com/thomasjfox [@till]: https://github.com/till [@timoschinkel]: https://github.com/timoschinkel +[@TimWolla]: https://github.com/TimWolla [@uniquexor]: https://github.com/uniquexor [@valorin]: https://github.com/valorin [@VasekPurchart]: https://github.com/VasekPurchart diff --git a/vendor/squizlabs/php_codesniffer/README.md b/vendor/squizlabs/php_codesniffer/README.md index 383fed2a..d375015b 100644 --- a/vendor/squizlabs/php_codesniffer/README.md +++ b/vendor/squizlabs/php_codesniffer/README.md @@ -15,7 +15,7 @@ PHP_CodeSniffer > [!NOTE] -> This package is the continuation of the now abandoned [PHP_CodeSniffer package which was created by Squizlabs](https://github.com/squizlabs/PHP_CodeSniffer). +> This package is the official continuation of the now abandoned [PHP_CodeSniffer package which was created by Squizlabs](https://github.com/squizlabs/PHP_CodeSniffer). ## About diff --git a/vendor/squizlabs/php_codesniffer/autoload.php b/vendor/squizlabs/php_codesniffer/autoload.php index 7e546bb5..d7d655e8 100644 --- a/vendor/squizlabs/php_codesniffer/autoload.php +++ b/vendor/squizlabs/php_codesniffer/autoload.php @@ -16,6 +16,9 @@ namespace PHP_CodeSniffer; +use Composer\Autoload\ClassLoader; +use Exception; + if (class_exists('PHP_CodeSniffer\Autoload', false) === false) { class Autoload { @@ -77,7 +80,7 @@ public static function load($class) && @file_exists(__DIR__.'/../../autoload.php') === true ) { self::$composerAutoloader = include __DIR__.'/../../autoload.php'; - if (self::$composerAutoloader instanceof \Composer\Autoload\ClassLoader) { + if (self::$composerAutoloader instanceof ClassLoader) { self::$composerAutoloader->unregister(); self::$composerAutoloader->register(); } else { @@ -282,7 +285,7 @@ public static function getSearchPaths() public static function getLoadedClassName($path) { if (isset(self::$loadedClasses[$path]) === false) { - throw new \Exception("Cannot get class name for $path; file has not been included"); + throw new Exception("Cannot get class name for $path; file has not been included"); } return self::$loadedClasses[$path]; @@ -301,7 +304,7 @@ public static function getLoadedClassName($path) public static function getLoadedFileName($class) { if (isset(self::$loadedFiles[$class]) === false) { - throw new \Exception("Cannot get file name for $class; class has not been included"); + throw new Exception("Cannot get file name for $class; class has not been included"); } return self::$loadedFiles[$class]; diff --git a/vendor/squizlabs/php_codesniffer/bin/phpcbf b/vendor/squizlabs/php_codesniffer/bin/phpcbf index 2e86a40e..c804bdf1 100755 --- a/vendor/squizlabs/php_codesniffer/bin/phpcbf +++ b/vendor/squizlabs/php_codesniffer/bin/phpcbf @@ -8,11 +8,7 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -if (is_file(__DIR__.'/../autoload.php') === true) { - include_once __DIR__.'/../autoload.php'; -} else { - include_once 'PHP/CodeSniffer/autoload.php'; -} +require_once __DIR__.'/../autoload.php'; $runner = new PHP_CodeSniffer\Runner(); $exitCode = $runner->runPHPCBF(); diff --git a/vendor/squizlabs/php_codesniffer/bin/phpcs b/vendor/squizlabs/php_codesniffer/bin/phpcs index e8e8b028..d098bf87 100755 --- a/vendor/squizlabs/php_codesniffer/bin/phpcs +++ b/vendor/squizlabs/php_codesniffer/bin/phpcs @@ -8,11 +8,7 @@ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -if (is_file(__DIR__.'/../autoload.php') === true) { - include_once __DIR__.'/../autoload.php'; -} else { - include_once 'PHP/CodeSniffer/autoload.php'; -} +require_once __DIR__.'/../autoload.php'; $runner = new PHP_CodeSniffer\Runner(); $exitCode = $runner->runPHPCS(); diff --git a/vendor/squizlabs/php_codesniffer/src/Config.php b/vendor/squizlabs/php_codesniffer/src/Config.php index d9248398..e512d33f 100644 --- a/vendor/squizlabs/php_codesniffer/src/Config.php +++ b/vendor/squizlabs/php_codesniffer/src/Config.php @@ -12,9 +12,12 @@ namespace PHP_CodeSniffer; +use Exception; +use Phar; use PHP_CodeSniffer\Exceptions\DeepExitException; use PHP_CodeSniffer\Exceptions\RuntimeException; use PHP_CodeSniffer\Util\Common; +use PHP_CodeSniffer\Util\Standards; /** * Stores the configuration used to run PHPCS and PHPCBF. @@ -81,7 +84,7 @@ class Config * * @var string */ - const VERSION = '3.8.1'; + const VERSION = '3.9.1'; /** * Package stability; either stable, beta or alpha. @@ -265,7 +268,7 @@ public function __set($name, $value) $cleaned = []; // Check if the standard name is valid, or if the case is invalid. - $installedStandards = Util\Standards::getInstalledStandards(); + $installedStandards = Standards::getInstalledStandards(); foreach ($value as $standard) { foreach ($installedStandards as $validStandard) { if (strtolower($standard) === strtolower($validStandard)) { @@ -420,7 +423,7 @@ public function __construct(array $cliArgs=[], $dieOnUnknownArg=true) // Check for content on STDIN. if ($this->stdin === true - || (Util\Common::isStdinATTY() === false + || (Common::isStdinATTY() === false && feof($handle) === false) ) { $readStreams = [$handle]; @@ -649,7 +652,7 @@ public function processShortArgument($arg, $pos) throw new DeepExitException($output, 0); case 'i' : ob_start(); - Util\Standards::printInstalledStandards(); + Standards::printInstalledStandards(); $output = ob_get_contents(); ob_end_clean(); throw new DeepExitException($output, 0); @@ -812,7 +815,7 @@ public function processLongArgument($arg, $pos) try { $this->setConfigData($key, $value); - } catch (\Exception $e) { + } catch (Exception $e) { throw new DeepExitException($e->getMessage().PHP_EOL, 3); } @@ -840,7 +843,7 @@ public function processLongArgument($arg, $pos) } else { try { $this->setConfigData($key, null); - } catch (\Exception $e) { + } catch (Exception $e) { throw new DeepExitException($e->getMessage().PHP_EOL, 3); } @@ -922,7 +925,7 @@ public function processLongArgument($arg, $pos) $this->cache = true; self::$overriddenDefaults['cache'] = true; - $this->cacheFile = Util\Common::realpath(substr($arg, 6)); + $this->cacheFile = Common::realpath(substr($arg, 6)); // It may not exist and return false instead. if ($this->cacheFile === false) { @@ -941,9 +944,9 @@ public function processLongArgument($arg, $pos) } else { if ($dir[0] === '/') { // An absolute path. - $dir = Util\Common::realpath($dir); + $dir = Common::realpath($dir); } else { - $dir = Util\Common::realpath(getcwd().'/'.$dir); + $dir = Common::realpath(getcwd().'/'.$dir); } if ($dir !== false) { @@ -964,7 +967,7 @@ public function processLongArgument($arg, $pos) $files = explode(',', substr($arg, 10)); $bootstrap = []; foreach ($files as $file) { - $path = Util\Common::realpath($file); + $path = Common::realpath($file); if ($path === false) { $error = 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; $error .= $this->printShortUsage(true); @@ -978,7 +981,7 @@ public function processLongArgument($arg, $pos) self::$overriddenDefaults['bootstrap'] = true; } else if (substr($arg, 0, 10) === 'file-list=') { $fileList = substr($arg, 10); - $path = Util\Common::realpath($fileList); + $path = Common::realpath($fileList); if ($path === false) { $error = 'ERROR: The specified file list "'.$fileList.'" does not exist'.PHP_EOL.PHP_EOL; $error .= $this->printShortUsage(true); @@ -1001,7 +1004,7 @@ public function processLongArgument($arg, $pos) break; } - $this->stdinPath = Util\Common::realpath(substr($arg, 11)); + $this->stdinPath = Common::realpath(substr($arg, 11)); // It may not exist and return false instead, so use whatever they gave us. if ($this->stdinPath === false) { @@ -1014,13 +1017,13 @@ public function processLongArgument($arg, $pos) break; } - $this->reportFile = Util\Common::realpath(substr($arg, 12)); + $this->reportFile = Common::realpath(substr($arg, 12)); // It may not exist and return false instead. if ($this->reportFile === false) { $this->reportFile = substr($arg, 12); - $dir = Util\Common::realpath(dirname($this->reportFile)); + $dir = Common::realpath(dirname($this->reportFile)); if (is_dir($dir) === false) { $error = 'ERROR: The specified report file path "'.$this->reportFile.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; $error .= $this->printShortUsage(true); @@ -1056,7 +1059,7 @@ public function processLongArgument($arg, $pos) break; } - $this->basepath = Util\Common::realpath(substr($arg, 9)); + $this->basepath = Common::realpath(substr($arg, 9)); // It may not exist and return false instead. if ($this->basepath === false) { @@ -1083,7 +1086,7 @@ public function processLongArgument($arg, $pos) if ($output === false) { $output = null; } else { - $dir = Util\Common::realpath(dirname($output)); + $dir = Common::realpath(dirname($output)); if (is_dir($dir) === false) { $error = 'ERROR: The specified '.$report.' report file path "'.$output.'" points to a non-existent directory'.PHP_EOL.PHP_EOL; $error .= $this->printShortUsage(true); @@ -1317,7 +1320,7 @@ public function processFilePath($path) return; } - $file = Util\Common::realpath($path); + $file = Common::realpath($path); if (file_exists($file) === false) { if ($this->dieOnUnknownArg === false) { return; @@ -1407,7 +1410,7 @@ public function printPHPCSUsage() echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL; echo ' -w Print both warnings and errors (this is the default)'.PHP_EOL; echo ' -l Local directory only, no recursion'.PHP_EOL; - echo ' -s Show sniff codes in all reports'.PHP_EOL; + echo ' -s Show error codes in all reports'.PHP_EOL; echo ' -a Run interactively'.PHP_EOL; echo ' -e Explain a standard by showing the sniffs it includes'.PHP_EOL; echo ' -p Show progress of the run'.PHP_EOL; @@ -1608,7 +1611,7 @@ public static function setConfigData($key, $value, $temp=false) if ($temp === false) { $path = ''; if (is_callable('\Phar::running') === true) { - $path = \Phar::running(false); + $path = Phar::running(false); } if ($path !== '') { @@ -1653,7 +1656,7 @@ public static function setConfigData($key, $value, $temp=false) // If the installed paths are being set, make sure all known // standards paths are added to the autoloader. if ($key === 'installed_paths') { - $installedStandards = Util\Standards::getInstalledStandardDetails(); + $installedStandards = Standards::getInstalledStandardDetails(); foreach ($installedStandards as $name => $details) { Autoload::addSearchPath($details['path'], $details['namespace']); } @@ -1679,7 +1682,7 @@ public static function getAllConfigData() $path = ''; if (is_callable('\Phar::running') === true) { - $path = \Phar::running(false); + $path = Phar::running(false); } if ($path !== '') { diff --git a/vendor/squizlabs/php_codesniffer/src/Exceptions/DeepExitException.php b/vendor/squizlabs/php_codesniffer/src/Exceptions/DeepExitException.php index 7732c6da..6943e033 100644 --- a/vendor/squizlabs/php_codesniffer/src/Exceptions/DeepExitException.php +++ b/vendor/squizlabs/php_codesniffer/src/Exceptions/DeepExitException.php @@ -12,7 +12,9 @@ namespace PHP_CodeSniffer\Exceptions; -class DeepExitException extends \Exception +use Exception; + +class DeepExitException extends Exception { }//end class diff --git a/vendor/squizlabs/php_codesniffer/src/Exceptions/RuntimeException.php b/vendor/squizlabs/php_codesniffer/src/Exceptions/RuntimeException.php index a3d59098..25eacd0b 100644 --- a/vendor/squizlabs/php_codesniffer/src/Exceptions/RuntimeException.php +++ b/vendor/squizlabs/php_codesniffer/src/Exceptions/RuntimeException.php @@ -9,7 +9,9 @@ namespace PHP_CodeSniffer\Exceptions; -class RuntimeException extends \RuntimeException +use RuntimeException as PHPRuntimeException; + +class RuntimeException extends PHPRuntimeException { }//end class diff --git a/vendor/squizlabs/php_codesniffer/src/Exceptions/TokenizerException.php b/vendor/squizlabs/php_codesniffer/src/Exceptions/TokenizerException.php index ad25ace1..1cf53d62 100644 --- a/vendor/squizlabs/php_codesniffer/src/Exceptions/TokenizerException.php +++ b/vendor/squizlabs/php_codesniffer/src/Exceptions/TokenizerException.php @@ -9,7 +9,9 @@ namespace PHP_CodeSniffer\Exceptions; -class TokenizerException extends \Exception +use Exception; + +class TokenizerException extends Exception { }//end class diff --git a/vendor/squizlabs/php_codesniffer/src/Files/DummyFile.php b/vendor/squizlabs/php_codesniffer/src/Files/DummyFile.php index eb947fd2..f5dc7cc7 100644 --- a/vendor/squizlabs/php_codesniffer/src/Files/DummyFile.php +++ b/vendor/squizlabs/php_codesniffer/src/Files/DummyFile.php @@ -14,8 +14,8 @@ namespace PHP_CodeSniffer\Files; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Ruleset; class DummyFile extends File { diff --git a/vendor/squizlabs/php_codesniffer/src/Files/File.php b/vendor/squizlabs/php_codesniffer/src/Files/File.php index 7b54bea1..ab3cc290 100644 --- a/vendor/squizlabs/php_codesniffer/src/Files/File.php +++ b/vendor/squizlabs/php_codesniffer/src/Files/File.php @@ -9,12 +9,13 @@ namespace PHP_CodeSniffer\Files; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Fixer; -use PHP_CodeSniffer\Util; use PHP_CodeSniffer\Exceptions\RuntimeException; use PHP_CodeSniffer\Exceptions\TokenizerException; +use PHP_CodeSniffer\Fixer; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Util\Common; +use PHP_CodeSniffer\Util\Tokens; class File { @@ -276,7 +277,7 @@ public function setContent($content) $this->tokens = []; try { - $this->eolChar = Util\Common::detectLineEndings($content); + $this->eolChar = Common::detectLineEndings($content); } catch (RuntimeException $e) { $this->addWarningOnLine($e->getMessage(), 1, 'Internal.DetectLineEndings'); return; @@ -430,7 +431,7 @@ public function process() if (PHP_CODESNIFFER_VERBOSITY > 2) { $type = $token['type']; - $content = Util\Common::prepareForOutput($token['content']); + $content = Common::prepareForOutput($token['content']); echo "\t\tProcess token $stackPtr: $type => $content".PHP_EOL; } @@ -872,7 +873,7 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s $parts = explode('.', $code); if ($parts[0] === 'Internal') { // An internal message. - $listenerCode = Util\Common::getSniffCode($this->activeListener); + $listenerCode = Common::getSniffCode($this->activeListener); $sniffCode = $code; $checkCodes = [$sniffCode]; } else { @@ -881,7 +882,7 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s $sniffCode = $code; $listenerCode = substr($sniffCode, 0, strrpos($sniffCode, '.')); } else { - $listenerCode = Util\Common::getSniffCode($this->activeListener); + $listenerCode = Common::getSniffCode($this->activeListener); $sniffCode = $listenerCode.'.'.$code; $parts = explode('.', $sniffCode); } @@ -1615,7 +1616,7 @@ public function getMethodParameters($stackPtr) $paramCount++; break; case T_EQUAL: - $defaultStart = $this->findNext(Util\Tokens::$emptyTokens, ($i + 1), null, true); + $defaultStart = $this->findNext(Tokens::$emptyTokens, ($i + 1), null, true); $equalToken = $i; break; }//end switch @@ -1885,7 +1886,7 @@ public function getMemberProperties($stackPtr) T_READONLY => T_READONLY, ]; - $valid += Util\Tokens::$emptyTokens; + $valid += Tokens::$emptyTokens; $scope = 'public'; $scopeSpecified = false; @@ -2073,7 +2074,7 @@ public function isReference($stackPtr) } $tokenBefore = $this->findPrevious( - Util\Tokens::$emptyTokens, + Tokens::$emptyTokens, ($stackPtr - 1), null, true @@ -2097,14 +2098,14 @@ public function isReference($stackPtr) return true; } - if (isset(Util\Tokens::$assignmentTokens[$this->tokens[$tokenBefore]['code']]) === true) { + if (isset(Tokens::$assignmentTokens[$this->tokens[$tokenBefore]['code']]) === true) { // This is directly after an assignment. It's a reference. Even if // it is part of an operation, the other tests will handle it. return true; } $tokenAfter = $this->findNext( - Util\Tokens::$emptyTokens, + Tokens::$emptyTokens, ($stackPtr + 1), null, true @@ -2155,7 +2156,7 @@ public function isReference($stackPtr) if ($this->tokens[$tokenAfter]['code'] === T_VARIABLE) { return true; } else { - $skip = Util\Tokens::$emptyTokens; + $skip = Tokens::$emptyTokens; $skip[] = T_NS_SEPARATOR; $skip[] = T_SELF; $skip[] = T_PARENT; @@ -2382,7 +2383,7 @@ public function findNext( */ public function findStartOfStatement($start, $ignore=null) { - $startTokens = Util\Tokens::$blockOpeners; + $startTokens = Tokens::$blockOpeners; $startTokens[T_OPEN_SHORT_ARRAY] = true; $startTokens[T_OPEN_TAG] = true; $startTokens[T_OPEN_TAG_WITH_ECHO] = true; @@ -2436,7 +2437,7 @@ public function findStartOfStatement($start, $ignore=null) if ($prevMatch <= $this->tokens[$matchExpression]['scope_opener']) { // We're before the arrow in the first case. - $next = $this->findNext(Util\Tokens::$emptyTokens, ($this->tokens[$matchExpression]['scope_opener'] + 1), null, true); + $next = $this->findNext(Tokens::$emptyTokens, ($this->tokens[$matchExpression]['scope_opener'] + 1), null, true); if ($next === false) { return $start; } @@ -2449,12 +2450,12 @@ public function findStartOfStatement($start, $ignore=null) $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(Util\Tokens::$emptyTokens, ($this->tokens[$matchExpression]['scope_opener'] + 1), null, true); + $next = $this->findNext(Tokens::$emptyTokens, ($this->tokens[$matchExpression]['scope_opener'] + 1), null, true); return $next; } $end = $this->findEndOfStatement($prevMatchArrow); - $next = $this->findNext(Util\Tokens::$emptyTokens, ($end + 1), null, true); + $next = $this->findNext(Tokens::$emptyTokens, ($end + 1), null, true); return $next; } }//end if @@ -2515,7 +2516,7 @@ public function findStartOfStatement($start, $ignore=null) } }//end if - if (isset(Util\Tokens::$emptyTokens[$this->tokens[$i]['code']]) === false) { + if (isset(Tokens::$emptyTokens[$this->tokens[$i]['code']]) === false) { $lastNotEmpty = $i; } }//end for @@ -2610,7 +2611,7 @@ public function findEndOfStatement($start, $ignore=null) continue; } - if ($i === $start && isset(Util\Tokens::$scopeOpeners[$this->tokens[$i]['code']]) === true) { + if ($i === $start && isset(Tokens::$scopeOpeners[$this->tokens[$i]['code']]) === true) { return $this->tokens[$i]['scope_closer']; } @@ -2630,7 +2631,7 @@ public function findEndOfStatement($start, $ignore=null) } }//end if - if (isset(Util\Tokens::$emptyTokens[$this->tokens[$i]['code']]) === false) { + if (isset(Tokens::$emptyTokens[$this->tokens[$i]['code']]) === false) { $lastNotEmpty = $i; } }//end for diff --git a/vendor/squizlabs/php_codesniffer/src/Files/FileList.php b/vendor/squizlabs/php_codesniffer/src/Files/FileList.php index 13357ecd..ab52e338 100644 --- a/vendor/squizlabs/php_codesniffer/src/Files/FileList.php +++ b/vendor/squizlabs/php_codesniffer/src/Files/FileList.php @@ -11,14 +11,20 @@ namespace PHP_CodeSniffer\Files; +use Countable; +use FilesystemIterator; +use Iterator; use PHP_CodeSniffer\Autoload; -use PHP_CodeSniffer\Util; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Exceptions\DeepExitException; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Util\Common; +use RecursiveArrayIterator; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; use ReturnTypeWillChange; -class FileList implements \Iterator, \Countable +class FileList implements Iterator, Countable { /** @@ -72,7 +78,7 @@ public function __construct(Config $config, Ruleset $ruleset) $paths = $config->files; foreach ($paths as $path) { - $isPharFile = Util\Common::isPharFile($path); + $isPharFile = Common::isPharFile($path); if (is_dir($path) === true || $isPharFile === true) { if ($isPharFile === true) { $path = 'phar://'.$path; @@ -80,9 +86,9 @@ public function __construct(Config $config, Ruleset $ruleset) $filterClass = $this->getFilterClass(); - $di = new \RecursiveDirectoryIterator($path, (\RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)); + $di = new RecursiveDirectoryIterator($path, (RecursiveDirectoryIterator::SKIP_DOTS | FilesystemIterator::FOLLOW_SYMLINKS)); $filter = new $filterClass($di, $path, $config, $ruleset); - $iterator = new \RecursiveIteratorIterator($filter); + $iterator = new RecursiveIteratorIterator($filter); foreach ($iterator as $file) { $this->files[$file->getPathname()] = null; @@ -121,9 +127,9 @@ public function addFile($path, $file=null) $filterClass = $this->getFilterClass(); - $di = new \RecursiveArrayIterator([$path]); + $di = new RecursiveArrayIterator([$path]); $filter = new $filterClass($di, $path, $this->config, $this->ruleset); - $iterator = new \RecursiveIteratorIterator($filter); + $iterator = new RecursiveIteratorIterator($filter); foreach ($iterator as $path) { $this->files[$path] = $file; diff --git a/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php b/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php index c2af77c4..babfe69c 100644 --- a/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php +++ b/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php @@ -9,8 +9,8 @@ namespace PHP_CodeSniffer\Files; -use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Util\Cache; use PHP_CodeSniffer\Util\Common; diff --git a/vendor/squizlabs/php_codesniffer/src/Filters/ExactMatch.php b/vendor/squizlabs/php_codesniffer/src/Filters/ExactMatch.php index ce04e02b..89517b83 100644 --- a/vendor/squizlabs/php_codesniffer/src/Filters/ExactMatch.php +++ b/vendor/squizlabs/php_codesniffer/src/Filters/ExactMatch.php @@ -2,7 +2,7 @@ /** * An abstract filter class for checking files and folders against exact matches. * - * Supports both allowed files and blocked files. + * Supports both allowed files and disallowed files. * * @author Greg Sherwood * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,7 +11,7 @@ namespace PHP_CodeSniffer\Filters; -use PHP_CodeSniffer\Util; +use PHP_CodeSniffer\Util\Common; abstract class ExactMatch extends Filter { @@ -21,12 +21,12 @@ abstract class ExactMatch extends Filter * * @var array */ - private $blockedFiles = null; + private $disallowedFiles = null; /** * A list of files to include. * - * If the allowed files list is empty, only files in the blocked files list will be excluded. + * If the allowed files list is empty, only files in the disallowed files list will be excluded. * * @var array */ @@ -36,7 +36,7 @@ abstract class ExactMatch extends Filter /** * Check whether the current element of the iterator is acceptable. * - * If a file is both blocked and allowed, it will be deemed unacceptable. + * If a file is both disallowed and allowed, it will be deemed unacceptable. * * @return bool */ @@ -46,23 +46,33 @@ public function accept() return false; } - if ($this->blockedFiles === null) { - $this->blockedFiles = $this->getblacklist(); + if ($this->disallowedFiles === null) { + $this->disallowedFiles = $this->getDisallowedFiles(); + + // BC-layer. + if ($this->disallowedFiles === null) { + $this->disallowedFiles = $this->getBlacklist(); + } } if ($this->allowedFiles === null) { - $this->allowedFiles = $this->getwhitelist(); + $this->allowedFiles = $this->getAllowedFiles(); + + // BC-layer. + if ($this->allowedFiles === null) { + $this->allowedFiles = $this->getWhitelist(); + } } - $filePath = Util\Common::realpath($this->current()); + $filePath = Common::realpath($this->current()); - // If file is both blocked and allowed, the blocked files list takes precedence. - if (isset($this->blockedFiles[$filePath]) === true) { + // If a file is both disallowed and allowed, the disallowed files list takes precedence. + if (isset($this->disallowedFiles[$filePath]) === true) { return false; } - if (empty($this->allowedFiles) === true && empty($this->blockedFiles) === false) { - // We are only checking a blocked files list, so everything else should be allowed. + if (empty($this->allowedFiles) === true && empty($this->disallowedFiles) === false) { + // We are only checking the disallowed files list, so everything else should be allowed. return true; } @@ -74,7 +84,7 @@ public function accept() /** * Returns an iterator for the current entry. * - * Ensures that the blocked files list and the allowed files list are preserved so they don't have + * Ensures that the disallowed files list and the allowed files list are preserved so they don't have * to be generated each time. * * @return \RecursiveIterator @@ -82,8 +92,8 @@ public function accept() public function getChildren() { $children = parent::getChildren(); - $children->blockedFiles = $this->blockedFiles; - $children->allowedFiles = $this->allowedFiles; + $children->disallowedFiles = $this->disallowedFiles; + $children->allowedFiles = $this->allowedFiles; return $children; }//end getChildren() @@ -92,6 +102,11 @@ public function getChildren() /** * Get a list of file paths to exclude. * + * @deprecated 3.9.0 Implement the `getDisallowedFiles()` method instead. + * The `getDisallowedFiles()` method will be made abstract and therefore required + * in v4.0 and this method will be removed. + * If both methods are implemented, the new `getDisallowedFiles()` method will take precedence. + * * @return array */ abstract protected function getBlacklist(); @@ -100,9 +115,42 @@ abstract protected function getBlacklist(); /** * Get a list of file paths to include. * + * @deprecated 3.9.0 Implement the `getAllowedFiles()` method instead. + * The `getAllowedFiles()` method will be made abstract and therefore required + * in v4.0 and this method will be removed. + * If both methods are implemented, the new `getAllowedFiles()` method will take precedence. + * * @return array */ abstract protected function getWhitelist(); + /** + * Get a list of file paths to exclude. + * + * @since 3.9.0 Replaces the deprecated `getBlacklist()` method. + * + * @return array|null + */ + protected function getDisallowedFiles() + { + return null; + + }//end getDisallowedFiles() + + + /** + * Get a list of file paths to include. + * + * @since 3.9.0 Replaces the deprecated `getWhitelist()` method. + * + * @return array|null + */ + protected function getAllowedFiles() + { + return null; + + }//end getAllowedFiles() + + }//end class diff --git a/vendor/squizlabs/php_codesniffer/src/Filters/Filter.php b/vendor/squizlabs/php_codesniffer/src/Filters/Filter.php index c72518c6..349fd6db 100644 --- a/vendor/squizlabs/php_codesniffer/src/Filters/Filter.php +++ b/vendor/squizlabs/php_codesniffer/src/Filters/Filter.php @@ -9,12 +9,15 @@ namespace PHP_CodeSniffer\Filters; -use PHP_CodeSniffer\Util; -use PHP_CodeSniffer\Ruleset; +use FilesystemIterator; use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Util\Common; +use RecursiveDirectoryIterator; +use RecursiveFilterIterator; use ReturnTypeWillChange; -class Filter extends \RecursiveFilterIterator +class Filter extends RecursiveFilterIterator { /** @@ -94,7 +97,7 @@ public function __construct($iterator, $basedir, Config $config, Ruleset $rulese public function accept() { $filePath = $this->current(); - $realPath = Util\Common::realpath($filePath); + $realPath = Common::realpath($filePath); if ($realPath !== false) { // It's a real path somewhere, so record it @@ -137,7 +140,7 @@ public function getChildren() { $filterClass = get_called_class(); $children = new $filterClass( - new \RecursiveDirectoryIterator($this->current(), (\RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)), + new RecursiveDirectoryIterator($this->current(), (RecursiveDirectoryIterator::SKIP_DOTS | FilesystemIterator::FOLLOW_SYMLINKS)), $this->basedir, $this->config, $this->ruleset diff --git a/vendor/squizlabs/php_codesniffer/src/Filters/GitModified.php b/vendor/squizlabs/php_codesniffer/src/Filters/GitModified.php index 3395e06d..3337287b 100644 --- a/vendor/squizlabs/php_codesniffer/src/Filters/GitModified.php +++ b/vendor/squizlabs/php_codesniffer/src/Filters/GitModified.php @@ -9,7 +9,7 @@ namespace PHP_CodeSniffer\Filters; -use PHP_CodeSniffer\Util; +use PHP_CodeSniffer\Util\Common; class GitModified extends ExactMatch { @@ -18,21 +18,41 @@ class GitModified extends ExactMatch /** * Get a list of file paths to exclude. * + * @since 3.9.0 + * * @return array */ - protected function getBlacklist() + protected function getDisallowedFiles() { return []; + }//end getDisallowedFiles() + + + /** + * Get a list of file paths to exclude. + * + * @deprecated 3.9.0 Overload the `getDisallowedFiles()` method instead. + * + * @codeCoverageIgnore + * + * @return array + */ + protected function getBlacklist() + { + return $this->getDisallowedFiles(); + }//end getBlacklist() /** * Get a list of file paths to include. * + * @since 3.9.0 + * * @return array */ - protected function getWhitelist() + protected function getAllowedFiles() { $modified = []; @@ -45,7 +65,7 @@ protected function getWhitelist() } foreach ($output as $path) { - $path = Util\Common::realpath($path); + $path = Common::realpath($path); if ($path === false) { continue; @@ -59,6 +79,22 @@ protected function getWhitelist() return $modified; + }//end getAllowedFiles() + + + /** + * Get a list of file paths to include. + * + * @deprecated 3.9.0 Overload the `getAllowedFiles()` method instead. + * + * @codeCoverageIgnore + * + * @return array + */ + protected function getWhitelist() + { + return $this->getAllowedFiles(); + }//end getWhitelist() diff --git a/vendor/squizlabs/php_codesniffer/src/Filters/GitStaged.php b/vendor/squizlabs/php_codesniffer/src/Filters/GitStaged.php index 94c91940..7a764314 100644 --- a/vendor/squizlabs/php_codesniffer/src/Filters/GitStaged.php +++ b/vendor/squizlabs/php_codesniffer/src/Filters/GitStaged.php @@ -11,7 +11,7 @@ namespace PHP_CodeSniffer\Filters; -use PHP_CodeSniffer\Util; +use PHP_CodeSniffer\Util\Common; class GitStaged extends ExactMatch { @@ -20,21 +20,41 @@ class GitStaged extends ExactMatch /** * Get a list of file paths to exclude. * + * @since 3.9.0 + * * @return array */ - protected function getBlacklist() + protected function getDisallowedFiles() { return []; + }//end getDisallowedFiles() + + + /** + * Get a list of file paths to exclude. + * + * @deprecated 3.9.0 Overload the `getDisallowedFiles()` method instead. + * + * @codeCoverageIgnore + * + * @return array + */ + protected function getBlacklist() + { + return $this->getDisallowedFiles(); + }//end getBlacklist() /** * Get a list of file paths to include. * + * @since 3.9.0 + * * @return array */ - protected function getWhitelist() + protected function getAllowedFiles() { $modified = []; @@ -47,7 +67,7 @@ protected function getWhitelist() } foreach ($output as $path) { - $path = Util\Common::realpath($path); + $path = Common::realpath($path); if ($path === false) { // Skip deleted files. continue; @@ -61,6 +81,22 @@ protected function getWhitelist() return $modified; + }//end getAllowedFiles() + + + /** + * Get a list of file paths to include. + * + * @deprecated 3.9.0 Overload the `getAllowedFiles()` method instead. + * + * @codeCoverageIgnore + * + * @return array + */ + protected function getWhitelist() + { + return $this->getAllowedFiles(); + }//end getWhitelist() diff --git a/vendor/squizlabs/php_codesniffer/src/Fixer.php b/vendor/squizlabs/php_codesniffer/src/Fixer.php index b54dde94..b3e93335 100644 --- a/vendor/squizlabs/php_codesniffer/src/Fixer.php +++ b/vendor/squizlabs/php_codesniffer/src/Fixer.php @@ -12,6 +12,7 @@ namespace PHP_CodeSniffer; +use PHP_CodeSniffer\Exceptions\RuntimeException; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Util\Common; @@ -226,6 +227,8 @@ public function fixFile() * @param boolean $colors Print coloured output or not. * * @return string + * + * @throws \PHP_CodeSniffer\Exceptions\RuntimeException when the diff command fails. */ public function generateDiff($filePath=null, $colors=true) { @@ -246,19 +249,56 @@ public function generateDiff($filePath=null, $colors=true) $fixedFile = fopen($tempName, 'w'); fwrite($fixedFile, $contents); - // We must use something like shell_exec() because whitespace at the end + // We must use something like shell_exec() or proc_open() because whitespace at the end // of lines is critical to diff files. + // Using proc_open() instead of shell_exec improves performance on Windows significantly, + // while the results are the same (though more code is needed to get the results). + // This is specifically due to proc_open allowing to set the "bypass_shell" option. $filename = escapeshellarg($filename); $cmd = "diff -u -L$filename -LPHP_CodeSniffer $filename \"$tempName\""; - $diff = shell_exec($cmd); + // Stream 0 = STDIN, 1 = STDOUT, 2 = STDERR. + $descriptorspec = [ + 0 => [ + 'pipe', + 'r', + ], + 1 => [ + 'pipe', + 'w', + ], + 2 => [ + 'pipe', + 'w', + ], + ]; + + $options = null; + if (stripos(PHP_OS, 'WIN') === 0) { + $options = ['bypass_shell' => true]; + } + + $process = proc_open($cmd, $descriptorspec, $pipes, $cwd, null, $options); + if (is_resource($process) === false) { + throw new RuntimeException('Could not obtain a resource to execute the diff command.'); + } + + // We don't need these. + fclose($pipes[0]); + fclose($pipes[2]); + + // Stdout will contain the actual diff. + $diff = stream_get_contents($pipes[1]); + fclose($pipes[1]); + + proc_close($process); fclose($fixedFile); if (is_file($tempName) === true) { unlink($tempName); } - if ($diff === null) { + if ($diff === false || $diff === '') { return ''; } @@ -362,7 +402,7 @@ public function beginChangeset() if ($bt[1]['class'] === __CLASS__) { $sniff = 'Fixer'; } else { - $sniff = Util\Common::getSniffCode($bt[1]['class']); + $sniff = Common::getSniffCode($bt[1]['class']); } $line = $bt[0]['line']; @@ -447,7 +487,7 @@ public function rollbackChangeset() $line = $bt[0]['line']; } - $sniff = Util\Common::getSniffCode($sniff); + $sniff = Common::getSniffCode($sniff); $numChanges = count($this->changeset); @@ -504,7 +544,7 @@ public function replaceToken($stackPtr, $content) $line = $bt[0]['line']; } - $sniff = Util\Common::getSniffCode($sniff); + $sniff = Common::getSniffCode($sniff); $tokens = $this->currentFile->getTokens(); $type = $tokens[$stackPtr]['type']; @@ -619,7 +659,7 @@ public function revertToken($stackPtr) $line = $bt[0]['line']; } - $sniff = Util\Common::getSniffCode($sniff); + $sniff = Common::getSniffCode($sniff); $tokens = $this->currentFile->getTokens(); $type = $tokens[$stackPtr]['type']; diff --git a/vendor/squizlabs/php_codesniffer/src/Generators/Generator.php b/vendor/squizlabs/php_codesniffer/src/Generators/Generator.php index 483cae80..af0e0f5c 100644 --- a/vendor/squizlabs/php_codesniffer/src/Generators/Generator.php +++ b/vendor/squizlabs/php_codesniffer/src/Generators/Generator.php @@ -12,8 +12,10 @@ namespace PHP_CodeSniffer\Generators; -use PHP_CodeSniffer\Ruleset; +use DOMDocument; +use DOMNode; use PHP_CodeSniffer\Autoload; +use PHP_CodeSniffer\Ruleset; abstract class Generator { @@ -70,7 +72,7 @@ public function __construct(Ruleset $ruleset) * * @return string */ - protected function getTitle(\DOMNode $doc) + protected function getTitle(DOMNode $doc) { return $doc->getAttribute('title'); @@ -90,7 +92,7 @@ protected function getTitle(\DOMNode $doc) public function generate() { foreach ($this->docFiles as $file) { - $doc = new \DOMDocument(); + $doc = new DOMDocument(); $doc->load($file); $documentation = $doc->getElementsByTagName('documentation')->item(0); $this->processSniff($documentation); @@ -111,7 +113,7 @@ public function generate() * @return void * @see generate() */ - abstract protected function processSniff(\DOMNode $doc); + abstract protected function processSniff(DOMNode $doc); }//end class diff --git a/vendor/squizlabs/php_codesniffer/src/Generators/HTML.php b/vendor/squizlabs/php_codesniffer/src/Generators/HTML.php index 55acd9e1..a042f36b 100644 --- a/vendor/squizlabs/php_codesniffer/src/Generators/HTML.php +++ b/vendor/squizlabs/php_codesniffer/src/Generators/HTML.php @@ -13,6 +13,8 @@ namespace PHP_CodeSniffer\Generators; +use DOMDocument; +use DOMNode; use PHP_CodeSniffer\Config; class HTML extends Generator @@ -32,7 +34,7 @@ public function generate() $this->printToc(); foreach ($this->docFiles as $file) { - $doc = new \DOMDocument(); + $doc = new DOMDocument(); $doc->load($file); $documentation = $doc->getElementsByTagName('documentation')->item(0); $this->processSniff($documentation); @@ -145,7 +147,7 @@ protected function printToc() echo '