From 52f65ca4bd8e481cc6b6561bf82ae6177bd6c488 Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sun, 23 Nov 2025 11:22:38 +0100 Subject: [PATCH 1/2] style(phpcs): Adapt same code style as in PHPCS 4 --- .../Drupal/Sniffs/Arrays/ArraySniff.php | 11 +- .../Sniffs/Attributes/ValidHookNameSniff.php | 10 +- .../Sniffs/Classes/ClassDeclarationSniff.php | 17 +- .../Classes/FullyQualifiedNamespaceSniff.php | 10 +- .../Classes/PropertyDeclarationSniff.php | 10 +- .../Sniffs/Classes/UseGlobalClassSniff.php | 20 +- .../Sniffs/Commenting/ClassCommentSniff.php | 14 +- .../Commenting/DataTypeNamespaceSniff.php | 12 +- .../Sniffs/Commenting/DeprecatedSniff.php | 34 ++-- .../Commenting/DocCommentAlignmentSniff.php | 12 +- .../DocCommentLongArraySyntaxSniff.php | 10 +- .../Sniffs/Commenting/DocCommentSniff.php | 22 +- .../Sniffs/Commenting/DocCommentStarSniff.php | 18 +- .../Sniffs/Commenting/FileCommentSniff.php | 14 +- .../Commenting/FunctionCommentSniff.php | 61 +++--- .../Commenting/GenderNeutralCommentSniff.php | 10 +- .../Sniffs/Commenting/HookCommentSniff.php | 10 +- .../Sniffs/Commenting/InlineCommentSniff.php | 35 ++-- .../Commenting/InlineVariableCommentSniff.php | 12 +- .../Commenting/PostStatementCommentSniff.php | 10 +- .../Sniffs/Commenting/TodoCommentSniff.php | 19 +- .../Commenting/VariableCommentSniff.php | 21 +- .../ControlSignatureSniff.php | 24 +-- .../Sniffs/ControlStructures/ElseIfSniff.php | 10 +- .../InlineControlStructureSniff.php | 7 +- .../Sniffs/Files/EndFileNewlineSniff.php | 12 +- .../Drupal/Sniffs/Files/FileEncodingSniff.php | 10 +- .../Drupal/Sniffs/Files/LineLengthSniff.php | 14 +- .../Sniffs/Files/TxtFileLineLengthSniff.php | 10 +- .../Formatting/MultiLineAssignmentSniff.php | 10 +- .../MultipleStatementAlignmentSniff.php | 26 +-- .../Sniffs/Formatting/SpaceInlineIfSniff.php | 10 +- .../Formatting/SpaceUnaryOperatorSniff.php | 10 +- .../Functions/DiscouragedFunctionsSniff.php | 2 +- .../MultiLineFunctionDeclarationSniff.php | 14 +- .../Sniffs/InfoFiles/AutoAddedKeysSniff.php | 12 +- .../Sniffs/InfoFiles/ClassFilesSniff.php | 22 +- .../InfoFiles/DependenciesArraySniff.php | 11 +- .../Sniffs/InfoFiles/DuplicateEntrySniff.php | 15 +- .../Drupal/Sniffs/InfoFiles/RequiredSniff.php | 12 +- .../NamingConventions/ValidClassNameSniff.php | 10 +- .../NamingConventions/ValidEnumCaseSniff.php | 7 +- .../ValidFunctionNameSniff.php | 14 +- .../NamingConventions/ValidGlobalSniff.php | 10 +- .../ValidVariableNameSniff.php | 14 +- .../Drupal/Sniffs/Scope/MethodScopeSniff.php | 15 +- .../Sniffs/Semantics/ConstantNameSniff.php | 14 +- .../Sniffs/Semantics/EmptyInstallSniff.php | 11 +- .../Sniffs/Semantics/FunctionAliasSniff.php | 10 +- .../Drupal/Sniffs/Semantics/FunctionCall.php | 16 +- .../Sniffs/Semantics/FunctionDefinition.php | 10 +- .../Sniffs/Semantics/FunctionTSniff.php | 13 +- .../Semantics/FunctionTriggerErrorSniff.php | 14 +- .../Semantics/FunctionWatchdogSniff.php | 10 +- .../Sniffs/Semantics/InstallHooksSniff.php | 19 +- .../Semantics/LStringTranslatableSniff.php | 10 +- .../Sniffs/Semantics/PregSecuritySniff.php | 12 +- .../Sniffs/Semantics/RemoteAddressSniff.php | 10 +- .../Sniffs/Semantics/TInHookMenuSniff.php | 9 +- .../Sniffs/Semantics/TInHookSchemaSniff.php | 9 +- .../Semantics/UnsilencedDeprecationSniff.php | 12 +- .../WhiteSpace/CloseBracketSpacingSniff.php | 10 +- .../Drupal/Sniffs/WhiteSpace/CommaSniff.php | 10 +- .../Sniffs/WhiteSpace/EmptyLinesSniff.php | 10 +- .../WhiteSpace/ObjectOperatorIndentSniff.php | 13 +- .../WhiteSpace/ObjectOperatorSpacingSniff.php | 10 +- .../WhiteSpace/OpenBracketSpacingSniff.php | 10 +- .../Sniffs/WhiteSpace/OpenTagNewlineSniff.php | 12 +- .../WhiteSpace/ScopeClosingBraceSniff.php | 14 +- .../Sniffs/WhiteSpace/ScopeIndentSniff.php | 191 +++++++++--------- coder_sniffer/DrupalPractice/Project.php | 30 +-- .../Sniffs/Commenting/AuthorTagSniff.php | 10 +- .../Commenting/CommentEmptyLineSniff.php | 12 +- .../Commenting/ExpectedExceptionSniff.php | 10 +- .../Sniffs/Constants/GlobalConstantSniff.php | 10 +- .../Sniffs/Constants/GlobalDefineSniff.php | 10 +- .../Sniffs/FunctionCalls/CheckPlainSniff.php | 10 +- .../FunctionCalls/CurlSslVerifierSniff.php | 10 +- .../Sniffs/FunctionCalls/DbQuerySniff.php | 12 +- .../FunctionCalls/DbSelectBracesSniff.php | 10 +- .../DefaultValueSanitizeSniff.php | 10 +- .../Sniffs/FunctionCalls/FormErrorTSniff.php | 10 +- .../InsecureUnserializeSniff.php | 13 +- .../Sniffs/FunctionCalls/LCheckPlainSniff.php | 10 +- .../Sniffs/FunctionCalls/MessageTSniff.php | 10 +- .../Sniffs/FunctionCalls/TCheckPlainSniff.php | 10 +- .../Sniffs/FunctionCalls/ThemeSniff.php | 7 +- .../VariableSetSanitizeSniff.php | 10 +- .../AccessHookMenuSniff.php | 9 +- .../FunctionDefinitions/FormAlterDocSniff.php | 11 +- .../FunctionDefinitions/HookInitCssSniff.php | 11 +- .../FunctionDefinitions/InstallTSniff.php | 11 +- .../Sniffs/General/AccessAdminPagesSniff.php | 9 +- .../Sniffs/General/ClassNameSniff.php | 10 +- .../Sniffs/General/DescriptionTSniff.php | 10 +- .../Sniffs/General/ExceptionTSniff.php | 10 +- .../Sniffs/General/FormStateInputSniff.php | 10 +- .../Sniffs/General/LanguageNoneSniff.php | 10 +- .../Sniffs/General/OptionsTSniff.php | 10 +- .../Sniffs/General/VariableNameSniff.php | 10 +- .../InfoFiles/CoreVersionRequirementSniff.php | 10 +- .../Sniffs/InfoFiles/DescriptionSniff.php | 12 +- .../InfoFiles/NamespacedDependencySniff.php | 12 +- .../Sniffs/Objects/GlobalClassSniff.php | 13 +- .../Sniffs/Objects/GlobalDrupalSniff.php | 10 +- .../Sniffs/Objects/GlobalFunctionSniff.php | 7 +- .../Objects/StrictSchemaDisabledSniff.php | 18 +- .../Objects/UnusedPrivateMethodSniff.php | 15 +- .../Sniffs/Variables/GetRequestDataSniff.php | 10 +- .../Sniffs/Yaml/RoutingAccessSniff.php | 10 +- phpcs.xml.dist | 143 +++++++++---- tests/Drupal/Arrays/ArrayUnitTest.php | 112 +++++----- .../Attributes/ValidHookNameUnitTest.php | 10 +- .../Classes/ClassDeclarationUnitTest.php | 10 +- .../FullyQualifiedNamespaceUnitTest.php | 61 +++--- .../Classes/PropertyDeclarationUnitTest.php | 10 +- .../Drupal/Classes/UseGlobalClassUnitTest.php | 10 +- tests/Drupal/CoderSniffUnitTest.php | 63 +++--- .../Commenting/ClassCommentUnitTest.php | 10 +- .../Commenting/DataTypeNamespaceUnitTest.php | 10 +- .../Drupal/Commenting/DeprecatedUnitTest.php | 10 +- .../DocCommentAlignmentUnitTest.php | 10 +- .../DocCommentLongArraySyntaxUnitTest.php | 10 +- .../Commenting/DocCommentStarUnitTest.php | 28 ++- .../Drupal/Commenting/DocCommentUnitTest.php | 64 +++--- .../Drupal/Commenting/FileCommentUnitTest.php | 66 +++--- .../Commenting/FunctionCommentUnitTest.php | 122 ++++++----- .../GenderNeutralCommentUnitTest.php | 10 +- .../Drupal/Commenting/HookCommentUnitTest.php | 10 +- .../Commenting/InlineCommentUnitTest.php | 10 +- .../InlineVariableCommentUnitTest.php | 10 +- .../PostStatementCommentUnitTest.php | 28 ++- .../Drupal/Commenting/TodoCommentUnitTest.php | 10 +- .../Commenting/VariableCommentUnitTest.php | 10 +- .../ControlSignatureUnitTest.php | 10 +- .../ControlStructures/ElseIfUnitTest.php | 10 +- tests/Drupal/Files/EndFileNewlineUnitTest.php | 10 +- tests/Drupal/Files/FileEncodingUnitTest.php | 10 +- tests/Drupal/Files/LineLengthUnitTest.php | 10 +- .../Files/TxtFileLineLengthUnitTest.php | 10 +- .../MultipleStatementAlignmentUnitTest.php | 10 +- .../Formatting/SpaceUnaryOperatorUnitTest.php | 10 +- .../MultiLineFunctionDeclarationUnitTest.php | 13 +- .../InfoFiles/AutoAddedKeysUnitTest.php | 17 +- tests/Drupal/InfoFiles/ClassFilesUnitTest.php | 15 +- .../InfoFiles/DependenciesArrayUnitTest.php | 15 +- .../InfoFiles/DuplicateEntryUnitTest.php | 15 +- .../ValidClassNameUnitTest.php | 10 +- .../ValidEnumCaseUnitTest.php | 10 +- .../ValidFunctionNameUnitTest.php | 33 ++- .../ValidVariableNameUnitTest.php | 10 +- tests/Drupal/Scope/MethodScopeUnitTest.php | 10 +- .../Drupal/Semantics/ConstantNameUnitTest.php | 17 +- tests/Drupal/Semantics/FunctionTUnitTest.php | 10 +- .../FunctionTriggerErrorUnitTest.php | 80 ++++---- .../Semantics/FunctionWatchdogUnitTest.php | 10 +- .../Semantics/RemoteAddressUnitTest.php | 10 +- .../UnsilencedDeprecationUnitTest.php | 10 +- .../CloseBracketSpacingUnitTest.php | 10 +- tests/Drupal/WhiteSpace/CommaUnitTest.php | 10 +- .../ObjectOperatorIndentUnitTest.php | 10 +- .../ObjectOperatorSpacingUnitTest.php | 10 +- .../WhiteSpace/OpenBracketSpacingUnitTest.php | 10 +- .../WhiteSpace/OpenTagNewlineUnitTest.php | 10 +- .../WhiteSpace/ScopeClosingBraceUnitTest.php | 25 +-- .../Drupal/WhiteSpace/ScopeIndentUnitTest.php | 10 +- tests/Drupal/bad/BadUnitTest.php | 12 +- tests/Drupal/good/GoodUnitTest.php | 10 +- .../Commenting/AuthorTagUnitTest.php | 10 +- .../Commenting/CommentEmptyLineUnitTest.php | 10 +- .../Commenting/ExpectedExceptionUnitTest.php | 10 +- .../Constants/GlobalConstantUnitTest.php | 10 +- .../Constants/GlobalDefineUnitTest.php | 10 +- .../FunctionCalls/CheckPlainUnitTest.php | 10 +- .../FunctionCalls/CurlSslVerifierUnitTest.php | 10 +- .../FunctionCalls/DbQueryUnitTest.php | 10 +- .../FunctionCalls/DbSelectBracesUnitTest.php | 10 +- .../DefaultValueSanitizeUnitTest.php | 10 +- .../InsecureUnserializeUnitTest.php | 10 +- .../FunctionCalls/TCheckPlainUnitTest.php | 10 +- .../VariableSetSanitizeUnitTest.php | 10 +- .../AccessHookMenuUnitTest.php | 15 +- .../FormAlterDocUnitTest.php | 15 +- .../HookInitCssUnitTest.php | 15 +- .../FunctionDefinitions/InstallTUnitTest.php | 15 +- .../General/ExceptionTUnitTest.php | 10 +- .../General/OptionsTUnitTest.php | 10 +- .../General/VariableNameUnitTest.php | 10 +- .../CoreVersionRequirementUnitTest.php | 27 +-- .../InfoFiles/DescriptionUnitTest.php | 25 +-- .../NamespacedDependencyUnitTest.php | 33 ++- .../Objects/GlobalClassUnitTest.php | 39 ++-- .../Objects/GlobalDrupalUnitTest.php | 39 ++-- .../Objects/GlobalFunctionUnitTest.php | 65 +++--- .../Objects/StrictSchemaDisabledUnitTest.php | 10 +- .../Objects/UnusedPrivateMethodUnitTest.php | 10 +- .../ProjectDetection/ProjectUnitTest.php | 53 ++--- .../Variables/GetRequestDataUnitTest.php | 10 +- .../Yaml/RoutingAccessUnitTest.php | 15 +- tests/DrupalPractice/bad/BadUnitTest.php | 10 +- tests/DrupalPractice/good/GoodUnitTest.php | 10 +- 201 files changed, 1352 insertions(+), 2127 deletions(-) diff --git a/coder_sniffer/Drupal/Sniffs/Arrays/ArraySniff.php b/coder_sniffer/Drupal/Sniffs/Arrays/ArraySniff.php index 9749e147..908f6a8b 100644 --- a/coder_sniffer/Drupal/Sniffs/Arrays/ArraySniff.php +++ b/coder_sniffer/Drupal/Sniffs/Arrays/ArraySniff.php @@ -27,7 +27,6 @@ class ArraySniff implements Sniff { - /** * The limit that the length of a line should not exceed. * @@ -51,8 +50,7 @@ public function register() T_ARRAY, T_OPEN_SHORT_ARRAY, ]; - - }//end register() + } /** @@ -304,8 +302,5 @@ public function process(File $phpcsFile, $stackPtr) $lineStart = $newLineStart; }//end while - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Attributes/ValidHookNameSniff.php b/coder_sniffer/Drupal/Sniffs/Attributes/ValidHookNameSniff.php index 1f8791f8..afeb62d3 100644 --- a/coder_sniffer/Drupal/Sniffs/Attributes/ValidHookNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Attributes/ValidHookNameSniff.php @@ -31,8 +31,7 @@ class ValidHookNameSniff implements Sniff public function register() { return [T_ATTRIBUTE]; - - }//end register() + } /** @@ -75,8 +74,5 @@ public function process(File $phpcsFile, $stackPtr) } } }//end if - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php index a6f038d7..acc5da39 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php @@ -46,8 +46,7 @@ public function register() T_TRAIT, T_ENUM, ]; - - }//end register() + } /** @@ -106,7 +105,7 @@ public function process(File $phpcsFile, $stackPtr) $openingBrace = $tokens[$stackPtr]['scope_opener']; if ($tokens[($openingBrace - 1)]['code'] !== T_WHITESPACE) { $length = 0; - } else if ($tokens[($openingBrace - 1)]['content'] === "\t") { + } elseif ($tokens[($openingBrace - 1)]['content'] === "\t") { $length = '\t'; } else { $length = strlen($tokens[($openingBrace - 1)]['content']); @@ -129,8 +128,7 @@ public function process(File $phpcsFile, $stackPtr) $this->processOpen($phpcsFile, $stackPtr); $this->processClose($phpcsFile, $stackPtr); - - }//end process() + } /** @@ -171,7 +169,7 @@ public function processClose(File $phpcsFile, $stackPtr) $phpcsFile->fixer->replaceToken($i, ''); } - $phpcsFile->fixer->replaceToken($closeBrace, $phpcsFile->eolChar.$phpcsFile->eolChar.$tokens[$closeBrace]['content']); + $phpcsFile->fixer->replaceToken($closeBrace, $phpcsFile->eolChar . $phpcsFile->eolChar . $tokens[$closeBrace]['content']); $phpcsFile->fixer->endChangeset(); } @@ -188,8 +186,5 @@ public function processClose(File $phpcsFile, $stackPtr) $data = [$tokens[$stackPtr]['content']]; $phpcsFile->addError($error, $closeBrace, 'CloseBraceSameLine', $data); } - - }//end processClose() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php index c4ef66e6..c6345737 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php @@ -35,8 +35,7 @@ public function register() T_NAME_FULLY_QUALIFIED, T_NAME_QUALIFIED, ]; - - }//end register() + } /** @@ -201,8 +200,5 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->endChangeset(); }//end if - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Classes/PropertyDeclarationSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/PropertyDeclarationSniff.php index d67a119e..b7b44080 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/PropertyDeclarationSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/PropertyDeclarationSniff.php @@ -35,8 +35,7 @@ class PropertyDeclarationSniff implements Sniff public function register() { return [T_VAR]; - - }//end register() + } /** @@ -55,8 +54,5 @@ public function process(File $phpcsFile, $stackPtr) if ($fix === true) { $phpcsFile->fixer->replaceToken($stackPtr, 'public'); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Classes/UseGlobalClassSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/UseGlobalClassSniff.php index 2bf03c08..0c26357e 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/UseGlobalClassSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/UseGlobalClassSniff.php @@ -32,8 +32,7 @@ class UseGlobalClassSniff implements Sniff public function register() { return [T_USE]; - - }//end register() + } /** @@ -74,7 +73,7 @@ public function process(File $phpcsFile, $stackPtr) $lineStart = $stackPtr; // Iterate through a potential multiline use statement. - while (false !== $lineEnd = $phpcsFile->findNext([T_SEMICOLON, T_COMMA], ($lineStart + 1), ($stmtEnd + 1))) { + while (($lineEnd = $phpcsFile->findNext([T_SEMICOLON, T_COMMA], ($lineStart + 1), ($stmtEnd + 1))) !== false) { // Skip function imports. if ($phpcsFile->findNext(T_STRING, $lineStart, $lineEnd, false, 'function') !== false) { $lineStart = $lineEnd; @@ -108,11 +107,11 @@ public function process(File $phpcsFile, $stackPtr) // If there are lines before this one, // then leave the ending delimiter in place. $end = ($lineEnd - 1); - } else if ($tokens[$lineEnd]['code'] === T_COMMA) { + } elseif ($tokens[$lineEnd]['code'] === T_COMMA) { // If there are lines after, but not before, // then leave the use keyword. $start = $class; - } else if ($tokens[$next]['code'] === T_USE) { + } elseif ($tokens[$next]['code'] === T_USE) { // If the whole statement is removed, and there is one after it, // then also remove the linebreaks. $end = ($next - 1); @@ -125,8 +124,8 @@ public function process(File $phpcsFile, $stackPtr) // Find all usages of the class, and add a leading backslash. // Only start looking after the end of the use statement block. $i = $bodyStart; - while (false !== $i = $phpcsFile->findNext(T_STRING, ($i + 1), null, false, $aliasName)) { - $phpcsFile->fixer->replaceToken($i, '\\'.$className); + while (($i = $phpcsFile->findNext(T_STRING, ($i + 1), null, false, $aliasName)) !== false) { + $phpcsFile->fixer->replaceToken($i, '\\' . $className); } $phpcsFile->fixer->endChangeset(); @@ -134,8 +133,5 @@ public function process(File $phpcsFile, $stackPtr) $lineStart = $lineEnd; }//end while - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php index c7e1e6a9..7f6d1255 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php @@ -38,8 +38,7 @@ public function register() T_TRAIT, T_ENUM, ]; - - }//end register() + } /** @@ -118,11 +117,11 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->beginChangeset(); $comment = ''; for ($i = $commentEnd; $tokens[$i]['code'] === T_COMMENT; $i--) { - $comment = ' *'.ltrim($tokens[$i]['content'], '/* ').$comment; + $comment = ' *' . ltrim($tokens[$i]['content'], '/* ') . $comment; $phpcsFile->fixer->replaceToken($i, ''); } - $phpcsFile->fixer->replaceToken($commentEnd, "/**\n".rtrim($comment, "*/\n")."\n */"); + $phpcsFile->fixer->replaceToken($commentEnd, "/**\n" . rtrim($comment, "*/\n") . "\n */"); $phpcsFile->fixer->endChangeset(); } @@ -167,8 +166,5 @@ public function process(File $phpcsFile, $stackPtr) } } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/DataTypeNamespaceSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/DataTypeNamespaceSniff.php index 7602dca7..b38c131e 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/DataTypeNamespaceSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/DataTypeNamespaceSniff.php @@ -32,8 +32,7 @@ class DataTypeNamespaceSniff implements Sniff public function register() { return [T_USE]; - - }//end register() + } /** @@ -93,15 +92,12 @@ public function process(File $phpcsFile, $stackPtr) $data = [$tokens[$tag]['content']]; $fix = $phpcsFile->addFixableError($error, ($tag + 2), 'DataTypeNamespace', $data); if ($fix === true) { - $replacement = '\\'.$fullNamespace.substr($tokens[($tag + 2)]['content'], strlen($className)); + $replacement = '\\' . $fullNamespace . substr($tokens[($tag + 2)]['content'], strlen($className)); $phpcsFile->fixer->replaceToken(($tag + 2), $replacement); } } $tag = $phpcsFile->findNext(T_DOC_COMMENT_TAG, ($tag + 1)); }//end while - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/DeprecatedSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/DeprecatedSniff.php index 4628c7e9..b8cfdaab 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/DeprecatedSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/DeprecatedSniff.php @@ -45,8 +45,7 @@ public function register() } return [T_DOC_COMMENT_TAG]; - - }//end register() + } /** @@ -96,7 +95,7 @@ public function process(File $phpcsFile, $stackPtr) // The standard format for the deprecation text is: // @deprecated in %in-version% and is removed from %removal-version%. %extra-info%. - $standardFormat = "@deprecated in %%deprecation-version%% and is removed from %%removal-version%%. %%extra-info%%."; + $standardFormat = '@deprecated in %%deprecation-version%% and is removed from %%removal-version%%. %%extra-info%%.'; // Use (?U) 'ungreedy' before the removal-version so that only the text // up to the first dot+space is matched, as there may be more than one @@ -110,7 +109,7 @@ public function process(File $phpcsFile, $stackPtr) // The full text does not match the standard. Try to find fixes by // testing with a relaxed set of criteria, based on common // formatting variations. This is designed for Core fixes only. - $error = "The text '@deprecated %s' does not match the standard format: ".$standardFormat; + $error = "The text '@deprecated %s' does not match the standard format: " . $standardFormat; // All of the standard text should be on the first comment line, so // try to match with common formatting errors to allow an automatic // fix. If not possible then report a normal error. @@ -131,9 +130,9 @@ public function process(File $phpcsFile, $stackPtr) // It is a Drupal core deprecation and is fixable. if (empty($matchesFix[1]) === false && $this->debug === true) { // For info, to check it is acceptable to remove the text in [1]. - echo('DEBUG: File: '.$phpcsFile->path.', line '.$tokens[($stackPtr)]['line'].PHP_EOL); - echo('DEBUG: "@deprecated '.$text1.'"'.PHP_EOL); - echo('DEBUG: Fix will remove: "'.$matchesFix[1].'"'.PHP_EOL); + echo('DEBUG: File: ' . $phpcsFile->path . ', line ' . $tokens[($stackPtr)]['line'] . PHP_EOL); + echo('DEBUG: "@deprecated ' . $text1 . '"' . PHP_EOL); + echo('DEBUG: Fix will remove: "' . $matchesFix[1] . '"' . PHP_EOL); } $ver1 = str_Replace(['-dev', 'x'], ['', '0'], trim($matchesFix[5], '.')); @@ -147,14 +146,14 @@ public function process(File $phpcsFile, $stackPtr) $ver2 .= '.0'; } - $correctedText = trim('in drupal:'.$ver1.' and is removed from drupal:'.$ver2.'. '.trim($matchesFix[14])); + $correctedText = trim('in drupal:' . $ver1 . ' and is removed from drupal:' . $ver2 . '. ' . trim($matchesFix[14])); // If $correctedText is longer than 65 this will make the whole line // exceed 80 so give a warning if running with debug. if (strlen($correctedText) > 65 && $this->debug === true) { - echo('WARNING: File '.$phpcsFile->path.', line '.$tokens[($stackPtr)]['line'].PHP_EOL); - echo('WARNING: Original = * @deprecated '.$text1.PHP_EOL); - echo('WARNING: Corrected = * @deprecated '.$correctedText.PHP_EOL); - echo('WARNING: New line length '.(strlen($correctedText) + 15).' exceeds standard 80 character limit'.PHP_EOL); + echo('WARNING: File ' . $phpcsFile->path . ', line ' . $tokens[($stackPtr)]['line'] . PHP_EOL); + echo('WARNING: Original = * @deprecated ' . $text1 . PHP_EOL); + echo('WARNING: Corrected = * @deprecated ' . $correctedText . PHP_EOL); + echo('WARNING: New line length ' . (strlen($correctedText) + 15) . ' exceeds standard 80 character limit' . PHP_EOL); } $fix = $phpcsFile->addFixableError($error, $key, 'IncorrectTextLayout', [$fullText]); @@ -184,7 +183,7 @@ public function process(File $phpcsFile, $stackPtr) // except for missing extra info. This is a common fault so provide // a separate check and message for this. if ($matches[3] === '') { - $error = 'The @deprecated tag must have %extra-info%. The standard format is: '.str_replace('%%', '%', $standardFormat); + $error = 'The @deprecated tag must have %extra-info%. The standard format is: ' . str_replace('%%', '%', $standardFormat); $phpcsFile->addError($error, $stackPtr, 'MissingExtraInfo', []); } }//end if @@ -220,12 +219,9 @@ public function process(File $phpcsFile, $stackPtr) $content = substr($crLink, 0, -(strlen($matches[4]))); $phpcsFile->fixer->replaceToken($string, $content); }//end if - } else if (empty($matches) === true) { + } elseif (empty($matches) === true) { $error = "The @see url '%s' does not match the standard: http(s)://www.drupal.org/node/n or http(s)://www.drupal.org/project/aaa/issues/n"; $phpcsFile->addWarning($error, $seeTag, 'DeprecatedWrongSeeUrlFormat', [$crLink]); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentAlignmentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentAlignmentSniff.php index fa505741..fcefdc95 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentAlignmentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentAlignmentSniff.php @@ -35,8 +35,7 @@ class DocCommentAlignmentSniff implements Sniff public function register() { return [T_DOC_COMMENT_OPEN_TAG]; - - }//end register() + } /** @@ -127,7 +126,7 @@ public function process(File $phpcsFile, $stackPtr) if ($fix === true) { $phpcsFile->fixer->addContent($i, ' '); } - } else if ($tokens[($i + 2)]['code'] === T_DOC_COMMENT_TAG + } elseif ($tokens[($i + 2)]['code'] === T_DOC_COMMENT_TAG && $tokens[($i + 1)]['content'] !== ' ' // Special @code/@endcode/@see tags can have more than 1 space. && in_array( @@ -149,8 +148,5 @@ public function process(File $phpcsFile, $stackPtr) } }//end if }//end for - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentLongArraySyntaxSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentLongArraySyntaxSniff.php index 97952b29..9c717b54 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentLongArraySyntaxSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentLongArraySyntaxSniff.php @@ -31,8 +31,7 @@ class DocCommentLongArraySyntaxSniff implements Sniff public function register() { return [T_DOC_COMMENT_OPEN_TAG]; - - }//end register() + } /** @@ -70,8 +69,5 @@ public function process(File $phpcsFile, $stackPtr) } } } while ($codeStart !== false); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php index 440c76a4..a06b02fc 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php @@ -36,8 +36,7 @@ class DocCommentSniff implements Sniff public function register() { return [T_DOC_COMMENT_OPEN_TAG]; - - }//end register() + } /** @@ -179,7 +178,7 @@ public function process(File $phpcsFile, $stackPtr) for ($i = $start; $i < $short; $i++) { if ($tokens[$i]['line'] === $tokens[$start]['line']) { continue; - } else if ($tokens[$i]['line'] === $tokens[$short]['line']) { + } elseif ($tokens[$i]['line'] === $tokens[$short]['line']) { break; } @@ -293,7 +292,7 @@ public function process(File $phpcsFile, $stackPtr) for ($i = ($shortEnd + 1); $i < $long; $i++) { if ($tokens[$i]['line'] === $tokens[$shortEnd]['line']) { continue; - } else if ($tokens[$i]['line'] === ($tokens[$long]['line'] - 1)) { + } elseif ($tokens[$i]['line'] === ($tokens[$long]['line'] - 1)) { break; } @@ -378,7 +377,7 @@ public function process(File $phpcsFile, $stackPtr) } $indent = str_repeat(' ', $tokens[$stackPtr]['column']); - $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar.$indent.'*'.$phpcsFile->eolChar); + $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar . $indent . '*' . $phpcsFile->eolChar); $phpcsFile->fixer->endChangeset(); } } @@ -443,7 +442,7 @@ public function process(File $phpcsFile, $stackPtr) // All of the $checkTags sections should be separated by a blank // line both before and after the sections. - } else if ($isNewGroup === false + } elseif ($isNewGroup === false && (in_array($currentTag, $checkTags) === true || in_array($previousTag, $checkTags) === true) && $previousTag !== $currentTag && in_array($tokens[$prev]['code'], Tokens::PHPCS_ANNOTATION_TOKENS) === false @@ -451,7 +450,7 @@ public function process(File $phpcsFile, $stackPtr) $error = 'Separate the %s and %s sections by a blank line.'; $fix = $phpcsFile->addFixableError($error, $tag, 'TagGroupSpacing', [$previousTag, $currentTag]); if ($fix === true) { - $phpcsFile->fixer->replaceToken(($tag - 1), "\n".str_repeat(' ', ($tokens[$tag]['column'] - 3)).'* '); + $phpcsFile->fixer->replaceToken(($tag - 1), "\n" . str_repeat(' ', ($tokens[$tag]['column'] - 3)) . '* '); } }//end if @@ -502,7 +501,7 @@ public function process(File $phpcsFile, $stackPtr) } $indent = str_repeat(' ', $tokens[$stackPtr]['column']); - $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar.$indent.'*'.$phpcsFile->eolChar); + $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar . $indent . '*' . $phpcsFile->eolChar); $phpcsFile->fixer->endChangeset(); } } @@ -551,8 +550,5 @@ public function process(File $phpcsFile, $stackPtr) $foundTags[$tagName] = true; $lastPos = $pos; } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php index 1d0a8e3f..99385f08 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php @@ -31,8 +31,7 @@ class DocCommentStarSniff implements Sniff public function register() { return [T_DOC_COMMENT_OPEN_TAG]; - - }//end register() + } /** @@ -62,9 +61,9 @@ public function process(File $phpcsFile, $stackPtr) $fix = $phpcsFile->addFixableError($error, $i, 'StarMissing'); if ($fix === true) { if (strpos($tokens[$i]['content'], $phpcsFile->eolChar) !== false) { - $phpcsFile->fixer->replaceToken($i, str_repeat(' ', $tokens[$stackPtr]['column'])."* \n"); + $phpcsFile->fixer->replaceToken($i, str_repeat(' ', $tokens[$stackPtr]['column']) . "* \n"); } else { - $phpcsFile->fixer->replaceToken($i, str_repeat(' ', $tokens[$stackPtr]['column']).'* '); + $phpcsFile->fixer->replaceToken($i, str_repeat(' ', $tokens[$stackPtr]['column']) . '* '); } // Ordering of lines might have changed - stop here. The @@ -72,18 +71,15 @@ public function process(File $phpcsFile, $stackPtr) return; } } - } else if ($tokens[$i]['code'] !== T_DOC_COMMENT_STAR) { + } elseif ($tokens[$i]['code'] !== T_DOC_COMMENT_STAR) { $error = 'Doc comment star missing'; $fix = $phpcsFile->addFixableError($error, $i, 'StarMissing'); if ($fix === true) { - $phpcsFile->fixer->addContentBefore($i, str_repeat(' ', $tokens[$stackPtr]['column']).'* '); + $phpcsFile->fixer->addContentBefore($i, str_repeat(' ', $tokens[$stackPtr]['column']) . '* '); } }//end if $lastLineChecked = $tokens[$i]['line']; }//end for - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php index fb0f24dd..187fcec6 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php @@ -38,8 +38,7 @@ class FileCommentSniff implements Sniff public function register() { return [T_OPEN_TAG]; - - }//end register() + } /** @@ -122,7 +121,7 @@ public function process(File $phpcsFile, $stackPtr) // insert a space after the stars. if (strpos($content, '/**') === 0) { $phpcsFile->fixer->replaceToken($commentStart, str_replace('/**', '/** ', $content)); - } else if (strpos($content, '/*') === 0) { + } elseif (strpos($content, '/*') === 0) { // Just turn the /* ... */ style comment into a /** ... */ style // comment. $phpcsFile->fixer->replaceToken($commentStart, str_replace('/*', '/**', $content)); @@ -133,7 +132,7 @@ public function process(File $phpcsFile, $stackPtr) } return ($phpcsFile->numTokens + 1); - } else if ($commentStart === false || $tokens[$commentStart]['code'] !== T_DOC_COMMENT_OPEN_TAG) { + } elseif ($commentStart === false || $tokens[$commentStart]['code'] !== T_DOC_COMMENT_OPEN_TAG) { $fix = $phpcsFile->addFixableError('Missing file doc comment', 0, 'Missing'); if ($fix === true) { // Only PHP has a real opening tag, additional newline at the @@ -231,8 +230,5 @@ public function process(File $phpcsFile, $stackPtr) // Ignore the rest of the file. return ($phpcsFile->numTokens + 1); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php index dc83570f..2104345a 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php @@ -59,8 +59,7 @@ class FunctionCommentSniff implements Sniff public function register() { return [T_FUNCTION]; - - }//end register() + } /** @@ -139,11 +138,11 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->beginChangeset(); $comment = ''; for ($i = $commentEnd; $tokens[$i]['code'] === T_COMMENT; $i--) { - $comment = ' *'.ltrim($tokens[$i]['content'], '/* ').$comment; + $comment = ' *' . ltrim($tokens[$i]['content'], '/* ') . $comment; $phpcsFile->fixer->replaceToken($i, ''); } - $phpcsFile->fixer->replaceToken($commentEnd, "/**\n".rtrim($comment, "*/\n")."\n */\n"); + $phpcsFile->fixer->replaceToken($commentEnd, "/**\n" . rtrim($comment, "*/\n") . "\n */\n"); $phpcsFile->fixer->endChangeset(); } @@ -185,8 +184,7 @@ public function process(File $phpcsFile, $stackPtr) $this->processThrows($phpcsFile, $stackPtr, $commentStart); $this->processParams($phpcsFile, $stackPtr, $commentStart); $this->processSees($phpcsFile, $stackPtr, $commentStart); - - }//end process() + } /** @@ -199,8 +197,7 @@ public function process(File $phpcsFile, $stackPtr) public static function tokenIsPhpstanComment($token) { return ($token['code'] === T_COMMENT && strpos($token['content'], ' @phpstan-') !== false); - - }//end tokenIsPhpstanComment() + } /** @@ -253,7 +250,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) if (empty($returnType) === true || $tokens[($return + 2)]['code'] !== T_DOC_COMMENT_STRING) { $error = 'Return type missing for @return tag in function comment'; $phpcsFile->addError($error, $return, 'MissingReturnType'); - } else if (strpos($returnType, ' ') === false) { + } elseif (strpos($returnType, ' ') === false) { // Check return type (can be multiple, separated by '|'). $typeNames = explode('|', $returnType); $suggestedNames = []; @@ -321,7 +318,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) } } }//end if - } else if ($returnType !== 'mixed' + } elseif ($returnType !== 'mixed' && $returnType !== 'never' && in_array('void', $typeNames, true) === false ) { @@ -368,7 +365,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) $indent = strlen($tokens[($i - 1)]['content']); } - $comment .= ' '.$tokens[$i]['content']; + $comment .= ' ' . $tokens[$i]['content']; $commentLines[] = [ 'comment' => $tokens[$i]['content'], 'token' => $i, @@ -403,7 +400,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) } $phpcsFile->addError($error, $return, 'MissingReturnComment'); - } else if (strpos($returnType, ' ') !== false) { + } elseif (strpos($returnType, ' ') !== false) { if (preg_match('/^([^\s]+)[\s]+(\$[^\s]+)[\s]*$/', $returnType, $matches) === 1) { $error = 'Return type must not contain variable name "%s"'; $data = [$matches[2]]; @@ -414,15 +411,14 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) // Do not check PHPStan types that contain any kind of brackets. // See https://phpstan.org/writing-php-code/phpdoc-types#general-arrays . - } else if (preg_match('/[<\[\{\(]/', $returnType) === 0) { + } elseif (preg_match('/[<\[\{\(]/', $returnType) === 0) { $error = 'Return type "%s" must not contain spaces'; $data = [$returnType]; $phpcsFile->addError($error, $return, 'ReturnTypeSpaces', $data); } }//end if }//end if - - }//end processReturn() + } /** @@ -468,7 +464,7 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) $indent = strlen($tokens[($i - 1)]['content']); } - $comment .= ' '.$tokens[$i]['content']; + $comment .= ' ' . $tokens[$i]['content']; if ($indent < 3) { $error = 'Throws comment indentation must be 3 spaces, found %s spaces'; $phpcsFile->addError($error, $i, 'ThrowsCommentIndentation', [$indent]); @@ -501,8 +497,7 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) } }//end if }//end foreach - - }//end processThrows() + } /** @@ -571,7 +566,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $error = 'Doc comment parameter name "%s" must not end with a dot'; $fix = $phpcsFile->addFixableError($error, ($tag + 2), 'ParamNameDot', [$var]); if ($fix === true) { - $content = $type.' '.substr($var, 0, -1); + $content = $type . ' ' . substr($var, 0, -1); $phpcsFile->fixer->replaceToken(($tag + 2), $content); } @@ -627,7 +622,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) } } - $comment .= ' '.$tokens[$i]['content']; + $comment .= ' ' . $tokens[$i]['content']; $commentLines[] = [ 'comment' => $tokens[$i]['content'], 'token' => $i, @@ -679,7 +674,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) if (isset($matches[4]) === true && preg_match('/[^\s]+[\s]+[^\s]+/', $matches[4]) === 0) { $fix = $phpcsFile->addFixableError($error, $tag, 'MissingParamType'); if ($fix === true) { - $phpcsFile->fixer->replaceToken(($tag + 2), $matches[4].' '.$var); + $phpcsFile->fixer->replaceToken(($tag + 2), $matches[4] . ' ' . $var); } } else { $phpcsFile->addError($error, $tag, 'MissingParamType'); @@ -732,9 +727,9 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) if ($realName === $param['var'] || ($realParams[$checkPos]['pass_by_reference'] === true - && ('&'.$realName) === $param['var']) + && ('&' . $realName) === $param['var']) || ($realParams[$checkPos]['variable_length'] === true - && ('...'.$realName) === $param['var']) + && ('...' . $realName) === $param['var']) ) { $matched = true; break; @@ -767,7 +762,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) $data = [$param['type']]; $phpcsFile->addError($error, $param['tag'], 'ParamTypeSpaces', $data); } - } else if ($param['type'] !== $suggestedType) { + } elseif ($param['type'] !== $suggestedType) { $error = 'Expected "%s" but found "%s" for parameter type'; $data = [ $suggestedType, @@ -842,7 +837,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) // Reset the parameter position to check for following // parameters. $checkPos = ($pos - 1); - } else if (substr($param['var'], -4) !== ',...') { + } elseif (substr($param['var'], -4) !== ',...') { // We must have an extra parameter comment. $error = 'Superfluous parameter comment'; $phpcsFile->addError($error, $param['tag'], 'ExtraParamComment'); @@ -915,8 +910,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) } } }//end if - - }//end processParams() + } /** @@ -957,8 +951,7 @@ protected function processSees(File $phpcsFile, $stackPtr, $commentStart) } } }//end foreach - - }//end processSees() + } /** @@ -984,8 +977,7 @@ public static function suggestType($type) $type = preg_replace('/[^a-zA-Z0-9_\\\[\]\-<> ,"\{\}\?\':\*\|\&\(\)]/', '', $type); return $type; - - }//end suggestType() + } /** @@ -1017,8 +1009,5 @@ protected function isInCodeExample(File $phpcsFile, $stackPtr, $commentStart) } return false; - - }//end isInCodeExample() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/GenderNeutralCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/GenderNeutralCommentSniff.php index cb1f41d9..2f27de3a 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/GenderNeutralCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/GenderNeutralCommentSniff.php @@ -34,8 +34,7 @@ public function register() T_COMMENT, T_DOC_COMMENT_STRING, ]; - - }//end register() + } /** @@ -53,8 +52,5 @@ public function process(File $phpcsFile, $stackPtr) if ((bool) preg_match('/(^|\W)(he|her|hers|him|his|she)($|\W)/i', $tokens[$stackPtr]['content']) === true) { $phpcsFile->addError('Unnecessarily gendered language in a comment', $stackPtr, 'GenderNeutral'); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php index 75a52644..a37073f4 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php @@ -31,8 +31,7 @@ class HookCommentSniff implements Sniff public function register() { return [T_FUNCTION]; - - }//end register() + } /** @@ -122,8 +121,5 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->replaceToken($short, $newComment); } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php index 74415b79..4af56df4 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php @@ -40,8 +40,7 @@ public function register() T_COMMENT, T_DOC_COMMENT_OPEN_TAG, ]; - - }//end register() + } /** @@ -221,7 +220,7 @@ 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, 2), @@ -231,7 +230,7 @@ public function process(File $phpcsFile, $stackPtr) }//end if if ($fix === true) { - $newComment = '// '.ltrim($tokens[$lastCommentToken]['content'], "/\t "); + $newComment = '// ' . ltrim($tokens[$lastCommentToken]['content'], "/\t "); $phpcsFile->fixer->replaceToken($lastCommentToken, $newComment); } @@ -263,17 +262,17 @@ public function process(File $phpcsFile, $stackPtr) $error = 'Comment indentation error after %s element, expected %s spaces'; $fix = $phpcsFile->addFixableError($error, $lastCommentToken, 'SpacingBefore', [$words[1], ($prevSpaceCount + 2)]); if ($fix === true) { - $newComment = '//'.str_repeat(' ', ($prevSpaceCount + 2)).ltrim($tokens[$lastCommentToken]['content'], "/\t "); + $newComment = '//' . str_repeat(' ', ($prevSpaceCount + 2)) . ltrim($tokens[$lastCommentToken]['content'], "/\t "); $phpcsFile->fixer->replaceToken($lastCommentToken, $newComment); } } - } else if ($numberedList === true) { + } elseif ($numberedList === true) { $expectedSpaceCount = ($prevSpaceCount + strlen($words[1]) + 1); if ($spaceCount !== $expectedSpaceCount) { $error = 'Comment indentation error, expected %s spaces'; $fix = $phpcsFile->addFixableError($error, $lastCommentToken, 'SpacingBefore', [$expectedSpaceCount]); if ($fix === true) { - $newComment = '//'.str_repeat(' ', $expectedSpaceCount).ltrim($tokens[$lastCommentToken]['content'], "/\t "); + $newComment = '//' . str_repeat(' ', $expectedSpaceCount) . ltrim($tokens[$lastCommentToken]['content'], "/\t "); $phpcsFile->fixer->replaceToken($lastCommentToken, $newComment); } } @@ -291,7 +290,7 @@ public function process(File $phpcsFile, $stackPtr) ]; $fix = $phpcsFile->addFixableError($error, $lastCommentToken, 'SpacingBefore', $data); if ($fix === true) { - $phpcsFile->fixer->replaceToken($lastCommentToken, '// '.substr($comment, (2 + $spaceCount)).$phpcsFile->eolChar); + $phpcsFile->fixer->replaceToken($lastCommentToken, '// ' . substr($comment, (2 + $spaceCount)) . $phpcsFile->eolChar); } }//end if }//end if @@ -359,7 +358,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, ' ,'); @@ -407,7 +406,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; } } @@ -429,8 +428,7 @@ public function process(File $phpcsFile, $stackPtr) }//end if return ($lastCommentToken + 1); - - }//end process() + } /** @@ -446,7 +444,7 @@ public function process(File $phpcsFile, $stackPtr) protected function isInCodeExample(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr]['content'] === '// @code'.$phpcsFile->eolChar) { + if ($tokens[$stackPtr]['content'] === '// @code' . $phpcsFile->eolChar) { return true; } @@ -457,11 +455,11 @@ protected function isInCodeExample(File $phpcsFile, $stackPtr) return false; } - if ($tokens[$prevComment]['content'] === '// @code'.$phpcsFile->eolChar) { + if ($tokens[$prevComment]['content'] === '// @code' . $phpcsFile->eolChar) { return true; } - if ($tokens[$prevComment]['content'] === '// @endcode'.$phpcsFile->eolChar) { + if ($tokens[$prevComment]['content'] === '// @endcode' . $phpcsFile->eolChar) { return false; } @@ -469,8 +467,5 @@ protected function isInCodeExample(File $phpcsFile, $stackPtr) } return false; - - }//end isInCodeExample() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/InlineVariableCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/InlineVariableCommentSniff.php index 6f116329..3774f9fd 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/InlineVariableCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/InlineVariableCommentSniff.php @@ -36,8 +36,7 @@ public function register() T_COMMENT, T_DOC_COMMENT_TAG, ]; - - }//end register() + } /** @@ -99,7 +98,7 @@ public function process(File $phpcsFile, $stackPtr) // Remove all leading hashtags and slashes. $varContent = ltrim($varContent, '/# '); - $phpcsFile->fixer->replaceToken($stackPtr, ('/** '.$varContent." */\n")); + $phpcsFile->fixer->replaceToken($stackPtr, ('/** ' . $varContent . " */\n")); } } else { if ($phpcsFile->addFixableWarning($warning, $stackPtr, 'VarInline') === true) { @@ -144,8 +143,5 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->addWarning($warning, $varContentPtr, 'VarInlineOrder'); } }//end if - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/PostStatementCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/PostStatementCommentSniff.php index 2623fefa..d45bbee2 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/PostStatementCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/PostStatementCommentSniff.php @@ -33,8 +33,7 @@ class PostStatementCommentSniff implements Sniff public function register() { return [T_COMMENT]; - - }//end register() + } /** @@ -85,8 +84,5 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->replaceToken($stackPtr, $phpcsFile->eolChar); $phpcsFile->fixer->endChangeset(); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/TodoCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/TodoCommentSniff.php index 021ccd0a..2f007957 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/TodoCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/TodoCommentSniff.php @@ -49,8 +49,7 @@ public function register() T_DOC_COMMENT_TAG, T_DOC_COMMENT_STRING, ]; - - }//end register() + } /** @@ -71,8 +70,8 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); if ($this->debug === true) { - echo "\n------\n\$tokens[$stackPtr] = ".print_r($tokens[$stackPtr], true).PHP_EOL; - echo 'code = '.$tokens[$stackPtr]['code'].', type = '.$tokens[$stackPtr]['type']."\n"; + echo "\n------\n\$tokens[$stackPtr] = " . print_r($tokens[$stackPtr], true) . PHP_EOL; + echo 'code = ' . $tokens[$stackPtr]['code'] . ', type = ' . $tokens[$stackPtr]['type'] . "\n"; } // Standard comments and multi-line comments where the "@" is missing so @@ -84,7 +83,7 @@ public function process(File $phpcsFile, $stackPtr) } $this->checkTodoFormat($phpcsFile, $stackPtr, $comment, $tokens); - } else if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT_TAG) { + } elseif ($tokens[$stackPtr]['code'] === T_DOC_COMMENT_TAG) { // Document comment tag (i.e. comments that begin with "@"). // Determine if this is related at all and build the full comment line // from the various segments that the line is parsed into. @@ -108,8 +107,7 @@ public function process(File $phpcsFile, $stackPtr) $this->checkTodoFormat($phpcsFile, $stackPtr, $comment, $tokens); }//end if }//end if - - }//end process() + } /** @@ -184,8 +182,5 @@ private function checkTodoFormat(File $phpcsFile, int $stackPtr, string $comment }//end if }//end if }//end if - - }//end checkTodoFormat() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php index ac7c6fb2..f9e4ca4c 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php @@ -87,11 +87,11 @@ public function processMemberVar(File $phpcsFile, $stackPtr) $phpcsFile->fixer->beginChangeset(); $comment = ''; for ($i = $commentEnd; $tokens[$i]['code'] === T_COMMENT; $i--) { - $comment = ' *'.ltrim($tokens[$i]['content'], '/* ').$comment; + $comment = ' *' . ltrim($tokens[$i]['content'], '/* ') . $comment; $phpcsFile->fixer->replaceToken($i, ''); } - $phpcsFile->fixer->replaceToken($commentEnd, "/**\n".rtrim($comment, "*/\n")."\n */\n"); + $phpcsFile->fixer->replaceToken($commentEnd, "/**\n" . rtrim($comment, "*/\n") . "\n */\n"); $phpcsFile->fixer->endChangeset(); } @@ -117,7 +117,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr) } else { $foundVar = $tag; } - } else if ($tokens[$tag]['content'] === '@see') { + } 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']) { @@ -176,7 +176,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr) if ($fix === true) { $phpcsFile->fixer->replaceToken(($foundVar + 2), $matches[1]); } - } else if ($varType !== $suggestedType) { + } elseif ($varType !== $suggestedType) { $error = 'Expected "%s" but found "%s" for @var tag in member variable comment'; $data = [ $suggestedType, @@ -187,8 +187,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr) $phpcsFile->fixer->replaceToken(($foundVar + 2), $suggestedType); } }//end if - - }//end processMemberVar() + } /** @@ -204,8 +203,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr) */ protected function processVariable(File $phpcsFile, $stackPtr) { - - }//end processVariable() + } /** @@ -221,8 +219,5 @@ protected function processVariable(File $phpcsFile, $stackPtr) */ protected function processVariableInString(File $phpcsFile, $stackPtr) { - - }//end processVariableInString() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php b/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php index 1d1debf8..1abc71b0 100644 --- a/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -47,8 +47,7 @@ public function register() T_ELSEIF, T_SWITCH, ]; - - }//end register() + } /** @@ -72,7 +71,7 @@ public function process(File $phpcsFile, $stackPtr) $found = 1; if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { $found = 0; - } else if ($tokens[($stackPtr + 1)]['content'] !== ' ') { + } elseif ($tokens[($stackPtr + 1)]['content'] !== ' ') { if (strpos($tokens[($stackPtr + 1)]['content'], $phpcsFile->eolChar) !== false) { $found = 'newline'; } else { @@ -110,7 +109,7 @@ public function process(File $phpcsFile, $stackPtr) if (trim($content) === '') { $found = strlen($content); } else { - $found = '"'.str_replace($phpcsFile->eolChar, '\n', $content).'"'; + $found = '"' . str_replace($phpcsFile->eolChar, '\n', $content) . '"'; } $fix = $phpcsFile->addFixableError($error, $closer, 'SpaceAfterCloseParenthesis', [$found]); @@ -119,7 +118,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->addContent($closer, ' '); } else { $phpcsFile->fixer->beginChangeset(); - $phpcsFile->fixer->addContent($closer, ' '.$tokens[$opener]['content']); + $phpcsFile->fixer->addContent($closer, ' ' . $tokens[$opener]['content']); $phpcsFile->fixer->replaceToken($opener, ''); if ($tokens[$opener]['line'] !== $tokens[$closer]['line']) { @@ -181,7 +180,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->endChangeset(); } }//end if - } else if ($tokens[$stackPtr]['code'] === T_WHILE) { + } elseif ($tokens[$stackPtr]['code'] === T_WHILE) { // Zero spaces after parenthesis closer. $closer = $tokens[$stackPtr]['parenthesis_closer']; $found = 0; @@ -209,7 +208,7 @@ public function process(File $phpcsFile, $stackPtr) if (isset($tokens[$stackPtr]['scope_closer']) === true) { $closer = $tokens[$stackPtr]['scope_closer']; } - } else if ($tokens[$stackPtr]['code'] === T_ELSE + } elseif ($tokens[$stackPtr]['code'] === T_ELSE || $tokens[$stackPtr]['code'] === T_ELSEIF || $tokens[$stackPtr]['code'] === T_CATCH ) { @@ -226,7 +225,7 @@ public function process(File $phpcsFile, $stackPtr) $found = 1; if ($tokens[($closer + 1)]['code'] !== T_WHITESPACE) { $found = 0; - } else if ($tokens[($closer + 1)]['content'] !== ' ') { + } elseif ($tokens[($closer + 1)]['content'] !== ' ') { if (strpos($tokens[($closer + 1)]['content'], $phpcsFile->eolChar) !== false) { $found = 'newline'; } else { @@ -251,7 +250,7 @@ public function process(File $phpcsFile, $stackPtr) $found = 'newline'; if ($tokens[($closer + 1)]['code'] !== T_WHITESPACE) { $found = 'none'; - } else if (strpos($tokens[($closer + 1)]['content'], "\n") === false) { + } elseif (strpos($tokens[($closer + 1)]['content'], "\n") === false) { $found = 'spaces'; } @@ -267,8 +266,5 @@ public function process(File $phpcsFile, $stackPtr) } } }//end if - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php b/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php index 4d41827d..9df7a2b8 100644 --- a/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php +++ b/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php @@ -31,8 +31,7 @@ class ElseIfSniff implements Sniff public function register() { return [T_ELSE]; - - }//end register() + } /** @@ -73,8 +72,5 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->endChangeset(); } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/ControlStructures/InlineControlStructureSniff.php b/coder_sniffer/Drupal/Sniffs/ControlStructures/InlineControlStructureSniff.php index 90e757cc..6ff8364c 100644 --- a/coder_sniffer/Drupal/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/coder_sniffer/Drupal/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -54,8 +54,5 @@ public function process(File $phpcsFile, $stackPtr) } parent::process($phpcsFile, $stackPtr); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php b/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php index deb38402..8e5be4ba 100644 --- a/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php @@ -37,8 +37,7 @@ public function register() T_OPEN_TAG, T_INLINE_HTML, ]; - - }//end register() + } /** @@ -73,7 +72,7 @@ public function process(File $phpcsFile, $stackPtr) $lastLine = $tokens[$lastToken]['line']; if ($tokens[$lastToken]['code'] === T_WHITESPACE) { $lastCode = $phpcsFile->findPrevious(T_WHITESPACE, ($lastToken - 1), null, true); - } else if ($tokens[$lastToken]['code'] === T_INLINE_HTML) { + } elseif ($tokens[$lastToken]['code'] === T_INLINE_HTML) { $lastCode = $lastToken; while ($lastCode > 0 && trim($tokens[$lastCode]['content']) === '') { $lastCode--; @@ -105,8 +104,5 @@ public function process(File $phpcsFile, $stackPtr) // Skip the rest of the file. return ($phpcsFile->numTokens + 1); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Files/FileEncodingSniff.php b/coder_sniffer/Drupal/Sniffs/Files/FileEncodingSniff.php index dd3a8747..bbc777ea 100644 --- a/coder_sniffer/Drupal/Sniffs/Files/FileEncodingSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Files/FileEncodingSniff.php @@ -45,8 +45,7 @@ public function register() T_INLINE_HTML, T_OPEN_TAG, ]; - - }//end register() + } /** @@ -81,8 +80,5 @@ public function process(File $phpcsFile, $stackPtr) } return $phpcsFile->numTokens; - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php b/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php index 4cd3774d..d62b9a86 100644 --- a/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php @@ -88,7 +88,7 @@ protected function checkLineLength($phpcsFile, $tokens, $stackPtr) // Drupal 8 annotations can have long translatable descriptions and we // allow them to exceed 80 characters. - if ($tokens[($stackPtr - 2)]['code'] === T_DOC_COMMENT_STRING + if (($tokens[($stackPtr - 2)]['code'] === T_DOC_COMMENT_STRING && (strpos($tokens[($stackPtr - 2)]['content'], '@Translation(') !== false // Also allow anything without whitespace (like URLs) to exceed 80 // characters. @@ -98,7 +98,7 @@ protected function checkLineLength($phpcsFile, $tokens, $stackPtr) // Allow long paths or namespaces in annotations such as // "list_builder" = "Drupal\rules\Entity\Controller\RulesReactionListBuilder" // cardinality = \Drupal\webform\WebformHandlerInterface::CARDINALITY_UNLIMITED. - || preg_match('#= ("|\')?\S+[\\\\/]\S+("|\')?,*$#', $tokens[($stackPtr - 2)]['content']) === 1) + || preg_match('#= ("|\')?\S+[\\\\/]\S+("|\')?,*$#', $tokens[($stackPtr - 2)]['content']) === 1)) // Allow @link tags in lists. || strpos($tokens[($stackPtr - 2)]['content'], '- @link') !== false // Allow hook implementation line to exceed 80 characters. @@ -109,8 +109,7 @@ protected function checkLineLength($phpcsFile, $tokens, $stackPtr) parent::checkLineLength($phpcsFile, $tokens, $stackPtr); }//end if - - }//end checkLineLength() + } /** @@ -136,8 +135,5 @@ public function getLineLength(File $phpcsFile, $currentLine) } return strlen($currentLineContent); - - }//end getLineLength() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php b/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php index 66f93c83..dc3186d0 100644 --- a/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php @@ -34,8 +34,7 @@ class TxtFileLineLengthSniff implements Sniff public function register() { return [T_INLINE_HTML]; - - }//end register() + } /** @@ -81,8 +80,5 @@ public function process(File $phpcsFile, $stackPtr) } }//end if }//end if - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php b/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php index 8a02a790..9c017426 100644 --- a/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php @@ -33,8 +33,7 @@ class MultiLineAssignmentSniff implements Sniff public function register() { return [T_EQUAL]; - - }//end register() + } /** @@ -91,8 +90,5 @@ public function process(File $phpcsFile, $stackPtr) $error = "Multi-line assignment not indented correctly; expected $expectedIndent spaces but found $foundIndent"; $phpcsFile->addError($error, $stackPtr, 'MultiLineAssignmentIndent'); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/coder_sniffer/Drupal/Sniffs/Formatting/MultipleStatementAlignmentSniff.php index c3228dc2..86e497af 100644 --- a/coder_sniffer/Drupal/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Formatting/MultipleStatementAlignmentSniff.php @@ -24,7 +24,6 @@ class MultipleStatementAlignmentSniff extends GenericMultipleStatementAlignmentSniff { - /** * If true, an error will be thrown; otherwise a warning. * @@ -44,7 +43,7 @@ class MultipleStatementAlignmentSniff extends GenericMultipleStatementAlignmentS * * @return int */ - public function checkAlignment($phpcsFile, $stackPtr, $end=null) + public function checkAlignment($phpcsFile, $stackPtr, $end = null) { $tokens = $phpcsFile->getTokens(); @@ -124,7 +123,7 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null) } else { $lastSemi = $assign; } - } else if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) { + } elseif ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) { // Statement is in a different context, so the block is over. break; } @@ -132,7 +131,7 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null) }//end if continue; - } else if ($assign !== $stackPtr && $tokens[$assign]['line'] === $lastLine) { + } elseif ($assign !== $stackPtr && $tokens[$assign]['line'] === $lastLine) { // Skip multiple assignments on the same line. We only need to // try and align the first assignment. continue; @@ -145,10 +144,10 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null) $assign = $this->checkAlignment($phpcsFile, $assign); $lastCode = $assign; continue; - } else if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) { + } elseif ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) { // We've gone one level up, so the block we are processing is done. break; - } else if ($arrayEnd !== null) { + } elseif ($arrayEnd !== null) { // Assignments inside arrays are not part of // the original block, so process this new block. $assign = ($this->checkAlignment($phpcsFile, $assign, $arrayEnd) - 1); @@ -222,7 +221,7 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null) $padding = 1; $assignColumn = ($varEnd + 1); } - } else if ($padding > $assignments[$maxPadding]['expected']) { + } elseif ($padding > $assignments[$maxPadding]['expected']) { $maxPadding = $assign; }//end if } else { @@ -284,7 +283,7 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null) continue; } - $expectedText = $data['expected'].' space'; + $expectedText = $data['expected'] . ' space'; if ($data['expected'] !== 1) { $expectedText .= 's'; } @@ -292,7 +291,7 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null) if ($data['found'] === null) { $foundText = 'a new line'; } else { - $foundText = $data['found'].' space'; + $foundText = $data['found'] . ' space'; if ($data['found'] !== 1) { $foundText .= 's'; } @@ -314,7 +313,7 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null) if ($this->error === true) { $fix = $phpcsFile->addFixableError($error, $assignment, $type, $errorData); } else { - $fix = $phpcsFile->addFixableWarning($error, $assignment, $type.'Warning', $errorData); + $fix = $phpcsFile->addFixableWarning($error, $assignment, $type . 'Warning', $errorData); } $errorGenerated = true; @@ -342,8 +341,5 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null) } else { return $assign; } - - }//end checkAlignment() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php b/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php index e9f4ac04..dca186d0 100644 --- a/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php @@ -31,8 +31,7 @@ class SpaceInlineIfSniff implements Sniff public function register() { return [T_INLINE_ELSE]; - - }//end register() + } /** @@ -56,8 +55,5 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->addError($error, $stackPtr, 'SpaceInlineElse'); } }//end if - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php b/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php index b5abbf58..5217437c 100644 --- a/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php @@ -41,8 +41,7 @@ public function register() T_PLUS, T_BOOLEAN_NOT, ]; - - }//end register() + } /** @@ -139,8 +138,5 @@ public function process(File $phpcsFile, $stackPtr) } } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php b/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php index 444bc53b..9c5c16bc 100644 --- a/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php @@ -69,4 +69,4 @@ class DiscouragedFunctionsSniff extends ForbiddenFunctionsSniff */ public $error = false; -}//end class +} diff --git a/coder_sniffer/Drupal/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php b/coder_sniffer/Drupal/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php index 5c161ad7..312c68be 100644 --- a/coder_sniffer/Drupal/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php @@ -26,7 +26,6 @@ class MultiLineFunctionDeclarationSniff extends SquizFunctionDeclarationSniff { - /** * The number of spaces code should be indented. * @@ -53,8 +52,7 @@ public function processSingleLineDeclaration($phpcsFile, $stackPtr, $tokens) $sniff = new OpeningFunctionBraceKernighanRitchieSniff(); $sniff->checkClosures = true; $sniff->process($phpcsFile, $stackPtr); - - }//end processSingleLineDeclaration() + } /** @@ -78,8 +76,7 @@ public function isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tok } return true; - - }//end isMultiLineDeclaration() + } /** @@ -122,8 +119,5 @@ public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens) $phpcsFile->fixer->addContent($lastTrailingComma, ','); } } - - }//end processMultiLineDeclaration() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php b/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php index 571baed6..9e1d5ae3 100644 --- a/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php +++ b/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php @@ -32,8 +32,7 @@ class AutoAddedKeysSniff implements Sniff public function register() { return [T_INLINE_HTML]; - - }//end register() + } /** @@ -52,7 +51,7 @@ public function process(File $phpcsFile, $stackPtr) // Drupal 7 style info file. $contents = file_get_contents($phpcsFile->getFilename()); $info = ClassFilesSniff::drupalParseInfoFormat($contents); - } else if (preg_match('/\.info\.yml$/', $phpcsFile->getFilename()) === 1) { + } elseif (preg_match('/\.info\.yml$/', $phpcsFile->getFilename()) === 1) { // Drupal 8 style info.yml file. $contents = file_get_contents($phpcsFile->getFilename()); try { @@ -82,8 +81,5 @@ public function process(File $phpcsFile, $stackPtr) } return ($phpcsFile->numTokens + 1); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php b/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php index 6bb8bd82..bab2b237 100644 --- a/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php +++ b/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php @@ -32,8 +32,7 @@ class ClassFilesSniff implements Sniff public function register() { return [T_INLINE_HTML]; - - }//end register() + } /** @@ -57,7 +56,7 @@ public function process(File $phpcsFile, $stackPtr) $info = self::drupalParseInfoFormat($contents); if (isset($info['files']) === true && is_array($info['files']) === true) { foreach ($info['files'] as $file) { - $fileName = dirname($phpcsFile->getFilename()).'/'.$file; + $fileName = dirname($phpcsFile->getFilename()) . '/' . $file; if (file_exists($fileName) === false) { // We need to find the position of the offending line in the // info file. @@ -85,8 +84,7 @@ public function process(File $phpcsFile, $stackPtr) }//end if return ($phpcsFile->numTokens + 1); - - }//end process() + } /** @@ -102,14 +100,13 @@ public function process(File $phpcsFile, $stackPtr) public static function getPtr($key, $value, File $infoFile) { foreach ($infoFile->getTokens() as $ptr => $tokenInfo) { - if (preg_match('@^[\s]*'.preg_quote($key).'[\s]*=[\s]*["\']?'.preg_quote($value).'["\']?@', $tokenInfo['content']) === 1) { + if (preg_match('@^[\s]*' . preg_quote($key) . '[\s]*=[\s]*["\']?' . preg_quote($value) . '["\']?@', $tokenInfo['content']) === 1) { return $ptr; } } return false; - - }//end getPtr() + } /** @@ -154,7 +151,7 @@ public static function drupalParseInfoFormat($data) } } - $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3; + $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3; // Parse array syntax. $keys = preg_split('/\]?\[/', rtrim($key, ']')); @@ -189,8 +186,5 @@ public static function drupalParseInfoFormat($data) }//end if return $info; - - }//end drupalParseInfoFormat() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/InfoFiles/DependenciesArraySniff.php b/coder_sniffer/Drupal/Sniffs/InfoFiles/DependenciesArraySniff.php index 2d0f3927..926815a7 100644 --- a/coder_sniffer/Drupal/Sniffs/InfoFiles/DependenciesArraySniff.php +++ b/coder_sniffer/Drupal/Sniffs/InfoFiles/DependenciesArraySniff.php @@ -6,6 +6,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ + namespace Drupal\Sniffs\InfoFiles; use PHP_CodeSniffer\Files\File; @@ -32,8 +33,7 @@ class DependenciesArraySniff implements Sniff public function register() { return [T_INLINE_HTML]; - - }//end register() + } /** @@ -76,8 +76,5 @@ public function process(File $phpcsFile, $stackPtr) } return ($phpcsFile->numTokens + 1); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php b/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php index 6e0a04ee..713e48e6 100644 --- a/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php +++ b/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php @@ -31,8 +31,7 @@ class DuplicateEntrySniff implements Sniff public function register() { return [T_INLINE_HTML]; - - }//end register() + } /** @@ -62,8 +61,7 @@ public function process(File $phpcsFile, $stackPtr) } return ($phpcsFile->numTokens + 1); - - }//end process() + } /** @@ -109,7 +107,7 @@ protected function findDuplicateInfoFileEntries($data) } } - $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3; + $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3; // Parse array syntax. $keys = preg_split('/\]?\[/', rtrim($key, ']')); @@ -148,8 +146,5 @@ protected function findDuplicateInfoFileEntries($data) }//end if return $duplicates; - - }//end findDuplicateInfoFileEntries() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php b/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php index 3d1d9223..4c9b882e 100644 --- a/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php +++ b/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php @@ -32,8 +32,7 @@ class RequiredSniff implements Sniff public function register() { return [T_INLINE_HTML]; - - }//end register() + } /** @@ -68,7 +67,7 @@ public function process(File $phpcsFile, $stackPtr) if (isset($info['core']) === false) { $error = '"core" property is missing in the info file'; $phpcsFile->addError($error, $stackPtr, 'Core'); - } else if ($info['core'] === '7.x' && isset($info['php']) === true + } elseif ($info['core'] === '7.x' && isset($info['php']) === true && $info['php'] <= '5.2' ) { $error = 'Drupal 7 core already requires PHP 5.2'; @@ -77,8 +76,5 @@ public function process(File $phpcsFile, $stackPtr) } return ($phpcsFile->numTokens + 1); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php index 0ff3a569..a76b307c 100644 --- a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php @@ -39,8 +39,7 @@ public function register() T_INTERFACE, T_TRAIT, ]; - - }//end register() + } /** @@ -80,8 +79,5 @@ public function process(File $phpcsFile, $stackPtr) $error = '%s name must use UpperCamel naming and not contain multiple upper case letters in a row'; $phpcsFile->addError($error, $stackPtr, 'NoUpperAcronyms', $errorData); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidEnumCaseSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidEnumCaseSniff.php index 7eca94a7..9b4a7783 100644 --- a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidEnumCaseSniff.php +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidEnumCaseSniff.php @@ -28,8 +28,5 @@ class ValidEnumCaseSniff extends ValidClassNameSniff public function register() { return [T_ENUM_CASE]; - - }//end register() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidFunctionNameSniff.php index bc0a0da2..2778da8c 100644 --- a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -58,7 +58,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop } $className = $phpcsFile->getDeclarationName($currScope); - $errorData = [$className.'::'.$methodName]; + $errorData = [$className . '::' . $methodName]; // Is this a magic method. i.e., is prefixed with "__" ? if (preg_match('|^__|', $methodName) !== 0) { @@ -92,8 +92,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop } else { $phpcsFile->recordMetric($stackPtr, 'CamelCase method name', 'yes'); } - - }//end processTokenWithinScope() + } /** @@ -146,13 +145,10 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) $error = 'All functions defined in a module file must be prefixed with the module\'s name, found "%s" but expected "%s"'; $data = [ $functionName, - $moduleName.'_'.$functionName, + $moduleName . '_' . $functionName, ]; $phpcsFile->addError($error, $stackPtr, 'InvalidPrefix', $data); } } - - }//end processTokenOutsideScope() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidGlobalSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidGlobalSniff.php index c8930d77..4b2fefc6 100644 --- a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidGlobalSniff.php +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidGlobalSniff.php @@ -88,8 +88,7 @@ class ValidGlobalSniff implements Sniff public function register() { return [T_GLOBAL]; - - }//end register() + } /** @@ -118,8 +117,5 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->addError($error, $varToken, 'GlobalUnderScore'); } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php index 6034ddba..aa15722f 100644 --- a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -89,8 +89,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) $error = 'Class property %s should use lowerCamel naming without underscores'; $data = [$tokens[$stackPtr]['content']]; $phpcsFile->addError($error, $stackPtr, 'LowerCamelName', $data); - - }//end processMemberVar() + } /** @@ -133,8 +132,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) $error = "Variable \"$varName\" starts with a capital letter, but only \$lowerCamelCase or \$snake_case is allowed"; $phpcsFile->addError($error, $stackPtr, 'LowerStart'); } - - }//end processVariable() + } /** @@ -148,9 +146,5 @@ protected function processVariable(File $phpcsFile, $stackPtr) protected function processVariableInString(File $phpcsFile, $stackPtr) { // We don't care about variables in strings. - return; - - }//end processVariableInString() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php b/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php index 6e321aee..9f0154e4 100644 --- a/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php @@ -35,8 +35,7 @@ class MethodScopeSniff extends AbstractScopeSniff public function __construct() { parent::__construct([T_CLASS, T_INTERFACE, T_TRAIT, T_ENUM], [T_FUNCTION]); - - }//end __construct() + } /** @@ -67,7 +66,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop for ($i = ($stackPtr - 1); $i > 0; $i--) { if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) { break; - } else if (isset(Tokens::SCOPE_MODIFIERS[$tokens[$i]['code']]) === true) { + } elseif (isset(Tokens::SCOPE_MODIFIERS[$tokens[$i]['code']]) === true) { $modifier = $i; break; } @@ -84,8 +83,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop $phpcsFile->fixer->addContentBefore($stackPtr, 'public '); } } - - }//end processTokenWithinScope() + } /** @@ -100,8 +98,5 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop */ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) { - - }//end processTokenOutsideScope() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/ConstantNameSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/ConstantNameSniff.php index 682f2813..aa4175ca 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/ConstantNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/ConstantNameSniff.php @@ -39,8 +39,7 @@ public function register() T_STRING, T_CONST, ]; - - }//end register() + } /** @@ -82,7 +81,7 @@ public function process(File $phpcsFile, $stackPtr) if (strpos($constName, $expectedStart) !== 0) { $warning = 'All constants defined by a module must be prefixed with the module\'s name, expected "%s" but found "%s"'; $data = [ - $expectedStart."_$constName", + $expectedStart . "_$constName", $constName, ]; $phpcsFile->addWarning($warning, $stackPtr, 'ConstConstantStart', $data); @@ -123,13 +122,10 @@ public function process(File $phpcsFile, $stackPtr) if (strpos($constName, $expectedStart) !== 0) { $warning = 'All constants defined by a module must be prefixed with the module\'s name, expected "%s" but found "%s"'; $data = [ - $expectedStart."_$constName", + $expectedStart . "_$constName", $constName, ]; $phpcsFile->addWarning($warning, $stackPtr, 'ConstantStart', $data); }//end if - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php index 8bbc7fcd..8f0be55e 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php @@ -44,8 +44,8 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $fileName = substr(basename($phpcsFile->getFilename()), 0, -8); $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr]['content'] === ($fileName.'_install') - || $tokens[$stackPtr]['content'] === ($fileName.'_uninstall') + if ($tokens[$stackPtr]['content'] === ($fileName . '_install') + || $tokens[$stackPtr]['content'] === ($fileName . '_uninstall') ) { // Check if there is a function body. $bodyPtr = $phpcsFile->findNext( @@ -59,8 +59,5 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $phpcsFile->addError($error, $stackPtr, 'EmptyInstall'); } } - - }//end processFunction() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionAliasSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionAliasSniff.php index 71d0916d..53e6daf0 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionAliasSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionAliasSniff.php @@ -173,8 +173,7 @@ class FunctionAliasSniff extends FunctionCall public function registerFunctionNames() { return array_keys($this->aliases); - - }//end registerFunctionNames() + } /** @@ -204,8 +203,5 @@ public function processFunctionCall( $this->aliases[$name], ]; $phpcsFile->addError($error, $stackPtr, 'FunctionAlias', $data); - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php index 60e38d15..ea342bcb 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php @@ -75,8 +75,7 @@ abstract class FunctionCall implements Sniff public function register() { return [T_STRING]; - - }//end register() + } /** @@ -111,8 +110,7 @@ public function process(File $phpcsFile, $stackPtr) $this->arguments = []; $this->processFunctionCall($phpcsFile, $stackPtr, $openBracket, $this->closeBracket); - - }//end process() + } /** @@ -160,8 +158,7 @@ protected function isFunctionCall(File $phpcsFile, $stackPtr) } return true; - - }//end isFunctionCall() + } /** @@ -227,8 +224,5 @@ public function getArgument($number) 'end' => $end, ]; return $this->arguments[$counter]; - - }//end getArgument() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php index 389dfdc6..ad686096 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php @@ -32,8 +32,7 @@ abstract class FunctionDefinition implements Sniff public function register() { return [T_STRING]; - - }//end register() + } /** @@ -58,8 +57,7 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$functionPtr]['code'] === T_FUNCTION) { $this->processFunction($phpcsFile, $stackPtr, $functionPtr); } - - }//end process() + } /** @@ -74,6 +72,4 @@ public function process(File $phpcsFile, $stackPtr) * @return void */ abstract public function processFunction(File $phpcsFile, $stackPtr, $functionPtr); - - -}//end class +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php index c9de1162..bc0a3911 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php @@ -43,8 +43,7 @@ public function registerFunctionNames() 'TranslatableMarkup', 'TranslationWrapper', ]; - - }//end registerFunctionNames() + } /** @@ -132,8 +131,7 @@ public function processFunctionCall( $warn = "Avoid backslash escaping in translatable strings when possible, use '' quotes instead"; $phpcsFile->addWarning($warn, $argument['start'], 'BackslashDoubleQuote'); } - - }//end processFunctionCall() + } /** @@ -174,8 +172,5 @@ protected function checkConcatString($string) } return false; - - }//end checkConcatString() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTriggerErrorSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTriggerErrorSniff.php index 9c1f98ab..d2e01501 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTriggerErrorSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTriggerErrorSniff.php @@ -30,8 +30,7 @@ class FunctionTriggerErrorSniff extends FunctionCall public function registerFunctionNames() { return ['trigger_error']; - - }//end registerFunctionNames() + } /** @@ -48,7 +47,7 @@ public function registerFunctionNames() * @return void */ public function processFunctionCall( - file $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket @@ -177,13 +176,10 @@ public function processFunctionCall( if (isset($crMatches[4]) === true && empty($crMatches[4]) === false) { $error = "The url '%s' should not end with a period."; $phpcsFile->addWarning($error, $argument['start'], 'TriggerErrorPeriodAfterSeeUrl', [$crLink]); - } else if (empty($crMatches) === true) { + } elseif (empty($crMatches) === true) { $error = "The url '%s' does not match the standard: http(s)://www.drupal.org/node/n or http(s)://www.drupal.org/project/aaa/issues/n"; $phpcsFile->addWarning($error, $argument['start'], 'TriggerErrorSeeUrlFormat', [$crLink]); } }//end if - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php index 322ae1a6..dee5e8c0 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php @@ -30,8 +30,7 @@ class FunctionWatchdogSniff extends FunctionCall public function registerFunctionNames() { return ['watchdog']; - - }//end registerFunctionNames() + } /** @@ -74,8 +73,5 @@ public function processFunctionCall( $error = 'Concatenating translatable strings is not allowed, use placeholders instead and only one string literal'; $phpcsFile->addError($error, $concatFound, 'Concat'); } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php index 2145f98c..6d3d760b 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php @@ -45,19 +45,16 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $tokens = $phpcsFile->getTokens(); $fileName = substr(basename($phpcsFile->getFilename()), 0, -7); - if ($tokens[$stackPtr]['content'] === ($fileName.'_install') - || $tokens[$stackPtr]['content'] === ($fileName.'_uninstall') - || $tokens[$stackPtr]['content'] === ($fileName.'_requirements') - || $tokens[$stackPtr]['content'] === ($fileName.'_schema') - || $tokens[$stackPtr]['content'] === ($fileName.'_enable') - || $tokens[$stackPtr]['content'] === ($fileName.'_disable') + if ($tokens[$stackPtr]['content'] === ($fileName . '_install') + || $tokens[$stackPtr]['content'] === ($fileName . '_uninstall') + || $tokens[$stackPtr]['content'] === ($fileName . '_requirements') + || $tokens[$stackPtr]['content'] === ($fileName . '_schema') + || $tokens[$stackPtr]['content'] === ($fileName . '_enable') + || $tokens[$stackPtr]['content'] === ($fileName . '_disable') ) { $error = '%s() is an installation hook and must be declared in an install file'; $data = [$tokens[$stackPtr]['content']]; $phpcsFile->addError($error, $stackPtr, 'InstallHook', $data); } - - }//end processFunction() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php index d664a47d..c01aa396 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php @@ -30,8 +30,7 @@ class LStringTranslatableSniff extends FunctionCall public function registerFunctionNames() { return ['l']; - - }//end registerFunctionNames() + } /** @@ -63,8 +62,5 @@ public function processFunctionCall( $error = 'The $text argument to l() should be enclosed within t() so that it is translatable'; $phpcsFile->addError($error, $stackPtr, 'LArg'); } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php index cfc822a7..f844c862 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php @@ -39,8 +39,7 @@ public function registerFunctionNames() 'preg_replace_callback', 'preg_split', ]; - - }//end registerFunctionNames() + } /** @@ -82,7 +81,7 @@ public function processFunctionCall( // Get the delimiter - first char after the enclosing quotes. $delimiter = preg_quote(substr($pattern, 1, 1), '/'); // Check if there is the evil e flag. - if (preg_match('/'.$delimiter.'[\w]{0,}e[\w]{0,}$/', substr($pattern, 0, -1)) === 1) { + if (preg_match('/' . $delimiter . '[\w]{0,}e[\w]{0,}$/', substr($pattern, 0, -1)) === 1) { $warn = 'Using the e flag in %s is a possible security risk. For details see https://www.drupal.org/node/750148'; $phpcsFile->addError( $warn, @@ -93,8 +92,5 @@ public function processFunctionCall( return; } } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/RemoteAddressSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/RemoteAddressSniff.php index 754269d9..e01ba5af 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/RemoteAddressSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/RemoteAddressSniff.php @@ -32,8 +32,7 @@ class RemoteAddressSniff implements Sniff public function register() { return [T_VARIABLE]; - - }//end register() + } /** @@ -53,8 +52,5 @@ public function process(File $phpcsFile, $stackPtr) $error = 'Use ip_address() or Drupal::request()->getClientIp() instead of $_SERVER[\'REMOTE_ADDR\']'; $phpcsFile->addError($error, $stackPtr, 'RemoteAddress'); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php index 3ab078fa..24e81e57 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php @@ -44,7 +44,7 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $fileName = substr(basename($phpcsFile->getFilename()), 0, -7); $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr]['content'] !== ($fileName.'_menu')) { + if ($tokens[$stackPtr]['content'] !== ($fileName . '_menu')) { return; } @@ -76,8 +76,5 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $tokens[$functionPtr]['scope_closer'] ); }//end while - - }//end processFunction() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php index 7d15ae64..2675e705 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php @@ -44,7 +44,7 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $fileName = substr(basename($phpcsFile->getFilename()), 0, -8); $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr]['content'] !== ($fileName.'_schema')) { + if ($tokens[$stackPtr]['content'] !== ($fileName . '_schema')) { return; } @@ -76,8 +76,5 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $tokens[$functionPtr]['scope_closer'] ); }//end while - - }//end processFunction() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/UnsilencedDeprecationSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/UnsilencedDeprecationSniff.php index f9b8dba0..8d596bd6 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/UnsilencedDeprecationSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/UnsilencedDeprecationSniff.php @@ -30,8 +30,7 @@ class UnsilencedDeprecationSniff extends FunctionCall public function registerFunctionNames() { return ['trigger_error']; - - }//end registerFunctionNames() + } /** @@ -48,7 +47,7 @@ public function registerFunctionNames() * @return void */ public function processFunctionCall( - file $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket @@ -74,8 +73,5 @@ public function processFunctionCall( $phpcsFile->fixer->addContentBefore($stackPtr, '@'); } } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php index 65ec33a5..4473c043 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php @@ -38,8 +38,7 @@ public function register() T_CLOSE_PARENTHESIS, T_CLOSE_SHORT_ARRAY, ]; - - }//end register() + } /** @@ -72,8 +71,5 @@ public function process(File $phpcsFile, $stackPtr) } } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php index f1644271..0049cf0c 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php @@ -33,8 +33,7 @@ class CommaSniff implements Sniff public function register() { return [T_COMMA]; - - }//end register() + } /** @@ -78,8 +77,5 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php index b2f1239b..0c1f2e40 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php @@ -33,8 +33,7 @@ class EmptyLinesSniff implements Sniff public function register() { return [T_WHITESPACE]; - - }//end register() + } /** @@ -60,8 +59,5 @@ public function process(File $phpcsFile, $stackPtr) $error = 'More than 2 empty lines are not allowed'; $phpcsFile->addError($error, ($stackPtr + 3), 'EmptyLines'); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php index e17a62ee..c4e422f2 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php @@ -35,8 +35,7 @@ class ObjectOperatorIndentSniff implements Sniff public function register() { return [T_OBJECT_OPERATOR]; - - }//end register() + } /** @@ -120,8 +119,7 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr - 1), str_repeat(' ', $expectedIndent)); } } - - }//end process() + } /** @@ -148,8 +146,5 @@ protected function findStartOfline(File $phpcsFile, $stackPtr) } return $startOfLine; - - }//end findStartOfline() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php index c14fb2a8..376cd4d4 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php @@ -36,8 +36,7 @@ class ObjectOperatorSpacingSniff implements Sniff public function register() { return [T_OBJECT_OPERATOR]; - - }//end register() + } /** @@ -101,8 +100,5 @@ public function process(File $phpcsFile, $stackPtr) } } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php index 531778ec..60838242 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php @@ -37,8 +37,7 @@ public function register() T_OPEN_PARENTHESIS, T_OPEN_SHORT_ARRAY, ]; - - }//end register() + } /** @@ -72,8 +71,5 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php index 302b52ac..9cfa27b7 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php @@ -31,8 +31,7 @@ class OpenTagNewlineSniff implements Sniff public function register() { return [T_OPEN_TAG]; - - }//end register() + } /** @@ -80,7 +79,7 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$next]['line'] === 1) { $phpcsFile->fixer->addNewline($stackPtr); $phpcsFile->fixer->addNewline($stackPtr); - } else if ($tokens[$next]['line'] === 2) { + } elseif ($tokens[$next]['line'] === 2) { $phpcsFile->fixer->addNewline($stackPtr); } else { for ($i = ($stackPtr + 1); $i < $next; $i++) { @@ -94,8 +93,5 @@ public function process(File $phpcsFile, $stackPtr) } return ($phpcsFile->numTokens + 1); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index 428b231a..b1830b09 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -42,8 +42,7 @@ class ScopeClosingBraceSniff implements Sniff public function register() { return Tokens::SCOPE_OPENERS; - - }//end register() + } /** @@ -93,7 +92,7 @@ public function process(File $phpcsFile, $stackPtr) $startColumn = 1; if ($tokens[$lineStart]['code'] === T_WHITESPACE) { $startColumn = $tokens[($lineStart + 1)]['column']; - } else if ($tokens[$lineStart]['code'] === T_INLINE_HTML) { + } elseif ($tokens[$lineStart]['code'] === T_INLINE_HTML) { $trimmed = ltrim($tokens[$lineStart]['content']); if ($trimmed === '') { $startColumn = $tokens[($lineStart + 1)]['column']; @@ -145,7 +144,7 @@ public function process(File $phpcsFile, $stackPtr) $braceIndent = 0; if ($tokens[$lineStart]['code'] === T_WHITESPACE) { $braceIndent = ($tokens[($lineStart + 1)]['column'] - 1); - } else if ($tokens[$lineStart]['code'] === T_INLINE_HTML) { + } elseif ($tokens[$lineStart]['code'] === T_INLINE_HTML) { $trimmed = ltrim($tokens[$lineStart]['content']); if ($trimmed === '') { $braceIndent = ($tokens[($lineStart + 1)]['column'] - 1); @@ -190,8 +189,5 @@ public function process(File $phpcsFile, $stackPtr) $phpcsFile->fixer->addContentBefore($lineStart, $spaces); } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php index 65de7165..cee207c7 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -115,8 +115,7 @@ public function register() } return [T_OPEN_TAG]; - - }//end register() + } /** @@ -166,7 +165,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$stackPtr]['line']; - echo "Start with token $stackPtr on line $line with indent $currentIndent".PHP_EOL; + echo "Start with token $stackPtr on line $line with indent $currentIndent" . PHP_EOL; } if (empty($this->ignoreIndentation) === true) { @@ -199,7 +198,7 @@ public function process(File $phpcsFile, $stackPtr) $value = $tokens[$i]['sniffPropertyValue']; if ($value === 'true') { $value = true; - } else if ($value === 'false') { + } elseif ($value === 'false') { $value = false; } else { $value = (bool) $value; @@ -215,7 +214,7 @@ public function process(File $phpcsFile, $stackPtr) $value = 'false'; } - echo "* token $i on line $line set exact flag to $value *".PHP_EOL; + echo "* token $i on line $line set exact flag to $value *" . PHP_EOL; } }//end if @@ -238,8 +237,8 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$i]['line']; $type = $tokens[$disableExactEnd]['type']; - echo "Opening parenthesis found on line $line".PHP_EOL; - echo "\t=> disabling exact indent checking until $disableExactEnd ($type)".PHP_EOL; + echo "Opening parenthesis found on line $line" . PHP_EOL; + echo "\t=> disabling exact indent checking until $disableExactEnd ($type)" . PHP_EOL; } } @@ -279,7 +278,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$i]['line']; - echo "Closing parenthesis found on line $line".PHP_EOL; + echo "Closing parenthesis found on line $line" . PHP_EOL; } $parenOpener = $tokens[$parenCloser]['parenthesis_opener']; @@ -293,7 +292,7 @@ public function process(File $phpcsFile, $stackPtr) $parens = key($parens); if ($this->debug === true) { $line = $tokens[$parens]['line']; - echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL; + echo "\t* token has nested parenthesis $parens on line $line *" . PHP_EOL; } } @@ -309,20 +308,20 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$condition]['line']; $type = $tokens[$condition]['type']; - echo "\t* token is inside condition $condition ($type) on line $line *".PHP_EOL; + echo "\t* token is inside condition $condition ($type) on line $line *" . PHP_EOL; } } if ($parens > $condition) { if ($this->debug === true) { - echo "\t* using parenthesis *".PHP_EOL; + echo "\t* using parenthesis *" . PHP_EOL; } $parenOpener = $parens; $condition = 0; - } else if ($condition > 0) { + } elseif ($condition > 0) { if ($this->debug === true) { - echo "\t* using condition *".PHP_EOL; + echo "\t* using condition *" . PHP_EOL; } $parenOpener = $condition; @@ -336,14 +335,14 @@ public function process(File $phpcsFile, $stackPtr) if ($condition > 0 && $lastOpenTagCondition === $condition) { if ($this->debug === true) { - echo "\t* open tag is inside condition; using open tag *".PHP_EOL; + echo "\t* open tag is inside condition; using open tag *" . PHP_EOL; } $first = $phpcsFile->findFirstOnLine([T_WHITESPACE, T_INLINE_HTML], $lastOpenTag, true); if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* first token on line $line is $first ($type) *".PHP_EOL; + echo "\t* first token on line $line is $first ($type) *" . PHP_EOL; } $checkIndent = ($tokens[$first]['column'] - 1); @@ -355,9 +354,9 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = $tokens[$lastOpenTag]['type']; - echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $lastOpenTag ($type)".PHP_EOL; + echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $lastOpenTag ($type)" . PHP_EOL; } - } else if ($condition > 0 + } elseif ($condition > 0 && isset($tokens[$condition]['scope_opener']) === true && isset($setIndents[$tokens[$condition]['scope_opener']]) === true ) { @@ -370,7 +369,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = $tokens[$condition]['type']; - echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $condition ($type)".PHP_EOL; + echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $condition ($type)" . PHP_EOL; } } else { $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $parenOpener, true); @@ -383,7 +382,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* first token on line $line is $first ($type) *".PHP_EOL; + echo "\t* first token on line $line is $first ($type) *" . PHP_EOL; } if ($first === $tokens[$parenCloser]['parenthesis_opener'] @@ -395,8 +394,8 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* first token is the parenthesis opener *".PHP_EOL; - echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL; + echo "\t* first token is the parenthesis opener *" . PHP_EOL; + echo "\t* amended first token is $first ($type) on line $line *" . PHP_EOL; } } @@ -406,7 +405,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$prev]['line']; $type = $tokens[$prev]['type']; - echo "\t* previous is $type on line $line *".PHP_EOL; + echo "\t* previous is $type on line $line *" . PHP_EOL; } $first = $phpcsFile->findFirstOnLine([T_WHITESPACE, T_INLINE_HTML], $prev, true); @@ -420,7 +419,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL; + echo "\t* amended first token is $first ($type) on line $line *" . PHP_EOL; } }//end if @@ -428,7 +427,7 @@ public function process(File $phpcsFile, $stackPtr) && $tokens[$first]['scope_closer'] === $first ) { if ($this->debug === true) { - echo "\t* first token is a scope closer *".PHP_EOL; + echo "\t* first token is a scope closer *" . PHP_EOL; } if (isset($tokens[$first]['scope_condition']) === true) { @@ -449,7 +448,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = $tokens[$first]['type']; - echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL; + echo "\t=> indent set to $currentIndent by token $first ($type)" . PHP_EOL; } }//end if } else { @@ -464,12 +463,12 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = $tokens[$first]['type']; - echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL; + echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)" . PHP_EOL; } }//end if }//end if - } else if ($this->debug === true) { - echo "\t * ignoring single-line definition *".PHP_EOL; + } elseif ($this->debug === true) { + echo "\t * ignoring single-line definition *" . PHP_EOL; }//end if }//end if @@ -487,7 +486,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$arrayCloser]['line']; - echo "Closing short array bracket found on line $line".PHP_EOL; + echo "Closing short array bracket found on line $line" . PHP_EOL; } $arrayOpener = $tokens[$arrayCloser]['bracket_opener']; @@ -498,7 +497,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* first token on line $line is $first ($type) *".PHP_EOL; + echo "\t* first token on line $line is $first ($type) *" . PHP_EOL; } if ($first === $tokens[$arrayCloser]['bracket_opener']) { @@ -513,7 +512,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$prev]['line']; $type = $tokens[$prev]['type']; - echo "\t* previous is $type on line $line *".PHP_EOL; + echo "\t* previous is $type on line $line *" . PHP_EOL; } $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true); @@ -522,9 +521,9 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL; + echo "\t* amended first token is $first ($type) on line $line *" . PHP_EOL; } - } else if ($tokens[$first]['code'] === T_WHITESPACE) { + } elseif ($tokens[$first]['code'] === T_WHITESPACE) { $first = $phpcsFile->findNext(T_WHITESPACE, ($first + 1), null, true); } @@ -540,13 +539,13 @@ public function process(File $phpcsFile, $stackPtr) // been processed and set the indent level correctly, so // don't adjust it again. if ($this->debug === true) { - echo "\t* first token is a scope closer; ignoring closing short array bracket *".PHP_EOL; + echo "\t* first token is a scope closer; ignoring closing short array bracket *" . PHP_EOL; } if (isset($setIndents[$first]) === true) { $currentIndent = $setIndents[$first]; if ($this->debug === true) { - echo "\t=> indent reset to $currentIndent".PHP_EOL; + echo "\t=> indent reset to $currentIndent" . PHP_EOL; } } } else { @@ -561,11 +560,11 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = $tokens[$first]['type']; - echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL; + echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)" . PHP_EOL; } }//end if - } else if ($this->debug === true) { - echo "\t * ignoring single-line definition *".PHP_EOL; + } elseif ($this->debug === true) { + echo "\t * ignoring single-line definition *" . PHP_EOL; }//end if }//end if @@ -603,7 +602,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$checkToken]['line']; $type = $tokens[$checkToken]['type']; - echo "Indent adjusted to $length for $type on line $line".PHP_EOL; + echo "Indent adjusted to $length for $type on line $line" . PHP_EOL; } $adjustments[$checkToken] = $adjustments[$first]; @@ -611,7 +610,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$checkToken]['line']; $type = $tokens[$checkToken]['type']; - echo "\t=> add adjustment of ".$adjustments[$checkToken]." for token $checkToken ($type) on line $line".PHP_EOL; + echo "\t=> add adjustment of " . $adjustments[$checkToken] . " for token $checkToken ($type) on line $line" . PHP_EOL; } }//end if }//end if @@ -635,7 +634,7 @@ public function process(File $phpcsFile, $stackPtr) $line = $tokens[$checkToken]['line']; } - echo "Close scope ($type) on line $line".PHP_EOL; + echo "Close scope ($type) on line $line" . PHP_EOL; } $scopeCloser = $checkToken; @@ -647,7 +646,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$conditionToken]['line']; $type = $tokens[$conditionToken]['type']; - echo "\t=> removed open scope $conditionToken ($type) on line $line".PHP_EOL; + echo "\t=> removed open scope $conditionToken ($type) on line $line" . PHP_EOL; } if (isset($tokens[$scopeCloser]['scope_condition']) === true) { @@ -655,7 +654,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* first token is $first ($type) on line $line *".PHP_EOL; + echo "\t* first token is $first ($type) on line $line *" . PHP_EOL; } while ($tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING @@ -665,7 +664,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* found multi-line string; amended first token is $first ($type) on line $line *".PHP_EOL; + echo "\t* found multi-line string; amended first token is $first ($type) on line $line *" . PHP_EOL; } } @@ -678,7 +677,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = $tokens[$scopeCloser]['type']; - echo "\t=> indent set to $currentIndent by token $scopeCloser ($type)".PHP_EOL; + echo "\t=> indent set to $currentIndent by token $scopeCloser ($type)" . PHP_EOL; } // We only check the indent of scope closers if they are @@ -731,8 +730,8 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$i]['line']; $type = $tokens[$lastOpener]['type']; - echo "Shared closer found on line $line".PHP_EOL; - echo "\t=> indent set to $currentIndent by token $lastOpener ($type)".PHP_EOL; + echo "Shared closer found on line $line" . PHP_EOL; + echo "\t=> indent set to $currentIndent by token $lastOpener ($type)" . PHP_EOL; } } @@ -746,8 +745,8 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$i]['line']; - echo "Closure found on line $line".PHP_EOL; - echo "\t=> checking indent of $checkIndent; main indent remains at $currentIndent".PHP_EOL; + echo "Closure found on line $line" . PHP_EOL; + echo "\t=> checking indent of $checkIndent; main indent remains at $currentIndent" . PHP_EOL; } } }//end if @@ -780,7 +779,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$checkToken]['line']; $type = $tokens[$checkToken]['type']; - echo "\t* method prefix ($type) found on line $line; indent set to exact *".PHP_EOL; + echo "\t* method prefix ($type) found on line $line; indent set to exact *" . PHP_EOL; } $exact = true; @@ -950,7 +949,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$checkToken]['line']; $message = vsprintf($error, $data); - echo "[Line $line] $message".PHP_EOL; + echo "[Line $line] $message" . PHP_EOL; } // Assume the change would be applied and continue @@ -965,7 +964,7 @@ public function process(File $phpcsFile, $stackPtr) if ($accepted === true && $this->debug === true) { $line = $tokens[$checkToken]['line']; $type = $tokens[$checkToken]['type']; - echo "\t=> add adjustment of ".$adjustments[$checkToken]." for token $checkToken ($type) on line $line".PHP_EOL; + echo "\t=> add adjustment of " . $adjustments[$checkToken] . " for token $checkToken ($type) on line $line" . PHP_EOL; } } }//end if @@ -982,11 +981,11 @@ public function process(File $phpcsFile, $stackPtr) $line = $tokens[$i]['line']; $type = $tokens[$disableExactEnd]['type']; $endLine = $tokens[$disableExactEnd]['line']; - echo "Opening short array bracket found on line $line".PHP_EOL; + echo "Opening short array bracket found on line $line" . PHP_EOL; if ($disableExactEnd === $tokens[$i]['bracket_closer']) { - echo "\t=> disabling exact indent checking until $disableExactEnd ($type) on line $endLine".PHP_EOL; + echo "\t=> disabling exact indent checking until $disableExactEnd ($type) on line $endLine" . PHP_EOL; } else { - echo "\t=> continuing to disable exact indent checking until $disableExactEnd ($type) on line $endLine".PHP_EOL; + echo "\t=> continuing to disable exact indent checking until $disableExactEnd ($type) on line $endLine" . PHP_EOL; } } } @@ -998,7 +997,7 @@ public function process(File $phpcsFile, $stackPtr) ) { if ($this->debug === true) { $line = $tokens[$i]['line']; - echo "Here/nowdoc found on line $line".PHP_EOL; + echo "Here/nowdoc found on line $line" . PHP_EOL; } $i = $phpcsFile->findNext([T_END_HEREDOC, T_END_NOWDOC], ($i + 1)); @@ -1010,7 +1009,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$i]['line']; $type = $tokens[$i]['type']; - echo "\t* skipping to token $i ($type) on line $line *".PHP_EOL; + echo "\t* skipping to token $i ($type) on line $line *" . PHP_EOL; } continue; @@ -1042,7 +1041,7 @@ public function process(File $phpcsFile, $stackPtr) ) { if ($this->debug === true) { $line = $tokens[$i]['line']; - echo "Open PHP tag found on line $line".PHP_EOL; + echo "Open PHP tag found on line $line" . PHP_EOL; } if ($checkToken === null) { @@ -1064,7 +1063,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = $tokens[$i]['type']; - echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL; + echo "\t=> indent set to $currentIndent by token $i ($type)" . PHP_EOL; } continue; @@ -1075,7 +1074,7 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$i]['code'] === T_CLOSE_TAG) { if ($this->debug === true) { $line = $tokens[$i]['line']; - echo "Close PHP tag found on line $line".PHP_EOL; + echo "Close PHP tag found on line $line" . PHP_EOL; } if ($tokens[$lastOpenTag]['line'] !== $tokens[$i]['line']) { @@ -1099,7 +1098,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = $tokens[$i]['type']; - echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL; + echo "\t=> indent set to $currentIndent by token $i ($type)" . PHP_EOL; } continue; @@ -1112,7 +1111,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = str_replace('_', ' ', strtolower(substr($tokens[$i]['type'], 2))); $line = $tokens[$i]['line']; - echo "* ignoring single-line $type on line $line *".PHP_EOL; + echo "* ignoring single-line $type on line $line *" . PHP_EOL; } $i = $closer; @@ -1122,14 +1121,14 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = str_replace('_', ' ', strtolower(substr($tokens[$i]['type'], 2))); $line = $tokens[$i]['line']; - echo "Open $type on line $line".PHP_EOL; + echo "Open $type on line $line" . PHP_EOL; } $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $i, true); if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* first token is $first ($type) on line $line *".PHP_EOL; + echo "\t* first token is $first ($type) on line $line *" . PHP_EOL; } while ($tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING @@ -1139,7 +1138,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* found multi-line string; amended first token is $first ($type) on line $line *".PHP_EOL; + echo "\t* found multi-line string; amended first token is $first ($type) on line $line *" . PHP_EOL; } } @@ -1152,7 +1151,7 @@ public function process(File $phpcsFile, $stackPtr) $conditionToken = $tokens[$i]['scope_condition']; $conditionLine = $tokens[$conditionToken]['line']; $conditionType = $tokens[$conditionToken]['type']; - echo "\t=> added open scope $closerToken ($closerType) on line $closerLine, pointing to condition $conditionToken ($conditionType) on line $conditionLine".PHP_EOL; + echo "\t=> added open scope $closerToken ($closerType) on line $closerLine, pointing to condition $conditionToken ($conditionType) on line $conditionLine" . PHP_EOL; } if (isset($adjustments[$first]) === true) { @@ -1166,7 +1165,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = $tokens[$i]['type']; - echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL; + echo "\t=> indent set to $currentIndent by token $i ($type)" . PHP_EOL; } continue; @@ -1182,7 +1181,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$i]['line']; $type = $tokens[$i]['type']; - echo "* ignoring single-line $type on line $line *".PHP_EOL; + echo "* ignoring single-line $type on line $line *" . PHP_EOL; } $i = $closer; @@ -1193,7 +1192,7 @@ public function process(File $phpcsFile, $stackPtr) if ($condition === T_FN) { if ($this->debug === true) { $line = $tokens[$tokens[$i]['scope_condition']]['line']; - echo "* ignoring arrow function on line $line *".PHP_EOL; + echo "* ignoring arrow function on line $line *" . PHP_EOL; } $i = $closer; @@ -1206,7 +1205,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$i]['line']; $type = $tokens[$tokens[$i]['scope_condition']]['type']; - echo "Open scope ($type) on line $line".PHP_EOL; + echo "Open scope ($type) on line $line" . PHP_EOL; } $currentIndent += $this->indent; @@ -1219,12 +1218,12 @@ public function process(File $phpcsFile, $stackPtr) $conditionToken = $tokens[$i]['scope_condition']; $conditionLine = $tokens[$conditionToken]['line']; $conditionType = $tokens[$conditionToken]['type']; - echo "\t=> added open scope $closerToken ($closerType) on line $closerLine, pointing to condition $conditionToken ($conditionType) on line $conditionLine".PHP_EOL; + echo "\t=> added open scope $closerToken ($closerType) on line $closerLine, pointing to condition $conditionToken ($conditionType) on line $conditionLine" . PHP_EOL; } if ($this->debug === true) { $type = $tokens[$i]['type']; - echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL; + echo "\t=> indent set to $currentIndent by token $i ($type)" . PHP_EOL; } continue; @@ -1243,7 +1242,7 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = str_replace('_', ' ', strtolower(substr($tokens[$tokens[$i]['scope_condition']]['type'], 2))); $line = $tokens[$i]['line']; - echo "Close $type on line $line".PHP_EOL; + echo "Close $type on line $line" . PHP_EOL; } $prev = false; @@ -1257,7 +1256,7 @@ public function process(File $phpcsFile, $stackPtr) $parens = key($parens); if ($this->debug === true) { $line = $tokens[$parens]['line']; - echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL; + echo "\t* token has nested parenthesis $parens on line $line *" . PHP_EOL; } } @@ -1271,20 +1270,20 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$condition]['line']; $type = $tokens[$condition]['type']; - echo "\t* token is inside condition $condition ($type) on line $line *".PHP_EOL; + echo "\t* token is inside condition $condition ($type) on line $line *" . PHP_EOL; } } if ($parens > $condition) { if ($this->debug === true) { - echo "\t* using parenthesis *".PHP_EOL; + echo "\t* using parenthesis *" . PHP_EOL; } $prev = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($parens - 1), null, true); $condition = 0; - } else if ($condition > 0) { + } elseif ($condition > 0) { if ($this->debug === true) { - echo "\t* using condition *".PHP_EOL; + echo "\t* using condition *" . PHP_EOL; } $prev = $condition; @@ -1296,7 +1295,7 @@ public function process(File $phpcsFile, $stackPtr) if ($prev === false) { $prev = $i; if ($this->debug === true) { - echo "\t* could not find a previous T_EQUAL or T_RETURN token; will use current token *".PHP_EOL; + echo "\t* could not find a previous T_EQUAL or T_RETURN token; will use current token *" . PHP_EOL; } } } @@ -1304,14 +1303,14 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$prev]['line']; $type = $tokens[$prev]['type']; - echo "\t* previous token is $type on line $line *".PHP_EOL; + echo "\t* previous token is $type on line $line *" . PHP_EOL; } $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true); if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* first token on line $line is $first ($type) *".PHP_EOL; + echo "\t* first token on line $line is $first ($type) *" . PHP_EOL; } $prev = $phpcsFile->findStartOfStatement($first); @@ -1320,14 +1319,14 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $line = $tokens[$prev]['line']; $type = $tokens[$prev]['type']; - echo "\t* amended previous is $type on line $line *".PHP_EOL; + echo "\t* amended previous is $type on line $line *" . PHP_EOL; } $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true); if ($this->debug === true) { $line = $tokens[$first]['line']; $type = $tokens[$first]['type']; - echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL; + echo "\t* amended first token is $first ($type) on line $line *" . PHP_EOL; } } @@ -1340,13 +1339,13 @@ public function process(File $phpcsFile, $stackPtr) && $tokens[$first]['scope_closer'] === $first ) { if ($this->debug === true) { - echo "\t* first token is a scope closer *".PHP_EOL; + echo "\t* first token is a scope closer *" . PHP_EOL; } if ($condition === 0 || $tokens[$condition]['scope_opener'] < $first) { $currentIndent = $setIndents[$first]; - } else if ($this->debug === true) { - echo "\t* ignoring scope closer *".PHP_EOL; + } elseif ($this->debug === true) { + echo "\t* ignoring scope closer *" . PHP_EOL; } } @@ -1356,15 +1355,14 @@ public function process(File $phpcsFile, $stackPtr) if ($this->debug === true) { $type = $tokens[$first]['type']; - echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL; + echo "\t=> indent set to $currentIndent by token $first ($type)" . PHP_EOL; } }//end if }//end for // Don't process the rest of the file. return $phpcsFile->numTokens; - - }//end process() + } /** @@ -1394,7 +1392,7 @@ protected function adjustIndent(File $phpcsFile, $stackPtr, $length, $change) $numTabs = (int) floor($length / $this->tabWidth); if ($numTabs > 0) { $numSpaces = ($length - ($numTabs * $this->tabWidth)); - $padding = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces); + $padding = str_repeat("\t", $numTabs) . str_repeat(' ', $numSpaces); } } else { $padding = str_repeat(' ', $length); @@ -1403,7 +1401,7 @@ protected function adjustIndent(File $phpcsFile, $stackPtr, $length, $change) if ($tokens[$stackPtr]['column'] === 1) { $trimmed = ltrim($tokens[$stackPtr]['content']); - $accepted = $phpcsFile->fixer->replaceToken($stackPtr, $padding.$trimmed); + $accepted = $phpcsFile->fixer->replaceToken($stackPtr, $padding . $trimmed); } else { // Easier to just replace the entire indent. $accepted = $phpcsFile->fixer->replaceToken(($stackPtr - 1), $padding); @@ -1431,7 +1429,7 @@ protected function adjustIndent(File $phpcsFile, $stackPtr, $length, $change) if ($this->tabIndent === true) { $numTabs = (int) floor($padding / $this->tabWidth); $numSpaces = ($padding - ($numTabs * $this->tabWidth)); - $padding = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces); + $padding = str_repeat("\t", $numTabs) . str_repeat(' ', $numSpaces); } else { $padding = str_repeat(' ', $padding); } @@ -1444,14 +1442,11 @@ protected function adjustIndent(File $phpcsFile, $stackPtr, $length, $change) $length = strlen($padding); $line = $tokens[$x]['line']; $type = $tokens[$x]['type']; - echo "\t=> Indent adjusted to $length for $type on line $line".PHP_EOL; + echo "\t=> Indent adjusted to $length for $type on line $line" . PHP_EOL; } }//end for }//end if return true; - - }//end adjustIndent() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Project.php b/coder_sniffer/DrupalPractice/Project.php index 464e6166..e9b22019 100644 --- a/coder_sniffer/DrupalPractice/Project.php +++ b/coder_sniffer/DrupalPractice/Project.php @@ -63,8 +63,7 @@ public static function getName(File $phpcsFile) $cache[$phpcsFile->getFilename()] = $filename; return $filename; - - }//end getName() + } /** @@ -108,12 +107,11 @@ public static function getInfoFile(File $phpcsFile) } // Sort the info file names and take the shortest info file. - usort($infoFiles, [__NAMESPACE__.'\Project', 'compareLength']); + usort($infoFiles, [__NAMESPACE__ . '\Project', 'compareLength']); $infoFile = $infoFiles[0]; $cache[$phpcsFile->getFilename()] = $infoFile; return $infoFile; - - }//end getInfoFile() + } /** @@ -151,12 +149,11 @@ public static function getServicesYmlFile(File $phpcsFile) } // Sort the YML file names and take the shortest info file. - usort($ymlFiles, [__NAMESPACE__.'\Project', 'compareLength']); + usort($ymlFiles, [__NAMESPACE__ . '\Project', 'compareLength']); $ymlFile = $ymlFiles[0]; $cache[$phpcsFile->getFilename()] = $ymlFile; return $ymlFile; - - }//end getServicesYmlFile() + } /** @@ -198,7 +195,7 @@ public static function isServiceClass(File $phpcsFile, $classPtr) $nameQualifiedPtr = $phpcsFile->findNext(T_NAME_QUALIFIED, ($namespacePtr + 1)); $namespace = ($phpcsFile->getTokens()[$nameQualifiedPtr]['content'] ?? ''); - $classNameSpaced = ltrim($namespace.'\\'.$phpcsFile->getDeclarationName($classPtr), '\\'); + $classNameSpaced = ltrim($namespace . '\\' . $phpcsFile->getDeclarationName($classPtr), '\\'); foreach ($services['services'] as $service) { if (isset($service['class']) === true @@ -210,8 +207,7 @@ public static function isServiceClass(File $phpcsFile, $classPtr) } return false; - - }//end isServiceClass() + } /** @@ -225,8 +221,7 @@ public static function isServiceClass(File $phpcsFile, $classPtr) public static function compareLength($a, $b) { return (strlen($a) - strlen($b)); - - }//end compareLength() + } /** @@ -267,11 +262,6 @@ public static function getCoreVersion(File $phpcsFile) } // Drupal 8 uses the .yml file extension. - // @todo Revisit for Drupal 9, but I don't want to do YAML parsing - // for now. return 8; - - }//end getCoreVersion() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php index 6a26f151..6c828590 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php @@ -31,8 +31,7 @@ class AuthorTagSniff implements Sniff public function register() { return [T_DOC_COMMENT_TAG]; - - }//end register() + } /** @@ -53,8 +52,5 @@ public function process(File $phpcsFile, $stackPtr) $warning = '@author tags are not usually used in Drupal, because over time multiple contributors will touch the code anyway'; $phpcsFile->addWarning($warning, $stackPtr, 'AuthorFound'); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Commenting/CommentEmptyLineSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Commenting/CommentEmptyLineSniff.php index 0ac3f4ed..a8856b4e 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Commenting/CommentEmptyLineSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Commenting/CommentEmptyLineSniff.php @@ -32,8 +32,7 @@ class CommentEmptyLineSniff implements Sniff public function register() { return [T_COMMENT]; - - }//end register() + } /** @@ -62,15 +61,12 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$i]['code'] !== T_WHITESPACE) { return; } - } else if ($tokens[$i]['line'] > ($tokens[$stackPtr]['line'] + 1)) { + } elseif ($tokens[$i]['line'] > ($tokens[$stackPtr]['line'] + 1)) { break; } } $warning = 'There must be no blank line following an inline comment'; $phpcsFile->addWarning($warning, $stackPtr, 'SpacingAfter'); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php index 31f915c7..3fab857c 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php @@ -33,8 +33,7 @@ class ExpectedExceptionSniff implements Sniff public function register() { return [T_DOC_COMMENT_TAG]; - - }//end register() + } /** @@ -58,8 +57,5 @@ public function process(File $phpcsFile, $stackPtr) $warning = '%s tags should not be used, use $this->setExpectedException() or $this->expectException() instead'; $phpcsFile->addWarning($warning, $stackPtr, 'TagFound', [$content]); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalConstantSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalConstantSniff.php index 4652c92b..ad92bee7 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalConstantSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalConstantSniff.php @@ -32,8 +32,7 @@ class GlobalConstantSniff implements Sniff public function register() { return [T_CONST]; - - }//end register() + } /** @@ -76,8 +75,5 @@ public function process(File $phpcsFile, $stackPtr) $warning = 'Global constants should not be used, move it to a class or interface'; $phpcsFile->addWarning($warning, $stackPtr, 'GlobalConstant'); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalDefineSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalDefineSniff.php index 4cf6e11f..d02b9dd1 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalDefineSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalDefineSniff.php @@ -32,8 +32,7 @@ class GlobalDefineSniff extends FunctionCall public function registerFunctionNames() { return ['define']; - - }//end registerFunctionNames() + } /** @@ -84,8 +83,5 @@ public function processFunctionCall( $warning = 'Global constants should not be used, move it to a class or interface'; $phpcsFile->addWarning($warning, $stackPtr, 'GlobalConstant'); - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CheckPlainSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CheckPlainSniff.php index cde3312d..9192f892 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CheckPlainSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CheckPlainSniff.php @@ -31,8 +31,7 @@ class CheckPlainSniff extends FunctionCall public function registerFunctionNames() { return ['check_plain']; - - }//end registerFunctionNames() + } /** @@ -60,8 +59,5 @@ public function processFunctionCall( $warning = 'Do not use check_plain() on string literals, because they cannot contain user provided text'; $phpcsFile->addWarning($warning, $argument['start'], 'CheckPlainLiteral'); } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CurlSslVerifierSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CurlSslVerifierSniff.php index 36daee35..9a3b543c 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CurlSslVerifierSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CurlSslVerifierSniff.php @@ -32,8 +32,7 @@ class CurlSslVerifierSniff extends FunctionCall public function registerFunctionNames() { return ['curl_setopt']; - - }//end registerFunctionNames() + } /** @@ -66,8 +65,5 @@ public function processFunctionCall( $warning = 'Potential security problem: SSL peer verification must not be disabled'; $phpcsFile->addWarning($warning, $value['start'], 'SslPeerVerificationDisabled'); } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbQuerySniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbQuerySniff.php index 9c62807a..be601031 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbQuerySniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbQuerySniff.php @@ -32,8 +32,7 @@ class DbQuerySniff extends FunctionCall public function registerFunctionNames() { return ['db_query']; - - }//end registerFunctionNames() + } /** @@ -73,11 +72,8 @@ public function processFunctionCall( if (in_array(strtoupper($queryStart), ['INSERT', 'UPDATE', 'DELETE', 'TRUNCATE']) === true) { $warning = 'Do not use %s queries with db_query(), use %s instead'; - $phpcsFile->addWarning($warning, $start, 'DbQuery', [$queryStart, 'db_'.strtolower($queryStart).'()']); + $phpcsFile->addWarning($warning, $start, 'DbQuery', [$queryStart, 'db_' . strtolower($queryStart) . '()']); } } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbSelectBracesSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbSelectBracesSniff.php index 32b690a8..9ac45a8e 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbSelectBracesSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbSelectBracesSniff.php @@ -31,8 +31,7 @@ class DbSelectBracesSniff extends FunctionCall public function registerFunctionNames() { return ['db_select']; - - }//end registerFunctionNames() + } /** @@ -63,8 +62,5 @@ public function processFunctionCall( $warning = 'Do not use {} curly brackets in db_select() table names'; $phpcsFile->addWarning($warning, $argument['start'], 'DbSelectBrace'); } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DefaultValueSanitizeSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DefaultValueSanitizeSniff.php index 1b1525f8..1e325e3f 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DefaultValueSanitizeSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DefaultValueSanitizeSniff.php @@ -39,8 +39,7 @@ public function registerFunctionNames() 'filter_xss', 'filter_xss_admin', ]; - - }//end registerFunctionNames() + } /** @@ -82,8 +81,5 @@ public function processFunctionCall( $warning = 'Do not use the %s() sanitization function on Form API #default_value elements, they get escaped automatically'; $data = [$tokens[$stackPtr]['content']]; $phpcsFile->addWarning($warning, $stackPtr, 'DefaultValue', $data); - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php index b859f892..6603d9a7 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php @@ -34,8 +34,7 @@ public function registerFunctionNames() 'form_set_error', 'form_error', ]; - - }//end registerFunctionNames() + } /** @@ -63,8 +62,5 @@ public function processFunctionCall( $warning = 'Form error messages are user facing text and must run through t() for translation'; $phpcsFile->addWarning($warning, $argument['start'], 'ErrorMessage'); } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/InsecureUnserializeSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/InsecureUnserializeSniff.php index dd52cceb..dd2743d5 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/InsecureUnserializeSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/InsecureUnserializeSniff.php @@ -31,8 +31,7 @@ class InsecureUnserializeSniff extends FunctionCall public function registerFunctionNames() { return ['unserialize']; - - }//end registerFunctionNames() + } /** @@ -81,8 +80,7 @@ public function processFunctionCall( if ($tokens[$allowedClassesValue]['code'] === T_TRUE) { $this->fail($phpcsFile, $allowedClassesValue); } - - }//end processFunctionCall() + } /** @@ -96,8 +94,5 @@ public function processFunctionCall( protected function fail(File $phpcsFile, int $position) { $phpcsFile->addError('unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.', $position, 'InsecureUnserialize'); - - }//end fail() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/LCheckPlainSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/LCheckPlainSniff.php index ac0dfbbf..20820c6c 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/LCheckPlainSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/LCheckPlainSniff.php @@ -31,8 +31,7 @@ class LCheckPlainSniff extends FunctionCall public function registerFunctionNames() { return ['l']; - - }//end registerFunctionNames() + } /** @@ -60,8 +59,5 @@ public function processFunctionCall( $warning = 'Do not use check_plain() on the first argument of l(), because l() will sanitize it for you by default'; $phpcsFile->addWarning($warning, $argument['start'], 'LCheckPlain'); } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/MessageTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/MessageTSniff.php index a04de320..5a43557d 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/MessageTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/MessageTSniff.php @@ -31,8 +31,7 @@ class MessageTSniff extends FunctionCall public function registerFunctionNames() { return ['drupal_set_message']; - - }//end registerFunctionNames() + } /** @@ -60,8 +59,5 @@ public function processFunctionCall( $warning = 'Messages are user facing text and must run through t() for translation'; $phpcsFile->addWarning($warning, $argument['start'], 'ErrorMessage'); } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/TCheckPlainSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/TCheckPlainSniff.php index 73ece1a2..2509ba37 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/TCheckPlainSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/TCheckPlainSniff.php @@ -35,8 +35,7 @@ public function registerFunctionNames() 't', 'watchdog', ]; - - }//end registerFunctionNames() + } /** @@ -86,8 +85,5 @@ public function processFunctionCall( } } } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php index 3675d117..551e8618 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php @@ -60,8 +60,5 @@ public function process(File $phpcsFile, $stackPtr) $themeName = substr($functionName, 6); $warning = "Do not call theme functions directly, use theme('%s', ...) instead"; $phpcsFile->addWarning($warning, $stackPtr, 'ThemeFunctionDirect', [$themeName]); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/VariableSetSanitizeSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/VariableSetSanitizeSniff.php index abc32162..ac7e80e3 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/VariableSetSanitizeSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/VariableSetSanitizeSniff.php @@ -32,8 +32,7 @@ class VariableSetSanitizeSniff extends FunctionCall public function registerFunctionNames() { return ['variable_set']; - - }//end registerFunctionNames() + } /** @@ -73,8 +72,5 @@ public function processFunctionCall( $data = [$tokens[$argument['start']]['content']]; $phpcsFile->addWarning($warning, $argument['start'], 'VariableSet', $data); } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/AccessHookMenuSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/AccessHookMenuSniff.php index f53375d1..8c06c72c 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/AccessHookMenuSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/AccessHookMenuSniff.php @@ -45,7 +45,7 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $fileName = substr(basename($phpcsFile->getFilename()), 0, -7); $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr]['content'] !== ($fileName.'_menu')) { + if ($tokens[$stackPtr]['content'] !== ($fileName . '_menu')) { return; } @@ -95,8 +95,5 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $tokens[$functionPtr]['scope_closer'] ); }//end while - - }//end processFunction() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/FormAlterDocSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/FormAlterDocSniff.php index 5eb5282d..869bfd67 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/FormAlterDocSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/FormAlterDocSniff.php @@ -66,16 +66,13 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) return; } - if ($tokens[$stackPtr]['content'] !== $projectName.'_form_alter') { + if ($tokens[$stackPtr]['content'] !== $projectName . '_form_alter') { $warning = 'Doc comment indicates hook_form_alter() but function signature is "%s" instead of "%s". Did you mean hook_form_FORM_ID_alter()?'; $data = [ $tokens[$stackPtr]['content'], - $projectName.'_form_alter', + $projectName . '_form_alter', ]; $phpcsFile->addWarning($warning, $commentLine, 'Different', $data); } - - }//end processFunction() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/HookInitCssSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/HookInitCssSniff.php index 24cdb047..07ae4c4e 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/HookInitCssSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/HookInitCssSniff.php @@ -51,7 +51,7 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $fileName = substr(basename($phpcsFile->getFilename()), 0, -7); $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr]['content'] !== ($fileName.'_init') && $tokens[$stackPtr]['content'] !== ($fileName.'_page_build')) { + if ($tokens[$stackPtr]['content'] !== ($fileName . '_init') && $tokens[$stackPtr]['content'] !== ($fileName . '_page_build')) { return; } @@ -72,7 +72,7 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) if ($opener !== false && $tokens[$opener]['code'] === T_OPEN_PARENTHESIS ) { - if ($tokens[$stackPtr]['content'] === ($fileName.'_init')) { + if ($tokens[$stackPtr]['content'] === ($fileName . '_init')) { $warning = 'Do not use %s() in hook_init(), use #attached for CSS and JS in your page/form callback or in hook_page_build() instead'; $phpcsFile->addWarning($warning, $string, 'AddFunctionFound', [$tokens[$string]['content']]); } else { @@ -88,8 +88,5 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $tokens[$functionPtr]['scope_closer'] ); }//end while - - }//end processFunction() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/InstallTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/InstallTSniff.php index f8dc6a78..a833aa3b 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/InstallTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/InstallTSniff.php @@ -46,8 +46,8 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $fileName = substr(basename($phpcsFile->getFilename()), 0, -8); $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr]['content'] !== ($fileName.'_install') - && $tokens[$stackPtr]['content'] !== ($fileName.'_requirements') + if ($tokens[$stackPtr]['content'] !== ($fileName . '_install') + && $tokens[$stackPtr]['content'] !== ($fileName . '_requirements') ) { return; } @@ -85,8 +85,5 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $tokens[$functionPtr]['scope_closer'] ); }//end while - - }//end processFunction() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/AccessAdminPagesSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/AccessAdminPagesSniff.php index c2629d5c..c1e63216 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/AccessAdminPagesSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/AccessAdminPagesSniff.php @@ -46,7 +46,7 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $tokens = $phpcsFile->getTokens(); $fileName = substr(basename($phpcsFile->getFilename()), 0, -7); - if ($tokens[$stackPtr]['content'] !== ($fileName.'_menu')) { + if ($tokens[$stackPtr]['content'] !== ($fileName . '_menu')) { return; } @@ -69,8 +69,5 @@ public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) $tokens[$functionPtr]['scope_closer'] ); }//end while - - }//end processFunction() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/ClassNameSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/ClassNameSniff.php index 3a7eb98f..9e2d4f8d 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/ClassNameSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/ClassNameSniff.php @@ -36,8 +36,7 @@ public function register() T_CLASS, T_INTERFACE, ]; - - }//end register() + } /** @@ -89,8 +88,5 @@ public function process(File $phpcsFile, $stackPtr) ]; $phpcsFile->addWarning($warning, $className, 'ClassPrefix', $errorData); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/DescriptionTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/DescriptionTSniff.php index 43580e93..335c5e4c 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/DescriptionTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/DescriptionTSniff.php @@ -31,8 +31,7 @@ class DescriptionTSniff implements Sniff public function register() { return [T_CONSTANT_ENCAPSED_STRING]; - - }//end register() + } /** @@ -71,8 +70,5 @@ public function process(File $phpcsFile, $stackPtr) $warning = '#description values usually have to run through t() for translation'; $phpcsFile->addWarning($warning, $stringToken, 'DescriptionT'); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/ExceptionTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/ExceptionTSniff.php index b2341bff..d0014bd8 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/ExceptionTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/ExceptionTSniff.php @@ -32,8 +32,7 @@ class ExceptionTSniff implements Sniff public function register() { return [T_THROW]; - - }//end register() + } /** @@ -64,8 +63,5 @@ public function process(File $phpcsFile, $stackPtr) } } } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php index 0d8cee7f..525d1ab1 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php @@ -32,8 +32,7 @@ class FormStateInputSniff implements Sniff public function register() { return [T_VARIABLE]; - - }//end register() + } /** @@ -53,8 +52,5 @@ public function process(File $phpcsFile, $stackPtr) $warning = 'Do not use the raw $form_state[\'input\'], use $form_state[\'values\'] instead where possible'; $phpcsFile->addWarning($warning, $stackPtr, 'Input'); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/LanguageNoneSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/LanguageNoneSniff.php index d1fa525b..dd61998d 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/LanguageNoneSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/LanguageNoneSniff.php @@ -34,8 +34,7 @@ public function register() T_OPEN_SQUARE_BRACKET, T_OPEN_SHORT_ARRAY, ]; - - }//end register() + } /** @@ -54,8 +53,5 @@ public function process(File $phpcsFile, $stackPtr) $warning = "Are you accessing field values here? Then you should use LANGUAGE_NONE instead of 'und'"; $phpcsFile->addWarning($warning, ($stackPtr + 1), 'Und'); } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/OptionsTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/OptionsTSniff.php index f5969a45..7bb9a215 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/OptionsTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/OptionsTSniff.php @@ -31,8 +31,7 @@ class OptionsTSniff implements Sniff public function register() { return [T_CONSTANT_ENCAPSED_STRING]; - - }//end register() + } /** @@ -133,8 +132,5 @@ public function process(File $phpcsFile, $stackPtr) $arrow = $phpcsFile->findNext(T_DOUBLE_ARROW, ($arrow + 1), $statementEnd, false, null, true); }//end while - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/VariableNameSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/VariableNameSniff.php index 2f34104e..e18a0b2a 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/VariableNameSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/VariableNameSniff.php @@ -33,8 +33,7 @@ class VariableNameSniff extends FunctionCall public function registerFunctionNames() { return ['variable_get']; - - }//end registerFunctionNames() + } /** @@ -94,8 +93,5 @@ public function processFunctionCall( ]; $phpcsFile->addWarning($warning, $argument['start'], 'VariableName', $data); } - - }//end processFunctionCall() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/CoreVersionRequirementSniff.php b/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/CoreVersionRequirementSniff.php index 1ff38cfa..f726828d 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/CoreVersionRequirementSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/CoreVersionRequirementSniff.php @@ -34,8 +34,7 @@ class CoreVersionRequirementSniff implements Sniff public function register() { return [T_INLINE_HTML]; - - }//end register() + } /** @@ -85,8 +84,5 @@ public function process(File $phpcsFile, $stackPtr) } return ($phpcsFile->numTokens + 1); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/DescriptionSniff.php b/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/DescriptionSniff.php index b5b58793..4d4d8357 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/DescriptionSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/DescriptionSniff.php @@ -34,8 +34,7 @@ class DescriptionSniff implements Sniff public function register() { return [T_INLINE_HTML]; - - }//end register() + } /** @@ -76,14 +75,11 @@ public function process(File $phpcsFile, $stackPtr) if (isset($info['description']) === false) { $warning = '"Description" property is missing in the info.yml file'; $phpcsFile->addWarning($warning, $stackPtr, 'Missing'); - } else if ($info['description'] === '') { + } elseif ($info['description'] === '') { $warning = '"Description" should not be empty'; $phpcsFile->addWarning($warning, $stackPtr, 'Empty'); } return ($phpcsFile->numTokens + 1); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/NamespacedDependencySniff.php b/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/NamespacedDependencySniff.php index 441c8da2..10b3ac6a 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/NamespacedDependencySniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/NamespacedDependencySniff.php @@ -34,8 +34,7 @@ class NamespacedDependencySniff implements Sniff public function register() { return [T_INLINE_HTML]; - - }//end register() + } /** @@ -80,7 +79,7 @@ public function process(File $phpcsFile, $stackPtr) if (preg_match('/^[\s]+- [^:]+[\s]*$/', $tokens[$nextLine]['content']) === 1) { $error = 'All dependencies must be prefixed with the project name, for example "drupal:"'; $phpcsFile->addWarning($error, $nextLine, 'NonNamespaced'); - } else if (preg_match('/^[\s]+- [^:]+:[^:]+[\s]*$/', $tokens[$nextLine]['content']) === 0 + } elseif (preg_match('/^[\s]+- [^:]+:[^:]+[\s]*$/', $tokens[$nextLine]['content']) === 0 && preg_match('/^[\s]*#.*$/', $tokens[$nextLine]['content']) === 0 ) { // Not a dependency line with namespace or comment - stop. @@ -89,8 +88,5 @@ public function process(File $phpcsFile, $stackPtr) $nextLine++; } - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalClassSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalClassSniff.php index e19ca290..9e81105f 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalClassSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalClassSniff.php @@ -95,8 +95,7 @@ class GlobalClassSniff implements Sniff public function register() { return [T_STRING]; - - }//end register() + } /** @@ -165,8 +164,7 @@ public function process(File $phpcsFile, $stackPtr) $tokens[($stackPtr + 2)]['content'], ]; $phpcsFile->addWarning($warning, $stackPtr, 'GlobalClass', $data); - - }//end process() + } /** @@ -220,8 +218,5 @@ protected function getFullyQualifiedName(File $phpcsFile, $className) }//end while return $className; - - }//end getFullyQualifiedName() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalDrupalSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalDrupalSniff.php index 91245f85..4111141c 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalDrupalSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalDrupalSniff.php @@ -52,8 +52,7 @@ class GlobalDrupalSniff implements Sniff public function register() { return [T_NAME_FULLY_QUALIFIED]; - - }//end register() + } /** @@ -107,8 +106,5 @@ public function process(File $phpcsFile, $stackPtr) $warning = '\Drupal calls should be avoided in classes, use dependency injection instead'; $phpcsFile->addWarning($warning, $stackPtr, 'GlobalDrupal'); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalFunctionSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalFunctionSniff.php index fed6027f..2a3341b5 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalFunctionSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalFunctionSniff.php @@ -128,8 +128,5 @@ public function process(File $phpcsFile, $stackPtr) }//end if $phpcsFile->addWarning($warning, $stackPtr, 'GlobalFunction', $data); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Objects/StrictSchemaDisabledSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Objects/StrictSchemaDisabledSniff.php index 3e9e8d41..bc07d594 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Objects/StrictSchemaDisabledSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Objects/StrictSchemaDisabledSniff.php @@ -25,7 +25,7 @@ class StrictSchemaDisabledSniff extends AbstractVariableSniff /** * The name of the variable in the test base class to disable config schema checking. */ - const STRICT_CONFIG_SCHEMA_NAME = '$strictConfigSchema'; + public const STRICT_CONFIG_SCHEMA_NAME = '$strictConfigSchema'; /** @@ -62,8 +62,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr) ); } }//end if - - }//end processMemberVar() + } /** @@ -83,8 +82,7 @@ protected function isTestClass(File $phpcsFile, $stackPtr) $classPtr = key($tokens[$stackPtr]['conditions']); $name = $phpcsFile->findNext([T_STRING], $classPtr); return strpos($tokens[$name]['content'], 'Test') !== false; - - }//end isTestClass() + } /** @@ -101,8 +99,7 @@ protected function isTestClass(File $phpcsFile, $stackPtr) */ protected function processVariable(File $phpcsFile, $stackPtr) { - - }//end processVariable() + } /** @@ -123,8 +120,5 @@ protected function processVariable(File $phpcsFile, $stackPtr) */ protected function processVariableInString(File $phpcsFile, $stackPtr) { - - }//end processVariableInString() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Objects/UnusedPrivateMethodSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Objects/UnusedPrivateMethodSniff.php index 509e8c0c..ab89eabe 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Objects/UnusedPrivateMethodSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Objects/UnusedPrivateMethodSniff.php @@ -30,8 +30,7 @@ class UnusedPrivateMethodSniff extends AbstractScopeSniff public function __construct() { parent::__construct([T_CLASS], [T_FUNCTION], false); - - }//end __construct() + } /** @@ -90,7 +89,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop // At this point this is a method call to the private method, so we // can stop. return; - } else if ($tokens[$next]['code'] === T_COMMA) { + } elseif ($tokens[$next]['code'] === T_COMMA) { $call = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($next + 1), null, true); if ($call === false || substr($tokens[$call]['content'], 1, -1) !== $methodName) { continue; @@ -105,8 +104,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop $warning = 'Unused private method %s()'; $data = [$methodName]; $phpcsFile->addWarning($warning, $stackPtr, 'UnusedMethod', $data); - - }//end processTokenWithinScope() + } /** @@ -120,8 +118,5 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop */ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) { - - }//end processTokenOutsideScope() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Variables/GetRequestDataSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Variables/GetRequestDataSniff.php index 7bde9e0c..12faaa33 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Variables/GetRequestDataSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Variables/GetRequestDataSniff.php @@ -36,8 +36,7 @@ class GetRequestDataSniff implements Sniff public function register() { return [T_VARIABLE]; - - }//end register() + } /** @@ -100,8 +99,5 @@ public function process(File $phpcsFile, $stackPtr) $error .= ' instead'; $phpcsFile->addError($error, $stackPtr, $type, $data); - - }//end process() - - -}//end class + } +} diff --git a/coder_sniffer/DrupalPractice/Sniffs/Yaml/RoutingAccessSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Yaml/RoutingAccessSniff.php index c9a701a7..e7dc327a 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Yaml/RoutingAccessSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Yaml/RoutingAccessSniff.php @@ -34,8 +34,7 @@ class RoutingAccessSniff implements Sniff public function register() { return [T_INLINE_HTML]; - - }//end register() + } /** @@ -68,8 +67,5 @@ public function process(File $phpcsFile, $stackPtr) $warning = 'The administration page callback should probably use "administer site configuration" - which implies the user can change something - rather than "access administration pages" which is about viewing but not changing configurations.'; $phpcsFile->addWarning($warning, $stackPtr, 'PermissionFound'); } - - }//end process() - - -}//end class + } +} diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 7a447046..150a5f42 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -10,50 +10,77 @@ tests/*/(good|bad)/*\.php$ tests/*/drupal(6|7|8)/*\.php$ - + - - - error - + + + + + + + + - + - + - - - + + + + + + + + - + + + + + - + + - - - + + + + + + + + + + + - + + + bin/phpc(s|bf)$ + requirements\.php$ + + @@ -65,15 +92,9 @@ + - - - - - - - @@ -89,6 +110,12 @@ 0 + + + tests/*\.php$ + Standards/*/Tests/*/*UnitTest\.php$ + + @@ -102,7 +129,7 @@ - + @@ -112,45 +139,77 @@ - - - + + - - - error + + + + + + + + + tests/Core/Tokenizers/PHP/*WinTest\.php - - - error + + + src/Standards/Generic/Sniffs/Commenting/TodoSniff\.php + src/Standards/Generic/Tests/Commenting/TodoUnitTest\.php - + + - - - - + + + + + + - - + + + /requirements\.php + + + + + + + + + + + + + + + + - + + + + - tests/Drupal tests/DrupalPractice/Test + + + + diff --git a/tests/Drupal/Arrays/ArrayUnitTest.php b/tests/Drupal/Arrays/ArrayUnitTest.php index 3379d53a..a6e80b93 100644 --- a/tests/Drupal/Arrays/ArrayUnitTest.php +++ b/tests/Drupal/Arrays/ArrayUnitTest.php @@ -21,50 +21,49 @@ class ArrayUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { switch ($testFile) { - case 'ArrayUnitTest.inc': - return [ - 13 => 1, - 33 => 1, - 83 => 1, - 88 => 1, - 92 => 1, - 140 => 1, - 141 => 1, - 143 => 1, - 144 => 1, - 146 => 1, - 147 => 1, - 154 => 1, - 155 => 1, - 157 => 1, - 158 => 1, - 160 => 1, - 161 => 1, - 172 => 1, - 173 => 1, - 175 => 1, - 176 => 1, - 178 => 1, - 179 => 1, - 185 => 1, - 186 => 1, - 188 => 1, - 189 => 1, - 191 => 1, - 192 => 1, - ]; - case 'ArrayUnitTest.1.inc': - return [ - 14 => 1, - 17 => 1, - 20 => 1, - 24 => 1, - ]; + case 'ArrayUnitTest.inc': + return [ + 13 => 1, + 33 => 1, + 83 => 1, + 88 => 1, + 92 => 1, + 140 => 1, + 141 => 1, + 143 => 1, + 144 => 1, + 146 => 1, + 147 => 1, + 154 => 1, + 155 => 1, + 157 => 1, + 158 => 1, + 160 => 1, + 161 => 1, + 172 => 1, + 173 => 1, + 175 => 1, + 176 => 1, + 178 => 1, + 179 => 1, + 185 => 1, + 186 => 1, + 188 => 1, + 189 => 1, + 191 => 1, + 192 => 1, + ]; + case 'ArrayUnitTest.1.inc': + return [ + 14 => 1, + 17 => 1, + 20 => 1, + 24 => 1, + ]; }//end switch return []; - - }//end getErrorList() + } /** @@ -80,23 +79,20 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { switch ($testFile) { - case 'ArrayUnitTest.inc': - return [ - 17 => 1, - 22 => 1, - 23 => 1, - 24 => 1, - 37 => 1, - 42 => 1, - 44 => 1, - 59 => 1, - 76 => 1, - ]; + case 'ArrayUnitTest.inc': + return [ + 17 => 1, + 22 => 1, + 23 => 1, + 24 => 1, + 37 => 1, + 42 => 1, + 44 => 1, + 59 => 1, + 76 => 1, + ]; } return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Attributes/ValidHookNameUnitTest.php b/tests/Drupal/Attributes/ValidHookNameUnitTest.php index 19b8275e..262e85e9 100644 --- a/tests/Drupal/Attributes/ValidHookNameUnitTest.php +++ b/tests/Drupal/Attributes/ValidHookNameUnitTest.php @@ -21,8 +21,7 @@ class ValidHookNameUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -47,8 +46,5 @@ protected function getWarningList(string $testFile): array 92 => 1, 107 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Classes/ClassDeclarationUnitTest.php b/tests/Drupal/Classes/ClassDeclarationUnitTest.php index 188befe6..b5cc67ae 100644 --- a/tests/Drupal/Classes/ClassDeclarationUnitTest.php +++ b/tests/Drupal/Classes/ClassDeclarationUnitTest.php @@ -25,8 +25,7 @@ protected function getErrorList(string $testFile): array 19 => 1, 28 => 1, ]; - - }//end getErrorList() + } /** @@ -42,8 +41,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Classes/FullyQualifiedNamespaceUnitTest.php b/tests/Drupal/Classes/FullyQualifiedNamespaceUnitTest.php index aa80f26a..f7ed3757 100644 --- a/tests/Drupal/Classes/FullyQualifiedNamespaceUnitTest.php +++ b/tests/Drupal/Classes/FullyQualifiedNamespaceUnitTest.php @@ -21,29 +21,28 @@ class FullyQualifiedNamespaceUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { switch ($testFile) { - case 'FullyQualifiedNamespaceUnitTest.inc': - return [ - 29 => 1, - 36 => 1, - 43 => 1, - 57 => 1, - 64 => 1, - 71 => 2, - 78 => 1, - ]; - case 'FullyQualifiedNamespaceUnitTest.1.inc': - return [16 => 1]; - case 'FullyQualifiedNamespaceUnitTest.2.inc': - return [8 => 1]; - case 'FullyQualifiedNamespaceUnitTest.3.inc': - return [10 => 2]; - case 'FullyQualifiedNamespaceUnitTest.4.inc': - return []; + case 'FullyQualifiedNamespaceUnitTest.inc': + return [ + 29 => 1, + 36 => 1, + 43 => 1, + 57 => 1, + 64 => 1, + 71 => 2, + 78 => 1, + ]; + case 'FullyQualifiedNamespaceUnitTest.1.inc': + return [16 => 1]; + case 'FullyQualifiedNamespaceUnitTest.2.inc': + return [8 => 1]; + case 'FullyQualifiedNamespaceUnitTest.3.inc': + return [10 => 2]; + case 'FullyQualifiedNamespaceUnitTest.4.inc': + return []; }//end switch return []; - - }//end getErrorList() + } /** @@ -59,8 +58,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() + } /** @@ -73,15 +71,12 @@ protected function getWarningList(string $testFile): array protected function getTestFiles($testFileBase): array { return [ - __DIR__.'/FullyQualifiedNamespaceUnitTest.inc', - __DIR__.'/FullyQualifiedNamespaceUnitTest.1.inc', - __DIR__.'/FullyQualifiedNamespaceUnitTest.2.inc', - __DIR__.'/FullyQualifiedNamespaceUnitTest.3.inc', - __DIR__.'/FullyQualifiedNamespaceUnitTest.4.inc', - __DIR__.'/FullyQualifiedNamespaceUnitTest.api.php', + __DIR__ . '/FullyQualifiedNamespaceUnitTest.inc', + __DIR__ . '/FullyQualifiedNamespaceUnitTest.1.inc', + __DIR__ . '/FullyQualifiedNamespaceUnitTest.2.inc', + __DIR__ . '/FullyQualifiedNamespaceUnitTest.3.inc', + __DIR__ . '/FullyQualifiedNamespaceUnitTest.4.inc', + __DIR__ . '/FullyQualifiedNamespaceUnitTest.api.php', ]; - - }//end getTestFiles() - - -}//end class + } +} diff --git a/tests/Drupal/Classes/PropertyDeclarationUnitTest.php b/tests/Drupal/Classes/PropertyDeclarationUnitTest.php index 23474f58..39e0a6e4 100644 --- a/tests/Drupal/Classes/PropertyDeclarationUnitTest.php +++ b/tests/Drupal/Classes/PropertyDeclarationUnitTest.php @@ -21,8 +21,7 @@ class PropertyDeclarationUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return [16 => 1]; - - }//end getErrorList() + } /** @@ -38,8 +37,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Classes/UseGlobalClassUnitTest.php b/tests/Drupal/Classes/UseGlobalClassUnitTest.php index fd598dda..3d56297e 100644 --- a/tests/Drupal/Classes/UseGlobalClassUnitTest.php +++ b/tests/Drupal/Classes/UseGlobalClassUnitTest.php @@ -27,8 +27,7 @@ protected function getErrorList(string $testFile): array 13 => 1, 15 => 1, ]; - - }//end getErrorList() + } /** @@ -44,8 +43,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/CoderSniffUnitTest.php b/tests/Drupal/CoderSniffUnitTest.php index c83ba7c0..35d4644b 100644 --- a/tests/Drupal/CoderSniffUnitTest.php +++ b/tests/Drupal/CoderSniffUnitTest.php @@ -61,8 +61,8 @@ abstract class CoderSniffUnitTest extends TestCase */ public function setUp(): void { - $this->rootDir = __DIR__.'/../../'; - $this->testsDir = __DIR__.'/'; + $this->rootDir = __DIR__ . '/../../'; + $this->testsDir = __DIR__ . '/'; // Required to pull in all the defines from the tokens file. $tokens = new Tokens(); if (defined('PHP_CODESNIFFER_VERBOSITY') === false) { @@ -72,8 +72,7 @@ public function setUp(): void if (defined('PHP_CODESNIFFER_CBF') === false) { define('PHP_CODESNIFFER_CBF', 0); } - - }//end setUp() + } /** @@ -96,7 +95,7 @@ protected function getTestFiles(string $testFileBase): array foreach ($di as $file) { $path = $file->getPathname(); if (substr($path, 0, strlen($testFileBase)) === $testFileBase) { - if ($path !== $testFileBase.'php' && substr($path, -5) !== 'fixed') { + if ($path !== $testFileBase . 'php' && substr($path, -5) !== 'fixed') { $testFiles[] = $path; } } @@ -106,8 +105,7 @@ protected function getTestFiles(string $testFileBase): array sort($testFiles); return $testFiles; - - }//end getTestFiles() + } /** @@ -118,8 +116,7 @@ protected function getTestFiles(string $testFileBase): array protected function shouldSkipTest() { return false; - - }//end shouldSkipTest() + } /** @@ -146,15 +143,15 @@ final public function testSniff() list($standardName) = explode('\\', get_class($this)); } - $testFileBase = $this->rootDir.'tests'.DIRECTORY_SEPARATOR.$standardName.DIRECTORY_SEPARATOR.$categoryName.DIRECTORY_SEPARATOR.$sniffName.'UnitTest.'; + $testFileBase = $this->rootDir . 'tests' . DIRECTORY_SEPARATOR . $standardName . DIRECTORY_SEPARATOR . $categoryName . DIRECTORY_SEPARATOR . $sniffName . 'UnitTest.'; - $this->standardsDir = $this->rootDir.'coder_sniffer'.DIRECTORY_SEPARATOR.$standardName.DIRECTORY_SEPARATOR; + $this->standardsDir = $this->rootDir . 'coder_sniffer' . DIRECTORY_SEPARATOR . $standardName . DIRECTORY_SEPARATOR; // $testFileBase = $this->testsDir.$categoryName.DIRECTORY_SEPARATOR.$sniffName.'UnitTest.'; // Get a list of all test files to check. $testFiles = $this->getTestFiles($testFileBase); $this->assertNotEmpty( $testFiles, - 'No test files found for the '.$sniffCode.' unit test.' + 'No test files found for the ' . $sniffCode . ' unit test.' ); $config = new Config(); @@ -196,7 +193,7 @@ final public function testSniff() $phpcsFile = new LocalFile($testFile, $ruleset, $config); $phpcsFile->process(); } catch (RuntimeException $e) { - $this->fail('An unexpected exception has been caught: '.$e->getMessage()); + $this->fail('An unexpected exception has been caught: ' . $e->getMessage()); } // Attempt to fix the errors. @@ -207,7 +204,7 @@ final public function testSniff() } // Check for a .fixed file to check for accuracy of fixes. - $fixedFile = $testFile.'.fixed'; + $fixedFile = $testFile . '.fixed'; if (file_exists($fixedFile) === true) { $diff = $phpcsFile->fixer->generateDiff($fixedFile); if (trim($diff) !== '') { @@ -225,8 +222,7 @@ final public function testSniff() if (empty($failureMessages) === false) { $this->fail(implode(PHP_EOL, $failureMessages)); } - - }//end testSniff() + } /** @@ -276,7 +272,7 @@ public function generateFailureMessages(LocalFile $file): array $errorsTemp = []; foreach ($errors as $foundError) { - $errorsTemp[] = $foundError['message'].' ('.$foundError['source'].')'; + $errorsTemp[] = $foundError['message'] . ' (' . $foundError['source'] . ')'; $source = $foundError['source']; if (in_array($source, $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES']) === false) { @@ -333,7 +329,7 @@ public function generateFailureMessages(LocalFile $file): array $warningsTemp = []; foreach ($warnings as $warning) { - $warningsTemp[] = $warning['message'].' ('.$warning['source'].')'; + $warningsTemp[] = $warning['message'] . ' (' . $warning['source'] . ')'; } $allProblems[$line]['found_warnings'] = array_merge($foundWarningsTemp, $warningsTemp); @@ -376,14 +372,14 @@ public function generateFailureMessages(LocalFile $file): array if ($expectedErrors !== $numErrors || $expectedWarnings !== $numWarnings) { $lineMessage = "[LINE $line]"; $expectedMessage = 'Expected '; - $foundMessage = 'in '.basename($testFile).' but found '; + $foundMessage = 'in ' . basename($testFile) . ' but found '; if ($expectedErrors !== $numErrors) { $expectedMessage .= "$expectedErrors error(s)"; $foundMessage .= "$numErrors error(s)"; if ($numErrors !== 0) { $foundString .= 'error(s)'; - $errors .= implode(PHP_EOL.' -> ', $problems['found_errors']); + $errors .= implode(PHP_EOL . ' -> ', $problems['found_errors']); } if ($expectedWarnings !== $numWarnings) { @@ -403,16 +399,16 @@ public function generateFailureMessages(LocalFile $file): array if ($numWarnings !== 0) { $foundString .= 'warning(s)'; if (empty($errors) === false) { - $errors .= PHP_EOL.' -> '; + $errors .= PHP_EOL . ' -> '; } - $errors .= implode(PHP_EOL.' -> ', $problems['found_warnings']); + $errors .= implode(PHP_EOL . ' -> ', $problems['found_warnings']); } } $fullMessage = "$lineMessage $expectedMessage $foundMessage."; if ($errors !== '') { - $fullMessage .= " The $foundString found were:".PHP_EOL." -> $errors"; + $fullMessage .= " The $foundString found were:" . PHP_EOL . " -> $errors"; } $failureMessages[] = $fullMessage; @@ -420,8 +416,7 @@ public function generateFailureMessages(LocalFile $file): array }//end foreach return $failureMessages; - - }//end generateFailureMessages() + } /** @@ -452,15 +447,14 @@ public function getSniffCode(string $testClass): string $sniff = substr($sniff, 0, -8); } else { throw new \InvalidArgumentException( - 'The $testClass parameter was not passed a fully qualified sniff(test) class name. Received: '.$testClass + 'The $testClass parameter was not passed a fully qualified sniff(test) class name. Received: ' . $testClass ); } $standard = $parts[($partsCount - 4)]; $category = $parts[($partsCount - 2)]; - return $standard.'.'.$category.'.'.$sniff; - - }//end getSniffCode() + return $standard . '.' . $category . '.' . $sniff; + } /** @@ -473,9 +467,7 @@ public function getSniffCode(string $testClass): string */ public function setCliValues($filename, $config) { - return; - - }//end setCliValues() + } /** @@ -512,8 +504,5 @@ abstract protected function getWarningList(string $testFile): array; protected function checkAllSniffCodes() { return false; - - }//end checkAllSniffCodes() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/ClassCommentUnitTest.php b/tests/Drupal/Commenting/ClassCommentUnitTest.php index b8663224..de16d004 100644 --- a/tests/Drupal/Commenting/ClassCommentUnitTest.php +++ b/tests/Drupal/Commenting/ClassCommentUnitTest.php @@ -25,8 +25,7 @@ protected function getErrorList(string $testFile): array 41 => 1, 48 => 1, ]; - - }//end getErrorList() + } /** @@ -45,8 +44,5 @@ protected function getWarningList(string $testFile): array 14 => 1, 21 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/DataTypeNamespaceUnitTest.php b/tests/Drupal/Commenting/DataTypeNamespaceUnitTest.php index 6435e2e3..9e5d6d0b 100644 --- a/tests/Drupal/Commenting/DataTypeNamespaceUnitTest.php +++ b/tests/Drupal/Commenting/DataTypeNamespaceUnitTest.php @@ -26,8 +26,7 @@ protected function getErrorList(string $testFile): array 21 => 1, 31 => 1, ]; - - }//end getErrorList() + } /** @@ -43,8 +42,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/DeprecatedUnitTest.php b/tests/Drupal/Commenting/DeprecatedUnitTest.php index 06854a45..8c3eac72 100644 --- a/tests/Drupal/Commenting/DeprecatedUnitTest.php +++ b/tests/Drupal/Commenting/DeprecatedUnitTest.php @@ -39,8 +39,7 @@ protected function getErrorList(string $testFile): array // See Url has trailing punctuation which is fixable. 101 => 1, ]; - - }//end getErrorList() + } /** @@ -71,8 +70,5 @@ protected function getWarningList(string $testFile): array // Core version incorrectly formatted. 81 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/DocCommentAlignmentUnitTest.php b/tests/Drupal/Commenting/DocCommentAlignmentUnitTest.php index f43714aa..4fbae7cf 100644 --- a/tests/Drupal/Commenting/DocCommentAlignmentUnitTest.php +++ b/tests/Drupal/Commenting/DocCommentAlignmentUnitTest.php @@ -24,8 +24,7 @@ protected function getErrorList(string $testFile): array 14 => 1, 15 => 1, ]; - - }//end getErrorList() + } /** @@ -41,8 +40,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/DocCommentLongArraySyntaxUnitTest.php b/tests/Drupal/Commenting/DocCommentLongArraySyntaxUnitTest.php index b847f8ed..c3841e81 100644 --- a/tests/Drupal/Commenting/DocCommentLongArraySyntaxUnitTest.php +++ b/tests/Drupal/Commenting/DocCommentLongArraySyntaxUnitTest.php @@ -25,8 +25,7 @@ protected function getErrorList(string $testFile): array 23 => 1, 24 => 1, ]; - - }//end getErrorList() + } /** @@ -42,8 +41,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/DocCommentStarUnitTest.php b/tests/Drupal/Commenting/DocCommentStarUnitTest.php index 61764c9a..dca03ab1 100644 --- a/tests/Drupal/Commenting/DocCommentStarUnitTest.php +++ b/tests/Drupal/Commenting/DocCommentStarUnitTest.php @@ -20,17 +20,16 @@ class DocCommentStarUnitTest extends CoderSniffUnitTest */ protected function getErrorList(string $testFile): array { - switch ($testFile) { - case 'DocCommentStarUnitTest.inc': - return [ - 9 => 1, - 16 => 1, - ]; - default: - return []; - } - - }//end getErrorList() + switch ($testFile) { + case 'DocCommentStarUnitTest.inc': + return [ + 9 => 1, + 16 => 1, + ]; + default: + return []; + } + } /** @@ -46,8 +45,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/DocCommentUnitTest.php b/tests/Drupal/Commenting/DocCommentUnitTest.php index 8cf53a21..cfcf482c 100644 --- a/tests/Drupal/Commenting/DocCommentUnitTest.php +++ b/tests/Drupal/Commenting/DocCommentUnitTest.php @@ -21,38 +21,37 @@ class DocCommentUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { switch ($testFile) { - case 'DocCommentUnitTest.inc': - return [ - 8 => 1, - 12 => 1, - 14 => 1, - 16 => 1, - 29 => 1, - 36 => 2, - 45 => 1, - 66 => 1, - 100 => 4, - 101 => 1, - 136 => 1, - 141 => 1, - ]; + case 'DocCommentUnitTest.inc': + return [ + 8 => 1, + 12 => 1, + 14 => 1, + 16 => 1, + 29 => 1, + 36 => 2, + 45 => 1, + 66 => 1, + 100 => 4, + 101 => 1, + 136 => 1, + 141 => 1, + ]; - case 'DocCommentUnitTest.1.inc': - return [ - 24 => 1, - 28 => 1, - 32 => 1, - 36 => 1, - 41 => 2, - ]; + case 'DocCommentUnitTest.1.inc': + return [ + 24 => 1, + 28 => 1, + 32 => 1, + 36 => 1, + 41 => 2, + ]; - case 'DocCommentUnitTest.3.inc': - return [4 => 1]; - default: - return []; + case 'DocCommentUnitTest.3.inc': + return [4 => 1]; + default: + return []; }//end switch - - }//end getErrorList() + } /** @@ -68,8 +67,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/FileCommentUnitTest.php b/tests/Drupal/Commenting/FileCommentUnitTest.php index 2473d1a3..27855bd9 100644 --- a/tests/Drupal/Commenting/FileCommentUnitTest.php +++ b/tests/Drupal/Commenting/FileCommentUnitTest.php @@ -21,39 +21,38 @@ class FileCommentUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { switch ($testFile) { - case 'FileCommentUnitTest.inc': - return [1 => 1]; - case 'FileCommentUnitTest.1.inc': - return [3 => 1]; - case 'FileCommentUnitTest.2.inc': - return [4 => 1]; - case 'FileCommentUnitTest.3.inc': - return [4 => 1]; - case 'FileCommentUnitTest.4.inc': - return [3 => 1]; - case 'FileCommentUnitTest.5.inc': - return [1 => 1]; - case 'FileCommentUnitTest.6.inc': - return [3 => 1]; - case 'FileCommentUnitTest.7.inc': - return []; - case 'FileCommentUnitTest.8.inc': - return [3 => 1]; - case 'FileCommentUnitTest.9.inc': - return [3 => 1]; - case 'FileCommentUnitTest.10.inc': - return [4 => 1]; - case 'FileCommentUnitTest.11.inc': - return [4 => 1]; - case 'FileCommentUnitTest.12.inc': - return [2 => 1]; - case 'FileCommentUnitTest.13.inc': - return [3 => 1]; + case 'FileCommentUnitTest.inc': + return [1 => 1]; + case 'FileCommentUnitTest.1.inc': + return [3 => 1]; + case 'FileCommentUnitTest.2.inc': + return [4 => 1]; + case 'FileCommentUnitTest.3.inc': + return [4 => 1]; + case 'FileCommentUnitTest.4.inc': + return [3 => 1]; + case 'FileCommentUnitTest.5.inc': + return [1 => 1]; + case 'FileCommentUnitTest.6.inc': + return [3 => 1]; + case 'FileCommentUnitTest.7.inc': + return []; + case 'FileCommentUnitTest.8.inc': + return [3 => 1]; + case 'FileCommentUnitTest.9.inc': + return [3 => 1]; + case 'FileCommentUnitTest.10.inc': + return [4 => 1]; + case 'FileCommentUnitTest.11.inc': + return [4 => 1]; + case 'FileCommentUnitTest.12.inc': + return [2 => 1]; + case 'FileCommentUnitTest.13.inc': + return [3 => 1]; }//end switch return []; - - }//end getErrorList() + } /** @@ -69,8 +68,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/FunctionCommentUnitTest.php b/tests/Drupal/Commenting/FunctionCommentUnitTest.php index b32119ce..37c03916 100644 --- a/tests/Drupal/Commenting/FunctionCommentUnitTest.php +++ b/tests/Drupal/Commenting/FunctionCommentUnitTest.php @@ -21,68 +21,67 @@ class FunctionCommentUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { switch ($testFile) { - case 'FunctionCommentUnitTest.inc': - return [ - 12 => 1, - 14 => 1, - 33 => 1, - 43 => 1, - 53 => 1, - 62 => 1, - 71 => 1, - 78 => 1, - 87 => 1, - 92 => 1, - 101 => 1, - 113 => 1, - 126 => 2, - 147 => 1, - 148 => 2, - 187 => 1, - 195 => 1, - 205 => 1, - 215 => 1, - 216 => 1, - 225 => 3, - 233 => 1, - 235 => 1, - 237 => 1, - 248 => 1, - 250 => 1, - 252 => 1, - 254 => 1, - 256 => 1, - 298 => 1, - 308 => 1, - 311 => 1, - 321 => 1, - 324 => 1, - 334 => 1, - 345 => 1, - 357 => 1, - 360 => 1, - 371 => 1, - 389 => 2, - 390 => 2, - 401 => 1, - 414 => 1, - 416 => 1, - 426 => 2, - 427 => 2, - 538 => 1, - 540 => 1, - 941 => 1, - ]; - case 'FunctionCommentUnitTest.1.inc': - return []; + case 'FunctionCommentUnitTest.inc': + return [ + 12 => 1, + 14 => 1, + 33 => 1, + 43 => 1, + 53 => 1, + 62 => 1, + 71 => 1, + 78 => 1, + 87 => 1, + 92 => 1, + 101 => 1, + 113 => 1, + 126 => 2, + 147 => 1, + 148 => 2, + 187 => 1, + 195 => 1, + 205 => 1, + 215 => 1, + 216 => 1, + 225 => 3, + 233 => 1, + 235 => 1, + 237 => 1, + 248 => 1, + 250 => 1, + 252 => 1, + 254 => 1, + 256 => 1, + 298 => 1, + 308 => 1, + 311 => 1, + 321 => 1, + 324 => 1, + 334 => 1, + 345 => 1, + 357 => 1, + 360 => 1, + 371 => 1, + 389 => 2, + 390 => 2, + 401 => 1, + 414 => 1, + 416 => 1, + 426 => 2, + 427 => 2, + 538 => 1, + 540 => 1, + 941 => 1, + ]; + case 'FunctionCommentUnitTest.1.inc': + return []; - case 'FunctionCommentUnitTest.2.inc': - return [8 => 1]; + case 'FunctionCommentUnitTest.2.inc': + return [8 => 1]; }//end switch return []; - - }//end getErrorList() + } /** @@ -98,8 +97,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/GenderNeutralCommentUnitTest.php b/tests/Drupal/Commenting/GenderNeutralCommentUnitTest.php index 59253d1b..065b78df 100644 --- a/tests/Drupal/Commenting/GenderNeutralCommentUnitTest.php +++ b/tests/Drupal/Commenting/GenderNeutralCommentUnitTest.php @@ -36,8 +36,7 @@ protected function getErrorList(string $testFile): array 27 => 1, 31 => 1, ]; - - }//end getErrorList() + } /** @@ -53,8 +52,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/HookCommentUnitTest.php b/tests/Drupal/Commenting/HookCommentUnitTest.php index 1662dfbc..02d76b0a 100644 --- a/tests/Drupal/Commenting/HookCommentUnitTest.php +++ b/tests/Drupal/Commenting/HookCommentUnitTest.php @@ -21,8 +21,7 @@ class HookCommentUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return [9 => 1]; - - }//end getErrorList() + } /** @@ -38,8 +37,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/InlineCommentUnitTest.php b/tests/Drupal/Commenting/InlineCommentUnitTest.php index 0ad6b153..0b015b7f 100644 --- a/tests/Drupal/Commenting/InlineCommentUnitTest.php +++ b/tests/Drupal/Commenting/InlineCommentUnitTest.php @@ -36,8 +36,7 @@ protected function getErrorList(string $testFile): array 127 => 1, 148 => 1, ]; - - }//end getErrorList() + } /** @@ -53,8 +52,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [16 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/InlineVariableCommentUnitTest.php b/tests/Drupal/Commenting/InlineVariableCommentUnitTest.php index 12e1987a..2466ed86 100644 --- a/tests/Drupal/Commenting/InlineVariableCommentUnitTest.php +++ b/tests/Drupal/Commenting/InlineVariableCommentUnitTest.php @@ -21,8 +21,7 @@ class InlineVariableCommentUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -46,8 +45,5 @@ protected function getWarningList(string $testFile): array 17 => 1, 18 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/PostStatementCommentUnitTest.php b/tests/Drupal/Commenting/PostStatementCommentUnitTest.php index 5d24be07..e42895c2 100644 --- a/tests/Drupal/Commenting/PostStatementCommentUnitTest.php +++ b/tests/Drupal/Commenting/PostStatementCommentUnitTest.php @@ -21,20 +21,19 @@ class PostStatementCommentUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { switch ($testFile) { - case 'PostStatementCommentUnitTest.inc': - return [ - 3 => 1, - 7 => 1, - ]; - case 'PostStatementCommentUnitTest.1.inc': - return [1 => 1]; - case 'PostStatementCommentUnitTest.2.inc': - return [6 => 1]; + case 'PostStatementCommentUnitTest.inc': + return [ + 3 => 1, + 7 => 1, + ]; + case 'PostStatementCommentUnitTest.1.inc': + return [1 => 1]; + case 'PostStatementCommentUnitTest.2.inc': + return [6 => 1]; } return []; - - }//end getErrorList() + } /** @@ -50,8 +49,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/TodoCommentUnitTest.php b/tests/Drupal/Commenting/TodoCommentUnitTest.php index d50ecd73..6ae08257 100644 --- a/tests/Drupal/Commenting/TodoCommentUnitTest.php +++ b/tests/Drupal/Commenting/TodoCommentUnitTest.php @@ -21,8 +21,7 @@ class TodoCommentUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -39,8 +38,5 @@ protected function getWarningList(string $testFile): array { $warningList = (array_fill_keys(range(16, 34), 1) + array_fill_keys(range(38, 40), 1) + array_fill_keys(range(55, 73), 1) + array_fill_keys(range(75, 77), 1)); return $warningList; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Commenting/VariableCommentUnitTest.php b/tests/Drupal/Commenting/VariableCommentUnitTest.php index 0b764d18..7f1ea813 100644 --- a/tests/Drupal/Commenting/VariableCommentUnitTest.php +++ b/tests/Drupal/Commenting/VariableCommentUnitTest.php @@ -28,8 +28,7 @@ protected function getErrorList(string $testFile): array 45 => 1, 47 => 1, ]; - - }//end getErrorList() + } /** @@ -45,8 +44,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/ControlStructures/ControlSignatureUnitTest.php b/tests/Drupal/ControlStructures/ControlSignatureUnitTest.php index 2578afe8..1d7dc597 100644 --- a/tests/Drupal/ControlStructures/ControlSignatureUnitTest.php +++ b/tests/Drupal/ControlStructures/ControlSignatureUnitTest.php @@ -27,8 +27,7 @@ protected function getErrorList(string $testFile): array 6 => 1, 8 => 1, ]; - - }//end getErrorList() + } /** @@ -44,8 +43,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/ControlStructures/ElseIfUnitTest.php b/tests/Drupal/ControlStructures/ElseIfUnitTest.php index 87431df1..82396a03 100644 --- a/tests/Drupal/ControlStructures/ElseIfUnitTest.php +++ b/tests/Drupal/ControlStructures/ElseIfUnitTest.php @@ -24,8 +24,7 @@ protected function getErrorList(string $testFile): array 6 => 1, 9 => 1, ]; - - }//end getErrorList() + } /** @@ -41,8 +40,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Files/EndFileNewlineUnitTest.php b/tests/Drupal/Files/EndFileNewlineUnitTest.php index 4a979394..94d21755 100644 --- a/tests/Drupal/Files/EndFileNewlineUnitTest.php +++ b/tests/Drupal/Files/EndFileNewlineUnitTest.php @@ -28,8 +28,7 @@ protected function getErrorList(string $testFile): array // code line in them). return [1 => 1]; } - - }//end getErrorList() + } /** @@ -45,8 +44,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Files/FileEncodingUnitTest.php b/tests/Drupal/Files/FileEncodingUnitTest.php index 0271231f..1ee06bef 100644 --- a/tests/Drupal/Files/FileEncodingUnitTest.php +++ b/tests/Drupal/Files/FileEncodingUnitTest.php @@ -21,8 +21,7 @@ class FileEncodingUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,8 +37,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [1 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Files/LineLengthUnitTest.php b/tests/Drupal/Files/LineLengthUnitTest.php index 367e2e6e..f8b4bb4d 100644 --- a/tests/Drupal/Files/LineLengthUnitTest.php +++ b/tests/Drupal/Files/LineLengthUnitTest.php @@ -21,8 +21,7 @@ class LineLengthUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,8 +37,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Files/TxtFileLineLengthUnitTest.php b/tests/Drupal/Files/TxtFileLineLengthUnitTest.php index 4f5d57f0..ae030459 100644 --- a/tests/Drupal/Files/TxtFileLineLengthUnitTest.php +++ b/tests/Drupal/Files/TxtFileLineLengthUnitTest.php @@ -21,8 +21,7 @@ class TxtFileLineLengthUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,8 +37,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [1 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Formatting/MultipleStatementAlignmentUnitTest.php b/tests/Drupal/Formatting/MultipleStatementAlignmentUnitTest.php index c82f4b37..6502678c 100644 --- a/tests/Drupal/Formatting/MultipleStatementAlignmentUnitTest.php +++ b/tests/Drupal/Formatting/MultipleStatementAlignmentUnitTest.php @@ -31,8 +31,7 @@ protected function getErrorList(string $testFile): array 20 => 1, 30 => 1, ]; - - }//end getErrorList() + } /** @@ -48,8 +47,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Formatting/SpaceUnaryOperatorUnitTest.php b/tests/Drupal/Formatting/SpaceUnaryOperatorUnitTest.php index ced65f2d..809e2377 100644 --- a/tests/Drupal/Formatting/SpaceUnaryOperatorUnitTest.php +++ b/tests/Drupal/Formatting/SpaceUnaryOperatorUnitTest.php @@ -27,8 +27,7 @@ protected function getErrorList(string $testFile): array 6 => 1, 7 => 1, ]; - - }//end getErrorList() + } /** @@ -44,8 +43,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Functions/MultiLineFunctionDeclarationUnitTest.php b/tests/Drupal/Functions/MultiLineFunctionDeclarationUnitTest.php index fa49aa50..1758bcaa 100644 --- a/tests/Drupal/Functions/MultiLineFunctionDeclarationUnitTest.php +++ b/tests/Drupal/Functions/MultiLineFunctionDeclarationUnitTest.php @@ -26,8 +26,7 @@ protected function getErrorList(string $testFile): array 38 => 3, 41 => 2, ]; - - }//end getErrorList() + } /** @@ -43,8 +42,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() + } /** @@ -59,8 +57,5 @@ protected function shouldSkipTest() } return false; - - }//end shouldSkipTest() - - -}//end class + } +} diff --git a/tests/Drupal/InfoFiles/AutoAddedKeysUnitTest.php b/tests/Drupal/InfoFiles/AutoAddedKeysUnitTest.php index 7ee8e65c..16c62d39 100644 --- a/tests/Drupal/InfoFiles/AutoAddedKeysUnitTest.php +++ b/tests/Drupal/InfoFiles/AutoAddedKeysUnitTest.php @@ -25,8 +25,7 @@ class AutoAddedKeysUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -42,8 +41,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [1 => 3]; - - }//end getWarningList() + } /** @@ -56,11 +54,8 @@ protected function getWarningList(string $testFile): array protected function getTestFiles($testFileBase): array { return [ - __DIR__.'/drupal7/test.info', - __DIR__.'/drupal8/test.info.yml', + __DIR__ . '/drupal7/test.info', + __DIR__ . '/drupal8/test.info.yml', ]; - - }//end getTestFiles() - - -}//end class + } +} diff --git a/tests/Drupal/InfoFiles/ClassFilesUnitTest.php b/tests/Drupal/InfoFiles/ClassFilesUnitTest.php index be90e700..f705f7c7 100644 --- a/tests/Drupal/InfoFiles/ClassFilesUnitTest.php +++ b/tests/Drupal/InfoFiles/ClassFilesUnitTest.php @@ -21,8 +21,7 @@ class ClassFilesUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,8 +37,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() + } /** @@ -51,9 +49,6 @@ protected function getWarningList(string $testFile): array */ protected function getTestFiles($testFileBase): array { - return [__DIR__.'/drupal7/class_files.info']; - - }//end getTestFiles() - - -}//end class + return [__DIR__ . '/drupal7/class_files.info']; + } +} diff --git a/tests/Drupal/InfoFiles/DependenciesArrayUnitTest.php b/tests/Drupal/InfoFiles/DependenciesArrayUnitTest.php index 15db61ce..449d7c77 100644 --- a/tests/Drupal/InfoFiles/DependenciesArrayUnitTest.php +++ b/tests/Drupal/InfoFiles/DependenciesArrayUnitTest.php @@ -24,8 +24,7 @@ class DependenciesArrayUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return [3 => 1]; - - }//end getErrorList() + } /** @@ -41,8 +40,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() + } /** @@ -55,10 +53,7 @@ protected function getWarningList(string $testFile): array protected function getTestFiles($testFileBase): array { return [ - __DIR__.'/drupal8/dependencies_array.info.yml', + __DIR__ . '/drupal8/dependencies_array.info.yml', ]; - - }//end getTestFiles() - - -}//end class + } +} diff --git a/tests/Drupal/InfoFiles/DuplicateEntryUnitTest.php b/tests/Drupal/InfoFiles/DuplicateEntryUnitTest.php index f31cf43a..30decd91 100644 --- a/tests/Drupal/InfoFiles/DuplicateEntryUnitTest.php +++ b/tests/Drupal/InfoFiles/DuplicateEntryUnitTest.php @@ -27,8 +27,7 @@ class DuplicateEntryUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return [1 => 1]; - - }//end getErrorList() + } /** @@ -44,8 +43,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() + } /** @@ -57,9 +55,6 @@ protected function getWarningList(string $testFile): array */ protected function getTestFiles($testFileBase): array { - return [__DIR__.'/drupal7/test.info']; - - }//end getTestFiles() - - -}//end class + return [__DIR__ . '/drupal7/test.info']; + } +} diff --git a/tests/Drupal/NamingConventions/ValidClassNameUnitTest.php b/tests/Drupal/NamingConventions/ValidClassNameUnitTest.php index 37803750..ae96ee28 100644 --- a/tests/Drupal/NamingConventions/ValidClassNameUnitTest.php +++ b/tests/Drupal/NamingConventions/ValidClassNameUnitTest.php @@ -34,8 +34,7 @@ protected function getErrorList(string $testFile): array 24 => 1, 25 => 1, ]; - - }//end getErrorList() + } /** @@ -51,8 +50,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.php b/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.php index 28a5135b..6f776f31 100644 --- a/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.php +++ b/tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.php @@ -25,8 +25,7 @@ protected function getErrorList(string $testFile): array 7 => 2, 9 => 1, ]; - - }//end getErrorList() + } /** @@ -42,8 +41,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/NamingConventions/ValidFunctionNameUnitTest.php b/tests/Drupal/NamingConventions/ValidFunctionNameUnitTest.php index 416f1ef9..34563ec5 100644 --- a/tests/Drupal/NamingConventions/ValidFunctionNameUnitTest.php +++ b/tests/Drupal/NamingConventions/ValidFunctionNameUnitTest.php @@ -21,19 +21,18 @@ class ValidFunctionNameUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { switch ($testFile) { - case 'ValidFunctionNameUnitTest.inc': - return [ - 3 => 1, - 4 => 1, - 8 => 1, - ]; - case 'valid_function_name_test.module': - return [24 => 1]; + case 'ValidFunctionNameUnitTest.inc': + return [ + 3 => 1, + 4 => 1, + 8 => 1, + ]; + case 'valid_function_name_test.module': + return [24 => 1]; } return []; - - }//end getErrorList() + } /** @@ -49,8 +48,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() + } /** @@ -62,12 +60,9 @@ protected function getWarningList(string $testFile): array */ protected function getTestFiles($testFileBase): array { - $testFiles[] = __DIR__.'/valid_function_name_test.module'; - $testFiles[] = __DIR__.'/ValidFunctionNameUnitTest.inc'; + $testFiles[] = __DIR__ . '/valid_function_name_test.module'; + $testFiles[] = __DIR__ . '/ValidFunctionNameUnitTest.inc'; return $testFiles; - - }//end getTestFiles() - - -}//end class + } +} diff --git a/tests/Drupal/NamingConventions/ValidVariableNameUnitTest.php b/tests/Drupal/NamingConventions/ValidVariableNameUnitTest.php index ddf1795d..d6d5ea6e 100644 --- a/tests/Drupal/NamingConventions/ValidVariableNameUnitTest.php +++ b/tests/Drupal/NamingConventions/ValidVariableNameUnitTest.php @@ -25,8 +25,7 @@ protected function getErrorList(string $testFile): array 46 => 1, 57 => 1, ]; - - }//end getErrorList() + } /** @@ -42,8 +41,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Scope/MethodScopeUnitTest.php b/tests/Drupal/Scope/MethodScopeUnitTest.php index 8cbc70a6..37693b72 100644 --- a/tests/Drupal/Scope/MethodScopeUnitTest.php +++ b/tests/Drupal/Scope/MethodScopeUnitTest.php @@ -24,8 +24,7 @@ protected function getErrorList(string $testFile): array 8 => 1, 15 => 1, ]; - - }//end getErrorList() + } /** @@ -41,8 +40,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Semantics/ConstantNameUnitTest.php b/tests/Drupal/Semantics/ConstantNameUnitTest.php index 621b7ba9..b71c1201 100644 --- a/tests/Drupal/Semantics/ConstantNameUnitTest.php +++ b/tests/Drupal/Semantics/ConstantNameUnitTest.php @@ -18,11 +18,10 @@ class ConstantNameUnitTest extends CoderSniffUnitTest protected function getTestFiles($testFileBase): array { return [ - __DIR__.'/constant_test.install', - __DIR__.'/constant_test.module', + __DIR__ . '/constant_test.install', + __DIR__ . '/constant_test.module', ]; - - }//end getTestFiles() + } /** @@ -38,8 +37,7 @@ protected function getTestFiles($testFileBase): array protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -60,8 +58,5 @@ protected function getWarningList(string $testFile): array 3 => 1, 6 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Semantics/FunctionTUnitTest.php b/tests/Drupal/Semantics/FunctionTUnitTest.php index 0be35c42..ee3cdc8f 100644 --- a/tests/Drupal/Semantics/FunctionTUnitTest.php +++ b/tests/Drupal/Semantics/FunctionTUnitTest.php @@ -21,8 +21,7 @@ class FunctionTUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return [30 => 1]; - - }//end getErrorList() + } /** @@ -45,8 +44,5 @@ protected function getWarningList(string $testFile): array 30 => 1, 34 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Semantics/FunctionTriggerErrorUnitTest.php b/tests/Drupal/Semantics/FunctionTriggerErrorUnitTest.php index c614bf09..20c27915 100644 --- a/tests/Drupal/Semantics/FunctionTriggerErrorUnitTest.php +++ b/tests/Drupal/Semantics/FunctionTriggerErrorUnitTest.php @@ -21,24 +21,23 @@ class FunctionTriggerErrorUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { switch ($testFile) { - case 'FunctionTriggerErrorUnitTest.1.inc': - return [ - 34 => 1, - 36 => 1, - 38 => 1, - 40 => 1, - 42 => 1, - 44 => 1, - ]; - case 'FunctionTriggerErrorUnitTest.2.inc': - return [29 => 1]; - case 'FunctionTriggerErrorUnitTest.3.inc': - return [14 => 1]; - default: - return []; + case 'FunctionTriggerErrorUnitTest.1.inc': + return [ + 34 => 1, + 36 => 1, + 38 => 1, + 40 => 1, + 42 => 1, + 44 => 1, + ]; + case 'FunctionTriggerErrorUnitTest.2.inc': + return [29 => 1]; + case 'FunctionTriggerErrorUnitTest.3.inc': + return [14 => 1]; + default: + return []; } - - }//end getErrorList() + } /** @@ -54,29 +53,26 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { switch ($testFile) { - case 'FunctionTriggerErrorUnitTest.1.inc': - return [ - 46 => 1, - 48 => 1, - 50 => 1, - 52 => 1, - 54 => 1, - 56 => 1, - 58 => 1, - 60 => 1, - 62 => 1, - 64 => 1, - 66 => 1, - 68 => 1, - 70 => 1, - ]; - case 'FunctionTriggerErrorUnitTest.2.inc': - case 'FunctionTriggerErrorUnitTest.3.inc': - default: - return []; + case 'FunctionTriggerErrorUnitTest.1.inc': + return [ + 46 => 1, + 48 => 1, + 50 => 1, + 52 => 1, + 54 => 1, + 56 => 1, + 58 => 1, + 60 => 1, + 62 => 1, + 64 => 1, + 66 => 1, + 68 => 1, + 70 => 1, + ]; + case 'FunctionTriggerErrorUnitTest.2.inc': + case 'FunctionTriggerErrorUnitTest.3.inc': + default: + return []; }//end switch - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Semantics/FunctionWatchdogUnitTest.php b/tests/Drupal/Semantics/FunctionWatchdogUnitTest.php index 9085f76d..d8d6c63a 100644 --- a/tests/Drupal/Semantics/FunctionWatchdogUnitTest.php +++ b/tests/Drupal/Semantics/FunctionWatchdogUnitTest.php @@ -21,8 +21,7 @@ class FunctionWatchdogUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return [3 => 1]; - - }//end getErrorList() + } /** @@ -38,8 +37,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Semantics/RemoteAddressUnitTest.php b/tests/Drupal/Semantics/RemoteAddressUnitTest.php index f7b32668..ee898f06 100644 --- a/tests/Drupal/Semantics/RemoteAddressUnitTest.php +++ b/tests/Drupal/Semantics/RemoteAddressUnitTest.php @@ -24,8 +24,7 @@ protected function getErrorList(string $testFile): array 12 => 1, 19 => 1, ]; - - }//end getErrorList() + } /** @@ -41,8 +40,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/Semantics/UnsilencedDeprecationUnitTest.php b/tests/Drupal/Semantics/UnsilencedDeprecationUnitTest.php index fd99c54e..4d89af78 100644 --- a/tests/Drupal/Semantics/UnsilencedDeprecationUnitTest.php +++ b/tests/Drupal/Semantics/UnsilencedDeprecationUnitTest.php @@ -21,8 +21,7 @@ class UnsilencedDeprecationUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return [19 => 1]; - - }//end getErrorList() + } /** @@ -38,8 +37,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/WhiteSpace/CloseBracketSpacingUnitTest.php b/tests/Drupal/WhiteSpace/CloseBracketSpacingUnitTest.php index f316281b..262f7b5c 100644 --- a/tests/Drupal/WhiteSpace/CloseBracketSpacingUnitTest.php +++ b/tests/Drupal/WhiteSpace/CloseBracketSpacingUnitTest.php @@ -24,8 +24,7 @@ protected function getErrorList(string $testFile): array 3 => 1, 7 => 1, ]; - - }//end getErrorList() + } /** @@ -41,8 +40,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/WhiteSpace/CommaUnitTest.php b/tests/Drupal/WhiteSpace/CommaUnitTest.php index 97a7b8a3..18ef4c0f 100644 --- a/tests/Drupal/WhiteSpace/CommaUnitTest.php +++ b/tests/Drupal/WhiteSpace/CommaUnitTest.php @@ -28,8 +28,7 @@ protected function getErrorList(string $testFile): array 9 => 1, 11 => 1, ]; - - }//end getErrorList() + } /** @@ -45,8 +44,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/WhiteSpace/ObjectOperatorIndentUnitTest.php b/tests/Drupal/WhiteSpace/ObjectOperatorIndentUnitTest.php index 00f08fc9..6d707452 100644 --- a/tests/Drupal/WhiteSpace/ObjectOperatorIndentUnitTest.php +++ b/tests/Drupal/WhiteSpace/ObjectOperatorIndentUnitTest.php @@ -26,8 +26,7 @@ protected function getErrorList(string $testFile): array 28 => 1, 30 => 1, ]; - - }//end getErrorList() + } /** @@ -43,8 +42,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/WhiteSpace/ObjectOperatorSpacingUnitTest.php b/tests/Drupal/WhiteSpace/ObjectOperatorSpacingUnitTest.php index 3ce4ca3c..4315694e 100644 --- a/tests/Drupal/WhiteSpace/ObjectOperatorSpacingUnitTest.php +++ b/tests/Drupal/WhiteSpace/ObjectOperatorSpacingUnitTest.php @@ -24,8 +24,7 @@ protected function getErrorList(string $testFile): array 9 => 1, 10 => 1, ]; - - }//end getErrorList() + } /** @@ -41,8 +40,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/WhiteSpace/OpenBracketSpacingUnitTest.php b/tests/Drupal/WhiteSpace/OpenBracketSpacingUnitTest.php index 5f5e14bb..1ce1724f 100644 --- a/tests/Drupal/WhiteSpace/OpenBracketSpacingUnitTest.php +++ b/tests/Drupal/WhiteSpace/OpenBracketSpacingUnitTest.php @@ -24,8 +24,7 @@ protected function getErrorList(string $testFile): array 3 => 1, 5 => 1, ]; - - }//end getErrorList() + } /** @@ -41,8 +40,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/WhiteSpace/OpenTagNewlineUnitTest.php b/tests/Drupal/WhiteSpace/OpenTagNewlineUnitTest.php index d0fdd1b0..909f9660 100644 --- a/tests/Drupal/WhiteSpace/OpenTagNewlineUnitTest.php +++ b/tests/Drupal/WhiteSpace/OpenTagNewlineUnitTest.php @@ -21,8 +21,7 @@ class OpenTagNewlineUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return [1 => 1]; - - }//end getErrorList() + } /** @@ -38,8 +37,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/WhiteSpace/ScopeClosingBraceUnitTest.php b/tests/Drupal/WhiteSpace/ScopeClosingBraceUnitTest.php index 9ee4491b..67ba18f9 100644 --- a/tests/Drupal/WhiteSpace/ScopeClosingBraceUnitTest.php +++ b/tests/Drupal/WhiteSpace/ScopeClosingBraceUnitTest.php @@ -21,17 +21,16 @@ class ScopeClosingBraceUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { switch ($testFile) { - case 'ScopeClosingBraceUnitTest.inc': - return [ - 16 => 1, - 23 => 1, - 29 => 1, - ]; + case 'ScopeClosingBraceUnitTest.inc': + return [ + 16 => 1, + 23 => 1, + 29 => 1, + ]; } return []; - - }//end getErrorList() + } /** @@ -47,8 +46,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() + } /** @@ -63,8 +61,5 @@ protected function shouldSkipTest() } return false; - - }//end shouldSkipTest() - - -}//end class + } +} diff --git a/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.php b/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.php index 8659f668..e1d4f641 100644 --- a/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.php +++ b/tests/Drupal/WhiteSpace/ScopeIndentUnitTest.php @@ -29,8 +29,7 @@ protected function getErrorList(string $testFile): array 216 => 1, 222 => 1, ]; - - }//end getErrorList() + } /** @@ -46,8 +45,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/Drupal/bad/BadUnitTest.php b/tests/Drupal/bad/BadUnitTest.php index 2124fbe3..b40209d8 100644 --- a/tests/Drupal/bad/BadUnitTest.php +++ b/tests/Drupal/bad/BadUnitTest.php @@ -431,7 +431,7 @@ protected function getErrorList(string $testFile): array return []; - }//end getErrorList() + } /** @@ -482,7 +482,7 @@ protected function getWarningList(string $testFile): array return []; - }//end getWarningList() + } /** @@ -508,7 +508,7 @@ protected function getTestFiles($testFileBase): array sort($testFiles); return $testFiles; - }//end getTestFiles() + } /** @@ -521,7 +521,7 @@ protected function checkAllSniffCodes() // We want to test all sniffs defined in the standard. return true; - }//end checkAllSniffCodes() + } /** @@ -537,7 +537,7 @@ protected function shouldSkipTest() return false; - }//end shouldSkipTest() + } -}//end class +} \ No newline at end of file diff --git a/tests/Drupal/good/GoodUnitTest.php b/tests/Drupal/good/GoodUnitTest.php index 33eeee04..e8e98953 100644 --- a/tests/Drupal/good/GoodUnitTest.php +++ b/tests/Drupal/good/GoodUnitTest.php @@ -28,7 +28,7 @@ protected function getErrorList(string $testFile): array { return []; - }//end getErrorList() + } /** @@ -45,7 +45,7 @@ protected function getWarningList(string $testFile): array { return []; - }//end getWarningList() + } /** @@ -72,7 +72,7 @@ protected function getTestFiles($testFileBase): array sort($testFiles); return $testFiles; - }//end getTestFiles() + } /** @@ -85,7 +85,7 @@ protected function checkAllSniffCodes() // We want to test all sniffs defined in the standard. return true; - }//end checkAllSniffCodes() + } -}//end class +} \ No newline at end of file diff --git a/tests/DrupalPractice/Commenting/AuthorTagUnitTest.php b/tests/DrupalPractice/Commenting/AuthorTagUnitTest.php index 3ad028eb..737c2a8f 100644 --- a/tests/DrupalPractice/Commenting/AuthorTagUnitTest.php +++ b/tests/DrupalPractice/Commenting/AuthorTagUnitTest.php @@ -21,8 +21,7 @@ class AuthorTagUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -41,8 +40,5 @@ protected function getWarningList(string $testFile): array 7 => 1, 13 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Commenting/CommentEmptyLineUnitTest.php b/tests/DrupalPractice/Commenting/CommentEmptyLineUnitTest.php index aa2ab3f5..b2a0d2ed 100644 --- a/tests/DrupalPractice/Commenting/CommentEmptyLineUnitTest.php +++ b/tests/DrupalPractice/Commenting/CommentEmptyLineUnitTest.php @@ -30,8 +30,7 @@ class CommentEmptyLineUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -47,8 +46,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [3 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Commenting/ExpectedExceptionUnitTest.php b/tests/DrupalPractice/Commenting/ExpectedExceptionUnitTest.php index 63e07a6d..b5062e2c 100644 --- a/tests/DrupalPractice/Commenting/ExpectedExceptionUnitTest.php +++ b/tests/DrupalPractice/Commenting/ExpectedExceptionUnitTest.php @@ -21,8 +21,7 @@ class ExpectedExceptionUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -43,8 +42,5 @@ protected function getWarningList(string $testFile): array 10 => 1, 11 => 1,0 ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Constants/GlobalConstantUnitTest.php b/tests/DrupalPractice/Constants/GlobalConstantUnitTest.php index b55c975c..7db66bbc 100644 --- a/tests/DrupalPractice/Constants/GlobalConstantUnitTest.php +++ b/tests/DrupalPractice/Constants/GlobalConstantUnitTest.php @@ -27,8 +27,7 @@ class GlobalConstantUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -47,8 +46,5 @@ protected function getWarningList(string $testFile): array 3 => 1, 8 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Constants/GlobalDefineUnitTest.php b/tests/DrupalPractice/Constants/GlobalDefineUnitTest.php index 4d16de4d..e982d881 100644 --- a/tests/DrupalPractice/Constants/GlobalDefineUnitTest.php +++ b/tests/DrupalPractice/Constants/GlobalDefineUnitTest.php @@ -27,8 +27,7 @@ class GlobalDefineUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -47,8 +46,5 @@ protected function getWarningList(string $testFile): array 3 => 1, 8 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/FunctionCalls/CheckPlainUnitTest.php b/tests/DrupalPractice/FunctionCalls/CheckPlainUnitTest.php index a0054256..6159f6ee 100644 --- a/tests/DrupalPractice/FunctionCalls/CheckPlainUnitTest.php +++ b/tests/DrupalPractice/FunctionCalls/CheckPlainUnitTest.php @@ -30,8 +30,7 @@ class CheckPlainUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -47,8 +46,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [3 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/FunctionCalls/CurlSslVerifierUnitTest.php b/tests/DrupalPractice/FunctionCalls/CurlSslVerifierUnitTest.php index 5fed75da..e94f5dc1 100644 --- a/tests/DrupalPractice/FunctionCalls/CurlSslVerifierUnitTest.php +++ b/tests/DrupalPractice/FunctionCalls/CurlSslVerifierUnitTest.php @@ -27,8 +27,7 @@ class CurlSslVerifierUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -44,8 +43,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [4 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/FunctionCalls/DbQueryUnitTest.php b/tests/DrupalPractice/FunctionCalls/DbQueryUnitTest.php index 7ff53422..3177ef5e 100644 --- a/tests/DrupalPractice/FunctionCalls/DbQueryUnitTest.php +++ b/tests/DrupalPractice/FunctionCalls/DbQueryUnitTest.php @@ -30,8 +30,7 @@ class DbQueryUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -53,8 +52,5 @@ protected function getWarningList(string $testFile): array 12 => 1, 18 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/FunctionCalls/DbSelectBracesUnitTest.php b/tests/DrupalPractice/FunctionCalls/DbSelectBracesUnitTest.php index e38393bb..77f7f154 100644 --- a/tests/DrupalPractice/FunctionCalls/DbSelectBracesUnitTest.php +++ b/tests/DrupalPractice/FunctionCalls/DbSelectBracesUnitTest.php @@ -30,8 +30,7 @@ class DbSelectBracesUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -47,8 +46,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [3 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/FunctionCalls/DefaultValueSanitizeUnitTest.php b/tests/DrupalPractice/FunctionCalls/DefaultValueSanitizeUnitTest.php index d50e1013..37927b50 100644 --- a/tests/DrupalPractice/FunctionCalls/DefaultValueSanitizeUnitTest.php +++ b/tests/DrupalPractice/FunctionCalls/DefaultValueSanitizeUnitTest.php @@ -27,8 +27,7 @@ class DefaultValueSanitizeUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -44,8 +43,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [6 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/FunctionCalls/InsecureUnserializeUnitTest.php b/tests/DrupalPractice/FunctionCalls/InsecureUnserializeUnitTest.php index 5a3c09b9..e4e958e8 100644 --- a/tests/DrupalPractice/FunctionCalls/InsecureUnserializeUnitTest.php +++ b/tests/DrupalPractice/FunctionCalls/InsecureUnserializeUnitTest.php @@ -37,8 +37,7 @@ protected function getErrorList(string $testFile): array 22 => 1, 26 => 1, ]; - - }//end getErrorList() + } /** @@ -54,8 +53,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/FunctionCalls/TCheckPlainUnitTest.php b/tests/DrupalPractice/FunctionCalls/TCheckPlainUnitTest.php index 6f6ba66a..07a68054 100644 --- a/tests/DrupalPractice/FunctionCalls/TCheckPlainUnitTest.php +++ b/tests/DrupalPractice/FunctionCalls/TCheckPlainUnitTest.php @@ -27,8 +27,7 @@ class TCheckPlainUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -44,8 +43,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [8 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/FunctionCalls/VariableSetSanitizeUnitTest.php b/tests/DrupalPractice/FunctionCalls/VariableSetSanitizeUnitTest.php index c48e6214..5fcae885 100644 --- a/tests/DrupalPractice/FunctionCalls/VariableSetSanitizeUnitTest.php +++ b/tests/DrupalPractice/FunctionCalls/VariableSetSanitizeUnitTest.php @@ -27,8 +27,7 @@ class VariableSetSanitizeUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -44,8 +43,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [3 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/FunctionDefinitions/AccessHookMenuUnitTest.php b/tests/DrupalPractice/FunctionDefinitions/AccessHookMenuUnitTest.php index 66bb3410..1d893c8c 100644 --- a/tests/DrupalPractice/FunctionDefinitions/AccessHookMenuUnitTest.php +++ b/tests/DrupalPractice/FunctionDefinitions/AccessHookMenuUnitTest.php @@ -27,8 +27,7 @@ class AccessHookMenuUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -44,8 +43,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [24 => 1]; - - }//end getWarningList() + } /** @@ -57,9 +55,6 @@ protected function getWarningList(string $testFile): array */ protected function getTestFiles($testFileBase): array { - return [__DIR__.'/test.module']; - - }//end getTestFiles() - - -}//end class + return [__DIR__ . '/test.module']; + } +} diff --git a/tests/DrupalPractice/FunctionDefinitions/FormAlterDocUnitTest.php b/tests/DrupalPractice/FunctionDefinitions/FormAlterDocUnitTest.php index c39549eb..12128866 100644 --- a/tests/DrupalPractice/FunctionDefinitions/FormAlterDocUnitTest.php +++ b/tests/DrupalPractice/FunctionDefinitions/FormAlterDocUnitTest.php @@ -21,8 +21,7 @@ class FormAlterDocUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,8 +37,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [31 => 1]; - - }//end getWarningList() + } /** @@ -51,9 +49,6 @@ protected function getWarningList(string $testFile): array */ protected function getTestFiles($testFileBase): array { - return [__DIR__.'/test.module']; - - }//end getTestFiles() - - -}//end class + return [__DIR__ . '/test.module']; + } +} diff --git a/tests/DrupalPractice/FunctionDefinitions/HookInitCssUnitTest.php b/tests/DrupalPractice/FunctionDefinitions/HookInitCssUnitTest.php index c0c8e8b9..606cdb5a 100644 --- a/tests/DrupalPractice/FunctionDefinitions/HookInitCssUnitTest.php +++ b/tests/DrupalPractice/FunctionDefinitions/HookInitCssUnitTest.php @@ -27,8 +27,7 @@ class HookInitCssUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -47,8 +46,7 @@ protected function getWarningList(string $testFile): array 7 => 1, 14 => 1, ]; - - }//end getWarningList() + } /** @@ -60,9 +58,6 @@ protected function getWarningList(string $testFile): array */ protected function getTestFiles($testFileBase): array { - return [__DIR__.'/test.module']; - - }//end getTestFiles() - - -}//end class + return [__DIR__ . '/test.module']; + } +} diff --git a/tests/DrupalPractice/FunctionDefinitions/InstallTUnitTest.php b/tests/DrupalPractice/FunctionDefinitions/InstallTUnitTest.php index 4017da72..4caf5746 100644 --- a/tests/DrupalPractice/FunctionDefinitions/InstallTUnitTest.php +++ b/tests/DrupalPractice/FunctionDefinitions/InstallTUnitTest.php @@ -27,8 +27,7 @@ class InstallTUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return [12 => 1]; - - }//end getErrorList() + } /** @@ -44,8 +43,7 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() + } /** @@ -57,9 +55,6 @@ protected function getWarningList(string $testFile): array */ protected function getTestFiles($testFileBase): array { - return [__DIR__.'/test.install']; - - }//end getTestFiles() - - -}//end class + return [__DIR__ . '/test.install']; + } +} diff --git a/tests/DrupalPractice/General/ExceptionTUnitTest.php b/tests/DrupalPractice/General/ExceptionTUnitTest.php index 88d1ebb6..50995657 100644 --- a/tests/DrupalPractice/General/ExceptionTUnitTest.php +++ b/tests/DrupalPractice/General/ExceptionTUnitTest.php @@ -21,8 +21,7 @@ class ExceptionTUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -41,8 +40,5 @@ protected function getWarningList(string $testFile): array 6 => 1, 10 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/General/OptionsTUnitTest.php b/tests/DrupalPractice/General/OptionsTUnitTest.php index 07848b92..2d5718d0 100644 --- a/tests/DrupalPractice/General/OptionsTUnitTest.php +++ b/tests/DrupalPractice/General/OptionsTUnitTest.php @@ -27,8 +27,7 @@ class OptionsTUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -48,8 +47,5 @@ protected function getWarningList(string $testFile): array 31 => 1, 49 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/General/VariableNameUnitTest.php b/tests/DrupalPractice/General/VariableNameUnitTest.php index ed544885..7d246b2a 100644 --- a/tests/DrupalPractice/General/VariableNameUnitTest.php +++ b/tests/DrupalPractice/General/VariableNameUnitTest.php @@ -30,8 +30,7 @@ class VariableNameUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -47,8 +46,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [11 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/InfoFiles/CoreVersionRequirementUnitTest.php b/tests/DrupalPractice/InfoFiles/CoreVersionRequirementUnitTest.php index fd846bce..2897dc07 100644 --- a/tests/DrupalPractice/InfoFiles/CoreVersionRequirementUnitTest.php +++ b/tests/DrupalPractice/InfoFiles/CoreVersionRequirementUnitTest.php @@ -21,8 +21,7 @@ class CoreVersionRequirementUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,15 +37,14 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { switch ($testFile) { - case 'core_version.info.yml': - return [1 => 1]; - case 'core_version_test.info.yml': - return []; + case 'core_version.info.yml': + return [1 => 1]; + case 'core_version_test.info.yml': + return []; } return []; - - }//end getWarningList() + } /** @@ -59,12 +57,9 @@ protected function getWarningList(string $testFile): array protected function getTestFiles($testFileBase): array { return [ - __DIR__.'/core_version.info.yml', - __DIR__.'/core_version_test.info.yml', - __DIR__.'/core_version.config.info.yml', + __DIR__ . '/core_version.info.yml', + __DIR__ . '/core_version_test.info.yml', + __DIR__ . '/core_version.config.info.yml', ]; - - }//end getTestFiles() - - -}//end class + } +} diff --git a/tests/DrupalPractice/InfoFiles/DescriptionUnitTest.php b/tests/DrupalPractice/InfoFiles/DescriptionUnitTest.php index ce0fb6c4..9928a586 100644 --- a/tests/DrupalPractice/InfoFiles/DescriptionUnitTest.php +++ b/tests/DrupalPractice/InfoFiles/DescriptionUnitTest.php @@ -21,8 +21,7 @@ class DescriptionUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,15 +37,14 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { switch ($testFile) { - case 'description_missing.info.yml': - return [1 => 1]; - case 'description_empty.info.yml': - return [1 => 1]; + case 'description_missing.info.yml': + return [1 => 1]; + case 'description_empty.info.yml': + return [1 => 1]; } return []; - - }//end getWarningList() + } /** @@ -59,11 +57,8 @@ protected function getWarningList(string $testFile): array protected function getTestFiles($testFileBase): array { return [ - __DIR__.'/description_empty.info.yml', - __DIR__.'/description_missing.info.yml', + __DIR__ . '/description_empty.info.yml', + __DIR__ . '/description_missing.info.yml', ]; - - }//end getTestFiles() - - -}//end class + } +} diff --git a/tests/DrupalPractice/InfoFiles/NamespacedDependencyUnitTest.php b/tests/DrupalPractice/InfoFiles/NamespacedDependencyUnitTest.php index fac67b20..4172a028 100644 --- a/tests/DrupalPractice/InfoFiles/NamespacedDependencyUnitTest.php +++ b/tests/DrupalPractice/InfoFiles/NamespacedDependencyUnitTest.php @@ -21,8 +21,7 @@ class NamespacedDependencyUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,19 +37,18 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { switch ($testFile) { - case 'dependencies_test.info.yml': - return [ - 9 => 1, - 11 => 1, - 13 => 1, - ]; - case 'dependencies_theme.info.yml': - return []; + case 'dependencies_test.info.yml': + return [ + 9 => 1, + 11 => 1, + 13 => 1, + ]; + case 'dependencies_theme.info.yml': + return []; } return []; - - }//end getWarningList() + } /** @@ -63,11 +61,8 @@ protected function getWarningList(string $testFile): array protected function getTestFiles($testFileBase): array { return [ - __DIR__.'/dependencies_test.info.yml', - __DIR__.'/dependencies_theme.info.yml', + __DIR__ . '/dependencies_test.info.yml', + __DIR__ . '/dependencies_theme.info.yml', ]; - - }//end getTestFiles() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Objects/GlobalClassUnitTest.php b/tests/DrupalPractice/Objects/GlobalClassUnitTest.php index f96ab0ef..73c55e6b 100644 --- a/tests/DrupalPractice/Objects/GlobalClassUnitTest.php +++ b/tests/DrupalPractice/Objects/GlobalClassUnitTest.php @@ -21,8 +21,7 @@ class GlobalClassUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,17 +37,16 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { switch ($testFile) { - case 'GlobalClassUnitTest.inc': - return [9 => 1]; - case 'ExampleClassWithDependencyInjection.php': - return [24 => 1]; - case 'ExampleService.php': - return [23 => 1]; - default: - return []; + case 'GlobalClassUnitTest.inc': + return [9 => 1]; + case 'ExampleClassWithDependencyInjection.php': + return [24 => 1]; + case 'ExampleService.php': + return [23 => 1]; + default: + return []; } - - }//end getWarningList() + } /** @@ -61,14 +59,11 @@ protected function getWarningList(string $testFile): array protected function getTestFiles($testFileBase): array { return [ - __DIR__.'/GlobalClassUnitTest.inc', - __DIR__.'/drupal8/example.module', - __DIR__.'/drupal8/ExampleClass.php', - __DIR__.'/drupal8/ExampleClassWithDependencyInjection.php', - __DIR__.'/drupal8/ExampleService.php', + __DIR__ . '/GlobalClassUnitTest.inc', + __DIR__ . '/drupal8/example.module', + __DIR__ . '/drupal8/ExampleClass.php', + __DIR__ . '/drupal8/ExampleClassWithDependencyInjection.php', + __DIR__ . '/drupal8/ExampleService.php', ]; - - }//end getTestFiles() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Objects/GlobalDrupalUnitTest.php b/tests/DrupalPractice/Objects/GlobalDrupalUnitTest.php index 346e59de..d5764d23 100644 --- a/tests/DrupalPractice/Objects/GlobalDrupalUnitTest.php +++ b/tests/DrupalPractice/Objects/GlobalDrupalUnitTest.php @@ -21,8 +21,7 @@ class GlobalDrupalUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,17 +37,16 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { switch ($testFile) { - case 'GlobalDrupalUnitTest.inc': - return [6 => 1]; - case 'ExampleClassWithDependencyInjection.php': - return [17 => 1]; - case 'ExampleService.php': - return [16 => 1]; - default: - return []; + case 'GlobalDrupalUnitTest.inc': + return [6 => 1]; + case 'ExampleClassWithDependencyInjection.php': + return [17 => 1]; + case 'ExampleService.php': + return [16 => 1]; + default: + return []; } - - }//end getWarningList() + } /** @@ -61,14 +59,11 @@ protected function getWarningList(string $testFile): array protected function getTestFiles($testFileBase): array { return [ - __DIR__.'/GlobalDrupalUnitTest.inc', - __DIR__.'/drupal8/example.module', - __DIR__.'/drupal8/ExampleClass.php', - __DIR__.'/drupal8/ExampleClassWithDependencyInjection.php', - __DIR__.'/drupal8/ExampleService.php', + __DIR__ . '/GlobalDrupalUnitTest.inc', + __DIR__ . '/drupal8/example.module', + __DIR__ . '/drupal8/ExampleClass.php', + __DIR__ . '/drupal8/ExampleClassWithDependencyInjection.php', + __DIR__ . '/drupal8/ExampleService.php', ]; - - }//end getTestFiles() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Objects/GlobalFunctionUnitTest.php b/tests/DrupalPractice/Objects/GlobalFunctionUnitTest.php index 7c4f775b..12c29b4b 100644 --- a/tests/DrupalPractice/Objects/GlobalFunctionUnitTest.php +++ b/tests/DrupalPractice/Objects/GlobalFunctionUnitTest.php @@ -21,8 +21,7 @@ class GlobalFunctionUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,28 +37,27 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { switch ($testFile) { - case 'TestForm.php': - return [ - 6 => 1, - 8 => 1, - ]; - case 'ExampleClass.php': - return [37 => 1]; - case 'ExampleClassWithDependencyInjection.php': - return [ - 31 => 1, - 38 => 1, - ]; - case 'ExampleService.php': - return [ - 30 => 1, - 37 => 1, - ]; - default: - return []; + case 'TestForm.php': + return [ + 6 => 1, + 8 => 1, + ]; + case 'ExampleClass.php': + return [37 => 1]; + case 'ExampleClassWithDependencyInjection.php': + return [ + 31 => 1, + 38 => 1, + ]; + case 'ExampleService.php': + return [ + 30 => 1, + 37 => 1, + ]; + default: + return []; }//end switch - - }//end getWarningList() + } /** @@ -72,16 +70,13 @@ protected function getWarningList(string $testFile): array protected function getTestFiles($testFileBase): array { return [ - __DIR__.'/drupal8/DeclareT.php', - __DIR__.'/drupal8/example.module', - __DIR__.'/drupal8/ExampleClass.php', - __DIR__.'/drupal8/ExampleClassWithDependencyInjection.php', - __DIR__.'/drupal8/ExampleService.php', - __DIR__.'/drupal8/TestForm.php', - __DIR__.'/drupal7/ExampleMigration.php', + __DIR__ . '/drupal8/DeclareT.php', + __DIR__ . '/drupal8/example.module', + __DIR__ . '/drupal8/ExampleClass.php', + __DIR__ . '/drupal8/ExampleClassWithDependencyInjection.php', + __DIR__ . '/drupal8/ExampleService.php', + __DIR__ . '/drupal8/TestForm.php', + __DIR__ . '/drupal7/ExampleMigration.php', ]; - - }//end getTestFiles() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Objects/StrictSchemaDisabledUnitTest.php b/tests/DrupalPractice/Objects/StrictSchemaDisabledUnitTest.php index b86cee29..690c2b56 100644 --- a/tests/DrupalPractice/Objects/StrictSchemaDisabledUnitTest.php +++ b/tests/DrupalPractice/Objects/StrictSchemaDisabledUnitTest.php @@ -27,8 +27,7 @@ protected function getErrorList(string $testFile): array 29 => 1, 42 => 1, ]; - - }//end getErrorList() + } /** @@ -44,8 +43,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Objects/UnusedPrivateMethodUnitTest.php b/tests/DrupalPractice/Objects/UnusedPrivateMethodUnitTest.php index 5a068e0f..d9399721 100644 --- a/tests/DrupalPractice/Objects/UnusedPrivateMethodUnitTest.php +++ b/tests/DrupalPractice/Objects/UnusedPrivateMethodUnitTest.php @@ -21,8 +21,7 @@ class UnusedPrivateMethodUnitTest extends CoderSniffUnitTest protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -38,8 +37,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return [15 => 1]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/ProjectDetection/ProjectUnitTest.php b/tests/DrupalPractice/ProjectDetection/ProjectUnitTest.php index f1e61a73..585d74d3 100644 --- a/tests/DrupalPractice/ProjectDetection/ProjectUnitTest.php +++ b/tests/DrupalPractice/ProjectDetection/ProjectUnitTest.php @@ -29,8 +29,7 @@ public function setUp(): void $this->phpcsFile = $this->getMockBuilder('\PHP_CodeSniffer\Files\File') ->disableOriginalConstructor() ->getMock(); - - }//end setUp() + } /** @@ -42,11 +41,10 @@ public function testInfoFileDetection() { $this->phpcsFile->expects($this->any()) ->method('getFilename') - ->will($this->returnValue(__DIR__.'/drupal6/test.php')); - - $this->assertEquals(Project::getInfoFile($this->phpcsFile), __DIR__.'/drupal6/testmodule.info'); + ->will($this->returnValue(__DIR__ . '/drupal6/test.php')); - }//end testInfoFileDetection() + $this->assertEquals(Project::getInfoFile($this->phpcsFile), __DIR__ . '/drupal6/testmodule.info'); + } /** @@ -58,11 +56,10 @@ public function testInfoFileNestedDetection() { $this->phpcsFile->expects($this->any()) ->method('getFilename') - ->will($this->returnValue(__DIR__.'/drupal6/nested/test.php')); - - $this->assertEquals(Project::getInfoFile($this->phpcsFile), __DIR__.'/drupal6/testmodule.info'); + ->will($this->returnValue(__DIR__ . '/drupal6/nested/test.php')); - }//end testInfoFileNestedDetection() + $this->assertEquals(Project::getInfoFile($this->phpcsFile), __DIR__ . '/drupal6/testmodule.info'); + } /** @@ -82,8 +79,7 @@ public function testCoreVersion($filename, $coreVersion) ->will($this->returnValue($filename)); $this->assertEquals(Project::getCoreVersion($this->phpcsFile), $coreVersion); - - }//end testCoreVersion() + } /** @@ -95,15 +91,15 @@ public function coreVersionProvider(): array { return [ [ - __DIR__.'/drupal6/nested/test.php', + __DIR__ . '/drupal6/nested/test.php', 6, ], [ - __DIR__.'/drupal7/test.php', + __DIR__ . '/drupal7/test.php', 7, ], [ - __DIR__.'/drupal8/test.php', + __DIR__ . '/drupal8/test.php', 8, ], [ @@ -111,12 +107,11 @@ public function coreVersionProvider(): array 8, ], [ - __DIR__.'/directory.info/test.php', + __DIR__ . '/directory.info/test.php', 8, ], ]; - - }//end coreVersionProvider() + } /** @@ -136,8 +131,7 @@ public function testProjectNameDetection($filename, $projectname) ->will($this->returnValue($filename)); $this->assertEquals(Project::getName($this->phpcsFile), $projectname); - - }//end testProjectNameDetection() + } /** @@ -152,27 +146,27 @@ public function projectNameDetectionProvider(): array { return [ [ - __DIR__.'/drupal6/testmodule.info', + __DIR__ . '/drupal6/testmodule.info', 'testmodule', ], [ - __DIR__.'/drupal6/nested/test.php', + __DIR__ . '/drupal6/nested/test.php', 'testmodule', ], [ - __DIR__.'/drupal7/testmodule.info', + __DIR__ . '/drupal7/testmodule.info', 'testmodule', ], [ - __DIR__.'/drupal8/testmodule.info.yml', + __DIR__ . '/drupal8/testmodule.info.yml', 'testmodule', ], [ - __DIR__.'/drupal8/testtheme/testtheme.info.yml', + __DIR__ . '/drupal8/testtheme/testtheme.info.yml', 'testtheme', ], [ - __DIR__.'/drupal8/testtheme/testtheme.theme', + __DIR__ . '/drupal8/testtheme/testtheme.theme', 'testtheme', ], [ @@ -180,8 +174,5 @@ public function projectNameDetectionProvider(): array false, ], ]; - - }//end projectNameDetectionProvider() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Variables/GetRequestDataUnitTest.php b/tests/DrupalPractice/Variables/GetRequestDataUnitTest.php index 7d0798ff..7c01cbfd 100644 --- a/tests/DrupalPractice/Variables/GetRequestDataUnitTest.php +++ b/tests/DrupalPractice/Variables/GetRequestDataUnitTest.php @@ -32,8 +32,7 @@ protected function getErrorList(string $testFile): array 12 => 1, 13 => 1, ]; - - }//end getErrorList() + } /** @@ -49,8 +48,5 @@ protected function getErrorList(string $testFile): array protected function getWarningList(string $testFile): array { return []; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/Yaml/RoutingAccessUnitTest.php b/tests/DrupalPractice/Yaml/RoutingAccessUnitTest.php index ffc0eba9..0d14d6e8 100644 --- a/tests/DrupalPractice/Yaml/RoutingAccessUnitTest.php +++ b/tests/DrupalPractice/Yaml/RoutingAccessUnitTest.php @@ -17,9 +17,8 @@ class RoutingAccessUnitTest extends CoderSniffUnitTest */ protected function getTestFiles($testFileBase): array { - return [__DIR__.'/routing_access_test.routing.yml']; - - }//end getTestFiles() + return [__DIR__ . '/routing_access_test.routing.yml']; + } /** @@ -35,8 +34,7 @@ protected function getTestFiles($testFileBase): array protected function getErrorList(string $testFile): array { return []; - - }//end getErrorList() + } /** @@ -55,8 +53,5 @@ protected function getWarningList(string $testFile): array 7 => 1, 28 => 1, ]; - - }//end getWarningList() - - -}//end class + } +} diff --git a/tests/DrupalPractice/bad/BadUnitTest.php b/tests/DrupalPractice/bad/BadUnitTest.php index 17dbd2cc..56afa222 100644 --- a/tests/DrupalPractice/bad/BadUnitTest.php +++ b/tests/DrupalPractice/bad/BadUnitTest.php @@ -28,7 +28,7 @@ protected function getErrorList(string $testFile): array { return []; - }//end getErrorList() + } /** @@ -55,7 +55,7 @@ protected function getWarningList(string $testFile): array return []; - }//end getWarningList() + } /** @@ -81,7 +81,7 @@ protected function getTestFiles($testFileBase): array sort($testFiles); return $testFiles; - }//end getTestFiles() + } /** @@ -94,7 +94,7 @@ protected function checkAllSniffCodes() // We want to test all sniffs defined in the standard. return true; - }//end checkAllSniffCodes() + } -}//end class +} \ No newline at end of file diff --git a/tests/DrupalPractice/good/GoodUnitTest.php b/tests/DrupalPractice/good/GoodUnitTest.php index 3188ccb0..4afa41d6 100644 --- a/tests/DrupalPractice/good/GoodUnitTest.php +++ b/tests/DrupalPractice/good/GoodUnitTest.php @@ -28,7 +28,7 @@ protected function getErrorList(string $testFile): array { return []; - }//end getErrorList() + } /** @@ -45,7 +45,7 @@ protected function getWarningList(string $testFile): array { return []; - }//end getWarningList() + } /** @@ -59,7 +59,7 @@ protected function getTestFiles($testFileBase): array { return [__DIR__.'/good.php']; - }//end getTestFiles() + } /** @@ -72,7 +72,7 @@ protected function checkAllSniffCodes() // We want to test all sniffs defined in the standard. return true; - }//end checkAllSniffCodes() + } -}//end class +} \ No newline at end of file From acb6fc5fe49851b655e0dc29bdccdbb41d604564 Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sun, 23 Nov 2025 11:30:09 +0100 Subject: [PATCH 2/2] cspell --- phpcs.xml.dist | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 150a5f42..7d7fd556 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -75,7 +75,8 @@ - + bin/phpc(s|bf)$ requirements\.php$